#include <PartSet_WidgetSketchLabel.h>
#include <PartSet_Validators.h>
#include <PartSet_Tools.h>
-#include <PartSet_WidgetPoint2D.h>
+#include <PartSet_WidgetPoint2d.h>
#include <PartSet_WidgetPoint2dDistance.h>
#include <PartSet_WidgetShapeSelector.h>
#include <ModuleBase_IViewer.h>
#include <ModuleBase_IViewWindow.h>
#include <ModuleBase_IPropertyPanel.h>
+#include <ModuleBase_WidgetEditor.h>
+#include <ModuleBase_FilterFactory.h>
+#include <ModuleBase_FilterLinearEdge.h>
+
#include <ModelAPI_Object.h>
#include <ModelAPI_Events.h>
#include <GeomDataAPI_Point.h>
#include <GeomDataAPI_Dir.h>
-#include <XGUI_MainWindow.h>
#include <XGUI_Displayer.h>
-#include <XGUI_Viewer.h>
#include <XGUI_Workshop.h>
#include <XGUI_OperationMgr.h>
-#include <XGUI_ViewPort.h>
-#include <XGUI_ActionsMgr.h>
-#include <XGUI_ViewerProxy.h>
-#include <XGUI_ContextMenuMgr.h>
#include <XGUI_PropertyPanel.h>
#include <XGUI_ModuleConnector.h>
#include <XGUI_Tools.h>
PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
: ModuleBase_IModule(theWshop),
- myIsDragging(false), myRestartingMode(true), myDragDone(false)
+ myIsDragging(false), myRestartingMode(RM_None), myDragDone(false)
{
//myWorkshop = dynamic_cast<XGUI_Workshop*>(theWshop);
ModuleBase_IViewer* aViewer = aViewer = theWshop->viewer();
connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)),
this, SLOT(onMouseMoved(ModuleBase_IViewWindow*, QMouseEvent*)));
+ connect(aViewer, SIGNAL(mouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)),
+ this, SLOT(onMouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)));
+
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWshop);
+ XGUI_Workshop* aWorkshop = aConnector->workshop();
+
+ XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
+ connect(anOpMgr, SIGNAL(keyEnterReleased()), this, SLOT(onEnterReleased()));
+ connect(anOpMgr, SIGNAL(operationActivatedByPreselection()),
+ this, SLOT(onOperationActivatedByPreselection()));
+
+ connect(aViewer, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)),
+ this, SLOT(onKeyRelease(ModuleBase_IViewWindow*, QKeyEvent*)));
}
PartSet_Module::~PartSet_Module()
aFactory->registerValidator("PartSet_PerpendicularValidator", new PartSet_PerpendicularValidator);
aFactory->registerValidator("PartSet_ParallelValidator", new PartSet_ParallelValidator);
aFactory->registerValidator("PartSet_RadiusValidator", new PartSet_RadiusValidator);
+ aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator);
}
+void PartSet_Module::registerFilters()
+{
+ //Registering of selection filters
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
+ ModuleBase_FilterFactory* aFactory = aConnector->selectionFilters();
+
+ aFactory->registerFilter("LinearEdgeFilter", new ModuleBase_FilterLinearEdge);
+}
void PartSet_Module::onOperationComitted(ModuleBase_Operation* theOperation)
{
FeaturePtr aFeature = theOperation->feature();
std::shared_ptr<SketchPlugin_Feature> aSPFeature =
std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
- if (aSPFeature && myRestartingMode) {
+ if (aSPFeature && (myRestartingMode == RM_LastFeatureUsed ||
+ myRestartingMode == RM_EmptyFeatureUsed)) {
myLastOperationId = theOperation->id();
- myLastFeature = theOperation->feature();
+ myLastFeature = myRestartingMode == RM_LastFeatureUsed ? theOperation->feature() : FeaturePtr();
launchOperation(myLastOperationId);
- } else {
- breakOperationSequence();
}
+ breakOperationSequence();
}
void PartSet_Module::breakOperationSequence()
{
myLastOperationId = "";
myLastFeature = FeaturePtr();
- myRestartingMode = false;
-
+ myRestartingMode = RM_None;
}
void PartSet_Module::onOperationAborted(ModuleBase_Operation* theOperation)
void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation)
{
- myRestartingMode = true;
if (theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) {
// Display all sketcher sub-Objects
myCurrentSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theOperation->feature());
}
}
if (myDocumentShapeFilter.IsNull())
- myDocumentShapeFilter = new ModuleBase_ShapeDocumentFilter(myWorkshop);
+ myDocumentShapeFilter = new PartSet_GlobalFilter(myWorkshop);
myWorkshop->viewer()->addSelectionFilter(myDocumentShapeFilter);
}
void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
{
ModuleBase_IPropertyPanel* aPanel = theOperation->propertyPanel();
+ if ((theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) &&
+ (theOperation->isEditOperation())) {
+ // we have to manually activate the sketch label in edit mode
+ aPanel->activateWidget(aPanel->modelWidgets().first());
+ return;
+ }
+
// Restart last operation type
if ((theOperation->id() == myLastOperationId) && myLastFeature) {
ModuleBase_ModelWidget* aWgt = aPanel->activeWidget();
void PartSet_Module::onSelectionChanged()
{
+ ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
+ bool isSketcherOp = false;
+ // An edit operation is enable only if the current opeation is the sketch operation
+ if (aOperation && myCurrentSketch) {
+ if (PartSet_Tools::sketchPlane(myCurrentSketch))
+ isSketcherOp = (aOperation->id().toStdString() == SketchPlugin_Sketch::ID());
+ }
+ if (!isSketcherOp)
+ return;
+
// Editing of constraints can be done on selection
ModuleBase_ISelection* aSelect = myWorkshop->selection();
QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
return;
}
+ QObjectPtrList aSelObjects = getSumList(aHighlighted, aSelected);
if ((aHighlighted.size() == 1) && (aSelected.size() == 0)) {
// Move by selected shape (vertex). Can be used only for single selection
foreach(ModuleBase_ViewerPrs aPrs, aHighlighted) {
}
} else {
// Provide multi-selection. Can be used only for features
- QList<ObjectPtr> aObjects = getSumList(aHighlighted, aSelected);
- foreach (ObjectPtr aObj, aObjects) {
+ foreach (ObjectPtr aObj, aSelObjects) {
FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
if (aFeature && (!myEditingFeatures.contains(aFeature)))
myEditingFeatures.append(aFeature);
get2dPoint(theWnd, theEvent, myCurX, myCurY);
myDragDone = false;
myWorkshop->viewer()->enableSelection(false);
-
launchEditing();
} else if (isSketchOpe && isEditing) {
}
}
+void PartSet_Module::onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
+{
+ ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
+ if (aOperation->isEditOperation()) {
+ std::string aId = aOperation->id().toStdString();
+ if ((aId == SketchPlugin_ConstraintLength::ID()) ||
+ (aId == SketchPlugin_ConstraintDistance::ID()) ||
+ (aId == SketchPlugin_ConstraintRadius::ID()))
+ {
+ // Activate dimension value editing on double click
+ ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
+ QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
+ // Find corresponded widget to activate value editing
+ foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
+ if (aWgt->attributeID() == "ConstraintValue") {
+ aWgt->focusTo();
+ return;
+ }
+ }
+ }
+ }
+}
+
+void PartSet_Module::onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent)
+{
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
+ XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
+ anOpMgr->onKeyReleased(theEvent);
+}
+
+void PartSet_Module::onEnterReleased()
+{
+ myRestartingMode = RM_EmptyFeatureUsed;
+}
+
+void PartSet_Module::onOperationActivatedByPreselection()
+{
+ ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
+ if (!aOperation)
+ return;
+
+ // Set final definitions if they are necessary
+ //propertyPanelDefined(aOperation);
+
+ /// Commit sketcher operations automatically
+ FeaturePtr aFeature = aOperation->feature();
+ std::shared_ptr<SketchPlugin_Feature> aSPFeature =
+ std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+ if (aSPFeature) {
+ aOperation->commit();
+ }
+}
+
+void PartSet_Module::onNoMoreWidgets()
+{
+ ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
+ if (aOperation) {
+ /// Restart sketcher operations automatically
+ FeaturePtr aFeature = aOperation->feature();
+ std::shared_ptr<SketchPlugin_Feature> aSPFeature =
+ std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+ if (aSPFeature) {
+ if (myRestartingMode != RM_Forbided)
+ myRestartingMode = RM_LastFeatureUsed;
+ aOperation->commit();
+ }
+ }
+}
QStringList PartSet_Module::sketchOperationIdList() const
{
ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
if (aWidgets.last() == aPanel->activeWidget()) {
- breakOperationSequence();
+ myRestartingMode = RM_Forbided;
}
}
}
}else
return 0;
}
+