class ModuleBase_ModelWidget;\r
class ModuleBase_Operation;\r
class ModuleBase_IWorkshop;\r
+class ModuleBase_IDocumentDataModel;\r
\r
/**\r
* \ingroup GUI\r
/// \param theMenu a popup menu to be shown in the viewer\r
/// \param theStdActions a map of standard actions\r
/// \return true if items are added and there is no necessity to provide standard menu\r
- virtual bool addViewerItems(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const { return false; }\r
+ virtual bool addViewerMenu(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const { return false; }\r
\r
/// Add menu atems for object browser into the given menu\r
/// \param theMenu a popup menu to be shown in the object browser\r
- virtual void addObjectBrowserItems(QMenu* theMenu) const {};\r
+ virtual void addObjectBrowserMenu(QMenu* theMenu) const {};\r
\r
/// Called when it is necessary to update a command state (enable or disable it)\r
//virtual bool isFeatureEnabled(const QString& theCmdId) const = 0;\r
/// \returns true if the action is processed\r
virtual bool deleteObjects() { return false; };\r
\r
+ /// Returns data model object for representation of data tree in Object browser\r
+ virtual ModuleBase_IDocumentDataModel* dataModel() const = 0;\r
+\r
+ /// Returns a list of modes, where the AIS objects should be activated\r
+ /// \param theModes a list of modes\r
+ virtual void activeSelectionModes(QIntList& theModes) {};\r
+ \r
public slots:\r
/// Called on call of command corresponded to a feature\r
void onFeatureTriggered();\r
// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
#include "PartSet_Module.h"
-#include <PartSet_WidgetSketchLabel.h>
-#include <PartSet_Validators.h>
-#include <PartSet_Tools.h>
-#include <PartSet_WidgetPoint2d.h>
-#include <PartSet_WidgetPoint2dDistance.h>
-#include <PartSet_WidgetShapeSelector.h>
-#include <PartSet_WidgetMultiSelector.h>
-#include <PartSet_WidgetEditor.h>
+#include "PartSet_WidgetSketchLabel.h"
+#include "PartSet_Validators.h"
+#include "PartSet_Tools.h"
+#include "PartSet_WidgetPoint2d.h"
+#include "PartSet_WidgetPoint2dDistance.h"
+#include "PartSet_WidgetShapeSelector.h"
+#include "PartSet_WidgetMultiSelector.h"
+#include "PartSet_WidgetEditor.h"
#include "PartSet_SketcherMgr.h"
#include "PartSet_MenuMgr.h"
+#include "PartSet_DocumentDataModel.h"
+
+#include <PartSetPlugin_Remove.h>
+#include <PartSetPlugin_Part.h>
#include <ModuleBase_Operation.h>
#include <ModuleBase_IViewer.h>
#include <ModuleBase_IPropertyPanel.h>
#include <ModuleBase_WidgetEditor.h>
#include <ModuleBase_FilterFactory.h>
- #include <GeomValidators_Edge.h>
- #include <GeomValidators_EdgeOrVertex.h>
+#include <ModuleBase_Tools.h>
+ #include <GeomValidators_ShapeType.h>
+
#include <GeomValidators_Face.h>
#include <GeomValidators_ConstructionComposite.h>
#include <XGUI_ModuleConnector.h>
#include <XGUI_ContextMenuMgr.h>
#include <XGUI_Tools.h>
+#include <XGUI_ObjectsBrowser.h>
#include <SketchPlugin_Feature.h>
#include <SketchPlugin_Sketch.h>
#include <QApplication>
#include <QMessageBox>
#include <QMainWindow>
+#include <QLineEdit>
#include <GeomAlgoAPI_FaceBuilder.h>
#include <GeomDataAPI_Dir.h>
#include <QDebug>
#endif
+
+
/*!Create and return new instance of XGUI_Module*/
extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(ModuleBase_IWorkshop* theWshop)
{
}
PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
- : ModuleBase_IModule(theWshop),
+ : ModuleBase_IModule(theWshop),
myRestartingMode(RM_None), myVisualLayerId(0)
{
mySketchMgr = new PartSet_SketcherMgr(this);
+ myDataModel = new PartSet_DocumentDataModel(this);
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWshop);
XGUI_Workshop* aWorkshop = aConnector->workshop();
SLOT(onViewTransformed(int)));
myMenuMgr = new PartSet_MenuMgr(this);
+
+ Events_Loop* aLoop = Events_Loop::loop();
+ aLoop->registerListener(this, Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED));
}
PartSet_Module::~PartSet_Module()
aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator);
aFactory->registerValidator("PartSet_DifferentShapes", new ModelAPI_ShapeValidator);
- aFactory->registerValidator("GeomValidators_Edge", new GeomValidators_Edge);
- aFactory->registerValidator("GeomValidators_EdgeOrVertex",
- new GeomValidators_EdgeOrVertex);
+ aFactory->registerValidator("GeomValidators_ShapeType", new GeomValidators_ShapeType);
aFactory->registerValidator("GeomValidators_Face", new GeomValidators_Face);
aFactory->registerValidator("GeomValidators_ConstructionComposite",
}
-bool PartSet_Module::addViewerItems(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const
+bool PartSet_Module::addViewerMenu(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const
{
- return myMenuMgr->addViewerItems(theMenu, theStdActions);
+ return myMenuMgr->addViewerMenu(theMenu, theStdActions);
}
+ void PartSet_Module::activeSelectionModes(QIntList& theModes)
+ {
+ theModes.clear();
+ if (mySketchMgr->activeSketch().get())
+ PartSet_SketcherMgr::sketchSelectionModes(theModes);
+ }
+
bool PartSet_Module::isMouseOverWindow()
{
return mySketchMgr->isMouseOverWindow();
bool PartSet_Module::deleteObjects()
{
+ SessionPtr aMgr = ModelAPI_Session::get();
// 1. check whether the delete should be processed in the module
ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(anOperation),
isNestedOp = PartSet_SketcherMgr::isNestedSketchOperation(anOperation);
- if (!isSketchOp && !isNestedOp)
- return false;
-
- // 2. find selected presentations
- // selected objects should be collected before the current operation abort because
- // the abort leads to selection lost on constraint objects. It can be corrected after #386 issue
- XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
- XGUI_Workshop* aWorkshop = aConnector->workshop();
- ModuleBase_ISelection* aSel = workshop()->selection();
- QObjectPtrList aSelectedObj = aSel->selectedPresentations();
- // if there are no selected objects in the viewer, that means that the selection in another
- // place cased this method. It is necessary to return the false value to understande in above
- // method that delete is not processed
- if (aSelectedObj.count() == 0)
- return false;
-
- // avoid delete of the objects, which are not belong to the current sketch
- // in order to do not delete results of other sketches
- QObjectPtrList aSketchObjects;
- QObjectPtrList::const_iterator anIt = aSelectedObj.begin(), aLast = aSelectedObj.end();
- for ( ; anIt != aLast; anIt++) {
- ObjectPtr anObject = *anIt;
- if (mySketchMgr->isObjectOfSketch(anObject))
- aSketchObjects.append(anObject);
- }
- // if the selection contains only local selected presentations from other sketches,
- // the Delete operation should not be done at all
- if (aSketchObjects.size() == 0)
- return true;
-
- // the active nested sketch operation should be aborted unconditionally
- if (isNestedOp)
- anOperation->abort();
-
- // 3. start operation
- QString aDescription = aWorkshop->contextMenuMgr()->action("DELETE_CMD")->text();
- SessionPtr aMgr = ModelAPI_Session::get();
- aMgr->startOperation(aDescription.toStdString());
-
- // 4. delete features
- // sketch feature should be skipped, only sub-features can be removed
- // when sketch operation is active
- std::set<FeaturePtr> anIgnoredFeatures;
- anIgnoredFeatures.insert(mySketchMgr->activeSketch());
- aWorkshop->deleteFeatures(aSketchObjects, anIgnoredFeatures);
+ if (isSketchOp && isNestedOp) {
+ // 2. find selected presentations
+ // selected objects should be collected before the current operation abort because
+ // the abort leads to selection lost on constraint objects. It can be corrected after #386 issue
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
+ XGUI_Workshop* aWorkshop = aConnector->workshop();
+ ModuleBase_ISelection* aSel = workshop()->selection();
+ QObjectPtrList aSelectedObj = aSel->selectedPresentations();
+ // if there are no selected objects in the viewer, that means that the selection in another
+ // place cased this method. It is necessary to return the false value to understande in above
+ // method that delete is not processed
+ if (aSelectedObj.count() == 0)
+ return false;
+
+ // avoid delete of the objects, which are not belong to the current sketch
+ // in order to do not delete results of other sketches
+ QObjectPtrList aSketchObjects;
+ QObjectPtrList::const_iterator anIt = aSelectedObj.begin(), aLast = aSelectedObj.end();
+ for ( ; anIt != aLast; anIt++) {
+ ObjectPtr anObject = *anIt;
+ if (mySketchMgr->isObjectOfSketch(anObject))
+ aSketchObjects.append(anObject);
+ }
+ // if the selection contains only local selected presentations from other sketches,
+ // the Delete operation should not be done at all
+ if (aSketchObjects.size() == 0)
+ return true;
+
+ // the active nested sketch operation should be aborted unconditionally
+ if (isNestedOp)
+ anOperation->abort();
+
+ // 3. start operation
+ QString aDescription = aWorkshop->contextMenuMgr()->action("DELETE_CMD")->text();
+ aMgr->startOperation(aDescription.toStdString());
+
+ // 4. delete features
+ // sketch feature should be skipped, only sub-features can be removed
+ // when sketch operation is active
+ std::set<FeaturePtr> anIgnoredFeatures;
+ anIgnoredFeatures.insert(mySketchMgr->activeSketch());
+ aWorkshop->deleteFeatures(aSketchObjects, anIgnoredFeatures);
- // 5. stop operation
- aWorkshop->displayer()->updateViewer();
- aMgr->finishOperation();
-
+ // 5. stop operation
+ aWorkshop->displayer()->updateViewer();
+ aMgr->finishOperation();
+ } else {
+ // Delete part with help of PartSet plugin
+ // TODO: the deleted objects has to be processed by multiselection
+ QObjectPtrList aObjects = myWorkshop->selection()->selectedObjects();
+ if (aObjects.size() == 1) {
+ ObjectPtr aObj = aObjects.first();
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
+ if (aFeature.get() && (aFeature->getKind() == PartSetPlugin_Part::ID())) {
+ std::shared_ptr<ModelAPI_Document> aDoc = aMgr->activeDocument();
+ aMgr->startOperation(PartSetPlugin_Remove::ID());
+ FeaturePtr aFeature = aDoc->addFeature(PartSetPlugin_Remove::ID());
+ aFeature->execute();
+ aMgr->finishOperation();
+ }
+ }
+ }
return true;
}
if (isModified)
aDisplayer->updateViewer();
}
+
+ModuleBase_IDocumentDataModel* PartSet_Module::dataModel() const
+{
+ return myDataModel;
+}
+
+
+void PartSet_Module::addObjectBrowserMenu(QMenu* theMenu) const
+{
+ QObjectPtrList aObjects = myWorkshop->selection()->selectedObjects();
+ int aSelected = aObjects.size();
+ if (aSelected == 1) {
+ bool hasResult = false;
+ bool hasFeature = false;
+ bool hasParameter = false;
+ ModuleBase_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter);
+
+ SessionPtr aMgr = ModelAPI_Session::get();
+ ObjectPtr aObject = aObjects.first();
+ if (aObject) {
+ ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObject);
+ if (aPart) {
+ if (aMgr->activeDocument() == aPart->partDoc())
+ theMenu->addAction(myMenuMgr->action("DEACTIVATE_PART_CMD"));
+ else
+ theMenu->addAction(myMenuMgr->action("ACTIVATE_PART_CMD"));
+ } else if (aObject->document() == aMgr->activeDocument()) {
+ if (hasParameter || hasFeature)
+ theMenu->addAction(myMenuMgr->action("EDIT_CMD"));
+ }
+ } else { // If feature is 0 the it means that selected root object (document)
+ if (aMgr->activeDocument() != aMgr->moduleDocument())
+ theMenu->addAction(myMenuMgr->action("ACTIVATE_PARTSET_CMD"));
+ }
+ }
+}
+
+void PartSet_Module::processEvent(const std::shared_ptr<Events_Message>& theMessage)
+{
+ if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_DOCUMENT_CHANGED)) {
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
+ XGUI_Workshop* aWorkshop = aConnector->workshop();
+ XGUI_DataTree* aTreeView = aWorkshop->objectBrowser()->treeView();
+ QLineEdit* aLabel = aWorkshop->objectBrowser()->activeDocLabel();
+ QPalette aPalet = aLabel->palette();
+
+ SessionPtr aMgr = ModelAPI_Session::get();
+ DocumentPtr aActiveDoc = aMgr->activeDocument();
+ DocumentPtr aDoc = aMgr->moduleDocument();
+ QModelIndex aOldIndex = myDataModel->activePartIndex();
+ if (aActiveDoc == aDoc) {
+ if (aOldIndex.isValid())
+ aTreeView->setExpanded(aOldIndex, false);
+ myDataModel->deactivatePart();
+ aPalet.setColor(QPalette::Text, QColor(0, 72, 140));
+ } else {
+ std::string aGrpName = ModelAPI_ResultPart::group();
+ for (int i = 0; i < aDoc->size(aGrpName); i++) {
+ ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aDoc->object(aGrpName, i));
+ if (aPart->partDoc() == aActiveDoc) {
+ QModelIndex aIndex = myDataModel->partIndex(aPart);
+ if ((aOldIndex != aIndex) && aOldIndex.isValid()) {
+ aTreeView->setExpanded(aOldIndex, false);
+ }
+ if (myDataModel->activatePart(aIndex)) {
+ aTreeView->setExpanded(aIndex.parent(), true);
+ aTreeView->setExpanded(aIndex, true);
+ aPalet.setColor(QPalette::Text, Qt::black);
+ }
+ break;
+ }
+ }
+ }
+ aLabel->setPalette(aPalet);
+ }
+}
#include <ModelAPI_Attribute.h>
#include <ModelAPI_CompositeFeature.h>
+#include <Events_Listener.h>
+
//#include <StdSelect_FaceFilter.hxx>
#include <TopoDS_Shape.hxx>
class ModuleBase_IViewWindow;
class PartSet_MenuMgr;
class PartSet_SketcherMgr;
+class PartSet_DocumentDataModel;
class QAction;
* \ingroup Modules
* Implementation of Partset module
*/
-class PARTSET_EXPORT PartSet_Module : public ModuleBase_IModule
+class PARTSET_EXPORT PartSet_Module : public ModuleBase_IModule, public Events_Listener
{
Q_OBJECT
};
public:
+
/// Constructor
/// \param theWshop a pointer to a workshop
PartSet_Module(ModuleBase_IWorkshop* theWshop);
/// \param theObject a model object
virtual bool canDisplayObject(const ObjectPtr& theObject) const;
+ /// Add menu atems for object browser into the given menu
+ /// \param theMenu a popup menu to be shown in the object browser
+ virtual void addObjectBrowserMenu(QMenu* theMenu) const;
+
/// Add menu atems for viewer into the given menu
/// \param theMenu a popup menu to be shown in the viewer
/// \param theStdActions a map of standard actions
/// \return true if items are added and there is no necessity to provide standard menu
- virtual bool addViewerItems(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const;
+ virtual bool addViewerMenu(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const;
+ /// Returns a list of modes, where the AIS objects should be activated
+ /// \param theModes a list of modes
+ virtual void activeSelectionModes(QIntList& theModes);
+
/// Returns whether the mouse enter the viewer's window
/// \return true if items are added and there is no necessity to provide standard menu
bool isMouseOverWindow();
PartSet_SketcherMgr* sketchMgr() const { return mySketchMgr; }
+ /// Returns data model object for representation of data tree in Object browser
+ virtual ModuleBase_IDocumentDataModel* dataModel() const;
+
+ /// Event Listener method
+ /// \param theMessage an event message
+ virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
+
public slots:
/// SLOT, that is called by no more widget signal emitted by property panel
/// Set a specific flag to restart the sketcher operation
/// \param theOperation the operation
virtual void sendOperation(ModuleBase_Operation* theOperation);
+ //! Activates or deactivates a part
+ //! If PartPtr is Null pointer then PartSet will be activated
+ //void activatePart(std::shared_ptr<ModelAPI_ResultPart> theFeature);
+
private slots:
/// Processing of vertex selected
void onVertexSelected();
PartSet_MenuMgr* myMenuMgr;
int myVisualLayerId;
+
+ PartSet_DocumentDataModel* myDataModel;
};
#endif
//#define DEBUG_FEATURE_CREATED
//#define DEBUG_FEATURE_REDISPLAY
-QMap<QString, QString> XGUI_Workshop::myIcons;
-
-
-QIcon XGUI_Workshop::featureIcon(const FeaturePtr& theFeature)
-{
- QIcon anIcon;
-
- std::string aKind = theFeature->getKind();
- QString aId(aKind.c_str());
- if (!myIcons.contains(aId))
- return anIcon;
-
- QString anIconString = myIcons[aId];
-
- ModelAPI_ExecState aState = theFeature->data()->execState();
- switch(aState) {
- case ModelAPI_StateDone:
- case ModelAPI_StateNothing: {
- anIcon = QIcon(anIconString);
- }
- break;
- case ModelAPI_StateMustBeUpdated: {
- anIcon = ModuleBase_Tools::lighter(anIconString);
- }
- break;
- case ModelAPI_StateExecFailed: {
- anIcon = ModuleBase_Tools::composite(":pictures/exec_state_failed.png", anIconString);
- }
- break;
- case ModelAPI_StateInvalidArgument: {
- anIcon = ModuleBase_Tools::composite(":pictures/exec_state_invalid_parameters.png",
- anIconString);
- }
- break;
- default: break;
- }
- return anIcon;
-}
XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
: QObject(),
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
- aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED));
aLoop->registerListener(this, Events_LongOp::eventID());
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_PLUGIN_LOADED));
- aLoop->registerListener(this, Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TOSHOW));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TOHIDE));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_SELFILTER_LOADED));
std::shared_ptr<ModelAPI_ObjectUpdatedMessage> anUpdateMsg =
std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
onFeatureUpdatedMsg(anUpdateMsg);
- } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) {
- std::shared_ptr<ModelAPI_ObjectDeletedMessage> aDelMsg =
- std::dynamic_pointer_cast<ModelAPI_ObjectDeletedMessage>(theMessage);
- onObjectDeletedMsg(aDelMsg);
} else if (theMessage->eventID() == Events_LongOp::eventID()) {
if (Events_LongOp::isPerformed()) {
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
updateCommandStatus();
}
}
- } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_DOCUMENT_CHANGED)) {
- myActionsMgr->update();
- // Find and Activate active part
- if (myPartActivating)
- return;
- SessionPtr aMgr = ModelAPI_Session::get();
- DocumentPtr aActiveDoc = aMgr->activeDocument();
- DocumentPtr aDoc = aMgr->moduleDocument();
- if (aActiveDoc == aDoc) {
- activatePart(ResultPartPtr());
- return;
- }
- std::string aGrpName = ModelAPI_ResultPart::group();
- for (int i = 0; i < aDoc->size(aGrpName); i++) {
- ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aDoc->object(aGrpName, i));
- if (aPart->partDoc() == aActiveDoc) {
- activatePart(aPart); // Activate a part which corresponds to active Doc
- return;
- }
- }
- // If not found then activate global document
- activatePart(ResultPartPtr());
-
- }
+ }
else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_SELFILTER_LOADED)) {
std::shared_ptr<Config_SelectionFilterMessage> aMsg =
std::dynamic_pointer_cast<Config_SelectionFilterMessage>(theMessage);
}
}
myOperationMgr->onValidateOperation();
- if (myObjectBrowser)
- myObjectBrowser->processEvent(theMsg);
+ //if (myObjectBrowser)
+ // myObjectBrowser->processEvent(theMsg);
}
//******************************************************
isDisplayed = displayObject(*aIt);
//}
}
- if (myObjectBrowser)
- myObjectBrowser->processEvent(theMsg);
+ //if (myObjectBrowser)
+ // myObjectBrowser->processEvent(theMsg);
if (isDisplayed)
myDisplayer->updateViewer();
//if (aHasPart) { // TODO: Avoid activate last part on loading of document
//}
}
-//******************************************************
-void XGUI_Workshop::onObjectDeletedMsg(const std::shared_ptr<ModelAPI_ObjectDeletedMessage>& theMsg)
-{
- if (myObjectBrowser)
- myObjectBrowser->processEvent(theMsg);
- //std::set<ObjectPtr> aFeatures = theMsg->objects();
-}
-
//******************************************************
void XGUI_Workshop::onOperationStarted(ModuleBase_Operation* theOperation)
{
//myDisplayer->activateObjects(aModes);
myModule->operationStopped(theOperation);
- if (myOperationMgr->operationsCount() == 0) {
+ // if the operation is nested, do not deactivate objects
+ //if (myOperationMgr->operationsCount() == 0) {
// Activate selection mode for all objects
- QIntList aModes;
- myDisplayer->activateObjects(aModes);
- }
+ QIntList aModes;
+ // TODO: check on OCC_6.9.0
+ // the module current active modes should not be deactivated in order to save the objects selected
+ // the deactivate object in the mode of selection leads to the object is deselected in the viewer.
+ // But, in OCC_6.8.0 this deselection does not happened automatically. It is necessary to call
+ // ClearOutdatedSelection, but this method has an error in the realization, which should be fixed in
+ // the OCC_6.9.0 release. Moreother, it is possible that ClearOutdatedSelection will be called inside
+ // Deactivate method of AIS_InteractiveContext. In this case, we need not call it.
+ module()->activeSelectionModes(aModes);
+ myDisplayer->activateObjects(aModes);
+ //}
}
}
ActionInfo aFeatureInfo;
aFeatureInfo.initFrom(theMessage);
- // Remember features icons
- myIcons[QString::fromStdString(theMessage->id())] = aFeatureInfo.iconFile;
QString aWchName = QString::fromStdString(theMessage->workbenchId());
QStringList aNestedFeatures =
aObjDock->setStyleSheet(
"::title { position: relative; padding-left: 5px; text-align: left center }");
myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock);
- connect(myObjectBrowser, SIGNAL(activePartChanged(ObjectPtr)), this,
- SLOT(changeCurrentDocument(ObjectPtr)));
+ myObjectBrowser->setDataModel(myModule->dataModel());
+ //connect(myObjectBrowser, SIGNAL(activePartChanged(ObjectPtr)), this,
+ // SLOT(changeCurrentDocument(ObjectPtr)));
aObjDock->setWidget(myObjectBrowser);
myContextMenuMgr->connectObjectBrowser();
}
}
-//******************************************************
-void XGUI_Workshop::changeCurrentDocument(ObjectPtr theObj)
-{
- SessionPtr aMgr = ModelAPI_Session::get();
- if (theObj) {
- ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(theObj);
- if (aPart) {
- DocumentPtr aPartDoc = aPart->partDoc();
- if (aPartDoc) {
- aMgr->setActiveDocument(aPartDoc);
- return;
- }
- }
- }
- aMgr->setActiveDocument(aMgr->moduleDocument());
-}
-
//******************************************************
void XGUI_Workshop::salomeViewerSelectionChanged()
{
void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
{
QObjectPtrList aObjects = mySelector->selection()->selectedObjects();
- if ((theId == "ACTIVATE_PART_CMD") && (aObjects.size() > 0)) {
- ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObjects.first());
- activatePart(aPart);
- } else if (theId == "DEACTIVATE_PART_CMD")
- activatePart(ResultPartPtr());
- else if (theId == "DELETE_CMD")
+ if (theId == "DELETE_CMD")
deleteObjects();
else if (theId == "COLOR_CMD")
changeColor(aObjects);
setDisplayMode(aObjects, XGUI_Displayer::Wireframe);
else if (theId == "HIDEALL_CMD")
myDisplayer->eraseAll();
- else if (theId == "EDIT_CMD") {
- FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObjects.first());
- if (aFeature == NULL) {
- ResultParameterPtr aParam =
- std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aObjects.first());
- if (aParam.get() != NULL) {
- aFeature = ModelAPI_Feature::feature(aParam);
- }
- }
- if (aFeature.get() != NULL)
- myModule->editFeature(aFeature);
- }
}
-//**************************************************************
-void XGUI_Workshop::activatePart(ResultPartPtr theFeature)
-{
- if (!myPartActivating) {
- myPartActivating = true;
- if (theFeature)
- theFeature->activate();
- changeCurrentDocument(theFeature);
- myObjectBrowser->activatePart(theFeature);
- myPartActivating = false;
- }
- updateCommandStatus();
-}
-
-//**************************************************************
-//void XGUI_Workshop::activateLastPart()
-//{
-// SessionPtr aMgr = ModelAPI_Session::get();
-// DocumentPtr aDoc = aMgr->moduleDocument();
-// std::string aGrpName = ModelAPI_ResultPart::group();
-// ObjectPtr aLastPart = aDoc->object(aGrpName, aDoc->size(aGrpName) - 1);
-// ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aLastPart);
-// if (aPart) {
-// activatePart(aPart);
-// }
-//}
-
//**************************************************************
void XGUI_Workshop::deleteObjects()
{
bool hasResult = false;
bool hasFeature = false;
bool hasParameter = false;
- XGUI_Tools::checkObjects(anObjects, hasResult, hasFeature, hasParameter);
+ ModuleBase_Tools::checkObjects(anObjects, hasResult, hasFeature, hasParameter);
if (!(hasFeature || hasParameter))
return;