Example #1
0
 def _zoomHistogramByFactor (self,factor):
   """Changes histogram limits by specified factor""";
   # get max distance of plot limit from peak
   dprint(1,"zooming histogram by",factor);
   halfdist = (self._hist_range[1] - self._hist_range[0])/(factor*2);
   self._updateHistogram(self._hist_peak-halfdist,self._hist_peak+halfdist);
   self._histplot.replot();
Example #2
0
 def show (self):
   dprint(4,"show entrypoint");
   if self._geometry:
     dprint(4,"setting geometry");
     self.setGeometry(self._geometry);
   if self._hist is None:
     busy = BusyIndicator();
     dprint(4,"updating histogram");
     self._updateHistogram();
     dprint(4,"updating stats");
     self._updateStats(self._subset,self._subset_range);
     busy = None;
   dprint(4,"calling QDialog.show");
   QDialog.show(self);
Example #3
0
 def _zoomHistogramFinalize (self,value=None,preview=False):
   if self._zooming_histogram:
     return;
   self._zooming_histogram = True;
   try:
     if value is not None:
       dmin,dmax = self._subset_range;
       dist = max(dmax-self._hist_peak,self._hist_peak-dmin)/10**value;
       self._preview_hist_range = max(self._hist_peak-dist,dmin),min(self._hist_peak+dist,dmax);
     if preview:
       self._histplot.setAxisScale(QwtPlot.xBottom,*self._preview_hist_range);
     else:
       dprint(2,"wheel finalized at",value);
       self._whistzoom_timer.stop();
       self._updateHistogram(*self._preview_hist_range);
     self._histplot.replot();
   finally:
     self._zooming_histogram = False;
Example #4
0
 def _changeDisplayRangeToPercent (self,percent):
   busy = BusyIndicator();
   if self._hist is None:
     self._updateHistogram();
     self._updateStats(self._subset,self._subset_range);
   # delta: we need the [delta,100-delta] interval of the total distribution
   delta = self._subset.size*((100.-percent)/200.);
   # get F(x): cumulative sum
   cumsum = numpy.zeros(len(self._hist_hires)+1,dtype=int);
   cumsum[1:] = numpy.cumsum(self._hist_hires);
   bins = numpy.zeros(len(self._hist_hires)+1,dtype=float);
   bins[0] = self._subset_range[0];
   bins[1:] = self._hist_bins_hires + self._hist_binsize_hires/2;
   # use interpolation to find value interval corresponding to [delta,100-delta] of the distribution
   dprint(2,self._subset.size,delta,self._subset.size-delta);
   dprint(2,cumsum,self._hist_bins_hires);
   # if first bin is already > delta, then set colour range to first bin
   x0,x1 = numpy.interp([delta,self._subset.size-delta],cumsum,bins);
   # and change the display range (this will also cause a histplot.replot() via _updateDisplayRange above)
   self._rc.setDisplayRange(x0,x1);
Example #5
0
 def _showMeanStd (self,busy=True):
   if busy:
     busy = BusyIndicator();
   dmin,dmax = self._subset_range;
   subset,mask = self.image.optimalRavel(self._subset);
   dprint(5,"computing mean");
   mean = measurements.mean(subset,labels=mask,index=None if mask is None else False);
   dprint(5,"computing std");
   std = measurements.standard_deviation(subset,labels=mask,index=None if mask is None else False);
   dprint(5,"done");
   text = "  ".join([ ("%s: "+DataValueFormat)%(name,value) for name,value in ("min",dmin),("max",dmax),("mean",mean),("std",std) ]+["np: %d"%self._subset.size]);
   self._wlab_stats.setText(text);
   self._wmore_stats.hide();
   # update markers
   ypos = 0.3;
   self._line_mean.line.setData([mean,mean],[0,1]);
   self._line_mean.marker.setValue(mean,ypos);
   self._line_mean.setText((u"\u03BC="+DataValueFormat)%mean);
   self._line_mean.show();
   self._line_std.line.setData([mean-std,mean+std],[ypos,ypos]);
   self._line_std.marker.setValue(mean,ypos);
   self._line_std.setText((u"\u03C3="+DataValueFormat)%std);
   self._line_std.show();
   self._histplot.replot();
