activateCustom();
}
+bool ModuleBase_ModelWidget::storeValue()
+{
+ emit beforeValuesChanged();
+ bool isDone = storeValueCustom();
+ emit afterValuesChanged();
+
+ return isDone;
+}
+
void ModuleBase_ModelWidget::updateObject(ObjectPtr theObj) const
{
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
bool isEditingMode() const { return myIsEditing; }
signals:
+ /// The signal about widget values are to be changed
+ void beforeValuesChanged();
/// The signal about widget values changed
void valuesChanged();
+ /// The signal about widget values are to be changed
+ void afterValuesChanged();
/// The signal about key release on the control, that corresponds to the attribute
/// \param theEvent key release event
void focusOutWidget(ModuleBase_ModelWidget* theWidget);
protected:
- /// Saves the internal parameters to the given feature
- /// \return True in success
- virtual bool storeValue() const = 0;
-
/// \brief Set the attribute name
/// \param theAttribute the string value with attribute name
void setAttributeID(const std::string& theAttribute)
myAttributeID = theAttribute;
}
+ /// Saves the internal parameters to the given feature. Emits signals before and after store
+ /// \return True in success
+ bool storeValue();
+
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValueCustom() const = 0;
+
/// The methiod called when widget is activated
virtual void activateCustom() {};
return myCheckBox;
}
-bool ModuleBase_WidgetBoolValue::storeValue() const
+bool ModuleBase_WidgetBoolValue::storeValueCustom() const
{
DataPtr aData = myFeature->data();
std::shared_ptr<ModelAPI_AttributeBoolean> aBool = aData->boolean(attributeID());
protected:
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValue() const;
+ virtual bool storeValueCustom() const;
private:
/// The check box
{
}
-bool ModuleBase_WidgetChoice::storeValue() const
+bool ModuleBase_WidgetChoice::storeValueCustom() const
{
DataPtr aData = myFeature->data();
std::shared_ptr<ModelAPI_AttributeInteger> aIntAttr = aData->integer(attributeID());
protected:
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValue() const;
+ virtual bool storeValueCustom() const;
private slots:
/// Slot called on combo box index change
}
}
-bool ModuleBase_WidgetDoubleValue::storeValue() const
+bool ModuleBase_WidgetDoubleValue::storeValueCustom() const
{
DataPtr aData = myFeature->data();
AttributeDoublePtr aReal = aData->real(attributeID());
protected:
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValue() const;
+ virtual bool storeValueCustom() const;
protected:
/// Container for thw widget controls
{
}
-bool ModuleBase_WidgetFileSelector::storeValue() const
+bool ModuleBase_WidgetFileSelector::storeValueCustom() const
{
// A rare case when plugin was not loaded.
if(!myFeature)
protected:
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValue() const;
+ virtual bool storeValueCustom() const;
protected:
/// Returns string containing formats
protected:
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValue() const
+ virtual bool storeValueCustom() const
{
return true;
}
{
}
-bool ModuleBase_WidgetLineEdit::storeValue() const
+bool ModuleBase_WidgetLineEdit::storeValueCustom() const
{
// A rare case when plugin was not loaded.
if(!myFeature)
protected:
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValue() const;
+ virtual bool storeValueCustom() const;
private:
/// A line edit control
}
//********************************************************************
-bool ModuleBase_WidgetMultiSelector::storeValue() const
+bool ModuleBase_WidgetMultiSelector::storeValueCustom() const
{
// A rare case when plugin was not loaded.
if(!myFeature)
protected:
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValue() const;
+ virtual bool storeValueCustom() const;
/// Provide filtering of selected shapes
/// \param theShapesToFilter source list of shapes
}
//********************************************************************
-bool ModuleBase_WidgetShapeSelector::storeValue() const
+bool ModuleBase_WidgetShapeSelector::storeValueCustom() const
{
FeaturePtr aSelectedFeature = ModelAPI_Feature::feature(mySelectedObject);
if (aSelectedFeature == myFeature) // In order to avoid selection of the same object
}
}
+//********************************************************************
+void ModuleBase_WidgetShapeSelector::selectionFilters(SelectMgr_ListOfFilter& theFilters)
+{
+ if (!myObjectTypes.isEmpty()) {
+ myObjTypeFilter = new ModuleBase_ObjectTypesFilter(myWorkshop, myObjectTypes);
+ theFilters.Append(myObjTypeFilter);
+ }
+ // apply filters loaded from the XML definition of the widget
+ ModuleBase_FilterFactory* aFactory = myWorkshop->selectionFilters();
+ SelectMgr_ListOfFilter aFilters;
+ aFactory->filters(parentID(), attributeID(), aFilters);
+ SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
+ for (; aIt.More(); aIt.Next()) {
+ Handle(SelectMgr_Filter) aSelFilter = aIt.Value();
+ if (aSelFilter.IsNull())
+ continue;
+
+ theFilters.Append(aSelFilter);
+ }
+}
+
//********************************************************************
void ModuleBase_WidgetShapeSelector::raisePanel() const
{
protected:
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValue() const;
+ virtual bool storeValueCustom() const;
/// The methiod called when widget is activated
virtual void activateCustom();
PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule)
: QObject(theModule), myModule(theModule), myIsDragging(false), myDragDone(false),
myIsPropertyPanelValueChanged(false), myIsMouseOverWindow(false),
- myIsMouseOverViewProcessed(true)
+ myIsMouseOverViewProcessed(true), myPreviousUpdateViewerEnabled(true)
{
ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
ModuleBase_IViewer* aViewer = anIWorkshop->viewer();
visualizeFeature(aOperation, canDisplayObject());
}
+void PartSet_SketcherMgr::onBeforeValuesChangedInPropertyPanel()
+{
+ if (isNestedCreateOperation(getCurrentOperation()))
+ return;
+ storeSelection();
+}
+
+void PartSet_SketcherMgr::onAfterValuesChangedInPropertyPanel()
+{
+ if (isNestedCreateOperation(getCurrentOperation()))
+ return;
+ restoreSelection();
+}
+
void PartSet_SketcherMgr::onValuesChangedInPropertyPanel()
{
if (!isNestedCreateOperation(getCurrentOperation()))
if (aPropertyPanel) {
const QList<ModuleBase_ModelWidget*>& aWidgets = aPropertyPanel->modelWidgets();
foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
- if (isToConnect)
+ if (isToConnect) {
+ connect(aWidget, SIGNAL(beforeValuesChanged()),
+ this, SLOT(onBeforeValuesChangedInPropertyPanel()));
connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
- else
+ connect(aWidget, SIGNAL(afterValuesChanged()),
+ this, SLOT(onAfterValuesChangedInPropertyPanel()));
+ }
+ else {
+ disconnect(aWidget, SIGNAL(beforeValuesChanged()),
+ this, SLOT(onBeforeValuesChangedInPropertyPanel()));
disconnect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
+ disconnect(aWidget, SIGNAL(afterValuesChanged()),
+ this, SLOT(onAfterValuesChangedInPropertyPanel()));
+ }
}
}
}
}
aDisplayer->updateViewer();
}
+
+void PartSet_SketcherMgr::storeSelection()
+{
+ //qDebug(" storeSelection");
+ ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
+ // 1. it is necessary to save current selection in order to restore it after the features moving
+ //FeatureToSelectionMap aCurrentSelection;
+ myCurrentSelection.clear();
+ getCurrentSelection(myFeature2AttributeMap, myCurrentSketch, aWorkshop, myCurrentSelection);
+
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
+ XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
+ // 3. the flag to disable the update viewer should be set in order to avoid blinking in the
+ // viewer happens by deselect/select the modified objects. The flag should be restored after
+ // the selection processing. The update viewer should be also called.
+ myPreviousUpdateViewerEnabled = aDisplayer->enableUpdateViewer(false);
+}
+
+void PartSet_SketcherMgr::restoreSelection()
+{
+ //qDebug("restoreSelection");
+ ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
+ // 5. it is necessary to save current selection in order to restore it after the features moving
+ FeatureToSelectionMap::const_iterator aSIt = myCurrentSelection.begin(),
+ aSLast = myCurrentSelection.end();
+ SelectMgr_IndexedMapOfOwner anOwnersToSelect;
+ for (; aSIt != aSLast; aSIt++) {
+ anOwnersToSelect.Clear();
+ getSelectionOwners(aSIt->first, myCurrentSketch, aWorkshop, myCurrentSelection,
+ anOwnersToSelect);
+ aConnector->workshop()->selector()->setSelectedOwners(anOwnersToSelect, false);
+ }
+ XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
+ // 3. the flag to disable the update viewer should be set in order to avoid blinking in the
+ // viewer happens by deselect/select the modified objects. The flag should be restored after
+ // the selection processing. The update viewer should be also called.
+ aDisplayer->enableUpdateViewer(myPreviousUpdateViewerEnabled);
+ //if (myPreviousUpdateViewerEnabled)
+ aDisplayer->updateViewer();
+}
/// Process the leave mouse of the view port. If the current operation is a create of
/// a nested sketch feature, it hides the feature in the viewer
void onLeaveViewPort();
- /// Listens the value changed signal and display the current operation feature
+ /// Listens to the value changed signal and display the current operation feature
+ void onBeforeValuesChangedInPropertyPanel();
+ /// Listens to the signal about values are to be changed in the property panel
void onValuesChangedInPropertyPanel();
+ /// Listens to the signal about the modification of the values have been done in the property panel
+ void onAfterValuesChangedInPropertyPanel();
void onMousePressed(ModuleBase_IViewWindow*, QMouseEvent*);
void onMouseReleased(ModuleBase_IViewWindow*, QMouseEvent*);
/// \param isToDisplay a flag about the display or erase the feature
void visualizeFeature(ModuleBase_Operation* theOperation, const bool isToDisplay);
+ void storeSelection();
+ void restoreSelection();
+
private:
PartSet_Module* myModule;
FeatureToAttributesMap myFeature2AttributeMap; /// a map of a feature to attributes
Handle(ModuleBase_ShapeInPlaneFilter) myPlaneFilter;
+ FeatureToSelectionMap myCurrentSelection;
+ bool myPreviousUpdateViewerEnabled;
};
return true;
}
-bool PartSet_WidgetPoint2D::storeValue() const
+bool PartSet_WidgetPoint2D::storeValueCustom() const
{
std::shared_ptr<ModelAPI_Data> aData = myFeature->data();
if (!aData) // can be on abort of sketcher element
QIntList aModes;
aModes << TopAbs_VERTEX;
+ if (isEditingMode())
+ aModes << TopAbs_EDGE;
myWorkshop->moduleConnector()->activateSubShapesSelection(aModes);
}
protected:
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValue() const;
+ virtual bool storeValueCustom() const;
/// The methiod called when widget is activated
virtual void activateCustom();
#include <SketchPlugin_Feature.h>
-bool PartSet_WidgetShapeSelector::storeValue() const
+bool PartSet_WidgetShapeSelector::storeValueCustom() const
{
if (!mySelectedObject)
return false;
}
}
}
- return ModuleBase_WidgetShapeSelector::storeValue();
+ return ModuleBase_WidgetShapeSelector::storeValueCustom();
}
//********************************************************************
}
//*********************************************
-bool PartSet_WidgetConstraintShapeSelector::storeValue() const
+bool PartSet_WidgetConstraintShapeSelector::storeValueCustom() const
{
FeaturePtr aFeature = ModelAPI_Feature::feature(mySelectedObject);
if (aFeature) {
return false;
}
}
- return ModuleBase_WidgetShapeSelector::storeValue();
+ return ModuleBase_WidgetShapeSelector::storeValueCustom();
}
protected:
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValue() const;
+ virtual bool storeValueCustom() const;
/// Check the selected with validators if installed
virtual bool isValid(ObjectPtr theObj, std::shared_ptr<GeomAPI_Shape> theShape);
protected:
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValue() const;
+ virtual bool storeValueCustom() const;
private:
/// Pointer to a sketch
protected:
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValue() const
+ virtual bool storeValueCustom() const
{
return true;
}