예제 #1
0
void CurvesDialog::contextMenuEvent(QContextMenuEvent *e)
{
	QPoint pos = available->viewport()->mapFromGlobal(QCursor::pos());
	QRect rect = available->visualItemRect(available->currentItem());
	if (rect.contains(pos))
	{
       QList<QTreeWidgetItem *> lst = available->selectedItems();
       int count = 0;
	   foreach (QTreeWidgetItem *item, lst){
			if (item->type() == FolderItem)
				continue;

			count++;
	   }

	   if (!count)
		return;

	   QMenu contextMenu(this);
       if (count > 1)
	       contextMenu.insertItem(tr("&Plot Selection"), this, SLOT(addCurves()));
       else if (count == 1)
	       contextMenu.insertItem(tr("&Plot"), this, SLOT(addCurves()));
	   contextMenu.exec(QCursor::pos());
    }
예제 #2
0
void CurvesDialog::contextMenuEvent(QContextMenuEvent *e)
{
  QPoint pos = available->viewport()->mapFromGlobal(QCursor::pos());
  QRect rect = available->visualItemRect(available->currentItem());
  if (rect.contains(pos))
  {
    QMenu contextMenu(this);
    QList<QListWidgetItem *> lst = available->selectedItems();
    if (lst.size() > 1)
      contextMenu.insertItem(tr("&Plot Selection"), this, SLOT(addCurves()));
    else if (lst.size() == 1)
      contextMenu.insertItem(tr("&Plot"), this, SLOT(addCurves()));
    contextMenu.exec(QCursor::pos());
  }

  pos = contents->viewport()->mapFromGlobal(QCursor::pos());
  rect = contents->visualItemRect(contents->currentItem());
  if (rect.contains(pos))
  {
    QMenu contextMenu(this);
    QList<QListWidgetItem *> lst = contents->selectedItems();
    if (lst.size() > 1)
      contextMenu.insertItem(tr("&Delete Selection"), this, SLOT(removeCurves()));
    else if (lst.size() == 1)
      contextMenu.insertItem(tr("&Delete Curve"), this, SLOT(removeCurves()));
    contextMenu.exec(QCursor::pos());
  }

  e->accept();
}
예제 #3
0
/* private */
void
OffsetCurveSetBuilder::addPolygonRing(const CoordinateSequence *coord,
	double offsetDistance, int side, int cwLeftLoc, int cwRightLoc)
{

	// don't bother adding ring if it is "flat" and
	// will disappear in the output
	if (offsetDistance == 0.0 && coord->size() < LinearRing::MINIMUM_VALID_SIZE)
		return;

	int leftLoc=cwLeftLoc;
	int rightLoc=cwRightLoc;
#if GEOS_DEBUG
	std::cerr<<"OffsetCurveSetBuilder::addPolygonRing: CCW: "<<CGAlgorithms::isCCW(coord)<<std::endl;
#endif
	if (coord->size() >= LinearRing::MINIMUM_VALID_SIZE
			&& CGAlgorithms::isCCW(coord))
	{
		leftLoc=cwRightLoc;
		rightLoc=cwLeftLoc;
#if GEOS_DEBUG
	std::cerr<<" side "<<side<<" becomes "<<Position::opposite(side)<<std::endl;
#endif
		side=Position::opposite(side);
	}
	std::vector<CoordinateSequence*> lineList;
	curveBuilder.getRingCurve(coord, side, offsetDistance, lineList);
	addCurves(lineList, leftLoc, rightLoc);
}
예제 #4
0
/**
* Add a Point to the graph->
*/
void OffsetCurveSetBuilder::addPoint(const Point *p){
	if (distance <= 0.0) return;
	CoordinateSequence *coord=p->getCoordinates();
	vector<CoordinateSequence*> *lineList=curveBuilder->getLineCurve(coord, distance);
	delete coord;
	addCurves(lineList, Location::EXTERIOR, Location::INTERIOR);
	delete lineList;
}
예제 #5
0
void
OffsetCurveSetBuilder::addLineString(const LineString *line)
{
	if (distance <= 0.0) return;
	CoordinateSequence *coord=CoordinateSequence::removeRepeatedPoints(line->getCoordinatesRO());
	vector<CoordinateSequence*> *lineList=curveBuilder->getLineCurve(coord, distance);
	delete coord;
	addCurves(lineList, Location::EXTERIOR, Location::INTERIOR);
	delete lineList;
}
예제 #6
0
/*private*/
void
OffsetCurveSetBuilder::addPoint(const Point *p)
{
	if (distance <= 0.0) return;
	const CoordinateSequence *coord=p->getCoordinatesRO();
	std::vector<CoordinateSequence*> lineList;
	curveBuilder.getLineCurve(coord, distance, lineList);

	addCurves(lineList, Location::EXTERIOR, Location::INTERIOR);
	//delete lineList;
}
예제 #7
0
/**
* Add an offset curve for a ring->
* The side and left and right topological location arguments
* assume that the ring is oriented CW->
* If the ring is in the opposite orientation,
* the left and right locations must be interchanged and the side flipped->
*
* @param coord the coordinates of the ring (must not contain repeated points)
* @param offsetDistance the distance at which to create the buffer
* @param side the side of the ring on which to construct the buffer line
* @param cwLeftLoc the location on the L side of the ring (if it is CW)
* @param cwRightLoc the location on the R side of the ring (if it is CW)
*/
void OffsetCurveSetBuilder::addPolygonRing(const CoordinateSequence *coord, double offsetDistance, int side, int cwLeftLoc, int cwRightLoc){
	int leftLoc =cwLeftLoc;
	int rightLoc=cwRightLoc;
	if (cga->isCCW(coord)) {
		leftLoc=cwRightLoc;
		rightLoc=cwLeftLoc;
		side=Position::opposite(side);
	}
	vector<CoordinateSequence*> *lineList=curveBuilder->getRingCurve(coord, side, offsetDistance);
	addCurves(lineList, leftLoc, rightLoc);
	delete lineList;
}
예제 #8
0
/*private*/
void
OffsetCurveSetBuilder::addLineString(const LineString *line)
{
	if (distance <= 0.0) return;
#if GEOS_DEBUG
	std::cerr<<__FUNCTION__<<": "<<line->toString()<<std::endl;
#endif
	std::auto_ptr<CoordinateSequence> coord(CoordinateSequence::removeRepeatedPoints(line->getCoordinatesRO()));
#if GEOS_DEBUG
	std::cerr<<" After coordinate removal: "<<coord->toString()<<std::endl;
#endif
	std::vector<CoordinateSequence*> lineList;
	curveBuilder.getLineCurve(coord.get(), distance, lineList);
	addCurves(lineList, Location::EXTERIOR, Location::INTERIOR);
}
예제 #9
0
/* private */
void
OffsetCurveSetBuilder::addPolygonRing(const CoordinateSequence *coord,
	double offsetDistance, int side, int cwLeftLoc, int cwRightLoc)
{
	int leftLoc=cwLeftLoc;
	int rightLoc=cwRightLoc;
#if GEOS_DEBUG
	std::cerr<<"OffsetCurveSetBuilder::addPolygonRing: CCW: "<<CGAlgorithms::isCCW(coord)<<std::endl;
#endif
	if (CGAlgorithms::isCCW(coord)) {
		leftLoc=cwRightLoc;
		rightLoc=cwLeftLoc;
#if GEOS_DEBUG
	std::cerr<<" side "<<side<<" becomes "<<Position::opposite(side)<<std::endl;
#endif
		side=Position::opposite(side);
	}
	std::vector<CoordinateSequence*> lineList;
	curveBuilder.getRingCurve(coord, side, offsetDistance, lineList);
	addCurves(lineList, leftLoc, rightLoc);
}
예제 #10
0
CurvesDialog::CurvesDialog( QWidget* parent, Qt::WFlags fl )
: QDialog( parent, fl )
{
    setName( "CurvesDialog" );
	setWindowTitle( tr( "QtiPlot - Add/Remove curves" ) );
    setSizeGripEnabled(true);
	setFocus();

    QHBoxLayout *hl = new QHBoxLayout();

	hl->addWidget(new QLabel(tr("New curves style")));
	boxStyle = new QComboBox();
	boxStyle->addItem( QPixmap(lPlot_xpm), tr( " Line" ) );
	boxStyle->addItem( QPixmap(pPlot_xpm), tr( " Scatter" ) );
	boxStyle->addItem( QPixmap(lpPlot_xpm), tr( " Line + Symbol" ) );
	boxStyle->addItem( QPixmap(dropLines_xpm), tr( " Vertical drop lines" ) );
	boxStyle->addItem( QPixmap(spline_xpm), tr( " Spline" ) );
	boxStyle->addItem( QPixmap(vert_steps_xpm), tr( " Vertical steps" ) );
	boxStyle->addItem( QPixmap(hor_steps_xpm), tr( " Horizontal steps" ) );
	boxStyle->addItem( QPixmap(area_xpm), tr( " Area" ) );
	boxStyle->addItem( QPixmap(vertBars_xpm), tr( " Vertical Bars" ) );
	boxStyle->addItem( QPixmap(hBars_xpm), tr( " Horizontal Bars" ) );
	boxStyle->addItem( QPixmap(histogram_xpm), tr( " Histogram" ) );
    hl->addWidget(boxStyle);

    boxMatrixStyle = new QComboBox();
	boxMatrixStyle->addItem( QPixmap(color_map_xpm), tr("Contour - Color Fill"));
	boxMatrixStyle->addItem( QPixmap(contour_map_xpm), tr("Contour Lines"));
	boxMatrixStyle->addItem( QPixmap(gray_map_xpm), tr("Gray Scale Map"));
	boxMatrixStyle->addItem( QPixmap(histogram_xpm), tr("Histogram"));
    hl->addWidget(boxMatrixStyle);
    hl->addStretch();

    QGridLayout *gl = new QGridLayout();
    gl->addWidget(new QLabel( tr( "Available data" )), 0, 0);

    QHBoxLayout *hbc = new QHBoxLayout;
    hbc->addWidget(new QLabel( tr( "Graph contents" )));

    btnUp = new QPushButton();
    btnUp->setIcon(QPixmap(arrow_up_xpm));
    btnUp->setMaximumWidth(20);
    hbc->addWidget(btnUp);
	btnDown = new QPushButton();
	btnDown->setIcon(QPixmap(arrow_down_xpm));
	btnDown->setMaximumWidth(20);
	hbc->addWidget(btnDown);
	hbc->addStretch();
	gl->addLayout(hbc, 0, 2);

	available = new QTreeWidget();
	available->setColumnCount(1);
	available->header()->hide();
    available->setIndentation(15);
	available->setSelectionMode (QAbstractItemView::ExtendedSelection);
    gl->addWidget(available, 1, 0);

    QVBoxLayout* vl1 = new QVBoxLayout();
	btnAdd = new QPushButton();
	btnAdd->setPixmap( QPixmap(next_xpm) );
	btnAdd->setFixedWidth (35);
	btnAdd->setFixedHeight (30);
    vl1->addWidget(btnAdd);

	btnRemove = new QPushButton();
	btnRemove->setPixmap( QPixmap(prev_xpm) );
	btnRemove->setFixedWidth (35);
	btnRemove->setFixedHeight(30);
    vl1->addWidget(btnRemove);
    vl1->addStretch();

    gl->addLayout(vl1, 1, 1);
	contents = new QListWidget();
	contents->setSelectionMode (QAbstractItemView::ExtendedSelection);
    gl->addWidget(contents, 1, 2);

    QVBoxLayout* vl2 = new QVBoxLayout();
	btnAssociations = new QPushButton(tr( "&Plot Associations..." ));
	btnAssociations->setEnabled(false);
    vl2->addWidget(btnAssociations);

	btnRange = new QPushButton(tr( "Edit &Range..." ));
	btnRange->setEnabled(false);
    vl2->addWidget(btnRange);

	btnEditFunction = new QPushButton(tr( "&Edit Function..." ));
	btnEditFunction->setEnabled(false);
    vl2->addWidget(btnEditFunction);

	btnOK = new QPushButton(tr( "OK" ));
	btnOK->setDefault( true );
    vl2->addWidget(btnOK);

	btnCancel = new QPushButton(tr( "Close" ));
    vl2->addWidget(btnCancel);

    boxShowRange = new QCheckBox(tr( "&Show Range" ));
    vl2->addWidget(boxShowRange);

    vl2->addStretch();
    gl->addLayout(vl2, 1, 3);

    QVBoxLayout* vl3 = new QVBoxLayout(this);
    vl3->addLayout(hl);
    vl3->addLayout(gl);

	boxShowCurrentFolder = new QCheckBox(tr("Show current &folder only" ));
	vl3->addWidget(boxShowCurrentFolder);

    init();

	connect(btnUp, SIGNAL(clicked()),this, SLOT(raiseCurve()));
	connect(btnDown, SIGNAL(clicked()),this, SLOT(shiftCurveBy()));

	connect(boxShowCurrentFolder, SIGNAL(toggled(bool)), this, SLOT(showCurrentFolder(bool)));
    connect(boxShowRange, SIGNAL(toggled(bool)), this, SLOT(showCurveRange(bool)));
	connect(btnRange, SIGNAL(clicked()),this, SLOT(showCurveRangeDialog()));
	connect(btnAssociations, SIGNAL(clicked()),this, SLOT(showPlotAssociations()));
	connect(btnEditFunction, SIGNAL(clicked()),this, SLOT(showFunctionDialog()));
	connect(btnAdd, SIGNAL(clicked()),this, SLOT(addCurves()));
	connect(btnRemove, SIGNAL(clicked()),this, SLOT(removeCurves()));
	connect(btnOK, SIGNAL(clicked()),this, SLOT(close()));
	connect(btnCancel, SIGNAL(clicked()),this, SLOT(close()));
	connect(contents, SIGNAL(currentRowChanged(int)), this, SLOT(showCurveBtn(int)));
    connect(contents, SIGNAL(itemSelectionChanged()), this, SLOT(enableContentsBtns()));
    connect(available, SIGNAL(itemSelectionChanged()), this, SLOT(enableAddBtn()));

    QShortcut *shortcut = new QShortcut(QKeySequence(Qt::Key_Delete), this);
    connect(shortcut, SIGNAL(activated()), this, SLOT(removeCurves()));
    shortcut = new QShortcut(QKeySequence("-"), this);
    connect(shortcut, SIGNAL(activated()), this, SLOT(removeCurves()));
    shortcut = new QShortcut(QKeySequence("+"), this);
    connect(shortcut, SIGNAL(activated()), this, SLOT(addCurves()));
}
예제 #11
0
CurvesDialog::CurvesDialog( ApplicationWindow* app, Graph* g, Qt::WFlags fl )
  : QDialog( g, fl ),
    d_app(app),
    d_graph(g)
{
  setName( "CurvesDialog" );
  setWindowTitle( tr( "MantidPlot - Add/Remove curves" ) );
  setSizeGripEnabled(true);
  setFocus();

  QHBoxLayout *hl = new QHBoxLayout();

  hl->addWidget(new QLabel(tr("New curves style")));
  boxStyle = new QComboBox();
  boxStyle->addItem( getQPixmap("lPlot_xpm"), tr( " Line" ) );
  boxStyle->addItem( getQPixmap("pPlot_xpm"), tr( " Scatter" ) );
  boxStyle->addItem( getQPixmap("lpPlot_xpm"), tr( " Line + Symbol" ) );
  boxStyle->addItem( getQPixmap("dropLines_xpm"), tr( " Vertical drop lines" ) );
  boxStyle->addItem( getQPixmap("spline_xpm"), tr( " Spline" ) );
  boxStyle->addItem( getQPixmap("hor_steps_xpm"), tr( " Horizontal steps" ) );
  boxStyle->addItem( getQPixmap("vert_steps_xpm"), tr( " Vertical steps" ) );
  boxStyle->addItem( getQPixmap("area_xpm"), tr( " Area" ) );
  boxStyle->addItem( getQPixmap("vertBars_xpm"), tr( " Vertical Bars" ) );
  boxStyle->addItem( getQPixmap("hBars_xpm"), tr( " Horizontal Bars" ) );
  hl->addWidget(boxStyle);

  boxMatrixStyle = new QComboBox();
  boxMatrixStyle->addItem( getQPixmap("color_map_xpm"), tr("Contour - Color Fill"));
  boxMatrixStyle->addItem( getQPixmap("contour_map_xpm"), tr("Contour Lines"));
  boxMatrixStyle->addItem( getQPixmap("gray_map_xpm"), tr("Gray Scale Map"));
  boxMatrixStyle->addItem( getQPixmap("histogram_xpm"), tr("Histogram"));
  boxMatrixStyle->hide();
  hl->addWidget(boxMatrixStyle);
  hl->addStretch();

  QGridLayout *gl = new QGridLayout();
  gl->addWidget(new QLabel( tr( "Available data" )), 0, 0);
  gl->addWidget(new QLabel( tr( "Graph contents" )), 0, 2);

  available = new QListWidget();
  available->setSelectionMode (QAbstractItemView::ExtendedSelection);
  gl->addWidget(available, 1, 0);

  QVBoxLayout* vl1 = new QVBoxLayout();
  btnAdd = new QPushButton();
  btnAdd->setPixmap( getQPixmap("next_xpm") );
  btnAdd->setFixedWidth (35);
  btnAdd->setFixedHeight (30);
  vl1->addWidget(btnAdd);

  btnRemove = new QPushButton();
  btnRemove->setPixmap( getQPixmap("prev_xpm") );
  btnRemove->setFixedWidth (35);
  btnRemove->setFixedHeight(30);
  vl1->addWidget(btnRemove);
  vl1->addStretch();

  gl->addLayout(vl1, 1, 1);
  contents = new QListWidget();
  contents->setSelectionMode (QAbstractItemView::ExtendedSelection);
  gl->addWidget(contents, 1, 2);

  QVBoxLayout* vl2 = new QVBoxLayout();
  btnAssociations = new QPushButton(tr( "&Plot Associations..." ));
  btnAssociations->setEnabled(false);
  vl2->addWidget(btnAssociations);

  btnRange = new QPushButton(tr( "Edit &Range..." ));
  btnRange->setEnabled(false);
  vl2->addWidget(btnRange);

  btnEditFunction = new QPushButton(tr( "&Edit Function..." ));
  btnEditFunction->setEnabled(false);
  vl2->addWidget(btnEditFunction);

  btnOK = new QPushButton(tr( "OK" ));
  btnOK->setDefault( true );
  vl2->addWidget(btnOK);

  btnCancel = new QPushButton(tr( "Close" ));
  vl2->addWidget(btnCancel);

  boxShowRange = new QCheckBox(tr( "&Show Range" ));
  vl2->addWidget(boxShowRange);

  vl2->addStretch();
  gl->addLayout(vl2, 1, 3);

  QVBoxLayout* vl3 = new QVBoxLayout(this);
  vl3->addLayout(hl);
  vl3->addLayout(gl);

  boxShowCurrentFolder = new QCheckBox(tr("Show current &folder only" ));
  vl3->addWidget(boxShowCurrentFolder);

  init();

  connect(boxShowCurrentFolder, SIGNAL(toggled(bool)), this, SLOT(showCurrentFolder(bool)));
  connect(boxShowRange, SIGNAL(toggled(bool)), this, SLOT(showCurveRange(bool)));
  connect(btnRange, SIGNAL(clicked()),this, SLOT(showCurveRangeDialog()));
  connect(btnAssociations, SIGNAL(clicked()),this, SLOT(showPlotAssociations()));
  connect(btnEditFunction, SIGNAL(clicked()),this, SLOT(showFunctionDialog()));
  connect(btnAdd, SIGNAL(clicked()),this, SLOT(addCurves()));
  connect(btnRemove, SIGNAL(clicked()),this, SLOT(removeCurves()));
  connect(btnOK, SIGNAL(clicked()),this, SLOT(close()));
  connect(btnCancel, SIGNAL(clicked()),this, SLOT(close()));
  connect(contents, SIGNAL(currentRowChanged(int)), this, SLOT(showCurveBtn(int)));
  connect(contents, SIGNAL(itemSelectionChanged()), this, SLOT(enableRemoveBtn()));
  connect(available, SIGNAL(itemSelectionChanged()), this, SLOT(enableAddBtn()));

  QShortcut *shortcut = new QShortcut(QKeySequence(Qt::Key_Delete), this);
  connect(shortcut, SIGNAL(activated()), this, SLOT(removeCurves()));
  shortcut = new QShortcut(QKeySequence("-"), this);
  connect(shortcut, SIGNAL(activated()), this, SLOT(removeCurves()));
  shortcut = new QShortcut(QKeySequence("+"), this);
  connect(shortcut, SIGNAL(activated()), this, SLOT(addCurves()));

  setGraph(g);
}