# Create a part for extrusions & boolean
aSession.startOperation()
aPartFeature = aSession.moduleDocument().addFeature("Part")
-aPart = aSession.activeDocument()
aSession.finishOperation()
+aPart = aSession.activeDocument()
#=========================================================================
# Create a sketch with circle to extrude
#=========================================================================
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX"))
dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirY"))
-diry.setValue(0, 1, 0)
norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm"))
norm.setValue(0, 0, 1)
aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirX"))
dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirY"))
-diry.setValue(0, 1, 0)
norm = geomDataAPI_Dir(aTriangleSketchFeature.attribute("Norm"))
norm.setValue(0, 0, 1)
aSketchLineA = aTriangleSketchFeature.addFeature("SketchLine")
aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape()
origin = geomDataAPI_Point(eachSketchFeature.attribute("Origin")).pnt()
dirX = geomDataAPI_Dir(eachSketchFeature.attribute("DirX")).dir()
- dirY = geomDataAPI_Dir(eachSketchFeature.attribute("DirY")).dir()
norm = geomDataAPI_Dir(eachSketchFeature.attribute("Norm")).dir()
aSketchFaces = ShapeList()
GeomAlgoAPI_SketchBuilder.createFaces(
- origin, dirX, dirY, norm, aSketchEdges, aSketchFaces)
+ origin, dirX, norm, aSketchEdges, aSketchFaces)
# Create extrusion on them
anExtrusionFt = aPart.addFeature("Extrusion")
anExtrusionFt.selectionList("base").append(
class FeaturesPlugin_Extrusion : public ModelAPI_Feature
static const std::string MY_EXTRUSION_ID("Extrusion");
- static const std::string MY_FACE_ID("extrusion_face");
- static const std::string MY_SIZE_ID("extrusion_size");
- static const std::string MY_REVERSE_ID("extrusion_reverse");
+ static const std::string MY_FACE_ID("base");
+ static const std::string MY_SIZE_ID("size");
+ static const std::string MY_REVERSE_ID("reverse");
data()->addAttribute(FeaturesPlugin_Extrusion::FACE_ID(), ModelAPI_AttributeSelection::typeId());
data()->addAttribute(FeaturesPlugin_Extrusion::SIZE_ID(), ModelAPI_AttributeDouble::typeId());
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
-diry.setValue(0, 1, 0)
norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
norm.setValue(0, 0, 1)
# Create circle
aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape()
origin = geomDataAPI_Point(aSketchFeature.attribute("Origin")).pnt()
dirX = geomDataAPI_Dir(aSketchFeature.attribute("DirX")).dir()
-dirY = geomDataAPI_Dir(aSketchFeature.attribute("DirY")).dir()
norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm")).dir()
aSketchFaces = ShapeList()
GeomAlgoAPI_SketchBuilder.createFaces(
- origin, dirX, dirY, norm, aSketchEdges, aSketchFaces)
+ origin, dirX, norm, aSketchEdges, aSketchFaces)
assert (len(aSketchFaces) > 0)
assert (aSketchFaces[0] is not None)
# Create extrusion
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirX"))
dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirY"))
-diry.setValue(0, 1, 0)
norm = geomDataAPI_Dir(aTriangleSketchFeature.attribute("Norm"))
norm.setValue(0, 0, 1)
aSketchLineA = aTriangleSketchFeature.addFeature("SketchLine")
aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape()
origin = geomDataAPI_Point(aTriangleSketchFeature.attribute("Origin")).pnt()
dirX = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirX")).dir()
-dirY = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirY")).dir()
norm = geomDataAPI_Dir(aTriangleSketchFeature.attribute("Norm")).dir()
aSketchFaces = ShapeList()
GeomAlgoAPI_SketchBuilder.createFaces(
- origin, dirX, dirY, norm, aSketchEdges, aSketchFaces)
+ origin, dirX, norm, aSketchEdges, aSketchFaces)
# Create extrusion on them
anExtrusionFt = aPart.addFeature("Extrusion")
anExtrusionFt.selectionList("base").append(
for i in xrange(0, N):
for j in xrange(0, N):
# Create circle
- aSketchFeature = modelAPI_CompositeFeature(aPart.addFeature("Sketch"))
+ aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
dirx.setValue(1, 0, 0)
- diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
- diry.setValue(0, 1, 0)
norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
norm.setValue(0, 0, 1)
aSketchCircle = aSketchFeature.addFeature("SketchCircle")
aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape()
origin = geomDataAPI_Point(aSketchFeatures[i].attribute("Origin")).pnt()
dirX = geomDataAPI_Dir(aSketchFeatures[i].attribute("DirX")).dir()
- dirY = geomDataAPI_Dir(aSketchFeatures[i].attribute("DirY")).dir()
norm = geomDataAPI_Dir(aSketchFeatures[i].attribute("Norm")).dir()
aSketchFaces = ShapeList()
GeomAlgoAPI_SketchBuilder.createFaces(
- origin, dirX, dirY, norm, aSketchEdges, aSketchFaces)
+ origin, dirX, norm, aSketchEdges, aSketchFaces)
anExtrusionFt = aPart.addFeature("Extrusion")
assert (anExtrusionFt.getKind() == "Extrusion")
# Make rectangle sketch: base for the box, size 100x100
#=========================================================================
aSession.startOperation()
-aQuadrangleSketchFeature = modelAPI_CompositeFeature(aPart.addFeature("Sketch"))
+aQuadrangleSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
origin = geomDataAPI_Point(aQuadrangleSketchFeature.attribute("Origin"))
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aQuadrangleSketchFeature.attribute("DirX"))
dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aQuadrangleSketchFeature.attribute("DirY"))
-diry.setValue(0, 1, 0)
norm = geomDataAPI_Dir(aQuadrangleSketchFeature.attribute("Norm"))
norm.setValue(0, 0, 1)
aSketchLineA = aQuadrangleSketchFeature.addFeature("SketchLine")
aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape()
origin = geomDataAPI_Point(aQuadrangleSketchFeature.attribute("Origin")).pnt()
dirX = geomDataAPI_Dir(aQuadrangleSketchFeature.attribute("DirX")).dir()
-dirY = geomDataAPI_Dir(aQuadrangleSketchFeature.attribute("DirY")).dir()
norm = geomDataAPI_Dir(aQuadrangleSketchFeature.attribute("Norm")).dir()
aSketchFaces = ShapeList()
GeomAlgoAPI_SketchBuilder.createFaces(
- origin, dirX, dirY, norm, aSketchEdges, aSketchFaces)
+ origin, dirX, norm, aSketchEdges, aSketchFaces)
# Create extrusion on them
aBox = aPart.addFeature("Extrusion")
aBox.selectionList("base").append(
# Duplicate the document
assert(aSession.moduleDocument().size("Parts") == 1)
aSession.startOperation()
-aSession.moduleDocument().addFeature("Duplicate")
+aPart.addFeature("Duplicate")
aSession.finishOperation()
assert(aSession.moduleDocument().size("Parts") == 2)
aCopyOfPart = aSession.activeDocument()
#=========================================================================
assert(aSession.moduleDocument().size("Parts") == 2)
aSession.startOperation()
-aSession.moduleDocument().addFeature("Remove")
+aPart.addFeature("Remove")
aSession.finishOperation()
assert(aSession.moduleDocument().size("Parts") == 1)
assert(aSession.activeDocument().id() == aSession.moduleDocument().id())
aSession.startOperation()
aDoc1 = aSession.document("Part_1")
aSession.setActiveDocument(aDoc1, False)
-aSession.moduleDocument().addFeature("Remove")
+aDoc1.addFeature("Remove")
aSession.finishOperation()
assert(aSession.moduleDocument().size("Parts") == 0)
assert(aSession.activeDocument())
-#=========================================================================
-# Trying to duplicate/remove the root
-#=========================================================================
-aSession.startOperation()
-aSession.moduleDocument().addFeature("Duplicate")
-aSession.finishOperation()
-assert(aSession.activeDocument().id() == aSession.moduleDocument().id())
-assert(aSession.moduleDocument().size("Parts") == 0)
-aSession.startOperation()
-aSession.moduleDocument().addFeature("Remove")
-aSession.finishOperation()
-assert(aSession.activeDocument().id() == aSession.moduleDocument().id())
-assert(aSession.moduleDocument().size("Parts") == 0)
-#=========================================================================
-# End of test
-#=========================================================================
NewGeom_DataModel.h
NewGeom_OCCSelector.h
NewGeom_SalomeViewer.h
+ NewGeom_NestedButton.h
)
SET(PROJECT_AUTOMOC
NewGeom_DataModel.cpp
NewGeom_OCCSelector.cpp
NewGeom_SalomeViewer.cpp
+ NewGeom_NestedButton.cpp
)
SET(PROJECT_RESOURCES
#include "NewGeom_Module.h"
#include "NewGeom_DataModel.h"
#include "NewGeom_OCCSelector.h"
+#include <NewGeom_NestedButton.h>
#include <XGUI_Workshop.h>
#include <XGUI_PropertyPanel.h>
#include <ModuleBase_Operation.h>
#include <ModuleBase_Preferences.h>
+#include <ModuleBase_ActionInfo.h>
#include <LightApp_Application.h>
#include <LightApp_SelectionMgr.h>
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,
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<QAction*>& 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;
}
virtual QAction* addFeature(const QString& theWBName,
const ActionInfo& theInfo);
+ virtual QAction* addNestedFeature(const QString& theWBName,
+ const ActionInfo& theInfo,
+ const QList<QAction*>& theNestedActions);
+
virtual QAction* addDesktopCommand(const QString& theId, const QString& theTitle,
const QString& theTip, const QIcon& theIcon,
const QKeySequence& theKeys, bool isCheckable,
--- /dev/null
+/*
+ * NewGeom_NestedButton.cpp
+ *
+ * Created on: Apr 13, 2015
+ * Author: sbh
+ */
+
+#include <NewGeom_NestedButton.h>
+
+#include <QAction>
+#include <QFrame>
+#include <QHBoxLayout>
+#include <QToolButton>
+
+NewGeom_NestedButton::NewGeom_NestedButton(QObject* theParent,
+ const QList<QAction*>& 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";
+ }
+
+}
--- /dev/null
+/*
+ * NewGeom_NestedButton.h
+ *
+ * Created on: Apr 13, 2015
+ * Author: sbh
+ */
+
+#ifndef SRC_NEWGEOM_NEWGEOM_NESTEDBUTTON_H_
+#define SRC_NEWGEOM_NEWGEOM_NESTEDBUTTON_H_
+
+#include <QWidgetAction>
+
+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<QAction*>& 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<QAction*> 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_ */
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
-diry.setValue(0, 1, 0)
norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
norm.setValue(0, 0, 1)
aSession.finishOperation()
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
-diry.setValue(0, 1, 0)
norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
norm.setValue(0, 0, 1)
aSession.finishOperation()
#=========================================================================
aSession.startOperation()
aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
-diry.setValue(0, 1, 0)
norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
norm.setValue(0, 0, 1)
aSession.finishOperation()
#=========================================================================
aSession.startOperation()
aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
-diry.setValue(0, 1, 0)
norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
norm.setValue(0, 0, 1)
aSession.finishOperation()
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
-diry.setValue(0, 1, 0)
norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
norm.setValue(0, 0, 1)
aSession.finishOperation()
#=========================================================================
aSession.startOperation()
aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
-diry.setValue(0, 1, 0)
norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
norm.setValue(0, 0, 1)
aSession.finishOperation()
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
-diry.setValue(0, 1, 0)
norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
norm.setValue(0, 0, 1)
aSession.finishOperation()
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
-diry.setValue(0, 1, 0)
norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
norm.setValue(0, 0, 1)
aSession.finishOperation()
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
-diry.setValue(0, 1, 0)
norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
norm.setValue(0, 0, 1)
aSession.finishOperation()
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
-diry.setValue(0, 1, 0)
norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
norm.setValue(0, 0, 1)
aSession.finishOperation()
#=========================================================================
aSession.startOperation()
aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
-diry.setValue(0, 1, 0)
norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
norm.setValue(0, 0, 1)
aSession.finishOperation()
#=========================================================================
aSession.startOperation()
aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
-diry.setValue(0, 1, 0)
norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
norm.setValue(0, 0, 1)
aSession.finishOperation()
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
-diry.setValue(0, 1, 0)
norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
norm.setValue(0, 0, 1)
aSession.finishOperation()
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
-diry.setValue(0, 1, 0)
norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
norm.setValue(0, 0, 1)
aSession.finishOperation()
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
-diry.setValue(0, 1, 0)
norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
norm.setValue(0, 0, 1)
aSession.finishOperation()
assert (dirx.x() == 1)
assert (dirx.y() == 0)
assert (dirx.z() == 0)
-diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
-assert (diry.x() == 0)
-assert (diry.y() == 1)
-assert (diry.z() == 0)
norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
assert (norm.x() == 0)
assert (norm.y() == 0)
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
-diry.setValue(0, 1, 0)
norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
norm.setValue(0, 0, 1)
#=========================================================================
return;
FeaturePtr aFeature = theOperation->feature();
QString aFeatureId = QString::fromStdString(aFeature->getKind());
+ setActionEnabled(aFeatureId, true);
setNestedCommandsEnabled(true, aFeatureId);
setNestedStackEnabled(myOperationMgr->previousOperation(theOperation));
closeLocalContexts(false);
}
aContext->SetDisplayMode(aAISIO, theMode, false);
+ // Redisplay in order to update new mode because it could be not computed before
+ aContext->Redisplay(aAISIO, false);
if (aCanBeShaded) {
openLocalContext();
activateObjects(myActiveSelectionModes);
void XGUI_OperationMgr::onOperationStarted()
{
ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
- if (myOperations.count() == 1) {
- emit nestedStateChanged(false);
- }
+
+ bool isNestedOk = (myOperations.count() >= 1) &&
+ myOperations.at(0)->isValid();
+ emit nestedStateChanged(isNestedOk);
emit operationStarted(aSenderOperation);
}
void XGUI_OperationMgr::onOperationCommitted()
{
ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
- emit nestedStateChanged(true);
+ emit nestedStateChanged(myOperations.count() >= 1);
emit operationCommitted(aSenderOperation);
}
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<QAction*>& theNestedActions) = 0;
+
//! Creates a command in Edit menu of SALOME desktop
//! \param theId - an id of the feature
//! \param theTitle - a menu item string
QStringList aNestedFeatures =
QString::fromStdString(theMessage->nestedFeatures()).split(" ", QString::SkipEmptyParts);
QString aDocKind = QString::fromStdString(theMessage->documentKind());
+ QList<QAction*> 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);
// Enrich created button with accept/abort buttons if necessary
AppElements_Button* aButton = aCommand->button();
if (aButton->isColumnButton()) {
- QString aNestedActions = QString::fromStdString(theMessage->actionsWhenNested());
- QList<QAction*> 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);