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()));
}
curvesDialog::curvesDialog( QWidget* parent,  const char* name, bool modal, WFlags fl )
    : QDialog( parent, name, modal, fl )
{
    if ( !name )
	setName( "curvesDialog" );
	setMinimumSize(QSize(400,200));
    setCaption( tr( "QtiPlot - Add/Remove curves" ) );
	setFocus();
	
	QHBox *box5 = new QHBox (this, "box5"); 
	box5->setSpacing (5);
	box5->setMargin(5);

	new QLabel("New curves style", box5, "label0");
	boxStyle = new QComboBox (box5, "boxStyle");
	boxStyle->insertItem( QPixmap(lPlot_xpm), tr( " Line" ) );
    boxStyle->insertItem( QPixmap(pPlot_xpm), tr( " Scatter" ) );
    boxStyle->insertItem( QPixmap(lpPlot_xpm), tr( " Line + Symbol" ) );
    boxStyle->insertItem( QPixmap(dropLines_xpm), tr( " Vertical drop lines" ) );
	boxStyle->insertItem( QPixmap(spline_xpm), tr( " Spline" ) );
	boxStyle->insertItem( QPixmap(steps_xpm), tr( " Vertical steps" ) );
	boxStyle->insertItem( QPixmap(area_xpm), tr( " Area" ) );
	boxStyle->insertItem( QPixmap(vertBars_xpm), tr( " Vertical Bars" ) );
	boxStyle->insertItem( QPixmap(hBars_xpm), tr( " Horizontal Bars" ) );

	QHBox  *box0 = new QHBox (this, "box0"); 
	box0->setSpacing (5);

	QVBox  *box1=new QVBox (box0, "box1"); 
	box1->setMargin(5);
	box1->setSpacing (5);
	
	TextLabel1 = new QLabel(box1, "TextLabel1" );
    TextLabel1->setText( tr( "Available data" ) );

    available = new QListBox( box1, "available" );
	available->setSelectionMode (QListBox::Multi);
	
	QVBox  *box2=new QVBox (box0, "box2"); 
	box2->setMargin(5);
	box2->setSpacing (5);

    btnAdd = new QPushButton(box2, "btnAdd" );
    btnAdd->setPixmap( QPixmap(add_xpm) );
	btnAdd->setFixedWidth (35);
	btnAdd->setFixedHeight (30);
	
    btnRemove = new QPushButton(box2, "btnRemove" );
    btnRemove->setPixmap( QPixmap(remove_xpm) );
	btnRemove->setFixedWidth (35);
	btnRemove->setFixedHeight(30);
		
	QVBox  *box3=new QVBox (box0, "box3"); 
	box3->setMargin(5);
	box3->setSpacing (5);
	
	TextLabel2 = new QLabel(box3, "TextLabel2" );
    TextLabel2->setText( tr( "Graph contents" ) );

    contents = new QListBox( box3, "contents" );
	contents->setSelectionMode (QListBox::Multi);

	QVBox  *box4=new QVBox (box0, "box4"); 
	box4->setMargin(5);
	box4->setSpacing (5);

	btnAssociations = new QPushButton(box4, "btnAssociations" );
    btnAssociations->setText( tr( "&Plot Associations..." ) );
	btnAssociations->setEnabled(false);
	
	btnEditFunction = new QPushButton(box4, "btnEditFunction" );
    btnEditFunction->setText( tr( "&Edit Function..." ) );
	btnEditFunction->setEnabled(false);
	
    btnOK = new QPushButton(box4, "btnOK" );
    btnOK->setText( tr( "OK" ) );
	btnOK->setDefault( TRUE );
	
    btnCancel = new QPushButton(box4, "btnCancel" );
    btnCancel->setText( tr( "Close" ) );

	QVBoxLayout* layout = new QVBoxLayout(this,5,5, "hlayout3");
    layout->addWidget(box5);
	layout->addWidget(box0);

connect(btnAssociations, SIGNAL(clicked()),this, SLOT(showPlotAssociations()));
connect(btnEditFunction, SIGNAL(clicked()),this, SLOT(showFunctionDialog()));

connect(btnAdd, SIGNAL(clicked()),this, SLOT(addCurve()));
connect(btnRemove, SIGNAL(clicked()),this, SLOT(removeCurve()));
connect(btnOK, SIGNAL(clicked()),this, SLOT(close()));
connect(btnCancel, SIGNAL(clicked()),this, SLOT(close()));
connect(btnAdd, SIGNAL(clicked()),this, SLOT(enableRemoveBtn()));
connect(btnRemove, SIGNAL(clicked()),this, SLOT(enableRemoveBtn()));

connect(contents, SIGNAL(highlighted (int)), this, SLOT(showCurveBtn(int)));
connect(contents, SIGNAL(rightButtonClicked(QListBoxItem *, const QPoint &)), this, SLOT(deletePopupMenu(QListBoxItem *, const QPoint &)));
connect(available, SIGNAL(rightButtonClicked(QListBoxItem *, const QPoint &)), this, SLOT(addPopupMenu(QListBoxItem *, const QPoint &)));

QAccel *accel = new QAccel(this);
accel->connectItem( accel->insertItem( Key_Delete ), this, SLOT(removeCurve()) );
}
void curvesDialog::showFunctionDialog() 
{
emit showFunctionDialog(g, contents->currentItem());
close();
}
Example #4
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);
}