-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 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
//
// 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
+// 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>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "PartSet_Module.h"
#include "PartSet_IconFactory.h"
#include "PartSet_OverconstraintListener.h"
#include "PartSet_TreeNodes.h"
+#include "PartSet_FieldStepPrs.h"
#include "PartSet_Filters.h"
#include "PartSet_FilterInfinite.h"
#include <PartSetPlugin_Part.h>
#include <PartSetPlugin_Duplicate.h>
+#include <SketchPlugin_ConstraintCoincidence.h>
+
#include <ModuleBase_Operation.h>
#include <ModuleBase_OperationAction.h>
#include <ModuleBase_IViewer.h>
#include <ModuleBase_WidgetFactory.h>
#include <ModuleBase_OperationDescription.h>
#include <ModuleBase_ViewerPrs.h>
+#include <ModelAPI_ResultField.h>
#include <ModelAPI_Object.h>
#include <ModelAPI_Events.h>
myRoot(0),
myIsOperationIsLaunched(false)
{
- new PartSet_IconFactory();
+ new PartSet_IconFactory(this);
mySketchMgr = new PartSet_SketcherMgr(this);
mySketchReentrantMgr = new PartSet_SketcherReentrantMgr(theWshop);
Events_Loop* aLoop = Events_Loop::loop();
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED));
+ aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
registerSelectionFilter(SF_GlobalFilter, new PartSet_GlobalFilter(myWorkshop));
registerSelectionFilter(SF_FilterInfinite, new PartSet_FilterInfinite(myWorkshop));
"Dimension value size", Config_Prop::IntSpin, aStream.str());
Config_PropManager::registerProp("Visualization", "sketch_dimension_color",
- "Sketch dimension color",
+ "Dimension color",
Config_Prop::Color, SKETCH_DIMENSION_COLOR);
}
//******************************************************
PartSet_Module::~PartSet_Module()
{
- std::map<XGUI_SelectionFilterType, Handle(SelectMgr_Filter)>::const_iterator aFiltersIt =
- mySelectionFilters.begin();
- for (; aFiltersIt != mySelectionFilters.end(); aFiltersIt++) {
- Handle(SelectMgr_Filter) aFilter = aFiltersIt->second;
- if (!aFilter.IsNull())
- aFilter.Nullify();
- }
delete myCustomPrs;
delete myOverconstraintListener;
delete myRoot;
{
bool isSketchActive = mySketchMgr->activeSketch().get();
- std::map<XGUI_SelectionFilterType, Handle(SelectMgr_Filter)>::const_iterator aFiltersIt =
+ std::map<ModuleBase_SelectionFilterType, Handle(SelectMgr_Filter)>::const_iterator aFiltersIt =
mySelectionFilters.begin();
for (; aFiltersIt != mySelectionFilters.end(); aFiltersIt++) {
int aFilterType = aFiltersIt->first;
// using sketch filters only if sketch operation is active
if (!isSketchActive &&
- mySketchMgr->sketchSelectionFilter((XGUI_SelectionFilterType)aFilterType))
+ mySketchMgr->sketchSelectionFilter((ModuleBase_SelectionFilterType)aFilterType))
continue;
// using filtering of construction results only from faces panel
}
}
-//******************************************************
-QIntList PartSet_Module::selectionFilters()
-{
- QIntList aTypes;
-
- std::map<XGUI_SelectionFilterType, Handle(SelectMgr_Filter)>::const_iterator aFiltersIt =
- mySelectionFilters.begin();
- for (; aFiltersIt != mySelectionFilters.end(); aFiltersIt++)
- aTypes.append(aFiltersIt->first);
-
- return aTypes;
-}
-
-//******************************************************
-void PartSet_Module::registerSelectionFilter(const XGUI_SelectionFilterType theFilterType,
- const Handle(SelectMgr_Filter)& theFilter)
-{
- mySelectionFilters[theFilterType] = theFilter;
-}
-
-//******************************************************
-Handle(SelectMgr_Filter) PartSet_Module::selectionFilter(const int theType)
-{
- XGUI_SelectionFilterType aType = (XGUI_SelectionFilterType)theType;
-
- if (mySelectionFilters.find(aType) != mySelectionFilters.end())
- return mySelectionFilters[aType];
- else
- return Handle(SelectMgr_Filter)();
-}
-
//******************************************************
void PartSet_Module::customSubShapesSelectionModes(QIntList& theModes)
{
mySketchMgr, SLOT(onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>&)));
connect(aLabelWgt, SIGNAL(showConstraintToggled(int, bool)),
mySketchMgr, SLOT(onShowConstraintsToggle(int, bool)));
+ connect(aLabelWgt, SIGNAL(showFreePoints(bool)), mySketchMgr, SLOT(onShowPoints(bool)));
+ connect(aLabelWgt, SIGNAL(autoConstraints(bool)),
+ sketchReentranceMgr(), SLOT(onAutoConstraints(bool)));
+ aLabelWgt->setShowPointsState(mySketchMgr->isShowFreePointsShown());
aWgt = aLabelWgt;
} else if (theType == "sketch-2dpoint_selector") {
PartSet_WidgetPoint2D* aPointWgt = new PartSet_WidgetPoint2D(theParent, aWorkshop,
}
if (aToUseZLayer) {
Handle(AIS_InteractiveContext) aCtx = anAIS->GetContext();
- aCtx->SetZLayer(anAIS, myVisualLayerId);
+ if (aFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID())
+ aCtx->SetZLayer(anAIS, Graphic3d_ZLayerId_Top);
+ else
+ aCtx->SetZLayer(anAIS, myVisualLayerId);
}
}
}
SketcherPrs_Tools::setArrowSize(aLen);
const double aCurScale = aViewer->activeView()->Camera()->Scale();
aViewer->SetScale(aViewer->activeView(), aCurScale);
+#ifdef OPTIMIZE_PRS
QList<Handle(AIS_InteractiveObject)> aPrsList = aDisplayer->displayedPresentations();
foreach(Handle(AIS_InteractiveObject) aAisObj, aPrsList) {
+#else
+ QList<AISObjectPtr> aPrsList = aDisplayer->displayedPresentations();
+ foreach(AISObjectPtr aAIS, aPrsList) {
+ Handle(AIS_InteractiveObject) aAisObj = aAIS->impl<Handle(AIS_InteractiveObject)>();
+#endif
Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast(aAisObj);
if (!aDim.IsNull()) {
aDim->DimensionAspect()->ArrowAspect()->SetLength(aLen);
}
//******************************************************
-Handle(AIS_InteractiveObject) PartSet_Module::createPresentation(const ResultPtr& theResult)
+Handle(AIS_InteractiveObject) PartSet_Module::createPresentation(const ObjectPtr& theObject)
{
- return mySketchMgr->createPresentation(theResult);
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+ if (aResult.get())
+ return mySketchMgr->createPresentation(aResult);
+ else {
+ FieldStepPtr aStep =
+ std::dynamic_pointer_cast<ModelAPI_ResultField::ModelAPI_FieldStep>(theObject);
+ if (aStep.get()) {
+ return new PartSet_FieldStepPrs(aStep);
+ }
+ }
+ return Handle(AIS_InteractiveObject)();
}
//******************************************************
SessionPtr aMgr = ModelAPI_Session::get();
DocumentPtr aActiveDoc = aMgr->activeDocument();
- // workaround for #2431 (SISGSEGV when launching some unit tests from GUI)
- //if (myActivePartIndex.isValid())
- // aTreeView->setExpanded(myActivePartIndex, false);
+
+ // Clear active part index if there is no Part documents
+ // It could be not null if document was closed and opened a new
+ // without closeDocument call
+ if (aMgr->allOpenedDocuments().size() <= 1)
+ myActivePartIndex = QModelIndex();
XGUI_DataModel* aDataModel = aWorkshop->objectBrowser()->dataModel();
+ QModelIndex aOldActive = myActivePartIndex;
myActivePartIndex = aDataModel->documentRootIndex(aActiveDoc, 0);
bool needUpdate = false;
if (myActivePartIndex.isValid()) {
if (!needUpdate)
aTreeView->setExpanded(myActivePartIndex, true);
}
+ if ((aOldActive != myActivePartIndex) && (aOldActive.isValid()))
+ aTreeView->setExpanded(aOldActive, false);
aLabel->setPalette(aPalet);
aWorkshop->updateCommandStatus();
aDisplayer->updateViewer();
// Update tree items if they are expanded
if (needUpdate) {
- aTreeView->viewport()->repaint(aTreeView->viewport()->rect());
+ aTreeView->viewport()->update(aTreeView->viewport()->rect());
}
} else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
}
}
}
+ else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)) {
+ CompositeFeaturePtr aSketch = mySketchMgr->activeSketch();
+ if (aSketch.get()) {
+ ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
+ if (PartSet_SketcherMgr::isSketchOperation(anOperation))
+ mySketchMgr->previewSketchPlane()->createSketchPlane(aSketch, myWorkshop);
+ }
+ }
}
//******************************************************
{
return myRoot;
}
+
+//******************************************************
+void PartSet_Module::disableCustomMode(ModuleBase_CustomizeFlag theMode) {
+ myCustomPrs->disableCustomMode(theMode);
+}
+
+//******************************************************
+void PartSet_Module::enableCustomModes() {
+ myCustomPrs->enableCustomModes();
+}