From: vsv Date: Fri, 17 Apr 2015 15:45:48 +0000 (+0300) Subject: Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0 X-Git-Tag: V_1.1.0~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1a8aa827e187ffca7d952c92b81f1801c9fb0d0e;hp=18a83fe9a77ee80f6d06c36a492012ffd10195fb;p=modules%2Fshaper.git Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0 --- diff --git a/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp b/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp index c206ff4d5..13ae2b36d 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include #include @@ -32,6 +34,11 @@ void ConstructionPlugin_Plane::initAttributes() data()->addAttribute(ConstructionPlugin_Plane::B(), ModelAPI_AttributeDouble::typeId()); data()->addAttribute(ConstructionPlugin_Plane::C(), ModelAPI_AttributeDouble::typeId()); data()->addAttribute(ConstructionPlugin_Plane::D(), ModelAPI_AttributeDouble::typeId()); + + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), ConstructionPlugin_Plane::A()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), ConstructionPlugin_Plane::B()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), ConstructionPlugin_Plane::C()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), ConstructionPlugin_Plane::D()); } void ConstructionPlugin_Plane::execute() diff --git a/src/NewGeom/CMakeLists.txt b/src/NewGeom/CMakeLists.txt index 979269418..70f406e6f 100644 --- a/src/NewGeom/CMakeLists.txt +++ b/src/NewGeom/CMakeLists.txt @@ -9,6 +9,7 @@ SET(PROJECT_HEADERS NewGeom_DataModel.h NewGeom_OCCSelector.h NewGeom_SalomeViewer.h + NewGeom_NestedButton.h ) SET(PROJECT_AUTOMOC @@ -20,6 +21,7 @@ SET(PROJECT_SOURCES NewGeom_DataModel.cpp NewGeom_OCCSelector.cpp NewGeom_SalomeViewer.cpp + NewGeom_NestedButton.cpp ) SET(PROJECT_RESOURCES diff --git a/src/NewGeom/NewGeom_Module.cpp b/src/NewGeom/NewGeom_Module.cpp index a569af015..6e27289e3 100644 --- a/src/NewGeom/NewGeom_Module.cpp +++ b/src/NewGeom/NewGeom_Module.cpp @@ -4,6 +4,7 @@ #include "NewGeom_Module.h" #include "NewGeom_DataModel.h" #include "NewGeom_OCCSelector.h" +#include #include #include @@ -14,6 +15,7 @@ #include #include +#include #include #include @@ -332,6 +334,16 @@ CAM_DataModel* NewGeom_Module::createDataModel() return aDataModel; } +QAction* NewGeom_Module::addFeature(const QString& theWBName, const ActionInfo& theInfo) +{ + return addFeature(theWBName, + theInfo.id, + theInfo.text, + theInfo.toolTip, + theInfo.icon, + theInfo.shortcut); +} + //****************************************************** QAction* NewGeom_Module::addFeature(const QString& theWBName, const QString& theId, const QString& theTitle, const QString& theTip, @@ -352,17 +364,37 @@ QAction* NewGeom_Module::addFeature(const QString& theWBName, const QString& the aAction->setData(theId); int aItemId = createMenu(aId, aMenu, -1, 10); int aToolId = createTool(aId, aTool); + return aAction; } -QAction* NewGeom_Module::addFeature(const QString& theWBName, const ActionInfo& theInfo) + +QAction* NewGeom_Module::addNestedFeature(const QString& theWBName, + const ActionInfo& theInfo, + const QList& theNestedActions) { - return addFeature(theWBName, - theInfo.id, - theInfo.text, - theInfo.toolTip, - theInfo.icon, - theInfo.shortcut); + int aMenu = createMenu(theWBName, -1, -1, 50); + int aTool = createTool(theWBName); + + int aId = myActionsList.size(); + myActionsList.append(theInfo.id); + SUIT_Desktop* aDesk = application()->desktop(); + NewGeom_NestedButton* anAction = new NewGeom_NestedButton(aDesk, theNestedActions); + anAction->setData(theInfo.id); + anAction->setCheckable(theInfo.checkable); + anAction->setChecked(theInfo.checked); + anAction->setEnabled(theInfo.enabled); + anAction->setVisible(theInfo.visible); + anAction->setIcon(theInfo.icon); + anAction->setText(theInfo.text); + anAction->setToolTip(theInfo.toolTip); + anAction->setShortcut(theInfo.shortcut); + anAction->setFont(theInfo.font); + + //int aItemId = createMenu(aId, aMenu, -1, 10); + int aToolId = createTool(anAction, aTool, aId); + + return anAction; } diff --git a/src/NewGeom/NewGeom_Module.h b/src/NewGeom/NewGeom_Module.h index f8834b760..89cfc45a2 100644 --- a/src/NewGeom/NewGeom_Module.h +++ b/src/NewGeom/NewGeom_Module.h @@ -57,6 +57,10 @@ Q_OBJECT virtual QAction* addFeature(const QString& theWBName, const ActionInfo& theInfo); + virtual QAction* addNestedFeature(const QString& theWBName, + const ActionInfo& theInfo, + const QList& theNestedActions); + virtual QAction* addDesktopCommand(const QString& theId, const QString& theTitle, const QString& theTip, const QIcon& theIcon, const QKeySequence& theKeys, bool isCheckable, diff --git a/src/NewGeom/NewGeom_NestedButton.cpp b/src/NewGeom/NewGeom_NestedButton.cpp new file mode 100644 index 000000000..ff42227ce --- /dev/null +++ b/src/NewGeom/NewGeom_NestedButton.cpp @@ -0,0 +1,84 @@ +/* + * NewGeom_NestedButton.cpp + * + * Created on: Apr 13, 2015 + * Author: sbh + */ + +#include + +#include +#include +#include +#include + +NewGeom_NestedButton::NewGeom_NestedButton(QObject* theParent, + const QList& theNestedActions) +: QWidgetAction(theParent), + myNestedActions(theNestedActions), + myAdditionalButtonsWidget(0), + myButtonFrame(0), + myThisButton(0) +{ +} + +NewGeom_NestedButton::~NewGeom_NestedButton() +{ +} + +void NewGeom_NestedButton::showAdditionalButtons(bool isShow) +{ + myAdditionalButtonsWidget->setVisible(isShow); + if (isShow) { + myButtonFrame->setFrameStyle(QFrame::WinPanel); + myButtonFrame->setFrameShadow(QFrame::Sunken); + myThisButton->setAutoRaise(false); + } else { + myButtonFrame->setFrameStyle(QFrame::NoFrame); + myButtonFrame->setFrameShadow(QFrame::Plain); + myThisButton->setAutoRaise(true); + } +} + +QWidget * NewGeom_NestedButton::createWidget(QWidget * theParent) +{ + myButtonFrame = new QFrame(theParent); + QHBoxLayout* aBoxLay = new QHBoxLayout(myButtonFrame); + aBoxLay->setContentsMargins(2, 0, 0, 0); + aBoxLay->setSpacing(1); + + myThisButton = new QToolButton(myButtonFrame); + myThisButton->setDefaultAction(this); + myThisButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + aBoxLay->addWidget(myThisButton, 1); + + myAdditionalButtonsWidget = new QWidget(myButtonFrame); + QHBoxLayout* aAdditionalBoxLay = new QHBoxLayout(myAdditionalButtonsWidget); + aAdditionalBoxLay->setContentsMargins(0, 0, 0, 0); + aAdditionalBoxLay->setSpacing(1); + foreach (QAction* eachAct, myNestedActions) { + QToolButton* aButton = new QToolButton(myButtonFrame); + aButton->setDefaultAction(eachAct); + aButton->setAutoRaise(true); + aAdditionalBoxLay->addWidget(aButton); + } + myAdditionalButtonsWidget->setLayout(aAdditionalBoxLay); + aBoxLay->addWidget(myAdditionalButtonsWidget); + + myButtonFrame->setLayout(aBoxLay); + + showAdditionalButtons(false); + connect(this, SIGNAL(toggled(bool)), this, SLOT(showAdditionalButtons(bool))); + connect(this, SIGNAL(changed()), this, SLOT(actionStateChanged())); + return myButtonFrame; +} + +void NewGeom_NestedButton::actionStateChanged() +{ + if (isEnabled()) { + QString s = "true"; + } else { + QString s = "false"; + } + +} diff --git a/src/NewGeom/NewGeom_NestedButton.h b/src/NewGeom/NewGeom_NestedButton.h new file mode 100644 index 000000000..7be12d491 --- /dev/null +++ b/src/NewGeom/NewGeom_NestedButton.h @@ -0,0 +1,45 @@ +/* + * NewGeom_NestedButton.h + * + * Created on: Apr 13, 2015 + * Author: sbh + */ + +#ifndef SRC_NEWGEOM_NEWGEOM_NESTEDBUTTON_H_ +#define SRC_NEWGEOM_NEWGEOM_NESTEDBUTTON_H_ + +#include + +class QFrame; +class QAction; +class QWidget; +class QToolButton; + +/*! + * \ingroup Salome + * Custom (nested) button in salome mode. + */ +class NewGeom_NestedButton : public QWidgetAction +{ + Q_OBJECT + public: + NewGeom_NestedButton(QObject *parent, const QList& theNestedActions); + virtual ~NewGeom_NestedButton(); + + public slots: + /// Shows/hides the additional buttons widget + void showAdditionalButtons(bool); + void actionStateChanged(); + + protected: + /// Creates the button representation + virtual QWidget * createWidget(QWidget * theParent); + + private: + QList myNestedActions; ///< list of nested actions + QWidget* myAdditionalButtonsWidget; ///< widget to precess additional buttons visibility + QFrame* myButtonFrame; ///< frame arround button representation + QToolButton* myThisButton; ///< main button +}; + +#endif /* SRC_NEWGEOM_NEWGEOM_NESTEDBUTTON_H_ */ diff --git a/src/NewGeom/resources/LightApp.xml b/src/NewGeom/resources/LightApp.xml index 7b1574183..0ce335100 100644 --- a/src/NewGeom/resources/LightApp.xml +++ b/src/NewGeom/resources/LightApp.xml @@ -23,7 +23,7 @@ - +
diff --git a/src/NewGeom/resources/SalomeApp.xml b/src/NewGeom/resources/SalomeApp.xml index 1c8b9e477..d5c820939 100644 --- a/src/NewGeom/resources/SalomeApp.xml +++ b/src/NewGeom/resources/SalomeApp.xml @@ -27,7 +27,7 @@ - +
diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index 239aeb75a..ceeeb6bff 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -85,6 +85,17 @@ PartSet_WidgetSketchLabel::~PartSet_WidgetSketchLabel() erasePreviewPlanes(); } +bool PartSet_WidgetSketchLabel::setSelection(ModuleBase_ViewerPrs theValue) +{ + // do not use the given selection if the plane of the sketch has been already set. + // If this check is absent, a selected plane in the viewer can be set in the sketch + // even if the sketch is built on another plane. + if (plane().get()) + return true; + + return ModuleBase_WidgetValidated::setSelection(theValue); +} + QList PartSet_WidgetSketchLabel::getControls() const { QList aResult; diff --git a/src/PartSet/PartSet_WidgetSketchLabel.h b/src/PartSet/PartSet_WidgetSketchLabel.h index ab7cd18eb..eea79ea6d 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.h +++ b/src/PartSet/PartSet_WidgetSketchLabel.h @@ -48,6 +48,13 @@ Q_OBJECT virtual ~PartSet_WidgetSketchLabel(); + /// Set the given wrapped value to the current widget + /// This value should be processed in the widget according to the needs + /// The method is called by the current operation to process the operation preselection. + /// It is redefined to do nothing if the plane of the sketch has been already set. + /// \param theValue the wrapped widget value + virtual bool setSelection(ModuleBase_ViewerPrs theValue); + virtual bool restoreValue() { return true; diff --git a/src/XGUI/XGUI_ActionsMgr.cpp b/src/XGUI/XGUI_ActionsMgr.cpp index 129fdb2cf..bdc91203b 100644 --- a/src/XGUI/XGUI_ActionsMgr.cpp +++ b/src/XGUI/XGUI_ActionsMgr.cpp @@ -299,6 +299,7 @@ void XGUI_ActionsMgr::setNestedStackEnabled(ModuleBase_Operation* theOperation) return; FeaturePtr aFeature = theOperation->feature(); QString aFeatureId = QString::fromStdString(aFeature->getKind()); + setActionEnabled(aFeatureId, true); setNestedCommandsEnabled(true, aFeatureId); setNestedStackEnabled(myOperationMgr->previousOperation(theOperation)); diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index 1fe9717fb..dacd82f21 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -235,9 +235,10 @@ void XGUI_OperationMgr::onAbortOperation() void XGUI_OperationMgr::onOperationStarted() { ModuleBase_Operation* aSenderOperation = dynamic_cast(sender()); - if (myOperations.count() == 1) { - emit nestedStateChanged(false); - } + + bool isNestedOk = (myOperations.count() >= 1) && + myOperations.at(0)->isValid(); + emit nestedStateChanged(isNestedOk); emit operationStarted(aSenderOperation); } @@ -250,7 +251,7 @@ void XGUI_OperationMgr::onOperationAborted() void XGUI_OperationMgr::onOperationCommitted() { ModuleBase_Operation* aSenderOperation = dynamic_cast(sender()); - emit nestedStateChanged(true); + emit nestedStateChanged(myOperations.count() >= 1); emit operationCommitted(aSenderOperation); } diff --git a/src/XGUI/XGUI_SalomeConnector.h b/src/XGUI/XGUI_SalomeConnector.h index 414ac4d66..312342e14 100644 --- a/src/XGUI/XGUI_SalomeConnector.h +++ b/src/XGUI/XGUI_SalomeConnector.h @@ -40,6 +40,13 @@ class XGUI_EXPORT XGUI_SalomeConnector virtual QAction* addFeature(const QString& theWBName, const ActionInfo& theInfo) = 0; + //! Creates a feature (command) in SALOME desktop + //! \param theWBName - name of toolbar (workbench) + //! \param theInfo - information about action (icon, text, etc) + virtual QAction* addNestedFeature(const QString& theWBName, + const ActionInfo& theInfo, + const QList& theNestedActions) = 0; + //! Creates a command in Edit menu of SALOME desktop //! \param theId - an id of the feature //! \param theTitle - a menu item string diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 42aa97e30..2ce90358a 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -762,8 +762,29 @@ void XGUI_Workshop::addFeature(const std::shared_ptr& the QStringList aNestedFeatures = QString::fromStdString(theMessage->nestedFeatures()).split(" ", QString::SkipEmptyParts); QString aDocKind = QString::fromStdString(theMessage->documentKind()); + QList aNestedActList; + bool isColumnButton = !aNestedFeatures.isEmpty(); + if (isColumnButton) { + QString aNestedActions = QString::fromStdString(theMessage->actionsWhenNested()); + if (aNestedActions.contains("accept")) { + QAction* anAction = myActionsMgr->operationStateAction(XGUI_ActionsMgr::AcceptAll, NULL); + connect(anAction, SIGNAL(triggered()), myOperationMgr, SLOT(commitAllOperations())); + aNestedActList << anAction; + } + if (aNestedActions.contains("abort")) { + QAction* anAction = myActionsMgr->operationStateAction(XGUI_ActionsMgr::AbortAll, NULL); + connect(anAction, SIGNAL(triggered()), myOperationMgr, SLOT(abortAllOperations())); + aNestedActList << anAction; + } + } + if (isSalomeMode()) { - QAction* aAction = salomeConnector()->addFeature(aWchName, aFeatureInfo); + QAction* aAction; + if (isColumnButton) { + aAction = salomeConnector()->addNestedFeature(aWchName, aFeatureInfo, aNestedActList); + } else { + aAction = salomeConnector()->addFeature(aWchName, aFeatureInfo); + } salomeConnector()->setNestedActions(aFeatureInfo.id, aNestedFeatures); salomeConnector()->setDocumentKind(aFeatureInfo.id, aDocKind); @@ -794,19 +815,7 @@ void XGUI_Workshop::addFeature(const std::shared_ptr& the // Enrich created button with accept/abort buttons if necessary AppElements_Button* aButton = aCommand->button(); if (aButton->isColumnButton()) { - QString aNestedActions = QString::fromStdString(theMessage->actionsWhenNested()); - QList anActList; - if (aNestedActions.contains("accept")) { - QAction* anAction = myActionsMgr->operationStateAction(XGUI_ActionsMgr::AcceptAll, aButton); - connect(anAction, SIGNAL(triggered()), myOperationMgr, SLOT(commitAllOperations())); - anActList << anAction; - } - if (aNestedActions.contains("abort")) { - QAction* anAction = myActionsMgr->operationStateAction(XGUI_ActionsMgr::AbortAll, aButton); - connect(anAction, SIGNAL(triggered()), myOperationMgr, SLOT(abortAllOperations())); - anActList << anAction; - } - aButton->setAdditionalButtons(anActList); + aButton->setAdditionalButtons(aNestedActList); } myActionsMgr->addCommand(aCommand); myModule->actionCreated(aCommand);