0031456: Visualization - move out Dimensions and Relations from package AIS to PrsDims
[occt.git] / src / TPrsStd / TPrsStd_ConstraintDriver.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 92eeff3..60172ef
@@ -1,15 +1,31 @@
-#include <TPrsStd_ConstraintDriver.ixx>
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
 
-#include <TDF_Label.hxx>
-#include <TDataXtd_Constraint.hxx>
-#include <TPrsStd_ConstraintTools.hxx>
-#include <Standard_ProgramError.hxx>
+
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_InteractiveObject.hxx>
+#include <PrsDim_Relation.hxx>
 #include <Standard_GUID.hxx>
+#include <Standard_ProgramError.hxx>
+#include <Standard_Type.hxx>
 #include <TDataStd_Real.hxx>
+#include <TDataXtd_Constraint.hxx>
 #include <TDataXtd_Position.hxx>
-#include <AIS_Drawer.hxx>
-#include <AIS_InteractiveContext.hxx>
-#include <AIS_Relation.hxx>
+#include <TDF_Label.hxx>
+#include <TPrsStd_ConstraintDriver.hxx>
+#include <TPrsStd_ConstraintTools.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(TPrsStd_ConstraintDriver,TPrsStd_Driver)
 
 //=======================================================================
 //function :
@@ -34,7 +50,12 @@ Standard_Boolean TPrsStd_ConstraintDriver::Update (const TDF_Label& aLabel,
   if (!anAISObject.IsNull() && anAISObject->HasInteractiveContext()) {
     if (!apConstraint->Verified()) {
       TPrsStd_ConstraintTools::UpdateOnlyValue(apConstraint,anAISObject);
-      if (anAISObject->Color() != Quantity_NOC_RED) anAISObject->SetColor(Quantity_NOC_RED);
+      Quantity_Color aColor;
+      anAISObject->Color (aColor);
+      if (aColor.Name() != Quantity_NOC_RED)
+      {
+        anAISObject->SetColor(Quantity_NOC_RED);
+      }
       return Standard_True;
     }
   }
@@ -152,7 +173,7 @@ Standard_Boolean TPrsStd_ConstraintDriver::Update (const TDF_Label& aLabel,
   }
   if (anAIS.IsNull()) return Standard_False;
  
-  anAIS->ResetLocation();
+  anAIS->ResetTransformation();
   anAIS->SetToUpdate();
   anAIS->UpdateSelection();
   
@@ -160,20 +181,21 @@ Standard_Boolean TPrsStd_ConstraintDriver::Update (const TDF_Label& aLabel,
   
   Handle(TDataXtd_Position) Position;
   if (aLabel.FindAttribute(TDataXtd_Position::GetID(),Position)) {
-    Handle(AIS_Relation)::DownCast(anAISObject)->SetPosition(Position->GetPosition());
+    Handle(PrsDim_Relation)::DownCast(anAISObject)->SetPosition(Position->GetPosition());
   }
 
   if (anAISObject->HasInteractiveContext()) {
-    Quantity_NameOfColor originColor = anAISObject->Color();
+    Quantity_Color originColor;
+    anAISObject->Color (originColor);
     if (!apConstraint->Verified()) {
-      if (originColor != Quantity_NOC_RED)
+      if (originColor.Name() != Quantity_NOC_RED)
        anAISObject->SetColor(Quantity_NOC_RED);
     }
     else if (apConstraint->IsDimension() && apConstraint->GetValue()->IsCaptured()) {
-      if (originColor != Quantity_NOC_PURPLE)
+      if (originColor.Name() != Quantity_NOC_PURPLE)
        anAISObject->SetColor(Quantity_NOC_PURPLE);
     }
-    else if (!apConstraint->IsPlanar() && (originColor != Quantity_NOC_YELLOW)) 
+    else if (!apConstraint->IsPlanar() && (originColor.Name() != Quantity_NOC_YELLOW))
       anAISObject->SetColor(Quantity_NOC_YELLOW);
   }
   else {