Salome HOME
Documentation of the sources
authorvsv <vitaly.smetannikov@opencascade.com>
Mon, 19 Oct 2015 16:37:59 +0000 (19:37 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Mon, 19 Oct 2015 16:38:12 +0000 (19:38 +0300)
16 files changed:
src/SketcherPrs/SketcherPrs_Coincident.cpp
src/SketcherPrs/SketcherPrs_Equal.cpp
src/SketcherPrs/SketcherPrs_Factory.cpp
src/SketcherPrs/SketcherPrs_HVDirection.cpp
src/SketcherPrs/SketcherPrs_LengthDimension.cpp
src/SketcherPrs/SketcherPrs_Mirror.cpp
src/SketcherPrs/SketcherPrs_Parallel.cpp
src/SketcherPrs/SketcherPrs_Perpendicular.cpp
src/SketcherPrs/SketcherPrs_PositionMgr.cpp
src/SketcherPrs/SketcherPrs_Radius.cpp
src/SketcherPrs/SketcherPrs_Rigid.cpp
src/SketcherPrs/SketcherPrs_SymbolPrs.cpp
src/SketcherPrs/SketcherPrs_Tangent.cpp
src/SketcherPrs/SketcherPrs_Tools.cpp
src/SketcherPrs/SketcherPrs_Tools.h
src/SketcherPrs/SketcherPrs_Transformation.cpp

index 8b533fdba3e19c95d8d53d6d34f23a697806c2f1..f9e2e2959123b8d00fd9ce62356ada24721d7892 100644 (file)
@@ -43,6 +43,7 @@ void SketcherPrs_Coincident::Compute(const Handle(PrsMgr_PresentationManager3d)&
                                    const Handle(Prs3d_Presentation)& thePresentation, 
                                    const Standard_Integer theMode)
 {
+  // Get point of the presentation
   std::shared_ptr<GeomAPI_Pnt2d> aPnt = SketcherPrs_Tools::getPoint(myConstraint, 
                                                                     SketchPlugin_Constraint::ENTITY_A());
   if (aPnt.get() == NULL)
@@ -57,6 +58,9 @@ void SketcherPrs_Coincident::Compute(const Handle(PrsMgr_PresentationManager3d)&
   if (aPtA.IsNull()) {
     aPtA = new Graphic3d_AspectMarker3d ();
   }
+  // Create the presentation as a combination of standard point markers
+
+  // The external yellow contour
   aPtA->SetType(Aspect_TOM_RING3);
   aPtA->SetScale(2.);
   aPtA->SetColor(Quantity_NOC_YELLOW);
@@ -67,12 +71,14 @@ void SketcherPrs_Coincident::Compute(const Handle(PrsMgr_PresentationManager3d)&
   aPntArray->AddVertex (aPoint->x(), aPoint->y(), aPoint->z());
   aGroup->AddPrimitiveArray (aPntArray);
 
+  // Make a black mid ring
   aPtA->SetType(Aspect_TOM_RING1);
   aPtA->SetScale(1.);
   aPtA->SetColor(Quantity_NOC_BLACK);
   aGroup->SetPrimitivesAspect(aPtA);
   aGroup->AddPrimitiveArray (aPntArray);
 
+  // Make an internal ring
   aPtA->SetType(Aspect_TOM_POINT);
   aPtA->SetScale(5.);
   aGroup->SetPrimitivesAspect(aPtA);
@@ -83,11 +89,7 @@ void SketcherPrs_Coincident::Compute(const Handle(PrsMgr_PresentationManager3d)&
 void SketcherPrs_Coincident::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
                                             const Standard_Integer aMode)
 {
-//  if ((aMode == 0) || (aMode == SketcherPrs_Tools::Sel_Constraint)) {
-//    Handle(SelectMgr_EntityOwner) aOwn = new SelectMgr_EntityOwner(this, 10);
-//    Handle(Select3D_SensitivePoint) aSp = new Select3D_SensitivePoint(aOwn, myPoint);
-//    aSelection->Add(aSp);
-//  }
+  // There is no selection of coincident - a point is selected instead of coincidence
 }
 
 void SketcherPrs_Coincident::SetColor(const Quantity_NameOfColor aCol)
index 90f705fd8512e2c9692145ef1d20c0a7e1c36e1d..9cfd69b595de843b8e1ff87db92f72ad0c6c8590 100644 (file)
@@ -37,6 +37,7 @@ bool SketcherPrs_Equal::updatePoints(double theStep) const
   if (SketcherPrs_Tools::getShape(aObj2).get() == NULL)
     return false;
 
+  // Set points of the presentation
   SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
   gp_Pnt aP1 = aMgr->getPosition(aObj1, this, theStep);
   gp_Pnt aP2 = aMgr->getPosition(aObj2, this, theStep);
@@ -52,12 +53,14 @@ void SketcherPrs_Equal::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quan
   Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
   aGroup->SetPrimitivesAspect(aLineAspect);
 
+  // Draw first line
   ObjectPtr aObj = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
   std::shared_ptr<GeomAPI_Shape> aLine = SketcherPrs_Tools::getShape(aObj);
   if (aLine.get() == NULL)
     return;
   drawShape(aLine, thePrs);
 
+  // Draw second line
   aObj = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_B());
   aLine = SketcherPrs_Tools::getShape(aObj);
   if (aLine.get() == NULL)
index 6971d7826829866ea5ff955b1bc14ee27da02a15..24914e915e31e80f8d157a7cffdec4f913af5f72 100644 (file)
@@ -19,6 +19,7 @@
 #include "SketcherPrs_Transformation.h"
 #include "SketcherPrs_Angle.h"
 
+// Macros for constraint presentation definition
 #define CONSTRAINT_PRS_IMPL(NAME, CLASS) \
 AISObjectPtr SketcherPrs_Factory::NAME(ModelAPI_Feature* theConstraint, \
                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane) \
@@ -40,7 +41,7 @@ CONSTRAINT_PRS_IMPL(lengthDimensionConstraint, SketcherPrs_LengthDimension);
 CONSTRAINT_PRS_IMPL(mirrorConstraint, SketcherPrs_Mirror);
 CONSTRAINT_PRS_IMPL(angleConstraint, SketcherPrs_Angle);
 
-
+// Non-standard constraints definition
 AISObjectPtr SketcherPrs_Factory::horisontalConstraint(ModelAPI_Feature* theConstraint,
                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane)
 { 
index b1459205ea1e311efa11dfb672cd284e4a41125c..e7bdfdda7c5fba61a891484b0c9b10144e983501 100644 (file)
@@ -35,6 +35,7 @@ bool SketcherPrs_HVDirection::updatePoints(double theStep) const
   if (SketcherPrs_Tools::getShape(aObj).get() == NULL)
     return false;
 
+  // Set point of the symbol
   SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
   gp_Pnt aP1 = aMgr->getPosition(aObj, this, theStep);
   myPntArray->SetVertice(1, aP1);
@@ -45,6 +46,7 @@ void SketcherPrs_HVDirection::drawLines(const Handle(Prs3d_Presentation)& thePrs
 {
   Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
 
+  // Draw constrained object
   Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
   aGroup->SetPrimitivesAspect(aLineAspect);
 
index 3ab9bc6be8b050906cf8d2e6b2679692841bf5aa..24977ecee183754414167f5ef6bf6ea5e1cd766a 100644 (file)
@@ -56,13 +56,17 @@ void SketcherPrs_LengthDimension::Compute(const Handle(PrsMgr_PresentationManage
   if (!getPoints(aPnt1, aPnt2))
     return;
 
+  // compute flyout distance
   double aD = SketcherPrs_Tools::getFlyoutDistance(myConstraint);
   SetFlyout(SketcherPrs_Tools::getFlyoutDistance(myConstraint));
   SetMeasuredGeometry(aPnt1, aPnt2, myPlane->impl<gp_Ax3>());
+
+  // Update variable aspect parameters (depending on viewer scale)
   myAspect->SetExtensionSize(myAspect->ArrowAspect()->Length());
   myAspect->SetArrowTailSize(myAspect->ArrowAspect()->Length());
   // The value of vertical aligment is sometimes changed
   myAspect->TextAspect()->SetVerticalJustification(Graphic3d_VTA_CENTER);
+
   AIS_LengthDimension::Compute(thePresentationManager, thePresentation, theMode);
 }
 
@@ -70,6 +74,7 @@ bool SketcherPrs_LengthDimension::getPoints(gp_Pnt& thePnt1, gp_Pnt& thePnt2)
 {
   DataPtr aData = myConstraint->data();
   if (myConstraint->getKind() == SketchPlugin_ConstraintLength::ID()) {
+    // The constraint is length
     std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
       std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>
       (aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
@@ -80,6 +85,7 @@ bool SketcherPrs_LengthDimension::getPoints(gp_Pnt& thePnt1, gp_Pnt& thePnt2)
     if (!aFeature || aFeature->getKind() != SketchPlugin_Line::ID())
       return false;
 
+    // Get geometry of the object
     DataPtr aLineData = aFeature->data();
     std::shared_ptr<GeomDataAPI_Point2D> aStartPoint = 
       std::dynamic_pointer_cast<GeomDataAPI_Point2D>
@@ -92,6 +98,7 @@ bool SketcherPrs_LengthDimension::getPoints(gp_Pnt& thePnt1, gp_Pnt& thePnt2)
     return true;
 
   } else if (myConstraint->getKind() == SketchPlugin_ConstraintDistance::ID()) {
+    // The constraint is distance
     std::shared_ptr<GeomDataAPI_Point2D> aPoint_A = SketcherPrs_Tools::getFeaturePoint(
         aData, SketchPlugin_Constraint::ENTITY_A(), myPlane);
     std::shared_ptr<GeomDataAPI_Point2D> aPoint_B = SketcherPrs_Tools::getFeaturePoint(
@@ -100,9 +107,11 @@ bool SketcherPrs_LengthDimension::getPoints(gp_Pnt& thePnt1, gp_Pnt& thePnt2)
     std::shared_ptr<GeomAPI_Pnt2d> aPnt_A;
     std::shared_ptr<GeomAPI_Pnt2d> aPnt_B;
     if (aPoint_A && aPoint_B) {
+      // Both objects are points
       aPnt_A = aPoint_A->pnt();
       aPnt_B = aPoint_B->pnt();
     } else if (!aPoint_A && aPoint_B) {
+      // First object is line
       FeaturePtr aLine = SketcherPrs_Tools::getFeatureLine(
           aData, SketchPlugin_Constraint::ENTITY_A());
       if (aLine) {
@@ -110,6 +119,7 @@ bool SketcherPrs_LengthDimension::getPoints(gp_Pnt& thePnt1, gp_Pnt& thePnt2)
         aPnt_A = SketcherPrs_Tools::getProjectionPoint(aLine, aPnt_B);
       }
     } else if (aPoint_A && !aPoint_B) {
+      // Second object is line
       FeaturePtr aLine = SketcherPrs_Tools::getFeatureLine(
           aData, SketchPlugin_Constraint::ENTITY_B());
       if (aLine) {
@@ -117,9 +127,10 @@ bool SketcherPrs_LengthDimension::getPoints(gp_Pnt& thePnt1, gp_Pnt& thePnt2)
         aPnt_B = SketcherPrs_Tools::getProjectionPoint(aLine, aPnt_A);
       }
     }
-    if (!aPnt_A || !aPnt_B)
+    if (!aPnt_A || !aPnt_B) // Objects not found
       return false;
 
+    // Get points from these objects
     std::shared_ptr<GeomAPI_Pnt> aPoint1 = myPlane->to3D(aPnt_A->x(), aPnt_A->y());
     std::shared_ptr<GeomAPI_Pnt> aPoint2 = myPlane->to3D(aPnt_B->x(), aPnt_B->y());
     thePnt1 = aPoint1->impl<gp_Pnt>();
@@ -134,6 +145,7 @@ bool SketcherPrs_LengthDimension::getPoints(gp_Pnt& thePnt1, gp_Pnt& thePnt2)
 void SketcherPrs_LengthDimension::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
                                                    const Standard_Integer theMode)
 {
+  // Map the application selection modes to standard ones
   Standard_Integer aMode;
   switch (theMode) {
   case 0: // we should use selection of all objects
index 6ad3fb41705e57166584fd2d638b2557f209c7b5..9719dc8cd066175fdc641e7fa98217cfe5f865f7 100644 (file)
@@ -30,20 +30,24 @@ SketcherPrs_Mirror::SketcherPrs_Mirror(ModelAPI_Feature* theConstraint,
 
 bool SketcherPrs_Mirror::updatePoints(double theStep) const
 {
+  // Get axis of mirror
   ObjectPtr aAxisObj = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
   if (SketcherPrs_Tools::getShape(aAxisObj).get() == NULL)
     return false;
 
   std::shared_ptr<ModelAPI_Data> aData = myConstraint->data();
+  // Get source objects
   std::shared_ptr<ModelAPI_AttributeRefList> anAttrB = aData->reflist(SketchPlugin_Constraint::ENTITY_B());
   if (anAttrB.get() == NULL)
     return false;
+  // Get mirrored objects
   std::shared_ptr<ModelAPI_AttributeRefList> anAttrC = aData->reflist(SketchPlugin_Constraint::ENTITY_C());
   if (anAttrC.get() == NULL)
     return false;
 
   SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
   int aNb = anAttrB->size();
+  // If size of source objects and mirrored ones is not equal then the constraint is not computed
   if (aNb != anAttrC->size())
     return false;
 
@@ -51,11 +55,13 @@ bool SketcherPrs_Mirror::updatePoints(double theStep) const
   int i;
   ObjectPtr aObj;
   gp_Pnt aP1;
+  // get position for each source object
   for (i = 0; i < aNb; i++) {
     aObj = anAttrB->object(i);
     aP1 = aMgr->getPosition(aObj, this, theStep);
     myPntArray->SetVertice(i + 1, aP1);
   }  
+  // Get position of each mirrored object
   for (i = 0; i < aNb; i++) {
     aObj = anAttrC->object(i);
     aP1 = aMgr->getPosition(aObj, this, theStep);
@@ -81,9 +87,6 @@ void SketcherPrs_Mirror::drawLines(const Handle(Prs3d_Presentation)& thePrs, Qua
 
   Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
 
-  //Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
-  //aGroup->SetPrimitivesAspect(aLineAspect);
-
   // drawListOfShapes uses myDrawer for attributes definition
   Handle(Prs3d_LineAspect) aLnAspect = new Prs3d_LineAspect(theColor, Aspect_TOL_SOLID, 1);
   myDrawer->SetLineAspect(aLnAspect);
index e80fb8f784c387190422a6b109c45866e13302b5..1b6712d9ea90e2c98e2d5f95436c54377c830d5d 100644 (file)
@@ -24,6 +24,7 @@ SketcherPrs_Parallel::SketcherPrs_Parallel(ModelAPI_Feature* theConstraint,
                                            const std::shared_ptr<GeomAPI_Ax3>& thePlane) 
  : SketcherPrs_SymbolPrs(theConstraint, thePlane)
 {
+  // Create default array
   myPntArray = new Graphic3d_ArrayOfPoints(2);
   myPntArray->AddVertex(0., 0., 0.);
   myPntArray->AddVertex(0., 0., 0.);
@@ -39,6 +40,7 @@ bool SketcherPrs_Parallel::updatePoints(double theStep) const
   if (SketcherPrs_Tools::getShape(aObj2).get() == NULL)
     return false;
 
+  // Compute position of symbols
   SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
   gp_Pnt aP1 = aMgr->getPosition(aObj1, this, theStep);
   gp_Pnt aP2 = aMgr->getPosition(aObj2, this, theStep);
@@ -55,6 +57,7 @@ void SketcherPrs_Parallel::drawLines(const Handle(Prs3d_Presentation)& thePrs, Q
   Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
   aGroup->SetPrimitivesAspect(aLineAspect);
 
+  // Draw constrained lines
   addLine(aGroup, SketchPlugin_Constraint::ENTITY_A());
   addLine(aGroup, SketchPlugin_Constraint::ENTITY_B());
 }
index ecfd72d1181c21d3da822e6086c97f0c46b9497e..dfc6964e681abfa6b78033f6b03e31846cc7ef24 100644 (file)
@@ -24,6 +24,7 @@ SketcherPrs_Perpendicular::SketcherPrs_Perpendicular(ModelAPI_Feature* theConstr
                                                      const std::shared_ptr<GeomAPI_Ax3>& thePlane) 
  : SketcherPrs_SymbolPrs(theConstraint, thePlane)
 {
+  // Create default array
   myPntArray = new Graphic3d_ArrayOfPoints(2);
   myPntArray->AddVertex(0., 0., 0.);
   myPntArray->AddVertex(0., 0., 0.);
@@ -39,6 +40,7 @@ bool SketcherPrs_Perpendicular::updatePoints(double theStep) const
   if (SketcherPrs_Tools::getShape(aObj2).get() == NULL)
     return false;
 
+  // Compute position of symbols
   SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
   gp_Pnt aP1 = aMgr->getPosition(aObj1, this, theStep);
   gp_Pnt aP2 = aMgr->getPosition(aObj2, this, theStep);
@@ -55,6 +57,7 @@ void SketcherPrs_Perpendicular::drawLines(const Handle(Prs3d_Presentation)& theP
   Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
   aGroup->SetPrimitivesAspect(aLineAspect);
 
+  // Draw constrained lines
   addLine(aGroup, SketchPlugin_Constraint::ENTITY_A());
   addLine(aGroup, SketchPlugin_Constraint::ENTITY_B());
 }
index 2e361420d3995e655190a34f3d727bfc3dc9c9c2..1eb15216c24f051af4d2e9eed72d8857f84f9f5d 100644 (file)
@@ -14,7 +14,7 @@
 
 static SketcherPrs_PositionMgr* MyPosMgr = NULL;
 
-
+// The class is implemented as a singlton
 SketcherPrs_PositionMgr* SketcherPrs_PositionMgr::get()
 {
   if (MyPosMgr == NULL) 
@@ -31,15 +31,19 @@ int SketcherPrs_PositionMgr::getPositionIndex(ObjectPtr theLine,
                                               const SketcherPrs_SymbolPrs* thePrs)
 {
   if (myShapes.count(theLine) == 1) {
+    // Find the map and add new [Presentation - Index] pair
     PositionsMap& aPosMap = myShapes[theLine];
     if (aPosMap.count(thePrs) == 1) {
+      // return existing index
       return aPosMap[thePrs];
     } else {
+      // Add a new [Presentation - Index] pair
       int aInd = aPosMap.size();
       aPosMap[thePrs] = aInd;
       return aInd;
     }
   } else {
+    // Create a new map with initial index
     PositionsMap aPosMap;
     aPosMap[thePrs] = 0;
     myShapes[theLine] = aPosMap;
@@ -71,6 +75,7 @@ gp_Pnt SketcherPrs_PositionMgr::getPosition(ObjectPtr theShape,
                   (aPnt1->z() + aPnt2->z())/2.);
 
     } else {
+      // this is a circle or arc
       double aMidParam = (aCurve->startParam() + aCurve->endParam()) / 2.;
       std::shared_ptr<GeomAPI_Pnt> aPnt = aCurve->getPoint(aMidParam);
       aP = aPnt->impl<gp_Pnt>();
@@ -88,10 +93,12 @@ gp_Pnt SketcherPrs_PositionMgr::getPosition(ObjectPtr theShape,
     std::shared_ptr<GeomAPI_Dir> aDir = thePrs->plane()->dirX();
     aVec1 = gp_Vec(aDir->impl<gp_Dir>());
   }
+  // Compute shifting vector for a one symbol
   gp_Vec aShift = aVec1.Crossed(thePrs->plane()->normal()->impl<gp_Dir>());
   aShift.Normalize();
   aShift.Multiply(theStep * 0.8);
 
+  // Shift the position coordinate according to position index
   int aPos = getPositionIndex(theShape, thePrs);
   int aM = 1;
   if ((aPos % 2) == 0) {
@@ -126,13 +133,17 @@ void SketcherPrs_PositionMgr::deleteConstraint(const SketcherPrs_SymbolPrs* theP
 {
   std::map<ObjectPtr, PositionsMap>::iterator aIt;
   std::list<ObjectPtr> aToDel;
+  // Clear map for deleted presentation
   for (aIt = myShapes.begin(); aIt != myShapes.end(); ++aIt) {
     PositionsMap& aPosMap = aIt->second;
     if (aPosMap.count(thePrs) > 0) {
+      // Erase index
       aPosMap.erase(aPosMap.find(thePrs));
       if (aPosMap.size() == 0)
+        // Delete the map
         aToDel.push_back(aIt->first);
       else {
+        // Reindex objects positions in order to avoid spaces
         PositionsMap::iterator aIt;
         int i = 0;
         for (aIt = aPosMap.begin(); aIt != aPosMap.end(); aIt++, i++)
index 4a805eae7005cb4279b33ad971c818df6e786752..0846607545204f88e73403d9734f3b077025f423 100644 (file)
@@ -29,6 +29,7 @@ SketcherPrs_Radius::SketcherPrs_Radius(ModelAPI_Feature* theConstraint,
                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane)
 : AIS_RadiusDimension(MyDefCirc), myConstraint(theConstraint), myPlane(thePlane)
 {
+  // Set default values of the presentation
   myAspect = new Prs3d_DimensionAspect();
   myAspect->MakeArrows3d(false);
   myAspect->MakeText3d(false);
@@ -109,6 +110,7 @@ void SketcherPrs_Radius::Compute(const Handle(PrsMgr_PresentationManager3d)& the
 void SketcherPrs_Radius::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
                                                    const Standard_Integer theMode)
 {
+  // Map the application selection modes to standard ones
   Standard_Integer aMode;
   switch (theMode) {
   case 0: // we should use selection of all objects
index 7ef19eef99015c7aed1e9c62e05fa8b58495de27..2fc417fedd38a16c02b4e7e2468c8bbc07df1914 100644 (file)
@@ -41,6 +41,7 @@ SketcherPrs_Rigid::SketcherPrs_Rigid(ModelAPI_Feature* theConstraint,
                                            const std::shared_ptr<GeomAPI_Ax3>& thePlane) 
  : SketcherPrs_SymbolPrs(theConstraint, thePlane)
 {
+  // Set default points array
   myPntArray = new Graphic3d_ArrayOfPoints(1);
   myPntArray->AddVertex(0., 0., 0.);
 }  
@@ -52,6 +53,7 @@ bool SketcherPrs_Rigid::updatePoints(double theStep) const
   std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = aData->refattr(SketchPlugin_Constraint::ENTITY_A());
   AttributePtr aRefAttr = anAttr->attr();
   if (anAttr->isObject()) {
+    // The constraint attached to an object
     ObjectPtr aObj = anAttr->object();
     if (SketcherPrs_Tools::getShape(aObj).get() == NULL)
       return false;
@@ -60,6 +62,7 @@ bool SketcherPrs_Rigid::updatePoints(double theStep) const
     gp_Pnt aP1 = aMgr->getPosition(aObj, this, theStep);
     myPntArray->SetVertice(1, aP1);
   } else {
+    // The constraint attached to a point
     std::shared_ptr<GeomAPI_Pnt2d> aPnt = SketcherPrs_Tools::getPoint(myConstraint, SketchPlugin_Constraint::ENTITY_A());
     if (aPnt.get() == NULL)
       return false;
@@ -76,14 +79,17 @@ void SketcherPrs_Rigid::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quan
   FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
   std::shared_ptr<GeomAPI_Shape> aShape;
   if (aFeature.get()) {
+    // If constraint attached to a feature
     const std::list<ResultPtr>& aResults = aFeature->results();
     std::list<ResultPtr>::const_iterator aIt;
+    // Find a shape
     for (aIt = aResults.cbegin(); aIt != aResults.cend(); aIt++) {
       aShape = (*aIt)->shape();
       if (aShape->isEdge())
         break;
     }
   } else {
+    // Else it is a result
     aShape = SketcherPrs_Tools::getShape(aObj);
   }
   if (aShape.get() == NULL)
index 05fa43cf8568c5be037329cb89f4d03e00ed9a31..b66ecbd035211b72fca1adfb8ef989cb2e022c7f 100644 (file)
@@ -257,6 +257,7 @@ SketcherPrs_SymbolPrs::SketcherPrs_SymbolPrs(ModelAPI_Feature* theConstraint,
 SketcherPrs_SymbolPrs::~SketcherPrs_SymbolPrs()
 {
   SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
+  // Empty memory in position manager
   aMgr->deleteConstraint(this);
 }
 
@@ -269,6 +270,7 @@ Handle(Image_AlienPixMap) SketcherPrs_SymbolPrs::icon()
   if (myIconsMap.count(iconName()) == 1) {
     return myIconsMap[iconName()];
   }
+  // Load icon for the presentation
   char* aEnv = getenv("NEWGEOM_ROOT_DIR");
   if (aEnv != NULL) {
     TCollection_AsciiString aFile(aEnv);
@@ -282,6 +284,7 @@ Handle(Image_AlienPixMap) SketcherPrs_SymbolPrs::icon()
       return aPixMap;
     }
   }
+  // The icon for constraint is not found
   static const char aMsg[] = "Error! constraint images are not found";
   cout<<aMsg<<endl;
   Events_Error::send(aMsg);
@@ -291,6 +294,7 @@ Handle(Image_AlienPixMap) SketcherPrs_SymbolPrs::icon()
 
 void SketcherPrs_SymbolPrs::prepareAspect()
 {
+  // Create an aspect with the icon
   if (myAspect.IsNull()) {
     Handle(Image_AlienPixMap) aIcon = icon();
     if (aIcon.IsNull()) 
@@ -311,6 +315,7 @@ void SketcherPrs_SymbolPrs::addLine(const Handle(Graphic3d_Group)& theGroup, std
   std::shared_ptr<GeomAPI_Pnt> aPnt1 = aEdge->firstPoint();
   std::shared_ptr<GeomAPI_Pnt> aPnt2 = aEdge->lastPoint();
 
+  // Draw line by two points
   Handle(Graphic3d_ArrayOfSegments) aLines = new Graphic3d_ArrayOfSegments(2, 1);
   aLines->AddVertex(aPnt1->impl<gp_Pnt>());
   aLines->AddVertex(aPnt2->impl<gp_Pnt>());
@@ -348,6 +353,7 @@ void SketcherPrs_SymbolPrs::Compute(const Handle(PrsMgr_PresentationManager3d)&
                                    const Handle(Prs3d_Presentation)& thePresentation, 
                                    const Standard_Integer theMode)
 {
+  // Create an icon
   prepareAspect();
 
   Handle(AIS_InteractiveContext) aCtx = GetContext();
@@ -357,6 +363,7 @@ void SketcherPrs_SymbolPrs::Compute(const Handle(PrsMgr_PresentationManager3d)&
     aDriver->UserDrawCallback() = SymbolPrsCallBack;
   }
 
+  // Update points with default shift value
   if (!updatePoints(20)) {
     return;
   }
@@ -366,6 +373,7 @@ void SketcherPrs_SymbolPrs::Compute(const Handle(PrsMgr_PresentationManager3d)&
     myOwner = new SelectMgr_EntityOwner(this);
   }
 
+  // Create sensitive point for each symbol
   mySPoints.Clear();
   for (int i = 1; i <= aNbVertex; i++) {
     Handle(SketcherPrs_SensitivePoint) aSP = new SketcherPrs_SensitivePoint(myOwner, i);
@@ -375,6 +383,7 @@ void SketcherPrs_SymbolPrs::Compute(const Handle(PrsMgr_PresentationManager3d)&
   Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePresentation);
   aGroup->SetPrimitivesAspect(myAspect);
 
+  // Recompute boundary box of the group
   Graphic3d_BndBox4f& aBnd = aGroup->ChangeBoundingBox();
   gp_Pnt aVert;
   aBnd.Clear();
@@ -383,6 +392,7 @@ void SketcherPrs_SymbolPrs::Compute(const Handle(PrsMgr_PresentationManager3d)&
     aBnd.Add (Graphic3d_Vec4((float)aVert.X(), (float)aVert.Y(), (float)aVert.Z(), 1.0f));
   }
 
+  // Pint the group with custom procedure (see Render)
   aGroup->UserDraw(this, true);
 
   // Disable frustum culling for this object by marking it as mutable
@@ -415,6 +425,7 @@ void SketcherPrs_SymbolPrs::Render(const Handle(OpenGl_Workspace)& theWorkspace)
   Handle(OpenGl_View) aView = theWorkspace->ActiveView();
   
   double aScale = aView->Camera()->Scale();
+  // Update points coordinate taking the viewer scale into account
   if (!updatePoints(MyDist * aScale))
     return;
 
@@ -424,6 +435,7 @@ void SketcherPrs_SymbolPrs::Render(const Handle(OpenGl_Workspace)& theWorkspace)
     myVboAttribs = new SketcherPrs_VertexBuffer(*aAttribs);
   }
 
+  // Update drawing attributes
   if (!myVboAttribs->init(aCtx, 0, aAttribs->NbElements, aAttribs->Data(), GL_NONE, aAttribs->Stride)) {
     myVboAttribs->Release (aCtx.operator->());
     myVboAttribs.Nullify();
@@ -445,6 +457,7 @@ void SketcherPrs_SymbolPrs::Render(const Handle(OpenGl_Workspace)& theWorkspace)
     if (theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT)
       aLineColor = theWorkspace->HighlightColor;
 
+    // Set lighting of the symbol
     if (toHilight)
       aCtx->core11fwd->glDisable (GL_LIGHTING);
     else
@@ -483,6 +496,7 @@ void SketcherPrs_SymbolPrs::Render(const Handle(OpenGl_Workspace)& theWorkspace)
 
 void SketcherPrs_SymbolPrs::Release (OpenGl_Context* theContext)
 {
+  // Release OpenGl resources
   if (!myVboAttribs.IsNull()) {
     if (theContext) {
       theContext->DelayedRelease (myVboAttribs);
@@ -495,16 +509,20 @@ void SketcherPrs_SymbolPrs::drawShape(const std::shared_ptr<GeomAPI_Shape>& theS
                                       const Handle(Prs3d_Presentation)& thePrs) const
 {
   if (theShape->isEdge()) {
+    // The shape is edge
     std::shared_ptr<GeomAPI_Curve> aCurve = 
       std::shared_ptr<GeomAPI_Curve>(new GeomAPI_Curve(theShape));
     if (aCurve->isLine()) {
+      // The shape is line
       GeomAdaptor_Curve aCurv(aCurve->impl<Handle(Geom_Curve)>(), aCurve->startParam(), aCurve->endParam());
       StdPrs_Curve::Add(thePrs, aCurv, myDrawer);
     } else {
+      // The shape is circle or arc
       GeomAdaptor_Curve aAdaptor(aCurve->impl<Handle(Geom_Curve)>(), aCurve->startParam(), aCurve->endParam());
       StdPrs_DeflectionCurve::Add(thePrs,aAdaptor,myDrawer);
     }
   } else if (theShape->isVertex()) {
+    // draw vertex
     std::shared_ptr<GeomAPI_Vertex> aVertex = 
       std::shared_ptr<GeomAPI_Vertex>(new GeomAPI_Vertex(theShape));
     std::shared_ptr<GeomAPI_Pnt> aPnt = aVertex->point();
@@ -532,8 +550,7 @@ void SketcherPrs_SymbolPrs::drawListOfShapes(const std::shared_ptr<ModelAPI_Attr
 void SketcherPrs_SymbolPrs::BoundingBox (Bnd_Box& theBndBox)
 {
   Select3D_BndBox3d aTmpBox;
-  for (Select3D_EntitySequenceIter aPntIter (mySPoints); aPntIter.More(); aPntIter.Next())
-  {
+  for (Select3D_EntitySequenceIter aPntIter (mySPoints); aPntIter.More(); aPntIter.Next()) {
     const Handle(Select3D_SensitiveEntity)& anEnt = aPntIter.Value();
     aTmpBox.Combine (anEnt->BoundingBox());
   }
index 199eb782f8161ff7123909e695805e648292752e..c9adc9b55f38671a6fd811576aafc6f99144c009 100644 (file)
@@ -27,6 +27,7 @@ SketcherPrs_Tangent::SketcherPrs_Tangent(ModelAPI_Feature* theConstraint,
                                            const std::shared_ptr<GeomAPI_Ax3>& thePlane) 
  : SketcherPrs_SymbolPrs(theConstraint, thePlane)
 {
+  // Init default points
   myPntArray = new Graphic3d_ArrayOfPoints(2);
   myPntArray->AddVertex(0., 0., 0.);
   myPntArray->AddVertex(0., 0., 0.);
@@ -41,6 +42,7 @@ bool SketcherPrs_Tangent::updatePoints(double theStep) const
   if (SketcherPrs_Tools::getShape(aObj2).get() == NULL)
     return false;
 
+  // Compute points coordinates
   SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
   gp_Pnt aP1 = aMgr->getPosition(aObj1, this, theStep);
   gp_Pnt aP2 = aMgr->getPosition(aObj2, this, theStep);
index 912ea14467ee32d7c7b9fecd0c925422e72d2a6e..c2ccd87488ab57d5f11c986059ef128cd30b3b0c 100644 (file)
@@ -73,6 +73,11 @@ std::shared_ptr<GeomAPI_Pnt2d> getPoint(ModelAPI_Feature* theFeature,
 }
 
 //*************************************************************************************
+/// Find an attribute of the given object which corresponds to a vetrex 
+/// defined by a shape
+/// \param theObject an object
+/// \param theShape a vertex
+/// \param thePlane a projection plane (sketcher plane)
 std::shared_ptr<GeomDataAPI_Point2D> findGeomPoint(ObjectPtr theObject, 
                                     const TopoDS_Shape& theShape, 
                                     const std::shared_ptr<GeomAPI_Ax3>& thePlane)
@@ -129,10 +134,12 @@ std::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
       ObjectPtr anObject = anAttr->object();
       aFeature = ModelAPI_Feature::feature(anObject);
       if (aFeature && aFeature->getKind() == SketchPlugin_Point::ID()) {
+        // Attribute refers to a point
         aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
                      aFeature->data()->attribute(SketchPlugin_Point::COORD_ID()));
       }
       else {
+        // if the attribute refers on another object
         ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
         if (aRes.get()) {
           GeomShapePtr aShape = aRes->shape();
@@ -144,6 +151,7 @@ std::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
       }
     }
     else if (anAttr->attr()) {
+      // If attribute is a point
       aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr->attr());
     }
   }
@@ -231,13 +239,13 @@ std::shared_ptr<GeomAPI_Pnt> getAnchorPoint(const ModelAPI_Feature* theConstrain
 
   FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object());
   std::shared_ptr<GeomAPI_Pnt2d> aCenter;
-  if (aFeature->getKind() == SketchPlugin_Arc::ID()) {
+  if (aFeature->getKind() == SketchPlugin_Arc::ID()) { // arc
     aCenter = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
         aFeature->attribute(SketchPlugin_Arc::CENTER_ID()))->pnt();
-  } else if (aFeature->getKind() == SketchPlugin_Circle::ID()) {
+  } else if (aFeature->getKind() == SketchPlugin_Circle::ID()) { // circle
     aCenter = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
         aFeature->attribute(SketchPlugin_Circle::CENTER_ID()))->pnt();
-  } else
+  } else 
     return std::shared_ptr<GeomAPI_Pnt>();
 
   std::shared_ptr<GeomAPI_Pnt2d> anOrigin(new GeomAPI_Pnt2d(0.0, 0.0));
index 481e7d96d2eae703326284f11b9ca98e77105933..a7c0925b53b194bb321b2da75b90055de369d3d4 100644 (file)
@@ -21,32 +21,45 @@ class GeomDataAPI_Point2D;
 
 namespace SketcherPrs_Tools {
 
-/// Enumeration with modes for activation of selection custom presentations
-enum SelectionModes {
-  /// Start of enumeration
-  Sel_Mode_First = 100, 
+  /// Enumeration with modes for activation of selection custom presentations
+  enum SelectionModes {
+    /// Start of enumeration
+    Sel_Mode_First = 100, 
   
-  /// Selection mode for all constraints exclude dimensions
-  Sel_Constraint,
+    /// Selection mode for all constraints exclude dimensions
+    Sel_Constraint,
   
-  /// Selection mode for whole dimension
-  Sel_Dimension_All,
+    /// Selection mode for whole dimension
+    Sel_Dimension_All,
   
-  /// Selection mode for line of dimension
-  Sel_Dimension_Line,
+    /// Selection mode for line of dimension
+    Sel_Dimension_Line,
 
-  /// Selection mode foe text of dimension
-  Sel_Dimension_Text
-};
+    /// Selection mode foe text of dimension
+    Sel_Dimension_Text
+  };
 
+  /// Returns result object referenced by feature
+  /// \param theFeature a feature
+  /// \param theAttrName an attribute name
   SKETCHERPRS_EXPORT ObjectPtr getResult(ModelAPI_Feature* theFeature,
                                          const std::string& theAttrName);
 
+  /// Returns shape from result object (or NULL)
+  /// \param theObject a result object
   SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Shape> getShape(ObjectPtr theObject);
 
+
+  /// Returns point from a line feature
+  /// \param theFeature a line feature
+  /// \param theAttrName an attribute of the point
   SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt2d> getPoint(ModelAPI_Feature* theFeature,
                                           const std::string& theAttrName);
 
+
+  /// Returns point projected on a line
+  /// \param theLine  a line
+  /// \param thePoint a projecting point
   SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(
                         const FeaturePtr theLine,
                         const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
@@ -55,22 +68,35 @@ enum SelectionModes {
                                                const std::string& theAttribute);
 
   /// Obtain the point object from specified constraint parameter
+  /// \param theData a data object
+  /// \param theAttribute an attribute name
+  /// \param thePlane a projection plane (sketcher plane)
   SKETCHERPRS_EXPORT std::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
                                                        const std::string& theAttribute,
                                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane);
 
+  /// Returns value of dimension arrows size
   SKETCHERPRS_EXPORT double getArrowSize();
 
+  /// Set value of dimension arrows size
+  /// \param theSize a size value
   SKETCHERPRS_EXPORT void setArrowSize(double theSize);
 
+  /// Set value of dimension text height
+  /// \param theHeight a height value
   SKETCHERPRS_EXPORT void setTextHeight(double theHeight);
 
+  /// Returns value of dimension text height
   SKETCHERPRS_EXPORT double getTextHeight();
 
+  /// Returns default value of dimension text height
   SKETCHERPRS_EXPORT double getDefaultTextHeight();
 
+  /// Get flayout distance of the dimension constraint
+  /// \param theConstraint a dimension constraint object
   SKETCHERPRS_EXPORT double getFlyoutDistance(const ModelAPI_Feature* theConstraint);
 
+  /// Compute anchor pint for radius dimension
   SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt> getAnchorPoint(
                                               const ModelAPI_Feature* theConstraint,
                                               const std::shared_ptr<GeomAPI_Ax3>& thePlane);
index b783a75440db11ceb1baaf856f28e9318d11ad2d..929148d60ba25a5408a1bbd9b2fc985d4d843101 100644 (file)
@@ -38,6 +38,7 @@ SketcherPrs_Transformation::SketcherPrs_Transformation(ModelAPI_Feature* theCons
 bool SketcherPrs_Transformation::updatePoints(double theStep) const 
 {
   std::shared_ptr<ModelAPI_Data> aData = myConstraint->data();
+  // Get transformated objects list
   std::shared_ptr<ModelAPI_AttributeRefList> anAttrB = aData->reflist(SketchPlugin_Constraint::ENTITY_B());
   if (anAttrB.get() == NULL)
     return false;
@@ -58,6 +59,7 @@ bool SketcherPrs_Transformation::updatePoints(double theStep) const
   int i;
   ObjectPtr aObj;
   gp_Pnt aP1;
+  // Compute points of symbols
   for (i = 0; i < aNbB; i++) {
     aObj = anAttrB->object(i);
     aP1 = aMgr->getPosition(aObj, this, theStep);
@@ -85,24 +87,29 @@ void SketcherPrs_Transformation::drawLines(const Handle(Prs3d_Presentation)& the
 
   drawListOfShapes(anAttrB, thePrs);
   if (myConstraint->getKind() == SketchPlugin_MultiTranslation::ID()) {
+    // If it is translation
     std::shared_ptr<GeomDataAPI_Point2D> aStart = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
         aData->attribute(SketchPlugin_MultiTranslation::START_POINT_ID()));
     std::shared_ptr<GeomDataAPI_Point2D> aEnd = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
         aData->attribute(SketchPlugin_MultiTranslation::END_POINT_ID()));
   
     if (aStart.get() && aEnd.get() && aStart->isInitialized() && aEnd->isInitialized()) {
+      // Add start point
       std::shared_ptr<GeomAPI_Pnt> aPnt = myPlane->to3D(aStart->x(), aStart->y());
       Handle(Geom_CartesianPoint) aPoint = new Geom_CartesianPoint(aPnt->impl<gp_Pnt>());
       StdPrs_Point::Add(thePrs, aPoint, myDrawer);
 
+      // Add end point
       aPnt = myPlane->to3D(aEnd->x(), aEnd->y());
       aPoint = new Geom_CartesianPoint(aPnt->impl<gp_Pnt>());
       StdPrs_Point::Add(thePrs, aPoint, myDrawer);
     }
   } else if (myConstraint->getKind() == SketchPlugin_MultiRotation::ID()) {
+    // if it is rotation
     std::shared_ptr<GeomDataAPI_Point2D> aCenter = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
         aData->attribute(SketchPlugin_MultiRotation::CENTER_ID()));
     if (aCenter.get() && aCenter->isInitialized()) {
+      // Show center of rotation
       std::shared_ptr<GeomAPI_Pnt> aPnt = myPlane->to3D(aCenter->x(), aCenter->y());
       Handle(Geom_CartesianPoint) aPoint = new Geom_CartesianPoint(aPnt->impl<gp_Pnt>());
       StdPrs_Point::Add(thePrs, aPoint, myDrawer);