Skip to content

Commit

Permalink
Fixes ticket#5923 flag for moving the connectors together
Browse files Browse the repository at this point in the history
Allow users moving the connectors both on icon and diagram layer.
By default the flag is not enabled i.e., the connectors don't move together.
  • Loading branch information
adeas31 committed Apr 28, 2020
1 parent 43c8902 commit 38a1cbb
Show file tree
Hide file tree
Showing 7 changed files with 233 additions and 229 deletions.
4 changes: 3 additions & 1 deletion OMEdit/OMEditLIB/Component/Component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "Plotting/VariablesWidget.h"
#include "OMS/BusDialog.h"
#include "Util/ResourceCache.h"
#include "Options/OptionsDialog.h"

#include <QMessageBox>
#include <QMenu>
Expand Down Expand Up @@ -1583,7 +1584,8 @@ void Component::adjustInterfacePoints()
void Component::updateComponentTransformations(const Transformation &oldTransformation, const bool positionChanged)
{
mpGraphicsView->getModelWidget()->beginMacro("Update component transformations");
mpGraphicsView->getModelWidget()->getUndoStack()->push(new UpdateComponentTransformationsCommand(this, oldTransformation, mTransformation, positionChanged));
mpGraphicsView->getModelWidget()->getUndoStack()->push(new UpdateComponentTransformationsCommand(this, oldTransformation, mTransformation, positionChanged,
OptionsDialog::instance()->getGraphicalViewsPage()->getMoveConnectorsTogetherCheckBox()->isChecked()));
emit transformChanging();
mpGraphicsView->getModelWidget()->endMacro();
}
Expand Down
7 changes: 4 additions & 3 deletions OMEdit/OMEditLIB/Modeling/Commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,14 @@ void AddComponentCommand::undo()
}

UpdateComponentTransformationsCommand::UpdateComponentTransformationsCommand(Component *pComponent, const Transformation &oldTransformation, const Transformation &newTransformation,
const bool positionChanged, UndoCommand *pParent)
const bool positionChanged, const bool moveConnectorsTogether, UndoCommand *pParent)
: UndoCommand(pParent)
{
mpComponent = pComponent;
mOldTransformation = oldTransformation;
mNewTransformation = newTransformation;
mPositionChanged = positionChanged;
mMoveConnectorsTogether = moveConnectorsTogether;
setText(QString("Update Component %1 Transformations").arg(mpComponent->getName()));
}

Expand All @@ -309,7 +310,7 @@ UpdateComponentTransformationsCommand::UpdateComponentTransformationsCommand(Com
void UpdateComponentTransformationsCommand::redoInternal()
{
ModelWidget *pModelWidget = mpComponent->getGraphicsView()->getModelWidget();
if (mpComponent->getLibraryTreeItem() && mpComponent->getLibraryTreeItem()->isConnector() &&
if (mpComponent->getLibraryTreeItem() && mpComponent->getLibraryTreeItem()->isConnector() && mMoveConnectorsTogether &&
pModelWidget->getLibraryTreeItem()->getLibraryType() == LibraryTreeItem::Modelica) {
GraphicsView *pGraphicsView;
if (mpComponent->getGraphicsView()->getViewType() == StringHandler::Icon) {
Expand Down Expand Up @@ -347,7 +348,7 @@ void UpdateComponentTransformationsCommand::redoInternal()
void UpdateComponentTransformationsCommand::undo()
{
ModelWidget *pModelWidget = mpComponent->getGraphicsView()->getModelWidget();
if (mpComponent->getLibraryTreeItem() && mpComponent->getLibraryTreeItem()->isConnector() &&
if (mpComponent->getLibraryTreeItem() && mpComponent->getLibraryTreeItem()->isConnector() && mMoveConnectorsTogether &&
pModelWidget->getLibraryTreeItem()->getLibraryType() == LibraryTreeItem::Modelica) {
GraphicsView *pGraphicsView;
if (mpComponent->getGraphicsView()->getViewType() == StringHandler::Icon) {
Expand Down
3 changes: 2 additions & 1 deletion OMEdit/OMEditLIB/Modeling/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,15 @@ class UpdateComponentTransformationsCommand : public UndoCommand
{
public:
UpdateComponentTransformationsCommand(Component *pComponent, const Transformation &oldTransformation, const Transformation &newTransformation,
const bool positionChanged, UndoCommand *pParent = 0);
const bool positionChanged, const bool moveConnectorsTogether, UndoCommand *pParent = 0);
void redoInternal();
void undo();
private:
Component *mpComponent;
Transformation mOldTransformation;
Transformation mNewTransformation;
bool mPositionChanged;
bool mMoveConnectorsTogether;
};

class UpdateComponentAttributesCommand : public UndoCommand
Expand Down
2 changes: 1 addition & 1 deletion OMEdit/OMEditLIB/Modeling/LibraryTreeWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1811,7 +1811,7 @@ void LibraryTreeModel::showModelWidget(LibraryTreeItem *pLibraryTreeItem, bool s
&& ((pLibraryTreeItem->mClassInformation.preferredView.compare("info") == 0) ||
(pLibraryTreeItem->mClassInformation.preferredView.isEmpty() && pLibraryTreeItem->isDocumentationClass()) ||
(pLibraryTreeItem->mClassInformation.preferredView.isEmpty() &&
OptionsDialog::instance()->getGeneralSettingsPage()->getDefaultView().compare(Helper::documentationView) == 0))) {
OptionsDialog::instance()->getGraphicalViewsPage()->getDefaultView().compare(Helper::documentationView) == 0))) {
bool state = MainWindow::instance()->getDocumentationDockWidget()->blockSignals(true);
MainWindow::instance()->getDocumentationDockWidget()->show();
MainWindow::instance()->getDocumentationDockWidget()->blockSignals(state);
Expand Down
4 changes: 2 additions & 2 deletions OMEdit/OMEditLIB/Modeling/ModelWidgetContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7429,7 +7429,7 @@ ModelWidgetContainer::ModelWidgetContainer(QWidget *pParent)
#if QT_VERSION >= 0x040800
setTabsClosable(true);
#endif
if (OptionsDialog::instance()->getGeneralSettingsPage()->getModelingViewMode().compare(Helper::subWindow) == 0) {
if (OptionsDialog::instance()->getGraphicalViewsPage()->getModelingViewMode().compare(Helper::subWindow) == 0) {
setViewMode(QMdiArea::SubWindowView);
} else {
setViewMode(QMdiArea::TabbedView);
Expand Down Expand Up @@ -7533,7 +7533,7 @@ void ModelWidgetContainer::addModelWidget(ModelWidget *pModelWidget, bool checkP
} else if (pModelWidget->getModelWidgetContainer()->getPreviousViewType() != StringHandler::NoView) {
loadPreviousViewType(pModelWidget);
} else {
QString defaultView = OptionsDialog::instance()->getGeneralSettingsPage()->getDefaultView();
QString defaultView = OptionsDialog::instance()->getGraphicalViewsPage()->getDefaultView();
if (defaultView.compare(Helper::iconView) == 0) {
pModelWidget->getIconViewToolButton()->setChecked(true);
} else if (defaultView.compare(Helper::textView) == 0) {
Expand Down

0 comments on commit 38a1cbb

Please sign in to comment.