Salome HOME
Fix for the issue #2753 : error when dump/load script
[modules/shaper.git] / src / ModelAPI / ModelAPI_Result.cpp
index cefbd7af8310d7d2119ced6737c347304fc2e5e3..588d138bf17cb447927b3273fed0f6fdfbeb1988 100644 (file)
@@ -1,24 +1,51 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:        ModelAPI_Result.cpp
-// Created:     07 Jul 2014
-// Author:      Mikhail PONIKAROV
+// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
 
 #include "ModelAPI_Result.h"
 #include <ModelAPI_Events.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Attribute.h>
+#include <ModelAPI_AttributeIntArray.h>
+#include <ModelAPI_AttributeDouble.h>
+
 #include <Events_Loop.h>
 
 ModelAPI_Result::~ModelAPI_Result()
 {
 }
 
+void ModelAPI_Result::initAttributes()
+{
+  // append the color attribute. It is empty, the attribute will be filled by a request
+  DataPtr aData = data();
+  aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::typeId());
+  aData->addAttribute(DEFLECTION_ID(), ModelAPI_AttributeDouble::typeId());
+  aData->addAttribute(TRANSPARENCY_ID(), ModelAPI_AttributeDouble::typeId());
+}
+
 bool ModelAPI_Result::setDisabled(std::shared_ptr<ModelAPI_Result> theThis, const bool theFlag)
 {
   if (myIsDisabled != theFlag) {
     myIsDisabled = theFlag;
-    data()->setIsDeleted(theFlag); // store it in data model (t oget back on undo/redo, etc)
+    if (data()->isValid())
+      data()->setIsDeleted(theFlag); // store it in data model (to get back on undo/redo, etc)
     // this must be before "updated" message send to have history updated for OB update
     document()->updateHistory(groupName()); // to update the history cash data in the document
     // generate related events