void JackContextGraphicsScene::changeToCurrentContext()
{
    delete graphicsClientItemsClient;
    clear();
    QGraphicsRectItem *dummy = new QGraphicsRectItem(-5000, -5000, 10000, 10000, 0, this);
    dummy->setVisible(false);
    graphicsClientItemsClient = new GraphicsClientItemsClient(this);
}
Exemple #2
0
QAbstractGraphicsShapeItem* GIFactory::createPortAdapteeGI() {
    // cast here otherwise -PORT_RADIUS will be about 4 billion and something
    // since PORT_RADIUS is unsigned
    const qreal r = (qreal)PORT_RADIUS;
    QGraphicsRectItem* adaptee = new QGraphicsRectItem(-r / 2, -r / 2, r, r);
    adaptee->setVisible(true);
    return adaptee;
}
JackContextGraphicsScene::JackContextGraphicsScene() :
    graphicsClientItemsClient(new GraphicsClientItemsClient(this)),
    waitForMacroPosition(false),
    waitForModulePosition(false)
{
    setBackgroundBrush(QBrush(QColor("lightsteelblue")));

    QGraphicsRectItem *dummy = new QGraphicsRectItem(-5000, -5000, 10000, 10000, 0, this);
    dummy->setVisible(false);
}
void DlgSettingsPointMatch::load (CmdMediator &cmdMediator)
{
  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsPointMatch::load";

  setCmdMediator (cmdMediator);

  // Flush old data
  if (m_modelPointMatchBefore != 0) {
    delete m_modelPointMatchBefore;
  }
  if (m_modelPointMatchAfter != 0) {
    delete m_modelPointMatchAfter;
  }

  // Save new data
  m_modelPointMatchBefore = new DocumentModelPointMatch (cmdMediator.document());
  m_modelPointMatchAfter = new DocumentModelPointMatch (cmdMediator.document());

  // Sanity checks. Incoming defaults must be acceptable to the local limits
  ENGAUGE_ASSERT (POINT_SEPARATION_MIN <= m_modelPointMatchAfter->minPointSeparation());
  ENGAUGE_ASSERT (POINT_SEPARATION_MAX > m_modelPointMatchAfter->minPointSeparation());
  ENGAUGE_ASSERT (POINT_SIZE_MIN <= m_modelPointMatchAfter->maxPointSize());
  ENGAUGE_ASSERT (POINT_SIZE_MAX > m_modelPointMatchAfter->maxPointSize());

  // Populate controls
  m_spinMinPointSeparation->setValue(m_modelPointMatchAfter->minPointSeparation());
  m_spinPointSize->setValue(m_modelPointMatchAfter->maxPointSize());

  int indexAccepted = m_cmbAcceptedPointColor->findData(QVariant(m_modelPointMatchAfter->paletteColorAccepted()));
  ENGAUGE_ASSERT (indexAccepted >= 0);
  m_cmbAcceptedPointColor->setCurrentIndex(indexAccepted);

  int indexCandidate = m_cmbCandidatePointColor->findData(QVariant(m_modelPointMatchAfter->paletteColorCandidate()));
  ENGAUGE_ASSERT (indexCandidate >= 0);
  m_cmbCandidatePointColor->setCurrentIndex(indexCandidate);

  int indexRejected = m_cmbRejectedPointColor->findData(QVariant(m_modelPointMatchAfter->paletteColorRejected()));
  ENGAUGE_ASSERT (indexRejected >= 0);
  m_cmbRejectedPointColor->setCurrentIndex(indexRejected);

  initializeBox ();

  // Fix the preview size using an invisible boundary
  QGraphicsRectItem *boundary = m_scenePreview->addRect (QRect (0,
                                                                0,
                                                                cmdMediator.document().pixmap().width (),
                                                                cmdMediator.document().pixmap().height ()));
  boundary->setVisible (false);

  m_scenePreview->addPixmap (cmdMediator.document().pixmap());

  updateControls();
  enableOk (false); // Disable Ok button since there not yet any changes
  updatePreview();
}
void CustomGraphicsScene::removeAllShapes()
{
	QPainterPath path;
	path.addRect(this->sceneRect());
	setSelectionArea(path);
	removeSelectedShapes();
	this->clear();
	QGraphicsRectItem *item;
	addItem(item = new QGraphicsRectItem(QRectF(0,0,10000,10000)));
	item->setVisible(false);
}
CustomGraphicsScene::CustomGraphicsScene(QObject* _parent) :
	QGraphicsScene(_parent),
	m_afterMoving(false)
{
	setItemIndexMethod(QGraphicsScene::NoIndex);

	setBackgroundBrush(Qt::transparent);

	QGraphicsRectItem *item;
	addItem(item = new QGraphicsRectItem(QRectF(0,0,10000,10000)));
	item->setVisible(false);
}
Exemple #7
0
void DlgSettingsCurveProperties::resetSceneRectangle ()
{

  QRect rect (0.0,
              0.0,
              PREVIEW_WIDTH,
              PREVIEW_HEIGHT);

  QGraphicsRectItem *itemPerimeter = new QGraphicsRectItem(rect);
  itemPerimeter->setVisible(false);
  m_scenePreview->addItem (itemPerimeter);
  m_viewPreview->centerOn (QPointF (0.0, 0.0));
}
Exemple #8
0
void ViewScene::drawTile(r2d2::Box box,QColor color){
    QRectF tempRect = box_tile_2_qrect(box);
    QGraphicsRectItem *block = new QGraphicsRectItem;
    block->setBrush(* new QBrush(color));
    //check current draw outline state
    if(!outlined){
        block->setPen(Qt::NoPen);
    }
    block->setRect(0,0,tempRect.width(),tempRect.height());
    block->setPos(tempRect.x(),tempRect.y());
    block->setVisible(true);
    addItem(block);
}
void cbSimulator::showGraph(int id)
{
    unsigned int w,c;
    QGraphicsPolygonItem *wallCanvas;
    QGraphicsRectItem *grCanvas;

	if(id<1 || id > (int)robots.size()) {
		cerr << "Cannot show graph of robot " << id << "\n";
		return;
	}

	labCanvasWidth=(int)(lab->Width()*30);
	labCanvasHeight=(int)(lab->Height()*30);

    labScene=new QGraphicsScene(0, 0, labCanvasWidth,labCanvasHeight);

    labView=new cbGraphView(labScene,this);
    labView->viewport()->setMouseTracking(true);

    QPolygon *pa;

    for(w=1; w<lab->nWalls();w++) {
        vector<cbPoint> &corners=lab->Wall(w)->Corners();
        //pa.resize(corners.size());
        pa = new QPolygon(corners.size());
        for(c=0; c<corners.size();c++)
            pa->setPoint(c,(int)(corners[c].X()*labCanvasWidth/lab->Width()),
                         (int)(labCanvasHeight-corners[c].Y()*labCanvasHeight/lab->Height()) );
        wallCanvas = new QGraphicsPolygonItem(0, labScene);
        wallCanvas->setPolygon(*pa);
        wallCanvas->setBrush(QBrush(Qt::black));
		wallCanvas->setVisible(true);
	}


	unsigned int x,y;
	double distMax=0.0;

	//grAux=graph;  Tentativa de optimizacao
	for(x = 0; x < GRIDSIZE; x++)
	    for(y = 0; y < GRIDSIZE; y++) {
		    *grAux=*graph;

		    //grAux->resetInitState();  Tentativa de optimizacao - testes indicam que fica muito mais lento!!
		    //grAux->writeGraph();

		    cbPoint p((0.5+x)*lab->Width()/GRIDSIZE, (GRIDSIZE-0.5-y)*lab->Height()/GRIDSIZE);
		    grAux->addFinalPoint(id,p);
		    distGrid[x][y]=grAux->dist(id);
		    if(distGrid[x][y] < 2000 && distGrid[x][y]>distMax)
			    distMax=distGrid[x][y];
	    }

//        fprintf(stderr,"distmax=%f labCanvasWidth=%d labCanvasHeight=%d\n",
//			 distMax,labCanvasWidth,labCanvasHeight);

	for(x = 0; x < GRIDSIZE; x++)
	    for(y = 0; y < GRIDSIZE; y++) {

            if(distGrid[x][y]<2000) {
                grCanvas = new QGraphicsRectItem(x*labCanvasWidth/GRIDSIZE,y*labCanvasHeight/GRIDSIZE,
                                                 (x+1)*labCanvasWidth/GRIDSIZE - x*labCanvasWidth/GRIDSIZE,
                                                 (y+1)*labCanvasHeight/GRIDSIZE -y*labCanvasHeight/GRIDSIZE,
                                                 0, labScene);
                QColor color((int)(0+distGrid[x][y]/distMax*250),
                             (int)(0+distGrid[x][y]/distMax*250),
                             (int)(0+distGrid[x][y]/distMax*250));
                grCanvas->setBrush(QBrush(color));
                grCanvas->setPen(QPen(color));
			    grCanvas->setVisible(true);
			    //debug
			    //distGrid[x][y]=(int)(0+distGrid[x][y]/distMax*250);
		    }

        }
    labScene->update();

}