Beispiel #1
0
void callGraphDisplay::resize(bool currentlyDisplayedAbstraction) {
  const int newWindowWidth = Tk_Width(consts.theTkWindow);
  //   const int newWindowHeight = Tk_Height(consts.theTkWindow); [not used]

  consts.resize(); // reallocates offscreen pixmap; rethinks
                   //listboxHeightWhereSBappears'
  
  // Loop through EVERY listbox (gasp) and rethink whether or not it needs
  // a scrollbar and (possibly) change listBoxActualHeight...
  // _Must_ go _after_ the consts.resize()
  (void)rootPtr->rethinkListboxAfterResize(consts);
  
  // Now the more conventional resize code:
  rootPtr->rethinkAfterResize(consts, newWindowWidth);
  rethink_nominal_centerx(); 
  // must go _after_ the rootPtr->rethinkAfterResize()
  
  if (currentlyDisplayedAbstraction) {
    // We have changed axis width and/or height.  Let's inform tcl, so it may
    // rethink the scrollbar ranges.
    resizeScrollbars();
    
    // Now, let's update our own stored horiz & vert scrollbar offset values
    adjustHorizSBOffset(); // obtain FirstPix from the actual tk scrollbar
    adjustVertSBOffset (); // obtain FirstPix from the actual tk scrollbar
  }
}
Beispiel #2
0
void callGraphDisplay::rethinkEntireLayout(){
  rootPtr->recursiveDoneAddingChildren(consts, false); 
  // false --> don't resort
  rethink_nominal_centerx();
  resizeScrollbars();
  adjustHorizSBOffset();
  adjustVertSBOffset();
}
Beispiel #3
0
bool callGraphDisplay::forciblyScrollToEndOfPath(const whereNodePosRawPath &thePath) {
   // Forcibly expands path items as needed, then calls softScrollToEndOfPath()
   const bool anyChanges = rootPtr->expandEntirePath(consts, thePath, 0);
   if (anyChanges) {
      rethink_nominal_centerx();
      resizeScrollbars();
      adjustHorizSBOffset();
      adjustVertSBOffset();
   }

   softScrollToEndOfPath(thePath);

   return anyChanges;
}
Beispiel #4
0
  /**
   * Change the box line size.
   *
   */
  void StatisticsTool::changeBoxLines() {
    QString lines = p_linesEdit->text();
    if(lines != "" && lines.toInt() != p_boxLines && lines.toInt() > 0) {
      p_boxLines = lines.toInt();
      QString samps;
      samps.setNum(p_boxSamps);
      p_boxLabel->setText(samps + "x" + lines);

      p_visualDisplay->setLines(p_boxLines);

      p_set = false;

      resizeScrollbars();
    }
  }
