for anIndex in range(0, aFeaturesNum):
aFeature = self.Part.object("Features", anIndex)
aSelectionList = aFeature.data().selectionList("group_list")
+ aName = aFeature.data().name()
# if a group has been found
if aSelectionList:
groupIndex = groupIndex + 1
- self.createGroupFromList(aSelectionList, "NewGeomGroup_{0}".format(groupIndex))
+ self.createGroupFromList(aSelectionList, aName)
## Creates a group by given list of selected objects and the name
# @param theSelectionList: list of selected objects
{
if (myDoc->HasOpenCommand()) { // start of nested command
if (myDoc->CommitCommand()) { // commit the current: it will contain all nested after compactification
- (*myTransactions.rbegin())++; // if has open command, the list is not empty
+ myTransactions.rbegin()->myOCAFNum++; // if has open command, the list is not empty
}
myNestedNum.push_back(0); // start of nested operation with zero transactions inside yet
myDoc->OpenCommand();
myDoc->NewCommand();
}
// starts a new operation
- myTransactions.push_back(0);
+ myTransactions.push_back(Transaction());
if (!myNestedNum.empty())
(*myNestedNum.rbegin())++;
myRedos.clear();
int aNumToCompact = *(myNestedNum.rbegin());
int aSumOfTransaction = 0;
for(int a = 0; a < aNumToCompact; a++) {
- aSumOfTransaction += *(myTransactions.rbegin());
+ aSumOfTransaction += myTransactions.rbegin()->myOCAFNum;
myTransactions.pop_back();
}
// the latest transaction is the start of lower-level operation which startes the nested
- *(myTransactions.rbegin()) += aSumOfTransaction;
+ myTransactions.rbegin()->myOCAFNum += aSumOfTransaction;
myNestedNum.pop_back();
}
}
// transaction may be empty if this document was created during this transaction (create part)
if (!myTransactions.empty() && myDoc->CommitCommand()) { // if commit is successfull, just increment counters
- (*myTransactions.rbegin())++;
+ myTransactions.rbegin()->myOCAFNum++;
aResult = true;
}
compactNested();
}
if (!aResult && !myTransactions.empty() /* it can be for just created part document */)
- aResult = *(myTransactions.rbegin()) != 0;
+ aResult = myTransactions.rbegin()->myOCAFNum != 0;
if (!aResult && Model_Session::get()->moduleDocument().get() == this) {
// nothing inside in all documents, so remove this transaction from the transactions list
myDoc->ClearRedos();
myRedos.clear();
} else { // abort the current
- int aNumTransactions = *myTransactions.rbegin();
+ int aNumTransactions = myTransactions.rbegin()->myOCAFNum;
myTransactions.pop_back();
if (!myNestedNum.empty())
(*myNestedNum.rbegin())--;
void Model_Document::undoInternal(const bool theWithSubs, const bool theSynchronize)
{
- int aNumTransactions = *myTransactions.rbegin();
+ int aNumTransactions = myTransactions.rbegin()->myOCAFNum;
+ myRedos.push_back(*myTransactions.rbegin());
myTransactions.pop_back();
- myRedos.push_back(aNumTransactions);
if (!myNestedNum.empty())
(*myNestedNum.rbegin())--;
// roll back the needed number of transactions
{
if (!myNestedNum.empty())
(*myNestedNum.rbegin())++;
- int aNumRedos = *myRedos.rbegin();
+ int aNumRedos = myRedos.rbegin()->myOCAFNum;
+ myTransactions.push_back(*myRedos.rbegin());
myRedos.pop_back();
- myTransactions.push_back(aNumRedos);
for(int a = 0; a < aNumRedos; a++)
myDoc->Redo();
subDoc(*aSubIter)->redo();
}
+std::list<std::string> Model_Document::undoList() const
+{
+ std::list<std::string> aResult;
+ std::list<Transaction>::const_reverse_iterator aTrIter = myTransactions.crbegin();
+ int aNumUndo = myTransactions.size();
+ if (!myNestedNum.empty())
+ aNumUndo = *myNestedNum.rbegin();
+ for( ; aNumUndo > 0; aTrIter++, aNumUndo--) {
+ aResult.push_back(aTrIter->myId);
+ }
+ return aResult;
+}
+
+std::list<std::string> Model_Document::redoList() const
+{
+ std::list<std::string> aResult;
+ std::list<Transaction>::const_reverse_iterator aTrIter = myRedos.crbegin();
+ for( ; aTrIter != myRedos.crend(); aTrIter++) {
+ aResult.push_back(aTrIter->myId);
+ }
+ return aResult;
+}
+
+void Model_Document::operationId(const std::string& theId)
+{
+ myTransactions.rbegin()->myId = theId;
+}
+
/// Append to the array of references a new referenced label
static void AddToRefArray(TDF_Label& theArrayLab, TDF_Label& theReferenced)
{
//! The implementation of undo: with or without recoursive calls in the sub-documents
void undoInternal(const bool theWithSubs, const bool theSynchronize);
+ //! Stores the Id of the current operation (normally is called for the root document)
+ void operationId(const std::string& theId);
+
+ //! Returns the list of Ids of the operations that can be undoed (called for the root document)
+ std::list<std::string> undoList() const;
+
+ //! Returns the list of Ids of the operations that can be redoed (called for the root document)
+ std::list<std::string> redoList() const;
+
friend class Model_Application;
friend class Model_Session;
friend class Model_Update;
/// the list is empty if not nested transaction is performed
std::list<int> myNestedNum;
- /// transaction indexes (related to myTransactionsAfterSave) and number of real transactions
+ /// Information related to the every user-transaction
+ struct Transaction {
+ int myOCAFNum; ///< number of OCAF transactions related to each "this" transaction, may be 0
+ std::string myId; ///< user-identifier string of transaction
+ /// default constructor with default Id
+ Transaction(): myOCAFNum(0), myId("") {}
+ };
+
+ /// transaction indexes (related to myTransactionsAfterSave) and info about the real transactions
/// in myDocument connected to this operation (may be zero for empty transaction)
- std::list<int> myTransactions;
- /// list of numbers of real document transactions undone (first is oldest undone)
- std::list<int> myRedos;
+ std::list<Transaction> myTransactions;
+ /// list of info about transactions undone (first is oldest undone)
+ std::list<Transaction> myRedos;
/// All features managed by this document (not only in history of OB)
/// For optimization mapped by labels
NCollection_DataMap<TDF_Label, FeaturePtr> myObjs;
void Model_Session::startOperation(const std::string& theId)
{
ROOT_DOC->startOperation();
+ ROOT_DOC->operationId(theId);
static std::shared_ptr<Events_Message> aStartedMsg
(new Events_Message(Events_Loop::eventByName("StartOperation")));
Events_Loop::loop()->send(aStartedMsg);
//! Returns stack of performed operations
std::list<std::string> Model_Session::undoList()
{
- std::list<std::string> temp;
- temp.push_front("Part");
- temp.push_front("Sketch");
- temp.push_front("Extrusion");
- return temp;
+ return ROOT_DOC->undoList();
}
//! Returns stack of rolled back operations
std::list<std::string> Model_Session::redoList()
{
- std::list<std::string> temp;
- return temp;
+ return ROOT_DOC->redoList();
}
FeaturePtr Model_Session::createFeature(string theFeatureID)
ModuleBase_FilterLinearEdge.h
ModuleBase_FilterMulti.h
ModuleBase_FilterNoConsructionSubShapes.h
+ ModuleBase_FilterNoDegeneratedEdge.h
ModuleBase_FilterShapeType.h
ModuleBase_Tools.h
ModuleBase_IModule.h
ModuleBase_FilterLinearEdge.cpp
ModuleBase_FilterMulti.cpp
ModuleBase_FilterNoConsructionSubShapes.cpp
+ ModuleBase_FilterNoDegeneratedEdge.cpp
ModuleBase_FilterShapeType.cpp
ModuleBase_Tools.cpp
ModuleBase_IModule.cpp
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModuleBase_ViewerFilters.cpp
+// Created: 10 Feb 2015
+// Author: Natalia ERMOLAEVA
+
+
+#include "ModuleBase_FilterNoDegeneratedEdge.h"
+
+#include <StdSelect_BRepOwner.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+#include <BRep_Tool.hxx>
+
+IMPLEMENT_STANDARD_HANDLE(ModuleBase_FilterNoDegeneratedEdge, StdSelect_EdgeFilter);
+IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_FilterNoDegeneratedEdge, StdSelect_EdgeFilter);
+
+ModuleBase_FilterNoDegeneratedEdge::ModuleBase_FilterNoDegeneratedEdge()
+: StdSelect_EdgeFilter(StdSelect_AnyEdge)
+{
+}
+
+Standard_Boolean ModuleBase_FilterNoDegeneratedEdge::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
+{
+ bool isEdge = StdSelect_EdgeFilter::IsOk(theOwner);
+ if (isEdge) {
+ Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(theOwner);
+ if (!anOwner.IsNull() && anOwner->HasShape()) {
+ const TopoDS_Shape& aShape = anOwner->Shape();
+ if (BRep_Tool::Degenerated(TopoDS::Edge(aShape)))
+ return Standard_False;
+ }
+ }
+ return isEdge;
+}
+
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModuleBase_ViewerFilters.h
+// Created: 10 Feb 2015
+// Author: Natalia ERMOLAEVA
+
+
+#ifndef ModuleBase_FilterNoDegeneratedEdge_H
+#define ModuleBase_FilterNoDegeneratedEdge_H
+
+#include <QStringList>
+
+#include <StdSelect_EdgeFilter.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+
+/**
+* \ingroup GUI
+* \class ModuleBase_FilterNoDegeneratedEdge
+* An edge filter, which additionally filters degenerative edges.
+*/
+DEFINE_STANDARD_HANDLE(ModuleBase_FilterNoDegeneratedEdge, StdSelect_EdgeFilter);
+class ModuleBase_FilterNoDegeneratedEdge: public StdSelect_EdgeFilter
+{
+public:
+ /// Constructor
+ Standard_EXPORT ModuleBase_FilterNoDegeneratedEdge();
+
+ /**
+ * Returns true if the owner is computed from decomposition(it is global selection, not the sub-shapes)
+ * of if the selected result is a construction and the result feature is composite and has sub-elements.
+ * \param theOwner the result of selection
+ * \return whether the owner is selectable in the viewer
+ */
+ Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const;
+
+ DEFINE_STANDARD_RTTI(ModuleBase_FilterNoDegeneratedEdge)
+
+protected:
+};
+
+#endif
\ No newline at end of file
myIsValueDefault = !theData->getProperty(ATTR_DEFAULT).empty();
myIsComputedDefault = false;
myAttributeID = theData ? theData->widgetId() : "";
+
+ connect(this, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged()));
}
bool ModuleBase_ModelWidget::isInitialized(ObjectPtr theObject) const
}
}
+void ModuleBase_ModelWidget::setFeature(const FeaturePtr& theFeature, const bool theToStoreValue)
+{
+ myFeature = theFeature;
+ if (theToStoreValue)
+ storeValue();
+}
+
bool ModuleBase_ModelWidget::focusTo()
{
QList<QWidget*> aControls = getControls();
return QObject::eventFilter(theObject, theEvent);
}
+
+//**************************************************************
+void ModuleBase_ModelWidget::onWidgetValuesChanged()
+{
+ storeValue();
+}
return false;
}
- /// Saves the internal parameters to the given feature
- virtual bool storeValue() const = 0;
-
/// Restore value from attribute data to the widget's control
virtual bool restoreValue() = 0;
}
/// Set feature which is processing by active operation
- void setFeature(const FeaturePtr& theFeature)
- {
- myFeature = theFeature;
- }
+ /// \param theToStoreValue a value about necessity to store the widget value to the feature
+ void setFeature(const FeaturePtr& theFeature, const bool theToStoreValue = false);
/// Editing mode depends on mode of current operation. This value is defined by it.
void setEditingMode(bool isEditing) { myIsEditing = isEditing; }
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)
/// \param theObj is object for moving
void moveObject(ObjectPtr theObj) const;
+protected slots:
+ /// Processing of values changed in model widget by store the current value to the feature
+ void onWidgetValuesChanged();
+
protected:
/// The attribute name of the model feature
virtual ~ModuleBase_WidgetBoolValue();
- virtual bool storeValue() const;
-
virtual bool restoreValue();
virtual QList<QWidget*> getControls() const;
QWidget* getControl() const;
+protected:
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValue() const;
+
private:
/// The check box
QCheckBox* myCheckBox;
virtual ~ModuleBase_WidgetChoice();
- virtual bool storeValue() const;
-
virtual bool restoreValue();
virtual bool focusTo();
/// \return a controls list
virtual QList<QWidget*> getControls() const;
+protected:
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValue() const;
+
private slots:
/// Slot called on combo box index change
void onCurrentIndexChanged(int theIndex);
virtual ~ModuleBase_WidgetDoubleValue();
- //! Saves the internal parameters to the given feature
- // \return True in success
- virtual bool storeValue() const;
-
//! Read value of corresponded attribute from data model to the input control
// \return True in success
virtual bool restoreValue();
// it gives him a 0,5 second to finish typing, when sends valueChnaged() signal
// void onValueChanged();
- protected:
+protected:
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValue() const;
+
+protected:
/// Container for thw widget controls
QWidget* myContainer;
const std::string& theParentId);
virtual ~ModuleBase_WidgetFileSelector();
- virtual bool storeValue() const;
-
virtual bool restoreValue();
QWidget* getControl() const;
/// Processing of path changing
void onPathChanged();
+protected:
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValue() const;
+
protected:
/// Returns string containing formats
QString formatsString() const;
/// It returns false because this is an info widget
virtual bool canSetValue() const { return false; };
- virtual bool storeValue() const
- {
- return true;
- }
-
virtual bool restoreValue()
{
return true;
/// This control doesn't accept focus
virtual bool focusTo() { return false; }
+protected:
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValue() const
+ {
+ return true;
+ }
+
private:
/// A label control
QLabel* myLabel;
const std::string& theParentId);
virtual ~ModuleBase_WidgetLineEdit();
- virtual bool storeValue() const;
-
virtual bool restoreValue();
QWidget* getControl() const;
/// A slot for processing text changed event
void onTextChanged();
- private:
+protected:
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValue() const;
+
+private:
/// A line edit control
QLineEdit* myLineEdit;
#include <ModuleBase_WidgetMultiSelector.h>
#include <ModuleBase_WidgetShapeSelector.h>
+#include <ModuleBase_FilterNoDegeneratedEdge.h>
#include <ModuleBase_ISelection.h>
#include <ModuleBase_IWorkshop.h>
+#include <ModuleBase_IViewer.h>
#include <ModuleBase_Tools.h>
#include <ModelAPI_Data.h>
} else {
disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
myWorkshop->deactivateSubShapesSelection();
+
+ myWorkshop->viewer()->removeSelectionFilter(myEdgesTypeFilter);
}
}
QIntList aList;
aList.append(ModuleBase_WidgetShapeSelector::shapeType(aNewType));
myWorkshop->activateSubShapesSelection(aList);
+
+ // it is necessary to filter the selected edges to be non-degenerated
+ // it is not possible to build naming name for such edges
+ if (aNewType == "Edges") {
+ myEdgesTypeFilter = new ModuleBase_FilterNoDegeneratedEdge();
+ ModuleBase_IViewer* aViewer = myWorkshop->viewer();
+ aViewer->addSelectionFilter(myEdgesTypeFilter);
+ }
+ else {
+ myWorkshop->viewer()->removeSelectionFilter(myEdgesTypeFilter);
+ }
}
//********************************************************************
#include <ModuleBase.h>
#include <ModuleBase_ModelWidget.h>
+#include <ModuleBase_FilterNoDegeneratedEdge.h>
#include <GeomAPI_Shape.h>
#include <ModelAPI_Result.h>
const std::string& theParentId);
virtual ~ModuleBase_WidgetMultiSelector();
- /// Saves the internal parameters to the given feature
- virtual bool storeValue() const;
-
virtual bool restoreValue();
/// Returns the internal parent wiget control, that can be shown anywhere
void onListSelection();
protected:
- /// Provide filtering of selected shapes
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValue() const;
+
+ /// Provide filtering of selected shapes
/// \param theShapesToFilter source list of shapes
/// \param theResult result list of shapes
void filterShapes(const NCollection_List<TopoDS_Shape>& theShapesToFilter,
/// An action for pop-up menu in a list control
QAction* myCopyAction;
+
+ /// A filter for the Edges type, which avoid the generated edges selection
+ Handle(ModuleBase_FilterNoDegeneratedEdge) myEdgesTypeFilter;
};
#endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */
virtual ~ModuleBase_WidgetShapeSelector();
- /// Saves the internal parameters to the given feature
- virtual bool storeValue() const;
-
virtual bool restoreValue();
/// Defines if it is supposed that the widget should interact with the viewer.
void onSelectionChanged();
protected:
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValue() const;
+
/// The methiod called when widget is activated
virtual void activateCustom();
bool NewGeom_SalomeViewer::canDragByMouse() const
{
OCCViewer_Viewer* aViewer = mySelector->viewer();
- return (aViewer->interactionStyle() != 0);
+ SUIT_ViewWindow* aWnd = aViewer->getViewManager()->getActiveView();
+ OCCViewer_ViewWindow* aViewWnd = dynamic_cast<OCCViewer_ViewWindow*>(aWnd);
+ if (aViewWnd) {
+ return (aViewWnd->interactionStyle() == 0);
+ }
+ return true;
}
${CMAKE_SOURCE_DIR}/src/SketchPlugin
${CMAKE_SOURCE_DIR}/src/FeaturesPlugin
${CMAKE_SOURCE_DIR}/src/GeomAPI
+ ${CMAKE_SOURCE_DIR}/src/AppElements
${CAS_INCLUDE_DIRS}
${SUIT_INCLUDE}
)
void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation)
{
- if (theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) {
+ if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
mySketchMgr->startSketch(theOperation);
}
+ else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
+ mySketchMgr->startNestedSketch(theOperation);
+ }
+
if (myDocumentShapeFilter.IsNull())
myDocumentShapeFilter = new PartSet_GlobalFilter(myWorkshop);
myWorkshop->viewer()->addSelectionFilter(myDocumentShapeFilter);
void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation)
{
- if (theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) {
+ if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
mySketchMgr->stopSketch(theOperation);
}
+ else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
+ mySketchMgr->stopNestedSketch(theOperation);
+ }
myWorkshop->viewer()->removeSelectionFilter(myDocumentShapeFilter);
}
bool PartSet_Module::canDisplayObject(const ObjectPtr& theObject) const
{
bool aCanDisplay = false;
+ if (!mySketchMgr->canDisplayObject(theObject))
+ return aCanDisplay;
CompositeFeaturePtr aSketchFeature = mySketchMgr->activeSketch();
if (aSketchFeature.get() != NULL) {
FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
void PartSet_Module::addViewerItems(QMenu* theMenu) const
{
- if (!isSketchOperationActive() && !isSketchFeatureOperationActive())
+ if (!PartSet_SketcherMgr::isSketchOperation(myWorkshop->currentOperation()) &&
+ !isSketchFeatureOperationActive())
return;
ModuleBase_ISelection* aSelection = myWorkshop->selection();
QObjectPtrList aObjects = aSelection->selectedPresentations();
void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
{
ModuleBase_IPropertyPanel* aPanel = theOperation->propertyPanel();
- if ((theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) &&
- (theOperation->isEditOperation())) {
+ if (PartSet_SketcherMgr::isSketchOperation(theOperation) && (theOperation->isEditOperation())) {
// we have to manually activate the sketch label in edit mode
aPanel->activateWidget(aPanel->modelWidgets().first());
return;
if (theOperation->isEditOperation()) {
// TODO: #391 - to be removed
std::string aId = theOperation->id().toStdString();
- if (PartSet_SketcherMgr::sketchOperationIdList().contains(QString(aId.c_str()))) {
- if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
- (aId == SketchPlugin_ConstraintLength::ID()) ||
- (aId == SketchPlugin_ConstraintDistance::ID())) {
- // Find and activate widget for management of point for dimension line position
- QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
- foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
- PartSet_WidgetPoint2D* aPntWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
- if (aPntWgt) {
- aPanel->activateWidget(aPntWgt);
- return;
- }
+ if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation) &&
+ PartSet_SketcherMgr::isDistanceOperation(theOperation)) {
+ // Find and activate widget for management of point for dimension line position
+ QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
+ foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
+ PartSet_WidgetPoint2D* aPntWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
+ if (aPntWgt) {
+ aPanel->activateWidget(aPntWgt);
+ return;
}
- }
+ }
}
}
}
// An edit operation is enable only if the current opeation is the sketch operation
if (mySketchMgr->activeSketch()) {
if (PartSet_Tools::sketchPlane(mySketchMgr->activeSketch()))
- isSketcherOp = (aOperation->id().toStdString() == SketchPlugin_Sketch::ID());
+ isSketcherOp = PartSet_SketcherMgr::isSketchOperation(aOperation);
}
if (isSketcherOp) {
// Editing of constraints can be done on selection
return 0;
}
-bool PartSet_Module::isSketchOperationActive() const
-{
- ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
-
- bool isSketchOp = aOperation && aOperation->id().toStdString() == SketchPlugin_Sketch::ID();
- return isSketchOp;
-}
-
bool PartSet_Module::isSketchFeatureOperationActive() const
{
bool isCurrentSketchOp = false;
void PartSet_Module::deleteObjects()
{
- bool isSketchOp = isSketchOperationActive();
+ bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(myWorkshop->currentOperation());
if (!isSketchOp && !isSketchFeatureOperationActive())
return;
#include <XGUI_ModuleConnector.h>
#include <XGUI_PropertyPanel.h>
+#include <AppElements_MainWindow.h>
+
#include <ModuleBase_IViewer.h>
#include <ModuleBase_IWorkshop.h>
#include <ModuleBase_IViewWindow.h>
PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule)
- : QObject(theModule), myModule(theModule), myIsDragging(false), myDragDone(false)
+ : QObject(theModule), myModule(theModule), myIsDragging(false), myDragDone(false),
+ myIsMouseOverWindow(false), myIsPropertyPanelValueChanged(false)
{
ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
ModuleBase_IViewer* aViewer = anIWorkshop->viewer();
myPlaneFilter.Nullify();
}
+void PartSet_SketcherMgr::onMouseMoveOverWindow(bool theOverWindow)
+{
+ myIsMouseOverWindow = theOverWindow;
+ if (theOverWindow)
+ myIsPropertyPanelValueChanged = false;
+
+ updateVisibilityOfCreatedFeature();
+}
+
+void PartSet_SketcherMgr::onValuesChangedInPropertyPanel()
+{
+ myIsPropertyPanelValueChanged = true;
+
+ updateVisibilityOfCreatedFeature();
+}
+
void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
{
get2dPoint(theWnd, theEvent, myClickedPoint);
if (!PartSet_Tools::sketchPlane(myCurrentSketch))
return;
- bool isSketcher = (aOperation->id().toStdString() == SketchPlugin_Sketch::ID());
- bool isSketchOpe = sketchOperationIdList().contains(aOperation->id());
+ bool isSketcher = isSketchOperation(aOperation);
+ bool isSketchOpe = isNestedSketchOperation(aOperation);
// Avoid non-sketch operations
if ((!isSketchOpe) && (!isSketcher))
return;
ModuleBase_Operation* aOp = aWorkshop->currentOperation();
if (aOp) {
- if (sketchOperationIdList().contains(aOp->id())) {
- get2dPoint(theWnd, theEvent, myClickedPoint);
+ if (isNestedSketchOperation(aOp)) {
+ get2dPoint(theWnd, theEvent, myClickedPoint);
// Only for sketcher operations
if (myIsDragging) {
ModuleBase_Operation* aOperation = myModule->workshop()->currentOperation();
if (!aOperation)
return;
- if (aOperation->id().toStdString() == SketchPlugin_Sketch::ID())
+ if (isSketchOperation(aOperation))
return; // No edit operation activated
Handle(V3d_View) aView = theWnd->v3dView();
connect(aPropertyPanel, SIGNAL(beforeWidgetActivated(ModuleBase_ModelWidget*)),
this, SLOT(onBeforeWidgetActivated(ModuleBase_ModelWidget*)));
}
+
+ AppElements_MainWindow* aMainWindow = aWorkshop->mainWindow();
+ connect(aMainWindow, SIGNAL(mouseMoveOverWindow(bool)), this, SLOT(onMouseMoveOverWindow(bool)));
}
void PartSet_SketcherMgr::onBeforeWidgetActivated(ModuleBase_ModelWidget* theWidget)
}
}
-bool PartSet_SketcherMgr::isDistanceOperation(ModuleBase_Operation* theOperation) const
-{
- std::string aId = theOperation ? theOperation->id().toStdString() : "";
-
- return (aId == SketchPlugin_ConstraintLength::ID()) ||
- (aId == SketchPlugin_ConstraintDistance::ID()) ||
- (aId == SketchPlugin_ConstraintRadius::ID());
-}
-
void PartSet_SketcherMgr::get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent,
Point& thePoint)
{
return aIds;
}
+bool PartSet_SketcherMgr::isSketchOperation(ModuleBase_Operation* theOperation)
+{
+ return theOperation && theOperation->id().toStdString() == SketchPlugin_Sketch::ID();
+}
+
+bool PartSet_SketcherMgr::isNestedSketchOperation(ModuleBase_Operation* theOperation)
+{
+ return theOperation &&
+ PartSet_SketcherMgr::sketchOperationIdList().contains(theOperation->id());
+}
+
+bool PartSet_SketcherMgr::isDistanceOperation(ModuleBase_Operation* theOperation)
+{
+ std::string aId = theOperation ? theOperation->id().toStdString() : "";
+
+ return (aId == SketchPlugin_ConstraintLength::ID()) ||
+ (aId == SketchPlugin_ConstraintDistance::ID()) ||
+ (aId == SketchPlugin_ConstraintRadius::ID());
+}
+
void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
{
// Display all sketcher sub-Objects
aDisplayer->updateViewer();
}
+void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* )
+{
+ connectToPropertyPanel(true);
+}
+
+void PartSet_SketcherMgr::stopNestedSketch(ModuleBase_Operation* )
+{
+ connectToPropertyPanel(false);
+}
+
+bool PartSet_SketcherMgr::canDisplayObject(const ObjectPtr& theObject) const
+{
+ return myIsMouseOverWindow || myIsPropertyPanelValueChanged;
+}
void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
{
}
}
}
+
+void PartSet_SketcherMgr::connectToPropertyPanel(const bool isToConnect)
+{
+ ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(anIWorkshop);
+ XGUI_Workshop* aWorkshop = aConnector->workshop();
+ XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel();
+ if (aPropertyPanel) {
+ const QList<ModuleBase_ModelWidget*>& aWidgets = aPropertyPanel->modelWidgets();
+ foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
+ if (isToConnect)
+ connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
+ else
+ disconnect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
+ }
+ }
+}
+
+void PartSet_SketcherMgr::updateVisibilityOfCreatedFeature()
+{
+ ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
+ ModuleBase_Operation* aOperation = aWorkshop->currentOperation();
+ if (!aOperation || aOperation->isEditOperation())
+ return;
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
+ XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
+
+ FeaturePtr aFeature = aOperation->feature();
+ std::list<ResultPtr> aResults = aFeature->results();
+ std::list<ResultPtr>::const_iterator aIt;
+ for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
+ if (canDisplayObject(aFeature)) {
+ aDisplayer->display(*aIt, false);
+ }
+ else {
+ aDisplayer->erase(*aIt, false);
+ }
+ }
+ aDisplayer->updateViewer();
+}
\ No newline at end of file
virtual ~PartSet_SketcherMgr();
- /// Returns list of strings which contains id's of sketch operations
- static QStringList sketchOperationIdList();
+ /// Returns true if the operation is the sketch
+ /// \param theOperation an operation
+ /// \return the boolean result
+ static bool isSketchOperation(ModuleBase_Operation* theOperation);
+
+ /// Returns true if the operation id is in the sketch operation id list
+ /// \param theOperation an operation
+ /// \return the boolean result
+ static bool isNestedSketchOperation(ModuleBase_Operation* theOperation);
+
+ /// Returns whethe the current operation is a sketch distance - lenght, distance or radius
+ /// \param the operation
+ /// \return a boolean value
+ static bool isDistanceOperation(ModuleBase_Operation* theOperation);
/// Launches the operation from current highlighting
void launchEditing();
/// Stops sketch operation
void stopSketch(ModuleBase_Operation* );
+ /// Starts sketch operation
+ void startNestedSketch(ModuleBase_Operation* );
+
+ /// Stops sketch operation
+ void stopNestedSketch(ModuleBase_Operation* );
+
+ /// Returns whether the object can be displayed at the bounds of the active operation.
+ /// Display only current operation results for usual operation and ask the sketcher manager
+ /// if it is a sketch operation
+ /// \param theObject a model object
+ bool canDisplayObject(const ObjectPtr& theObject) const;
+
public slots:
/// Process sketch plane selected event
void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
private slots:
+ /// Process the signal about mouse moving into or out of the window
+ /// \param heOverWindow true, if the moving happens to window
+ void onMouseMoveOverWindow(bool theOverWindow);
+ void onValuesChangedInPropertyPanel();
void onMousePressed(ModuleBase_IViewWindow*, QMouseEvent*);
void onMouseReleased(ModuleBase_IViewWindow*, QMouseEvent*);
void onMouseMoved(ModuleBase_IViewWindow*, QMouseEvent*);
void onBeforeWidgetActivated(ModuleBase_ModelWidget* theWidget);
private:
- /// Returns whethe the current operation is a sketch distance - lenght, distance or radius
- /// \param the operation
- /// \return a boolean value
- bool isDistanceOperation(ModuleBase_Operation* theOperation) const;
+ /// Returns list of strings which contains id's of sketch operations
+ static QStringList sketchOperationIdList();
/// Converts mouse position to 2d coordinates.
/// Member myCurrentSketch has to be correctly defined
const FeatureToSelectionMap& theSelection,
SelectMgr_IndexedMapOfOwner& anOwnersToSelect);
+ /// Connects or disconnects to the value changed signal of the property panel widgets
+ /// \param isToConnect a boolean value whether connect or disconnect
+ void connectToPropertyPanel(const bool isToConnect);
+
+ void updateVisibilityOfCreatedFeature();
+
private:
PartSet_Module* myModule;
bool myPreviousSelectionEnabled; // the previous selection enabled state in the viewer
bool myIsDragging;
bool myDragDone;
+ bool myIsMouseOverWindow; /// the state that mouse is over view
+ bool myIsPropertyPanelValueChanged; /// the state that value in the property panel is changed
Point myCurrentPoint;
Point myClickedPoint;
return thePoint2D->to3D(aC->pnt(), aX->dir(), aY->dir());
}
-bool PartSet_Tools::isConstraintFeature(const std::string& theKind)
-{
- return theKind == SketchPlugin_ConstraintDistance::ID()
- || theKind == SketchPlugin_ConstraintLength::ID()
- || theKind == SketchPlugin_ConstraintRadius::ID()
- || theKind == SketchPlugin_ConstraintRigid::ID();
-}
-
-ResultPtr PartSet_Tools::createFixedObjectByEdge(const TopoDS_Shape& theShape,
+ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShape,
const ObjectPtr& theObject,
CompositeFeaturePtr theSketch)
{
/// \return API object of point 3D
static std::shared_ptr<GeomAPI_Pnt> point3D(std::shared_ptr<GeomAPI_Pnt2d> thePoint2D,
CompositeFeaturePtr theSketch);
- /// Check whether there is a constraint with the feature kind given
- /// \param theKind a feature kind
- /// \return the boolean value
- static bool isConstraintFeature(const std::string& theKind);
/// Creates a line (arc or circle) by given edge
/// Created line will have fixed constraint
/// \param theObject a selected result object
/// \param theSketch a sketch feature
/// \return result of created feature
- static ResultPtr createFixedObjectByEdge(const TopoDS_Shape& theShape,
- const ObjectPtr& theObject,
- CompositeFeaturePtr theSketch);
+ static ResultPtr createFixedObjectByExternal(const TopoDS_Shape& theShape,
+ const ObjectPtr& theObject,
+ CompositeFeaturePtr theSketch);
/// Checks whether the list of selected presentations contains the given one
/// \param theSelected a list of presentations
#include <GeomDataAPI_Point2D.h>
#include <GeomAPI_Pnt2d.h>
+#include <SketchPlugin_Feature.h>
+
#include <QGroupBox>
#include <QGridLayout>
#include <QLabel>
myYSpin->blockSignals(false);
this->blockSignals(isBlocked);
- emit valuesChanged();
+ storeValue();
return true;
}
void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
{
XGUI_Selection* aSelection = myWorkshop->selector()->selection();
+ Handle(V3d_View) aView = theWnd->v3dView();
// TODO: This fragment doesn't work because bug in OCC Viewer. It can be used after fixing.
- //NCollection_List<TopoDS_Shape> aShapes;
- //std::list<ObjectPtr> aObjects;
- //aSelection->selectedShapes(aShapes, aObjects);
- //if (aShapes.Extent() > 0) {
- // TopoDS_Shape aShape = aShapes.First();
- // double aX, aY;
- // if (getPoint2d(theWnd->v3dView(), aShape, aX, aY)) {
- // setPoint(aX, aY);
-
- // PartSet_Tools::setConstraints(mySketch, feature(), attributeID(),aX, aY);
- // emit vertexSelected(aObjects.front(), aShape);
- // emit focusOutWidget(this);
- // return;
- // }
- //}
+ NCollection_List<TopoDS_Shape> aShapes;
+ std::list<ObjectPtr> aObjects;
+ aSelection->selectedShapes(aShapes, aObjects);
+ // if we have selection
+ if (aShapes.Extent() > 0) {
+ TopoDS_Shape aShape = aShapes.First();
+ ObjectPtr aObject = aObjects.front();
+ FeaturePtr aSelectedFeature = ModelAPI_Feature::feature(aObject);
+ if (aSelectedFeature.get() != NULL) {
+ std::shared_ptr<SketchPlugin_Feature> aSPFeature =
+ std::dynamic_pointer_cast<SketchPlugin_Feature>(aSelectedFeature);
+ if ((!aSPFeature) && (!aShape.IsNull()))
+ PartSet_Tools::createFixedObjectByExternal(aShape, aObject, mySketch);
+ }
+ double aX, aY;
+ if (getPoint2d(aView, aShape, aX, aY)) {
+ setPoint(aX, aY);
+
+ PartSet_Tools::setConstraints(mySketch, feature(), attributeID(),aX, aY);
+ emit vertexSelected();
+ emit focusOutWidget(this);
+ return;
+ }
+ }
// End of Bug dependent fragment
// A case when point is taken from mouse event
gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWnd->v3dView());
double aX, anY;
- Handle(V3d_View) aView = theWnd->v3dView();
PartSet_Tools::convertTo2D(aPoint, mySketch, aView, aX, anY);
if (!setPoint(aX, anY))
return;
- std::shared_ptr<GeomDataAPI_Point2D> aFeaturePoint = std::dynamic_pointer_cast<
- GeomDataAPI_Point2D>(feature()->data()->attribute(attributeID()));
- QList<FeaturePtr> aIgnore;
- aIgnore.append(feature());
-
- double aTolerance = aView->Convert(7);
- std::shared_ptr<GeomDataAPI_Point2D> aAttrPnt =
- PartSet_Tools::findAttributePoint(mySketch, aX, anY, aTolerance, aIgnore);
- if (aAttrPnt.get() != NULL) {
- aFeaturePoint->setValue(aAttrPnt->pnt());
- PartSet_Tools::createConstraint(mySketch, aAttrPnt, aFeaturePoint);
- emit vertexSelected();
- }
+ /// Start alternative code
+ //std::shared_ptr<GeomDataAPI_Point2D> aFeaturePoint = std::dynamic_pointer_cast<
+ // GeomDataAPI_Point2D>(feature()->data()->attribute(attributeID()));
+ //QList<FeaturePtr> aIgnore;
+ //aIgnore.append(feature());
+
+ //double aTolerance = aView->Convert(7);
+ //std::shared_ptr<GeomDataAPI_Point2D> aAttrPnt =
+ // PartSet_Tools::findAttributePoint(mySketch, aX, anY, aTolerance, aIgnore);
+ //if (aAttrPnt.get() != NULL) {
+ // aFeaturePoint->setValue(aAttrPnt->pnt());
+ // PartSet_Tools::createConstraint(mySketch, aAttrPnt, aFeaturePoint);
+ // emit vertexSelected();
+ //}
+ /// End alternative code
emit focusOutWidget(this);
}
/// \param theValue the wrapped widget value
virtual bool setSelection(ModuleBase_ViewerPrs theValue);
- virtual bool storeValue() const;
-
virtual bool restoreValue();
/// Returns the internal parent wiget control, that can be shown anywhere
void onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
protected:
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValue() const;
+
/// The methiod called when widget is activated
virtual void activateCustom();
mySpinBox->blockSignals(true);
mySpinBox->setValue(aRadius);
mySpinBox->blockSignals(false);
- emit valuesChanged();
+ storeValue();
}
}
std::dynamic_pointer_cast<SketchPlugin_Feature>(aSelectedFeature);
if ((!aSPFeature) && (!myShape->isNull())) {
// Processing of external (non-sketch) object
- ObjectPtr aObj = PartSet_Tools::createFixedObjectByEdge(myShape->impl<TopoDS_Shape>(),
- mySelectedObject, mySketch);
+ ObjectPtr aObj = PartSet_Tools::createFixedObjectByExternal(myShape->impl<TopoDS_Shape>(),
+ mySelectedObject, mySketch);
if (aObj) {
PartSet_WidgetShapeSelector* that = (PartSet_WidgetShapeSelector*) this;
that->mySelectedObject = aObj;
std::shared_ptr<SketchPlugin_Feature> aSPFeature =
std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
if ((!aSPFeature) && (!myShape->isNull())) {
- ObjectPtr aObj = PartSet_Tools::createFixedObjectByEdge(myShape->impl<TopoDS_Shape>(),
- mySelectedObject, mySketch);
+ ObjectPtr aObj = PartSet_Tools::createFixedObjectByExternal(myShape->impl<TopoDS_Shape>(),
+ mySelectedObject, mySketch);
if (aObj) {
PartSet_WidgetConstraintShapeSelector* that = (PartSet_WidgetConstraintShapeSelector*) this;
that->mySelectedObject = aObj;
virtual ~PartSet_WidgetShapeSelector() {}
- virtual bool storeValue() const;
-
/// Set sketcher
/// \param theSketch a sketcher object
void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
CompositeFeaturePtr sketch() const { return mySketch; }
protected:
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValue() const;
+
/// Check the selected with validators if installed
virtual bool isValid(ObjectPtr theObj, std::shared_ptr<GeomAPI_Shape> theShape);
virtual ~PartSet_WidgetConstraintShapeSelector() {}
- /// Saves the internal parameters to the given feature
- virtual bool storeValue() const;
-
/// Set sketcher
/// \param theSketch a sketcher object
void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
/// Retrurns installed sketcher
CompositeFeaturePtr sketch() const { return mySketch; }
+protected:
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValue() const;
+
private:
/// Pointer to a sketch
CompositeFeaturePtr mySketch;
virtual ~PartSet_WidgetSketchLabel();
- virtual bool storeValue() const
- {
- return true;
- }
-
virtual bool restoreValue()
{
return true;
void planeSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
protected:
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValue() const
+ {
+ return true;
+ }
+
/// The methiod called when widget is activated
virtual void activateCustom();
#include <ModelAPI_AttributeRefList.h>
#include <ModelAPI_ResultConstruction.h>
+/// It is important.
+///
+/// Before writing a new method implementation in this file, please check the next rule:
+/// exported public methods must not be implemented in this source file. They should be inline and
+/// placed in the header file.
+/// Because it leads to the runtime problem on the Linux OS.
+///
+/// The reason is that this is an abstract interface. An interface of this class can be used in
+/// outside libraries through casting without a link to the current library.
+
SketchPlugin_Feature::SketchPlugin_Feature()
{
mySketch = 0;
}
-void SketchPlugin_Feature::erase()
-{
- SketchPlugin_Sketch* aSketch = sketch();
- if (aSketch)
- aSketch->removeFeature(this);
-
- ModelAPI_Feature::erase();
-}
-
SketchPlugin_Sketch* SketchPlugin_Feature::sketch()
{
if (!mySketch) {
}
/// removes also all sub-sketch elements
- SKETCHPLUGIN_EXPORT virtual void erase();
+ SKETCHPLUGIN_EXPORT virtual void erase()
+ {
+ /*SketchPlugin_Sketch* aSketch = sketch();
+ if (aSketch)
+ aSketch->removeFeature(this);
+ */
+ ModelAPI_Feature::erase();
+ }
/// Returns the sketch of this feature
SketchPlugin_Sketch* sketch();
void SketchPlugin_Sketch::removeFeature(ModelAPI_Feature* theFeature)
{
+ if (!data().get()) // sketch is already removed (case on undo of sketch), sync is not needed
+ return;
list<ObjectPtr> aSubs = data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->list();
list<ObjectPtr>::iterator aSubIt = aSubs.begin(), aLastIt = aSubs.end();
bool isRemoved = false;
// if the object is not found in the sketch sub-elements, that means that the object is removed already.
// Find the first empty element and remove it
if (!isRemoved && aHasEmtpyFeature)
- data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->remove(NULL);
+ data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->remove(ObjectPtr());
}
int SketchPlugin_Sketch::numberOfSubs() const
return std::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(anOrigin->pnt(), aNorm->dir()));
}
-//void addPlane(double theX, double theY, double theZ,
-// std::list<std::shared_ptr<GeomAPI_Shape> >& theShapes)
-//{
-// std::shared_ptr<GeomAPI_Pnt> anOrigin(new GeomAPI_Pnt(0, 0, 0));
-// std::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(theX, theY, theZ));
-// double aSize = Config_PropManager::integer("Sketch planes", "Size of planes", PLANE_SIZE);
-// std::shared_ptr<GeomAPI_Shape> aFace = GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal,
-// aSize);
-// theShapes.push_back(aFace);
-//}
-
-//AISObjectPtr SketchPlugin_Sketch::getAISObject(AISObjectPtr thePrevious)
-//{
-// std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-// data()->attribute(SketchPlugin_Sketch::NORM_ID()));
-//
-// if (!aNorm || (aNorm->x() == 0 && aNorm->y() == 0 && aNorm->z() == 0)) {
-// AISObjectPtr aAIS = thePrevious;
-// if (!aAIS) {
-// std::list<std::shared_ptr<GeomAPI_Shape> > aFaces;
-//
-// addPlane(1, 0, 0, aFaces); // YZ plane
-// addPlane(0, 1, 0, aFaces); // XZ plane
-// addPlane(0, 0, 1, aFaces); // XY plane
-// std::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces);
-// aAIS = AISObjectPtr(new GeomAPI_AISObject());
-// aAIS->createShape(aCompound);
-//
-// std::vector<int> aRGB = Config_PropManager::color("Sketch planes", "planes_color",
-// SKETCH_PLANE_COLOR);
-// aAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
-//
-// aAIS->setWidth(Config_PropManager::integer("Sketch planes", "planes_thickness",
-// SKETCH_WIDTH));
-// }
-// return aAIS;
-// }
-// return AISObjectPtr();
-//}
-
void SketchPlugin_Sketch::erase()
{
std::shared_ptr<ModelAPI_AttributeRefList> aRefList = std::dynamic_pointer_cast<
QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
- aWidget->setFeature(theOperation->feature());
+ bool isStoreValue = !theOperation->isEditOperation() &&
+ aWidget->isValueDefault() && !aWidget->isComputedDefault();
+ aWidget->setFeature(theOperation->feature(), isStoreValue);
aWidget->enableFocusProcessing();
- QObject::connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged()));
- // Init default values
- if (!theOperation->isEditOperation() && aWidget->isValueDefault() && !aWidget->isComputedDefault()) {
- aWidget->storeValue();
- }
}
myPropertyPanel->setModelWidgets(aWidgets);
}
}
-//**************************************************************
-void XGUI_Workshop::onWidgetValuesChanged()
-{
- ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
- FeaturePtr aFeature = anOperation->feature();
-
- ModuleBase_ModelWidget* aSenderWidget = dynamic_cast<ModuleBase_ModelWidget*>(sender());
-
- const QList<ModuleBase_ModelWidget*>& aWidgets = myPropertyPanel->modelWidgets();
- QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
- for (; anIt != aLast; anIt++) {
- ModuleBase_ModelWidget* aCustom = *anIt;
- if (aCustom && (aCustom == aSenderWidget)) {
- aCustom->storeValue();
- }
- }
-}
-
//**************************************************************
void XGUI_Workshop::activatePart(ResultPartPtr theFeature)
{
/// \param isChecked a state of toggle if the action is checkable
void onContextMenuCommand(const QString& theId, bool isChecked);
- /// Processing of values changed in model widget
- void onWidgetValuesChanged();
-
/// Set waiting cursor
void onStartWaiting();