#include <GeomAPI_Pnt2d.h>
#include <GeomAPI_XY.h>
+#include <SketcherPrs_Factory.h>
+
#define PI 3.1415926535897932
SketchPlugin_MultiRotation::SketchPlugin_MultiRotation()
AISObjectPtr anAIS = thePrevious;
if (!anAIS) {
-// TODO:
-// anAIS = SketcherPrs_Factory::mirrorConstraint(this, sketch()->coordinatePlane());
+ anAIS = SketcherPrs_Factory::rotateConstraint(this, sketch()->coordinatePlane());
}
return anAIS;
}
#include <ModelAPI_Session.h>
#include <ModelAPI_Validator.h>
+#include <SketcherPrs_Factory.h>
+
SketchPlugin_MultiTranslation::SketchPlugin_MultiTranslation()
{
}
AISObjectPtr anAIS = thePrevious;
if (!anAIS) {
-// TODO:
-// anAIS = SketcherPrs_Factory::mirrorConstraint(this, sketch()->coordinatePlane());
+ anAIS = SketcherPrs_Factory::translateConstraint(this, sketch()->coordinatePlane());
}
return anAIS;
}
SketcherPrs_Radius.h
SketcherPrs_LengthDimension.h
SketcherPrs_Mirror.h
+ SketcherPrs_Transformation.h
)
SET(PROJECT_SOURCES
SketcherPrs_Radius.cpp
SketcherPrs_LengthDimension.cpp
SketcherPrs_Mirror.cpp
+ SketcherPrs_Transformation.cpp
)
SET(PROJECT_LIBRARIES
icons/equal.png
icons/tangent.png
icons/mirror.png
+ icons/rotate.png
+ icons/translate.png
)
ADD_DEFINITIONS(-DSKETCHERPRS_EXPORTS ${CAS_DEFINITIONS})
#include "SketcherPrs_Radius.h"
#include "SketcherPrs_LengthDimension.h"
#include "SketcherPrs_Mirror.h"
+#include "SketcherPrs_Transformation.h"
#define CONSTRAINT_PRS_IMPL(NAME, CLASS) \
AISObjectPtr SketcherPrs_Factory::NAME(ModelAPI_Feature* theConstraint, \
aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs));
return aAISObj;
}
+
+AISObjectPtr SketcherPrs_Factory::translateConstraint(ModelAPI_Feature* theConstraint,
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane)
+{
+ std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
+ Handle(SketcherPrs_Transformation) aPrs = new SketcherPrs_Transformation(theConstraint, thePlane, true);
+ aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs));
+ return aAISObj;
+}
+
+AISObjectPtr SketcherPrs_Factory::rotateConstraint(ModelAPI_Feature* theConstraint,
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane)
+{
+ std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
+ Handle(SketcherPrs_Transformation) aPrs = new SketcherPrs_Transformation(theConstraint, thePlane, false);
+ aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs));
+ return aAISObj;
+}
/// \param thePlane the current sketch plane
GET_CONSTRAINT_PRS(coincidentConstraint)
- /// Creates coincedent parallel presentation
+ /// Creates parallel constraint presentation
/// \param theConstraint the constraint
/// \param thePlane the current sketch plane
GET_CONSTRAINT_PRS(parallelConstraint)
/// \param thePlane the current sketch plane
GET_CONSTRAINT_PRS(perpendicularConstraint)
- /// Creates coincedent perpendicular presentation
+ /// Creates rigid constraint presentation
/// \param theConstraint the constraint
/// \param thePlane the current sketch plane
GET_CONSTRAINT_PRS(rigidConstraint)
- /// Creates coincedent perpendicular presentation
+ /// Creates horizontal constraint presentation
/// \param theConstraint the constraint
/// \param thePlane the current sketch plane
GET_CONSTRAINT_PRS(horisontalConstraint)
- /// Creates coincedent perpendicular presentation
+ /// Creates vertical constraint presentation
/// \param theConstraint the constraint
/// \param thePlane the current sketch plane
GET_CONSTRAINT_PRS(verticalConstraint)
- /// Creates coincedent perpendicular presentation
+ /// Creates equal constraint presentation
/// \param theConstraint the constraint
/// \param thePlane the current sketch plane
GET_CONSTRAINT_PRS(equalConstraint)
- /// Creates coincedent perpendicular presentation
+ /// Creates tangent constraiont presentation
/// \param theConstraint the constraint
/// \param thePlane the current sketch plane
GET_CONSTRAINT_PRS(tangentConstraint)
- /// Creates coincedent perpendicular presentation
+ /// Creates radius dimension presentation
/// \param theConstraint the constraint
/// \param thePlane the current sketch plane
GET_CONSTRAINT_PRS(radiusConstraint)
- /// Creates coincedent perpendicular presentation
+ /// Creates length dimension presentation
/// \param theConstraint the constraint
/// \param thePlane the current sketch plane
GET_CONSTRAINT_PRS(lengthDimensionConstraint)
- /// Creates coincedent perpendicular presentation
+ /// Creates mirror constraint presentation
/// \param theConstraint the constraint
/// \param thePlane the current sketch plane
GET_CONSTRAINT_PRS(mirrorConstraint)
+
+ /// Creates translate constraint presentation
+ /// \param theConstraint the constraint
+ /// \param thePlane the current sketch plane
+ GET_CONSTRAINT_PRS(translateConstraint)
+
+ /// Creates rotate constraint presentation
+ /// \param theConstraint the constraint
+ /// \param thePlane the current sketch plane
+ GET_CONSTRAINT_PRS(rotateConstraint)
};
#endif
#include <SketchPlugin_Constraint.h>
-#include <ModelAPI_AttributeRefList.h>
-
#include <Graphic3d_AspectLine3d.hxx>
#include <Prs3d_Root.hxx>
if (anAttrC.get() == NULL)
return;
- SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
int aNb = anAttrB->size();
if (aNb != anAttrC->size())
return;
addLine(aGroup, SketchPlugin_Constraint::ENTITY_A());
// Draw source objects
- int i;
- ObjectPtr aObj;
- for (i = 0; i < aNb; i++) {
- aObj = anAttrB->object(i);
- std::shared_ptr<GeomAPI_Shape> aShape = SketcherPrs_Tools::getShape(aObj);
- if (aShape.get() != NULL)
- drawShape(aShape, thePrs);
- }
+ drawListOfShapes(anAttrB, thePrs);
+
// draw mirrored objects
- for (i = 0; i < aNb; i++) {
- aObj = anAttrC->object(i);
- std::shared_ptr<GeomAPI_Shape> aShape = SketcherPrs_Tools::getShape(aObj);
- if (aShape.get() != NULL)
- drawShape(aShape, thePrs);
- }
+ drawListOfShapes(anAttrC, thePrs);
}
int aNbVertex = myPntArray->VertexNumber();
if (myOwner.IsNull()) {
myOwner = new SelectMgr_EntityOwner(this);
- for (int i = 1; i <= aNbVertex; i++) {
- Handle(SketcherPrs_SensitivePoint) aSP = new SketcherPrs_SensitivePoint(myOwner, myPntArray, i);
- mySPoints.Append(aSP);
- }
+ }
+
+ mySPoints.Clear();
+ for (int i = 1; i <= aNbVertex; i++) {
+ Handle(SketcherPrs_SensitivePoint) aSP = new SketcherPrs_SensitivePoint(myOwner, myPntArray, i);
+ mySPoints.Append(aSP);
}
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePresentation);
StdPrs_Point::Add(thePrs, aPoint, myDrawer);
}
}
+
+void SketcherPrs_SymbolPrs::drawListOfShapes(const std::shared_ptr<ModelAPI_AttributeRefList>& theListAttr,
+ const Handle(Prs3d_Presentation)& thePrs) const
+{
+ int aNb = theListAttr->size();
+ if (aNb == 0)
+ return;
+ int i;
+ ObjectPtr aObj;
+ for (i = 0; i < aNb; i++) {
+ aObj = theListAttr->object(i);
+ std::shared_ptr<GeomAPI_Shape> aShape = SketcherPrs_Tools::getShape(aObj);
+ if (aShape.get() != NULL)
+ drawShape(aShape, thePrs);
+ }
+}
+
#include "SketcherPrs_SensitivePoint.h"
#include <ModelAPI_Feature.h>
+#include <ModelAPI_AttributeRefList.h>
#include <AIS_InteractiveObject.hxx>
#include <GeomAPI_Ax3.h>
void drawShape(const std::shared_ptr<GeomAPI_Shape>& theShape,
const Handle(Prs3d_Presentation)& thePrs) const;
+ /// Draw a list of shapes stored in a RefListAttribute
+ /// \param theListAttr the attribute of reference3s list
+ /// \param thePrs the presentation scene
+ void drawListOfShapes(const std::shared_ptr<ModelAPI_AttributeRefList>& theListAttr,
+ const Handle(Prs3d_Presentation)& thePrs) const;
protected:
/// Constraint feature
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: SketcherPrs_Transformation.cpp
+// Created: 16 February 2015
+// Author: Vitaly SMETANNIKOV
+
+#include "SketcherPrs_Transformation.h"
+#include "SketcherPrs_Tools.h"
+#include "SketcherPrs_PositionMgr.h"
+
+#include <SketchPlugin_Constraint.h>
+#include <ModelAPI_AttributeRefList.h>
+
+#include <Graphic3d_AspectLine3d.hxx>
+#include <Prs3d_Root.hxx>
+
+
+
+IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Transformation, SketcherPrs_SymbolPrs);
+IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Transformation, SketcherPrs_SymbolPrs);
+
+static Handle(Image_AlienPixMap) MyPixMap;
+
+SketcherPrs_Transformation::SketcherPrs_Transformation(ModelAPI_Feature* theConstraint,
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane,
+ bool isTranslation)
+ : SketcherPrs_SymbolPrs(theConstraint, thePlane), myIsTranslation(isTranslation)
+{
+}
+
+bool SketcherPrs_Transformation::updatePoints(double theStep) const
+{
+ std::shared_ptr<ModelAPI_Data> aData = myConstraint->data();
+ std::shared_ptr<ModelAPI_AttributeRefList> anAttrB = aData->reflist(SketchPlugin_Constraint::ENTITY_B());
+ if (anAttrB.get() == NULL)
+ return false;
+
+ int aNbB = anAttrB->size();
+ if (aNbB == 0)
+ return false;
+
+ SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
+ myPntArray = new Graphic3d_ArrayOfPoints(aNbB);
+
+ int i;
+ ObjectPtr aObj;
+ gp_Pnt aP1;
+ for (i = 0; i < aNbB; i++) {
+ aObj = anAttrB->object(i);
+ aP1 = aMgr->getPosition(aObj, this, theStep);
+ myPntArray->SetVertice(i + 1, aP1);
+ }
+
+ return true;
+}
+
+void SketcherPrs_Transformation::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const
+{
+ std::shared_ptr<ModelAPI_Data> aData = myConstraint->data();
+ std::shared_ptr<ModelAPI_AttributeRefList> anAttrB = aData->reflist(SketchPlugin_Constraint::ENTITY_B());
+ if (anAttrB.get() == NULL)
+ return;
+
+ Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
+
+ Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
+ aGroup->SetPrimitivesAspect(aLineAspect);
+
+ drawListOfShapes(anAttrB, thePrs);
+}
+
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: SketcherPrs_Transformation.h
+// Created: 16 February 2015
+// Author: Vitaly SMETANNIKOV
+
+#ifndef SketcherPrs_Transformation_H
+#define SketcherPrs_Transformation_H
+
+#include "SketcherPrs_SymbolPrs.h"
+#include <ModelAPI_Feature.h>
+
+
+DEFINE_STANDARD_HANDLE(SketcherPrs_Transformation, SketcherPrs_SymbolPrs)
+
+/**
+* \ingroup GUI
+* A redefinition of standard AIS Interactive Object in order to provide
+* presentation of parallel constraint
+*/
+class SketcherPrs_Transformation: public SketcherPrs_SymbolPrs
+{
+public:
+ /// Constructor
+ /// \param theConstraint a constraint feature
+ /// \param thePlane a coordinate plane of current sketch
+ Standard_EXPORT SketcherPrs_Transformation(ModelAPI_Feature* theConstraint,
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane,
+ bool isTranslation);
+
+ DEFINE_STANDARD_RTTI(SketcherPrs_Transformation)
+protected:
+ virtual const char* iconName() const { return myIsTranslation? "translate.png" : "rotate.png"; }
+
+ /// Redefine this function in order to add additiona lines of constraint base
+ /// \param thePrs a presentation
+ /// \param theColor a color of additiona lines
+ virtual void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const;
+
+ /// Update myPntArray according to presentation positions
+ /// \return true in case of success
+ virtual bool updatePoints(double theStep) const;
+
+private:
+ bool myIsTranslation;
+};
+
+#endif
\ No newline at end of file
<file>pictures/shading.png</file>
<file>pictures/wireframe.png</file>
<file>pictures/expression.png</file>
+ <file>pictures/arrow.png</file>
</qresource>
</RCC>