]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Make the concealed bodies also concealed on open
authormpv <mikhail.ponikarov@opencascade.com>
Thu, 6 Nov 2014 15:50:26 +0000 (18:50 +0300)
committermpv <mikhail.ponikarov@opencascade.com>
Thu, 6 Nov 2014 15:50:26 +0000 (18:50 +0300)
src/Config/Config_FeatureReader.cpp
src/Model/Model_Session.cpp
src/Model/Model_Validator.cpp

index 91e59df393658825a7fe3e4bf852d71c3adc13ef..947fdb8ab9cf1e1711c010f5232712c533378210 100644 (file)
@@ -62,10 +62,13 @@ void Config_FeatureReader::processNode(xmlNodePtr theNode)
   } else if (myIsProcessWidgets && isWidgetNode(theNode)) {
     boost::shared_ptr<Config_AttributeMessage> aMessage(new Config_AttributeMessage(aMenuItemEvent, this));
     aMessage->setFeatureId(restoreAttribute(NODE_FEATURE, _ID));
-    aMessage->setAttributeId(getProperty(theNode, _ID));
-    aMessage->setObligatory(getBooleanAttribute(theNode, ATTRIBUTE_OBLIGATORY, true));
-    aMessage->setConcealment(getBooleanAttribute(theNode, ATTRIBUTE_CONCEALMENT, false));
-    Events_Loop::loop()->send(aMessage);
+    std::string anAttributeID = getProperty(theNode, _ID);
+    if (!anAttributeID.empty()) {
+      aMessage->setAttributeId(anAttributeID);
+      aMessage->setObligatory(getBooleanAttribute(theNode, ATTRIBUTE_OBLIGATORY, true));
+      aMessage->setConcealment(getBooleanAttribute(theNode, ATTRIBUTE_CONCEALMENT, false));
+      Events_Loop::loop()->send(aMessage);
+    }
   }
   //Process SOURCE, VALIDATOR nodes.
   Config_XMLReader::processNode(theNode);
index e3d811d0b0b03ca3814281e20be18de9ea8e5cf8..23e7a2621633170b0ecf97ec6034c8a62dfc54a1 100644 (file)
@@ -13,6 +13,7 @@
 #include <Events_Loop.h>
 #include <Events_Error.h>
 #include <Config_FeatureMessage.h>
+#include <Config_AttributeMessage.h>
 #include <Config_ValidatorMessage.h>
 #include <Config_ModuleReader.h>
 
@@ -94,7 +95,6 @@ FeaturePtr Model_Session::createFeature(string theFeatureID)
   if (this != myImpl)
     return myImpl->createFeature(theFeatureID);
 
-  LoadPluginsInfo();
   if (myPlugins.find(theFeatureID) != myPlugins.end()) {
     std::pair<std::string, std::string>& aPlugin = myPlugins[theFeatureID]; // plugin and doc kind
     if (!aPlugin.second.empty() && aPlugin.second != activeDocument()->kind()) {
@@ -211,6 +211,9 @@ Model_Session::Model_Session()
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED), 0, true);
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED), 0, true);
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_VALIDATOR_LOADED));
+  
+  // load all information about plugins, features and attributes
+  LoadPluginsInfo();
 }
 
 void Model_Session::processEvent(const boost::shared_ptr<Events_Message>& theMessage)
@@ -226,6 +229,18 @@ void Model_Session::processEvent(const boost::shared_ptr<Events_Message>& theMes
         myPlugins[aMsg->id()] = std::pair<std::string, std::string>(
           aMsg->pluginLibrary(), aMsg->documentKind());
       }
+    } else {
+      const boost::shared_ptr<Config_AttributeMessage> aMsgAttr = 
+        boost::dynamic_pointer_cast<Config_AttributeMessage>(theMessage);
+      if (aMsgAttr) {
+        if (!aMsgAttr->isObligatory()) {
+          validators()->registerNotObligatory(aMsgAttr->featureId(), aMsgAttr->attributeId());
+        }
+        if(aMsgAttr->isConcealment()) {
+          validators()->registerConcealment(aMsgAttr->featureId(), aMsgAttr->attributeId());
+        }
+        
+      }
     }
     // plugins information was started to load, so, it will be loaded
     myPluginsInfoLoaded = true;
index eecd08b33013590344a004f9e794fc7a7031ac4a..9db3a3cba7593cc8f9629c51c2c3fbb31d1d1b0b 100644 (file)
@@ -176,7 +176,7 @@ bool Model_ValidatorsFactory::validate(const boost::shared_ptr<ModelAPI_Feature>
   }
   // check all attributes for validity
   boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
-  if (!aData->isValid())
+  if (!aData || !aData->isValid())
     return false;
   static const std::string kAllTypes = "";
   std::map<std::string, std::map<std::string, AttrValidators> >::const_iterator aFeatureIter =