Skip to content

Commit 0e17c70

Browse files
committed
State machines debugging supports all result file formats
Diagram window for visualization Visualization controls in VariablesWidget States and transitions are visualized as active or inactive
1 parent eb5a8a2 commit 0e17c70

26 files changed

+914
-104
lines changed

OMEdit/OMEditGUI/Animation/AbstractAnimationWindow.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ AbstractAnimationWindow::AbstractAnimationWindow(QWidget *pParent)
7777
mCameraInitialized(false)
7878
{
7979
// to distinguish this widget as a subwindow among the plotwindows
80-
setObjectName(QString("animationWidget"));
80+
setObjectName(QString("animationWindow"));
8181
//the viewer widget
8282
mpViewerWidget = new ViewerWidget(this);
8383
// we need to set the minimum height so that visualization window is still shown when we cascade windows.
@@ -190,7 +190,7 @@ void AbstractAnimationWindow::createActions()
190190
mpAnimationSpeedLabel->setText(tr("Speed:"));
191191
mpSpeedComboBox = new QComboBox;
192192
mpSpeedComboBox->setEditable(true);
193-
mpSpeedComboBox->addItems(QStringList() << "10" << "5" << "2" << "1" << "0.5" << "0.2" << "0.1");
193+
mpSpeedComboBox->addItems(Helper::speedOptions.split(","));
194194
mpSpeedComboBox->setCurrentIndex(3);
195195
mpSpeedComboBox->setMaximumSize(QSize(toolbarIconSize*2, toolbarIconSize));
196196
mpSpeedComboBox->setEnabled(false);

OMEdit/OMEditGUI/Annotations/LineAnnotation.cpp

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ LineAnnotation::LineAnnotation(QString annotation, GraphicsView *pGraphicsView)
5858
setZfr("");
5959
setAlpha("");
6060
setOMSConnectionType(oms3_connection_single);
61+
setActiveState(false);
6162
// set the default values
6263
GraphicItem::setDefaults();
6364
ShapeAnnotation::setDefaults();
@@ -87,6 +88,7 @@ LineAnnotation::LineAnnotation(ShapeAnnotation *pShapeAnnotation, Component *pPa
8788
setZfr("");
8889
setAlpha("");
8990
setOMSConnectionType(oms3_connection_single);
91+
setActiveState(false);
9092
setPos(mOrigin);
9193
setRotation(mRotation);
9294
connect(pShapeAnnotation, SIGNAL(updateReferenceShapes()), pShapeAnnotation, SIGNAL(changed()));
@@ -125,6 +127,7 @@ LineAnnotation::LineAnnotation(LineAnnotation::LineType lineType, Component *pSt
125127
setSynchronize(false);
126128
setPriority(1);
127129
setOMSConnectionType(oms3_connection_single);
130+
setActiveState(false);
128131
if (mLineType == LineAnnotation::ConnectionType) {
129132
/* Use the linecolor of the first shape from icon layer of start component for the connection line.
130133
* Or use black color if there is no shape in the icon layer
@@ -210,6 +213,7 @@ LineAnnotation::LineAnnotation(QString annotation, Component *pStartComponent, C
210213
setZfr("");
211214
setAlpha("");
212215
setOMSConnectionType(oms3_connection_single);
216+
setActiveState(false);
213217
parseShapeAnnotation(annotation);
214218
/* make the points relative to origin */
215219
QList<QPointF> points;
@@ -248,6 +252,7 @@ LineAnnotation::LineAnnotation(QString annotation, QString text, Component *pSta
248252
setZfr("");
249253
setAlpha("");
250254
setOMSConnectionType(oms3_connection_single);
255+
setActiveState(false);
251256
parseShapeAnnotation(annotation);
252257
/* make the points relative to origin */
253258
QList<QPointF> points;
@@ -287,6 +292,7 @@ LineAnnotation::LineAnnotation(QString annotation, Component *pComponent, Graphi
287292
setZfr("");
288293
setAlpha("");
289294
setOMSConnectionType(oms3_connection_single);
295+
setActiveState(false);
290296
parseShapeAnnotation(annotation);
291297
/* make the points relative to origin */
292298
QList<QPointF> points;
@@ -318,6 +324,7 @@ LineAnnotation::LineAnnotation(Component *pParent)
318324
setZfr("");
319325
setAlpha("");
320326
setOMSConnectionType(oms3_connection_single);
327+
setActiveState(false);
321328
// set the default values
322329
GraphicItem::setDefaults();
323330
ShapeAnnotation::setDefaults();
@@ -354,6 +361,7 @@ LineAnnotation::LineAnnotation(GraphicsView *pGraphicsView)
354361
setZfr("");
355362
setAlpha("");
356363
setOMSConnectionType(oms3_connection_single);
364+
setActiveState(false);
357365
// set the default values
358366
GraphicItem::setDefaults();
359367
ShapeAnnotation::setDefaults();
@@ -467,6 +475,13 @@ void LineAnnotation::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
467475
Q_UNUSED(option);
468476
Q_UNUSED(widget);
469477
if (mVisible || !mDynamicVisible.isEmpty()) {
478+
if (mLineType == LineAnnotation::TransitionType && mpGraphicsView->isVisualizationView()) {
479+
if (isActiveState()) {
480+
painter->setOpacity(1.0);
481+
} else {
482+
painter->setOpacity(0.2);
483+
}
484+
}
470485
drawLineAnnotaion(painter);
471486
}
472487
}
@@ -1019,20 +1034,27 @@ void LineAnnotation::updateShape(ShapeAnnotation *pShapeAnnotation)
10191034
setReset(pLineAnnotation->getReset());
10201035
setSynchronize(pLineAnnotation->getSynchronize());
10211036
setPriority(pLineAnnotation->getPriority());
1022-
mpTextAnnotation = pLineAnnotation->getTextAnnotation();
1037+
if (pLineAnnotation->getTextAnnotation()) {
1038+
mpTextAnnotation = new TextAnnotation("", this);
1039+
mpTextAnnotation->updateShape(pLineAnnotation->getTextAnnotation());
1040+
} else {
1041+
mpTextAnnotation = 0;
1042+
}
10231043
setOldAnnotation(pLineAnnotation->getOldAnnotation());
10241044
setDelay(pLineAnnotation->getDelay());
10251045
setZf(pLineAnnotation->getZf());
10261046
setZfr(pLineAnnotation->getZfr());
10271047
setAlpha(pLineAnnotation->getAlpha());
10281048
setOMSConnectionType(pLineAnnotation->getOMSConnectionType());
1049+
setActiveState(pLineAnnotation->isActiveState());
10291050
// set the default values
10301051
GraphicItem::setDefaults(pShapeAnnotation);
10311052
mPoints.clear();
10321053
QList<QPointF> points = pShapeAnnotation->getPoints();
10331054
for (int i = 0 ; i < points.size() ; i++) {
10341055
addPoint(points[i]);
10351056
}
1057+
updateTransitionTextPosition();
10361058
ShapeAnnotation::setDefaults(pShapeAnnotation);
10371059
}
10381060

@@ -1093,6 +1115,22 @@ void LineAnnotation::showOMSConnection()
10931115
}
10941116
}
10951117

1118+
void LineAnnotation::updateToolTip()
1119+
{
1120+
if (mLineType == LineAnnotation::ConnectionType) {
1121+
setToolTip(QString("<b>connect</b>(%1, %2)").arg(getStartComponentName()).arg(getEndComponentName()));
1122+
} else if (mLineType == LineAnnotation::TransitionType) {
1123+
setToolTip(QString("<b>transition</b>(%1, %2, %3, %4, %5, %6, %7)")
1124+
.arg(getStartComponentName())
1125+
.arg(getEndComponentName())
1126+
.arg(getCondition())
1127+
.arg(getImmediate() ? "true" : "false")
1128+
.arg(getReset() ? "true" : "false")
1129+
.arg(getSynchronize() ? "true" : "false")
1130+
.arg(getPriority()));
1131+
}
1132+
}
1133+
10961134
QVariant LineAnnotation::itemChange(GraphicsItemChange change, const QVariant &value)
10971135
{
10981136
ShapeAnnotation::itemChange(change, value);
@@ -2076,6 +2114,9 @@ CreateOrEditTransitionDialog::CreateOrEditTransitionDialog(GraphicsView *pGraphi
20762114
// Create the buttons
20772115
mpOkButton = new QPushButton(Helper::ok);
20782116
mpOkButton->setAutoDefault(true);
2117+
if (mpGraphicsView->getModelWidget()->getLibraryTreeItem()->isSystemLibrary() || mpGraphicsView->isVisualizationView()) {
2118+
mpOkButton->setDisabled(true);
2119+
}
20792120
connect(mpOkButton, SIGNAL(clicked()), SLOT(createOrEditTransition()));
20802121
mpCancelButton = new QPushButton(Helper::cancel);
20812122
mpCancelButton->setAutoDefault(false);

OMEdit/OMEditGUI/Annotations/LineAnnotation.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,15 @@ class LineAnnotation : public ShapeAnnotation
126126
QString getZfr() {return mZfr;}
127127
void setAlpha(QString alpha) {mAlpha = alpha;}
128128
QString getAlpha() {return mAlpha;}
129+
void setOMSConnectionType(oms3_connection_type_enu_t connectionType) {mOMSConnectionType = connectionType;}
130+
oms3_connection_type_enu_t getOMSConnectionType() {return mOMSConnectionType;}
131+
void setActiveState(bool activeState) {mActiveState = activeState;}
132+
bool isActiveState() {return mActiveState;}
129133
void setShapeFlags(bool enable);
130134
void updateShape(ShapeAnnotation *pShapeAnnotation);
131135
void setAligned(bool aligned);
132136
void updateOMSConnection();
133-
void setOMSConnectionType(oms3_connection_type_enu_t connectionType) {mOMSConnectionType = connectionType;}
134-
oms3_connection_type_enu_t getOMSConnectionType() {return mOMSConnectionType;}
137+
void updateToolTip();
135138
void showOMSConnection();
136139
protected:
137140
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
@@ -156,6 +159,7 @@ class LineAnnotation : public ShapeAnnotation
156159
QString mZfr;
157160
QString mAlpha;
158161
oms3_connection_type_enu_t mOMSConnectionType;
162+
bool mActiveState;
159163
public slots:
160164
void handleComponentMoved();
161165
void updateConnectionAnnotation();

OMEdit/OMEditGUI/Annotations/RectangleAnnotation.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,15 @@ void RectangleAnnotation::paint(QPainter *painter, const QStyleOptionGraphicsIte
159159
Q_UNUSED(option);
160160
Q_UNUSED(widget);
161161
if (mVisible || !mDynamicVisible.isEmpty()) {
162+
// state machine visualization
163+
if (mpParentComponent && mpParentComponent->getLibraryTreeItem() && mpParentComponent->getLibraryTreeItem()->isState()
164+
&& mpParentComponent->getGraphicsView()->isVisualizationView()) {
165+
if (mpParentComponent->isActiveState()) {
166+
painter->setOpacity(1.0);
167+
} else {
168+
painter->setOpacity(0.2);
169+
}
170+
}
162171
drawRectangleAnnotaion(painter);
163172
}
164173
}

OMEdit/OMEditGUI/Annotations/ShapeAnnotation.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ void ShapeAnnotation::setDefaults(ShapeAnnotation *pShapeAnnotation)
381381
mTextString = pShapeAnnotation->mTextString;
382382
mFontSize = pShapeAnnotation->mFontSize;
383383
mFontName = pShapeAnnotation->mFontName;
384+
mTextStyles = pShapeAnnotation->mTextStyles;
384385
mHorizontalAlignment = pShapeAnnotation->mHorizontalAlignment;
385386
mOriginalFileName = mOriginalFileName;
386387
mFileName = pShapeAnnotation->mFileName;

OMEdit/OMEditGUI/Annotations/TextAnnotation.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,26 @@ void TextAnnotation::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
269269
return;
270270
}
271271
if (mVisible || !mDynamicVisible.isEmpty()) {
272+
// state machine visualization
273+
// text annotation on a component
274+
if (mpComponent && mpComponent->getLibraryTreeItem() && mpComponent->getLibraryTreeItem()->isState()
275+
&& mpComponent->getGraphicsView()->isVisualizationView()) {
276+
if (mpComponent->isActiveState()) {
277+
painter->setOpacity(1.0);
278+
} else {
279+
painter->setOpacity(0.2);
280+
}
281+
}
282+
// text annotation on a transition
283+
LineAnnotation *pTransitionLineAnnotation = dynamic_cast<LineAnnotation*>(parentItem());
284+
if (pTransitionLineAnnotation && pTransitionLineAnnotation->getLineType() == LineAnnotation::TransitionType
285+
&& pTransitionLineAnnotation->getGraphicsView() && pTransitionLineAnnotation->getGraphicsView()->isVisualizationView()) {
286+
if (pTransitionLineAnnotation->isActiveState()) {
287+
painter->setOpacity(1.0);
288+
} else {
289+
painter->setOpacity(0.2);
290+
}
291+
}
272292
drawTextAnnotaion(painter);
273293
}
274294
}

OMEdit/OMEditGUI/Component/Component.cpp

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "FMUProperties.h"
3939
#include "Modeling/Commands.h"
4040
#include "Modeling/DocumentationWidget.h"
41+
#include "Plotting/VariablesWidget.h"
4142
#include "Modeling/BusDialog.h"
4243

4344
#include <QMessageBox>
@@ -460,6 +461,7 @@ Component::Component(QString name, LibraryTreeItem *pLibraryTreeItem, QString an
460461
createStateComponent();
461462
mHasTransition = false;
462463
mIsInitialState = false;
464+
mActiveState = false;
463465
mpBusComponent = 0;
464466
if (mpGraphicsView->getModelWidget()->getLibraryTreeItem()->getLibraryType() == LibraryTreeItem::CompositeModel) {
465467
mpDefaultComponentRectangle->setVisible(true);
@@ -532,6 +534,7 @@ Component::Component(LibraryTreeItem *pLibraryTreeItem, Component *pParentCompon
532534
mpStateComponentRectangle = 0;
533535
mHasTransition = false;
534536
mIsInitialState = false;
537+
mActiveState = false;
535538
mpBusComponent = 0;
536539
drawInheritedComponentsAndShapes();
537540
setDialogAnnotation(QStringList());
@@ -567,6 +570,7 @@ Component::Component(Component *pComponent, Component *pParentComponent, Compone
567570
mpStateComponentRectangle = 0;
568571
mHasTransition = false;
569572
mIsInitialState = false;
573+
mActiveState = false;
570574
mpBusComponent = mpReferenceComponent->getBusComponent();
571575
drawInheritedComponentsAndShapes();
572576
mTransformation = Transformation(mpReferenceComponent->mTransformation);
@@ -616,8 +620,9 @@ Component::Component(Component *pComponent, GraphicsView *pGraphicsView)
616620
createNonExistingComponent();
617621
createDefaultComponent();
618622
createStateComponent();
619-
mHasTransition = false;
620-
mIsInitialState = false;
623+
mHasTransition = mpReferenceComponent->hasTransition();;
624+
mIsInitialState = mpReferenceComponent->isInitialState();
625+
mActiveState = false;
621626
mpBusComponent = 0;
622627
drawComponent();
623628
mTransformation = Transformation(mpReferenceComponent->mTransformation);
@@ -663,6 +668,7 @@ Component::Component(ComponentInfo *pComponentInfo, Component *pParentComponent)
663668
mpStateComponentRectangle = 0;
664669
mHasTransition = false;
665670
mIsInitialState = false;
671+
mActiveState = false;
666672
mpBusComponent = 0;
667673

668674
if (mpComponentInfo->getTLMCausality() == StringHandler::getTLMCausality(StringHandler::TLMBidirectional)) {
@@ -1347,17 +1353,15 @@ void Component::renameComponentInConnections(QString newName)
13471353
QString startComponentName = pConnectionLineAnnotation->getStartComponentName();
13481354
startComponentName.replace(getName(), newName);
13491355
pConnectionLineAnnotation->setStartComponentName(startComponentName);
1350-
pConnectionLineAnnotation->setToolTip(QString("<b>connect</b>(%1, %2)").arg(pConnectionLineAnnotation->getStartComponentName())
1351-
.arg(pConnectionLineAnnotation->getEndComponentName()));
1356+
pConnectionLineAnnotation->updateToolTip();
13521357
}
13531358
// update end component name
13541359
Component *pEndComponent = pConnectionLineAnnotation->getEndComponent();
13551360
if (pEndComponent->getRootParentComponent() == this) {
13561361
QString endComponentName = pConnectionLineAnnotation->getEndComponentName();
13571362
endComponentName.replace(getName(), newName);
13581363
pConnectionLineAnnotation->setEndComponentName(endComponentName);
1359-
pConnectionLineAnnotation->setToolTip(QString("<b>connect</b>(%1, %2)").arg(pConnectionLineAnnotation->getStartComponentName())
1360-
.arg(pConnectionLineAnnotation->getEndComponentName()));
1364+
pConnectionLineAnnotation->updateToolTip();
13611365
}
13621366
}
13631367
}
@@ -2108,7 +2112,7 @@ void Component::updateToolTip()
21082112
comment.replace("src=\"file://", "src=\"");
21092113
#endif
21102114

2111-
if ((mIsInheritedComponent || mComponentType == Component::Port) && mpReferenceComponent) {
2115+
if ((mIsInheritedComponent || mComponentType == Component::Port) && mpReferenceComponent && !mpGraphicsView->isVisualizationView()) {
21122116
setToolTip(tr("<b>%1</b> %2<br/>%3<br /><br />Component declared in %4").arg(mpComponentInfo->getClassName())
21132117
.arg(mpComponentInfo->getName()).arg(comment)
21142118
.arg(mpReferenceComponent->getGraphicsView()->getModelWidget()->getLibraryTreeItem()->getNameStructure()));
@@ -2909,6 +2913,24 @@ void Component::showFMUPropertiesDialog()
29092913
}
29102914
}
29112915

2916+
/*!
2917+
* \brief Component::updateDynamicSelect
2918+
* Slot activated when updateDynamicSelect SIGNAL is raised by VariablesWidget during the visualization of result file.
2919+
* \param time
2920+
*/
2921+
void Component::updateDynamicSelect(double time)
2922+
{
2923+
if (mpLibraryTreeItem && mpLibraryTreeItem->isState()) {
2924+
double value = MainWindow::instance()->getVariablesWidget()->readVariableValue(getName() + ".active", time);
2925+
setActiveState(value);
2926+
foreach (LineAnnotation *pTransitionLineAnnotation, mpGraphicsView->getTransitionsList()) {
2927+
if (pTransitionLineAnnotation->getEndComponent()->getName().compare(getName()) == 0) {
2928+
pTransitionLineAnnotation->setActiveState(value);
2929+
}
2930+
}
2931+
}
2932+
}
2933+
29122934
/*!
29132935
* \brief Component::contextMenuEvent
29142936
* Reimplementation of contextMenuEvent.\n

OMEdit/OMEditGUI/Component/Component.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,11 @@ class Component : public QObject, public QGraphicsItem
226226
void addConnectionDetails(LineAnnotation *pConnectorLineAnnotation);
227227
void removeConnectionDetails(LineAnnotation *pConnectorLineAnnotation);
228228
void setHasTransition(bool hasTransition);
229+
bool hasTransition() {return mHasTransition;}
229230
void setIsInitialState(bool isInitialState);
231+
bool isInitialState() {return mIsInitialState;}
232+
void setActiveState(bool activeState) {mActiveState = activeState;}
233+
bool isActiveState() {return mActiveState;}
230234
void removeChildren();
231235
void emitAdded();
232236
void emitTransformChange() {emit transformChange();}
@@ -293,6 +297,7 @@ class Component : public QObject, public QGraphicsItem
293297
QPointF mOldPosition;
294298
bool mHasTransition;
295299
bool mIsInitialState;
300+
bool mActiveState;
296301
Component *mpBusComponent;
297302
void createNonExistingComponent();
298303
void createDefaultComponent();
@@ -370,6 +375,7 @@ public slots:
370375
void viewDocumentation();
371376
void showSubModelAttributes();
372377
void showFMUPropertiesDialog();
378+
void updateDynamicSelect(double time);
373379
protected:
374380
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
375381
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);

OMEdit/OMEditGUI/Component/ComponentProperties.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ void ComponentParameters::setUpDialog()
776776
mpOkButton = new QPushButton(Helper::ok);
777777
mpOkButton->setAutoDefault(true);
778778
connect(mpOkButton, SIGNAL(clicked()), this, SLOT(updateComponentParameters()));
779-
if (mpComponent->getGraphicsView()->getModelWidget()->getLibraryTreeItem()->isSystemLibrary()) {
779+
if (mpComponent->getGraphicsView()->getModelWidget()->getLibraryTreeItem()->isSystemLibrary() || mpComponent->getGraphicsView()->isVisualizationView()) {
780780
mpOkButton->setDisabled(true);
781781
}
782782
mpCancelButton = new QPushButton(Helper::cancel);

0 commit comments

Comments
 (0)