Example #6
0
 def _zoomHistogramPreview (self,value):
   dprint(2,"wheel moved to",value);
   self._zoomHistogramFinalize(value,preview=True);
   self._whistzoom_timer.start();
Example #7
0
  def __init__ (self,parent,rc,imgman):
    """An ImageControlDialog is initialized with a parent widget, a RenderControl object,
    and an ImageManager object""";
    QDialog.__init__(self,parent);
    image = rc.image;
    self.setWindowTitle("%s: Colour Controls"%image.name);
    self.setWindowIcon(pixmaps.colours.icon());
    self.setModal(False);
    self.image = image;
    self._rc = rc;
    self._imgman = imgman;
    self._currier = PersistentCurrier();

    # init internal state
    self._prev_range = self._display_range = None,None;
    self._hist = None;
    self._geometry = None;

    # create layouts
    lo0 = QVBoxLayout(self);
#    lo0.setContentsMargins(0,0,0,0);

    # histogram plot
    whide = self.makeButton("Hide",self.hide,width=128);
    whide.setShortcut(Qt.Key_F9);
    lo0.addWidget(Separator(self,"Histogram and ITF",extra_widgets=[whide]));
    lo1 = QHBoxLayout();
    lo1.setContentsMargins(0,0,0,0);
    self._histplot = QwtPlot(self);
    self._histplot.setAutoDelete(False);
    lo1.addWidget(self._histplot,1);
    lo2 = QHBoxLayout();
    lo2.setContentsMargins(0,0,0,0);
    lo2.setSpacing(2);
    lo0.addLayout(lo2);
    lo0.addLayout(lo1);
    self._wautozoom = QCheckBox("autozoom",self);
    self._wautozoom.setChecked(True);
    self._wautozoom.setToolTip("""<P>If checked, then the histrogram plot will zoom in automatically when
      you narrow the current intensity range.</P>""");
    self._wlogy = QCheckBox("log Y",self);
    self._wlogy.setChecked(True);
    self._ylogscale = True;
    self._wlogy.setToolTip("""<P>If checked, a log-scale Y axis is used for the histogram plot instead of a linear one.""");
    QObject.connect(self._wlogy,SIGNAL("toggled(bool)"),self._setHistLogScale);
    self._whistunzoom  = self.makeButton("",self._unzoomHistogram,icon=pixmaps.full_range.icon());
    self._whistzoomout = self.makeButton("-",self._currier.curry(self._zoomHistogramByFactor,math.sqrt(.1)));
    self._whistzoomin  = self.makeButton("+",self._currier.curry(self._zoomHistogramByFactor,math.sqrt(10)));
    self._whistzoomin.setToolTip("""<P>Click to zoom into the histogram plot by one step. This does not
      change the current intensity range.</P>""");
    self._whistzoomout.setToolTip("""<P>Click to zoom out of the histogram plot by one step. This does not
      change the current intensity range.</P>""");
    self._whistunzoom.setToolTip("""<P>Click to reset the histogram plot back to its full extent.
      This does not change the current intensity range.</P>""");
    self._whistzoom = QwtWheel(self);
    self._whistzoom.setOrientation(Qt.Horizontal);
    self._whistzoom.setMaximumWidth(80);
    self._whistzoom.setRange(10,0);
    self._whistzoom.setStep(0.1);
    self._whistzoom.setTickCnt(30);
    self._whistzoom.setTracking(False);
    QObject.connect(self._whistzoom,SIGNAL("valueChanged(double)"),self._zoomHistogramFinalize);
    QObject.connect(self._whistzoom,SIGNAL("sliderMoved(double)"),self._zoomHistogramPreview);
    self._whistzoom.setToolTip("""<P>Use this wheel control to zoom in/out of the histogram plot.
      This does not change the current intensity range.
      Note that the zoom wheel should also respond to your mouse wheel, if you have one.</P>""");
    # This works around a stupid bug in QwtSliders -- when using the mousewheel, only sliderMoved() signals are emitted,
    # with no final  valueChanged(). If we want to do a fast preview of something on sliderMoved(), and a "slow" final
    # step on valueChanged(), we're in trouble. So we start a timer on sliderMoved(), and if the timer expires without
    # anything else happening, do a valueChanged().
    # Here we use a timer to call zoomHistogramFinalize() w/o an argument.
    self._whistzoom_timer = QTimer(self);
    self._whistzoom_timer.setSingleShot(True);
    self._whistzoom_timer.setInterval(500);
    QObject.connect(self._whistzoom_timer,SIGNAL("timeout()"),self._zoomHistogramFinalize);
    # set same size for all buttons and controls
    width = 24;
    for w in self._whistunzoom,self._whistzoomin,self._whistzoomout:
      w.setMinimumSize(width,width);
      w.setMaximumSize(width,width);
    self._whistzoom.setMinimumSize(80,width);
    self._wlab_histpos_text = "(hover here for help)";
    self._wlab_histpos = QLabel(self._wlab_histpos_text,self);
    self._wlab_histpos.setToolTip("""
      <P>The plot shows a histogram of either the full image or its selected subset
      (as per the "Data subset" section below).</P>
      <P>The current intensity range is indicated by the grey box
      in the plot.</P>
      <P>Use the left mouse button to change the low intensity limit, and the right
      button (on Macs, use Ctrl-click) to change the high limit.</P>
      <P>Use Shift with the left mouse button to zoom into an area of the histogram,
      or else use the "zoom wheel" control or the plus/minus toolbuttons above the histogram to zoom in or out.
      To zoom back out to the full extent of the histogram, click on the rightmost button above the histogram.</P>
      """);
    lo2.addWidget(self._wlab_histpos,1);
    lo2.addWidget(self._wautozoom);
    lo2.addWidget(self._wlogy,0);
    lo2.addWidget(self._whistzoomin,0);
    lo2.addWidget(self._whistzoom,0);
    lo2.addWidget(self._whistzoomout,0);
    lo2.addWidget(self._whistunzoom,0);
    self._zooming_histogram = False;

    sliced_axes = rc.slicedAxes();
    dprint(1,"sliced axes are",sliced_axes);
    self._stokes_axis = None;

    # subset indication
    lo0.addWidget(Separator(self,"Data subset"));
    # sliced axis selectors
    self._wslicers = [];
    if sliced_axes:
      lo1 = QHBoxLayout();
      lo1.setContentsMargins(0,0,0,0);
      lo1.setSpacing(2);
      lo0.addLayout(lo1);
      lo1.addWidget(QLabel("Current slice:  ",self));
      for i,(iextra,name,labels) in enumerate(sliced_axes):
        lo1.addWidget(QLabel("%s:"%name,self));
        if name == "STOKES":
          self._stokes_axis = iextra;
        # add controls
        wslicer = QComboBox(self);
        self._wslicers.append(wslicer);
        wslicer.addItems(labels);
        wslicer.setToolTip("""<P>Selects current slice along the %s axis.</P>"""%name);
        wslicer.setCurrentIndex(self._rc.currentSlice()[iextra]);
        QObject.connect(wslicer,SIGNAL("activated(int)"),self._currier.curry(self._rc.changeSlice,iextra));
        lo2 = QVBoxLayout();
        lo1.addLayout(lo2);
        lo2.setContentsMargins(0,0,0,0);
        lo2.setSpacing(0);
        wminus = QToolButton(self);
        wminus.setArrowType(Qt.UpArrow);
        QObject.connect(wminus,SIGNAL("clicked()"),self._currier.curry(self._rc.incrementSlice,iextra,1));
        if i == 0:
          wminus.setShortcut(Qt.SHIFT+Qt.Key_F7);
        elif i == 1:
          wminus.setShortcut(Qt.SHIFT+Qt.Key_F8);
        wplus = QToolButton(self);
        wplus.setArrowType(Qt.DownArrow);
        QObject.connect(wplus,SIGNAL("clicked()"),self._currier.curry(self._rc.incrementSlice,iextra,-1));
        if i == 0:
          wplus.setShortcut(Qt.Key_F7);
        elif i == 1:
          wplus.setShortcut(Qt.Key_F8);
        wminus.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Fixed);
        wplus.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Fixed);
        sz = QSize(12,8);
        wminus.setMinimumSize(sz);
        wplus.setMinimumSize(sz);
        wminus.resize(sz);
        wplus.resize(sz);
        lo2.addWidget(wminus);
        lo2.addWidget(wplus);
        lo1.addWidget(wslicer);
        lo1.addSpacing(5);
      lo1.addStretch(1);
    # subset indicator
    lo1 = QHBoxLayout();
    lo1.setContentsMargins(0,0,0,0);
    lo1.setSpacing(2);
    lo0.addLayout(lo1);
    self._wlab_subset = QLabel("Subset: xxx",self);
    self._wlab_subset.setToolTip("""<P>This indicates the current data subset to which the histogram
      and the stats given here apply. Use the "Reset to" control on the right to change the
      current subset and recompute the histogram and stats.</P>""");
    lo1.addWidget(self._wlab_subset,1);

    self._wreset_full = self.makeButton(u"\u2192 full",self._rc.setFullSubset);
    lo1.addWidget(self._wreset_full);
    if sliced_axes:
