29 #include "../../StatechartViewerPlugin/view/StatechartView.h"
30 #include "../../StatechartViewerPlugin/view/StateItem.h"
32 #include <QFileDialog>
34 #include <QMessageBox>
49 setupStatechartGroupsToolbar();
50 addAction(ui->actionSave_State);
51 addAction(ui->actionDelete_State);
62 return ui->stateTabWidget;
67 this->tipDialog = tipDialog;
72 if (ui->stateTabWidget->currentStateview())
74 ui->stateTabWidget->currentStateview()->setOriginalZoom();
80 if (QMessageBox::question(
this,
"Delete state?",
81 "Do you really want to delete the selected states?",
86 if (ui->stateTabWidget->currentStateview())
88 ui->stateTabWidget->currentStateview()->deleteSelectedStates();
100 ui->graphicsOverview->setScene(view->
getScene());
101 ui->graphicsOverview->fitInView(view->
getScene()->itemsBoundingRect(), Qt::KeepAspectRatio);
106 ui->graphicsOverview->setZoomer(NULL);
114 if (ui->stateTabWidget->currentStateview()
115 && ui->stateTabWidget->currentStateview()->getScene()
116 && ui->stateTabWidget->currentStateview()->getScene()->selectedItems().size() > 0)
118 StateItem* item =
dynamic_cast<StateItem*
>(*ui->stateTabWidget->currentStateview()->getScene()->selectedItems().begin());
127 if (instance && view)
146 if (ui->stateTabWidget->currentStateview()
147 && ui->stateTabWidget->currentStateview()->getScene()
148 && ui->stateTabWidget->currentStateview()->getScene()->selectedItems().size() > 0)
150 StateItem* item =
dynamic_cast<StateItem*
>(*ui->stateTabWidget->currentStateview()->getScene()->selectedItems().begin());
157 const QString newStateNameBase =
"MyEndState";
158 QString newStateName = newStateNameBase;
160 while (!state->addEndSubstate(newStateName, newStateName))
162 newStateName = newStateNameBase +
"_" + QString::number(i);
179 if (ui->stateTabWidget->currentStateview())
181 ui->stateTabWidget->currentStateview()->viewAll();
185 void StatechartEditorMainWindow::setupStatechartGroupsToolbar()
187 stGroupToolBar =
new QToolBar(
this);
188 stGroupToolBar->setIconSize(QSize(16, 16));
189 ui->gridLayout_3->addWidget(stGroupToolBar, 0, 0);
190 stGroupToolBar->addAction(ui->actionNew_Statechart_Group);
191 stGroupToolBar->addAction(ui->actionOpenStatechartGroup);
192 stGroupToolBar->addSeparator();
193 stGroupToolBar->addAction(ui->actionNew_State_Definition);
194 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, SIGNAL(currentChanged(
int)),
this, SLOT(
connectOverviewToTab(
int)), Qt::UniqueConnection);
204 highlighter =
new CppHighlighter(ui->textEditCppCode->document());
212 void armarx::StatechartEditorMainWindow::on_actionSave_as_Image_file_triggered()
214 if (ui->stateTabWidget->currentStateview())
216 QFileDialog d(0,
"Save statechart to file",
"",
"Images (*.png *.jpg *.jpeg)");
217 d.setDefaultSuffix(
"png");
218 d.setFileMode(QFileDialog::QFileDialog::AnyFile);
219 d.setAcceptMode(QFileDialog::AcceptSave);
220 d.layout()->addWidget(
new QLabel(
"Image width in pixel"));
221 QLineEdit* localQLineEdit =
new QLineEdit(
"4000");
222 localQLineEdit->setValidator(
new QIntValidator(1, 20000));
223 d.layout()->addWidget(localQLineEdit);
224 if (d.exec() == QDialog::Accepted)
226 ui->stateTabWidget->currentStateview()->getScene()->saveSceneToSVG(d.selectedFiles().first(), localQLineEdit->text().toInt());