+
+void PartSet_SketcherMgr::connectToPropertyPanel(const bool isToConnect)
+{
+ ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(anIWorkshop);
+ XGUI_Workshop* aWorkshop = aConnector->workshop();
+ XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel();
+ if (aPropertyPanel) {
+ const QList<ModuleBase_ModelWidget*>& aWidgets = aPropertyPanel->modelWidgets();
+ foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
+ if (isToConnect) {
+ connect(aWidget, SIGNAL(beforeValuesChanged()),
+ this, SLOT(onBeforeValuesChangedInPropertyPanel()));
+ connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
+ connect(aWidget, SIGNAL(afterValuesChanged()),
+ this, SLOT(onAfterValuesChangedInPropertyPanel()));
+ }
+ else {
+ disconnect(aWidget, SIGNAL(beforeValuesChanged()),
+ this, SLOT(onBeforeValuesChangedInPropertyPanel()));
+ disconnect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
+ disconnect(aWidget, SIGNAL(afterValuesChanged()),
+ this, SLOT(onAfterValuesChangedInPropertyPanel()));
+ }
+ }
+ }
+}
+
+ModuleBase_Operation* PartSet_SketcherMgr::getCurrentOperation() const
+{
+ return myModule->workshop()->currentOperation();
+}
+
+void PartSet_SketcherMgr::visualizeFeature(ModuleBase_Operation* theOperation,
+ const bool isToDisplay)
+{
+ #ifdef DEBUG_DO_NOT_BY_ENTER
+ return;
+ #endif
+
+ if (!theOperation || theOperation->isEditOperation())
+ return;
+
+ ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
+ XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
+
+ // 1. change visibility of the object itself, here the presentable object is processed,
+ // e.g. constraints features
+ FeaturePtr aFeature = theOperation->feature();
+ std::list<ResultPtr> aResults = aFeature->results();
+ if (isToDisplay)
+ aDisplayer->display(aFeature, false);
+ else
+ aDisplayer->erase(aFeature, false);
+
+ // change visibility of the object results, e.g. non-constraint features
+ std::list<ResultPtr>::const_iterator aIt;
+ for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
+ if (isToDisplay) {
+ aDisplayer->display(*aIt, false);
+ }
+ else {
+ aDisplayer->erase(*aIt, false);
+ }
+ }
+ aDisplayer->updateViewer();
+}
+
+void PartSet_SketcherMgr::activateObjectsInSketchMode(const bool isActive)
+{
+ ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
+ XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
+
+ QIntList aModes;
+ if (isActive) {
+ aModes.append(SketcherPrs_Tools::Sel_Dimension_Text);
+ aModes.append(SketcherPrs_Tools::Sel_Dimension_Line);
+ aModes.append(SketcherPrs_Tools::Sel_Constraint);
+ aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
+ aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));
+ }
+ aDisplayer->activateObjects(aModes);
+}
+
+void PartSet_SketcherMgr::storeSelection(const bool theHighlightedOnly)
+{
+ ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
+ ModuleBase_ISelection* aSelect = aWorkshop->selection();
+ QList<ModuleBase_ViewerPrs> aHighlighted = aSelect->getHighlighted();
+
+ QMap<FeaturePtr, QList<AttributePtr> > aFeature2AttributeMap;
+ if (theHighlightedOnly) {
+ fillFeature2Attribute(aHighlighted, aFeature2AttributeMap, myCurrentSketch);
+ }
+ else {
+ fillFeature2Attribute(aHighlighted, aFeature2AttributeMap, myCurrentSketch);
+
+ QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
+ fillFeature2Attribute(aSelected, aFeature2AttributeMap, myCurrentSketch);
+ }
+
+ // 1. it is necessary to save current selection in order to restore it after the features moving
+ myCurrentSelection.clear();
+ QMap<FeaturePtr, QList<AttributePtr> >::const_iterator anIt = aFeature2AttributeMap.begin(),
+ aLast = aFeature2AttributeMap.end();
+ for (; anIt != aLast; anIt++) {
+ FeaturePtr aFeature = anIt.key();
+ getCurrentSelection(aFeature, myCurrentSketch, aWorkshop, myCurrentSelection);
+ }
+ //qDebug(QString(" storeSelection: %1").arg(myCurrentSelection.size()).toStdString().c_str());
+}
+
+void PartSet_SketcherMgr::restoreSelection()
+{
+ //qDebug(QString("restoreSelection: %1").arg(myCurrentSelection.size()).toStdString().c_str());
+ ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
+ FeatureToSelectionMap::const_iterator aSIt = myCurrentSelection.begin(),
+ aSLast = myCurrentSelection.end();
+ SelectMgr_IndexedMapOfOwner anOwnersToSelect;
+ for (; aSIt != aSLast; aSIt++) {
+ anOwnersToSelect.Clear();
+ getSelectionOwners(aSIt.key(), myCurrentSketch, aWorkshop, myCurrentSelection,
+ anOwnersToSelect);
+ aConnector->workshop()->selector()->setSelectedOwners(anOwnersToSelect, false);
+ }
+}
+
+void PartSet_SketcherMgr::onShowConstraintsToggle(bool theOn)
+{
+ if (myIsConstraintsShown == theOn)
+ return;
+ if (myCurrentSketch.get() == NULL)
+ return;
+
+ myIsConstraintsShown = theOn;
+
+ ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
+ XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
+
+ const QStringList& aConstrIds = constraintsIdList();
+ for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
+ FeaturePtr aSubFeature = myCurrentSketch->subFeature(i);
+ if (aConstrIds.contains(QString(aSubFeature->getKind().c_str()))) {
+ if (myIsConstraintsShown)
+ aDisplayer->display(aSubFeature, false);
+ else
+ aDisplayer->erase(aSubFeature, false);
+ }
+ }
+ aDisplayer->updateViewer();
+}