#      if self._stokes_axis is not None and len(sliced_axes)>1:
#        self._wreset_stokes = self.makeButton(u"\u21920Stokes",self._rc.setFullSubset);
      self._wreset_slice = self.makeButton(u"\u2192 slice",self._rc.setSliceSubset);
      lo1.addWidget(self._wreset_slice);
    else:
      self._wreset_slice = None;

    # min/max controls
    lo1 = QHBoxLayout();
    lo1.setContentsMargins(0,0,0,0);
    lo0.addLayout(lo1,0);
    self._wlab_stats = QLabel(self);
    lo1.addWidget(self._wlab_stats,0);
    self._wmore_stats = self.makeButton("more...",self._showMeanStd);
    self._wlab_stats.setMinimumHeight(self._wmore_stats.height());
    lo1.addWidget(self._wmore_stats,0);
    lo1.addStretch(1);

    # intensity controls
    lo0.addWidget(Separator(self,"Intensity mapping"));
    lo1 = QHBoxLayout();
    lo1.setContentsMargins(0,0,0,0);
    lo1.setSpacing(2);
    lo0.addLayout(lo1,0);
    self._range_validator = FloatValidator(self);
    self._wrange = QLineEdit(self),QLineEdit(self);
    self._wrange[0].setToolTip("""<P>This is the low end of the intensity range.</P>""");
    self._wrange[1].setToolTip("""<P>This is the high end of the intensity range.</P>""");
    for w in self._wrange:
      w.setValidator(self._range_validator);
      QObject.connect(w,SIGNAL("editingFinished()"),self._changeDisplayRange);
    lo1.addWidget(QLabel("low:",self),0);
    lo1.addWidget(self._wrange[0],1);
    self._wrangeleft0 = self.makeButton(u"\u21920",self._setZeroLeftLimit,width=32);
    self._wrangeleft0.setToolTip("""<P>Click this to set the low end of the intensity range to 0.</P>""");
    lo1.addWidget(self._wrangeleft0,0);
    lo1.addSpacing(8);
    lo1.addWidget(QLabel("high:",self),0);
    lo1.addWidget(self._wrange[1],1);
    lo1.addSpacing(8);
    self._wrange_full = self.makeButton(None,self._setHistDisplayRange,icon=pixmaps.intensity_graph.icon());
    lo1.addWidget(self._wrange_full);
    self._wrange_full.setToolTip("""<P>Click this to reset the intensity range to the current extent of the histogram plot.</P>""");
    # add menu for display range
    range_menu = QMenu(self);
    wrange_menu = QToolButton(self);
    wrange_menu.setText("Reset to");
    wrange_menu.setToolTip("""<P>Use this to reset the intensity range to various pre-defined settings.</P>""");
    lo1.addWidget(wrange_menu);
    self._qa_range_full = range_menu.addAction(pixmaps.full_range.icon(),"Full subset",self._rc.resetSubsetDisplayRange);
    self._qa_range_hist = range_menu.addAction(pixmaps.intensity_graph.icon(),"Current histogram limits",self._setHistDisplayRange);
    for percent in (99.99,99.9,99.5,99,98,95):
      range_menu.addAction("%g%%"%percent,self._currier.curry(self._changeDisplayRangeToPercent,percent));
    wrange_menu.setMenu(range_menu);
    wrange_menu.setPopupMode(QToolButton.InstantPopup);

    lo1 = QGridLayout();
    lo1.setContentsMargins(0,0,0,0);
    lo0.addLayout(lo1,0);
    self._wimap = QComboBox(self);
    lo1.addWidget(QLabel("Intensity policy:",self),0,0);
    lo1.addWidget(self._wimap,1,0);
    self._wimap.addItems(rc.getIntensityMapNames());
    QObject.connect(self._wimap,SIGNAL("currentIndexChanged(int)"),self._rc.setIntensityMapNumber);
    self._wimap.setToolTip("""<P>Use this to change the type of the intensity transfer function (ITF).</P>""");

    # log cycles control
    lo1.setColumnStretch(1,1);
    self._wlogcycles_label = QLabel("Log cycles: ",self);
    lo1.addWidget(self._wlogcycles_label,0,1);