Beispiel #5
0
bool callGraphDisplay::processDoubleClick(int x, int y) {
  // returns true iff a complete redraw is called for
  
  bool scrollToWhenDone = false; // for now...
  
  whereNodeGraphicalPath<callGraphRootNode> thePath = point2path(x, y);
  
   switch (thePath.whatDoesPathEndIn()) {
      case whereNodeGraphicalPath<callGraphRootNode>::Nothing:
	return false;
      case whereNodeGraphicalPath<callGraphRootNode>::ListboxScrollbarUpArrow:
      case whereNodeGraphicalPath<callGraphRootNode>::ListboxScrollbarDownArrow:
      case whereNodeGraphicalPath<callGraphRootNode>::ListboxScrollbarPageup:
      case whereNodeGraphicalPath<callGraphRootNode>::ListboxScrollbarPagedown:
         // in this case, do the same as a single-click
         processNonSliderButtonPress(thePath);
         return false; // no need to redraw further
      case whereNodeGraphicalPath<callGraphRootNode>::ListboxScrollbarSlider:
         return false;
      case whereNodeGraphicalPath<callGraphRootNode>::ExpandedNode: {
         // double-click in a "regular" node (not in listbox): un-expand
         if (thePath.getSize() == 0) {
            return false;
         }

         if (!rootPtr->path2lbItemUnexpand(consts, thePath.getPath(), 0)) {
            // probably an attempt to expand a leaf item (w/o a triangle next to it)
            return false;
         }

         // Now let's scroll to the un-expanded item.
         rethink_nominal_centerx();
         resizeScrollbars();
         adjustHorizSBOffset();
         adjustVertSBOffset();
         softScrollToEndOfPath(thePath.getPath());

    	 where4tree<callGraphRootNode> *ptr = thePath.getLastPathNode(rootPtr);
    	 bool ishighlight=ptr->isHighlighted();
    	 map_to_WhereAxis(ptr->getNodeData().getUniqueId(),ishighlight);

         return true;
      }
      case whereNodeGraphicalPath<callGraphRootNode>::ListboxItem: {
         // double-click in a listbox item
         // first thing's first: now that we know the user 
	 //intended to do a double-click
         // all along, we should undo the effects of the 
	 //single-click which came earlier.
         thePath.getLastPathNode(rootPtr)->toggle_highlight(); 

    	 where4tree<callGraphRootNode> *ptr = thePath.getLastPathNode(rootPtr);
    	 bool ishighlight=ptr->isHighlighted();
    	 map_to_WhereAxis(ptr->getNodeData().getUniqueId(),ishighlight);

	 // doesn't redraw

         const bool anyChanges = rootPtr->path2lbItemExpand(consts,
							  thePath.getPath(),0);

         if (!anyChanges) {
            // The only real change we made was the toggle_highlight(). This is
            // a case where we can do the redrawing ourselves (and fast).
            thePath.getParentOfLastPathNode(rootPtr)->
	      draw(consts.theTkWindow, consts, Tk_WindowId(consts.theTkWindow),
		   thePath.get_endpath_centerx(),
		   thePath.get_endpath_topy(),
		   false, // not root only
		   true // listbox only
		   );
            return false;
         }
         else {
	   // expansion was successful...later, we'll scroll to the 
	   // expanded item.
	   // NOTE: rootPtr->path2lbItemExpand will have modified "thePath"
	   //       for us (by changing the last item from a listbox item to
	   //       an expanded one, which is the proper thing to do).

            scrollToWhenDone = true;
         }
         break;
      }
   default:
     assert(false);
   }
   
   // expansion or un-expansion successful
   
   rethink_nominal_centerx();
   
   // We have changed axis width and/or height.  Let's inform tcl, so it may
   // rethink the scrollbar ranges.
   resizeScrollbars();

   // Now, let's update our own stored horiz & vert scrollbar offset values
   adjustHorizSBOffset(); // obtain FirstPix from the actual tk scrollbar
   adjustVertSBOffset (); // obtain FirstPix from the actual tk scrollbar
   
   if (scrollToWhenDone) {
     const int overallWindowBorderPix = 0;

     whereNodeGraphicalPath<callGraphRootNode>
	   path_to_scroll_to(thePath.getPath(),
			     consts, rootPtr,
			     nominal_centerx,
		    // root centerx (abs. pos., regardless of sb [intentional])
			overallWindowBorderPix
                    // topy of root (abs. pos., regardless of sb [intentional])
			     );

     int newlyExpandedElemCenterX = path_to_scroll_to.get_endpath_centerx();
     int newlyExpandedElemTopY    = path_to_scroll_to.get_endpath_topy();
     int newlyExpandedElemMiddleY = newlyExpandedElemTopY +
       path_to_scroll_to.getLastPathNode(rootPtr)->getNodeData().getHeightAsRoot() / 2;
     
     (void)set_scrollbars(newlyExpandedElemCenterX, x,
			  newlyExpandedElemMiddleY, y,
			  true);
   }

   return true;
}
Beispiel #6
0
bool callGraphDisplay::processShiftDoubleClick(int x, int y) {
   // returns true iff a complete redraw is called for

   whereNodeGraphicalPath<callGraphRootNode> thePath = point2path(x, y);

   switch (thePath.whatDoesPathEndIn()) {
      case whereNodeGraphicalPath<callGraphRootNode>::Nothing:
        return false;
      case whereNodeGraphicalPath<callGraphRootNode>::ListboxItem:
        return false;
      case whereNodeGraphicalPath<callGraphRootNode>::ExpandedNode:
	break; // some breathing room for lots of code to follow...
      case whereNodeGraphicalPath<callGraphRootNode>::ListboxScrollbarUpArrow:
      case whereNodeGraphicalPath<callGraphRootNode>::ListboxScrollbarDownArrow:
      case whereNodeGraphicalPath<callGraphRootNode>::ListboxScrollbarPageup:
      case whereNodeGraphicalPath<callGraphRootNode>::ListboxScrollbarPagedown:
     // in this case, do the same as a single-click
        processNonSliderButtonPress(thePath);
        return false; // no need to redraw further
      case whereNodeGraphicalPath<callGraphRootNode>::ListboxScrollbarSlider:
	return false;
      default:
        assert(false);
   }

   // How do we know whether to expand-all or un-expand all?
   // Well, if there is no listbox up, then we should _definitely_ unexpand.
   // And, if there is a listbox up containing all items 
   // (no explicitly expanded items), then we should _definitely_ expand.
   // But, if there is a listbox up with _some_ explicitly expanded items, 
   // then are we supposed to expand out the remaining ones; or un-expand 
   // the expanded ones?  It could go either way.  For now, we'll say 
   // that we should un-expand.

   bool anyChanges = false; // so far...
   where4tree<callGraphRootNode> *ptr = thePath.getLastPathNode(rootPtr);
   ptr->toggle_highlight(); // doesn't redraw

   if (ptr->getListboxPixWidth() > 0) {
      bool noExplicitlyExpandedChildren = true; // so far...
      for (unsigned childlcv=0; childlcv < ptr->getNumChildren(); childlcv++)
         if (ptr->getChildIsExpandedFlag(childlcv)) {
            noExplicitlyExpandedChildren = false; 
            break;
         }

      if (noExplicitlyExpandedChildren)
         // There is a listbox up, and it contains ALL children.
         // So, obviously, we want to expand them all...
         anyChanges = rootPtr->path2ExpandAllChildren(consts, 
						      thePath.getPath(), 0);
      else
         // There is a listbox up, but there are also some expanded children.
         // This call (whether to expand the remaining listbox items, or whether
         // to un-expand the expanded items) could go either way; we choose the
         // latter (for now, at least)
         anyChanges = rootPtr->path2UnExpandAllChildren(consts, 
							thePath.getPath(), 0);
   }
   else
     // No listbox is up; hence, all children are expanded.
     // So obviously, we wish to un-expand all the children.
     anyChanges = rootPtr->path2UnExpandAllChildren(consts, thePath.getPath(), 0);
   
   if (!anyChanges)
     return false;
   
   rethink_nominal_centerx();

   // We have changed axis width and/or height.  Let's inform tcl, so it may
   // rethink the scrollbar ranges.
   resizeScrollbars();

   // Now, let's update our own stored horiz & vert scrollbar offset values
   adjustHorizSBOffset(); // obtain FirstPix from the actual tk scrollbar
   adjustVertSBOffset (); // obtain FirstPix from the actual tk scrollbar

   return true;
}
Beispiel #7
0
  /**
   * Retrieve the statistics based on the box size
   * and point on the cube.
   *
   * @param p
   */
  void StatisticsTool::getStatistics(QPoint p) {
    MdiCubeViewport *cvp = cubeViewport();
    if(cvp == NULL) return;

    double sample, line;
    cvp->viewportToCube(p.x(), p.y(), sample, line);

    // If we are outside of the cube, do nothing
    if((sample < 0.5) || (line < 0.5) ||
        (sample > cvp->cubeSamples() + 0.5) || (line > cvp->cubeLines() + 0.5)) {
      return;
    }

    int isamp = (int)(sample + 0.5);
    int iline = (int)(line + 0.5);

    Statistics stats;
    Brick *brick = new Brick(1, 1, 1, cvp->cube()->pixelType());


    QVector<QVector<double> > pixelData(p_boxLines, QVector<double>(p_boxSamps, Null));

    double lineDiff = p_boxLines / 2.0;
    double sampDiff = p_boxSamps / 2.0;

    p_ulSamp = isamp - (int)floor(sampDiff);
    p_ulLine = iline - (int)floor(lineDiff);

    int x, y;

    y = p_ulLine;

    for(int i = 0; i < p_boxLines; i++) {
      x = p_ulSamp;
      if(y < 1 || y > cvp->cubeLines()) {
        y++;
        continue;
      }
      for(int j = 0; j < p_boxSamps; j++) {
        if(x < 1 || x > cvp->cubeSamples()) {
          x++;
          continue;
        }
        brick->SetBasePosition(x, y, cvp->grayBand());
        cvp->cube()->read(*brick);
        stats.AddData(brick->at(0));
        pixelData[i][j] = brick->at(0);

        x++;
      }
      y++;
    }

    p_visualDisplay->setPixelData(pixelData, p_ulSamp, p_ulLine);

    if (stats.ValidPixels()) {
      p_minLabel->setText(QString("Minimum: %1").arg(stats.Minimum()));
      p_maxLabel->setText(QString("Maximum: %1").arg(stats.Maximum()));
      p_avgLabel->setText(QString("Average: %1").arg(stats.Average()));
      p_stdevLabel->setText(QString("Standard Dev: %1").arg(stats.StandardDeviation(), 0, 'f', 6));
    }
    else {
      p_minLabel->setText(QString("Minimum: n/a"));
      p_maxLabel->setText(QString("Maximum: n/a"));
      p_avgLabel->setText(QString("Average: n/a"));
      p_stdevLabel->setText(QString("Standard Dev: n/a"));
    }

    p_set = true;

    resizeScrollbars();
  }
