Salome HOME
Fix the SHAPER version of resources
[modules/shaper.git] / src / SketcherPrs / SketcherPrs_Transformation.cpp
index 8639c3bb0351258ba7f42c3dc5c2f0ee858ed567..e4a4899ffef79ba0ba1ca34292bd270ac2d32994 100644 (file)
@@ -35,14 +35,49 @@ SketcherPrs_Transformation::SketcherPrs_Transformation(ModelAPI_Feature* theCons
 {
 }  
 
-bool SketcherPrs_Transformation::updatePoints(double theStep) const 
+bool SketcherPrs_Transformation::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
+                                                  const std::shared_ptr<GeomAPI_Ax3>&/* thePlane*/)
 {
-  std::shared_ptr<ModelAPI_Data> aData = myConstraint->data();
+  bool aReadyToDisplay = false;
+
+  std::shared_ptr<ModelAPI_Data> aData = theConstraint->data();
   // Get transformated objects list
   std::shared_ptr<ModelAPI_AttributeRefList> anAttrB = aData->reflist(SketchPlugin_Constraint::ENTITY_B());
   if (anAttrB.get() == NULL)
+    return aReadyToDisplay;
+
+  int aNbB = anAttrB->size();
+  aReadyToDisplay = aNbB > 0;
+
+#ifdef DEBUG_HIDE_COPY_ATTRIBUTE
+  // additional check
+  if (theConstraint->getKind() == SketchPlugin_MultiTranslation::ID()) {
+    // If it is translation
+    AttributePoint2DPtr aStart = GeomDataAPI_Point2D::getPoint2D(aData,
+                                            SketchPlugin_MultiTranslation::START_POINT_ID());
+    AttributePoint2DPtr aEnd = GeomDataAPI_Point2D::getPoint2D(aData,
+                                            SketchPlugin_MultiTranslation::END_POINT_ID());
+
+    aReadyToDisplay = aStart.get() && aEnd.get() && aStart->isInitialized() && aEnd->isInitialized();
+  }
+  else if (theConstraint->getKind() == SketchPlugin_MultiRotation::ID()) {
+    // if it is rotation
+    AttributePoint2DPtr aCenter = GeomDataAPI_Point2D::getPoint2D(aData, SketchPlugin_MultiRotation::CENTER_ID());
+    aReadyToDisplay = aCenter.get() && aCenter->isInitialized();
+  }
+#endif
+  return aReadyToDisplay;
+}
+
+bool SketcherPrs_Transformation::updateIfReadyToDisplay(double theStep) const 
+{
+  if (!IsReadyToDisplay(myConstraint, myPlane))
     return false;
 
+  std::shared_ptr<ModelAPI_Data> aData = myConstraint->data();
+  // Get transformated objects list
+  std::shared_ptr<ModelAPI_AttributeRefList> anAttrB = aData->reflist(SketchPlugin_Constraint::ENTITY_B());
+
   int aNbB = anAttrB->size();
   if (aNbB == 0)
   {
@@ -50,7 +85,6 @@ bool SketcherPrs_Transformation::updatePoints(double theStep) const
   //if (!myPntArray.IsNull())
     //  mySPoints.Clear();
 #endif
-    return false;
   }
 
   SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
@@ -62,6 +96,8 @@ bool SketcherPrs_Transformation::updatePoints(double theStep) const
   // Compute points of symbols
   for (i = 0; i < aNbB; i++) {
     aObj = anAttrB->object(i);
+    if (SketcherPrs_Tools::getShape(aObj).get() == NULL)
+      continue;
     aP1 = aMgr->getPosition(aObj, this, theStep);
     myPntArray->SetVertice(i + 1, aP1);
   }