#    self._wlogcycles = QwtWheel(self);
#    self._wlogcycles.setTotalAngle(360);
    self._wlogcycles = QwtSlider(self);
    self._wlogcycles.setToolTip("""<P>Use this to change the log-base for the logarithmic intensity transfer function (ITF).</P>""");
    # This works around a stupid bug in QwtSliders -- see comments on histogram zoom wheel above
    self._wlogcycles_timer = QTimer(self);
    self._wlogcycles_timer.setSingleShot(True);
    self._wlogcycles_timer.setInterval(500);
    QObject.connect(self._wlogcycles_timer,SIGNAL("timeout()"),self._setIntensityLogCycles);
    lo1.addWidget(self._wlogcycles,1,1);
    self._wlogcycles.setRange(1.,10);
    self._wlogcycles.setStep(0.1);
    self._wlogcycles.setTracking(False);
    QObject.connect(self._wlogcycles,SIGNAL("valueChanged(double)"),self._setIntensityLogCycles);
    QObject.connect(self._wlogcycles,SIGNAL("sliderMoved(double)"),self._previewIntensityLogCycles);
    self._updating_imap = False;

    # lock intensity map
    lo1 = QHBoxLayout();
    lo1.setContentsMargins(0,0,0,0);
    lo0.addLayout(lo1,0);
