]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Make Data not null, but invalid after the feature remove
authormpv <mpv@opencascade.com>
Tue, 26 May 2015 07:33:49 +0000 (10:33 +0300)
committermpv <mpv@opencascade.com>
Tue, 26 May 2015 07:33:49 +0000 (10:33 +0300)
12 files changed:
src/Model/Model_AttributeReference.cpp
src/Model/Model_FeatureValidator.cpp
src/Model/Model_Update.cpp
src/ModelAPI/ModelAPI_Object.cpp
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_Tools.cpp
src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_Validators.cpp
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchSolver/SketchSolver_ConstraintManager.cpp
src/XGUI/XGUI_Workshop.cpp

index a6ac5e31acfff3927684c76b6d2b792bbaee3723..700e2f7d3d387f3e1d902d34a7de0e02692f14a8 100644 (file)
@@ -28,7 +28,7 @@ void Model_AttributeReference::setValue(ObjectPtr theObject)
     REMOVE_BACK_REF(aValue);
 
     TDF_Label anObjLab;
-    if (theObject.get() && theObject->data().get() && theObject->data()->isValid()) {
+    if (theObject.get() && theObject->data()->isValid()) {
       std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(
         theObject->data());
       anObjLab = aData->label().Father(); // object label
index a809abe461a5d1653edcd6a4e8e5b3af2c817858..8cec7f4b7849ef1cf6edccede77472c3a3b9c03a 100644 (file)
@@ -23,7 +23,7 @@ bool Model_FeatureValidator::isValid(const std::shared_ptr<ModelAPI_Feature>& th
 
   std::shared_ptr<ModelAPI_Data> aData = theFeature->data();
   // "Action" features has no data, but still valid. e.g "Remove Part"  
-  if (!aData) {
+  if (!aData->isValid()) {
     return theFeature->isAction();
   }
   if (!aData->isValid())
index 6a2d435ff2ebad9f7e9da7e0d3888c16b4be39b2..17f344c28ec1efebaaf735712eb95aee27871092 100644 (file)
@@ -145,7 +145,7 @@ void Model_Update::processOperation(const bool theTotalUpdate, const bool theFin
     for(aFIter = myJustCreated.begin(); aFIter != myJustCreated.end(); aFIter++)
     {
       FeaturePtr aF = std::dynamic_pointer_cast<ModelAPI_Feature>(*aFIter);
-      if (aF && aF->data().get() && aF->getKind() == "Extrusion") {
+      if (aF && aF->data()->isValid() && aF->getKind() == "Extrusion") {
         AttributeSelectionListPtr aBase = aF->selectionList("base");
         if (aBase.get()) {
           for(int a = aBase->size() - 1; a >= 0; a--) {
index bb3339f932430191a5dc7ccd3e8f6e955c1653b9..dc76a0792dd2d925653ae077e039dc740bce4ec9 100644 (file)
@@ -12,7 +12,7 @@
 
 bool ModelAPI_Object::isInHistory()
 {
-  if (myData.get() && myData->isValid()) {
+  if (myData->isValid()) {
     return myData->isInHistory();
   }
   return true; // default value
@@ -22,7 +22,7 @@ void ModelAPI_Object::setInHistory(
   const std::shared_ptr<ModelAPI_Object> theObject, const bool theFlag)
 {
   if (isInHistory() != theFlag) {
-    if (myData.get() && myData->isValid()) {
+    if (myData->isValid()) {
       myData->setIsInHistory(theFlag);
     }
     myDoc->updateHistory(theObject);
@@ -68,7 +68,7 @@ void ModelAPI_Object::setDoc(std::shared_ptr<ModelAPI_Document> theDoc)
 
 void ModelAPI_Object::erase()
 {
-  if (myData.get() && myData != myData->invalidPtr()) myData->erase();
+  if (myData->isValid() && myData != myData->invalidPtr()) myData->erase();
   setData(myData->invalidPtr());
 }
 
index d688e90aab52c4f9500caac0ad8b8e532fc79123..8b5ed2d24abe05e4280ec276f4b45810756e8088 100644 (file)
@@ -64,7 +64,7 @@ FeaturePtr ModuleBase_Operation::feature() const
 
 bool ModuleBase_Operation::isValid() const
 {
-  if (!myFeature || !myFeature->data().get())
+  if (!myFeature || !myFeature->data()->isValid())
     return true; // rename operation
   if (myFeature->isAction())
     return true;
index 745497c8abd58c1650826c19e4faab3a8b3efa8c..449dd2d3fe8562ec91477c68e8d907c67f66da17 100644 (file)
@@ -150,7 +150,7 @@ QString objectInfo(const ObjectPtr& theObj, const bool isUseAttributesInfo)
 
   if (aFeature.get()) {
     aFeatureStr.append(QString(": %1").arg(aFeature->getKind().c_str()).toStdString().c_str());
-    if (aFeature->data().get() && aFeature->data()->isValid()) {
+    if (aFeature->data()->isValid()) {
       aFeatureStr.append(QString(", name=%1").arg(aFeature->data()->name().c_str()).toStdString()
                                                                                        .c_str());
     }
index 62e152f620af1c039655b151707d2b3a2ee32579..1441e29579bc62ba5ff71b0b2c2388084366d04f 100644 (file)
@@ -251,7 +251,7 @@ GeomShapePtr ModuleBase_WidgetShapeSelector::getShape() const
 {
   GeomShapePtr aShape;
   DataPtr aData = myFeature->data();
-  if (aData.get() == NULL)
+  if (!aData->isValid())
     return aShape;
 
   AttributeSelectionPtr aSelect = aData->selection(attributeID());
@@ -265,7 +265,7 @@ GeomShapePtr ModuleBase_WidgetShapeSelector::getShape() const
 void ModuleBase_WidgetShapeSelector::updateSelectionName()
 {
   DataPtr aData = myFeature->data();
-  if (aData.get() == NULL)
+  if (!aData->isValid())
     return;
 
   bool isNameUpdated = false;
index 9394b1a6bb190628bbdd67204583f90df7a3f207..339e26101f43a050af6138bc4f8bb3f48a76767d 100644 (file)
@@ -460,7 +460,7 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
             continue;
           std::string aAttrId = anAttr->id();
           DataPtr aData = aFeature->data();
-          if (aData.get() != NULL) {
+          if (aData->isValid()) {
             std::shared_ptr<GeomDataAPI_Point2D> aPoint = 
               std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(aAttrId));
             if (aPoint.get() != NULL) {
@@ -723,7 +723,7 @@ void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation)
   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
 
   DataPtr aData = myCurrentSketch->data();
-  if ((!aData) || (!aData->isValid())) {
+  if (!aData->isValid()) {
     XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
     // The sketch was aborted
     myCurrentSketch = CompositeFeaturePtr();
@@ -734,7 +734,7 @@ void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation)
     QObjectPtrList aObjects = aDisplayer->displayedObjects();
     foreach (ObjectPtr aObj, aObjects) {
       DataPtr aObjData = aObj->data();
-      if ((!aObjData) || (!aObjData->isValid()))
+      if (!aObjData->isValid())
         aObj->setDisplayed(false);
     }
     return; 
index 55f0157b003a2ff8e9f36cdc1ec364f706b1d98f..e31b1b2b50257a04d870bc72860e4fac5953b839 100644 (file)
@@ -264,7 +264,7 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute
 bool PartSet_DifferentObjectsValidator::featureHasReferences(const AttributePtr& theAttribute) const
 {
   std::list<std::pair<std::string, std::list<ObjectPtr> > > allRefs;
-  if (theAttribute->owner().get() && theAttribute->owner()->data().get())
+  if (theAttribute->owner().get() && theAttribute->owner()->data()->isValid())
     theAttribute->owner()->data()->referencesToObjects(allRefs);
   // collect object referenced by theAttribute
   std::list<ObjectPtr>* anAttrObjs = 0;
index 2d02f0dd10f3a64e2900c035b30f96cb48e06cb9..7b7fb78d0e1608a9afbbf4ab8c677feccadb3508 100644 (file)
@@ -137,7 +137,7 @@ std::shared_ptr<ModelAPI_Feature> SketchPlugin_Sketch::addFeature(std::string th
 
 void SketchPlugin_Sketch::removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature)
 {
-  if (!data().get()) // sketch is already removed (case on undo of sketch), sync is not needed
+  if (!data()->isValid()) // 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();
index 8e2aa58b67ccc529e56207188e713c0939a4c254..ef725b5633fe6ddc5eb464c7313c3b84b018b737 100644 (file)
@@ -341,7 +341,7 @@ std::shared_ptr<ModelAPI_CompositeFeature> SketchSolver_ConstraintManager
       continue;
 
     DataPtr aData = aWP->data();
-    if (aData) {
+    if (aData->isValid()) {
       std::shared_ptr<ModelAPI_AttributeRefList> aWPFeatures = std::dynamic_pointer_cast<
           ModelAPI_AttributeRefList>(aData->attribute(SketchPlugin_Sketch::FEATURES_ID()));
       std::list<ObjectPtr> aFeaturesList = aWPFeatures->list();
index dcf348ff61b4b7bf4349e4d8c397fa9c32b5fc95..b7f68ebaab0e4f82b918caf0234a44c98e0d32c9 100644 (file)
@@ -1267,7 +1267,7 @@ void XGUI_Workshop::deleteObjects()
   aDescription += tr(" %1");
   QStringList aObjectNames;
   foreach (ObjectPtr aObj, anObjects) {
-    if (!aObj->data().get())
+    if (!aObj->data()->isValid())
       continue;
     aObjectNames << QString::fromStdString(aObj->data()->name());
   }