//
#include "PartSet_SketcherMgr.h"
+
+#include "PartSet_Filters.h"
#include "PartSet_SketcherReentrantMgr.h"
#include "PartSet_Module.h"
#include "PartSet_MouseProcessor.h"
#include <XGUI_Workshop.h>
#include <XGUI_ContextMenuMgr.h>
#include <XGUI_Selection.h>
+#include <XGUI_SelectionActivate.h>
#include <XGUI_SelectionMgr.h>
#include <XGUI_ModuleConnector.h>
#include <XGUI_PropertyPanel.h>
#include <ModuleBase_ViewerPrs.h>
#include <ModuleBase_Tools.h>
#include <ModuleBase_ResultPrs.h>
+#include <ModuleBase_ViewerFilters.h>
#include <GeomDataAPI_Point2D.h>
#include <SketchPlugin_MultiTranslation.h>
#include <SketchPlugin_IntersectionPoint.h>
#include <SketchPlugin_Projection.h>
+#include <SketchPlugin_ConstraintDistanceAlongDir.h>
+#include <SketchPlugin_ConstraintDistanceHorizontal.h>
+#include <SketchPlugin_ConstraintDistanceVertical.h>
#include <SketcherPrs_Tools.h>
myIsConstraintsShown[PartSet_Tools::Expressions] = false;
mySketchPlane = new PartSet_PreviewSketchPlane();
+
+ registerSelectionFilter(SF_SketchCirclePointFilter, new PartSet_CirclePointFilter(anIWorkshop));
+ registerSelectionFilter(SF_SketchPlaneFilter, new ModuleBase_ShapeInPlaneFilter());
}
PartSet_SketcherMgr::~PartSet_SketcherMgr()
{
- if (!myPlaneFilter.IsNull())
- myPlaneFilter.Nullify();
}
void PartSet_SketcherMgr::onEnterViewPort()
connect(aPropertyPanel, SIGNAL(noMoreWidgets(const std::string&)),
aReentranceMgr, SLOT(onNoMoreWidgets(const std::string&)));
- connect(aPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)),
- aReentranceMgr, SLOT(onWidgetActivated()));
+ //connect(aPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)),
+ // aReentranceMgr, SLOT(onWidgetActivated()));
}
XGUI_ViewerProxy* aViewerProxy = aWorkshop->viewer();
aConstraintIds << SketchPlugin_ConstraintMirror::ID().c_str();
aConstraintIds << SketchPlugin_MultiTranslation::ID().c_str();
aConstraintIds << SketchPlugin_MultiRotation::ID().c_str();
+ aConstraintIds << SketchPlugin_ConstraintDistanceAlongDir::ID().c_str();
+ aConstraintIds << SketchPlugin_ConstraintDistanceHorizontal::ID().c_str();
+ aConstraintIds << SketchPlugin_ConstraintDistanceVertical::ID().c_str();
}
return aConstraintIds;
}
-void PartSet_SketcherMgr::sketchSelectionModes(QIntList& theModes)
+void PartSet_SketcherMgr::sketchSelectionModes(const CompositeFeaturePtr& theSketch,
+ QIntList& theModes)
{
- theModes.clear();
+ if (!theSketch.get() || !PartSet_Tools::sketchPlane(theSketch).get())
+ return;
theModes.append(SketcherPrs_Tools::Sel_Dimension_Text);
theModes.append(SketcherPrs_Tools::Sel_Dimension_Line);
return (theKind == SketchPlugin_ConstraintLength::ID()) ||
(theKind == SketchPlugin_ConstraintDistance::ID()) ||
(theKind == SketchPlugin_ConstraintRadius::ID()) ||
- (theKind == SketchPlugin_ConstraintAngle::ID());
+ (theKind == SketchPlugin_ConstraintAngle::ID()) ||
+ (theKind == SketchPlugin_ConstraintDistanceHorizontal::ID()) ||
+ (theKind == SketchPlugin_ConstraintDistanceVertical::ID()) ||
+ (theKind == SketchPlugin_ConstraintDistanceAlongDir::ID());
}
void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
// Display all sketcher sub-Objects
myCurrentSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aFOperation->feature());
+ double aSizeOfView = 0;
+ std::shared_ptr<GeomAPI_Pnt> aCentralPoint;
+ if (aFOperation->isEditOperation() &&
+ mySketchPlane->getDefaultSizeOfView(myCurrentSketch, aSizeOfView, aCentralPoint)) {
+ mySketchPlane->setSizeOfView(aSizeOfView, true, aCentralPoint);
+ }
+
mySketchPlane->createSketchPlane(myCurrentSketch, myModule->workshop());
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
qDebug(QString("startSketch: %1, %2").arg(anInfo.size()).arg(anInfoStr).toStdString().c_str());
#endif
- if(myCirclePointFilter.IsNull()) {
- myCirclePointFilter = new PartSet_CirclePointFilter(myModule->workshop());
- }
-
- myModule->workshop()->viewer()->addSelectionFilter(myCirclePointFilter);
-
- if (myPlaneFilter.IsNull())
- myPlaneFilter = new ModuleBase_ShapeInPlaneFilter();
-
- myModule->workshop()->viewer()->addSelectionFilter(myPlaneFilter);
bool aHasPlane = false;
std::shared_ptr<GeomAPI_Pln> aPln;
aPln = PartSet_Tools::sketchPlane(myCurrentSketch);
- myPlaneFilter->setPlane(aPln);
+ Handle(SelectMgr_Filter) aFilter = myModule->selectionFilter(SF_SketchPlaneFilter);
+ if (!aFilter.IsNull())
+ Handle(ModuleBase_ShapeInPlaneFilter)::DownCast(aFilter)->setPlane(aPln);
+
+ workshop()->selectionActivate()->updateSelectionFilters();
+ workshop()->selectionActivate()->updateSelectionModes();
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
- // all displayed objects should be activated in current selection modes according to switched
- // plane filter
- if (aPln.get())
- aConnector->activateModuleSelectionModes();
myExternalPointsMgr = new PartSet_ExternalPointsMgr(myModule->workshop(), myCurrentSketch);
}
// The sketch was aborted
myCurrentSketch = CompositeFeaturePtr();
mySketchPlane->eraseSketchPlane(myModule->workshop());
- // TODO: move this outside of if-else
- myModule->workshop()->viewer()->removeSelectionFilter(myCirclePointFilter);
- myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
// Erase all sketcher objects
QObjectPtrList aObjects = aDisplayer->displayedObjects();
myCurrentSketch = CompositeFeaturePtr();
mySketchPlane->eraseSketchPlane(myModule->workshop());
- myModule->workshop()->viewer()->removeSelectionFilter(myCirclePointFilter);
- myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
-
Events_Loop::loop()->flush(aDispEvent);
}
- // restore the module selection modes, which were changed on startSketch
- aConnector->activateModuleSelectionModes();
+ workshop()->selectionActivate()->updateSelectionFilters();
+ workshop()->selectionActivate()->updateSelectionModes();
}
void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* theOperation)
}
}
-void PartSet_SketcherMgr::activatePlaneFilter(const bool& toActivate)
+bool PartSet_SketcherMgr::sketchSelectionFilter(const XGUI_SelectionFilterType theFilterType)
{
- if (toActivate)
- myModule->workshop()->viewer()->addSelectionFilter(myPlaneFilter);
- else
- myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
+ return mySelectionFilterTypes.find(theFilterType) != mySelectionFilterTypes.end();
+}
+
+void PartSet_SketcherMgr::registerSelectionFilter(const XGUI_SelectionFilterType theFilterType,
+ const Handle(SelectMgr_Filter)& theFilter)
+{
+ mySelectionFilterTypes.insert(theFilterType);
+ myModule->registerSelectionFilter(theFilterType, theFilter);
}
bool PartSet_SketcherMgr::operationActivatedByPreselection()
return isFoundObject;
}
-void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
+void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePlane)
{
- if (myPlaneFilter.IsNull())
- myPlaneFilter = new ModuleBase_ShapeInPlaneFilter();
+ Handle(SelectMgr_Filter) aFilter = myModule->selectionFilter(SF_SketchPlaneFilter);
+ if (!aFilter.IsNull())
+ Handle(ModuleBase_ShapeInPlaneFilter)::DownCast(aFilter)->setPlane(thePlane);
- myPlaneFilter->setPlane(thePln);
+ workshop()->selectionActivate()->updateSelectionModes();
}
bool PartSet_SketcherMgr::setDistanceValueByPreselection(ModuleBase_Operation* theOperation,