#    lo1.addWidget(QLabel("Lock range accross",self));
    wlock = QCheckBox("Lock display range",self);
    wlock.setToolTip("""<P>If checked, then the intensity range will be locked. The ranges of all locked images
      change simultaneously.</P>""");
    lo1.addWidget(wlock);
    wlockall = QToolButton(self);
    wlockall.setIcon(pixmaps.locked.icon());
    wlockall.setText("Lock all to this");
    wlockall.setToolButtonStyle(Qt.ToolButtonTextBesideIcon);
    wlockall.setAutoRaise(True);
    wlockall.setToolTip("""<P>Click this to lock together the intensity ranges of all images.</P>""");
    lo1.addWidget(wlockall);
    wunlockall = QToolButton(self);
    wunlockall.setIcon(pixmaps.unlocked.icon());
    wunlockall.setText("Unlock all");
    wunlockall.setToolButtonStyle(Qt.ToolButtonTextBesideIcon);
    wunlockall.setAutoRaise(True);
    wunlockall.setToolTip("""<P>Click this to unlock the intensity ranges of all images.</P>""");
    lo1.addWidget(wunlockall);
    wlock.setChecked(self._rc.isDisplayRangeLocked());
    QObject.connect(wlock,SIGNAL("clicked(bool)"),self._rc.lockDisplayRange);
    QObject.connect(wlockall,SIGNAL("clicked()"),self._currier.curry(self._imgman.lockAllDisplayRanges,self._rc));
    QObject.connect(wunlockall,SIGNAL("clicked()"),self._imgman.unlockAllDisplayRanges);
    QObject.connect(self._rc,SIGNAL("displayRangeLocked"),wlock.setChecked);

