diff --git a/ExtraResources/lynx-1.png b/ExtraResources/lynx-1.png new file mode 100644 index 0000000000000000000000000000000000000000..281f55284b94910e1aa4a64002e0280391cb28de Binary files /dev/null and b/ExtraResources/lynx-1.png differ diff --git a/Modules/CommandPad/commandpadmodule.cpp b/Modules/CommandPad/commandpadmodule.cpp index fd31912e14db2fdc5d7f85af993ce3cfecb827ba..a1f79ead7b260eeeecab38a98648159b09bde54d 100644 --- a/Modules/CommandPad/commandpadmodule.cpp +++ b/Modules/CommandPad/commandpadmodule.cpp @@ -41,9 +41,9 @@ void CommandPadModule::buildUI() connect(ui->resetARBServo_button, &QPushButton::clicked, this, &CommandPadModule::onResetARBServoClicked); connect(ui->wiggleDPLServo_button, &QPushButton::clicked, this, &CommandPadModule::onWiggleDPLServoClicked); connect(ui->resetDPLServo_button, &QPushButton::clicked, this, &CommandPadModule::onResetDPLServoClicked); - connect(ui->testPrimaryCut_button, &QPushButton::clicked, this, &CommandPadModule::onTestPrimaryCutClicked); +// connect(ui->testPrimaryCut_button, &QPushButton::clicked, this, &CommandPadModule::onTestPrimaryCutClicked); connect(ui->testMode_button, &QPushButton::clicked, this, &CommandPadModule::onTestModeClicked); - connect(ui->testBackupCut_button, &QPushButton::clicked, this, &CommandPadModule::onTestBackupCutClicked); +// connect(ui->testBackupCut_button, &QPushButton::clicked, this, &CommandPadModule::onTestBackupCutClicked); connect(ui->boardReset_button, &QPushButton::clicked, this, &CommandPadModule::onBoardResetClicked); connect(ui->testAerobrakest_button, &QPushButton::clicked, this, &CommandPadModule::onTestAerobrakesClicked); connect(ui->disableAerobrakes_button, &QPushButton::clicked, this, &CommandPadModule::onDisableAerobrakesClicked); @@ -63,10 +63,12 @@ void CommandPadModule::buildUI() connect(ui->calibrateAlgos_button, &QPushButton::clicked, this, &CommandPadModule::onCalibrateALGOSClicked); connect(ui->calibrateSensors_button, &QPushButton::clicked, this, &CommandPadModule::onCalibrateSENSORSClicked); connect(ui->startLog_button, &QPushButton::clicked, this, &CommandPadModule::onStartLogClicked); + connect(ui->startTelemetry_button, &QPushButton::clicked, this, &CommandPadModule::onStartTelemetryClicked); + connect(ui->stopTelemetry_button, &QPushButton::clicked, this, &CommandPadModule::onStopTelemetryClicked); connect(ui->cutDrogue_button, &QPushButton::clicked, this, &CommandPadModule::onCutDrogueClicked); - connect(ui->primaryCut_button, &QPushButton::clicked, this, &CommandPadModule::onPrimaryCutClicked); - connect(ui->backupCut_button, &QPushButton::clicked, this, &CommandPadModule::onBackupClicked); +// connect(ui->primaryCut_button, &QPushButton::clicked, this, &CommandPadModule::onPrimaryCutClicked); +// connect(ui->backupCut_button, &QPushButton::clicked, this, &CommandPadModule::onBackupClicked); } //void CommandPadModule::buildMsgKeyList() @@ -169,21 +171,21 @@ void CommandPadModule::onResetDPLServoClicked() send(createCommandMsg("MAV_CMD_DPL_RESET_SERVO")); } -void CommandPadModule::onTestPrimaryCutClicked() -{ - send(createCommandMsg("MAV_CMD_TEST_PRIMARY_CUTTER")); -} +//void CommandPadModule::onTestPrimaryCutClicked() +//{ +// send(createCommandMsg("MAV_CMD_TEST_PRIMARY_CUTTER")); +//} + +//void CommandPadModule::onTestBackupCutClicked() +//{ +// send(createCommandMsg("MAV_CMD_TEST_BACKUP_CUTTER")); +//} void CommandPadModule::onTestModeClicked() { send(createCommandMsg("MAV_CMD_TEST_MODE")); } -void CommandPadModule::onTestBackupCutClicked() -{ - send(createCommandMsg("MAV_CMD_TEST_BACKUP_CUTTER")); -} - void CommandPadModule::onBoardResetClicked() { send(createCommandMsg("MAV_CMD_BOARD_RESET")); @@ -248,8 +250,17 @@ void CommandPadModule::onAerobrakeAngleSetClicked() void CommandPadModule::onInitialOrientationSetClicked() { - QString payload = QString::number(ui->referenceAltitude_spinBox->value()); - send(createCommandMsgWithPayload("SET_REFERENCE_ALTITUDE", payload)); + ModuleMessage msg = createCommandMsg("SET_INITIAL_ORIENTATION_TC"); + + QString yaw = QString::number(ui->initialOrientationYaw_spinBox->value()); + QString pitch = QString::number(ui->initialOrientationPitch_spinBox->value()); + QString roll = QString::number(ui->initialOrientationRoll_spinBox->value()); + + msg.addOption(SkywardHubStrings::mavlink_orientation_tc_yaw_name, yaw); + msg.addOption(SkywardHubStrings::mavlink_orientation_tc_pitch_name, pitch); + msg.addOption(SkywardHubStrings::mavlink_orientation_tc_roll_name, roll); + + send(msg); } void CommandPadModule::onArmClicked() @@ -294,13 +305,23 @@ void CommandPadModule::onCutDrogueClicked() send(createCommandMsg("MAV_CMD_CUT_DROGUE")); } -void CommandPadModule::onPrimaryCutClicked() +//void CommandPadModule::onPrimaryCutClicked() +//{ +// send(createCommandMsg("MAV_CMD_CUT_PRIMARY")); +//} + +//void CommandPadModule::onBackupClicked() +//{ +// send(createCommandMsg("MAV_CMD_CUT_BACKUP")); +//} + +void CommandPadModule::onStartTelemetryClicked() { - send(createCommandMsg("MAV_CMD_CUT_PRIMARY")); + send(createCommandMsg("MAV_CMD_RADIO_TM")); } -void CommandPadModule::onBackupClicked() +void CommandPadModule::onStopTelemetryClicked() { - send(createCommandMsg("MAV_CMD_CUT_BACKUP")); + send(createCommandMsg("MAV_CMD_SERIAL_TM")); } diff --git a/Modules/CommandPad/commandpadmodule.h b/Modules/CommandPad/commandpadmodule.h index 5cdc7dd8020fda39a1f9656871a42b0c47b54f34..6435f37a56aff85298e0699a784ac47dff7ef13c 100644 --- a/Modules/CommandPad/commandpadmodule.h +++ b/Modules/CommandPad/commandpadmodule.h @@ -33,9 +33,9 @@ protected: void onResetARBServoClicked(); void onWiggleDPLServoClicked(); void onResetDPLServoClicked(); - void onTestPrimaryCutClicked(); +// void onTestPrimaryCutClicked(); void onTestModeClicked(); - void onTestBackupCutClicked(); +// void onTestBackupCutClicked(); void onBoardResetClicked(); void onCalibrateALGOSClicked(); void onCalibrateSENSORSClicked(); @@ -55,8 +55,10 @@ protected: void onEndMissionClicked(); void onRawEventSendClicked(); void onCutDrogueClicked(); - void onPrimaryCutClicked(); - void onBackupClicked(); +// void onPrimaryCutClicked(); +// void onBackupClicked(); + void onStartTelemetryClicked(); + void onStopTelemetryClicked(); private: Ui::CommandPadModule *ui; diff --git a/Modules/CommandPad/commandpadmodule.ui b/Modules/CommandPad/commandpadmodule.ui index 1b20f310c2ddce1a9db29fcc5b05607cf2ac8dc4..9c6fe95a5580db996838ca60e81279815ef4658e 100644 --- a/Modules/CommandPad/commandpadmodule.ui +++ b/Modules/CommandPad/commandpadmodule.ui @@ -27,11 +27,11 @@ <rect> <x>0</x> <y>0</y> - <width>427</width> - <height>1027</height> + <width>442</width> + <height>931</height> </rect> </property> - <layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,1,1,1,1,3,1,1,1"> + <layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,1,1,1,3,1,1,1"> <item> <widget class="QGroupBox" name="groupBox"> <property name="title"> @@ -287,46 +287,6 @@ </layout> </widget> </item> - <item> - <widget class="QGroupBox" name="groupBox_9"> - <property name="title"> - <string>Cutter</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="2" column="0"> - <widget class="QPushButton" name="testPrimaryCut_button"> - <property name="text"> - <string>TEST PRIMARY CUT</string> - </property> - </widget> - </item> - <item row="2" column="3"> - <widget class="QPushButton" name="backupCut_button"> - <property name="text"> - <string>CUT BACKUP</string> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QPushButton" name="primaryCut_button"> - <property name="text"> - <string>CUT PRIMARY</string> - </property> - </widget> - </item> - <item row="3" column="3"> - <widget class="QPushButton" name="testBackupCut_button"> - <property name="text"> - <string>TEST BACKUP CUT</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> <item> <widget class="QGroupBox" name="groupBox_3"> <property name="sizePolicy"> diff --git a/Modules/FileStream/filestreammodule.cpp b/Modules/FileStream/filestreammodule.cpp index 2be76fa2467a91208cfe6553fe32f4484a9315ab..557bb1909d72bb7e6bb8ea17c10bb953b002725c 100644 --- a/Modules/FileStream/filestreammodule.cpp +++ b/Modules/FileStream/filestreammodule.cpp @@ -88,10 +88,17 @@ void FileStreamModule::resetTopicName() void FileStreamModule::onMsgReceived(const ModuleMessage &msg) { - if(file.isOpen() ){ - QTextStream out(&file); - out << msg.toString() << Qt::endl; - } +// if(file.isOpen() ){ +// QTextStream out(&file); +// out << msg.payload() << Qt::endl; +// } + + QFile file(getFilePath()); + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) + return; + + QTextStream out(&file); + out << msg.payload() << Qt::endl; } void FileStreamModule::onAddTopicClicked() @@ -106,7 +113,7 @@ void FileStreamModule::onAddTopicClicked() void FileStreamModule::onStartClicked() { file.setFileName(getFilePath()); - if(!file.open(QIODevice::ReadWrite)){ + if(!file.open(QIODevice::WriteOnly | QIODevice::Text)){ // Append QIODevice::ReadWrite QString msg = "FileStream: Error occurred while opening file " + getFilePath(); QMessageBox msgBox; msgBox.setText(msg); diff --git a/Modules/Fsm/Model/model.cpp b/Modules/Fsm/Model/model.cpp deleted file mode 100644 index 57be97f41d398d86a4f51cfcc86aefce5ab3f674..0000000000000000000000000000000000000000 --- a/Modules/Fsm/Model/model.cpp +++ /dev/null @@ -1,766 +0,0 @@ -#include "model.h" - -Model::Model(QObject *parent) : QObject(parent) -{ - connect(this, &Model::stateCreated, this, &Model::modelTreeChanged); - connect(this, &Model::stateChanged, this, &Model::modelTreeChanged); - connect(this, &Model::stateDeleted, this, &Model::modelTreeChanged); - connect(this, &Model::clearViewRequested, this, [this](){ - QList<State> s; - emit updateModelTreeRequested(s); - }); -// QObject::connect(this, &Model::transitionCreated, this, &Model::modelTreeChanged); -// QObject::connect(this, &Model::transitionChanged, this, &Model::modelTreeChanged); -// QObject::connect(this, &Model::transitionDeleted, this, &Model::modelTreeChanged); - -} - -Model::~Model() -{ - -} - -void Model::toScxml() -{ - scxml.setStateList(states); - scxml.setTransList(transitions); - scxml.merge(); -} - -void Model::toSvg() -{ - svg.setStateList(states); - svg.setTransList(transitions); - svg.merge(); -} - - -void Model::onCreateDefaultState() -{ - State newState; - newState.drawStateBox(); - emit defaultStateCreated(newState); -} - -void Model::onCreateStateRequested(const QPoint &point, const QPoint &offset) -{ - State newState; - customizeState(&newState); - newState.setBoxPosition(point - offset); - newState.setStateId(generateId()); - newState.drawStateBox(); - states.append(newState); - emit stateCreated(newState); - onChangeStatePositionRequested(newState.getStateId(), point, offset); -} - -void Model::onChangeStatePositionRequested(const int &id, const QPoint &point, const QPoint &offset) -{ - QList <State *> superstates = identifySuperstates(id, point); -// qDebug()<<"superstati: "<<superstates.count(); - QList <State *> statePath = searchState(id); - - if( (superstates.count() == statePath.count() - 1) || (superstates.count() < statePath.count() - 1)){ - statePath.last()->setBoxPosition(point-offset); - statePath.first()->adaptBoxToContent(); -// qDebug()<<"stati nestati: "<<statePath.first()->getBranch().count(); - updateBranch(statePath.first()); -// emit superstatesBoxSizeChanged(fromPointerToObjectList(statePath.first()->getBranch())); - updateTransitions(); - -// emit stateChanged(*statePath.last()); -// qDebug()<<"normale"; - - } else if(superstates.count() > statePath.count() - 1 /*&& !superstateIsOwnChild(superstates.last(), statePath.last())*/){ - State stateToNest = *statePath.last(); - stateToNest.setBoxPosition(point-offset); - if(statePath.count() == 1){ - states.removeAt(indexOf(stateToNest.getStateId())); - } else if (statePath.count() > 1){ - QList <State *> reducedPath = chopList(statePath, -1); - reducedPath.last()->removeChildAt(reducedPath.last()->getIndexOfChild(stateToNest)); - } - superstates.last()->addChild(stateToNest); - superstates = searchState(stateToNest.getStateId()); -// superstates.last()->setBoxPosition(point-offset); - superstates.first()->adaptBoxToContent(); - updateBranch(superstates.first()); -// emit superstatesBoxSizeChanged(fromPointerToObjectList(superstates.first()->getBranch())); - updateTransitions(); - -// emit stateChanged(*superstates.last()); -// qDebug()<<"entrato"; - } -} - -void Model::onResizeStateRequested(const int &id, const QPoint &point) -{ - QList <State *> statePath = searchState(id); - statePath.last()->resize(point); - statePath.first()->adaptBoxToContent(); - updateBranch(statePath.first()); - updateTransitions(); -// emit superstatesBoxSizeChanged(fromPointerToObjectList(statePath.first()->getBranch())); -} - -int Model::generateId() -{ - idCounter++; - return idCounter; -} - - -void Model::onStateContextMenuRequested(const int &id) -{ - QList <State *> statePath = searchState(id); - emit stateContextMenuGenerated(*statePath.last()); -} - - -int Model::indexOf(const int &id) const -{ - for(int i=0; i<states.count(); i++) - { - if(states[i].getStateId() == id) - return i; - } - return -1; -} - -int Model::indexOfTransition(const int &id) const -{ - for(int i=0; i<transitions.count(); i++) - { - if(transitions[i].getTransitionId() == id) - return i; - } - return -1; -} - -void Model::onStateEditTitleRequested(const int &id, const QString &title) -{ - QList <State *> statePath = searchState(id); - statePath.last()->setTitle(title); - statePath.last()->drawStateBox(); - updateBranch(statePath.last()); -// emit stateChanged(*statePath.last()); -// updateTransitions(); -} - - -void Model::onStateDeleteRequested(const int &id) -{ - QList <State *> statePath = searchState(id); - QList <int> deletedStateIds; - if(statePath.count() == 1){ - int index = indexOf(id); - deletedStateIds = states[index].getBranchIds(); - states.removeAt(index); - }else if(statePath.count() > 1){ - State * stateDockingPoint = statePath[statePath.count()-2]; - deletedStateIds = statePath.last()->getBranchIds(); - stateDockingPoint->removeChildAt(stateDockingPoint->getIndexOfChild(id)); - } - for(int i=0; i<deletedStateIds.count();i++){ - emit stateDeleted(deletedStateIds[i]); - emit clearDependecies(deletedStateIds[i]); - } -} - -void Model::onStateHierarchyRequested(const State &state) -{ - emit stateHierarchyRetrieved(searchState(state.getStateId()).count() - 1); -} - -void Model::onTransitionContextMenuRequested(const int &id) -{ - emit transitionContextMenuGenerated(transitions[indexOfTransition(id)]); -} - -void Model::onCreateTransitionRequested(const int &startState, const int &stopState) -{ - Transition newTransition; - customizeTransition(&newTransition); - newTransition.setStartState(*searchState(startState).last()); - newTransition.setStopState(*searchState(stopState).last()); - newTransition.setTransitionId(generateId()); - newTransition.drawArrow(); - transitions.append(newTransition); -// qDebug()<<"transizione appena appesa"<<transitions.last().getTransitionId(); -// qDebug()<<"numero transizioni totali in lista"<<transitions.count(); - - emit transitionCreated(newTransition); -} - -void Model::onTransitionDeleteRequested(const int &id) -{ - for(int i=0;i<transitions.count();i++) - { - if(transitions[i].getTransitionId() == id) - { - emit transitionDeleted(transitions[i].getTransitionId()); - transitions.removeAt(i); - return; - } - } -} - -void Model::onTransitionEditTitleRequested(const int &id, const QString &title) -{ - int index = indexOfTransition(id); - transitions[index].setTransitionTitle(title); - transitions[index].drawArrow(); - emit transitionChanged(transitions[index]); -} - -void Model::onTransitionEditActionRequested(const int &id, const QString &action) -{ - int index = indexOfTransition(id); - transitions[index].setAction(action); -// transitions[index].drawArrow(); -// emit transitionChanged(transitions[index]); -} - -void Model::onSaveRequested() -{ - toSvg(); - toScxml(); - svg.save(); - scxml.save(); - emit scxmlSaved(scxml.getXml()); - emit svgSaved(svg.getXml()); -} - -void Model::onSaveAsRequested(const QString &path) -{ - if(!path.isEmpty()){ - QList <QString> splittedPath = path.split("."); - if(splittedPath.last() == "scxml") - scxml.setResourceRepo(path); - else - scxml.setResourceRepo(path + ".scxml"); - if(splittedPath.last() == "svg") - svg.setResourceRepo(path); - else - svg.setResourceRepo(path + ".svg"); - onSaveRequested(); - } -} - -void Model::onOpenRequested(const QString &path) -{ - if(!path.isEmpty()){ - QList <QString> splittedPath = path.split("."); - XmlObject obj; - if(splittedPath.last() == "svg"){ - if(obj.loadFromFile(path)){ - svg.setResourceRepo(path); - scxml.setResourceRepo(path.chopped(splittedPath.last().size()) + "scxml"); - onRunSvgScriptRequested(obj); - toScxml(); - emit scxmlSaved(scxml.getXml()); - emit svgSaved(svg.getXml()); - } - }else if(splittedPath.last() == "scxml"){ - if(obj.loadFromFile(path)){ - scxml.setResourceRepo(path); - svg.setResourceRepo(path.chopped(splittedPath.last().size()) + "svg"); - onRunScxmlScriptRequested(obj); - toSvg(); - emit scxmlSaved(scxml.getXml()); - emit svgSaved(svg.getXml()); - } - } - } -} - -void Model::onRunScxmlScriptRequested(const XmlObject &script) -{ - QString pathScxml = scxml.getResourceRepo(); - QString pathSvg = svg.getResourceRepo(); - clearModel(); - scxml.setResourceRepo(pathScxml); - svg.setResourceRepo(pathSvg); - fromScxml(script); // ================================================================ - refreshView(); -} - - -void Model::onRunSvgScriptRequested(const XmlObject &script) -{ - QString pathScxml = scxml.getResourceRepo(); - QString pathSvg = svg.getResourceRepo(); - clearModel(); - scxml.setResourceRepo(pathScxml); - svg.setResourceRepo(pathSvg); - fromSvg(script); // ================================================================ - refreshView(); -} - -void Model::onClearAllRequested() -{ - clearModel(); - clearView(); -} - -void Model::onCheckPathRequested() -{ - if(scxml.getResourceRepo().isEmpty() && svg.getResourceRepo().isEmpty()) - emit pathChecked(false); - else if(!scxml.getResourceRepo().isEmpty() && !svg.getResourceRepo().isEmpty()) - emit pathChecked(true); -} - -void Model::onShowCodeRequested() -{ - toSvg(); - toScxml(); - emit scxmlSaved(scxml.getXml()); - emit svgSaved(svg.getXml()); -} - - -void Model::fromScxml(const XmlObject &obj) -{ - scxml.setScxml(obj); - states = scxml.getStates(); - transitions = scxml.getTransitions(); - syncIdCounter(); -} - - -void Model::fromSvg(const XmlObject &obj) -{ - svg.setSvg(obj); - states = svg.getStates(); - transitions = svg.getTransitions(); - syncIdCounter(); -} - -void Model::refreshView() -{ - clearView(); - for(int i=0; i<states.count(); i++){ - QList <State *> branch = states[i].getBranch(); - for(int k=0; k<branch.count(); k++){ -// customizeState(branch[k]); - emit stateCreated(*branch[k]); - } - } - for(int i=0; i<transitions.count(); i++){ -// customizeTransition(&transitions[i]); - emit transitionCreated(transitions[i]); - } -} - -void Model::updateBranch(State *branchHead) -{ -// State head = branchHead; - QList <State *> branch = branchHead->getBranch(); - for(int i=0; i< branch.count() ; i++) - emit stateChanged(*branch[i]); -} - - -void Model::clearModel() -{ - svg.clear(); - scxml.clear(); - transitions.clear(); - states.clear(); - idCounter = 0; -} - - -void Model::clearView() -{ - emit clearViewRequested(); -} - -QList <State *> Model::identifySuperstates(const int &id,const QPoint &p) -{ - QList <State *> results; - QList <State *> checkList = searchState(id).last()->getBranch(); - - for(int i = 0; i<states.count(); i++) - { - results.append(states[i].deepSearchState(p,false)); - } - for(int i = 0; i<results.count(); i++) - { - for(int j = 0; j<checkList.count(); j++){ - if(results[i]->getStateId() == checkList[j]->getStateId()) - { - results.removeAt(i); - i=-1; - break; - } - } - } - qDebug()<<"risultati: "<<results.count(); - - return results; -} - - -QList <State *> Model::searchState(const int &id) -{ - QList <State *> stateList; - for(int i = 0; i<states.count(); i++){ - stateList = states[i].deepSearchStateById(id); - if(!stateList.isEmpty()){ - return stateList; - } - } - return stateList; -} - -QList<State *> Model::chopList(const QList<State *> &list, const int &chop) -{ - QList <State *> temp; - if(chop <= 0){ -// if(abs(chop) <=list.count()) -// { - for(int j = 0; j<list.count() - abs(chop); j++) - temp.append(list[j]); -// } - } else if(chop > 0){ - for(int j = abs(chop); j<list.count(); j++) - temp.append(list[j]); - } - return temp; -} - - -QList <State> Model::fromPointerToObjectList(const QList <State *> &pointerList) -{ - QList <State> result; - for(int i=0; i<pointerList.count(); i++){ - result.append(*pointerList[i]); - } - return result; -} - - -void Model::updateTransitions() -{ - for(int i=0;i<transitions.count();i++) - { -// qDebug()<<"aoooo"<<transitions.at(i).getTransitionId(); - - QList <State*> start = searchState(transitions[i].getStartState().getStateId()); - QList <State*> stop = searchState(transitions[i].getStopState().getStateId()); - if(start.count() > 0) - transitions[i].setStartState(*start.last()); - if(stop.count() > 0) - transitions[i].setStopState(*stop.last()); - transitions[i].drawArrow(); -// qDebug()<<transitions.at(i).getTransitionId(); - emit transitionChanged(transitions.at(i)); - } -} - -void Model::clearDependecies(const int &id) -{ - for(int i=0;i<transitions.count();i++) - { - if(transitions[i].getStartState().getStateId() == id || transitions[i].getStopState().getStateId() == id) - { - emit transitionDeleted(transitions[i].getTransitionId()); - transitions.removeAt(i); - i=-1; - } - } -} - -void Model::syncIdCounter() -{ - int max = 0; - for(int i=0;i<states.count();i++){ - QList <State *> branch = states[i].getBranch(); - for(int k=0;k<branch.count();k++){ - if(branch[k]->getStateId() > max) - max = branch[k]->getStateId(); - } - } - for(int i=0;i<transitions.count();i++){ - if(transitions[i].getTransitionId() > max) - max = transitions[i].getTransitionId(); - } - idCounter = max; -} - - - -//void Model::onHoveredStateRequested(const int &id) -//{ - -//} - - -void Model::onSetColorRequested(const QString &attribute, const QString &color, const int &id) -{ - if(id == -1){ - if(attribute == "Background"){ - setStatesBackgroundColor(color); - customBackground = color; - }else if(attribute == "Border"){ - setStatesBorderColor(color); - customBorder = color; - }else if(attribute == "Text"){ - setStatesTextColor(color); - customTextColor = color; - } - } else{ - if(attribute == "Background"){ - State * s = searchState(id).last(); - s->setFill(color); - s->drawStateBox(); - updateBranch(s); - updateTransitions(); -// emit stateChanged(*s); - }else if(attribute == "Border"){ - State * s = searchState(id).last(); - s->setStroke(color); - s->drawStateBox(); - updateBranch(s); - updateTransitions(); -// emit stateChanged(*s); - }else if(attribute == "Text"){ - State * s = searchState(id).last(); - s->setTextColor(color); - s->drawStateBox(); - updateBranch(s); - updateTransitions(); -// emit stateChanged(*s); - } - } -} - -void Model::onSetFontRequested(const QFont &font, const int &id) -{ - if(id == -1){ - setItemsTextFont(font); - if(font.pixelSize()) - customFontSize = font.pixelSize(); - else if(font.pointSize()) - customFontSize = font.pointSize(); - } - else { - if(indexOf(id) != -1){ - State * s = searchState(id).last(); - s->setTextFont(font); - s->drawStateBox(); - updateBranch(s); - updateTransitions(); -// emit stateChanged(*s); - }else if(indexOfTransition(id) != -1){ - int index = indexOfTransition(id); - transitions[index].setTextFont(font); - transitions[index].drawArrow(); - emit transitionChanged(transitions[index]); - } - } -} - -void Model::setStatesBackgroundColor(const QString &color) -{ - clearView(); - for(int i=0; i<states.count(); i++){ - QList <State *> branch = states[i].getBranch(); - for(int k=0; k<branch.count(); k++){ - branch[k]->setFill(color); - branch[k]->drawStateBox(); - emit stateCreated(*branch[k]); - } - } - for(int i=0; i<transitions.count(); i++){ - emit transitionCreated(transitions[i]); - } -} - -void Model::setStatesBorderColor(const QString &color) -{ - clearView(); - for(int i=0; i<states.count(); i++){ - QList <State *> branch = states[i].getBranch(); - for(int k=0; k<branch.count(); k++){ - branch[k]->setStroke(color); - branch[k]->drawStateBox(); - emit stateCreated(*branch[k]); - } - } - for(int i=0; i<transitions.count(); i++){ - emit transitionCreated(transitions[i]); - } -} - -void Model::setStatesTextColor(const QString &color) -{ - clearView(); - for(int i=0; i<states.count(); i++){ - QList <State *> branch = states[i].getBranch(); - for(int k=0; k<branch.count(); k++){ - branch[k]->setTextColor(color); - branch[k]->drawStateBox(); - emit stateCreated(*branch[k]); - } - } - for(int i=0; i<transitions.count(); i++){ - emit transitionCreated(transitions[i]); - } -} - -void Model::setItemsTextFont(const QFont &font) -{ - clearView(); - for(int i=0; i<states.count(); i++){ - QList <State *> branch = states[i].getBranch(); - for(int k=0; k<branch.count(); k++){ - branch[k]->setTextFont(font); - branch[k]->drawStateBox(); - emit stateCreated(*branch[k]); - } - } - for(int i=0; i<transitions.count(); i++){ - transitions[i].setTextFont(font); - transitions[i].drawArrow(); - emit transitionCreated(transitions[i]); - } -} - -void Model::onSetEntryRequested(const QString &action, const int &id) -{ - State *s = searchState(id).last(); - s->setEntryAction(action); - s->drawStateBox(); - updateBranch(s); - updateTransitions(); -// emit stateChanged(*s); -} - -void Model::onSetExitRequested(const QString &action, const int &id) -{ - State *s = searchState(id).last(); - s->setExitAction(action); - s->drawStateBox(); - updateBranch(s); - updateTransitions(); - // emit stateChanged(*s); -} - -void Model::customizeState(State *state) -{ - if(!customBackground.isEmpty()) - state->setFill(customBackground); - if(!customBorder.isEmpty()) - state->setStroke(customBorder); - if(!customTextColor.isEmpty()) - state->setTextColor(customTextColor); - if(customFontSize != -1) - state->setTextFont(QFont("Helvetica,sans-Serif", customFontSize)); -} - -void Model::customizeTransition(Transition *trans) -{ - if(customFontSize != -1) - trans->setTextFont(QFont("Helvetica,sans-Serif", customFontSize)); -} - - -void Model::modelTreeChanged() -{ - emit updateModelTreeRequested(states); -} - - -void Model::onChangeStateHierarchyRequested(const int &id, const int &step) -{ - QList <State *> path = searchState(id); -// qDebug()<<"model Id"<<id; - if(path.count() > 1){ - int index = path[path.count() - 2]->getIndexOfChild(*path.last()); -// qDebug()<<"index"<<index; - - int newIndex = index + step; -// qDebug()<<"newIndex"<<newIndex; - - if (newIndex >= 0 && newIndex < path[path.count() - 2]->getChildList().count()) - { - path[path.count() - 2]->swapChild(index, newIndex); -// qDebug()<<"stop"<<newIndex; - - updateBranch(path[path.count() - 2]); - updateTransitions(); - } - } else if(path.count() == 1){ - // DA IMPLEMENTARE - } -} - -void Model::onSetInitialRequested(const bool &val, const int &id) -{ - resetInitialState(id); - QList <State *> path = searchState(id); - path.last()->setInitial(val); - if(path.last()->isFinal()){ - path.last()->setFinal(false); - } - if(path.count() > 1){ - updateBranch(path[path.count() - 2]); - } - else if(path.count() == 1){ - for(int i=0; i< states.count(); i++){ - updateBranch(&states[i]); - } - } - updateTransitions(); -} - -void Model::onSetFinalRequested(const bool &val, const int &id) -{ - resetFinalState(id); - QList <State *> path = searchState(id); - path.last()->setFinal(val); - if(path.last()->isInitial()){ - path.last()->setInitial(false); - } - if(path.count() > 1){ - updateBranch(path[path.count() - 2]); - } - else if(path.count() == 1){ - for(int i=0; i< states.count(); i++){ - updateBranch(&states[i]); - } - } updateTransitions(); -} - -void Model::resetInitialState(const int &id) -{ - QList <State *> path = searchState(id); - if(path.count() > 1){ - State *father = path[path.count() - 2]; - for(int i=0; i< father->getChildList().count(); i++){ - father->getChildAt(i).setInitial(false); - } - } else if(path.count() == 1){ - for(int i=0; i< states.count(); i++){ - states[i].setInitial(false); - } - } -} - -void Model::resetFinalState(const int &id) -{ - QList <State *> path = searchState(id); - if(path.count() > 1){ - State *father = path[path.count() - 2]; - for(int i=0; i< father->getChildList().count(); i++){ - father->getChildAt(i).setFinal(false); - } - } else if(path.count() == 1){ - for(int i=0; i< states.count(); i++){ - states[i].setFinal(false); - } - } -} diff --git a/Modules/Fsm/Model/model.h b/Modules/Fsm/Model/model.h deleted file mode 100644 index 7b054f11eabf8f8f446fd2f469504dace51736a1..0000000000000000000000000000000000000000 --- a/Modules/Fsm/Model/model.h +++ /dev/null @@ -1,132 +0,0 @@ -#ifndef MODEL_H -#define MODEL_H - -#include "QObject" -#include "Modules/Fsm/Model/state.h" -#include "Modules/Fsm/Model/scxml.h" -#include "Modules/Fsm/Model/svg.h" -#include "Modules/Fsm/Model/transition.h" -#include <QList> - -class Model : public QObject -{ - Q_OBJECT - -public: - Model(QObject *parent = nullptr); - ~Model(); - - void toScxml(); - void toSvg(); - - int indexOf(const int &id) const; - int indexOfTransition(const int &id) const; - QList<State *> searchState(const int &id); - QList <State *> chopList(const QList <State *> &list, const int &chop); - - // bool superstateIsOwnChild(const State &superstate, const State &assignedState); - void updateTransitions(); - void clearDependecies(const int &id); - void clearModel(); - void clearView(); - void fromScxml(const XmlObject &obj); - void fromSvg(const XmlObject &obj); - void refreshView(); - void updateBranch(State *branchHead); - - void setStatesBackgroundColor(const QString &color); - void setStatesBorderColor(const QString &color); - void setStatesTextColor(const QString &color); - void setItemsTextFont(const QFont &font); - -private: - int generateId(); - void syncIdCounter(); - void customizeState(State *state); - void customizeTransition(Transition *trans); - void resetInitialState(const int &id); - void resetFinalState(const int &id); - - -public slots: - void onCreateDefaultState(); - void onCreateStateRequested(const QPoint &point, const QPoint &offset); - void onChangeStatePositionRequested(const int &id, const QPoint &point, const QPoint &offset); - void onResizeStateRequested(const int &id, const QPoint &point); - void onStateContextMenuRequested(const int &id); - void onStateEditTitleRequested(const int &id, const QString &title); - void onStateDeleteRequested(const int &id); - void onStateHierarchyRequested(const State &state); - void onTransitionContextMenuRequested(const int &id); - void onCreateTransitionRequested(const int &startState, const int &stopState); - void onTransitionDeleteRequested(const int &id); - void onTransitionEditTitleRequested(const int &id, const QString &title); - void onTransitionEditActionRequested(const int &id, const QString &action); - -// void onChangeStateRequested(); -// void onStateDeleteRequested(); -// void onStateIdEditRequested(); -// void onStateChildAppendRequested(); -// void onStateTransitionRequested(); -// void onTransitionTitleEditRequested(); -// void onTransitionDeleteRequested(); - void onSaveRequested(); - void onSaveAsRequested(const QString &path); - void onOpenRequested(const QString &path); - - void onRunScxmlScriptRequested(const XmlObject &script); - void onRunSvgScriptRequested(const XmlObject &script); - void onClearAllRequested(); - void onCheckPathRequested(); - void onShowCodeRequested(); - -// void onHoveredStateRequested(const int &id); - void onSetColorRequested(const QString &attribute,const QString &color, const int &id); - void onSetFontRequested(const QFont &font, const int &id); - void onSetEntryRequested(const QString &action, const int &id); - void onSetExitRequested(const QString &action, const int &id); - void onChangeStateHierarchyRequested(const int &id, const int &step); - - - void onSetInitialRequested(const bool &val, const int &id); - void onSetFinalRequested(const bool &val, const int &id); -signals: - void defaultStateCreated(const State &defState); - void stateCreated(const State &newState); - void stateChanged(const State &state); - void stateContextMenuGenerated(const State &state); - void transitionContextMenuGenerated(const Transition &trans); - void stateDeleted(const int &id); -// void superstatesBoxSizeChanged(const QList <State> &superstates); - void stateHierarchyRetrieved(const int &stateHierarchy); - void transitionCreated(const Transition &transition); -// void stateIdChanged(const int &oldId, const int &newId); - void transitionChanged(const Transition &transition); - void transitionDeleted(const int &id); - void scxmlSaved(const XmlObject &scxml); - void svgSaved(const XmlObject &scxml); - void clearViewRequested(); - void pathChecked(const bool &check); - void updateModelTreeRequested(const QList <State> &states); - -private slots: - void modelTreeChanged(); -private: - - QList <State> states; - QList <Transition> transitions; - QString filePath = ""; - int idCounter = 0; - - QList<State *> identifySuperstates(const int &id, const QPoint &p); - QList<State> fromPointerToObjectList(const QList<State *> &pointerList); - Scxml scxml; - Svg svg; - - - QString customBackground = ""; - QString customBorder = ""; - QString customTextColor = ""; - int customFontSize = -1; -}; -#endif // MODEL_H diff --git a/Modules/Fsm/Model/scxml.cpp b/Modules/Fsm/Model/scxml.cpp deleted file mode 100644 index bf742403a7753aa2cb72d6f7e239353f002030c3..0000000000000000000000000000000000000000 --- a/Modules/Fsm/Model/scxml.cpp +++ /dev/null @@ -1,332 +0,0 @@ -#include "scxml.h" - -Scxml::Scxml() -{ - scxml.setObjectName("scxml"); -// scxml.addAttribute("initial", "Idle"); -} - -Scxml::Scxml(const Scxml &other) -{ - copy(other); -} - - -Scxml::~Scxml() -{ - -} - - -void Scxml::copy(const Scxml &other) -{ - scxmlStates = other.getStates(); - scxmlTransitions = other.getTransitions(); - scxml = other.getXml(); - resourceRepo = other.getResourceRepo(); -} - -void Scxml::operator=(const Scxml &other) -{ - copy(other); -} - -void Scxml::save() -{ - scxml.writeToFile(resourceRepo); -} - -void Scxml::merge() -{ - // if(!scxmlStates.isEmpty() && !scxmlTransitions.isEmpty()) - // { - XmlObject obj("scxml"); -// obj.addAttribute("initial", "Idle"); - for(int i=0 ; i<scxmlStates.count() ; i++) - { - obj.addChild(convertHierarchyToXml(scxmlStates[i])); - } - scxml = obj; - // } -} - -// <state id="on"> -// <onentry>lampOn()</onentry> -// <transition event="SWITCH_OFF" target="off"/> -// </state> - -// <state id="off"> -// <onentry>lampOff()</onentry> -// <transition event="SWITCH_ON" target="on"/> -// </state> - -void Scxml::setResourceRepo(const QString &repo) -{ - resourceRepo = repo; -} - -QString Scxml::getResourceRepo() const -{ - return resourceRepo; -} - -void Scxml::setStateList(QList<State> states) -{ - scxmlStates = states; -} - -void Scxml::setTransList(QList<Transition> trans) -{ - scxmlTransitions = trans; -} - -QString Scxml::toString() const -{ - return scxml.toXml(); -} - -QList<State> Scxml::getStates() const -{ - return scxmlStates; -} - -QList<Transition> Scxml::getTransitions() const -{ - return scxmlTransitions; -} - - -XmlObject Scxml::getXml() const -{ - return scxml; -} - -QList<XmlObject> Scxml::buildStateTags(const State &state) -{ - QList<XmlObject> result; - - if(!state.getEntryAction().isEmpty()){ - XmlObject entry("onentry"); - entry.setTextValue(state.getEntryAction()); - result.append(entry); - } - - if(!state.getExitAction().isEmpty()){ - XmlObject exit("onexit"); - exit.setTextValue(state.getExitAction()); - result.append(exit); - } - - for(int i=0; i< scxmlTransitions.count(); i++){ - if(scxmlTransitions[i].getStartState().getStateId() == state.getStateId()){ - result.append(wrapTransition(scxmlTransitions[i])); - } - } - return result; -} - -XmlObject Scxml::wrapTransition(const Transition &transition) -{ - XmlObject t("transition"); - if(!transition.getTransitionTitle().isEmpty()){ - t.addAttribute("event", transition.getTransitionTitle()); - } - t.addAttribute("target", QString::number(transition.getStopState().getStateId())); - t.addAttribute("id", QString::number(transition.getTransitionId())); - if(!transition.getAction().isEmpty()){ - t.setTextValue(transition.getAction()); - } - return t; -} - -XmlObject Scxml::wrapState(const State &state) -{ - XmlObject newState; - if(state.isInitial()){ - newState.setObjectName("initial");} - else if(state.isFinal()){ - newState.setObjectName("final");} - else{ - newState.setObjectName("state");} - - if(!state.getTitle().isEmpty()){ - newState.addAttribute("title", state.getTitle()); - } -// QList <State> list = state.getChildList(); -// for(int i=0; i< list.count(); i++){ -// if(list[i].isInitial() && newState.getAttribute("initial").isEmpty()){ -// newState.addAttribute("initial", list[i].getTitle()); -// } -// if(list[i].isFinal() && newState.getAttribute("final").isEmpty()){ -// newState.addAttribute("final", list[i].getTitle()); -// } -// } - newState.addAttribute("id", QString::number(state.getStateId())); - newState.addChilds(buildStateTags(state)); - return newState; -} - -XmlObject Scxml::convertHierarchyToXml(const State &state) -{ - XmlObject result; - QList <State> childlist = state.getChildList(); - result = wrapState(state); - for(int i=0; i<childlist.count(); i++){ - result.addChild(convertHierarchyToXml(childlist[i])); - } - return result; -} - - -QList <Transition> Scxml::getTransitionsfromXml(const XmlObject &xml) -{ - QList <Transition> result; - if(xml.getObjectName() == "state"){ - for(int i=0; i<xml.childCount(); i++){ - if(xml.childAt(i).getObjectName() == "transition"){ - result.append(unwrapTransition(xml)); - } - } - } - for(int i=0; i<xml.childCount(); i++){ - result.append(getTransitionsfromXml(xml.childAt(i))); - } - return result; -} - -QList<State> Scxml::getStatesfromXml(const XmlObject &xml) -{ - QList <State> result; - if(xml.getObjectName() == "state" || xml.getObjectName() == "final" || xml.getObjectName() == "initial"){ - State superstate = unwrapState(xml); - for(int i=0; i<xml.childCount(); i++) - result.append(getStatesfromXml(xml.childAt(i))); - for(int i=0; i<result.count(); i++) - superstate.addChild(result[i]); - result.clear(); - result.append(superstate); - }else{ - for(int i=0; i<xml.childCount(); i++) - result.append(getStatesfromXml(xml.childAt(i))); - } - return result; -} - -State Scxml::unwrapState(const XmlObject &xml) -{ - State newState; - if(xml.getObjectName() == "initial"){ - newState.setInitial(true); - newState.setStateId(getAttribute(xml,"initial","id").toInt()); - newState.setTitle(getAttribute(xml,"initial","title")); - } else if(xml.getObjectName() == "final"){ - newState.setFinal(true); - newState.setStateId(getAttribute(xml,"final","id").toInt()); - newState.setTitle(getAttribute(xml,"final","title")); - } else if(xml.getObjectName() == "state"){ - newState.setStateId(getAttribute(xml,"state","id").toInt()); - newState.setTitle(getAttribute(xml,"state","title")); - } -// newState.setBoxPosition(QPoint(getAttribute(xml,"rect","x").toInt(), getAttribute(xml,"rect","y").toInt())); -// newState.setBoxSize(QSize(getAttribute(xml,"rect","width").toInt(), getAttribute(xml,"rect","height").toInt())); - newState.setEntryAction(getAttribute(xml,"onentry","textValue")); - newState.setExitAction(getAttribute(xml,"onexit","textValue")); -// newState.setFill(getAttribute(xml,"rect","fill")); -// newState.setFontSize(getAttribute(xml,"text","font-size")); -// newState.setStroke(getAttribute(xml,"rect","stroke")); - -// newState.setTitlePosition(QPoint(getAttribute(xml,"text","x").toInt()/* - newState.getBoxPosition().x()*/, getAttribute(xml,"text","y").toInt()/* - newState.getBoxPosition().y()*/)); -// newState.setBoxPosition(QPoint(0,0)); - - newState.drawStateBox(); - return newState; -} - -Transition Scxml::unwrapTransition(const XmlObject &xml) -{ - Transition newTransition; - newTransition.setTransitionTitle(getAttribute(xml,"transition","event")); - newTransition.setTransitionId(getAttribute(xml,"transition","id").toInt()); - - newTransition.setStartState(*searchState(getAttribute(xml,"state","id").toInt()).last()); - newTransition.setStopState(*searchState(getAttribute(xml,"transition","target").toInt()).last()); - newTransition.setAction(getAttribute(xml,"transition","textValue")); - - newTransition.drawArrow(); - - return newTransition; -} - -QString Scxml::getAttribute(const XmlObject &xml, const QString objName, const QString &attribute) -{ - if(xml.getObjectName() == objName){ - if(attribute != "textValue") - return xml.getAttribute(attribute); - else - return xml.getTextValue(); - } - for(int i=0; i<xml.childCount(); i++){ - if(xml.childAt(i).getObjectName() == objName){ - if(attribute != "textValue") - return xml.childAt(i).getAttribute(attribute); - else - return xml.childAt(i).getTextValue(); - } - } - return ""; -} - -QList <State *> Scxml::searchState(const int &id) -{ - QList <State *> stateList; - for(int i = 0; i<scxmlStates.count(); i++){ - stateList = scxmlStates[i].deepSearchStateById(id); - if(!stateList.isEmpty()){ - return stateList; - } - } - return stateList; -} - -void Scxml::setScxml(const XmlObject &xml) -{ - scxml = xml; - fromScxml(xml); -} - -void Scxml::fromScxml(const XmlObject &xml) -{ - scxmlStates = getStatesfromXml(xml); - autosetStatesBoxPosition(); - autosetStatesBoxSize(); - scxmlTransitions = getTransitionsfromXml(xml); -} - -void Scxml::clear() -{ - scxml.reset(); - scxmlTransitions.clear(); - scxmlStates.clear(); - resourceRepo.clear(); -} - -void Scxml::autosetStatesBoxSize() -{ - for( int i = 0; i<scxmlStates.count() ; i++) - { - scxmlStates[i].adaptBoxToContent(); - } -} - - -void Scxml::autosetStatesBoxPosition() -{ - for( int i = 0; i<scxmlStates.count() ; i++) - { - int x = scxmlStates[i].getBoxPosition().x() + i*(scxmlStates[i].getBoxSize().width() + 20) +20; - int y = scxmlStates[i].getBoxPosition().y() + /*i**/(scxmlStates[i].getBoxSize().height() + 20) +20; - QPoint offset(x,y); - scxmlStates[i].setBoxPosition(scxmlStates[i].getBoxPosition() + offset); - scxmlStates[i].adaptPositionToContent(); - } -} diff --git a/Modules/Fsm/Model/scxml.h b/Modules/Fsm/Model/scxml.h deleted file mode 100644 index 3a6f8d2f484839454abbeff0c9ce199b42637ee2..0000000000000000000000000000000000000000 --- a/Modules/Fsm/Model/scxml.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef SCXML_H -#define SCXML_H - -#include "Core/xmlobject.h" -#include "Modules/Fsm/Model/transition.h" -#include "Modules/Fsm/Model/state.h" - -class Scxml -{ -public: - Scxml(); - Scxml(const Scxml &other); - ~Scxml(); - - - void save(); - void merge(); - - void setScxml(const XmlObject &xml); - - void fromScxml(const XmlObject &xml); - void setResourceRepo(const QString &repo); - QString getResourceRepo() const; - void setStateList(QList <State> states); - void setTransList(QList <Transition> trans); - - QString toString() const; - - XmlObject getXml() const; - QList <State> getStates() const; - QList <Transition> getTransitions() const; - - void copy(const Scxml &other); - void operator=(const Scxml &other); - void clear(); - - QList<State *> searchState(const int &id); - -private: - QList<XmlObject> buildStateTags(const State &state); - XmlObject convertHierarchyToXml(const State &state); - - XmlObject wrapTransition(const Transition &transition); - XmlObject wrapState(const State &state); - - Transition unwrapTransition(const XmlObject &xml); - State unwrapState(const XmlObject &xml); - - QList<Transition> getTransitionsfromXml(const XmlObject &xml); - QList<State> getStatesfromXml(const XmlObject &xml); - - QString getAttribute(const XmlObject &xml, const QString objName, const QString &attribute); - - void autosetStatesBoxSize(); - void autosetStatesBoxPosition(); - -private: - QList <State> scxmlStates; - QList <Transition> scxmlTransitions; - XmlObject scxml; - QString resourceRepo = ""; -}; - -#endif // SCXML_H diff --git a/Modules/Fsm/Model/state.cpp b/Modules/Fsm/Model/state.cpp deleted file mode 100644 index 1c60b0b313ff3520f8fabf186fb65a980eab24f1..0000000000000000000000000000000000000000 --- a/Modules/Fsm/Model/state.cpp +++ /dev/null @@ -1,593 +0,0 @@ -#include "state.h" - - -State::State(QObject *parent) : QObject(parent) -{ - -} - -State::State(const State &other) : QObject() -{ - copy(other); -} - -State::~State() -{ - -} - -void State::operator =(const State &other) -{ - copy(other); -} - -void State::copy(const State &other) -{ - stateId = other.getStateId(); - title = other.getTitle(); - childList = other.getChildList(); - - onEntry = other.getEntryAction(); - onExit = other.getExitAction(); - - xml = other.getXml(); - boxPosition = other.getBoxPosition(); - - boxSize = other.getBoxSize(); - titlePosition = other.getTitlePosition(); - font_family = other.getFontFamily(); - font_size = other.getFontSize(); - text_anchor = other.getTextAnchor(); - stroke = other.getStroke(); - fill = other.getFill(); - text_color = other.getTextColor(); - - final = other.isFinal(); - initial = other.isInitial(); -} - -void State::setStateId(const int &id) -{ - stateId = id; -} -void State::setTitle(const QString &t) -{ - title = t; -} -void State::addChild(const State &s) -{ - childList.append(s); -} - -int State::getStateId() const -{ - return stateId; -} - -QString State::getTitle() const -{ - return title; -} - -State State::getChildAt(const int &index) const -{ - return childList[index]; -} - -QList<State> State::getChildList() const -{ - return childList; -} - -XmlObject State::getXml() const -{ - return xml; -} - - -QPoint State::getBoxPosition() const -{ - return boxPosition; -} - - -QString State::getStroke() const -{ - return stroke; -} - - - -QString State::getFontSize() const -{ - return font_size; -} - - -QSize State::getBoxSize() const -{ - return boxSize; -} - - -QPoint State::getTitlePosition() const -{ - return titlePosition; -} - -QString State::getTextColor() const -{ - return text_color; -} - -QString State::getFontFamily() const -{ - return font_family; -} - -QString State::getTextAnchor() const -{ - return text_anchor; -} - -QString State::getFill() const -{ - return fill; -} - - - - - -void State::setBoxPosition(const QPoint &p) -{ - for(int i=0; i<childList.count(); i++) - { - childList[i].adaptContentToBox(p - boxPosition); - } - boxPosition = p; -} - - -void State::adaptContentToBox(const QPoint &deltaPosition) -{ - boxPosition = boxPosition + deltaPosition; - for(int i=0; i<childList.count(); i++) - { - childList[i].adaptContentToBox(deltaPosition); - } -} - -void State::setStroke(const QString &s) -{ - stroke = s; -} - - -void State::setFontSize(const QString &s) -{ - font_size = s; -} - - -void State::setFill(const QString &f) -{ - fill = f; -} - -void State::setBoxSize(const QSize &size) -{ - boxSize = size; -} - -void State::setEntryAction(const QString &action) -{ - onEntry = action; -} - -void State::setExitAction(const QString &action) -{ - onExit = action; -} - -void State::setTitlePosition(const QPoint &pos) -{ - titlePosition = pos; -} - -void State::setFontFamily(const QString &family) -{ - font_family = family; -} - -void State::setTextAnchor(const QString &anchor) -{ - text_anchor = anchor; -} - -void State::setTextColor(const QString &color) -{ - text_color = color; -} - - - -void State::drawStateBox() -{ - QSize s(boxSize.width(), boxSize.height()); - xml.reset(); - xml.setObjectName("svg"); - XmlObject rect("rect"); - XmlObject txt("text"); - - xml.addAttribute("height", QString::number(s.height())); - xml.addAttribute("width", QString::number(s.width())); - xml.addAttribute("entry", onEntry); - xml.addAttribute("exit", onExit); - -// rect.addAttribute("id", QString::number(stateId)); - rect.addAttribute("fill", fill); - rect.addAttribute("fill-rule", "nonzero"); - rect.addAttribute("height", QString::number(s.height())); - rect.addAttribute("width", QString::number(s.width())); - rect.addAttribute("stroke", stroke); - rect.addAttribute("x", "0"); - rect.addAttribute("y", "0"); - rect.addAttribute("rx", "10"); - rect.addAttribute("stroke-width", "3"); - - txt.addAttribute("text-anchor", text_anchor); - txt.addAttribute("fill", text_color); - txt.addAttribute("x", QString::number(s.width()/2)); - txt.addAttribute("y", QString::number(QSize(220,28).height()/2 + font_size.toInt()/2)); - txt.addAttribute("font-family", font_family); - txt.addAttribute("font-size", font_size); - txt.setTextValue(title); - - xml.addChild(rect); - xml.addChild(txt); -} - - -void State::removeChildAt(const int &index) -{ - childList.removeAt(index); -} - - - - - - - - - - - - - - -//void State::addChild(State state) -//{ -//// childList->append(state); -//// drawStateBox(); -//// placeChildLabel(); -//} - -////void State::placeChildLabel() -////{ -//// int offset_y = boxSize.height(); -//// for(int i=0; i<childList->count(); i++){ -//// (*childList)[i].getLabel()->move(position + QPoint(0, offset_y)); -//// (*childList)[i].setPosition(position + QPoint(0, offset_y)); -//// offset_y = offset_y + (*childList)[i].getLabel()->size().height(); -//// } -////} - - - - -//int State::childCount() -//{ -// if(childList != nullptr) -// return childList->count(); -// else -// return 0; -//} - - -QList <State *> State::deepSearchState(const QPoint &p, const bool &ignoreChild) -{ - QList <State *> list; - if(!xml.isEmpty()){ - int minX = boxPosition.x(); - int maxX = minX + boxSize.width(); - int minY = boxPosition.y(); - int maxY = minY + boxSize.height(); - if(p.x()>=minX && p.x()<=maxX && p.y()>=minY && p.y()<=maxY) - list.append(this); - - if(!childList.isEmpty() && !ignoreChild) - { - for(int i=0; i<childList.count(); i++) - { -// int minX = childList[i].getBoxPosition().x(); -// int maxX = minX + childList[i].getBoxSize().width(); -// int minY = childList[i].getBoxPosition().y(); -// int maxY = minY + childList[i].getBoxSize().height(); -// if(p.x()>=minX && p.x()<=maxX && p.y()>=minY && p.y()<=maxY) -// list.append(&childList[i]); - list.append(childList[i].deepSearchState(p, false)); - } - } - } - return list; -} - - - -//QList <State *> State::deepSearchState(const QString &str, const bool &ignoreChild) -//{ - -// QList <State *> list; -// if(label != nullptr){ - -// if(stroke == str) -// list.append(this); - -// if(childList != nullptr && !ignoreChild) -// { -// if(!childList->isEmpty()){ - -// for(int i=0; i<childList->count(); i++) -// { -// if((*childList)[i].getStroke() == str) -// list.append(&(*childList)[i]); -// list.append((*childList)[i].deepSearchState(str)); -// } -// } -// } -// } -// return list; -//} - - - -//QList <State *> State::deepSearchStateId(const QString &str, const bool &ignoreChild) -//{ -// QList <State *> list; -// if(label != nullptr){ - -// if(stateId == str) -// list.append(this); - -// if(childList != nullptr && !ignoreChild) -// { -// if(!childList->isEmpty()){ - -// for(int i=0; i<childList->count(); i++) -// { -// if((*childList)[i].getStateId() == str) -// list.append(&(*childList)[i]); -// list.append((*childList)[i].deepSearchStateId(str)); -// } -// } -// } -// } -// return list; -//} - -void State::adaptBoxToContent() -{ - if(!childList.isEmpty()) - { - for(int j=0; j<childList.count(); j++) - { - childList[j].adaptBoxToContent(); - } -// double margin = 0.2; - - for(int i=0; i<childList.count(); i++) - { - if(childList[i].getBoxPosition().x() <= boxPosition.x()) - boxPosition.setX(childList[i].getBoxPosition().x() - 20); - if(childList[i].getBoxPosition().y() <= boxPosition.y()) - boxPosition.setY(childList[i].getBoxPosition().y() - 20); - } - - for(int i=0; i<childList.count(); i++) - { - int val_w = childList[i].getBoxPosition().x() - boxPosition.x() + childList[i].getBoxSize().width(); - int val_h = childList[i].getBoxPosition().y() - boxPosition.y() + childList[i].getBoxSize().height(); - if(val_w > boxSize.width()) - boxSize.setWidth(val_w); - if(val_h > boxSize.height()) - boxSize.setHeight(val_h); - } -// boxSize = boxSize + QSize(boxSize.width()*margin,boxSize.width()*margin); - drawStateBox(); - } -} - -//QList <int> State::getStateChildTree(const QPoint &p) -//{ -// QList <int> list; -// if(!xml.isEmpty()) -// { -// int minX = boxPosition.x(); -// int maxX = minX + boxSize.width(); -// int minY = boxPosition.y(); -// int maxY = minY + boxSize.height(); -// if(p.x()>=minX && p.x()<=maxX && p.y()>=minY && p.y()<=maxY) -// list.append(stateId); - -// if(!childList.isEmpty()) -// { -// for(int i=0; i<childList.count(); i++) -// { -// int minX = childList[i].getBoxPosition().x(); -// int maxX = minX + childList[i].getBoxSize().width(); -// int minY = childList[i].getBoxPosition().y(); -// int maxY = minY + childList[i].getBoxSize().height(); -// if(p.x()>=minX && p.x()<=maxX && p.y()>=minY && p.y()<=maxY) -// list.append(childList[i].getStateId()); -// list.append(childList[i].getStateChildTree(p)); -// } -// } -// } -// return list; -//} - - -QList <State*> State::deepSearchStateById(const int &id) -{ - QList <State*> stateList; - if(stateId == id){ - stateList.append(this); - return stateList; - } - else { - for(int i=0; i<childList.count(); i++) - { - stateList = childList[i].deepSearchStateById(id); - if(!stateList.isEmpty()){ - QList <State*> temp; - temp.append(this); - temp.append(stateList); - return temp; - } - } - return stateList; - } -} - - - -int State::getIndexOfChild(const State &state) const -{ - for(int i=0; i<childList.count(); i++){ - if(childList[i].getStateId() == state.getStateId()) - return i; - } - return -1; -} - - -int State::getIndexOfChild(const int &stateId) const -{ - for(int i=0; i<childList.count(); i++){ - if(childList[i].getStateId() == stateId) - return i; - } - return -1; -} - -QList <State *> State::getBranch() -{ - QList <State *> list; - list.append(this); - if(!childList.isEmpty()){ - for(int i=0; i<childList.count(); i++) - { - list.append(childList[i].getBranch()); - } - } - return list; -} - - -QList <int> State::getBranchIds() -{ - QList <int> result; - QList <State *> branch = getBranch(); - for(int i=0 ; i<branch.count(); i++) - { - result.append(branch[i]->getStateId()); - } - return result; -} - -QString State::getEntryAction() const -{ - return onEntry; -} - -QString State::getExitAction() const -{ - return onExit; -} - -void State::adaptPositionToContent() -{ - for(int i=0;i<childList.count(); i++){ - int x = boxPosition.x() + i*(childList[i].getBoxSize().width() + 20) +20; - int y = boxPosition.y() + i*(childList[i].getBoxSize().height() + 20) +20; - QPoint offset(x,y); - childList[i].setBoxPosition(boxPosition + offset); - childList[i].adaptPositionToContent(); - } -} - -void State::resize(const QPoint &point) -{ - int delta_X = abs(boxPosition.x() - point.x()); - int delta_Y = abs(boxPosition.y() - point.y()); - - if(point.x() > boxPosition.x() && point.y() > boxPosition.y()){ - boxSize = QSize(delta_X, delta_Y); - } - else if(point.x() < boxPosition.x() && point.y() < boxPosition.y()){ - boxSize = QSize(delta_X, delta_Y); - setBoxPosition(point); - } - else if(point.x() > boxPosition.x() && point.y() < boxPosition.y()){ - boxSize = QSize(delta_X, delta_Y); - setBoxPosition(QPoint(boxPosition.x(), boxPosition.y() - delta_Y)); - } - else if(point.x() < boxPosition.x() && point.y() > boxPosition.y()){ - boxSize = QSize(delta_X, delta_Y); - setBoxPosition(QPoint(boxPosition.x() - delta_X, boxPosition.y())); - } - drawStateBox(); -} - - - -void State::setTextFont(const QFont &font) -{ -// font_family = font.family(); - if(font.pixelSize() != -1) - font_size = QString::number(font.pixelSize()); - else if(font.pointSize() != -1) - font_size = QString::number(font.pointSize()); -} - - -void State::swapChild(const int &index_1, const int index_2) -{ - State state_2 = childList[index_2]; - childList[index_2] = childList[index_1]; - childList[index_1] = state_2; -} - - - -void State::setFinal(const bool &val) -{ - final = val; -} - -void State::setInitial(const bool &val) -{ - initial = val; -} - -bool State::isFinal() const -{ - return final; -} - -bool State::isInitial() const -{ - return initial; -} diff --git a/Modules/Fsm/Model/state.h b/Modules/Fsm/Model/state.h deleted file mode 100644 index e294e2953b128da278575a9a5a56552220f293ba..0000000000000000000000000000000000000000 --- a/Modules/Fsm/Model/state.h +++ /dev/null @@ -1,106 +0,0 @@ -#ifndef STATE_H -#define STATE_H - -#include <QObject> -#include <QtWidgets> -#include "Core/xmlobject.h" - -class State : public QObject -{ - Q_OBJECT -public: - State(QObject *parent = nullptr); - State(const State &other); - ~State(); - - void setFinal(const bool &val); - void setInitial(const bool &val); - bool isFinal() const; - bool isInitial() const; - - void addChild(const State &s); - - void drawStateBox(); - - void setStateId(const int &id); - void setTitle(const QString &t); - void setBoxPosition(const QPoint &p); - void setStroke(const QString &s); - void setFontSize(const QString &s); - void setFill(const QString &f); - void setBoxSize(const QSize &size); - void setEntryAction(const QString &action); - void setExitAction(const QString &action); - void setTitlePosition(const QPoint &pos); - void setFontFamily(const QString &family); - void setTextAnchor(const QString &anchor); - void setTextColor(const QString &color); - - void removeChildAt(const int &index); - void adaptBoxToContent(); - - QList <State *> deepSearchState(const QPoint &p, const bool &ignoreChild = true); -// QList<State *> deepSearchState(const QString &str, const bool &ignoreChild = true); -// QList<State *> deepSearchStateId(const QString &str, const bool &ignoreChild = true); - - int getStateId() const; - QString getTitle() const; - QList <State> getChildList() const; - State getChildAt(const int &index) const; - XmlObject getXml() const; - QPoint getBoxPosition() const; - QString getStroke() const; - QString getFontSize() const; - QSize getBoxSize() const; - QString getFill() const; - QString getTextAnchor() const; - QString getFontFamily() const; - QPoint getTitlePosition() const; - QString getTextColor() const; - void operator =(const State &other); - QList <int> getStateChildTree(const QPoint &p); - QList <State*> deepSearchStateById(const int &id); -// void setSelfPath - int getIndexOfChild(const State &state) const; - int getIndexOfChild(const int &stateId) const; - - QList<State *> getBranch(); - QList<int> getBranchIds(); - - QString getEntryAction() const; - QString getExitAction() const; - - void adaptPositionToContent(); - void resize(const QPoint &point); - - void setTextFont(const QFont &font); - void swapChild(const int &index_1, const int index_2); -private: - void copy(const State &other); - void adaptContentToBox(const QPoint &deltaPosition); - -private: - int stateId; - QString title; - - QList <State> childList; - - QString onEntry; - QString onExit; - bool initial = false; - bool final = false; - - XmlObject xml; - - QPoint boxPosition = QPoint(0,0); - QSize boxSize = QSize(220,28); - QPoint titlePosition = QPoint(110,14); - QString font_family = "Helvetica,sans-Serif"; - QString font_size = "12"; - QString text_anchor = "middle"; - QString text_color = "#000000"; - QString stroke = "#000000"; - QString fill = "#e6e6e6"; -}; - -#endif // STATE_H diff --git a/Modules/Fsm/Model/svg.cpp b/Modules/Fsm/Model/svg.cpp deleted file mode 100644 index 5e11cbbaf44f7b0e2d467f8c20607254d9965055..0000000000000000000000000000000000000000 --- a/Modules/Fsm/Model/svg.cpp +++ /dev/null @@ -1,384 +0,0 @@ -#include "svg.h" - -Svg::Svg() -{ - -} - -Svg::Svg(const Svg &other) -{ - copy(other); -} - -Svg::~Svg() -{ - -} - -void Svg::merge() -{ - - XmlObject shell = createFrame(setShellSize()); - joinStates(shell); -} - -void Svg::save() -{ - svg.writeToFile(resourceRepo); -} - -void Svg::setResourceRepo(const QString &repo) -{ - resourceRepo = repo; -} - -QString Svg::getResourceRepo() const -{ - return resourceRepo; -} - - -void Svg::joinStates(XmlObject &obj) -{ - for (int i=0; i<svgStates.count() ; i++ ) { - obj.addChild(convertHierarchyToXml(svgStates[i])); - } - for(int j=0; j<svgTransitions.count() ; j++ ){ - obj.addChild(wrapTransition(svgTransitions[j])); - } - svg = obj; -} - -QSize Svg::setShellSize() -{ - int max_x= 0; - int max_y = 0; - int max_size_x = 0; - int max_size_y = 0; - int min_x = 100000; - int min_y = 100000; -// qDebug()<<max_y; - for (int i=0; i<svgStates.count() ; i++ ) { -// qDebug()<<scxmlStates[i].getLabel()->pos()<<" "<<scxmlStates[i].getPosition(); - if(svgStates[i].getBoxPosition().x() > max_x) max_x = svgStates[i].getBoxPosition().x(); - if(svgStates[i].getBoxPosition().y() > max_y) max_y = svgStates[i].getBoxPosition().y(); - if(svgStates[i].getBoxPosition().x() < min_x) min_x = svgStates[i].getBoxPosition().x(); - if(svgStates[i].getBoxPosition().y() < min_y) min_y = svgStates[i].getBoxPosition().y(); - if(svgStates[i].getBoxSize().width() > max_size_x) max_size_x = svgStates[i].getBoxSize().width(); - if(svgStates[i].getBoxSize().height() > max_size_y) max_size_y = svgStates[i].getBoxSize().height(); -// qDebug()<<max_y; - } - -// qDebug()<<max_x<<" "<<max_size_x<<" "<<min_x; -// qDebug()<<max_y<<" "<<max_size_y<<" "<<min_y; - int width = max_x + max_size_x + min_x; - int height = max_y + max_size_y + min_y; - - return QSize(width, height); -} - -void Svg::clear() -{ - svg.reset(); - svgTransitions.clear(); - svgStates.clear(); - resourceRepo.clear(); -} - -XmlObject Svg::wrapState(State &state) -{ - XmlObject temp = state.getXml(); - temp.clearAttributes(); - temp.setObjectName("g"); - temp.addAttribute("id", QString::number(state.getStateId())); - temp.addAttribute("class", "node"); - temp.addAttribute("entry", state.getEntryAction()); - temp.addAttribute("exit", state.getExitAction()); - - if(state.isInitial()) - temp.addAttribute("initial", "true"); - else if(state.isFinal()) - temp.addAttribute("final", "true"); -// QList <State> list = state.getChildList(); -// for(int i=0; i< list.count(); i++){ -// if(list[i].isInitial() && temp.getAttribute("initial").isEmpty()){ -// temp.addAttribute("initial", list[i].getTitle()); -// } -// if(list[i].isFinal() && temp.getAttribute("final").isEmpty()){ -// temp.addAttribute("final", list[i].getTitle()); -// } -// } - - moveState(state.getBoxPosition(), &temp); - return temp; -} - -XmlObject Svg::convertHierarchyToXml(State &state) -{ - XmlObject result; - QList <State> childlist = state.getChildList(); - result = wrapState(state); - for(int i=0; i<childlist.count(); i++){ - result.addChild(convertHierarchyToXml(childlist[i])); - } - return result; -} - - -XmlObject Svg::wrapTransition(Transition &trans) -{ - XmlObject tempArrow = trans.getArrowXml(); // OCCHIO QUANDO AGGIUNGI IL TESTO - XmlObject tempTitle = trans.getTitleXml(); - moveTransitionArrow(trans.getArrowPosition(), &tempArrow); - tempArrow.getChild(0)->addAttribute("id-start", QString::number(trans.getStartState().getStateId())); - tempArrow.getChild(0)->addAttribute("id-stop", QString::number(trans.getStopState().getStateId())); - tempArrow.getChild(0)->addAttribute("id", QString::number(trans.getTransitionId())); - tempArrow.getChild(0)->addAttribute("action",trans.getAction()); - tempArrow.getChild(0)->addAttribute("class", "edge"); - - moveText(trans.getTitlePosition(), &tempTitle); - tempArrow.getChild(0)->addChild(*tempTitle.getChild(0)->getChild(0)); - return *tempArrow.getChild(0); -} - -XmlObject Svg::createFrame(const QSize &p) -{ - XmlObject frame("svg"); - frame.addAttribute("width", QString::number(p.width())); - frame.addAttribute("height", QString::number(p.height())); - return frame; -} - -void Svg::moveState(QPoint point, XmlObject *stateToMove) -{ - QList <XmlObject *> scopes = stateToMove->deepSearchObjects("rect"); - for(int i = 0 ; i < scopes.count() ; i++){ - scopes[i]->addAttribute("x", QString::number(point.x())); - scopes[i]->addAttribute("y", QString::number(point.y())); - } - moveText(point, stateToMove); -} - -void Svg::moveText(QPoint p, XmlObject *obj) -{ - QList <XmlObject *> scopes = obj->deepSearchObjects("text"); - for(int i = 0 ; i < scopes.count() ; i++){ - int x = scopes[i]->getAttribute("x").toInt(); - int y = scopes[i]->getAttribute("y").toInt(); - scopes[i]->addAttribute("x", QString::number(x + p.x())); - scopes[i]->addAttribute("y", QString::number(y + p.y())); - } -} - -void Svg::moveTransitionArrow(QPoint point, XmlObject *transitionToMove) -{ - - QList <XmlObject *> scopes = transitionToMove->deepSearchObjects("polygon"); - - for(int i = 0 ; i < scopes.count() ; i++){ - QString p = scopes[i]->getAttribute("points"); - QList <QString> spaceSplit = p.split(" "); - QList <QString> commaSplit; - QList <QPoint> arrowPoints; - for(int i = 0; i < spaceSplit.count() ; i++){ - commaSplit = spaceSplit[i].split(","); - arrowPoints.append(QPoint(commaSplit.first().toInt(), commaSplit.last().toInt()) + point); - } - QString buffer = ""; - for(int i = 0; i < arrowPoints.count() ; i++){ - if(i == arrowPoints.count()-1) buffer.append(QString::number(arrowPoints[i].x()) + "," + QString::number(arrowPoints[i].y())); - else buffer.append(QString::number(arrowPoints[i].x()) + "," + QString::number(arrowPoints[i].y()) + " "); - } - - scopes[i]->addAttribute("points", buffer); - } -} - - - - - -void Svg::setStateList(QList<State> states) -{ - svgStates = states; -} -void Svg::setTransList(QList<Transition> trans) -{ - svgTransitions = trans; -} - - -//QList <XmlObject *> Scxml::getScopes(QList <XmlObject *> list, const QString &attr, const QString &val) -//{ -// QList <XmlObject *> scopes; -// for(int i = 0; i < list.count(); i++) -// { -// if(list.at(i)->getAttribute(attr) == val) -// scopes.append(list.at(i)); -// } -// return scopes; -//} - - -QString Svg::toString() const -{ - return svg.toXml(); -} - -QList<State> Svg::getStates() const -{ - return svgStates; -} - -QList<Transition> Svg::getTransitions() const -{ - return svgTransitions; -} - -void Svg::copy(const Svg &other) -{ - svgStates = other.getStates(); - svgTransitions = other.getTransitions(); - svg = other.getXml(); - resourceRepo = other.getResourceRepo(); -} - -void Svg::operator=(const Svg &other) -{ - copy(other); -} - -XmlObject Svg::getXml() const -{ - return svg; -} - - - - -Transition Svg::unwrapTransition(const XmlObject &xml) -{ - Transition newTransition; - newTransition.setTransitionTitle(getAttribute(xml,"text","textValue")); - newTransition.setTransitionId(getAttribute(xml,"g","id").toInt()); - - newTransition.setStartState(*searchState(getAttribute(xml,"g","id-start").toInt()).last()); - newTransition.setStopState(*searchState(getAttribute(xml,"g","id-stop").toInt()).last()); - newTransition.setAction(getAttribute(xml,"g","action")); -// event = other.getEvent(); - newTransition.setFontFamily(getAttribute(xml,"text","font-family")); - newTransition.setFontSize(getAttribute(xml,"text","font-size")); - newTransition.setTextAnchor(getAttribute(xml,"text","text-anchor")); - newTransition.setTextColor(getAttribute(xml,"text","fill")); - newTransition.setStroke(getAttribute(xml,"polygon","stroke")); - newTransition.setFill("none"); - newTransition.drawArrow(); - - return newTransition; -} - - -QList <Transition> Svg::getTransitionsfromXml(const XmlObject &xml) -{ - QList <Transition> result; - if(xml.getObjectName() == "g" && xml.getAttribute("class") == "edge"){ - result.append(unwrapTransition(xml)); - } - for(int i=0; i<xml.childCount(); i++){ - result.append(getTransitionsfromXml(xml.childAt(i))); - } - return result; -} - -QList<State> Svg::getStatesfromXml(const XmlObject &xml) -{ - QList <State> result; - if(xml.getObjectName() == "g" && xml.getAttribute("class") == "node"){ - State superstate = unwrapState(xml); - for(int i=0; i<xml.childCount(); i++) - result.append(getStatesfromXml(xml.childAt(i))); - for(int i=0; i<result.count(); i++) - superstate.addChild(result[i]); - result.clear(); - result.append(superstate); - }else{ - for(int i=0; i<xml.childCount(); i++) - result.append(getStatesfromXml(xml.childAt(i))); - } - return result; -} - -State Svg::unwrapState(const XmlObject &xml) -{ - State newState; - if(!getAttribute(xml,"g","initial").isEmpty()){ - newState.setInitial(true); - } - else if(!getAttribute(xml,"g","final").isEmpty()){ - newState.setFinal(true); - } - newState.setStateId(getAttribute(xml,"g","id").toInt()); - newState.setBoxPosition(QPoint(getAttribute(xml,"rect","x").toInt(), getAttribute(xml,"rect","y").toInt())); - newState.setBoxSize(QSize(getAttribute(xml,"rect","width").toInt(), getAttribute(xml,"rect","height").toInt())); - newState.setEntryAction(getAttribute(xml,"g","entry")); - newState.setExitAction(getAttribute(xml,"g","exit")); - newState.setFill(getAttribute(xml,"rect","fill")); - newState.setFontSize(getAttribute(xml,"text","font-size")); - newState.setStroke(getAttribute(xml,"rect","stroke")); - newState.setTitle(getAttribute(xml,"text","textValue")); - -// newState.setTitlePosition(QPoint(getAttribute(xml,"text","x").toInt()/* - newState.getBoxPosition().x()*/, getAttribute(xml,"text","y").toInt()/* - newState.getBoxPosition().y()*/)); -// newState.setBoxPosition(QPoint(0,0)); - newState.setFontFamily(getAttribute(xml,"text","font-family")); - newState.setTextAnchor(getAttribute(xml,"text","text-anchor")); - newState.setTextColor(getAttribute(xml,"text","stroke")); - newState.drawStateBox(); - return newState; -} - -QString Svg::getAttribute(const XmlObject &xml, const QString objName, const QString &attribute) -{ - if(xml.getObjectName() == objName){ - if(attribute != "textValue") - return xml.getAttribute(attribute); - else - return xml.getTextValue(); - } - for(int i=0; i<xml.childCount(); i++){ - if(xml.childAt(i).getObjectName() == objName){ - if(attribute != "textValue") - return xml.childAt(i).getAttribute(attribute); - else - return xml.childAt(i).getTextValue(); - } - } - return ""; -} - -void Svg::setSvg(const XmlObject &xml) -{ - svg = xml; - fromSvg(xml); -} - -void Svg::fromSvg(const XmlObject &xml) -{ - svgStates = getStatesfromXml(xml); - svgTransitions = getTransitionsfromXml(xml); -// qDebug()<<svgStates.count(); -// qDebug()<<svgTransitions.count(); -} - - - -QList <State *> Svg::searchState(const int &id) -{ - QList <State *> stateList; - for(int i = 0; i<svgStates.count(); i++){ - stateList = svgStates[i].deepSearchStateById(id); - if(!stateList.isEmpty()){ - return stateList; - } - } - return stateList; -} diff --git a/Modules/Fsm/Model/svg.h b/Modules/Fsm/Model/svg.h deleted file mode 100644 index 47f5e0fea5568d2cde13cf9b0bd3536f586bdc2b..0000000000000000000000000000000000000000 --- a/Modules/Fsm/Model/svg.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef SVG_H -#define SVG_H - -#include "Core/xmlobject.h" -#include "Modules/Fsm/Model/transition.h" -#include "Modules/Fsm/Model/state.h" - -class Svg -{ -public: - Svg(); - Svg(const Svg &other); - ~Svg(); - - void merge(); - void save(); - void setResourceRepo(const QString &repo); - QString getResourceRepo() const; - void setStateList(QList <State> states); - void setTransList(QList <Transition> trans); - - QString toString() const; - - - XmlObject getXml() const; - QList <State> getStates() const; - QList <Transition> getTransitions() const; - - void copy(const Svg &other); - void operator=(const Svg &other); - void clear(); - - void setSvg(const XmlObject &xml); - void fromSvg(const XmlObject &xml); - - QList<State *> searchState(const int &id); -private: - XmlObject wrapState(State &state); - XmlObject wrapTransition(Transition &trans); - - Transition unwrapTransition(const XmlObject &xml); - State unwrapState(const XmlObject &xml); - - QList<Transition> getTransitionsfromXml(const XmlObject &xml); - QList<State> getStatesfromXml(const XmlObject &xml); - - XmlObject createFrame(const QSize &p); - void moveState(QPoint point, XmlObject *stateToMove); - void moveTransitionArrow(QPoint point, XmlObject *transitionToMove); - void moveText(QPoint p, XmlObject *obj); - XmlObject convertHierarchyToXml(State &state); - -// QList <XmlObject *> getScopes(QList <XmlObject *> list, const QString &attr, const QString &val); - - void joinStates(XmlObject &obj); - QSize setShellSize(); - - QString getAttribute(const XmlObject &xml, const QString objName, const QString &attribute); - -private: - QList <State> svgStates; - QList <Transition> svgTransitions; - XmlObject svg; - QString resourceRepo = ""; -}; - -#endif // SVG_H diff --git a/Modules/Fsm/Model/transition.cpp b/Modules/Fsm/Model/transition.cpp deleted file mode 100644 index 6a7dbc0e675e995fa0bf689633da4eae089fe289..0000000000000000000000000000000000000000 --- a/Modules/Fsm/Model/transition.cpp +++ /dev/null @@ -1,492 +0,0 @@ -#include "transition.h" - -Transition::Transition(QObject *parent) : QObject(parent) -{ - -} - -Transition::Transition(const Transition &other) : QObject() -{ - copy(other); -} - -Transition::~Transition() -{ - -} - -void Transition::setTransitionId(const int &id) -{ - transitionId = id; -} - -int Transition::getTransitionId() const -{ - return transitionId; -} - -void Transition::setStartState(const State &s) -{ - startState = s; - isStartEmptyBool = false; -} -void Transition::setStopState(const State &s) -{ - stopState = s; - isStopEmptyBool = false; -} - -QPoint Transition::getArrowPosition() const -{ - return boxPosition; -} - -QPoint Transition::getTitlePosition() const -{ - return titlePosition; -} - -State Transition::getStartState() const -{ - return startState; -} - -State Transition::getStopState() const -{ - return stopState; -} - -QString Transition::getEvent() const -{ - return event; -} - -QString Transition::getAction() const -{ - return action; -} - -void Transition::setEvent(const QString &e) -{ - event = e; -} - -void Transition::setAction(const QString &a) -{ - action = a; -} - -void Transition::copy(const Transition &other) -{ - startState = other.getStartState(); - stopState = other.getStopState(); - transitionId = other.getTransitionId(); - event = other.getEvent(); - action = other.getAction(); - isStartEmptyBool = other.isStartEmpty(); - isStopEmptyBool = other.isStopEmpty(); - transitionTitle = other.getTransitionTitle(); - titleXml = other.getTitleXml(); - arrowXml = other.getArrowXml(); - start = other.getStartPoint(); - end = other.getStopPoint(); - boxPosition = other.getArrowPosition(); - boxSize = other.getArrowBoxSize(); - titlePosition = other.getTitlePosition(); - - font_family = other.getFontFamily(); - font_size = other.getFontSize(); - text_anchor = other.getTextAnchor(); - stroke = other.getStroke(); - fill = other.getFill(); - text_color = other.getTextColor(); -} - -bool Transition::isStartEmpty() const -{ - return isStartEmptyBool; -} - -bool Transition::isStopEmpty() const -{ - return isStopEmptyBool; -} - - - - - -void Transition::drawArrow() -{ - //necessario implementare isEmpty() per XmlObjects - if(!isStartEmpty() && !isStopEmpty()){ - - if(startState.getStateId() != stopState.getStateId()){ - QPoint startPos = startState.getBoxPosition(); - QPoint stopPos = stopState.getBoxPosition(); - - QSize startSize = startState.getBoxSize(); - QSize stopSize = stopState.getBoxSize(); - - QList <QPoint> startSides; - startSides.append(QPoint(startSize.width()/2, 0) + startPos); - startSides.append(QPoint(startSize.width(), startSize.height()/2) + startPos); - startSides.append(QPoint(startSize.width()/2, startSize.height()) + startPos); - startSides.append(QPoint(0, startSize.height()/2) + startPos); - - QList <QPoint> stopSides; - stopSides.append(QPoint(stopSize.width()/2, 0) + stopPos); - stopSides.append(QPoint(stopSize.width(), stopSize.height()/2) + stopPos); - stopSides.append(QPoint(stopSize.width()/2, stopSize.height()) + stopPos); - stopSides.append(QPoint(0, stopSize.height()/2) + stopPos); - - double min_distance = sqrt((abs(startSides.first().x() - stopSides.first().x() )^2) + (abs(startSides.first().y() - stopSides.first().y())^2)) ; - for(int i=0;i<startSides.count();i++){ - for(int k=0;k<stopSides.count();k++){ - double dist = sqrt( (abs(startSides[i].x() - stopSides[k].x() )^2) + (abs(startSides[i].y() - stopSides[k].y())^2) ); - if(dist < min_distance){ - min_distance = dist; - start = startSides.at(i); - end = stopSides.at(k); - } - } - } - - QSize labelSize; - - if(start.x() == end.x()){ - labelSize.setHeight(abs(start.y() - end.y())); - labelSize.setWidth(100); - }else if(start.y() == end.y()){ - labelSize.setHeight(100); - labelSize.setWidth(abs(start.x() - end.x())); - }else{ - labelSize.setHeight(abs(start.y() - end.y())); - labelSize.setWidth(abs(start.x() - end.x())); - } - - - - XmlObject svg("svg"); - svg.addAttribute("height", QString::number(labelSize.height())); - svg.addAttribute("width", QString::number(labelSize.width())); - - XmlObject g("g"); - - XmlObject p("polygon"); - p.addAttribute("fill", "none"); - p.addAttribute("stroke", "#000000"); - XmlObject a("polygon"); - a.addAttribute("fill", "#000000"); - a.addAttribute("stroke", "#000000"); - - double ratio = 0; - ratio = static_cast<double>(labelSize.height())/static_cast<double>(labelSize.width()); - double arrowAngle = atan(ratio)*180/M_PI; - - if(start.x() < end.x() && start.y() < end.y()){ - p.addAttribute("points", "0,0 " + QString::number(labelSize.width()) + "," + QString::number(labelSize.height())); - a.addAttribute("points", drawArrowTip( - 180 + arrowAngle,QPoint(labelSize.width(),labelSize.height()))); - - } else if(start.x() < end.x() && start.y() > end.y()){ - p.addAttribute("points", "0," + QString::number(labelSize.height()) + " " + QString::number(labelSize.width()) + ",0"); - a.addAttribute("points", drawArrowTip( 180 - arrowAngle,QPoint(labelSize.width(),0))); - start = start - QPoint(0,labelSize.height()); - - }else if(start.x() > end.x() && start.y() > end.y()){ - p.addAttribute("points", QString::number(labelSize.width()) + "," + QString::number(labelSize.height()) + " 0,0"); - a.addAttribute("points", drawArrowTip(arrowAngle,QPoint(0,0))); - start = start - QPoint(labelSize.width(),labelSize.height()); - }else if(start.x() > end.x() && start.y() < end.y()){ - - p.addAttribute("points", QString::number(labelSize.width()) + ",0 0," + QString::number(labelSize.height())); - a.addAttribute("points", drawArrowTip(-arrowAngle,QPoint(0,labelSize.height()))); - start = start - QPoint(labelSize.width(),0); - - }else if(start.x() == end.x() && start.y() < end.y()){ - p.addAttribute("points", QString::number(labelSize.width()/2) + ",0 " + QString::number(labelSize.width()/2) + "," + QString::number(labelSize.height())); - a.addAttribute("points", drawArrowTip(-90,QPoint(labelSize.width()/2,labelSize.height()))); - start = start - QPoint(labelSize.width()/2,0); - - }else if(start.x() == end.x() && start.y() > end.y()){ - p.addAttribute("points", QString::number(labelSize.width()/2) + "," + QString::number(labelSize.height()) + " " + QString::number(labelSize.width()/2) + ",0"); - a.addAttribute("points", drawArrowTip(90,QPoint(labelSize.width()/2,0))); - start = start - QPoint(labelSize.width()/2,labelSize.height()); - - }else if(start.y() == end.y() && start.x() < end.x()){ - p.addAttribute("points", "0," + QString::number(labelSize.height()/2) + " " + QString::number(labelSize.width()) + "," + QString::number(labelSize.height()/2)); - a.addAttribute("points", drawArrowTip(180,QPoint(labelSize.width(),labelSize.height()/2))); - start = start - QPoint(0,labelSize.height()/2); - - }else if(start.y() == end.y() && start.x() > end.x()){ - p.addAttribute("points", QString::number(labelSize.width()) + "," + QString::number(labelSize.height()/2) + " " + "0," + QString::number(labelSize.height()/2)); - a.addAttribute("points", drawArrowTip(0,QPoint(0,labelSize.height()/2))); - start = start - QPoint(labelSize.width(),labelSize.height()/2); - - } - - g.addChild(p); - g.addChild(a); - svg.addChild(g); - - arrowXml = svg; - - QPoint arrowCenter(labelSize.width()/2 + labelSize.width()/5, labelSize.height()/2); - - boxPosition = start; - createTextLabel(start + arrowCenter); - } - else if(startState.getStateId() == stopState.getStateId()){ - // transizioni che tornano in se stesse - QSize labelSize(70,15); - QPoint pos = startState.getBoxPosition(); - QSize size = startState.getBoxSize(); - start = pos + QPoint(- labelSize.width(),size.height()/2 - labelSize.height()/2); - - XmlObject svg("svg"); - svg.addAttribute("height", QString::number(labelSize.height())); - svg.addAttribute("width", QString::number(labelSize.width())); - - XmlObject g("g"); - - XmlObject p("polygon"); - p.addAttribute("fill", "none"); - p.addAttribute("stroke", "#000000"); - XmlObject a("polygon"); - a.addAttribute("fill", "#000000"); - a.addAttribute("stroke", "#000000"); - - p.addAttribute("points", QString::number(labelSize.width()) + ",0 0,0 0," + QString::number(labelSize.height()) + " " + QString::number(labelSize.width()) + "," + QString::number(labelSize.height())); - a.addAttribute("points", drawArrowTip(180,QPoint(labelSize.width(),labelSize.height()))); - - g.addChild(p); - g.addChild(a); - svg.addChild(g); - - arrowXml = svg; -// QFont myFont(font_family, font_size.toInt()); -// QFontMetrics fm(myFont); - QPoint arrowCenter = start - QPoint(transitionTitle.size()*font_size.toInt()/2,0); - -// qDebug()<<transitionTitle.size()*font_size.toInt()/2; -// qDebug()<<fm.horizontalAdvance(transitionTitle); -// qDebug()<<fm.width(transitionTitle); - - - boxPosition = start; - createTextLabel(arrowCenter); - } - } -} - -void Transition::setTitleXml(const XmlObject &x) -{ - titleXml = x; -} - -XmlObject Transition::getTitleXml() const -{ - return titleXml; -} - -void Transition::setArrowXml(const XmlObject &x) -{ - arrowXml = x; -} - -XmlObject Transition::getArrowXml() const -{ - return arrowXml; -} - -void Transition::setTransitionTitle(const QString &name) -{ - transitionTitle = name; -// LA PARTE SOTTO è INUTILE FINTATO CHE DOPO OGNI MODIFICA ALLA TRANSIZIONE CHIAMO drawArrow() -// QList<XmlObject *> scopes = titleXml.deepSearchObjects("text"); -// if(scopes.count() == 1){ -// scopes.first()->setTextValue(name); -// }else qDebug()<<"no text attribute"; -// qDebug()<<"transition set"; -} - -QString Transition::getTransitionTitle() const -{ - return transitionTitle; -} - -void Transition::operator =(const Transition &other) -{ - copy(other); -} - -QPoint Transition::getStartPoint() const -{ - return start; -} - -QPoint Transition::getStopPoint() const -{ - return end; -} - -QSize Transition::getArrowBoxSize() const -{ - return boxSize; -} - -QString Transition::getFontFamily() const -{ - return font_family; -} - -QString Transition::getFontSize() const -{ - return font_size; -} - -QString Transition::getTextAnchor() const -{ - return text_anchor; -} - -QString Transition::getStroke() const -{ - return stroke; -} - -QString Transition::getFill() const -{ - return fill; -} - -QString Transition::getTextColor() const -{ - return text_color; -} - -void Transition::setFontFamily(const QString &family) -{ - font_family = family; -} - -void Transition::setFontSize(const QString &size) -{ - font_size = size; -} - -void Transition::setTextAnchor(const QString &anchor) -{ - text_anchor = anchor; -} - -void Transition::setStroke(const QString &s) -{ - stroke = s; -} - -void Transition::setFill(const QString &f) -{ - fill = f; -} - -void Transition::setTextColor(const QString &color) -{ - text_color = color; -} - - - - - - -//void Transition::drawXml(const QSize &labelSize) -//{ -// XmlObject svg("svg"); -// svg.addAttribute("height", QString::number(labelSize.height())); -// svg.addAttribute("width", QString::number(labelSize.width())); - -// XmlObject g("g"); -//// g.addAttribute("id", "edge" + getStateId()); - -// XmlObject p("polygon"); -// p.addAttribute("fill", "#000000"); -// p.addAttribute("stroke", "#000000"); -// p.addAttribute("points", "0,0 " + QString::number(labelSize.width()) + "," + QString::number(labelSize.height())); - -// g.addChild(p); -// svg.addChild(g); - -// setXml(svg); -// svg.writeXml(getRepo(), svg); - -// getLabel()->setPixmap(QPixmap(getRepo())); -// getLabel()->move(start); -// getLabel()->show(); -// getLabel()->setAttribute(Qt::WA_DeleteOnClose); -//} - - - - -QString Transition::drawArrowTip(const int &angle, const QPoint &offset) -{ -// qDebug()<<angle; - QString tip = ""; - QMatrix rotationMatrix; - rotationMatrix.rotate(angle); - QList <QPoint> points; - points.append(QPoint(0,0) + offset); - points.append(QPoint(10,2) * rotationMatrix + offset); - points.append(QPoint(10,-2) * rotationMatrix + offset); - - for(int i = 0; i < points.count() ; i++){ - if(i == points.count()-1) tip.append(QString::number(points[i].x()) + "," + QString::number(points[i].y())); - else tip.append(QString::number(points[i].x()) + "," + QString::number(points[i].y()) + " "); - } - return tip; -} - -void Transition::createTextLabel(const QPoint &p) -{ -// QString font = font_size; - QString text(""); - if(!transitionTitle.isEmpty()) -// { - text = transitionTitle; -// }else{ -// text = startState.getTitle() + "->" + stopState.getTitle(); -// } -// QFont myFont(font_family, font_size.toInt()); -// QFontMetrics fm(myFont); - - XmlObject svg("svg"); - svg.addAttribute("width", QString::number(text.size()*font_size.toInt()/2)); - svg.addAttribute("height", font_size); - XmlObject g("g"); - XmlObject t("text"); - t.setTextValue(text); - t.addAttribute("fill", text_color); - t.addAttribute("font-family", font_family); - t.addAttribute("font-size", font_size ); - t.addAttribute("text-anchor", "start"); - t.addAttribute("x", "0"); - t.addAttribute("y", font_size); - g.addChild(t); - svg.addChild(g); - - titleXml = svg; - titlePosition = p; -} - - - -void Transition::setTextFont(const QFont &font) -{ -// font_family = font.family(); - if(font.pixelSize() != -1) - font_size = QString::number(font.pixelSize()); - else if(font.pointSize() != -1) - font_size = QString::number(font.pointSize()); -} - diff --git a/Modules/Fsm/Model/transition.h b/Modules/Fsm/Model/transition.h deleted file mode 100644 index 06301121a801af0262971692298b52008d5adde2..0000000000000000000000000000000000000000 --- a/Modules/Fsm/Model/transition.h +++ /dev/null @@ -1,108 +0,0 @@ -#ifndef TRANSITION_H -#define TRANSITION_H - -#include <QObject> -#include <QtWidgets> -#include "Core/xmlobject.h" -#include "Modules/Fsm/Model/state.h" - -class Transition : public QObject -{ - Q_OBJECT - -public: - Transition(QObject *parent = nullptr); - Transition(const Transition &other); - ~Transition(); - - void setTransitionId(const int &id); - int getTransitionId() const; - - void setStartState(const State &s); - void setStopState(const State &s); - - QPoint getArrowPosition() const; - QPoint getTitlePosition() const; - - State getStartState() const; - State getStopState() const; - - QString getEvent() const; - QString getAction() const; - - void setEvent(const QString &e); - void setAction(const QString &a); - - bool isStartEmpty() const; - bool isStopEmpty() const; - - void drawArrow(); - - void setTitleXml(const XmlObject &x); - XmlObject getTitleXml() const; - - void setArrowXml(const XmlObject &x); - XmlObject getArrowXml() const; - - void setTransitionTitle(const QString &name); - QString getTransitionTitle() const; - - void operator =(const Transition &other); - -// void updateTarget(const State &start, const State &stop); - - QPoint getStartPoint() const; - QPoint getStopPoint() const; - QSize getArrowBoxSize() const; - QString getFontFamily() const; - QString getFontSize() const; - QString getTextAnchor() const; - QString getStroke() const; - QString getFill() const; - QString getTextColor() const; - - - void setFontFamily(const QString &family); - void setFontSize(const QString &size); - void setTextAnchor(const QString &anchor); - void setStroke(const QString &s); - void setFill(const QString &f); - void setTextColor(const QString &color); - void setTextFont(const QFont &font); -private: - void copy(const Transition &other); - QString drawArrowTip(const int &angle, const QPoint &offset); - void createTextLabel(const QPoint &p); - -private: - - int transitionId; - State startState; - State stopState; - - bool isStartEmptyBool = true; - bool isStopEmptyBool = true; - - QString action; - QString event; - - QPoint start; - QPoint end; - - QString transitionTitle; - - XmlObject titleXml; - XmlObject arrowXml; - - QPoint boxPosition; - QSize boxSize = QSize(220,28); - QPoint titlePosition = QPoint(110,14); - QString font_family = "Helvetica,sans-Serif"; - QString font_size = "12"; - QString text_anchor = "middle"; - QString stroke = "#000000"; - QString fill = "none"; - QString text_color = "#000000"; -}; - -#endif // TRANSITION_H diff --git a/Modules/Fsm/View/dragwidget.cpp b/Modules/Fsm/View/dragwidget.cpp deleted file mode 100644 index d77b0aea5da7b953b3e58a45c7f0fc2a9dccb834..0000000000000000000000000000000000000000 --- a/Modules/Fsm/View/dragwidget.cpp +++ /dev/null @@ -1,611 +0,0 @@ -#include "dragwidget.h" -//#include "griplabel.h" - -/* - * TODO: - * REMOVE LABEL FROM THE MAP WHEN THE LABEL IS CLOSE (deleted) - * - */ - - -DragWidget::DragWidget(QWidget *parent, bool locked) : QFrame(parent) -{ - locker = locked; - setMinimumSize(400, 400); // l'esempio diceva 200,200 - setFrameStyle(QFrame::Sunken | QFrame::StyledPanel); - setAcceptDrops(true); - cache.setPalette({"#77dd77","#e3bbbb", "#f0e1bc", "#aae3d9","#c4b7d4"}); - connect(&cache, &PixCache::stateHierarchyRequested, this, &DragWidget::requestStateHierarchy); - connect(this, &DragWidget::stateHierarchyRetrieved, &cache, &PixCache::getHierarchyColor); -} - -DragWidget::~DragWidget() -{ - -} - -void DragWidget::dragEnterEvent(QDragEnterEvent *event) -{ - event->acceptProposedAction(); -} - -void DragWidget::dragMoveEvent(QDragMoveEvent *event) -{ - if (event->source() == this) { - hover(event->pos()); - event->setDropAction(Qt::MoveAction); - event->accept(); - } else { - hover(event->pos()); - event->acceptProposedAction(); - } -} - - - -void DragWidget::dropEvent(QDropEvent *event) -{ - //QString dataInsideEvent = event->mimeData()->text(); - - if (event->mimeData()->hasFormat("application/x-dnditemdata")) { - QByteArray itemData = event->mimeData()->data("application/x-dnditemdata"); - QDataStream dataStream(&itemData, QIODevice::ReadOnly); - - QPoint offset; - dataStream >> offset; // l'offset è la posizione del mouse rispetto all'immagine con origine del sistema di riferimento nel vertice top-left dellimmagine - - resetHighlighted(); - if (event->source() == this ) { - if(resizeRequestFlag){ - resizeState(movingStateIndex, event->pos()); - } else{ - moveState(movingStateIndex, event->pos(), offset); - } - event->setDropAction(Qt::MoveAction); - event->accept(); - } else { - dropNewState(event->pos(), offset); - event->acceptProposedAction(); - } - } else { - event->ignore(); - } -} - -void DragWidget::mouseDoubleClickEvent(QMouseEvent *event) -{ - if(locker || event->button() != Qt::LeftButton){ - return; - } - - QLabel *selectedLabel = getLabelAtPosition(event->pos()); - int tempId = getIdOfState(selectedLabel); - - if(tempId == -1){ - // if stateId == -1 => it's not a state - tempId = getIdOfTransition(selectedLabel); - if(tempId != -1){ - requestTransitionContextMenu(tempId); - } - } else{ - requestStateContextMenu(tempId); - } - return; -} - -int DragWidget::getIdOfState(const QLabel* label) const -{ - if(label == nullptr) - return -1; - - for (int i=0; i<stateIdToLabel.keys().count() ; i++ ) { - if(label == stateIdToLabel[stateIdToLabel.keys()[i]]) - return stateIdToLabel.keys()[i]; - } - return -1; -} - -int DragWidget::getIdOfTransition(const QLabel* label) const -{ - if(label == nullptr) - return -1; - - for (int i=0; i<transitionIdToLabel.keys().count() ; i++ ) { - if(label == transitionIdToLabel[transitionIdToLabel.keys()[i]][0] || label == transitionIdToLabel[transitionIdToLabel.keys()[i]][1]) { - return transitionIdToLabel.keys()[i]; - } - } - return -1; -} - - -void DragWidget::mousePressEvent(QMouseEvent *event) -{ - if(locker || event->button() != Qt::LeftButton){ - return; - } - - QLabel *selectedLabel = getLabelAtPosition(event->pos()); - movingStateIndex = getIdOfState(selectedLabel); - - if(movingStateIndex == -1) - return; - - QLabel* hook = hookGrabbed(movingStateIndex, event->pos()); - if(hook != nullptr){ - selectedLabel = hook; - resizeRequestFlag = true; - } - - // Create shaded state placeholder - QPixmap pixmap = selectedLabel->pixmap(Qt::ReturnByValue); - - QByteArray itemData; - QDataStream dataStream(&itemData, QIODevice::WriteOnly); - dataStream << pixmap << QPoint(event->pos() - selectedLabel->pos()); - - QMimeData *mimeData = new QMimeData; - mimeData->setData("application/x-dnditemdata", itemData); - - QDrag *drag = new QDrag(this); - drag->setMimeData(mimeData); - drag->setPixmap(pixmap); - drag->setHotSpot(event->pos() - selectedLabel->pos()); - - QPixmap tempPixmap = pixmap; - QPainter painter; - painter.begin(&tempPixmap); - painter.fillRect(pixmap.rect(), QColor(127, 127, 127, 127)); - painter.end(); - - selectedLabel->setPixmap(tempPixmap); - - Qt::DropAction result = drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction); - - if (result == Qt::MoveAction) { - selectedLabel->close(); - } else { - selectedLabel->show(); - selectedLabel->setPixmap(pixmap); - } - movingStateIndex = -1; - resizeRequestFlag = false; -} - - - -void DragWidget::requestStateContextMenu(const int &id) -{ - emit stateContextMenuRequested(id); -} - -void DragWidget::onStateContextMenuGenerated(const State &state) -{ - StateDialog settings(this); -// settings.setCaller(this); - settings.setTargetState(state); - settings.exec(); -} - -void DragWidget::onStateEditTitleRequested(const int &id, const QString &title) -{ - emit stateEditTitleRequested(id, title); -} - -void DragWidget::onTransitionEditTitleRequested(const int &id, const QString &title) -{ - emit transitionEditTitleRequested(id, title); -} - -void DragWidget::onTransitionEditActionRequested(const int &id, const QString &action) -{ - emit transitionEditActionRequested(id, action); -} - -void DragWidget::onStateDeleteRequested(const int &id) -{ - emit stateDeleteRequested(id); -} - -void DragWidget::onStateDeleted(const int &id) -{ - stateIdToLabel[id]->close(); - stateIdToLabel.remove(id); - cache.remove(id); - deleteHooks(id); -} - -int DragWidget::indexOf(const int &id) const -{ - for (int i=0; i<stateIdToLabel.keys().count() ; i++ ) { - if(stateIdToLabel.keys()[i] == id) - return i; - } - return -1; -} - - -int DragWidget::indexOf(const QLabel &label) const -{ - for (int i=0; i<stateIdToLabel.keys().count() ; i++ ) { - if(stateIdToLabel[stateIdToLabel.keys()[i]] == &label) - return i; - } - return -1; -} - -void DragWidget::onDefaultStateCreated(const State &defState) -{ - createLabel(defState.getXml(), QPoint(0,0)); -} - - -void DragWidget::onStateCreated(const State &newState) -{ - stateIdToLabel.insert(newState.getStateId(), createLabel(newState.getXml(), newState.getBoxPosition())); - cache.addState(newState); - drawHooks(newState); -} - -void DragWidget::dropNewState(const QPoint &point, const QPoint &offset) -{ - emit createStateRequested(point, offset); -} - -void DragWidget::moveState(const int &id, const QPoint &point, const QPoint &offset) -{ - emit changeStatePositionRequested(id, point, offset); -} - -void DragWidget::resizeState(const int &id, const QPoint &point) -{ - emit resizeStateRequested(id, point); -} - -void DragWidget::onStateChanged(const State &changedState) -{ - stateIdToLabel[changedState.getStateId()]->close(); - stateIdToLabel[changedState.getStateId()] = createLabel(changedState.getXml(), changedState.getBoxPosition()); - deleteHooks(changedState.getStateId()); - drawHooks(changedState); - cache.updateCache(changedState); -} - -QLabel *DragWidget::createLabel(const XmlObject &xml, const QPoint &point) -{ - QLabel *newLabel = new QLabel(this); - QPixmap pix; - pix.loadFromData(xml.toXml().toUtf8()); - newLabel->setPixmap(pix); - newLabel->move(point); - newLabel->show(); - newLabel->setAttribute(Qt::WA_DeleteOnClose); - QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect(); // CONTROLLARE LA DELETE DI QUESTO OGGETTO - effect->setBlurRadius(5); - newLabel->setGraphicsEffect(effect); - return newLabel; -} - -void DragWidget::onStateHierarchyRetrieved(const int &stateHierarchy) -{ - emit stateHierarchyRetrieved(stateHierarchy); -} - - -QLabel * DragWidget::getLabelAtPosition(const QPoint &p) -{ - QMap <int, QLabel *> tempMap = searchHoveredStates(p); - tempMap.insert(searchHoveredTransitions(p)); - int result; - int min = 0; - for(int i=0; i<tempMap.keys().count(); i++) - { - int labelArea = tempMap[tempMap.keys()[i]]->width() * tempMap[tempMap.keys()[i]]->height(); - if(labelArea < min || i==0){ - min = labelArea; - result = tempMap.keys()[i]; - } - } - if(!tempMap.isEmpty()) - return tempMap[result]; - else - return nullptr; -} - - -void DragWidget::requestStateHierarchy(const State &state) -{ - emit stateHierarchyRequested(state); -} - - -void DragWidget::onTransitionDeleted(const int &id) -{ - transitionIdToLabel[id][0]->close(); - transitionIdToLabel[id][1]->close(); - transitionIdToLabel.remove(id); -} - - -void DragWidget::onTransitionContextMenuGenerated(const Transition &trans) -{ - TransitionDialog settings(this); - settings.setTargetTransition(trans); - settings.exec(); -} - -void DragWidget::requestTransitionContextMenu(const int &id) -{ - emit transitionContextMenuRequested(id); -} - -void DragWidget::onTransitionCreated(const Transition &transition) -{ - qDebug()<<"transizione mostrata"<<transition.getTransitionId(); - transitionIdToLabel.insert(transition.getTransitionId(), {createLabel(transition.getArrowXml(), transition.getArrowPosition()), createLabel(transition.getTitleXml(), transition.getTitlePosition())}); -} - -void DragWidget::onTransitionChanged(const Transition &changedTransition) -{ - - if(transitionIdToLabel[changedTransition.getTransitionId()].count() == 2){ - transitionIdToLabel[changedTransition.getTransitionId()][1]->close(); - transitionIdToLabel[changedTransition.getTransitionId()][0]->close(); - transitionIdToLabel[changedTransition.getTransitionId()] = {createLabel(changedTransition.getArrowXml(), changedTransition.getArrowPosition()), createLabel(changedTransition.getTitleXml(), changedTransition.getTitlePosition())}; - } -} - -void DragWidget::onTransitionDeleteRequested(const int &id) -{ - emit transitionDeleteRequested(id); -} - -int DragWidget::getTransitionStartStateId() const -{ - return transitionStartStateId; -} - - -int DragWidget::getTransitionStopStateId() const -{ - return transitionStopStateId; -} - - -void DragWidget::initializeTrans(const State &startState) -{ - if(transitionStartStateId != -1) - onSetColorRequested("Background", "#e6e6e6", transitionStartStateId); - transitionStartStateId = startState.getStateId(); - onSetColorRequested("Background", "#cd605a", startState.getStateId()); -} - - -void DragWidget::finalizeTrans(const State &stopState) -{ - transitionStopStateId = stopState.getStateId(); - onSetColorRequested("Background", "#e6e6e6", transitionStartStateId); - emit createTransitionRequested(transitionStartStateId, transitionStopStateId); - transitionStartStateId = -1; - transitionStopStateId = -1; -} - - -void DragWidget::hover(const QPoint &p) // da rivedere -{ - - QMap <int , QLabel *> hov = searchHoveredStates(p); - QList <int> highlighted = cache.getHighlightedStates(); - QList <int> noMoreHigh = listDiffRetrospective(highlighted, hov.keys()); - QList <int> justSetHigh = listDiffRetrospective(hov.keys(), highlighted); - - if(!noMoreHigh.isEmpty()) - turnHighlightOff(noMoreHigh); - - if(!justSetHigh.isEmpty()) - turnHighlightOn(justSetHigh); -} - -void DragWidget::turnHighlightOff(const QList <int> &list) -{ - for(int i = 0; i<list.count(); i++){ - if(stateIdToLabel.keys().contains(list[i]) && list[i] != movingStateIndex) - stateIdToLabel[list[i]]->setPixmap(cache.highlightOff(list[i])); - } -} - -void DragWidget::turnHighlightOn(const QList <int> &list) -{ - for(int i = 0; i<list.count(); i++){ - if(stateIdToLabel.keys().contains(list[i]) && list[i] != movingStateIndex) - stateIdToLabel[list[i]]->setPixmap(cache.highlightOn(list[i])); - } -} - - - QMap <int , QLabel *> DragWidget::searchHoveredStates(const QPoint &p) - { - QMap <int , QLabel *> map; - for(int i=0; i<stateIdToLabel.count(); i++) - { - QLabel *label = stateIdToLabel[stateIdToLabel.keys()[i]]; - int minX = label->pos().x(); - int maxX = minX + label->size().width(); - int minY = label->pos().y(); - int maxY = minY + label->size().height(); - if(p.x()>=minX && p.x()<=maxX && p.y()>=minY && p.y()<=maxY) - map.insert(stateIdToLabel.keys()[i], label); - } - return map; - } - - void DragWidget::drawHooks(const State &state) - { - QSize labelSize(15,15); - QPoint pos = state.getBoxPosition(); - QSize size = state.getBoxSize(); - - QList <QPoint> points; -// points.append(QPoint(0,0)); - points.append(QPoint(0,labelSize.height())); - points.append(QPoint(labelSize.width(),labelSize.height())); - points.append(QPoint(labelSize.width(),0)); - - QString polygon; - for(int i=0; i<points.count() - 1; i++){ - polygon.append(QString::number(points[i].x()) + "," + QString::number(points[i].y()) + " "); - } - polygon.append(QString::number(points.last().x()) + "," + QString::number(points.last().y())); - - - XmlObject svg("svg"); - svg.addAttribute("height", QString::number(labelSize.height())); - svg.addAttribute("width", QString::number(labelSize.width())); - XmlObject g("g"); - XmlObject a("polygon"); - a.addAttribute("fill", "#000000"); - a.addAttribute("stroke", "#000000"); - a.addAttribute("points", polygon); - - g.addChild(a); - svg.addChild(g); - - QLabel * hook; - - hook = createLabel(svg, pos + QPoint(size.width() - labelSize.width(),size.height() - labelSize.height())); - - hooksIdToLabel.insert(state.getStateId(), hook); - } - - void DragWidget::deleteHooks(const int &id) - { - hooksIdToLabel[id]->close(); - hooksIdToLabel.remove(id); - } - - QLabel *DragWidget::hookGrabbed(const int &id, const QPoint &point) - { - if(!hooksIdToLabel.isEmpty()){ - int minX = hooksIdToLabel[id]->pos().x(); - int maxX = minX + hooksIdToLabel[id]->size().width(); - int minY = hooksIdToLabel[id]->pos().y(); - int maxY = minY + hooksIdToLabel[id]->size().height(); - if(point.x()>=minX && point.x()<=maxX && point.y()>=minY && point.y()<=maxY) - return hooksIdToLabel[id]; - } - return nullptr; - } - - QMap <int , QLabel *> DragWidget::searchHoveredTransitions(const QPoint &p) - { - QMap <int , QLabel *> map; - for(int i=0; i<transitionIdToLabel.count(); i++) - { - QList <QLabel *> labels = transitionIdToLabel[transitionIdToLabel.keys()[i]]; - for(int k=0; k<labels.count(); k++){ - int minX = labels[k]->pos().x(); - int maxX = minX + labels[k]->size().width(); - int minY = labels[k]->pos().y(); - int maxY = minY + labels[k]->size().height(); - if(p.x()>=minX && p.x()<=maxX && p.y()>=minY && p.y()<=maxY && !map.contains(transitionIdToLabel.keys()[i])) - map.insert(transitionIdToLabel.keys()[i], labels[k]); - } - } - return map; - } - - QList <int> DragWidget::listDiffAbsolute(const QList <int> &list1, const QList <int> &list2) // ritorna gli elementi che non sono in comune tra le due liste - { - QList <int> result; - for(int i = 0; i<list1.count(); i++){ - if(!list2.contains(list1[i])) - result.append(list1[i]); - } - for(int i = 0; i<list2.count(); i++){ - if(!list1.contains(list2[i])) - result.append(list2[i]); - } - return result; - } - - QList <int> DragWidget::listDiffRetrospective(const QList <int> &list1, const QList <int> &list2) // ritorna gli elementi della list1 che non sono nella list2 - { - QList <int> result; - for(int i = 0; i<list1.count(); i++){ - if(!list2.contains(list1[i])) - result.append(list1[i]); - } - return result; - } - - void DragWidget::resetHighlighted() - { - turnHighlightOff(stateIdToLabel.keys()); - } - - void DragWidget::onClearViewRequested() - { - for(int i=0; i<stateIdToLabel.keys().count(); i++) - { - onStateDeleted(stateIdToLabel.keys()[i]); - i = -1; - } - for(int i=0; i<transitionIdToLabel.keys().count(); i++) - { - onTransitionDeleted(transitionIdToLabel.keys()[i]); - i = -1; - } - cache.clear(); - } - - void DragWidget::onSetColorRequested(const QString &attribute, const QString &color, const int &id) - { - emit setColorRequested(attribute, color, id); - } - - void DragWidget::onSetTextFontRequested(const QFont &font, const int &id) - { - emit setFontRequested(font, id); - } - - void DragWidget::onSetPositionRequested(const QPoint &point, const int &id) - { - moveState(id, point, QPoint(0,0)); - } - - void DragWidget::onSetSizeRequested(const QPoint &size, const int &id) - { - resizeState(id,size); - } - - void DragWidget::onSetEntryRequested(const QString &action, const int &id) - { - emit setEntryRequested(action, id); - } - - void DragWidget::onSetExitRequested(const QString &action, const int &id) - { - emit setExitRequested(action, id); - } - - void DragWidget::onSetInitialRequested(const bool &val, const int &id) - { - emit setInitialRequested(val, id); - } - - void DragWidget::onSetFinalRequested(const bool &val, const int &id) - { - emit setFinalRequested(val, id); - } - - - void DragWidget::setLocked(const bool &val) - { - locker = val; - } - - - bool DragWidget::isLocked() const - { - return locker; - } diff --git a/Modules/Fsm/View/dragwidget.h b/Modules/Fsm/View/dragwidget.h deleted file mode 100644 index bfeabe49d0b57a6f2a2584bb180b7a9147d81342..0000000000000000000000000000000000000000 --- a/Modules/Fsm/View/dragwidget.h +++ /dev/null @@ -1,160 +0,0 @@ - -#ifndef DRAGWIDGET_H -#define DRAGWIDGET_H - -#include <QFrame> -#include <QtWidgets> -//#include <QMap> -#include "Modules/Fsm/View/statedialog.h" -#include "Core/xmlobject.h" -#include "Modules/Fsm/Model/state.h" -#include "Modules/Fsm/Model/transition.h" -#include "Modules/Fsm/View/transitiondialog.h" -#include "Modules/Fsm/View/pixcache.h" - - -QT_BEGIN_NAMESPACE -class QDragEnterEvent; -class QDropEvent; -QT_END_NAMESPACE - - -//class SettingsDialog; -class MainWindow; -class DragWidget : public QFrame -{ - Q_OBJECT -public: - explicit DragWidget(QWidget *parent = nullptr, bool locked = false); - ~DragWidget(); - - void dropNewState(const QPoint &point, const QPoint &offset); - void onDefaultStateCreated(const State &defState); - - void onStateCreated(const State &newState); - void moveState(const int &id, const QPoint &point, const QPoint &offset); - void resizeState(const int &id, const QPoint &point); - void requestStateContextMenu(const int &id); - void onStateContextMenuGenerated(const State &state); - void onTransitionContextMenuGenerated(const Transition &trans); - void onTransitionDeleted(const int &id); - - - void initializeTrans(const State &startState); - void finalizeTrans(const State &stopState); - - bool highlightHover(const QPoint &p); - int mouseScopeCheck(const QPoint &p); - QList<int> getSuperimposedStates(const QPoint &p) const; - void hover(const QPoint &p); - QList <int> listDiffAbsolute(const QList <int> &list1, const QList <int> &list2); - QList <int> listDiffRetrospective(const QList <int> &list1, const QList <int> &list2); - - void turnHighlightOff(const QList<int> &list); - void turnHighlightOn(const QList<int> &list); - - void onStateChanged(const State &changedState); - void onStateEditTitleRequested(const int &id, const QString &title); - void onTransitionEditTitleRequested(const int &id, const QString &title); - void onTransitionEditActionRequested(const int &id, const QString &action); - void onStateDeleteRequested(const int &id); - void onStateDeleted(const int &id); - int indexOf(const int &id) const; - int indexOf(const QLabel &label) const; - - - void resetHighlighted(); - void onStateHierarchyRetrieved(const int &stateHierarchy); - - QLabel *getLabelAtPosition(const QPoint &p); - QLabel *hookGrabbed(const int &id, const QPoint &point); - void requestTransitionContextMenu(const int &id); - void onTransitionCreated(const Transition &transition); - void onTransitionChanged(const Transition &changedTransition); - void onTransitionDeleteRequested(const int &id); - void onClearViewRequested(); - - int getTransitionStartStateId() const; - int getTransitionStopStateId() const; - - QMap<int, QLabel *> searchHoveredTransitions(const QPoint &p); - - void onSetColorRequested(const QString &attribute, const QString &color, const int &id); - void onSetTextFontRequested(const QFont &font, const int &id); - void onSetPositionRequested(const QPoint &point, const int &id); - void onSetSizeRequested(const QPoint &size, const int &id); - - void onSetEntryRequested(const QString &action, const int &id); - void onSetExitRequested(const QString &action, const int &id); - - void onSetInitialRequested(const bool &val, const int &id); - void onSetFinalRequested(const bool &val, const int &id); - - void setLocked(const bool &val); - bool isLocked() const; - -public slots: - void requestStateHierarchy(const State &state); - - -signals: - void stateHierarchyRetrieved(const int &stateHierarchy); - void stateContextMenuRequested(const int &id); - void stateEditTitleRequested(const int &id, const QString &title); - void transitionEditTitleRequested(const int &id, const QString &title); - void transitionEditActionRequested(const int &id, const QString &action); - void stateDeleteRequested(const int &id); - void createStateRequested(const QPoint &point, const QPoint &offset); - void changeStatePositionRequested(const int &id, const QPoint &point, const QPoint &offset); - void resizeStateRequested(const int &id, const QPoint &point); - void stateHierarchyRequested(const State &state); - void transitionContextMenuRequested(const int &id); - void transitionDeleteRequested(const int &id); - void createTransitionRequested(const int &startState, const int &stopState); - void setColorRequested(const QString &attribute,const QString &color, const int &id); - void setFontRequested(const QFont &font, const int &id); - void setEntryRequested(const QString &action, const int &id); - void setExitRequested(const QString &action, const int &id); - void setInitialRequested(const bool &val, const int &id); - void setFinalRequested(const bool &val, const int &id); - -protected: - void dragEnterEvent(QDragEnterEvent *event) override; - void dragMoveEvent(QDragMoveEvent *event) override; - void dropEvent(QDropEvent *event) override; - void mousePressEvent(QMouseEvent *event) override; - void mouseDoubleClickEvent(QMouseEvent* event) override; - - int getIdOfState(const QLabel* label) const; - int getIdOfTransition(const QLabel* label) const; - -private: - QLabel *createLabel(const XmlObject &xml, const QPoint &point); - - QMap <int , QLabel *> searchHoveredStates(const QPoint &p); - void drawHooks(const State &state); - void deleteHooks(const int &id); - - - // Attributes - - int movingStateIndex = -1; - - int transitionStartStateId = -1; - int transitionStopStateId = -1; - - bool stateHighlighted = false; - PixCache cache; - QMap <int , QLabel *> stateIdToLabel; - QMap <int , QList <QLabel *>> transitionIdToLabel; - - int lastHovered = -1; - QMap <int, QLabel *> hooksIdToLabel; - - - bool resizeRequestFlag = false; - bool locker = false; -}; -//! [0] - -#endif // DRAGWIDGET_H diff --git a/Modules/Fsm/View/mainwindow.cpp b/Modules/Fsm/View/mainwindow.cpp deleted file mode 100644 index 99414d9242b7b1ffd286d64dd11a883be74a3e3e..0000000000000000000000000000000000000000 --- a/Modules/Fsm/View/mainwindow.cpp +++ /dev/null @@ -1,537 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" - -MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui( new Ui::MainWindow) -{ - ui->setupUi(this); - this->setMinimumSize(QSize(3000,1500)); - QSize topItemsSize(220,28); - QWidget *topwidget = new QWidget(this); - QWidget *bottomwidget = new QWidget(this); - QWidget *bottomrightwidget_console = new QWidget(this); - - lockerButton = new QRadioButton(this); - - tabWidget = new QTabWidget(bottomwidget); - tabWidget->setMaximumWidth(1000); - tabWidget->setStyleSheet("background-color: #302f2f;"); - - bottomrightwidget_tree = new QTreeWidget(bottomwidget); - connect(bottomrightwidget_tree, &QTreeWidget::itemDoubleClicked, this, &MainWindow::treeActionRequested); - - bottomrightwidget_tree->setStyleSheet("" - "QTreeView, QListView" - "{" - " border: 1px solid #2dff6c;" - " background-color: #201F1F;" - "}" - - "QTreeView:branch:selected, QTreeView:branch:hover" - "{" - "background: url(:/qss_icons/rc/transparent.png);" - "}" - - "QTreeView::branch:has-siblings:!adjoins-item {" - "border-image: url(:/qss_icons/rc/transparent.png);" - "}" - - "QTreeView::branch:has-siblings:adjoins-item {" - "border-image: url(:/qss_icons/rc/transparent.png);" - "}" - - "QTreeView::branch:!has-children:!has-siblings:adjoins-item {" - " border-image: url(:/qss_icons/rc/transparent.png);" - "}" - - "QTreeView::branch:has-children:!has-siblings:closed," - "QTreeView::branch:closed:has-children:has-siblings {" - "image: url(:/qss_icons/rc/branch_closed.png);" - "}" - - "QTreeView::branch:open:has-children:!has-siblings," - "QTreeView::branch:open:has-children:has-siblings {" - "image: url(:/qss_icons/rc/branch_open.png);" - "}" - - "QTreeView::branch:has-children:!has-siblings:closed:hover," - "QTreeView::branch:closed:has-children:has-siblings:hover {" - "image: url(:/qss_icons/rc/branch_closed-on.png);" - "}" - - "QTreeView::branch:open:has-children:!has-siblings:hover," - "QTreeView::branch:open:has-children:has-siblings:hover {" - "image: url(:/qss_icons/rc/branch_open-on.png);" - "}" - - "QListView::item:!selected:hover, QTreeView::item:!selected:hover {" - "background-color: #282727;" - "border: 1px solid #3a3939;" - "outline: 0;" - "color: #e6e6e6" - "}" - - "QListView::item:selected:hover, QTreeView::item:selected:hover {" - "background-color: #201f1f;" - "border: 1px solid #2dff6c;" - "color: #e6e6e6;" - "}" - - - "QListView::item:!selected:!hover, QTreeView::item:!selected:!hover {" - "background-color: #201f1f;" - "border: 1px solid #3a3939;" - "color: #e6e6e6;" - "}" - - - "QListView::item:selected:!hover, QTreeView::item:selected:!hover {" - "background-color: #201f1f;" - "border: 1px solid #2dff6c;" - "color: #e6e6e6;" - "}" - ); - - bottomrightwidget_tree->setColumnCount(4); - bottomrightwidget_tree->setHeaderLabels({"Title", "Id", "Action1", "Action2"}); - - QWidget *bottomcentralwidget = new QWidget(this); - - QVBoxLayout *verticalLayout_bottomcentral = new QVBoxLayout(bottomcentralwidget); - - QHBoxLayout *horizontalLayout_top = new QHBoxLayout(topwidget); - QHBoxLayout *horizontalLayout_bottom = new QHBoxLayout(bottomwidget); - - QSpacerItem *horizontalSpacer_left = new QSpacerItem(topItemsSize.width(), topItemsSize.height(), QSizePolicy::Expanding, QSizePolicy::Fixed); - - saveButton = new QPushButton("save", topwidget); - runButton_scxml = new QPushButton("<<", bottomcentralwidget); - runButton_svg = new QPushButton("<<", bottomcentralwidget); - showCodeButton = new QPushButton(">>", bottomcentralwidget); - clearButton = new QPushButton("clear", topwidget); - - QVBoxLayout *verticalLayout = new QVBoxLayout(ui->centralwidget); - QVBoxLayout *verticalLayout_console = new QVBoxLayout(bottomrightwidget_console); - -// consoleScxml = new Console(bottomrightwidget_console); -// consoleScxml->setStyleSheet("QPlainTextEdit {background-color: #201F1F; padding: 2px; border-style: solid; border: 1px solid #3A3939; border-radius: 3px; color: silver;}" -// "QPlainTextEdit:hover {border: 1px solid #2dff6c; color: silver;}"); - -// consoleSvg = new Console(bottomrightwidget_console); -// consoleSvg->setStyleSheet("QPlainTextEdit {background-color: #201F1F; padding: 2px; border-style: solid; border: 1px solid #3A3939; border-radius: 3px; color: silver;}" -// "QPlainTextEdit:hover {border: 1px solid #2dff6c; color: silver;}"); - - - itemsToolBar = new DragWidget(this,false); - childList.append(new DragWidget(this,true)); - - itemsToolBar->setFixedSize(topItemsSize); - itemsToolBar->setStyleSheet("border-radius: 10px;"); - - saveButton->setFixedSize(topItemsSize + QSize(0,20)); - runButton_scxml->setFixedSize(QSize(50,40)); - runButton_svg->setFixedSize(QSize(50,40)); - showCodeButton->setFixedSize(QSize(50,40)); - clearButton->setFixedSize(topItemsSize + QSize(0,20)); - - verticalLayout_console->setMargin(0); - bottomrightwidget_console->setLayout(verticalLayout_console); - - verticalLayout_bottomcentral->addWidget(runButton_scxml); - verticalLayout_bottomcentral->addWidget(showCodeButton); - verticalLayout_bottomcentral->addWidget(runButton_svg); - verticalLayout_bottomcentral->setMargin(0); - bottomcentralwidget->setLayout(verticalLayout_bottomcentral); - bottomcentralwidget->setFixedWidth(50); - - - horizontalLayout_top->addWidget(itemsToolBar); - horizontalLayout_top->addSpacerItem(horizontalSpacer_left); - horizontalLayout_top->addWidget(lockerButton); - horizontalLayout_top->addWidget(clearButton); - horizontalLayout_top->addWidget(saveButton); - topwidget->setLayout(horizontalLayout_top); - - - horizontalLayout_bottom->addWidget(childList[0]); -// horizontalLayout_bottom->addWidget(bottomcentralwidget); - horizontalLayout_bottom->addWidget(tabWidget); - bottomwidget->setLayout(horizontalLayout_bottom); - -//=========================================================================================== - QWidget *consoleTab = new QWidget(bottomwidget); - QHBoxLayout *horizontalLayout_consoletab = new QHBoxLayout(consoleTab); - - horizontalLayout_consoletab->addWidget(bottomcentralwidget); - horizontalLayout_consoletab->addWidget(bottomrightwidget_console); - consoleTab->setLayout(horizontalLayout_consoletab); - horizontalLayout_consoletab->setMargin(0); - - tabWidget->addTab(consoleTab, "Console"); - tabWidget->addTab(bottomrightwidget_tree, "Tree"); -//=========================================================================================== - - verticalLayout->addWidget(topwidget); - verticalLayout->addWidget(bottomwidget); - ui->centralwidget->setLayout(verticalLayout); - - this->setWindowTitle("Scxml Designer"); - this->setWindowIcon(QIcon(":/new/prefix1/Images/skyward_icon.ico")); - - connect(saveButton, &QPushButton::clicked, this , &MainWindow::onCheckPathRequested); -// connect(runButton_scxml, &QPushButton::clicked, this, &MainWindow::onRunScxmlClicked); -// connect(runButton_svg, &QPushButton::clicked, this, &MainWindow::onRunSvgClicked); - connect(clearButton, &QPushButton::clicked, this, &MainWindow::onClearAllRequested); - connect(showCodeButton, &QPushButton::clicked, this, &MainWindow::onShowCodeRequested); - connect(lockerButton, &QRadioButton::toggled, this, &MainWindow::onLockRequested); - - createActions(); - createMenus(); - onLockRequested(false); - -} - - -MainWindow::~MainWindow() -{ - delete ui; -} - - - -void MainWindow::createActions() -{ - newAct = new QAction(tr("New"), this); - newAct->setShortcuts(QKeySequence::New); - newAct->setStatusTip(tr("Create a new file")); - connect(newAct, &QAction::triggered, this, &MainWindow::onNewRequested); - - openAct = new QAction(tr("Open..."), this); - openAct->setShortcuts(QKeySequence::Open); - openAct->setStatusTip(tr("Open an existing file")); - connect(openAct, &QAction::triggered, this, &MainWindow::onOpenRequested); - - saveAct = new QAction(tr("Save"), this); - saveAct->setShortcuts(QKeySequence::Save); - saveAct->setStatusTip(tr("Save the document to disk")); - connect(saveAct, &QAction::triggered, this, &MainWindow::onCheckPathRequested); - - saveAsAct = new QAction(tr("Save As..."), this); - saveAsAct->setShortcuts(QKeySequence::SaveAs); - saveAsAct->setStatusTip(tr("Save the document to disk")); - connect(saveAsAct, &QAction::triggered, this, &MainWindow::onSaveAsRequested); - - exitAct = new QAction(tr("Exit"), this); - exitAct->setShortcuts(QKeySequence::Quit); - exitAct->setStatusTip(tr("Exit the application")); - connect(exitAct, &QAction::triggered, this, &QWidget::close); - - setBackgroundColorAct = new QAction(tr("Background"), this); - setBackgroundColorAct->setStatusTip(tr("Set states background color")); - connect(setBackgroundColorAct, &QAction::triggered, this, &MainWindow::onSetBackgroundColor); - - setBorderColorAct = new QAction(tr("Border"), this); - setBorderColorAct->setStatusTip(tr("Set states border color")); - connect(setBorderColorAct, &QAction::triggered, this, &MainWindow::onSetBorderColor); - - setTextColorAct = new QAction(tr("Text"), this); - setTextColorAct->setStatusTip(tr("Set states text color")); - connect(setTextColorAct, &QAction::triggered, this, &MainWindow::onSetTextColor); - - setFontAct = new QAction(tr("Font"), this); - setFontAct->setStatusTip(tr("Set states text font")); - connect(setFontAct, &QAction::triggered, this, &MainWindow::onSetTextFont); - - -// popUpState = new QAction(tr("Up"), this); -//// setFontAct->setStatusTip(tr("Set states text font")); -// connect(popUpState, &QAction::triggered, this, &MainWindow::onPopUpState); - -} - -void MainWindow::createMenus() -{ - fileMenu = menuBar()->addMenu(tr("File")); - fileMenu->addAction(newAct); - fileMenu->addAction(openAct); - fileMenu->addAction(saveAct); - fileMenu->addAction(saveAsAct); - fileMenu->addSeparator(); - fileMenu->addAction(exitAct); - - editMenu = menuBar()->addMenu(tr("Edit")); - editMenu->addAction(setFontAct); - formatMenu = editMenu->addMenu(tr("Color...")); - formatMenu->addAction(setBackgroundColorAct); - formatMenu->addAction(setBorderColorAct); - formatMenu->addAction(setTextColorAct); - -} - -void MainWindow::onDefaultStateCreated(const State &defState) -{ - itemsToolBar->onDefaultStateCreated(defState); -} - -void MainWindow::onStateCreated(const State &newState) -{ - childList[0]->onStateCreated(newState); -} - -void MainWindow::onStateChanged(const State &changedState) -{ - childList[0]->onStateChanged(changedState); -} - -void MainWindow::onStateContextMenuGenerated(const State &state) -{ - childList[0]->onStateContextMenuGenerated(state); -} - -void MainWindow::onStateDeleted(const int &id) -{ - childList[0]->onStateDeleted(id); -} - -//================================= DA TOGLIERE ================================================ -//void MainWindow::onSuperstatesBoxSizeChanged(const QList <State> &superstates) -//{ -// childList[0]->onSuperstatesBoxSizeChanged(superstates); -//} -//============================================================================================== - - -void MainWindow::onStateHierarchyRetrieved(const int &stateHierarchy) -{ - childList[0]->onStateHierarchyRetrieved(stateHierarchy); -} - - -void MainWindow::onTransitionCreated(const Transition &transition) -{ - childList[0]->onTransitionCreated(transition); -} - -void MainWindow::onTransitionChanged(const Transition &transition) -{ - childList[0]->onTransitionChanged(transition); -} - -void MainWindow::onTransitionDeleted(const int &id) -{ - childList[0]->onTransitionDeleted(id); -} - -void MainWindow::onTransitionContextMenuGenerated(const Transition &transition) -{ - childList[0]->onTransitionContextMenuGenerated(transition); -} - - -void MainWindow::onClearViewRequested() -{ - childList[0]->onClearViewRequested(); -} - - - - -void MainWindow::onClearAllRequested() -{ - emit clearAllRequested(); -} - -void MainWindow::onNewRequested() -{ - emit clearAllRequested(); -} - - -void MainWindow::onOpenRequested() -{ - QString path = QFileDialog::getOpenFileName(this, tr("Open File"),QDir::homePath(), tr("Fsm (*.scxml);; Svg (*.svg)")); - emit openRequested(path); -} - -void MainWindow::onCheckPathRequested() -{ - emit checkPathRequested(); -} - -void MainWindow::onSaveRequested() -{ - emit saveRequested(); -} - -void MainWindow::onSaveAsRequested() -{ - QString path = QFileDialog::getSaveFileName(this, tr("Save File"),QDir::homePath()); - qDebug()<<path; - emit saveAsRequested(path); -} - -void MainWindow::onPathChecked(const bool &check) -{ - if(check) - onSaveRequested(); - else - onSaveAsRequested(); -} - - - -void MainWindow::onShowCodeRequested() -{ - emit showCodeRequested(); -} - -void MainWindow::onSetBackgroundColor() -{ - QString color = setColor(); - if(!color.isEmpty()) - emit setColorRequested("Background", color, -1); -} - -void MainWindow::onSetBorderColor() -{ - QString color = setColor(); - if(!color.isEmpty()) - emit setColorRequested("Border", color, -1); -} - -void MainWindow::onSetTextColor() -{ - QString color = setColor(); - if(!color.isEmpty()) - emit setColorRequested("Text", color, -1); -} - -void MainWindow::onSetTextFont() -{ - QFont font = setFont(); - if(!font.family().isEmpty()) - emit setFontRequested(font, -1); -} - - - -QString MainWindow::setColor() -{ - const QColor color = QColorDialog::getColor("#e6e6e6",this, "Select Color"); - if (color.isValid()) { - return color.name(); - } - return ""; -} - -QFont MainWindow::setFont() -{ - bool ok; - QFont font = QFontDialog::getFont(&ok, QFont(), this, "Select Font"); - if (ok) { - return font; - } - return QFont(""); -} - - -void MainWindow::setupTreeView(const QList <State> states) -{ - for(int i=0; i<states.count(); i++){ - QFileIconProvider provider; - QTreeWidgetItem *root = new QTreeWidgetItem(bottomrightwidget_tree); - root->setText(0, states[i].getTitle()); - root->setText(1, QString::number( states[i].getStateId())); - root->setText(2, "Up"); - root->setText(3, "Down"); - if( states[i].getChildList().count() > 0) - root->setIcon(0, provider.icon(QFileIconProvider::Folder)); - else - root->setIcon(0, provider.icon(QFileIconProvider::File)); - bottomrightwidget_tree->addTopLevelItem(root); - fillTree(root, states[i]); - } -} - -void MainWindow::fillTree(QTreeWidgetItem *root, const State &state) -{ - for(int i=0; i<state.getChildList().count() ; i++){ - QTreeWidgetItem *child = new QTreeWidgetItem(); - QFileIconProvider provider; - child->setText(0, state.getChildAt(i).getTitle()); - child->setText(1, QString::number(state.getChildAt(i).getStateId())); - child->setText(2, "Up"); - child->setText(3, "Down"); - if(state.getChildAt(i).getChildList().count() > 0) - child->setIcon(0, provider.icon(QFileIconProvider::Folder)); - else - child->setIcon(0, provider.icon(QFileIconProvider::File)); - root->addChild(child); - root->setExpanded(true); - fillTree(child, state.getChildAt(i)); - } -} - - -void MainWindow::onUpdateModelTreeRequested(const QList<State> &states) -{ - disconnect(bottomrightwidget_tree, &QTreeWidget::itemDoubleClicked, this, &MainWindow::treeActionRequested); - bottomrightwidget_tree->clear(); - setupTreeView(states); - connect(bottomrightwidget_tree, &QTreeWidget::itemDoubleClicked, this, &MainWindow::treeActionRequested); -} - -void MainWindow::treeActionRequested(QTreeWidgetItem *item, int column) -{ - if(column == 2){ - qDebug()<<"mainwindow Up"<<item->text(1); - QString itemText = item->text(1); - emit changeStateHierarchyRequested(itemText.toInt(), -1); - }else if(column == 3 ){ - qDebug()<<"mainwindow Down"<<item->text(1); - QString itemText = item->text(1); - emit changeStateHierarchyRequested(itemText.toInt(), 1); - } -} - -void MainWindow::onLockRequested(const bool &val) -{ - childList[0]->setLocked(val); - itemsToolBar->setLocked(val); - runButton_svg->setEnabled(!val); - runButton_scxml->setEnabled(!val); - clearButton->setEnabled(!val); - bottomrightwidget_tree->setEnabled(!val); - if(val){ - QPixmap pix(":/new/prefix1/Images/closed-lock.svg"); - pix.scaled(lockerButton->size()); - lockerButton->setIcon(pix); - } else{ - QPixmap pix(":/new/prefix1/Images/open-lock.svg"); - pix.scaled(lockerButton->size()); - lockerButton->setIcon(pix); - } -} - - -// Console work in progress - -//void MainWindow::onRunScxmlClicked() -//{ -// emit runScxmlScriptRequested(consoleScxml->getContentAsXml()); //=================== -//} - - -//void MainWindow::onRunSvgClicked() -//{ -// emit runSvgScriptRequested(consoleSvg->getContentAsXml()); //=================== -//} - -//void MainWindow::onScxmlSaved(const XmlObject &scxml) -//{ -// consoleScxml->setContentAsXml(scxml); -//} - -//void MainWindow::onSvgSaved(const XmlObject &svg) -//{ -// consoleSvg->setContentAsXml(svg); -//} diff --git a/Modules/Fsm/View/mainwindow.h b/Modules/Fsm/View/mainwindow.h deleted file mode 100644 index a181351331d6ea875eedbe450598be7c7474705c..0000000000000000000000000000000000000000 --- a/Modules/Fsm/View/mainwindow.h +++ /dev/null @@ -1,119 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include <QMainWindow> -#include "dragwidget.h" -#include "view.h" -#include "Modules/Fsm/Model/transition.h" - - -QT_BEGIN_NAMESPACE -namespace Ui { class MainWindow; } -QT_END_NAMESPACE - -class DragWidget; -class View; -class MainWindow : public QMainWindow -{ - Q_OBJECT -public: - explicit MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - - void addChild(State sub, const QString &string, State *super); - - void onDefaultStateCreated(const State &defState); - void onStateCreated(const State &newState); - void onStateChanged(const State &changedState); - void onStateContextMenuGenerated(const State &state); - void onStateDeleted(const int &id); - - void onStateHierarchyRetrieved(const int &stateHierarchy); - void onTransitionCreated(const Transition &transition); - void onTransitionChanged(const Transition &transition); - void onTransitionDeleted(const int &id); - void onTransitionContextMenuGenerated(const Transition &transition); -// void onScxmlSaved(const XmlObject &scxml); -// void onSvgSaved(const XmlObject &svg); - void onClearViewRequested(); - void onPathChecked(const bool &check); - void onUpdateModelTreeRequested(const QList <State> &states); - - QString setColor(); - QFont setFont(); - -public slots: - //void onRunScxmlClicked(); - //void onRunSvgClicked(); - void onClearAllRequested(); - void onSaveRequested(); - void onSaveAsRequested(); - void onCheckPathRequested(); - void onOpenRequested(); - void onNewRequested(); - void onShowCodeRequested(); - - void onSetBackgroundColor(); - void onSetBorderColor(); - void onSetTextColor(); - void onSetTextFont(); - -private slots: - void treeActionRequested(QTreeWidgetItem *item, int column); - void onLockRequested(const bool &val); - -private: - void createActions(); - void createMenus(); - void setupTreeView(const QList<State> states); - void fillTree(QTreeWidgetItem *root, const State &state); - -signals: - void runScxmlScriptRequested(const XmlObject &script); - void runSvgScriptRequested(const XmlObject &script); - void clearAllRequested(); - void checkPathRequested(); - void saveRequested(); - void saveAsRequested(const QString &path); - void openRequested(const QString &path); - void showCodeRequested(); - - void setColorRequested(const QString &attribute,const QString &color, const int &id); - void setFontRequested(const QFont &font, const int &id); - - void changeStateHierarchyRequested(const int &id, const int &step); -// void degradeStateRequested(const int &id); - -private: - Ui::MainWindow *ui; - DragWidget *itemsToolBar; - QList <DragWidget *> childList; - QTabWidget *tabWidget; - QTreeWidget *bottomrightwidget_tree; - - - QRadioButton *lockerButton; - QPushButton *saveButton; - QPushButton *runButton_scxml; - QPushButton *runButton_svg; - QPushButton *showCodeButton; - QPushButton *clearButton; - - - - QMenu *fileMenu; - QMenu *editMenu; - QMenu *formatMenu; - QAction *newAct; - QAction *openAct; - QAction *saveAct; - QAction *saveAsAct; - QAction *exitAct; - QAction *setBackgroundColorAct; - QAction *setBorderColorAct; - QAction *setTextColorAct; - QAction *setFontAct; - -}; - -#endif // MAINWINDOW_H diff --git a/Modules/Fsm/View/mainwindow.ui b/Modules/Fsm/View/mainwindow.ui deleted file mode 100644 index 6c9bb09b5d7a6b86d965912221bfb715ec85de73..0000000000000000000000000000000000000000 --- a/Modules/Fsm/View/mainwindow.ui +++ /dev/null @@ -1,1125 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>MainWindow</class> - <widget class="QMainWindow" name="MainWindow"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>800</width> - <height>600</height> - </rect> - </property> - <property name="windowTitle"> - <string>MainWindow</string> - </property> - <property name="styleSheet"> - <string notr="true">/* - * The MIT License (MIT) - * - * Copyright (c) <2013-2014> <Colin Duquesnoy> - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -QProgressBar:horizontal { - border: 1px solid #3A3939; - text-align: center; - padding: 1px; - background: #201F1F; -} -QProgressBar::chunk:horizontal { - background-color: qlineargradient(spread:reflect, x1:1, y1:0.545, x2:1, y2:0, stop:0 rgba(28, 66, 111, 255), stop:1 rgba(37, 87, 146, 255)); -} - -QToolTip -{ - border: 1px solid #3A3939; - background-color: rgb(90, 102, 117);; - color: white; - padding: 1px; - opacity: 200; -} - -QWidget -{ - color: silver; - background-color: #302F2F; - selection-background-color:#2dff6c; - selection-color: black; - background-clip: border; - border-image: none; - outline: 0; -} - -QWidget:item:hover -{ - background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0 #2dff6c, stop: 1 #2dff6c); - color: black; -} - -QWidget:item:selected -{ - background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0 #2dff6c, stop: 1 #2dff6c); -} - -QMenuBar -{ - background-color: #302F2F; - color: silver; -} - -QMenuBar::item -{ - background: transparent; -} - -QMenuBar::item:selected -{ - background: transparent; - border: 1px solid #3A3939; -} - -QMenuBar::item:pressed -{ - border: 1px solid #3A3939; - background-color: #2dff6c; - color: black; - margin-bottom:-1px; - padding-bottom:1px; -} - -QMenu -{ - border: 1px solid #3A3939; - color: silver; - margin: 2px; -} - -QMenu::icon -{ - margin: 5px; -} - -QMenu::item -{ - padding: 5px 30px 5px 30px; - margin-left: 5px; - border: 1px solid transparent; /* reserve space for selection border */ -} - -QMenu::item:selected -{ - color: black; -} - -QWidget:disabled -{ - color: #404040; - background-color: #302F2F; -} - -QAbstractItemView -{ - alternate-background-color: #3A3939; - color: silver; - border: 1px solid 3A3939; - border-radius: 3px; - padding: 1px; -} - -QWidget:focus, QMenuBar:focus -{ - border: 1px solid rgb(48, 86, 111); -} - -QTabWidget:focus, QCheckBox:focus, QRadioButton:focus -{ - border: none; -} - -QLineEdit -{ - background-color: #201F1F; - padding: 2px; - border-style: solid; - border: 1px solid #3A3939; - border-radius: 3px; - color: silver; -} - -QGroupBox { - border:1px solid #3A3939; - border-radius: 7px; - margin-top: 2ex; -} - -QGroupBox::title { - subcontrol-origin: margin; - subcontrol-position: top center; - padding-left: 10px; - padding-right: 10px; -} - -QAbstractScrollArea -{ - border-radius: 3px; - border: 1px solid #3A3939; -} - -QScrollBar:horizontal -{ - height: 15px; - margin: 0px 11px 0px 11px; - border: 1px solid #3A3939; - border-radius: 6px; - background-color: QLinearGradient( x1: 0, y1: 1, x2: 0, y2: 0, - stop: 0 #302F2F, stop: 1 #484846); -} - -QScrollBar::handle:horizontal -{ - background-color: QLinearGradient( x1: 0, y1: 1, x2: 0, y2: 0, - stop: 0 #605F5F, stop: 1 #787876); - min-width: 5px; - border-radius: 5px; -} - -QScrollBar::sub-line:horizontal -{ - border-image: url(:/qss_icons/rc/right_arrow_disabled.png); - width: 10px; - height: 10px; - subcontrol-position: right; - subcontrol-origin: margin; -} - -QScrollBar::add-line:horizontal -{ - border-image: url(:/qss_icons/rc/left_arrow_disabled.png); - height: 10px; - width: 10px; - subcontrol-position: left; - subcontrol-origin: margin; -} - -QScrollBar::sub-line:horizontal:hover,QScrollBar::sub-line:horizontal:on -{ - border-image: url(:/qss_icons/rc/right_arrow.png); - height: 10px; - width: 10px; - subcontrol-position: right; - subcontrol-origin: margin; -} - - -QScrollBar::add-line:horizontal:hover, QScrollBar::add-line:horizontal:on -{ - border-image: url(:/qss_icons/rc/left_arrow.png); - height: 10px; - width: 10px; - subcontrol-position: left; - subcontrol-origin: margin; -} - -QScrollBar::up-arrow:horizontal, QScrollBar::down-arrow:horizontal -{ - background: none; -} - - -QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal -{ - background: none; -} - -QScrollBar:vertical -{ - background-color: QLinearGradient( x1: 1, y1: 0, x2: 0, y2: 0, - stop: 0 #302F2F, stop: 1 #484846); - width: 15px; - margin: 11px 0 11px 0; - border: 1px solid #3A3939; - border-radius: 6px; -} - -QScrollBar::handle:vertical -{ - background-color: QLinearGradient( x1: 1, y1: 0, x2: 0, y2: 0, - stop: 0 #605F5F, stop: 1 #787876); - min-height: 5px; - border-radius: 5px; -} - -QScrollBar::sub-line:vertical -{ - border-image: url(:/qss_icons/rc/up_arrow_disabled.png); - height: 10px; - width: 10px; - subcontrol-position: top; - subcontrol-origin: margin; -} - -QScrollBar::add-line:vertical -{ - - border-image: url(:/qss_icons/rc/down_arrow_disabled.png); - height: 10px; - width: 10px; - subcontrol-position: bottom; - subcontrol-origin: margin; -} - -QScrollBar::sub-line:vertical:hover,QScrollBar::sub-line:vertical:on -{ - - border-image: url(:/qss_icons/rc/up_arrow.png); - height: 10px; - width: 10px; - subcontrol-position: top; - subcontrol-origin: margin; -} - - -QScrollBar::add-line:vertical:hover, QScrollBar::add-line:vertical:on -{ - border-image: url(:/qss_icons/rc/down_arrow.png); - height: 10px; - width: 10px; - subcontrol-position: bottom; - subcontrol-origin: margin; -} - -QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical -{ - background: none; -} - - -QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical -{ - background: none; -} - -QTextEdit -{ - background-color: #201F1F; - color: silver; - border: 1px solid #3A3939; -} - -QPlainTextEdit -{ - /*background-color: #201F1F;; - color: silver; - border-radius: 3px; - border: 1px solid #3A3939;*/ - - - background-color: #201F1F; - padding: 2px; - border-style: solid; - border: 1px solid #3A3939; - border-radius: 3px; - color: silver; -} - -QHeaderView::section -{ - background-color: #3A3939; - color: silver; - padding-left: 4px; - border: 1px solid #6c6c6c; -} - -QCheckBox:disabled -{ - color: #404040; -} - -QSizeGrip { - image: url(:/qss_icons/rc/sizegrip.png); - width: 12px; - height: 12px; -} - - -QMainWindow::separator -{ - background-color: #302F2F; - color: white; - padding-left: 4px; - spacing: 2px; - border: 1px dashed #3A3939; -} - -QMainWindow::separator:hover -{ - - background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:0 #58677b, - stop:0.5 #2dff6c stop:1 #58677b); - color: white; - padding-left: 4px; - border: 1px solid #3A3939; - spacing: 2px; -} - - -QMenu::separator -{ - height: 1px; - background-color: #3A3939; - color: white; - padding-left: 4px; - margin-left: 10px; - margin-right: 5px; -} - - - -QRadioButton::indicator:checked, QRadioButton::indicator:unchecked{ - color: #b1b1b1; - background-color: #302F2F; - border: 1px solid silver; - border-radius: 5px; -} - - - -QRadioButton::indicator:checked -{ - background-color: qradialgradient( - cx: 0.5, cy: 0.5, - fx: 0.5, fy: 0.5, - radius: 1.0, - stop: 0.25 #2dff6c, - stop: 0.3 #302F2F - ); -} - -QCheckBox, QRadioButton -{ - padding: 3px; - outline: none; -} - -QCheckBox::indicator{ - color: #b1b1b1; - background-color: #302F2F; - border: 1px solid silver; - width: 9px; - height: 9px; -} - -QRadioButton::indicator -{ - border-radius: 7px; - width: 9px; - height: 9px; -} - -QCheckBox::indicator:pressed -{ - border: 1px solid #2dff6c; -} - -QRadioButton::indicator:hover, QCheckBox::indicator:hover -{ - border: 1px solid #2dff6c; -} - -QCheckBox::indicator:checked -{ - background-color: #2dff6c; -} - -QCheckBox::indicator:disabled, QRadioButton::indicator:disabled -{ - border: 1px solid #444; -} - -QFrame -{ - border-radius: 3px; - background: #BEBEBE; - border-style: solid; - border: 1px solid #3A3939; -} - -QStackedWidget -{ - border: none; -} - -QToolBar { - border: 1px solid #393838; - background: 1px solid #302F2F; - font-weight: bold; -} - -QToolBar::handle:horizontal { - image: url(:/qss_icons/rc/Hmovetoolbar.png); -} -QToolBar::handle:vertical { - image: url(:/qss_icons/rc/Vmovetoolbar.png); -} -QToolBar::separator:horizontal { - image: url(:/qss_icons/rc/Hsepartoolbar.png); -} -QToolBar::separator:vertical { - image: url(:/qss_icons/rc/Vsepartoolbars.png); -} - -QPushButton -{ - color: silver; - background-color: QLinearGradient( x1: 0, y1: 1, x2: 0, y2: 0, - stop: 0 #302F2F, stop: 1 #484846); - border-width: 1px; - border-color: #4A4949; - border-style: solid; - padding-top: 5px; - padding-bottom: 5px; - padding-left: 5px; - padding-right: 5px; - border-radius: 5px; - outline: none; -} - -QPushButton:disabled -{ - background-color: #302F2F; - border-width: 1px; - border-color: #3A3939; - border-style: solid; - padding-top: 5px; - padding-bottom: 5px; - padding-left: 10px; - padding-right: 10px; - /*border-radius: 3px;*/ - color: #454545; -} - -QComboBox -{ - selection-background-color: #2dff6c; - background-color: #201F1F; - border-style: solid; - border: 1px solid #3A3939; - border-radius: 3px; - padding: 2px; - min-width: 75px; -} - -QComboBox:hover,QPushButton:hover,QAbstractSpinBox:hover,QLineEdit:hover,QTextEdit:hover,QPlainTextEdit:hover,QAbstractView:hover -{ - border: 1px solid #2dff6c; - color: silver; -} - -QComboBox:on -{ - background-color: #626873; - padding-top: 3px; - padding-left: 4px; - selection-background-color: #4a4a4a; -} - -QComboBox QAbstractItemView -{ - background-color: #201F1F; - border-radius: 3px; - border: 1px solid #3A3939; - selection-background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0 #2dff6c, stop: 1 #2dff6c); -} - -QComboBox::drop-down -{ - subcontrol-origin: padding; - subcontrol-position: top right; - width: 15px; - - border-left-width: 0px; - border-left-color: darkgray; - border-left-style: solid; - border-top-right-radius: 3px; - border-bottom-right-radius: 3px; -} - -QComboBox::down-arrow -{ - image: url(:/qss_icons/rc/down_arrow_disabled.png); -} - -QComboBox::down-arrow:on, QComboBox::down-arrow:hover, -QComboBox::down-arrow:focus -{ - image: url(:/qss_icons/rc/down_arrow.png); -} - -QPushButton:pressed -{ - background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0 #302F2F, stop: 1 #484846); -} - -QAbstractSpinBox { - padding-top: 2px; - padding-bottom: 2px; - border: 1px solid #3A3939; - background-color: #201F1F; - color: silver; - border-radius: 3px; - min-width: 75px; -} - -QAbstractSpinBox:up-button -{ - background-color: transparent; - subcontrol-origin: border; - subcontrol-position: center right; -} - -QAbstractSpinBox:down-button -{ - background-color: transparent; - subcontrol-origin: border; - subcontrol-position: center left; -} - -QAbstractSpinBox::up-arrow,QAbstractSpinBox::up-arrow:disabled,QAbstractSpinBox::up-arrow:off { - image: url(:/qss_icons/rc/up_arrow_disabled.png); - width: 10px; - height: 10px; -} -QAbstractSpinBox::up-arrow:hover -{ - image: url(:/qss_icons/rc/up_arrow.png); -} - - -QAbstractSpinBox::down-arrow,QAbstractSpinBox::down-arrow:disabled,QAbstractSpinBox::down-arrow:off -{ - image: url(:/qss_icons/rc/down_arrow_disabled.png); - width: 10px; - height: 10px; -} -QAbstractSpinBox::down-arrow:hover -{ - image: url(:/qss_icons/rc/down_arrow.png); -} - - -QLabel -{ - border: 0px solid black; - background: transparent; - border-radius: 10px; -} - - -QTabWidget::pane { - border: 1px solid #3A3939; -} - -QTabBar -{ - qproperty-drawBase: 0; - padding-right: 15px; -} - -QTabBar:focus -{ - border: 0px transparent black; -} - -QTabBar::close-button { - image: url(:/qss_icons/rc/close.png); - background: transparent; - icon-size: 10px; - padding: 5px; -} - -QTabBar::close-button:hover -{ - background: rgba(255, 255, 255, 20); - border-radius: 3px; -} - -QTabBar::close-button:pressed { - padding: 5px 4px 4px 5px; -} - -/* TOP - BOTTOM TABS */ -QTabBar::tab:top { - color: #b1b1b1; - border: 1px solid #3A3939; - background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, - stop:1 #302F2F, stop:0 #5A5959); - padding-left: 5px; - padding-right: 5px; - padding-top: 3px; - padding-bottom: 2px; - margin-right: -1px; - - border-top-left-radius: 3px; - border-top-right-radius: 3px; -} - -QTabBar::tab:bottom { - color: #b1b1b1; - border: 1px solid #3A3939; - background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, - stop:1 #302F2F, stop:0 #5A5959); - padding-left: 5px; - padding-right: 5px; - padding-top: 3px; - padding-bottom: 2px; - margin-right: -1px; - - border-bottom-left-radius: 3px; - border-bottom-right-radius: 3px; -} - -QTabBar::tab:top:last, QTabBar::tab:bottom:last -{ - margin-right: 0; -} - -QTabBar::tab:top:first:!selected, QTabBar::tab:bottom:first:!selected -{ - margin-left: 0px; -} - -QTabBar::tab:top:!selected -{ - color: #b1b1b1; - margin-top: 3px; - background-color: #302F2F; -} - -QTabBar::tab:top:selected -{ - margin-bottom: 0px; -} - -QTabBar::tab:bottom:!selected -{ - color: #b1b1b1; - margin-bottom: 3px; - background-color: #302F2F; -} - -QTabBar::tab:bottom:selected -{ - margin-top: 0px; -} - -/* LEFT - RIGHT TABS */ -QTabBar::tab:left { - color: #b1b1b1; - border: 1px solid #3A3939; - background-color: QLinearGradient(x1:1, y1:0, x2:0, y2:0, - stop:1 #302F2F, stop:0 #5A5959); - padding-left: 3px; - padding-right: 2px; - padding-top: 5px; - padding-bottom: 5px; - margin-bottom: -1px; - - border-top-right-radius: 3px; - border-bottom-right-radius: 3px; -} - -QTabBar::tab:right { - color: #b1b1b1; - border: 1px solid #3A3939; - background-color: QLinearGradient(x1:0, y1:0, x2:1, y2:0, - stop:1 #302F2F, stop:0 #5A5959); - padding-left: 3px; - padding-right: 2px; - padding-top: 5px; - padding-bottom: 5px; - margin-bottom: -1px; - - border-top-left-radius: 3px; - border-bottom-left-radius: 3px; -} - -QTabBar::tab:left:!selected -{ - color: #b1b1b1; - margin-right: 3px; - background-color: #302F2F; -} - -QTabBar::tab:left:selected -{ - margin-left: 0px; -} - -QTabBar::tab:right:!selected -{ - color: #b1b1b1; - margin-left: 3px; - background-color: #302F2F; -} - -QTabBar::tab:right:selected -{ - margin-right: 0px; -} - -QTabBar QToolButton::right-arrow:enabled { - image: url(:/qss_icons/rc/right_arrow.png); - } - - QTabBar QToolButton::left-arrow:enabled { - image: url(:/qss_icons/rc/left_arrow.png); - } - -QTabBar QToolButton::right-arrow:disabled { - image: url(:/qss_icons/rc/right_arrow_disabled.png); - } - - QTabBar QToolButton::left-arrow:disabled { - image: url(:/qss_icons/rc/left_arrow_disabled.png); - } - - -QDockWidget { - border: 1px solid #403F3F; - titlebar-close-icon: url(:/qss_icons/rc/close.png); - titlebar-normal-icon: url(:/qss_icons/rc/undock.png); -} - -QDockWidget::close-button, QDockWidget::float-button { - border: 1px solid transparent; - border-radius: 3px; - background: transparent; - icon-size: 10px; -} - -QDockWidget::close-button:hover, QDockWidget::float-button:hover { - background: rgba(255, 255, 255, 10); -} - -QDockWidget::close-button:pressed, QDockWidget::float-button:pressed { - padding: 1px -1px -1px 1px; - background: rgba(255, 255, 255, 10); -} - -QSlider::groove:horizontal { - border: 1px solid #3A3939; - height: 8px; - background: #201F1F; - margin: 2px 0; - border-radius: 4px; -} - -QSlider::handle:horizontal { - background: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0.0 silver, stop: 0.2 #a8a8a8, stop: 1 #727272); - border: 1px solid #3A3939; - width: 14px; - height: 14px; - margin: -4px 0; - border-radius: 7px; -} - -QSlider::groove:vertical { - border: 1px solid #3A3939; - width: 8px; - background: #201F1F; - margin: 0 0px; - border-radius: 4px; -} - -QSlider::handle:vertical { - background: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0.0 silver, - stop: 0.2 #a8a8a8, stop: 1 #727272); - border: 1px solid #3A3939; - width: 14px; - height: 14px; - margin: 0 -4px; - border-radius: 7px; -} - -QToolButton { - background-color: transparent; - border: 1px solid #3A3939; - border-radius: 3px; - margin: 3px; -} - -QToolButton:pressed, QToolButton::menu-button:pressed { - background-color: #4A4949; - border: 1px solid silver; -} - -QToolButton:hover, QToolButton::menu-button:hover { - background-color: #4A4949; - border: 1px solid gray; -} - -QToolButton[popupMode="1"] { /* only for MenuButtonPopup */ - padding-right: 20px; /* make way for the popup button */ -} - -QToolButton[popupMode="2"] { /* only for MenuButtonPopup */ - padding-right: 10px; /* make way for the popup button */ -} - -/* the subcontrols below are used only in the MenuButtonPopup mode */ -QToolButton::menu-button { - border: 1px solid #3A3939; - border-top-right-radius: 6px; - border-bottom-right-radius: 6px; - /* 16px width + 4px for border = 20px allocated above */ - width: 16px; -} - -QToolButton::menu-arrow { - image: url(:/qss_icons/rc/down_arrow.png); -} - -QToolButton::menu-arrow:open { - top: 1px; left: 1px; /* shift it a bit */ -} - -QPushButton::menu-indicator { - subcontrol-origin: padding; - subcontrol-position: bottom right; - left: 8px; -} - -QTableView -{ - border: transparent; - gridline-color: #6c6c6c; - background-color: #201F1F; -} - - -QTableView, QHeaderView -{ - border-radius: 0px; -} - -QTableView::item:pressed{ - background: #2dff6c; - color: #FFFFFF; -} - -QTableView::item:selected:active - { - background: #2dff6c; - color: #FFFFFF; -} - - -QHeaderView -{ - border: 1px transparent; - margin: 0px; - padding: 0px; -} - -QHeaderView::section { - background-color: #3A3939; - color: silver; - padding: 4px; - border: 1px solid #6c6c6c; - border-radius: 0px; - text-align: center; -} - -QHeaderView::section::vertical::first, QHeaderView::section::vertical::only-one -{ - border-top: 1px solid #6c6c6c; -} - -QHeaderView::section::vertical -{ - border-top: transparent; -} - -QHeaderView::section::horizontal::first, QHeaderView::section::horizontal::only-one -{ - border-left: 1px solid #6c6c6c; -} - -QHeaderView::section::horizontal -{ - border-left: transparent; -} - - -QHeaderView::section:checked - { - color: white; - background-color: #5A5959; - } - - /* style the sort indicator */ -QHeaderView::down-arrow { - image: url(:/qss_icons/rc/down_arrow.png); -} - -QHeaderView::up-arrow { - image: url(:/qss_icons/rc/up_arrow.png); -} - - -QTableCornerButton::section { - background-color: #3A3939; - border: 1px solid #3A3939; - border-radius: 0px; -} - -QToolBox::tab { - background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, - stop:1 #302F2F, stop:0 #5A5959); - padding-left: 3px; - padding-right: 2px; - padding-top: 5px; - padding-bottom: 5px; - margin-bottom: -1px; - - border-top-left-radius: 3px; - border-top-right-radius: 3px; - color: darkgray; - } - - QToolBox::tab:selected { /* italicize selected tabs */ - font: italic bold; - color: white; - } - -QStatusBar::item { - border: 1px solid #3A3939; - border-radius: 3px; - } - - -QTreeView, QListView -{ - border: 1px solid #2dff6c; - background-color: #201F1F; -} - -QTreeView:branch:selected, QTreeView:branch:hover -{ - background: url(:/qss_icons/rc/transparent.png); -} - -QTreeView::branch:has-siblings:!adjoins-item { - border-image: url(:/qss_icons/rc/transparent.png); -} - -QTreeView::branch:has-siblings:adjoins-item { - border-image: url(:/qss_icons/rc/transparent.png); -} - -QTreeView::branch:!has-children:!has-siblings:adjoins-item { - border-image: url(:/qss_icons/rc/transparent.png); -} - -QTreeView::branch:has-children:!has-siblings:closed, -QTreeView::branch:closed:has-children:has-siblings { - image: url(:/qss_icons/rc/branch_closed.png); -} - -QTreeView::branch:open:has-children:!has-siblings, -QTreeView::branch:open:has-children:has-siblings { - image: url(:/qss_icons/rc/branch_open.png); -} - -QTreeView::branch:has-children:!has-siblings:closed:hover, -QTreeView::branch:closed:has-children:has-siblings:hover { - image: url(:/qss_icons/rc/branch_closed-on.png); - } - -QTreeView::branch:open:has-children:!has-siblings:hover, -QTreeView::branch:open:has-children:has-siblings:hover { - image: url(:/qss_icons/rc/branch_open-on.png); - } - -/*QListView::item:!selected:hover, */QListView::item:!selected:hover, QTreeView::item:!selected:hover { - background-color: /*rgba(0, 0, 0, 0)*/ #212121; - border: 1px solid #3a3939; - outline: 0; - color: #FFFFFF -} - -/*QListView::item:selected:hover, */QListView::item:selected:hover, QTreeView::item:selected:hover { - background-color: /*#2dff6c*/#201f1f;; - border: 1px solid #2dff6c; - color: #FFFFFF; -} - - -/*QListView::item:!selected:!hover, */QListView::item:!selected:!hover, QTreeView::item:!selected:!hover { - background-color: /*#2dff6c*/#201f1f;; - border: 1px solid #3a3939; - color: #FFFFFF; -} - - -/*QListView::item:selected:!hover, */QListView::item:selected:!hover, QTreeView::item:selected:!hover { - background-color: /*#2dff6c*/#201f1f;; - border: 1px solid #2dff6c; - color: #FFFFFF; -} -/*QTreeView::item:selected:active, QListView::item:selected:active -{ - -} - - -QListView::item:pressed, QTreeView::item:pressed -{ - background-color: #2dff6c;; - border: 1px solid #3a3939; - color: #FFFFFF; -}*/ -QTabWidget -{ -background-color: #302f2f; -}</string> - </property> - <widget class="QWidget" name="centralwidget"/> - <widget class="QMenuBar" name="menubar"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>800</width> - <height>21</height> - </rect> - </property> - </widget> - <widget class="QStatusBar" name="statusbar"/> - </widget> - <resources/> - <connections/> -</ui> diff --git a/Modules/Fsm/View/pixcache.cpp b/Modules/Fsm/View/pixcache.cpp deleted file mode 100644 index ce33c9268741f7a616ed3e7679701272b6440d3f..0000000000000000000000000000000000000000 --- a/Modules/Fsm/View/pixcache.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include "pixcache.h" - -PixCache::PixCache(QObject *parent) : QObject(parent) -{ - -} - -PixCache::~PixCache() -{ - -} - -QMap<int , QList <QPixmap> > PixCache::getMap() const -{ - return cache; -} - - -void PixCache::addState(const State &state, const int &hierarchyLevel) -{ -// State temp = state; -//// temp.setStroke(highlightColor[hierarchyLevel]); -// temp.setFill(highlightColor[hierarchyLevel]); -// temp.drawStateBox(); -// QPixmap defPix, highPix; -// defPix.loadFromData(state.getXml().toXml().toUtf8()); -// highPix.loadFromData(temp.getXml().toXml().toUtf8()); - -// if(!cache.keys().contains(state.getStateId())){ -// cache.insert(state.getStateId(), {defPix, highPix}); -// } else{ -// cache[state.getStateId()] = QList <QPixmap>({defPix, highPix}); -// } -} - - -void PixCache::clear() -{ - cache.clear(); -} - -QList <QString> PixCache::getPalette() -{ - return highlightColor; -} - - -void PixCache::setPalette(const QList<QString> &color) -{ - highlightColor = color; -} - -QPixmap PixCache::highlightOff(const int &id) -{ - if(cache.keys().contains(id)){ - if(cache[id].count() > 0){ - if(highlightedStates.contains(id)) highlightedStates.removeOne(id); - return cache[id][0]; - } - } - return QPixmap(); -} - - -QPixmap PixCache::highlightOn(const int &id) -{ - if(cache.keys().contains(id)){ - if(cache[id].count() == 2){ - if(!highlightedStates.contains(id)) highlightedStates.append(id); - return cache[id][1]; - } - } - return QPixmap(); -} - -void PixCache::updateCache(const State &state) -{ - emit stateHierarchyRequested(state); - addState(state, tempColor); -} - -QList <int> PixCache::getHighlightedStates() const -{ - return highlightedStates; -} - - -void PixCache::remove(const int &id) -{ - cache.remove(id); - highlightedStates.removeOne(id); -} - -void PixCache::getHierarchyColor(const int &hierarchyColor) -{ - if(hierarchyColor < highlightColor.count()) - tempColor = hierarchyColor; - else - tempColor = hierarchyColor % highlightColor.count(); -} diff --git a/Modules/Fsm/View/pixcache.h b/Modules/Fsm/View/pixcache.h deleted file mode 100644 index 27767060f55a9577cc33a339d8df66f0d9a5d8d2..0000000000000000000000000000000000000000 --- a/Modules/Fsm/View/pixcache.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef PIXCACHE_H -#define PIXCACHE_H - -#include "Modules/Fsm/Model/state.h" -#include "QtWidgets" -#include "QMap" -#include <QObject> - -class PixCache : public QObject -{ - Q_OBJECT - -public: - PixCache(QObject *parent = nullptr); - ~PixCache(); - - QMap <int, QList<QPixmap>> getMap() const ; - - void addState(const State &state, const int &hierarchyLevel = 0); - void clear(); - - void setPalette(const QList <QString> &color); - QList <QString> getPalette(); - - QPixmap highlightOff(const int &id); - QPixmap highlightOn(const int &id); - - void resetAll(); - void highlight(const int &id); - void updateCache(const State &state); - QList<int> getHighlightedStates() const; - void resetHighlighted(); - void setCacheRepo(const QString &s); - void remove(const int &id); -private: - -signals: - void stateHierarchyRequested(const State &state); - -public slots: - void getHierarchyColor(const int &hierarchyColor); - -private: - - QMap <int , QList<QPixmap>> cache; - QList <QString> highlightColor; - QList <int> highlightedStates; - int tempColor; -}; - -#endif // PIXCACHE_H diff --git a/Modules/Fsm/View/statedialog.cpp b/Modules/Fsm/View/statedialog.cpp deleted file mode 100644 index 9771f221d289e2399c7656e14af1ad4f845c1213..0000000000000000000000000000000000000000 --- a/Modules/Fsm/View/statedialog.cpp +++ /dev/null @@ -1,247 +0,0 @@ -#include "statedialog.h" -#include "ui_statedialog.h" - - -StateDialog::StateDialog(DragWidget *caller, QWidget *parent) : QDialog(parent), ui(new Ui::StateDialog), callerWidget(caller) -{ - ui->setupUi(this); - this->setFixedHeight(1200); - this->setMinimumWidth(1500); - - - ui->flagstransition_container->layout()->setMargin(0); - ui->topLabel_container->layout()->setMargin(0); - - QScrollBar *scroll = new QScrollBar(ui->treeWidget); - ui->treeWidget->addScrollBarWidget(scroll, Qt::AlignRight); - ui->treeWidget->setMinimumWidth(400); - - ui->groupBox->setAlignment(Qt::AlignLeft); - ui->groupBox_2->setAlignment(Qt::AlignLeft); - ui->groupBox_3->setAlignment(Qt::AlignLeft); - ui->groupBox_4->setAlignment(Qt::AlignLeft); - ui->groupBox_5->setAlignment(Qt::AlignLeft); - ui->groupBox_6->setAlignment(Qt::AlignLeft); - - QSize pushbuttonSize(100, 50); - ui->fontPushButton->setFixedSize(pushbuttonSize); - ui->palettePushButton->setFixedSize(pushbuttonSize); - ui->setEntry->setFixedSize(pushbuttonSize); - ui->setExit->setFixedSize(pushbuttonSize); - ui->textEditButton->setFixedSize(pushbuttonSize); - ui->positionPushButton->setFixedSize(pushbuttonSize); - ui->sizePushButton->setFixedSize(pushbuttonSize); - - - ui->fontSpinBox->setFixedWidth(20); - ui->colorComboBox->addItem("Background"); - ui->colorComboBox->addItem("Border"); - ui->colorComboBox->addItem("Text"); - - ui->fontSpinBox->setMinimum(2); - ui->fontSpinBox->setMaximum(72); - - connect(ui->deleteLabelButton, &QPushButton::clicked, this, &StateDialog::onDeleteClicked); - connect(ui->textEditButton, &QPushButton::clicked, this, &StateDialog::onEditClicked); - connect(ui->setEntry, &QPushButton::clicked, this, &StateDialog::onSetEntryClicked); - connect(ui->setExit, &QPushButton::clicked, this, &StateDialog::onSetExitClicked); - connect(ui->startTransitionButton, &QPushButton::clicked, this, &StateDialog::onTransitionStart); - connect(ui->stopTransitionButton, &QPushButton::clicked, this, &StateDialog::onTransitionStop); - - connect(ui->palettePushButton, &QPushButton::clicked, this, &StateDialog::onPaletteRequested); - connect(ui->fontPushButton, &QPushButton::clicked, this, &StateDialog::onSetFontRequested); - - connect(ui->positionPushButton, &QPushButton::clicked, this, &StateDialog::onSetPositionRequested); - connect(ui->sizePushButton, &QPushButton::clicked, this, &StateDialog::onSetSizeRequested); - - connect(ui->initial_radioButton, &QRadioButton::toggled, this, &StateDialog::onSetInitialRequested); - connect(ui->final_radioButton, &QRadioButton::toggled, this, &StateDialog::onSetFinalRequested); - - - if(callerWidget->getTransitionStartStateId() != -1) - ui->stopTransitionButton->setEnabled(true); - else - ui->stopTransitionButton->setEnabled(false); - - this->setWindowTitle("State"); - this->setWindowIcon(QIcon(":/new/prefix1/Images/skyward_icon.ico")); -// this->setFixedHeight(this->height()); -} - -StateDialog::~StateDialog() -{ - delete ui; -} - -void StateDialog::setTargetState(const State &target) -{ - targetState = target; - showStateProperties(); - setupTreeView(); - ui->initial_radioButton->setChecked(targetState.isInitial()); - ui->final_radioButton->setChecked(targetState.isFinal()); -} - -void StateDialog::showStateProperties() -{ - ui->stateIdLabel->setText(QString::number(targetState.getStateId())); - ui->widthSpinBox->setMinimum(0); - ui->widthSpinBox->setMaximum(callerWidget->width()); - ui->widthSpinBox->setValue(targetState.getBoxSize().width()); - - ui->heightSpinBox->setMinimum(0); - ui->heightSpinBox->setMaximum(callerWidget->height()); - ui->heightSpinBox->setValue(targetState.getBoxSize().height()); - - ui->X_SpinBox->setMinimum(0); - ui->X_SpinBox->setMaximum(100000); - ui->X_SpinBox->setValue(targetState.getBoxPosition().x()); - - ui->Y_SpinBox->setMinimum(0); - ui->Y_SpinBox->setMaximum(100000); - ui->Y_SpinBox->setValue(targetState.getBoxPosition().y()); - - ui->lineEdit->setText(targetState.getTitle()); - ui->entry_lineEdit->setText(targetState.getEntryAction()); - ui->exit_lineEdit->setText(targetState.getExitAction()); - - ui->fontSpinBox->setValue(targetState.getFontSize().toInt()); - ui->fontComboBox->addItem(targetState.getFontFamily()); -// QAction *action = new QAction("Prova", this); - -// setBackgroundColorAct = new QAction(tr("Background"), this); -// action->setStatusTip(tr("Set states background color")); -// connect(action, &QAction::triggered, this, &StateDialog::contextMenuEvent); - - -} - -void StateDialog::setupTreeView() -{ -// ui->treeWidget->setStyleSheet("background-color: #201f1f;"); - ui->treeWidget->setColumnCount(3); - ui->treeWidget->setHeaderLabels({"Title", "Id", "Class"}); - QFileIconProvider provider; - QTreeWidgetItem *root = new QTreeWidgetItem(ui->treeWidget); - root->setText(0, targetState.getTitle()); - root->setText(1, QString::number(targetState.getStateId())); - if(targetState.isInitial()){ - root->setText(2, "initial");} - else if(targetState.isFinal()){ - root->setText(2, "final");} - else { - root->setText(2, "state"); - } - -// root->setBackground(0, QBrush("#2d2d2d")); -// root->setBackground(1, QBrush("#2d2d2d")); - if(targetState.getChildList().count() > 0) - root->setIcon(0, provider.icon(QFileIconProvider::Folder)); - else - root->setIcon(0, provider.icon(QFileIconProvider::File)); - - ui->treeWidget->addTopLevelItem(root); - fillTree(root, targetState); - ui->treeWidget->showDropIndicator(); -} - -void StateDialog::fillTree(QTreeWidgetItem *root, const State &state) -{ - for(int i=0; i<state.getChildList().count() ; i++){ - QTreeWidgetItem *child = new QTreeWidgetItem(); - QFileIconProvider provider; - child->setText(0, state.getChildAt(i).getTitle()); - child->setText(1, QString::number(state.getChildAt(i).getStateId())); - if(targetState.isInitial()){ - root->setText(2, "initial");} - else if(targetState.isFinal()){ - root->setText(2, "final");} - else { - root->setText(2, "state"); - } -// child->setBackground(0, QBrush("#2d2d2d")); -// child->setBackground(1, QBrush("#2d2d2d")); - if(state.getChildAt(i).getChildList().count() > 0) - child->setIcon(0, provider.icon(QFileIconProvider::Folder)); - else - child->setIcon(0, provider.icon(QFileIconProvider::File)); - root->addChild(child); - root->setExpanded(true); - fillTree(child, state.getChildAt(i)); - } -} - - -void StateDialog::setCaller(DragWidget *caller) -{ - callerWidget = caller; -} - - -void StateDialog::onDeleteClicked() -{ - callerWidget->onStateDeleteRequested(targetState.getStateId()); - this->close(); -} - -void StateDialog::onEditClicked() -{ - callerWidget->onStateEditTitleRequested(targetState.getStateId(), ui->lineEdit->text()); -} - -void StateDialog::onTransitionStart() -{ - callerWidget->initializeTrans(targetState); - this->close(); -} - - -void StateDialog::onTransitionStop() -{ - callerWidget->finalizeTrans(targetState); - this->close(); -} - -void StateDialog::onPaletteRequested() -{ - const QColor color = QColorDialog::getColor("#e6e6e6",this, "Select Color"); - if (color.isValid()) { - callerWidget->onSetColorRequested(ui->colorComboBox->currentText(),color.name(), targetState.getStateId()); -// qDebug()<<ui->colorComboBox->currentText()<<" "<<color.name(); - } -} - -void StateDialog::onSetFontRequested() -{ - callerWidget->onSetTextFontRequested(QFont("Helvetica,sans-Serif", ui->fontSpinBox->value()), targetState.getStateId()); -} - -void StateDialog::onSetPositionRequested() -{ - callerWidget->onSetPositionRequested(QPoint(ui->X_SpinBox->value(), ui->Y_SpinBox->value()), targetState.getStateId()); -} - -void StateDialog::onSetSizeRequested() -{ - callerWidget->onSetSizeRequested(QPoint(targetState.getBoxPosition().x() + ui->widthSpinBox->value(),targetState.getBoxPosition().y() + ui->heightSpinBox->value()), targetState.getStateId()); -} - -void StateDialog::onSetEntryClicked() -{ - callerWidget->onSetEntryRequested(ui->entry_lineEdit->text() , targetState.getStateId()); -} - -void StateDialog::onSetExitClicked() -{ - callerWidget->onSetExitRequested(ui->exit_lineEdit->text() , targetState.getStateId()); -} - -void StateDialog::onSetInitialRequested(const bool &val) -{ - callerWidget->onSetInitialRequested(val, targetState.getStateId()); -} - -void StateDialog::onSetFinalRequested(const bool &val) -{ - callerWidget->onSetFinalRequested(val, targetState.getStateId()); -} diff --git a/Modules/Fsm/View/statedialog.h b/Modules/Fsm/View/statedialog.h deleted file mode 100644 index 70477c13b962dabf833436d8ca9dcdcc38821033..0000000000000000000000000000000000000000 --- a/Modules/Fsm/View/statedialog.h +++ /dev/null @@ -1,58 +0,0 @@ - -#ifndef STATEDIALOG_H -#define STATEDIALOG_H - -#include <QDialog> -#include "Modules/Fsm/Model/state.h" -#include "dragwidget.h" - -QT_BEGIN_NAMESPACE -namespace Ui { class StateDialog; } -QT_END_NAMESPACE - -class DragWidget; -class StateDialog : public QDialog -{ - Q_OBJECT - -public: - - explicit StateDialog(DragWidget *caller, QWidget *parent = nullptr); - ~StateDialog(); - - void setTargetState(const State &target); - void setCaller(DragWidget* caller); - -public slots: - virtual void onDeleteClicked(); - void onEditClicked(); -// void onSetClicked(); -// void onSaveClicked(); - - void onTransitionStart(); - void onTransitionStop(); - - void onPaletteRequested(); - void onSetFontRequested(); - - void onSetPositionRequested(); - void onSetSizeRequested(); - - void onSetEntryClicked(); - void onSetExitClicked(); - - void onSetInitialRequested(const bool &val); - void onSetFinalRequested(const bool &val); - -private: - void showStateProperties(); - void setupTreeView(); - void fillTree(QTreeWidgetItem *root, const State &state); - -private: - Ui::StateDialog *ui = nullptr; - State targetState; - DragWidget *callerWidget = nullptr; -}; - -#endif // STATEDIALOG_H diff --git a/Modules/Fsm/View/statedialog.ui b/Modules/Fsm/View/statedialog.ui deleted file mode 100644 index 38b07e955781254ac9ee27a0ae2601e182673404..0000000000000000000000000000000000000000 --- a/Modules/Fsm/View/statedialog.ui +++ /dev/null @@ -1,334 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>StateDialog</class> - <widget class="QDialog" name="StateDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>1000</width> - <height>500</height> - </rect> - </property> - <property name="minimumSize"> - <size> - <width>1000</width> - <height>500</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>16777215</height> - </size> - </property> - <property name="windowTitle"> - <string>Dialog</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_6"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="sizeConstraint"> - <enum>QLayout::SetDefaultConstraint</enum> - </property> - </layout> - </item> - <item> - <widget class="QTreeWidget" name="treeWidget"> - <column> - <property name="text"> - <string notr="true">1</string> - </property> - </column> - </widget> - </item> - <item> - <widget class="QWidget" name="widget" native="true"> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QWidget" name="topLabel_container" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout_8"> - <item> - <widget class="QLabel" name="label"> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>State ID:</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="stateIdLabel"> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>TextLabel</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>463</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QWidget" name="flagstransition_container" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout_9"> - <item> - <widget class="QGroupBox" name="groupBox_7"> - <property name="title"> - <string>Flags</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_10"> - <item> - <widget class="QRadioButton" name="initial_radioButton"> - <property name="text"> - <string>Initial</string> - </property> - </widget> - </item> - <item> - <widget class="QRadioButton" name="final_radioButton"> - <property name="text"> - <string>Final</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_8"> - <property name="title"> - <string>Transition</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_11"> - <item> - <widget class="QPushButton" name="startTransitionButton"> - <property name="text"> - <string>Start</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="stopTransitionButton"> - <property name="text"> - <string>Stop</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox"> - <property name="title"> - <string>Font</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QComboBox" name="fontComboBox"/> - </item> - <item> - <widget class="QSpinBox" name="fontSpinBox"/> - </item> - <item> - <widget class="QPushButton" name="fontPushButton"> - <property name="text"> - <string>Set</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_2"> - <property name="title"> - <string>Color</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <widget class="QComboBox" name="colorComboBox"/> - </item> - <item> - <widget class="QPushButton" name="palettePushButton"> - <property name="text"> - <string>Palette</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_3"> - <property name="title"> - <string>Size</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <item> - <widget class="QLabel" name="width_label"> - <property name="text"> - <string>Width:</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="widthSpinBox"/> - </item> - <item> - <widget class="QLabel" name="height_label"> - <property name="text"> - <string>Height:</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="heightSpinBox"/> - </item> - <item> - <widget class="QPushButton" name="sizePushButton"> - <property name="text"> - <string>Set</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_4"> - <property name="title"> - <string>Position</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_5"> - <item> - <widget class="QLabel" name="X_label"> - <property name="text"> - <string>X:</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="X_SpinBox"/> - </item> - <item> - <widget class="QLabel" name="Y_label"> - <property name="text"> - <string>Y:</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="Y_SpinBox"/> - </item> - <item> - <widget class="QPushButton" name="positionPushButton"> - <property name="text"> - <string>Set</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_5"> - <property name="title"> - <string>Actions</string> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="0" column="1"> - <widget class="QLineEdit" name="entry_lineEdit"/> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Entry:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="exit_lineEdit"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Exit:</string> - </property> - </widget> - </item> - <item row="0" column="2"> - <widget class="QPushButton" name="setEntry"> - <property name="text"> - <string>Edit</string> - </property> - </widget> - </item> - <item row="1" column="2"> - <widget class="QPushButton" name="setExit"> - <property name="text"> - <string>Edit</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_6"> - <property name="title"> - <string>Title</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_7"> - <item> - <widget class="QLineEdit" name="lineEdit"/> - </item> - <item> - <widget class="QPushButton" name="textEditButton"> - <property name="text"> - <string>Edit</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QPushButton" name="deleteLabelButton"> - <property name="text"> - <string>Delete</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/Modules/Fsm/View/transitiondialog.cpp b/Modules/Fsm/View/transitiondialog.cpp deleted file mode 100644 index b0811d3a7a404d7d1a6d9fae713964eb765836e5..0000000000000000000000000000000000000000 --- a/Modules/Fsm/View/transitiondialog.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "transitiondialog.h" -#include "ui_transitiondialog.h" - -TransitionDialog::TransitionDialog(DragWidget *caller, QWidget *parent) : QDialog(parent), ui(new Ui::TransitionDialog) -{ - ui->setupUi(this); - callerWidget = caller; - connect(ui->deleteButton, &QPushButton::clicked, this, &TransitionDialog::onDeleteClicked); - connect(ui->textEditButton, &QPushButton::clicked, this, &TransitionDialog::onEventEditClicked); - connect(ui->actionEditButton, &QPushButton::clicked, this, &TransitionDialog::onActionEditClicked); - connect(ui->fontPushButton, &QPushButton::clicked, this, &TransitionDialog::onSetFontRequested); - - - QSize pushbuttonSize(100, 50); - ui->textEditButton->setFixedSize(pushbuttonSize); - ui->actionEditButton->setFixedSize(pushbuttonSize); - ui->fontPushButton->setFixedSize(pushbuttonSize); - - ui->fontSpinBox->setMinimum(2); - ui->fontSpinBox->setMaximum(72); - - this->setWindowTitle("Transition"); - this->setWindowIcon(QIcon(":/new/prefix1/Images/skyward_icon.ico")); - this->setMinimumWidth(450); - this->setFixedSize(QSize(800,500)); -} - - - -TransitionDialog::~TransitionDialog() -{ - delete ui; -} - -void TransitionDialog::setTargetTransition(const Transition &t) -{ - targetTransition = t; - ui->startIdLabel->setText(QString::number(targetTransition.getStartState().getStateId())); - ui->stopIdLabel->setText(QString::number(targetTransition.getStopState().getStateId())); - ui->event_lineEdit->setText(targetTransition.getTransitionTitle()); - ui->action_lineEdit->setText(targetTransition.getAction()); - ui->fontSpinBox->setValue(targetTransition.getFontSize().toInt()); - ui->fontComboBox->setCurrentText(targetTransition.getFontFamily()); -} - -void TransitionDialog::setCaller(DragWidget *caller) -{ - callerWidget = caller; -} - -void TransitionDialog::onDeleteClicked() -{ - callerWidget->onTransitionDeleteRequested(targetTransition.getTransitionId()); - this->close(); -} - -void TransitionDialog::onEventEditClicked() -{ - callerWidget->onTransitionEditTitleRequested(targetTransition.getTransitionId(), ui->event_lineEdit->text()); -} - -void TransitionDialog::onActionEditClicked() -{ - callerWidget->onTransitionEditActionRequested(targetTransition.getTransitionId(), ui->action_lineEdit->text()); -} - - -void TransitionDialog::onSetFontRequested() -{ - callerWidget->onSetTextFontRequested(QFont("Helvetica,sans-Serif", ui->fontSpinBox->value()), targetTransition.getTransitionId()); -} diff --git a/Modules/Fsm/View/transitiondialog.h b/Modules/Fsm/View/transitiondialog.h deleted file mode 100644 index 4a298a950e1d34a62eb4d77a8821b78ba68da5e4..0000000000000000000000000000000000000000 --- a/Modules/Fsm/View/transitiondialog.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef TRANSITIONDIALOG_H -#define TRANSITIONDIALOG_H - -#include <QDialog> -#include <QtWidgets> -#include "Modules/Fsm/Model/transition.h" -#include "dragwidget.h" - - - -QT_BEGIN_NAMESPACE -namespace Ui { - class TransitionDialog; -} -QT_END_NAMESPACE - - -class DragWidget; -class TransitionDialog : public QDialog -{ - Q_OBJECT -public: - explicit TransitionDialog(DragWidget *caller, QWidget *parent = nullptr); - ~TransitionDialog(); - - void setTargetTransition(const Transition &t); - void setCaller(DragWidget *caller); - -public slots: - void onDeleteClicked(); - void onEventEditClicked(); - void onActionEditClicked(); - void onSetFontRequested(); -private: - Ui::TransitionDialog *ui = nullptr; - Transition targetTransition; - DragWidget *callerWidget = nullptr; -}; - -#endif // TRANSITIONDIALOG_H diff --git a/Modules/Fsm/View/transitiondialog.ui b/Modules/Fsm/View/transitiondialog.ui deleted file mode 100644 index ed0c458dc76c050fb1e884a2eaac6aa6d79bc7fb..0000000000000000000000000000000000000000 --- a/Modules/Fsm/View/transitiondialog.ui +++ /dev/null @@ -1,147 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>TransitionDialog</class> - <widget class="QDialog" name="TransitionDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>400</width> - <height>300</height> - </rect> - </property> - <property name="windowTitle"> - <string>Dialog</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="1" column="1"> - <widget class="QLabel" name="stopIdLabel"> - <property name="text"> - <string>TextLabel</string> - </property> - </widget> - </item> - <item row="0" column="2"> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="3" column="0" colspan="5"> - <widget class="QGroupBox" name="groupBox"> - <property name="title"> - <string/> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="0" column="2"> - <widget class="QPushButton" name="textEditButton"> - <property name="text"> - <string>Edit</string> - </property> - </widget> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Event:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="event_lineEdit"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Action:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="action_lineEdit"/> - </item> - <item row="1" column="2"> - <widget class="QPushButton" name="actionEditButton"> - <property name="text"> - <string>Edit</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLabel" name="startIdLabel"> - <property name="text"> - <string>TextLabel</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Stop State ID: </string> - </property> - </widget> - </item> - <item row="1" column="2"> - <spacer name="horizontalSpacer_2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="5" column="0" colspan="5"> - <widget class="QPushButton" name="deleteButton"> - <property name="text"> - <string>Delete</string> - </property> - </widget> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Start State ID: </string> - </property> - </widget> - </item> - <item row="2" column="0" colspan="3"> - <widget class="QGroupBox" name="groupBox_2"> - <property name="title"> - <string>Font</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QFontComboBox" name="fontComboBox"/> - </item> - <item> - <widget class="QSpinBox" name="fontSpinBox"/> - </item> - <item> - <widget class="QPushButton" name="fontPushButton"> - <property name="text"> - <string>Set</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/Modules/Fsm/View/view.cpp b/Modules/Fsm/View/view.cpp deleted file mode 100644 index 1209ef3d128bf09ccd9f54bfab4eec0d54dd51ea..0000000000000000000000000000000000000000 --- a/Modules/Fsm/View/view.cpp +++ /dev/null @@ -1,174 +0,0 @@ -#include "view.h" - - -View::View(QObject *parent) : QObject(parent) -{ - mainwindow= new MainWindow(); - connect(mainwindow, &MainWindow::runScxmlScriptRequested, this, &View::onRunScxmlScriptRequested); - connect(mainwindow, &MainWindow::runSvgScriptRequested, this, &View::onRunSvgScriptRequested); - connect(mainwindow, &MainWindow::clearAllRequested, this, &View::onClearAllRequested); - connect(mainwindow, &MainWindow::checkPathRequested, this, &View::onCheckPathRequested); - connect(mainwindow, &MainWindow::saveRequested, this, &View::onSaveRequested); - connect(mainwindow, &MainWindow::saveAsRequested, this, &View::onSaveAsRequested); - connect(mainwindow, &MainWindow::openRequested, this, &View::onOpenRequested); - connect(mainwindow, &MainWindow::showCodeRequested, this, &View::onShowCodeRequested); - connect(mainwindow, &MainWindow::setColorRequested, this, &View::onSetColorRequested); - connect(mainwindow, &MainWindow::setFontRequested, this, &View::onSetTextFont); - connect(mainwindow, &MainWindow::changeStateHierarchyRequested, this, &View::onChangeStateHierarchyRequested); -// connect(mainwindow, &MainWindow::degradeStateRequested, this, &View::onDegradeStateRequested); - -} - -View::~View() -{ - -} - -void View::showMainWindow() -{ - mainwindow->show(); -} - - -void View::createDefaultState() -{ - emit createDefaultStateRequested(); -} - -void View::onDefaultStateCreated(const State &defState) -{ - mainwindow->onDefaultStateCreated(defState); -} - -QString View::styleSheet() const -{ - return mainwindow->styleSheet(); -} - -void View::onStateChanged(const State &changedState) -{ - mainwindow->onStateChanged(changedState); -} - -void View::onStateCreated(const State &newState) -{ - mainwindow->onStateCreated(newState); -} - - -void View::onStateContextMenuGenerated(const State &state) -{ - mainwindow->onStateContextMenuGenerated(state); -} - -void View::onStateDeleted(const int &id) -{ - mainwindow->onStateDeleted(id); -} - -void View::onStateHierarchyRetrieved(const int &stateHierarchy) -{ - mainwindow->onStateHierarchyRetrieved(stateHierarchy); -} - -void View::onTransitionCreated(const Transition &transition) -{ - mainwindow->onTransitionCreated(transition); -} - -void View::onTransitionChanged(const Transition &transition) -{ - mainwindow->onTransitionChanged(transition); -} - -void View::onTransitionDeleted(const int &id) -{ - mainwindow->onTransitionDeleted(id); -} - -void View::onTransitionContextMenuGenerated(const Transition &transition) -{ - mainwindow->onTransitionContextMenuGenerated(transition); -} - -void View::onScxmlSaved(const XmlObject &scxml) -{ - //mainwindow->onScxmlSaved(scxml); -} - -void View::onSvgSaved(const XmlObject &svg) -{ - //mainwindow->onSvgSaved(svg); -} - -void View::onClearAllRequested() -{ - emit clearAllRequested(); -} - -void View::onRunScxmlScriptRequested(const XmlObject &script) -{ - emit runScxmlScriptRequested(script); -} - -void View::onRunSvgScriptRequested(const XmlObject &script) -{ - emit runSvgScriptRequested(script); -} - -void View::onClearViewRequested() -{ - mainwindow->onClearViewRequested(); -} - -void View::onCheckPathRequested() -{ - emit checkPathRequested(); -} - -void View::onPathChecked(const bool &check) -{ - mainwindow->onPathChecked(check); -} - -void View::onSaveRequested() -{ - emit saveRequested(); -} - -void View::onSaveAsRequested(const QString &path) -{ - emit saveAsRequested(path); - -} - -void View::onOpenRequested(const QString &path) -{ - emit openRequested(path); -} - -void View::onShowCodeRequested() -{ - emit showCodeRequested(); -} - -void View::onSetColorRequested(const QString &attribute, const QString &color, const int &id) -{ - emit setColorRequested(attribute, color, id); - -} - -void View::onSetTextFont(const QFont &font, const int &id) -{ - emit setFontRequested(font, id); -} - -void View::onUpdateModelTreeRequested(const QList<State> &states) -{ - mainwindow->onUpdateModelTreeRequested(states); -} - -void View::onChangeStateHierarchyRequested(const int &id, const int &step) -{ - emit changeStateHierarchyRequested(id, step); -} diff --git a/Modules/Fsm/View/view.h b/Modules/Fsm/View/view.h deleted file mode 100644 index 7d2c453bfcbf76272d2523cf3d22cd19dd66f414..0000000000000000000000000000000000000000 --- a/Modules/Fsm/View/view.h +++ /dev/null @@ -1,109 +0,0 @@ -#ifndef VIEW_H -#define VIEW_H - -#include <QObject> -#include <QtWidgets> -#include "mainwindow.h" -#include "dragwidget.h" -#include "Modules/Fsm/Model/transition.h" - -class DragWidget; -class MainWindow; -class View : public QObject -{ - Q_OBJECT - -public: - View(QObject *parent = nullptr); - ~View(); - - void showMainWindow(); - - void createDefaultState(); - void forward_createStateRequested(const QPoint &point); - void forward_changeStatePositionRequested(const int &id); - QString styleSheet() const; -public slots: - void onStateChanged(const State &changedState); -// void onStateIdChanged(const State &state); - void onDefaultStateCreated(const State &defState); - void onStateCreated(const State &newState); - void onStateContextMenuGenerated(const State &state); - void onStateDeleted(const int &id); -// void onSuperstatesBoxSizeChanged(const QList<State> &superstates); - void onStateHierarchyRetrieved(const int &stateHierarchy); - void onTransitionCreated(const Transition &transition); - void onTransitionChanged(const Transition &transition); - void onTransitionDeleted(const int &id); - void onTransitionContextMenuGenerated(const Transition &transition); - void onScxmlSaved(const XmlObject &scxml); - void onRunScxmlScriptRequested(const XmlObject &script); - void onRunSvgScriptRequested(const XmlObject &script); - - void onClearViewRequested(); - - - void onSvgSaved(const XmlObject &svg); - void onClearAllRequested(); - void onCheckPathRequested(); - void onPathChecked(const bool &check); - void onSaveRequested(); - void onSaveAsRequested(const QString &path); - void onOpenRequested(const QString &path); - void onShowCodeRequested(); - - void onSetColorRequested(const QString &attribute,const QString &color, const int &id); - void onSetTextFont(const QFont &font, const int &id); - - void onUpdateModelTreeRequested(const QList <State> &states); - void onChangeStateHierarchyRequested(const int &id, const int &step); - - -signals: - void createDefaultStateRequested(); - void createStateRequested(const QPoint &point, const QPoint &offset); - void changeStatePositionRequested(const int &id, const QPoint &point, const QPoint &offset); - void resizeStateRequested(const int &id, const QPoint &point); - - void stateContextMenuRequested(const int &id); - void transitionContextMenuRequested(const int &id); - - void stateEditTitleRequested(const int &id, const QString &title); - void transitionEditTitleRequested(const int &id, const QString &title); - void transitionEditActionRequested(const int &id, const QString &action); - - - void stateDeleteRequested(const int &id); - void stateHierarchyRequested(const State &state); - - void createTransitionRequested(const int &startState, const int &stopState); - void transitionDeleteRequested(const int &id); - - - void saveRequested(); - void saveAsRequested(const QString &path); - void openRequested(const QString &path); - - - void runScxmlScriptRequested(const XmlObject &script); - void runSvgScriptRequested(const XmlObject &script); - void clearAllRequested(); - void checkPathRequested(); - void showCodeRequested(); - - - void setColorRequested(const QString &attribute,const QString &color, const int &id); - void setFontRequested(const QFont &font, const int &id); - - void setEntryRequested(const QString &action, const int &id); - void setExitRequested(const QString &action, const int &id); - - void changeStateHierarchyRequested(const int &id, const int &step); - void setInitialRequested(const bool &val, const int &id); - void setFinalRequested(const bool &val, const int &id); - -private: - MainWindow *mainwindow; - -}; -#endif // VIEW_H diff --git a/Modules/Fsm/defaultstatesettings.cpp b/Modules/Fsm/defaultstatesettings.cpp deleted file mode 100644 index 886dd87d576b9770931505d438bfa1dcfc246b0e..0000000000000000000000000000000000000000 --- a/Modules/Fsm/defaultstatesettings.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "defaultstatesettings.h" - -DefaultStateSettings::DefaultStateSettings() -{ - -} - -QPoint DefaultStateSettings::getBoxPosition() const -{ - return boxPosition; -} - -QSize DefaultStateSettings::getBoxSize() const -{ - return boxSize; -} - -QPoint DefaultStateSettings::getTitlePosition() const -{ - return titlePosition; -} - -QString DefaultStateSettings::getFont_family() const -{ - return font_family; -} - -QString DefaultStateSettings::getFont_size() const -{ - return font_size; -} - -QString DefaultStateSettings::getText_anchor() const -{ - return text_anchor; -} - -QString DefaultStateSettings::getText_color() const -{ - return text_color; -} - -QString DefaultStateSettings::getStroke() const -{ - return stroke; -} - -QString DefaultStateSettings::getFill() const -{ - return fill; -} - diff --git a/Modules/Fsm/defaultstatesettings.h b/Modules/Fsm/defaultstatesettings.h deleted file mode 100644 index 6e090fd2495cafa3bc27876053d50d90143e746a..0000000000000000000000000000000000000000 --- a/Modules/Fsm/defaultstatesettings.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef DEFAULTSTATESETTINGS_H -#define DEFAULTSTATESETTINGS_H - -#include <QPoint> -#include <QSize> -#include <QString> - -class DefaultStateSettings -{ -public: - DefaultStateSettings(); - - - QPoint getBoxPosition() const; - - QSize getBoxSize() const; - - QPoint getTitlePosition() const; - - QString getFont_family() const; - - QString getFont_size() const; - - QString getText_anchor() const; - - QString getText_color() const; - - QString getStroke() const; - - QString getFill() const; - -private: - QPoint boxPosition = QPoint(0,0); - QSize boxSize = QSize(220,28); - QPoint titlePosition = QPoint(110,14); - QString font_family = "Helvetica,sans-Serif"; - QString font_size = "12"; - QString text_anchor = "middle"; - QString text_color = "#000000"; - QString stroke = "#000000"; - QString fill = "#e6e6e6"; -}; - -#endif // DEFAULTSTATESETTINGS_H diff --git a/Modules/Fsm/draggablewidget.cpp b/Modules/Fsm/draggablewidget.cpp deleted file mode 100644 index f3b12dbd57670e2426990941306dc429502c0c7b..0000000000000000000000000000000000000000 --- a/Modules/Fsm/draggablewidget.cpp +++ /dev/null @@ -1,107 +0,0 @@ -#include "draggablewidget.h" - -#include <QMimeData> -#include <QDrag> -#include <QPainter> -#include <QMouseEvent> -#include <QApplication> -#include <QGraphicsDropShadowEffect> - -#include <QDebug> - -DraggableWidget::DraggableWidget() -{ - buildUI(); -} - -void DraggableWidget::dragEnterEvent(QDragEnterEvent *event) -{ - if (event->mimeData()->hasFormat("application/x-dnditemdata")) { - if (event->source() == this) { - event->setDropAction(Qt::MoveAction); - event->accept(); - } - } else { - event->ignore(); - } -} - -void DraggableWidget::mouseMoveEvent(QMouseEvent *event) -{ - if (!(event->buttons() & Qt::LeftButton)) - return; - if ((event->pos() - dragStartPosition).manhattanLength() < QApplication::startDragDistance()) - return; - - QDrag *drag = new QDrag(this); - QMimeData *mimeData = new QMimeData; - QByteArray itemData; - QDataStream dataStream(&itemData, QIODevice::WriteOnly); - dataStream << QPoint(event->pos() - this->pos()); - mimeData->setData("application/x-dnditemdata", itemData); - drag->setMimeData(mimeData); // This data will be passed to the dropWidget - - // Create the shady drag placeholder and hide the previous label - QPixmap pixmap = this->pixmap(Qt::ReturnByValue); - drag->setPixmap(pixmap); - drag->setHotSpot(event->pos() - this->pos()); - QPixmap tempPixmap = pixmap; - QPainter painter; - painter.begin(&tempPixmap); - painter.fillRect(pixmap.rect(), QColor(127, 127, 127, 127)); - painter.end(); - this->setPixmap(tempPixmap); - - // _______________________________________ - - - Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction); - Q_UNUSED(dropAction) - - this->setPixmap(pixmap); -} - -void DraggableWidget::buildUI() -{ - // We used an svg (xml) to define the design of the QLabel - XmlObject pixmapXml = createDraggableWidgetPixmapSvg(); - - QPixmap pix; - pix.loadFromData(pixmapXml.toXml().toUtf8()); - setPixmap(pix); - //move(point); - show(); - setAttribute(Qt::WA_DeleteOnClose); -// QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect(); -// effect->setBlurRadius(5); -// setGraphicsEffect(effect); -} - -XmlObject DraggableWidget::createDraggableWidgetPixmapSvg() -{ - XmlObject xml("svg"); - QSize s = defaultStateSettings.getBoxSize(); - XmlObject rect("rect"); - - xml.addAttribute("height", QString::number(s.height())); - xml.addAttribute("width", QString::number(s.width())); - - rect.addAttribute("fill", defaultStateSettings.getFill()); - rect.addAttribute("fill-rule", "nonzero"); - rect.addAttribute("height", QString::number(s.height())); - rect.addAttribute("width", QString::number(s.width())); - rect.addAttribute("stroke", defaultStateSettings.getStroke()); - rect.addAttribute("x", "0"); - rect.addAttribute("y", "0"); - rect.addAttribute("rx", "10"); - rect.addAttribute("stroke-width", "3"); - - xml.addChild(rect); - return xml; -} - -void DraggableWidget::mousePressEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) - dragStartPosition = event->pos(); -} diff --git a/Modules/Fsm/draggablewidget.h b/Modules/Fsm/draggablewidget.h deleted file mode 100644 index d1187a305d31179f0527d3222cf6e1f594ffcf88..0000000000000000000000000000000000000000 --- a/Modules/Fsm/draggablewidget.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef DRAGABLEWIDGET_H -#define DRAGABLEWIDGET_H - -#include <QLabel> -#include "defaultstatesettings.h" -#include "Core/xmlobject.h" - - -class DraggableWidget : public QLabel -{ -public: - DraggableWidget(); - -protected: - void mousePressEvent(QMouseEvent *event) override; - void dragEnterEvent(QDragEnterEvent *event) override; - void mouseMoveEvent(QMouseEvent *event) override; - - void buildUI(); - XmlObject createDraggableWidgetPixmapSvg(); - -private: - QPoint dragStartPosition; - DefaultStateSettings defaultStateSettings; -}; - -#endif // DRAGABLEWIDGET_H diff --git a/Modules/Fsm/fsmviewermodule.cpp b/Modules/Fsm/fsmviewermodule.cpp deleted file mode 100644 index b7ea1949a5aad579598b7d34f5dbd220eb68a99f..0000000000000000000000000000000000000000 --- a/Modules/Fsm/fsmviewermodule.cpp +++ /dev/null @@ -1,158 +0,0 @@ -#include "fsmviewermodule.h" -#include "ui_fsmviewermodule.h" - -#include "View/dragwidget.h" -#include "draggablewidget.h" - -FsmViewerModule::FsmViewerModule(QWidget *parent) : DefaultModule(parent), ui(new Ui::FsmViewerModule) -{ - ui->setupUi(this); - - defaultContextMenuSetup(); - buildUi(); -} - -FsmViewerModule::~FsmViewerModule() -{ - if(topDragWidget != nullptr) - delete topDragWidget; - - if(centralDragWidget != nullptr) - delete centralDragWidget; - - delete ui; -} - -QWidget *FsmViewerModule::toWidget() -{ - return this; -} - -XmlObject FsmViewerModule::toXmlObject() -{ - return XmlObject(getName(ModuleId::FSMVIEWER)); -} - -void FsmViewerModule::fromXmlObject(const XmlObject &xmlObject) -{ - Q_UNUSED(xmlObject); -} - -void FsmViewerModule::onLockClicked(bool checked) -{ - if(checked){ - lock(); - } - else{ - unlock(); - } -} - -void FsmViewerModule::lock() -{ - -} - -void FsmViewerModule::unlock() -{ - -} - -void FsmViewerModule::onTopDragWidgetDeleted() -{ - topDragWidget = nullptr; -} - -void FsmViewerModule::onCentralDragWidgetDeleted() -{ - centralDragWidget = nullptr; -} - -void FsmViewerModule::connectDragWidget(DragWidget *dragWidget) -{ - connect(dragWidget, &DragWidget::destroyed, this, &FsmViewerModule::onCentralDragWidgetDeleted); - connect(dragWidget, &DragWidget::createStateRequested, &model, &Model::onCreateStateRequested); - connect(&model, &Model::stateCreated, dragWidget, &DragWidget::onStateCreated); - connect(dragWidget, &DragWidget::resizeStateRequested, &model, &Model::onResizeStateRequested); - connect(&model, &Model::stateChanged, dragWidget, &DragWidget::onStateChanged); - connect(dragWidget, &DragWidget::changeStatePositionRequested, &model, &Model::onChangeStatePositionRequested); - connect(dragWidget, &DragWidget::stateContextMenuRequested, &model, &Model::onStateContextMenuRequested); - connect(&model, &Model::stateContextMenuGenerated, dragWidget, &DragWidget::onStateContextMenuGenerated); - -// connect(dragWidget, &DragWidget::createDefaultStateRequested, &model, &Model::onCreateDefaultState); -// connect(&model, &Model::defaultStateCreated, dragWidget, &DragWidget::onDefaultStateCreated); - - -// connect(&dragWidget, &DragWidget::stateEditTitleRequested, &model, &Model::onStateEditTitleRequested); -// connect(&dragWidget, &DragWidget::stateDeleteRequested, &model, &Model::onStateDeleteRequested); -// connect(&model, &Model::stateDeleted, &dragWidget, &DragWidget::onStateDeleted); - -//// connect(&m, &Model::superstatesBoxSizeChanged, &v, &DragWidget::onSuperstatesBoxSizeChanged); - -// connect(&dragWidget, &DragWidget::stateHierarchyRequested, &model, &Model::onStateHierarchyRequested); -// connect(&model, &Model::stateHierarchyRetrieved, &dragWidget, &DragWidget::onStateHierarchyRetrieved); - -// connect(&dragWidget, &DragWidget::createTransitionRequested, &model, &Model::onCreateTransitionRequested); -// connect(&model, &Model::transitionCreated, &dragWidget, &DragWidget::onTransitionCreated); - - -// connect(&dragWidget, &DragWidget::transitionDeleteRequested, &model, &Model::onTransitionDeleteRequested); -// connect(&model, &Model::transitionDeleted, &dragWidget, &DragWidget::onTransitionDeleted); - - -// connect(&dragWidget, &DragWidget::transitionContextMenuRequested, &model, &Model::onTransitionContextMenuRequested); -// connect(&model, &Model::transitionContextMenuGenerated, &dragWidget, &DragWidget::onTransitionContextMenuGenerated); - -// connect(&dragWidget, &DragWidget::transitionEditTitleRequested, &model, &Model::onTransitionEditTitleRequested); -// connect(&dragWidget, &DragWidget::transitionEditActionRequested, &model, &Model::onTransitionEditActionRequested); - -// connect(&model, &Model::transitionChanged, &dragWidget, &DragWidget::onTransitionChanged); - -// connect(&v, &DragWidget::saveRequested, &model, &Model::onSaveRequested); -// connect(&v, &DragWidget::saveAsRequested, &model, &Model::onSaveAsRequested); - -// connect(&model, &Model::scxmlSaved, &v, &DragWidget::onScxmlSaved); -// connect(&model, &Model::svgSaved, &v, &DragWidget::onSvgSaved); - -// connect(&v, &DragWidget::runScxmlScriptRequested, &model, &Model::onRunScxmlScriptRequested); -// connect(&v, &DragWidget::runSvgScriptRequested, &model, &Model::onRunSvgScriptRequested); - -// connect(&model, &Model::clearViewRequested, &dragWidget, &DragWidget::onClearViewRequested); -// connect(&v, &DragWidget::clearAllRequested, &model, &Model::onClearAllRequested); - -// connect(&v, &DragWidget::checkPathRequested, &model, &Model::onCheckPathRequested); -// connect(&model, &Model::pathChecked, &v, &DragWidget::onPathChecked); - -// connect(&v, &DragWidget::openRequested, &model, &Model::onOpenRequested); -// connect(&v, &DragWidget::showCodeRequested, &model, &Model::onShowCodeRequested); - - -// connect(&dragWidget, &DragWidget::setColorRequested, &model, &Model::onSetColorRequested); -// connect(&dragWidget, &DragWidget::setFontRequested, &model, &Model::onSetFontRequested); - -// connect(&dragWidget, &DragWidget::setEntryRequested, &model, &Model::onSetEntryRequested); -// connect(&dragWidget, &DragWidget::setExitRequested, &model, &Model::onSetExitRequested); - -// connect(&model, &Model::updateModelTreeRequested, &v, &DragWidget::onUpdateModelTreeRequested); -// connect(&v, &DragWidget::changeStateHierarchyRequested, &model, &Model::onChangeStateHierarchyRequested); - -// connect(&dragWidget, &DragWidget::setInitialRequested, &model, &Model::onSetInitialRequested); -// connect(&dragWidget, &DragWidget::setFinalRequested, &model, &Model::onSetFinalRequested); -} - -void FsmViewerModule::buildUi() -{ - if(topDragWidget == nullptr){ - topDragWidget = new DraggableWidget(); - connect(topDragWidget, &DragWidget::destroyed, this, &FsmViewerModule::onTopDragWidgetDeleted); - } - if(centralDragWidget == nullptr){ - centralDragWidget = new DragWidget(this); - connectDragWidget(centralDragWidget); - centralDragWidget->setStyleSheet("background-color: #ffffff; padding: 2px; border-style: solid; border: 1px solid #3A3939; border-radius: 3px; color: silver;"); - } - - ui->top_layout->insertWidget(0, topDragWidget); - ui->central_layout->addWidget(centralDragWidget); - connect(ui->checkBox_editorLocker, &QCheckBox::clicked, this, &FsmViewerModule::onLockClicked); -} diff --git a/Modules/Fsm/fsmviewermodule.h b/Modules/Fsm/fsmviewermodule.h deleted file mode 100644 index 286451d98ab7ec567d2286ab8d683d0e4f0b1be8..0000000000000000000000000000000000000000 --- a/Modules/Fsm/fsmviewermodule.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef FSMVIEWERMODULE_H -#define FSMVIEWERMODULE_H - -#include <QWidget> -#include "Modules/DefaultModule/defaultmodule.h" -#include "Model/model.h" - -class DragWidget; -class DraggableWidget; - -namespace Ui { -class FsmViewerModule; -} - -class FsmViewerModule : public DefaultModule -{ - Q_OBJECT - -public: - explicit FsmViewerModule(QWidget *parent = nullptr); - ~FsmViewerModule(); - - QWidget *toWidget() override; - - XmlObject toXmlObject() override; - void fromXmlObject(const XmlObject &xmlObject) override; - -protected: - void onLockClicked(bool checked); - void lock(); - void unlock(); - void onTopDragWidgetDeleted(); - void onCentralDragWidgetDeleted(); - void connectDragWidget(DragWidget *dragWidget); - -private: - - void buildUi(); - - Ui::FsmViewerModule *ui; - DraggableWidget* topDragWidget = nullptr; - DragWidget* centralDragWidget = nullptr; - - Model model; -}; - -#endif // FSMVIEWERMODULE_H diff --git a/Modules/Fsm/fsmviewermodule.ui b/Modules/Fsm/fsmviewermodule.ui deleted file mode 100644 index 6d135a78dd3dc0a5e2d78aa11e12e88313566ec1..0000000000000000000000000000000000000000 --- a/Modules/Fsm/fsmviewermodule.ui +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>FsmViewerModule</class> - <widget class="QWidget" name="FsmViewerModule"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>400</width> - <height>300</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2" stretch="1,10"> - <item> - <layout class="QHBoxLayout" name="top_layout"> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QCheckBox" name="checkBox_editorLocker"> - <property name="text"> - <string>Lock</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QVBoxLayout" name="central_layout"/> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/Modules/Mavlink/mavlink_skyward_lib b/Modules/Mavlink/mavlink_skyward_lib index 890bb650e42cd272286453612303dd4d989c9041..3417d291cb7d6ced723e18d43b7263b055d0f2a7 160000 --- a/Modules/Mavlink/mavlink_skyward_lib +++ b/Modules/Mavlink/mavlink_skyward_lib @@ -1 +1 @@ -Subproject commit 890bb650e42cd272286453612303dd4d989c9041 +Subproject commit 3417d291cb7d6ced723e18d43b7263b055d0f2a7 diff --git a/Modules/Mavlink/mavlinkmodule.cpp b/Modules/Mavlink/mavlinkmodule.cpp index b148e2e49b27270f033037ee49dcb7ee7c8d459a..c04c98d28db6137c9bd6a04bbbe675da27fc4b3c 100644 --- a/Modules/Mavlink/mavlinkmodule.cpp +++ b/Modules/Mavlink/mavlinkmodule.cpp @@ -322,18 +322,18 @@ void MavlinkModule::onCommandReceived(const ModuleMessage &msg) else if(arg == "MAV_CMD_CUT_DROGUE"){ encoded_mvl_msg = mavlinkCommandAdapter.encode_NOARG_TC(MAV_CMD_CUT_DROGUE); } - else if(arg == "MAV_CMD_CUT_PRIMARY"){ - encoded_mvl_msg = mavlinkCommandAdapter.encode_NOARG_TC(MAV_CMD_CUT_PRIMARY); - } - else if(arg == "MAV_CMD_CUT_BACKUP"){ - encoded_mvl_msg = mavlinkCommandAdapter.encode_NOARG_TC(MAV_CMD_CUT_BACKUP); - } - else if(arg == "MAV_CMD_TEST_PRIMARY_CUTTER"){ - encoded_mvl_msg = mavlinkCommandAdapter.encode_NOARG_TC(MAV_CMD_TEST_PRIMARY_CUTTER); - } - else if(arg == "MAV_CMD_TEST_BACKUP_CUTTER"){ - encoded_mvl_msg = mavlinkCommandAdapter.encode_NOARG_TC(MAV_CMD_TEST_BACKUP_CUTTER); - } +// else if(arg == "MAV_CMD_CUT_PRIMARY"){ +// encoded_mvl_msg = mavlinkCommandAdapter.encode_NOARG_TC(MAV_CMD_CUT_PRIMARY); +// } +// else if(arg == "MAV_CMD_CUT_BACKUP"){ +// encoded_mvl_msg = mavlinkCommandAdapter.encode_NOARG_TC(MAV_CMD_CUT_BACKUP); +// } +// else if(arg == "MAV_CMD_TEST_PRIMARY_CUTTER"){ +// encoded_mvl_msg = mavlinkCommandAdapter.encode_NOARG_TC(MAV_CMD_TEST_PRIMARY_CUTTER); +// } +// else if(arg == "MAV_CMD_TEST_BACKUP_CUTTER"){ +// encoded_mvl_msg = mavlinkCommandAdapter.encode_NOARG_TC(MAV_CMD_TEST_BACKUP_CUTTER); +// } else if(arg == "MAV_CMD_START_LOGGING"){ encoded_mvl_msg = mavlinkCommandAdapter.encode_NOARG_TC(MAV_CMD_START_LOGGING); } @@ -358,6 +358,12 @@ void MavlinkModule::onCommandReceived(const ModuleMessage &msg) else if(arg == "MAV_CMD_TEST_MODE"){ encoded_mvl_msg = mavlinkCommandAdapter.encode_NOARG_TC(MAV_CMD_TEST_MODE); } + else if(arg == "MAV_CMD_RADIO_TM"){ + encoded_mvl_msg = mavlinkCommandAdapter.encode_NOARG_TC(MAV_CMD_RADIO_TM); + } + else if(arg == "MAV_CMD_SERIAL_TM"){ + encoded_mvl_msg = mavlinkCommandAdapter.encode_NOARG_TC(MAV_CMD_SERIAL_TM); + } // else if(arg == "MAV_CMD_WIGGLE_SERVO"){ // encoded_mvl_msg = mavlinkCommandAdapter.encode_NOARG_TC(MAV_CMD_WIGGLE_SERVO); // } diff --git a/Modules/TimerController/timercontrollermodule.cpp b/Modules/TimerController/timercontrollermodule.cpp new file mode 100644 index 0000000000000000000000000000000000000000..beadef345a5ba70c6286ab611107c4574b7a2ef4 --- /dev/null +++ b/Modules/TimerController/timercontrollermodule.cpp @@ -0,0 +1,157 @@ +#include "timercontrollermodule.h" +#include "ui_timercontrollermodule.h" + +#include <QFile> +#include <QTextStream> + +TimerControllerModule::TimerControllerModule(QWidget *parent) : DefaultModule(parent), ui(new Ui::TimerControllerModule) +{ + ui->setupUi(this); + + connect(ui->setTimer_pushButton, &QPushButton::clicked, this, &TimerControllerModule::onSetTimerClicked); + connect(ui->setLabelInfo_pushButton, &QPushButton::clicked, this, &TimerControllerModule::onSetInfoLabelClicked); + connect(ui->start_pushButton, &QPushButton::clicked, this, &TimerControllerModule::onStartTimerClicked); + connect(ui->hold_pushButton, &QPushButton::clicked, this, &TimerControllerModule::onHoldTimerClicked); + connect(ui->enableOutput_checkBox, &QCheckBox::toggled, this, &TimerControllerModule::onEnableOutputToggled); + connect(&timer, &QTimer::timeout, this, &TimerControllerModule::onTimerTick); + + initCurrentTime(); +} + +TimerControllerModule::~TimerControllerModule() +{ + delete ui; +} + +QWidget *TimerControllerModule::toWidget() +{ + return this; +} + +XmlObject TimerControllerModule::toXmlObject() +{ + return XmlObject(getName(ModuleId::TIMER_CONTROLLER)); +} + +void TimerControllerModule::fromXmlObject(const XmlObject &xmlObject) +{ + Q_UNUSED(xmlObject); +} + +void TimerControllerModule::onSetTimerClicked() +{ + initCurrentTime(); +} + +void TimerControllerModule::onStartTimerClicked() +{ + isHold = false; + if(!timer.isActive()){ + timer.start(timerIntervalMs); + } + setInfoLabel(""); +} + +void TimerControllerModule::initCurrentTime() +{ + int hours = ui->hours_spinBox->value(); + int minutes = ui->minutes_spinBox->value(); + int seconds = ui->seconds_spinBox->value(); + + currentTime = QTime(hours, minutes, seconds); + + if(ui->increment_comboBox->currentIndex() == 0){ + increment = -1; + } + else{ + increment = 1; + } + updateTimeLabel(); +} + +void TimerControllerModule::onHoldTimerClicked() +{ + timer.stop(); + isHold = true; + setInfoLabel(holdTxt); +} + +void TimerControllerModule::onSetInfoLabelClicked() +{ + setInfoLabel(ui->labelInfo_lineEdit->text()); +} + +void TimerControllerModule::onTimerTick() +{ + currentTime = currentTime.addSecs(getIncrement()); + QString output = updateTimeLabel(); + updateOutputFile(output); + + if(isTimeExpired()){ + increment = increment * -1; + } +} + +void TimerControllerModule::onEnableOutputToggled(bool val) +{ + ui->outputFilePath_lineEdit->setEnabled(!val); + isOutputEnabled = val; +} + +QString TimerControllerModule::updateTimeLabel() +{ + QString newTime = currentTime.toString(timeFormat); + QString newPrefix = getPrefix(); + + ui->time_label->setText(newTime); + ui->prefix_label->setText(newPrefix); + + return newPrefix + newTime; +} + +void TimerControllerModule::setInfoLabel(const QString &txt) +{ + ui->Info_label->setText(txt); + ui->labelInfo_lineEdit->clear(); +} + +void TimerControllerModule::updateOutputFile(const QString &outputTxt) const +{ + if(!isOutputEnabled){ + return; + } + + if(isOutputEnabled){ + QString filePath = ui->outputFilePath_lineEdit->text().trimmed(); + QFile file(filePath); + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) + return; + + QTextStream out(&file); + out << outputTxt; + } +} + +QString TimerControllerModule::getPrefix() const +{ + if(getIncrement() > 0){ + return tPlus; + }else if (getIncrement() < 0){ + return tMinus; + } + return ui->prefix_label->text(); +} + +bool TimerControllerModule::isTimeExpired() const +{ + return currentTime.hour() == 0 && currentTime.minute() == 0 && currentTime.second() == 0; +} + +int TimerControllerModule::getIncrement() const +{ + if(isHold){ + return 0; + } + return increment; +} + diff --git a/Modules/TimerController/timercontrollermodule.h b/Modules/TimerController/timercontrollermodule.h new file mode 100644 index 0000000000000000000000000000000000000000..f8cbe8168934d7d7775d90fb249e1e25c4a20a40 --- /dev/null +++ b/Modules/TimerController/timercontrollermodule.h @@ -0,0 +1,60 @@ +#ifndef TIMERCONTROLLERMODULE_H +#define TIMERCONTROLLERMODULE_H + +#include "Modules/DefaultModule/defaultmodule.h" +#include <QTimer> +#include <QTime> + + + +namespace Ui { +class TimerControllerModule; +} + +class TimerControllerModule : public DefaultModule +{ + Q_OBJECT + +public: + explicit TimerControllerModule(QWidget *parent = nullptr); + ~TimerControllerModule(); + + QWidget *toWidget() override; + + XmlObject toXmlObject() override; + void fromXmlObject(const XmlObject &xmlObject) override; + + +protected: + void onSetTimerClicked(); + void onStartTimerClicked(); + void onHoldTimerClicked(); + void onSetInfoLabelClicked(); + void onTimerTick(); + void onEnableOutputToggled(bool val); + + QString updateTimeLabel(); + void setInfoLabel(const QString &txt); + void updateOutputFile(const QString &outputTxt) const; + + void initCurrentTime(); + QString getPrefix() const; + bool isTimeExpired() const; + int getIncrement() const; + +private: + Ui::TimerControllerModule *ui; + QTimer timer; + QString timeFormat = "hh:mm:ss"; + QTime currentTime; + int timerIntervalMs = 1000; + int increment = -1; + bool isHold; + bool isOutputEnabled = false; + QString holdTxt = "HOLD"; + + QString tMinus = "T- "; + QString tPlus = "T+ "; +}; + +#endif // TIMERCONTROLLERMODULE_H diff --git a/Modules/TimerController/timercontrollermodule.ui b/Modules/TimerController/timercontrollermodule.ui new file mode 100644 index 0000000000000000000000000000000000000000..ad807221a983020f333deb3106bffbc7145261eb --- /dev/null +++ b/Modules/TimerController/timercontrollermodule.ui @@ -0,0 +1,313 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>TimerControllerModule</class> + <widget class="QWidget" name="TimerControllerModule"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>537</width> + <height>301</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QScrollArea" name="scrollArea"> + <property name="widgetResizable"> + <bool>true</bool> + </property> + <widget class="QWidget" name="scrollAreaWidgetContents"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>515</width> + <height>279</height> + </rect> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,0,2,1"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="prefix_label"> + <property name="font"> + <font> + <family>Georgia Pro</family> + <pointsize>14</pointsize> + </font> + </property> + <property name="text"> + <string>T-</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="time_label"> + <property name="minimumSize"> + <size> + <width>75</width> + <height>50</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>500</width> + <height>500</height> + </size> + </property> + <property name="font"> + <font> + <family>Georgia</family> + <pointsize>20</pointsize> + <weight>50</weight> + <italic>false</italic> + <bold>false</bold> + <kerning>true</kerning> + </font> + </property> + <property name="styleSheet"> + <string notr="true"/> + </property> + <property name="text"> + <string>00:00:00</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <widget class="QLabel" name="Info_label"> + <property name="font"> + <font> + <family>Georgia Pro</family> + <pointsize>13</pointsize> + </font> + </property> + <property name="styleSheet"> + <string notr="true"/> + </property> + <property name="text"> + <string>HOLD</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item> + <layout class="QGridLayout" name="gridLayout_2" columnstretch="1,1"> + <item row="2" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_3" stretch="0,1,0,1,0,1,0"> + <item> + <widget class="QComboBox" name="increment_comboBox"> + <property name="currentIndex"> + <number>0</number> + </property> + <item> + <property name="text"> + <string>T-</string> + </property> + </item> + <item> + <property name="text"> + <string>T+</string> + </property> + </item> + </widget> + </item> + <item> + <widget class="QSpinBox" name="hours_spinBox"> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="buttonSymbols"> + <enum>QAbstractSpinBox::NoButtons</enum> + </property> + <property name="showGroupSeparator" stdset="0"> + <bool>false</bool> + </property> + <property name="stepType"> + <enum>QAbstractSpinBox::DefaultStepType</enum> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>:</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="minutes_spinBox"> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="buttonSymbols"> + <enum>QAbstractSpinBox::NoButtons</enum> + </property> + <property name="maximum"> + <number>60</number> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>:</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="seconds_spinBox"> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="buttonSymbols"> + <enum>QAbstractSpinBox::NoButtons</enum> + </property> + <property name="maximum"> + <number>60</number> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="setTimer_pushButton"> + <property name="text"> + <string>Set</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Set info label</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Set Timer</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="2" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QLineEdit" name="labelInfo_lineEdit"> + <property name="placeholderText"> + <string>Set info label</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="setLabelInfo_pushButton"> + <property name="text"> + <string>Set</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="0" column="0"> + <widget class="QPushButton" name="hold_pushButton"> + <property name="text"> + <string>HOLD</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QPushButton" name="start_pushButton"> + <property name="text"> + <string>START</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLineEdit" name="outputFilePath_lineEdit"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="placeholderText"> + <string>output file path</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QCheckBox" name="enableOutput_checkBox"> + <property name="text"> + <string>Enable output </string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Modules/ValuesConverterViewer/valuesconverterviewermodule.cpp b/Modules/ValuesConverterViewer/valuesconverterviewermodule.cpp index b1b944dbcbaa810e346d8e810357ca1519564100..cf5b13c80dba721440539737ad3ace80d35f72a7 100644 --- a/Modules/ValuesConverterViewer/valuesconverterviewermodule.cpp +++ b/Modules/ValuesConverterViewer/valuesconverterviewermodule.cpp @@ -130,7 +130,7 @@ void ValuesConverterViewerModule::createLabels() void ValuesConverterViewerModule::addRule(const ValueElement &el) { - if(el.getTopic() != "" && isTopicPresent(el.getTopic())){ + if(el.getTopic() != "" && !isTopicPresent(el.getTopic())){ getCore()->getModuleMessagesBroker()->subscribe(el.getTopic(), this, [this](const ModuleMessage &msg){ onMsgReceived(msg); }); diff --git a/Modules/moduleinfo.h b/Modules/moduleinfo.h index 77b4919d2b18ae9a0c4ee8cf2d95a206a944b20c..0aa4a56db15c27b86e3e589ad88b18f94edec8e5 100644 --- a/Modules/moduleinfo.h +++ b/Modules/moduleinfo.h @@ -23,7 +23,8 @@ enum ModuleId{ FILESTREAM, STATEVIEWER, VALUESCONVERTERVIEWER, - MAVLINK_RCK_TESTING + MAVLINK_RCK_TESTING, + TIMER_CONTROLLER }; enum ModuleCategory{ diff --git a/Modules/moduleslist.cpp b/Modules/moduleslist.cpp index f948f1532c20ebdc898a8a4e001399565b045d8e..d05a126276c5310f89b11fb3eeacc6bfea7a5072 100644 --- a/Modules/moduleslist.cpp +++ b/Modules/moduleslist.cpp @@ -14,13 +14,13 @@ #include "Modules/ImageViewer/imageviewermodule.h" #include "Modules/MessageViewer/messagesviewermodule.h" #include "Modules/Mavlink/mavlinkmodule.h" -#include "Modules/Fsm/fsmviewermodule.h" #include "Modules/TreeViewer/treeviewermodule.h" #include "Modules/ScrollArea/scrollareamodule.h" #include "Modules/FileStream/filestreammodule.h" #include "Modules/Mavlink/mavlinkrocketmsgtestingmodule.h" #include "Modules/StateViewer/stateviewermodule.h" #include "Modules/ValuesConverterViewer/valuesconverterviewermodule.h" +#include "Modules/TimerController/timercontrollermodule.h" void ModulesList::createModuleList() { @@ -120,13 +120,6 @@ void ModulesList::createModuleList() addModuleInfo(mvkRckTesting); #endif - #ifdef FSMVIEWERMODULE_H - ModuleInfo fsm(ModuleId::FSMVIEWER, "FsmViewer", ModuleCategory::UTILITY); - fsm.setFactory([](){return new FsmViewerModule();}); - fsm.addModuleSourceFiles("Modules/Fsm/"); - addModuleInfo(fsm); - #endif - #ifdef TREEVIEWERMODULE_H ModuleInfo treeViewer(ModuleId::TREEVIEWER, "TreeViewer", ModuleCategory::UTILITY); treeViewer.setFactory([](){return new TreeViewerModule();}); @@ -162,6 +155,13 @@ void ModulesList::createModuleList() addModuleInfo(valuesconverterviewer); #endif + #ifdef TIMERCONTROLLERMODULE_H + ModuleInfo timerController(ModuleId::TIMER_CONTROLLER, "TimerController", ModuleCategory::UTILITY); + timerController.setFactory([](){return new TimerControllerModule();}); + timerController.addModuleSourceFiles("Modules/TimerController/"); + addModuleInfo(timerController); + #endif + } diff --git a/SkywardHub.pro b/SkywardHub.pro index 7fdc13bfa0485d36745ddfd08258f8b84c5f2a31..b68a2b5e53881b3010448aaab1112fa0d58b2022 100644 --- a/SkywardHub.pro +++ b/SkywardHub.pro @@ -21,20 +21,6 @@ SOURCES += \ Modules/DefaultModule/defaultmodule.cpp \ Modules/Empty/emptymodule.cpp \ Modules/FileStream/filestreammodule.cpp \ - Modules/Fsm/Model/model.cpp \ - Modules/Fsm/Model/scxml.cpp \ - Modules/Fsm/Model/state.cpp \ - Modules/Fsm/Model/svg.cpp \ - Modules/Fsm/Model/transition.cpp \ - Modules/Fsm/View/dragwidget.cpp \ - Modules/Fsm/View/mainwindow.cpp \ - Modules/Fsm/View/pixcache.cpp \ - Modules/Fsm/View/statedialog.cpp \ - Modules/Fsm/View/transitiondialog.cpp \ - Modules/Fsm/View/view.cpp \ - Modules/Fsm/defaultstatesettings.cpp \ - Modules/Fsm/draggablewidget.cpp \ - Modules/Fsm/fsmviewermodule.cpp \ Modules/Graph/graphmodule.cpp \ Modules/Graph/qcustomplot.cpp \ Modules/ImageViewer/customgraphicsscene.cpp \ @@ -60,6 +46,7 @@ SOURCES += \ Modules/StateViewer/stateviewermodule.cpp \ Modules/Table/tablemodule.cpp \ Modules/Test/testmodule.cpp \ + Modules/TimerController/timercontrollermodule.cpp \ Modules/TreeViewer/treevieweritem.cpp \ Modules/TreeViewer/treeviewermodule.cpp \ Modules/Utility/contextmenuseparator.cpp \ @@ -88,20 +75,6 @@ HEADERS += \ Modules/DefaultModule/defaultmodule.h \ Modules/Empty/emptymodule.h \ Modules/FileStream/filestreammodule.h \ - Modules/Fsm/Model/model.h \ - Modules/Fsm/Model/scxml.h \ - Modules/Fsm/Model/state.h \ - Modules/Fsm/Model/svg.h \ - Modules/Fsm/Model/transition.h \ - Modules/Fsm/View/dragwidget.h \ - Modules/Fsm/View/mainwindow.h \ - Modules/Fsm/View/pixcache.h \ - Modules/Fsm/View/statedialog.h \ - Modules/Fsm/View/transitiondialog.h \ - Modules/Fsm/View/view.h \ - Modules/Fsm/defaultstatesettings.h \ - Modules/Fsm/draggablewidget.h \ - Modules/Fsm/fsmviewermodule.h \ Modules/Graph/graphmodule.h \ Modules/Graph/qcustomplot.h \ Modules/ImageViewer/customgraphicsscene.h \ @@ -129,6 +102,7 @@ HEADERS += \ Modules/StateViewer/stateviewermodule.h \ Modules/Table/tablemodule.h \ Modules/Test/testmodule.h \ + Modules/TimerController/timercontrollermodule.h \ Modules/TreeViewer/treevieweritem.h \ Modules/TreeViewer/treeviewermodule.h \ Modules/Utility/contextmenuseparator.h \ @@ -148,10 +122,6 @@ FORMS += \ Modules/CommandPad/telemetryrequestmodule.ui \ Modules/Empty/emptymodule.ui \ Modules/FileStream/filestreammodule.ui \ - Modules/Fsm/View/mainwindow.ui \ - Modules/Fsm/View/statedialog.ui \ - Modules/Fsm/View/transitiondialog.ui \ - Modules/Fsm/fsmviewermodule.ui \ Modules/Graph/graphmodule.ui \ Modules/ImageViewer/imageviewermodule.ui \ Modules/ImageViewer/imageviewersettings.ui \ @@ -169,6 +139,7 @@ FORMS += \ Modules/StateViewer/stateviewermodule.ui \ Modules/Table/tablemodule.ui \ Modules/Test/testmodule.ui \ + Modules/TimerController/timercontrollermodule.ui \ Modules/TreeViewer/treeviewermodule.ui \ Modules/Utility/modulespicker.ui \ Modules/Utility/saveconfigurationdialog.ui \ diff --git a/SkywardHub.pro.user b/SkywardHub.pro.user index 08ebd5c6644e9d09533b15b806db5ada5acbbd41..41c6066259ed2caaf6a0eb6d0f73b8be72cfdd06 100644 --- a/SkywardHub.pro.user +++ b/SkywardHub.pro.user @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE QtCreatorProject> -<!-- Written by QtCreator 4.14.2, 2021-08-26T17:31:54. --> +<!-- Written by QtCreator 4.14.2, 2021-09-07T22:18:51. --> <qtcreator> <data> <variable>EnvironmentId</variable>