-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
#include "PartSet_Module.h"
#include "PartSet_WidgetSketchLabel.h"
#include "PartSet_MenuMgr.h"
#include "PartSet_CustomPrs.h"
#include "PartSet_IconFactory.h"
-#include "PartSet_WidgetChoice.h"
#include "PartSet_OverconstraintListener.h"
#include "PartSet_Filters.h"
#include <ModuleBase_IViewer.h>
#include <ModuleBase_IViewWindow.h>
#include <ModuleBase_IPropertyPanel.h>
+#include <ModuleBase_WidgetChoice.h>
#include <ModuleBase_WidgetEditor.h>
#include <ModuleBase_WidgetValidated.h>
#include <ModuleBase_Tools.h>
#include <GeomDataAPI_Point.h>
#include <GeomDataAPI_Dir.h>
-#include <XGUI_Displayer.h>
-#include <XGUI_Workshop.h>
-#include <XGUI_OperationMgr.h>
-#include <XGUI_PropertyPanel.h>
-#include <XGUI_ModuleConnector.h>
+#include <XGUI_ActiveControlMgr.h>
+#include <XGUI_ActiveControlSelector.h>
+#include <XGUI_ActionsMgr.h>
#include <XGUI_ContextMenuMgr.h>
-#include <XGUI_Tools.h>
-#include <XGUI_ObjectsBrowser.h>
-#include <XGUI_SelectionMgr.h>
+#include <XGUI_CustomPrs.h>
#include <XGUI_DataModel.h>
+#include <XGUI_Displayer.h>
#include <XGUI_ErrorMgr.h>
-#include <XGUI_CustomPrs.h>
+#include <XGUI_FacesPanelSelector.h>
+#include <XGUI_ModuleConnector.h>
+#include <XGUI_ObjectsBrowser.h>
+#include <XGUI_OperationMgr.h>
+#include <XGUI_PropertyPanel.h>
#include <XGUI_SelectionMgr.h>
-#include <XGUI_ActionsMgr.h>
+#include <XGUI_Tools.h>
+#include <XGUI_Workshop.h>
-#include <SketchPlugin_Feature.h>
-#include <SketchPlugin_Sketch.h>
#include <SketchPlugin_ConstraintAngle.h>
#include <SketchPlugin_ConstraintLength.h>
#include <SketchPlugin_ConstraintDistance.h>
#include <SketchPlugin_ConstraintParallel.h>
#include <SketchPlugin_ConstraintPerpendicular.h>
#include <SketchPlugin_ConstraintRadius.h>
+#include <SketchPlugin_Feature.h>
+#include <SketchPlugin_Projection.h>
+#include <SketchPlugin_Sketch.h>
#include <SketcherPrs_SymbolPrs.h>
#include <SketcherPrs_Coincident.h>
Config_PropManager::registerProp("Visualization", "operation_remove_feature_color",
"Color of removed feature in operation", Config_Prop::Color,
PartSet_CustomPrs::OPERATION_REMOVE_FEATURE_COLOR());
+ Config_PropManager::registerProp("Visualization", "sketch_preview_plane",
+ "Color of sketch plane", Config_Prop::Color,
+ PartSet_CustomPrs::OPERATION_SKETCH_PLANE());
+
+ Config_PropManager::registerProp("Visualization", "hidden_face_transparency",
+ "Hidden faces transparency",
+ Config_Prop::Double,
+ "0.8");
}
PartSet_Module::~PartSet_Module()
}
}
+void PartSet_Module::updateActiveSelectionFilters()
+{
+ XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(workshop());
+ XGUI_ActiveControlSelector* anActiveSelector = aWorkshop->activeControlMgr()->activeSelector();
+
+ if (anActiveSelector && anActiveSelector->getType() == XGUI_FacesPanelSelector::Type())
+ sketchMgr()->deactivateSelectionFilters();
+ else
+ sketchMgr()->activateSelectionFilters();
+}
+
void PartSet_Module::storeSelection()
{
// cash is used only to restore selection, so it should be filled in storeSelection and
aFactory->registerValidator("PartSet_CollinearSelection", new PartSet_CollinearSelection);
aFactory->registerValidator("PartSet_MiddlePointSelection", new PartSet_MiddlePointSelection);
aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator);
+ aFactory->registerValidator("PartSet_DifferentPoints", new PartSet_DifferentPointsValidator);
aFactory->registerValidator("PartSet_CoincidentAttr", new PartSet_CoincidentAttr);
aFactory->registerValidator("PartSet_MultyTranslationSelection",
new PartSet_MultyTranslationSelection);
if (sketchMgr()->isNestedSketchOperation(theOperation)) {
mySketchMgr->commitNestedSketch(theOperation);
}
+ /// deactivate of overconstraint listener should be performed after Sketch commit (#2176)
+ if (PartSet_SketcherMgr::isSketchOperation(theOperation))
+ overconstraintListener()->setActive(false);
/// Restart sketcher operations automatically
if (!mySketchReentrantMgr->operationCommitted(theOperation)) {
{
/// Restart sketcher operations automatically
mySketchReentrantMgr->operationAborted(theOperation);
+ /// deactivate of overconstraint listener should be performed after Sketch abort (#2176)
+ if (PartSet_SketcherMgr::isSketchOperation(theOperation))
+ overconstraintListener()->setActive(false);
}
void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation)
void PartSet_Module::closeDocument()
{
myActivePartIndex = QModelIndex();
- clearViewer();
}
void PartSet_Module::clearViewer()
} else if (theType == "sketch_launcher") {
aWgt = new PartSet_WidgetSketchCreator(theParent, this, theWidgetApi);
} else if (theType == "module_choice") {
- aWgt = new PartSet_WidgetChoice(theParent, theWidgetApi);
+ aWgt = new ModuleBase_WidgetChoice(theParent, theWidgetApi);
connect(aWgt, SIGNAL(itemSelected(ModuleBase_ModelWidget*, int)),
this, SLOT(onChoiceChanged(ModuleBase_ModelWidget*, int)));
}
{
Handle(AIS_InteractiveObject) anAIS = theAIS->impl<Handle(AIS_InteractiveObject)>();
if (!anAIS.IsNull()) {
+ bool aToUseZLayer = false;
+ FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+ if (aFeature.get() && PartSet_Tools::findRefsToMeFeature(aFeature,
+ SketchPlugin_Projection::ID()))
+ aToUseZLayer = true;
Handle(AIS_InteractiveContext) aCtx = anAIS->GetContext();
Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast(anAIS);
if (!aDim.IsNull()) {
- aCtx->SetZLayer(aDim, myVisualLayerId);
+ aToUseZLayer = true;
} else {
Handle(SketcherPrs_SymbolPrs) aCons = Handle(SketcherPrs_SymbolPrs)::DownCast(anAIS);
if (!aCons.IsNull())
- aCtx->SetZLayer(aCons, myVisualLayerId);
+ aToUseZLayer = true;
}
+ aCtx->SetZLayer(anAIS, myVisualLayerId);
}
}
}
if (aView.IsNull())
return;
- double aLen = aView->Convert(SketcherPrs_Tools::getDefaultArrowSize());
-
- double aPrevLen = SketcherPrs_Tools::getArrowSize();
- SketcherPrs_Tools::setArrowSize(aLen);
- const double aPrevScale = aViewer->Scale(aViewer->activeView());
- const double aCurScale = aViewer->activeView()->Camera()->Scale();
- aViewer->SetScale(aViewer->activeView(), aCurScale);
- SketcherPrs_Tools::setTextHeight (aCurScale / aPrevScale * SketcherPrs_Tools::getTextHeight());
- bool isModified = false;
- QList<AISObjectPtr> aPrsList = aDisplayer->displayedPresentations();
- foreach (AISObjectPtr aAIS, aPrsList) {
- Handle(AIS_InteractiveObject) aAisObj = aAIS->impl<Handle(AIS_InteractiveObject)>();
-
- Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast(aAisObj);
- if (!aDim.IsNull()) {
- aDim->DimensionAspect()->ArrowAspect()->SetLength(aLen);
- aContext->Redisplay(aDim, false);
- isModified = true;
+
+ ModuleBase_Operation* aCurrentOperation = myWorkshop->currentOperation();
+ if (aCurrentOperation &&
+ (PartSet_SketcherMgr::isSketchOperation(aCurrentOperation) ||
+ sketchMgr()->isNestedSketchOperation(aCurrentOperation)))
+ {
+ double aLen = aView->Convert(SketcherPrs_Tools::getConfigArrowSize());
+
+ double aPrevLen = SketcherPrs_Tools::getArrowSize();
+ SketcherPrs_Tools::setArrowSize(aLen);
+ const double aCurScale = aViewer->activeView()->Camera()->Scale();
+ aViewer->SetScale(aViewer->activeView(), aCurScale);
+ bool isModified = false;
+ QList<AISObjectPtr> aPrsList = aDisplayer->displayedPresentations();
+ foreach (AISObjectPtr aAIS, aPrsList) {
+ Handle(AIS_InteractiveObject) aAisObj = aAIS->impl<Handle(AIS_InteractiveObject)>();
+
+ Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast(aAisObj);
+ if (!aDim.IsNull()) {
+ aDim->DimensionAspect()->ArrowAspect()->SetLength(aLen);
+ aContext->Redisplay(aDim, false);
+ isModified = true;
+ }
}
+ if (isModified)
+ aDisplayer->updateViewer();
}
- if (isModified)
- aDisplayer->updateViewer();
}
bool PartSet_Module::isCustomPrsActivated(const ModuleBase_CustomizeFlag& theFlag) const
bool hasParameter = false;
bool hasCompositeOwner = false;
bool hasResultInHistory = false;
+ bool hasFolder = false;
ModuleBase_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter,
- hasCompositeOwner, hasResultInHistory);
+ hasCompositeOwner, hasResultInHistory, hasFolder);
ModuleBase_Operation* aCurrentOp = myWorkshop->currentOperation();
if (aSelected == 1) {
aTreeView->setExpanded(myActivePartIndex, false);
XGUI_DataModel* aDataModel = aWorkshop->objectBrowser()->dataModel();
- myActivePartIndex = aDataModel->documentRootIndex(aActiveDoc);
+ myActivePartIndex = aDataModel->documentRootIndex(aActiveDoc, 0);
bool needUpdate = false;
if (myActivePartIndex.isValid()) {
needUpdate = aTreeView->isExpanded(myActivePartIndex);
//aMgr->setActiveDocument(aMgr->moduleDocument());
return;
}
- if (theIndex.column() != 0) // Use only first column
+ if (theIndex.column() != 1) // Use only first column
return;
XGUI_Workshop* aWorkshop = getWorkshop();
void PartSet_Module::onChoiceChanged(ModuleBase_ModelWidget* theWidget,
int theIndex)
{
- PartSet_WidgetChoice* aChoiceWidget = dynamic_cast<PartSet_WidgetChoice*>(theWidget);
+ ModuleBase_WidgetChoice* aChoiceWidget = dynamic_cast<ModuleBase_WidgetChoice*>(theWidget);
if (!aChoiceWidget)
return;