#    self._wlock_imap_axis = [ QCheckBox(name,self) for iaxis,name,labels in sliced_axes ];
#    for iw,w in enumerate(self._wlock_imap_axis):
#      QObject.connect(w,SIGNAL("toggled(bool)"),self._currier.curry(self._rc.lockDisplayRangeForAxis,iw));
#      lo1.addWidget(w,0);
    lo1.addStretch(1);

    # lo0.addWidget(Separator(self,"Colourmap"));
    # color bar
    self._colorbar = QwtPlot(self);
    lo0.addWidget(self._colorbar);
    self._colorbar.setAutoDelete(False);
    self._colorbar.setMinimumHeight(32);
    self._colorbar.enableAxis(QwtPlot.yLeft,False);
    self._colorbar.enableAxis(QwtPlot.xBottom,False);
    # color plot
    self._colorplot = QwtPlot(self);
    lo0.addWidget(self._colorplot);
    self._colorplot.setAutoDelete(False);
    self._colorplot.setMinimumHeight(64);
    self._colorplot.enableAxis(QwtPlot.yLeft,False);
    self._colorplot.enableAxis(QwtPlot.xBottom,False);
    # self._colorplot.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Preferred);
    self._colorbar.hide();
    self._colorplot.hide();
    # color controls
    lo1 = QHBoxLayout();
    lo1.setContentsMargins(0,0,0,0);
    lo0.addLayout(lo1,1);
    lo1.addWidget(QLabel("Colourmap:",self));
    # colormap list
    ### NB: use setIconSize() and icons in QComboBox!!!
    self._wcolmaps = QComboBox(self);
    self._wcolmaps.setIconSize(QSize(128,16));
    self._wcolmaps.setToolTip("""<P>Use this to select a different colourmap.</P>""");
    for cmap in self._rc.getColormapList():
      self._wcolmaps.addItem(QIcon(cmap.makeQPixmap(128,16)),cmap.name);
    lo1.addWidget(self._wcolmaps);
    QObject.connect(self._wcolmaps,SIGNAL("activated(int)"),self._rc.setColorMapNumber);
    # add widgetstack for colormap controls
    self._wcolmap_control_stack = QStackedWidget(self);
    self._wcolmap_control_blank = QWidget(self._wcolmap_control_stack);
    self._wcolmap_control_stack.addWidget(self._wcolmap_control_blank);
    lo0.addWidget(self._wcolmap_control_stack);
    self._colmap_controls = [];
    # add controls to stack
    for index,cmap in enumerate(self._rc.getColormapList()):
      if isinstance(cmap,Colormaps.ColormapWithControls):
        controls = cmap.makeControlWidgets(self._wcolmap_control_stack);
        self._wcolmap_control_stack.addWidget(controls);
        QObject.connect(cmap,SIGNAL("colormapChanged"),
            self._currier.curry(self._previewColormapParameters,index,cmap));
        QObject.connect(cmap,SIGNAL("colormapPreviewed"),
            self._currier.curry(self._previewColormapParameters,index,cmap));
        self._colmap_controls.append(controls);
      else:
        self._colmap_controls.append(self._wcolmap_control_blank);

    # connect updates from renderControl and image
    self.image.connect(SIGNAL("slice"),self._updateImageSlice);
    QObject.connect(self._rc,SIGNAL("intensityMapChanged"),self._updateIntensityMap);
    QObject.connect(self._rc,SIGNAL("colorMapChanged"),self._updateColorMap);
    QObject.connect(self._rc,SIGNAL("dataSubsetChanged"),self._updateDataSubset);
    QObject.connect(self._rc,SIGNAL("displayRangeChanged"),self._updateDisplayRange);

    # update widgets
    self._setupHistogramPlot();
    self._updateDataSubset(*self._rc.currentSubset());
    self._updateColorMap(image.colorMap());
    self._updateIntensityMap(rc.currentIntensityMap(),rc.currentIntensityMapNumber());
    self._updateDisplayRange(*self._rc.displayRange());
