25 #include <QFileDialog>
27 #include <QMessageBox>
35 #include "../../StatechartViewerPlugin/view/StateItem.h"
36 #include "../../StatechartViewerPlugin/view/StatechartView.h"
47 setupStatechartGroupsToolbar();
48 addAction(ui->actionSave_State);
49 addAction(ui->actionDelete_State);
60 return ui->stateTabWidget;
66 this->tipDialog = tipDialog;
72 if (ui->stateTabWidget->currentStateview())
74 ui->stateTabWidget->currentStateview()->setOriginalZoom();
81 if (QMessageBox::question(
this,
83 "Do you really want to delete the selected states?",
87 if (ui->stateTabWidget->currentStateview())
89 ui->stateTabWidget->currentStateview()->deleteSelectedStates();
101 ui->graphicsOverview->setScene(view->
getScene());
102 ui->graphicsOverview->fitInView(view->
getScene()->itemsBoundingRect(),
103 Qt::KeepAspectRatio);
108 ui->graphicsOverview->setZoomer(NULL);
117 if (ui->stateTabWidget->currentStateview() &&
118 ui->stateTabWidget->currentStateview()->getScene() &&
119 ui->stateTabWidget->currentStateview()->getScene()->selectedItems().size() > 0)
122 *ui->stateTabWidget->currentStateview()->getScene()->selectedItems().begin());
131 if (instance && view)
146 if (ui->stateTabWidget->currentStateview() &&
147 ui->stateTabWidget->currentStateview()->getScene() &&
148 ui->stateTabWidget->currentStateview()->getScene()->selectedItems().size() > 0)
151 *ui->stateTabWidget->currentStateview()->getScene()->selectedItems().begin());
158 const QString newStateNameBase =
"MyEndState";
159 QString newStateName = newStateNameBase;
161 while (!state->addEndSubstate(newStateName, newStateName))
163 newStateName = newStateNameBase +
"_" + QString::number(i);
177 if (ui->stateTabWidget->currentStateview())
179 ui->stateTabWidget->currentStateview()->viewAll();
184 StatechartEditorMainWindow::setupStatechartGroupsToolbar()
186 stGroupToolBar =
new QToolBar(
this);
187 stGroupToolBar->setIconSize(QSize(16, 16));
188 ui->gridLayout_3->addWidget(stGroupToolBar, 0, 0);
189 stGroupToolBar->addAction(ui->actionNew_Statechart_Group);
190 stGroupToolBar->addAction(ui->actionOpenStatechartGroup);
191 stGroupToolBar->addSeparator();
192 stGroupToolBar->addAction(ui->actionNew_State_Definition);
193 stGroupToolBar->addAction(ui->actionDelete_State_Definition);
199 connect(ui->actionView_All, SIGNAL(triggered()),
this, SLOT(
zoomToViewAll()));
200 connect(ui->actionInsert_Endstate, SIGNAL(triggered()),
this, SLOT(
addEndState()));
201 connect(ui->actionLayout_state, SIGNAL(triggered()),
this, SLOT(
layoutState()));
203 connect(ui->stateTabWidget,
204 SIGNAL(currentChanged(
int)),
207 Qt::UniqueConnection);
208 highlighter =
new CppHighlighter(ui->textEditCppCode->document());
215 armarx::StatechartEditorMainWindow::on_actionSave_as_Image_file_triggered()
217 if (ui->stateTabWidget->currentStateview())
219 QFileDialog d(0,
"Save statechart to file",
"",
"Images (*.png *.jpg *.jpeg)");
220 d.setDefaultSuffix(
"png");
221 d.setFileMode(QFileDialog::QFileDialog::AnyFile);
222 d.setAcceptMode(QFileDialog::AcceptSave);
223 d.layout()->addWidget(
new QLabel(
"Image width in pixel"));
224 QLineEdit* localQLineEdit =
new QLineEdit(
"4000");
225 localQLineEdit->setValidator(
new QIntValidator(1, 20000));
226 d.layout()->addWidget(localQLineEdit);
227 if (d.exec() == QDialog::Accepted)
229 ui->stateTabWidget->currentStateview()->getScene()->saveSceneToSVG(
230 d.selectedFiles().first(), localQLineEdit->text().toInt());