Salome HOME
Correct case when the weak-named attribute is dumped in Geom mode: geometrical repres...
[modules/shaper.git] / src / GeomAPI / GeomAPI_AISObject.cpp
index 8a3852baaf49ccff4263c87bdf511a44d6f71c16..c323a7835704631979c04f3dd8fefb1755444a3a 100644 (file)
@@ -1,8 +1,22 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:        GeomAPI_AISObject.cpp
-// Created:     25 Jun 2014
-// Author:      Artem ZHIDKOV
+// 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 <GeomAPI_AISObject.h>
 
@@ -374,7 +388,8 @@ void GeomAPI_AISObject::getColor(int& theR, int& theG, int& theB)
   if (anAIS.IsNull())
     return;
 
-  Quantity_Color aColor = anAIS->Color();
+  Quantity_Color aColor;
+  anAIS->Color(aColor);
   theR = (int)(aColor.Red()*255.);
   theG = (int)(aColor.Green()*255.);
   theB = (int)(aColor.Blue()*255.);
@@ -414,6 +429,39 @@ double GeomAPI_AISObject::getDeflection() const
   return aDeflection;
 }
 
+bool GeomAPI_AISObject::setTransparency(const double theTransparency)
+{
+  bool isModified = false;
+  Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
+  if (!anAIS.IsNull()) {
+    Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast(anAIS);
+    if (!anAISShape.IsNull()) {
+      Standard_Real aPreviousValue = anAISShape->Transparency();
+      if (fabs(aPreviousValue - theTransparency) > Precision::Confusion()) {
+        anAISShape->SetTransparency(theTransparency);
+        //>SetOwnDeviationCoefficient(theTransparency);
+        isModified = true;
+        // redisplay is necessary here to update presentation in all modes
+        // Standard True flag. Displayer uses Standard False flag. If it will be changed in
+        // displayer, redisplay here will not be necessary. But performance should be checked.
+        anAISShape->Redisplay(Standard_True);
+      }
+    }
+  }
+  return isModified;
+}
+
+double GeomAPI_AISObject::getTransparency() const
+{
+  double aTransparency = 0;
+
+  Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
+  if (!anAIS.IsNull()) {
+    aTransparency = anAIS->Transparency();
+  }
+  return aTransparency;
+}
+
 
 bool GeomAPI_AISObject::empty() const
 {