Example #8
0
 def _updateHistogram (self,hmin=None,hmax=None):
   """Recomputes histogram. If no arguments, computes full histogram for
   data subset. If hmin/hmax is specified, computes zoomed-in histogram.""";
   busy = BusyIndicator();
   self._prev_range = self._display_range;
   dmin,dmax = self._subset_range;
   hmin0,hmax0 = dmin,dmax;
   if hmin0 >= hmax0:
     hmax0 = hmin0+1;
   subset,mask = self.image.optimalRavel(self._subset);
   # compute full-subset hi-res histogram, if we don't have one (for percentile stats)
   if self._hist_hires is None:
     dprint(1,"computing histogram for full subset range",hmin0,hmax0);
     self._hist_hires = measurements.histogram(subset,hmin0,hmax0,self.NumHistBinsHi,labels=mask,index=None if mask is None else False);
     self._hist_bins_hires = hmin0 + (hmax0-hmin0)*(numpy.arange(self.NumHistBinsHi)+0.5)/float(self.NumHistBinsHi);
     self._hist_binsize_hires =  (hmax0-hmin0)/self.NumHistBins;
   # if hist limits not specified, then compute lo-res histogram based on the hi-res one
   if hmin is None:
     hmin,hmax = hmin0,hmax0;
     # downsample to low-res histogram
     self._hist = self._hist_hires.reshape((self.NumHistBins,self.NumHistBinsHi/self.NumHistBins)).sum(1);
   else:
     # zoomed-in low-res histogram
     # bracket limits at subset range
     hmin,hmax = max(hmin,dmin),min(hmax,dmax);
     if hmin >= hmax:
       hmax = hmin+1;
     dprint(1,"computing histogram for",self._subset.shape,self._subset.dtype,hmin,hmax);
     self._hist = measurements.histogram(subset,hmin,hmax,self.NumHistBins,labels=mask,index=None if mask is None else False);
   dprint(1,"histogram computed");
   # compute bins
   self._itf_bins = hmin + (hmax-hmin)*(numpy.arange(self.NumItfBins))/(float(self.NumItfBins)-1);
   self._hist_bins = hmin + (hmax-hmin)*(numpy.arange(self.NumHistBins)+0.5)/float(self.NumHistBins);
   # histogram range and position of peak
   self._hist_range = hmin,hmax;
   self._hist_min,self._hist_max,self._hist_imin,self._hist_imax = measurements.extrema(self._hist);
   self._hist_peak = self._hist_bins[self._hist_imax];
   # set controls accordingly
   if dmin >= dmax:
     dmax = dmin+1;
   zoom = math.log10((dmax-dmin)/(hmax-hmin));
   self._whistzoom.setValue(zoom);
   self._whistunzoom.setEnabled(zoom>0);
   self._whistzoomout.setEnabled(zoom>0);
   # reset scales
   self._histplot.setAxisScale(QwtPlot.xBottom,hmin,hmax);
   self._histplot.setAxisScale(QwtPlot.yRight,0,1+self.ColorBarHeight);
   # update curves
   # call _setHistLogScale() (with current setting) to update axis scales and set data
   self._setHistLogScale(self._ylogscale,replot=False);
   # set plot lines
   self._line_0.line.setData([0,0],[0,1]);
   self._line_0.marker.setValue(0,0);
   self._line_maxbin.line.setData([self._hist_peak,self._hist_peak],[0,1]);
   self._line_maxbin.marker.setValue(self._hist_peak,0);
   self._line_maxbin.setText(("max bin:"+DataValueFormat)%self._hist_peak);
   # set half-max line
   self._line_halfmax.line.setData(self._hist_range,[self._hist_max/2,self._hist_max/2]);
   self._line_halfmax.marker.setValue(hmin,self._hist_max/2);
   # update ITF
   self._updateITF();