#include <SketchPlugin_ConstraintFillet.h>
#include <SketchPlugin_ConstraintMirror.h>
+#include <SketcherPrs_Tools.h>
+
#include <SelectMgr_IndexedMapOfOwner.hxx>
#include <StdSelect_BRepOwner.hxx>
//#include <AIS_DimensionSelectionMode.hxx>
-//#include <AIS_Shape.hxx>
+#include <AIS_Shape.hxx>
#include <ModelAPI_Events.h>
#include <ModelAPI_Session.h>
#include <QMouseEvent>
#include <QApplication>
+//#define DEBUG_DO_NOT_BY_ENTER
/// Returns list of unique objects by sum of objects from List1 and List2
/*QList<ModuleBase_ViewerPrs> getSumList(const QList<ModuleBase_ViewerPrs>& theList1,
void PartSet_SketcherMgr::onEnterViewPort()
{
- if (!isNestedCreateOperation(getCurrentOperation()))
- return;
// 1. if the mouse over window, update the next flag. Do not perform update visibility of
// created feature because it should be done in onMouseMove(). Some widgets watch
// the mouse move and use the cursor position to update own values. If the presentaion is
// redisplayed before this update, the feature presentation jumps from reset value to current.
myIsMouseOverWindow = true;
myIsPropertyPanelValueChanged = false;
+
+ #ifdef DEBUG_DO_NOT_BY_ENTER
+ return;
+ #endif
+ //if (!isNestedCreateOperation(getCurrentOperation()))
+ // return;
}
void PartSet_SketcherMgr::onLeaveViewPort()
{
+ myIsMouseOverViewProcessed = false;
+ myIsMouseOverWindow = false;
+ myIsPropertyPanelValueChanged = false;
+
+ #ifdef DEBUG_DO_NOT_BY_ENTER
+ return;
+ #endif
+
if (!isNestedCreateOperation(getCurrentOperation()))
return;
// the method should be performed if the popup menu is called,
if (myIsPopupMenuActive)
return;
- myIsMouseOverViewProcessed = false;
- myIsMouseOverWindow = false;
-
// 2. if the mouse IS NOT over window, reset the active widget value and hide the presentation
ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
aDisplayer->enableUpdateViewer(isEnableUpdateViewer);
// hides the presentation of the current operation feature
- myIsPropertyPanelValueChanged = false;
+ //myIsPropertyPanelValueChanged = false;
// the feature is to be erased here, but it is correct to call canDisplayObject because
// there can be additional check (e.g. editor widget in distance constraint)
FeaturePtr aFeature = getCurrentOperation()->feature();
void PartSet_SketcherMgr::launchEditing()
{
- // there should be activate the vertex selection mode because the edit can happens by the selected
- // point
- QIntList aModes;
- aModes << TopAbs_VERTEX << TopAbs_EDGE;
- // TODO: #391 - to be uncommented
- /*aModes.append(AIS_DSM_Text);
- aModes.append(AIS_DSM_Line);
- aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
- aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));*/
-
- XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
- aConnector->activateSubShapesSelection(aModes);
+ // there should be activate the sketch selection mode because the edit can happens
+ // by any sketch entity or consttant selected
+ activateObjectsInSketchMode(true);
if (!myCurrentSelection.empty()) {
FeaturePtr aFeature = myCurrentSelection.begin().key();
void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation)
{
myIsMouseOverWindow = false;
+ myIsConstraintsShown = true;
+ // the objects activated in the sketch should be deactivated in order to do not have the specific
+ // sketch selection mode activated on objects in neutral point of the application(no started operation)
+ activateObjectsInSketchMode(false);
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
aDisplayer->updateViewer();
}
-void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* )
+void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* theOperation)
{
+ if (constraintsIdList().contains(theOperation->id())) {
+ // Show constraints if a constraint was created
+ onShowConstraintsToggle(true);
+ }
connectToPropertyPanel(true);
}
connectToPropertyPanel(false);
myIsPropertyPanelValueChanged = false;
myIsMouseOverViewProcessed = true;
+
+ // the sketch objects selection should be activated in order to select any sketch
+ // object
+ activateObjectsInSketchMode(true);
}
void PartSet_SketcherMgr::commitNestedSketch(ModuleBase_Operation* theOperation)
if (isNestedCreateOperation(theOperation))
visualizeFeature(theOperation, true);
- if (constraintsIdList().contains(theOperation->id())) {
- // Show constraints if a constraint was created
- onShowConstraintsToggle(true);
- }
}
bool PartSet_SketcherMgr::canUndo() const
bool PartSet_SketcherMgr::canDisplayObject(const ObjectPtr& theObject) const
{
bool aCanDisplay = true;
- // 1. the sketch feature should not be displayed during the sketch active operation
- // it is hidden by a sketch operation start and shown by a sketch stop, just the sketch
- // nested features can be visualized
- CompositeFeaturePtr aSketchFeature = activeSketch();
- if (aSketchFeature.get() != NULL) {
+
+ bool aHasActiveSketch = activeSketch().get() != NULL;
+ if (aHasActiveSketch) {
+ // 1. the sketch feature should not be displayed during the sketch active operation
+ // it is hidden by a sketch operation start and shown by a sketch stop, just the sketch
+ // nested features can be visualized
FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
- if (aFeature.get() != NULL && aFeature == aSketchFeature)
+ if (aFeature.get() != NULL && aFeature == activeSketch())
aCanDisplay = false;
}
- // 2. For created nested feature operation do not display the created feature if
+ else { // there are no an active sketch
+ // 2. sketch sub-features should not visualized if the sketch operation is not active
+ FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+ if (aFeature.get() != NULL) {
+ std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
+ std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+ if (aSketchFeature.get())
+ aCanDisplay = false;
+ }
+ }
+
+ // 3. For created nested feature operation do not display the created feature if
// the mouse curstor leaves the OCC window.
// The correction cases, which ignores this condition:
// a. the property panel values modification
// b. the popup menu activated
// c. widget editor control
- if (aCanDisplay) {
- if (!isNestedCreateOperation(getCurrentOperation()))
- return aCanDisplay;
-
+ #ifndef DEBUG_DO_NOT_BY_ENTER
+ if (aCanDisplay && isNestedCreateOperation(getCurrentOperation())) {
ModuleBase_Operation* aOperation = getCurrentOperation();
ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
ModuleBase_ModelWidget* anActiveWdg = aPanel ? aPanel->activeWidget() : 0;
+ ModuleBase_WidgetEditor* anEditorWdg = anActiveWdg ? dynamic_cast<ModuleBase_WidgetEditor*>(anActiveWdg) : 0;
// the active widget editor should not influence here. The presentation should be visible always
// when this widget is active.
- if (anActiveWdg) {
- ModuleBase_WidgetEditor* anEditorWdg = dynamic_cast<ModuleBase_WidgetEditor*>(anActiveWdg);
- if (anEditorWdg) {
- return aCanDisplay;
- }
+ if (!anEditorWdg && !myIsPopupMenuActive) {
+ // during a nested create operation, the feature is redisplayed only if the mouse over view
+ // of there was a value modified in the property panel after the mouse left the view
+ aCanDisplay = myIsPropertyPanelValueChanged || myIsMouseOverWindow;
}
- if (myIsPopupMenuActive)
- return aCanDisplay;
-
- // during a nested create operation, the feature is redisplayed only if the mouse over view
- // of there was a value modified in the property panel after the mouse left the view
- aCanDisplay = myIsPropertyPanelValueChanged || myIsMouseOverWindow;
}
+ #endif
return aCanDisplay;
}
-bool PartSet_SketcherMgr::canSetAuxiliary(bool& theValue) const
-{
- bool anEnabled = false;
- ModuleBase_Operation* anOperation = getCurrentOperation();
-
- bool isActiveSketch = PartSet_SketcherMgr::isSketchOperation(anOperation) ||
- PartSet_SketcherMgr::isNestedSketchOperation(anOperation);
- if (!isActiveSketch)
- return anEnabled;
-
- QObjectPtrList anObjects;
- // 1. change auxiliary type of a created feature
- if (PartSet_SketcherMgr::isNestedCreateOperation(anOperation) &&
- PartSet_SketcherMgr::isEntityOperation(anOperation) ) {
- anObjects.append(anOperation->feature());
- }
- else {
- /// The operation should not be aborted here, because the method does not changed
- /// the auxilliary state, but checks the possibility to perform this
- ///if (PartSet_SketcherMgr::isNestedSketchOperation(anOperation))
- /// anOperation->abort();
- // 2. change auxiliary type of selected sketch entities
- ModuleBase_ISelection* aSelection = myModule->workshop()->selection();
- anObjects = aSelection->selectedPresentations();
- }
- anEnabled = anObjects.size() > 0;
-
- bool isNotAuxiliaryFound = false;
- if (anObjects.size() > 0) {
- QObjectPtrList::const_iterator anIt = anObjects.begin(), aLast = anObjects.end();
- for (; anIt != aLast && !isNotAuxiliaryFound; anIt++) {
- FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt);
- if (aFeature.get() != NULL) {
- std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
- std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
- if (aSketchFeature.get() != NULL) {
- std::string anAttribute = SketchPlugin_SketchEntity::AUXILIARY_ID();
-
- std::shared_ptr<ModelAPI_AttributeBoolean> anAuxiliaryAttr =
- std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(aSketchFeature->data()->attribute(anAttribute));
- if (anAuxiliaryAttr)
- isNotAuxiliaryFound = !anAuxiliaryAttr->value();
- }
- }
- }
- }
- theValue = anObjects.size() && !isNotAuxiliaryFound;
- return anEnabled;
-}
-
-void PartSet_SketcherMgr::setAuxiliary(const bool isChecked)
-{
- ModuleBase_Operation* anOperation = getCurrentOperation();
-
- bool isActiveSketch = PartSet_SketcherMgr::isSketchOperation(anOperation) ||
- PartSet_SketcherMgr::isNestedSketchOperation(anOperation);
- if (!isActiveSketch)
- return;
-
- QObjectPtrList anObjects;
- bool isUseTransaction = false;
- // 1. change auxiliary type of a created feature
- if (PartSet_SketcherMgr::isNestedCreateOperation(anOperation) &&
- PartSet_SketcherMgr::isEntityOperation(anOperation) ) {
- anObjects.append(anOperation->feature());
- }
- else {
- isUseTransaction = true;
- // 2. change auxiliary type of selected sketch entities
- ModuleBase_ISelection* aSelection = myModule->workshop()->selection();
- anObjects = aSelection->selectedPresentations();
- }
-
- QAction* anAction = myModule->action("AUXILIARY_CMD");
- SessionPtr aMgr = ModelAPI_Session::get();
- if (isUseTransaction) {
- if (PartSet_SketcherMgr::isNestedSketchOperation(anOperation))
- anOperation->abort();
- aMgr->startOperation(anAction->text().toStdString());
- }
- storeSelection();
-
- if (anObjects.size() > 0) {
- QObjectPtrList::const_iterator anIt = anObjects.begin(), aLast = anObjects.end();
- for (; anIt != aLast; anIt++) {
- FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt);
- if (aFeature.get() != NULL) {
- std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
- std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
- if (aSketchFeature.get() != NULL) {
- std::string anAttribute = SketchPlugin_SketchEntity::AUXILIARY_ID();
-
- std::shared_ptr<ModelAPI_AttributeBoolean> anAuxiliaryAttr =
- std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(aSketchFeature->data()->attribute(anAttribute));
- if (anAuxiliaryAttr)
- anAuxiliaryAttr->setValue(isChecked);
- }
- }
- }
- }
- if (isUseTransaction) {
- aMgr->finishOperation();
- }
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
- restoreSelection();
-}
void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
{
myPlaneFilter->setPlane(thePln->impl<gp_Pln>());
+
+ // after the plane is selected in the sketch, the sketch selection should be activated
+ // it can not be performed in the sketch label widget because, we don't need to switch off
+ // the selection by any label deactivation, but need to switch it off by stop the sketch
+ activateObjectsInSketchMode(true);
}
void PartSet_SketcherMgr::getCurrentSelection(const FeaturePtr& theFeature,
void PartSet_SketcherMgr::visualizeFeature(ModuleBase_Operation* theOperation,
const bool isToDisplay)
{
+ #ifdef DEBUG_DO_NOT_BY_ENTER
+ return;
+ #endif
+
if (!theOperation || theOperation->isEditOperation())
return;
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();