Beispiel #8
0
Viewport::Viewport(int scale, int autoUpdateInterval, bool openGL, QWidget *parent) : QWidget(parent)
{
	// Init
	this->scale = scale;
	sliderZoom = NULL;
	maps = new QList<Map*>();
	mapMetas = new QList<MapMeta*>();
	antiAlias = true;
	selectedAction = NULL;
	timerAutoUpdate = new QTimer();
	timerAutoUpdate->setInterval(autoUpdateInterval);
	this->setAttribute(Qt::WA_DeleteOnClose, true);
	this->setWindowIcon(QIcon(":eye"));
	this->setWindowTitle("emss Viewport");
	maxMapWidth = 0.0;
	maxMapHeight = 0.0;

	// Toolbar
	this->setLayout(new QVBoxLayout());
	this->layout()->setContentsMargins(0,0,0,0);
	toolbar = new QToolBar();
	toolbar->setAutoFillBackground(true);
	this->layout()->addWidget(toolbar);

	// Add scrollbars...
	gridLayout = new QGridLayout();
	gridLayout->setContentsMargins(0,0,0,0);
	QWidget *gridHolder = new QWidget();
	gridHolder->setLayout(gridLayout);
	this->layout()->addWidget(gridHolder);
	scrollHorizontal = new QScrollBar(Qt::Horizontal);
	scrollHorizontal->setMinimum(0);
	scrollHorizontal->setMaximum(1000);
	scrollHorizontal->setSingleStep(10);
	scrollVertical = new QScrollBar(Qt::Vertical);
	scrollVertical->setMinimum(0);
	scrollVertical->setMaximum(1000);
	scrollVertical->setSingleStep(10);
	gridLayout->addWidget(scrollHorizontal,3,1);
	gridLayout->addWidget(scrollVertical,0,2);

	// Canvas
	if(openGL)	canvas = new DrawCanvasGL();
	else		canvas = new DrawCanvas();
	gridLayout->addWidget(canvas, 0,1);

	// Zoom
	if(openGL) {
		// Only allow zooming if open gl. Software render is just not built for this...
		sliderZoom = new QSlider(Qt::Horizontal);
		setNaturalZoom();
		gridLayout->addWidget(sliderZoom,2,1);
	}

	// Build menu
	menuMain = new QMenu(this);
	QAction *actionLabelNativeOrGL = new QAction( (openGL ? "openGL Render" : "Native Render"), menuMain);
	actionLabelNativeOrGL->setEnabled(false);
	menuMain->addAction(actionLabelNativeOrGL);
	actionAntiAlias = new QAction("Anti Alias", menuMain);
	actionAntiAlias->setCheckable(true);
	actionAntiAlias->setChecked(antiAlias);
	menuMain->addAction(actionAntiAlias);
	actionAutoUpdate = new QAction("Auto Update", menuMain);
	actionAutoUpdate->setCheckable(true);
	actionAutoUpdate->setChecked(true);
	menuMain->addAction(actionAutoUpdate);
	actionAutoFocus = new QAction("Auto Focus", menuMain);
	actionAutoFocus->setCheckable(true);
	actionAutoFocus->setChecked(true);
	menuMain->addAction(actionAutoFocus);
	menuMaps = new QMenu("Maps");
	menuMain->addMenu(menuMaps);

	// Register events
	this->setFocusPolicy(Qt::StrongFocus);
	this->setMouseTracking(true);

	// Connections
	connect(menuMain, SIGNAL(triggered(QAction*)), this, SLOT(menuAction(QAction*)));
	connect(menuMaps, SIGNAL(triggered(QAction*)), this, SLOT(menuAction(QAction*)));
	connect(toolbar, SIGNAL(actionTriggered(QAction*)), this, SLOT(toolbarAction(QAction*)));
	connect(timerAutoUpdate, SIGNAL(timeout()), this, SLOT(paintAndShow()));
	connect(canvas,SIGNAL(draw(QPainter*)), this, SLOT(drawMaps(QPainter*)));
	connect(canvas,SIGNAL(mouseClick(QMouseEvent*)), this, SLOT(canvasClicked(QMouseEvent*)));
	if(sliderZoom) connect(sliderZoom, SIGNAL(valueChanged(int)), this, SLOT(zoomChanged()));

	// Start timers...
	resizeScrollbars();
	timerAutoUpdate->start();
}