#include <GeomAPI_Pnt2d.h>
+//#define DEBUG_OBJECT_MOVED_MESSAGE
+#ifdef DEBUG_OBJECT_MOVED_MESSAGE
+#include <iostream>
+#endif
+
ModelAPI_ObjectUpdatedMessage::ModelAPI_ObjectUpdatedMessage(const Events_ID theID,
const void* theSender)
: Events_MessageGroup(theID, theSender)
void ModelAPI_ObjectMovedMessage::setOriginalPosition(double theX, double theY)
{
myOriginalPosition = std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY));
+#ifdef DEBUG_OBJECT_MOVED_MESSAGE
+ std::cout << "setOriginalPosition: " << myOriginalPosition->x() << ", "
+ << myOriginalPosition->y() << std::endl;
+#endif
}
void ModelAPI_ObjectMovedMessage::setOriginalPosition(
const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
{
myOriginalPosition = thePoint;
+#ifdef DEBUG_OBJECT_MOVED_MESSAGE
+ std::cout << "setOriginalPosition: " << myOriginalPosition->x() << ", "
+ << myOriginalPosition->y() << std::endl;
+#endif
}
void ModelAPI_ObjectMovedMessage::setCurrentPosition(double theX, double theY)
{
myCurrentPosition = std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY));
+#ifdef DEBUG_OBJECT_MOVED_MESSAGE
+ std::cout << "setCurrentPosition: " << myCurrentPosition->x() << ", " << myCurrentPosition->y()
+ << ", myCurrentPosition - myOriginalPosition: "
+ << myCurrentPosition->x() - myOriginalPosition->x() << ", "
+ << myCurrentPosition->y() - myOriginalPosition->y() << std::endl;
+#endif
}
void ModelAPI_ObjectMovedMessage::setCurrentPosition(
const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
{
myCurrentPosition = thePoint;
+#ifdef DEBUG_OBJECT_MOVED_MESSAGE
+ std::cout << "setCurrentPosition: " << myCurrentPosition->x() << ", " << myCurrentPosition->y()
+ << ", myCurrentPosition - myOriginalPosition: "
+ << myCurrentPosition->x() - myOriginalPosition->x() << ", "
+ << myCurrentPosition->y() - myOriginalPosition->y() << std::endl;
+#endif
}
{
}
-bool ModuleBase_WidgetEditor::editedValue(double& outValue, QString& outText)
+bool ModuleBase_WidgetEditor::editedValue(double theSpinMinValue, double theSpinMaxValue,
+ double& outValue, QString& outText)
{
bool isValueAccepted = false;
aLay->setContentsMargins(2, 2, 2, 2);
ModuleBase_ParamSpinBox* anEditor = new ModuleBase_ParamSpinBox(myEditorDialog);
- anEditor->setMinimum(0);
- anEditor->setMaximum(DBL_MAX);
+ anEditor->setMinimum(theSpinMinValue);
+ anEditor->setMaximum(theSpinMaxValue);
if (outText.isEmpty())
anEditor->setValue(outValue);
else
if (mySpinBox->hasVariable())
aText = mySpinBox->text();
- isValueAccepted = editedValue(aValue, aText);
+ isValueAccepted = editedValue(mySpinBox->minimum(), mySpinBox->maximum(), aValue, aText);
if (isValueAccepted) {
if (aText.isEmpty()) {
if (mySpinBox->hasVariable()) {
private:
/// Show editor
+ /// \param theSpinMinValue a minimal value of popup menu spin box
+ /// \param theSpinMaxValue a maximum value of popup menu spin box
/// \param theOutValue a result value
/// \param theOutText a result text
/// \return true if the editor value is accepted
- bool editedValue(double& theOutValue, QString& theOutText);
+ bool editedValue(double theSpinMinValue, double theSpinMaxValue,
+ double& theOutValue, QString& theOutText);
private:
///< the current widget feature
setResult(aResult, 1);
}
-void SketchPlugin_Arc::move(double theDeltaX, double theDeltaY)
-{
- std::shared_ptr<ModelAPI_Data> aData = data();
- if(!aData->isValid()) {
- return;
- }
-
- bool aWasBlocked = aData->blockSendAttributeUpdated(true);
-
- std::shared_ptr<GeomDataAPI_Point2D> aCenter = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- attribute(CENTER_ID()));
- if(aCenter->isInitialized()) {
- aCenter->move(theDeltaX, theDeltaY);
- }
-
- std::shared_ptr<GeomDataAPI_Point2D> aStart = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- attribute(START_ID()));
- if(aStart->isInitialized()) {
- aStart->move(theDeltaX, theDeltaY);
- }
-
- std::shared_ptr<GeomDataAPI_Point2D> anEnd = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- attribute(END_ID()));
- if(anEnd->isInitialized()) {
- anEnd->move(theDeltaX, theDeltaY);
- }
-
- aData->blockSendAttributeUpdated(aWasBlocked);
-}
-
bool SketchPlugin_Arc::isFixed()
{
return data()->selection(EXTERNAL_ID())->context().get() != NULL;
/// Creates an arc-shape
SKETCHPLUGIN_EXPORT virtual void execute();
- /// Moves the feature
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
-
/// Updates the "reversed" flag
/// \param isReversed whether the arc will be reversed
void setReversed(bool isReversed);
setResult(aResult, 1);
}
-void SketchPlugin_Circle::move(double theDeltaX, double theDeltaY)
-{
- std::shared_ptr<ModelAPI_Data> aData = data();
- if(!aData->isValid()) {
- return;
- }
-
- std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aData->attribute(CENTER_ID()));
- if(aPoint->isInitialized()) {
- aPoint->move(theDeltaX, theDeltaY);
- }
-}
-
bool SketchPlugin_Circle::isFixed() {
return data()->selection(EXTERNAL_ID())->context().get() != NULL;
}
/// Creates a new part document if needed
SKETCHPLUGIN_EXPORT virtual void execute();
- /// Moves the feature
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
-
/// Use plugin manager for features creation
SketchPlugin_Circle();
aValueAttr->setValue(anAngle);
}
-void SketchPlugin_ConstraintAngle::move(double theDeltaX, double theDeltaY)
-{
- std::shared_ptr<ModelAPI_Data> aData = data();
- if (!aData->isValid())
- return;
-
- myFlyoutUpdate = true;
- std::shared_ptr<GeomDataAPI_Point2D> aFlyoutAttr = std::dynamic_pointer_cast<
- GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
- aFlyoutAttr->setValue(aFlyoutAttr->x() + theDeltaX, aFlyoutAttr->y() + theDeltaY);
- myFlyoutUpdate = false;
-}
-
-
bool SketchPlugin_ConstraintAngle::compute(const std::string& theAttributeId)
{
if (theAttributeId != SketchPlugin_Constraint::FLYOUT_VALUE_PNT())
/// Returns the AIS preview
SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
- /// Moves the feature
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
-
/// Calculate current value of the angle
double calculateAngle();
{
}
-
-void SketchPlugin_ConstraintBase::move(const double theDeltaX, const double theDeltaY)
-{
-
-}
-
* \param theFeature sub-feature
*/
SKETCHPLUGIN_EXPORT virtual const void addSub(const FeaturePtr& theFeature);
- /// Moves the feature
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
/// Customize presentation of the feature
virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
return anAIS;
}
-//*************************************************************************************
-void SketchPlugin_ConstraintDistance::move(double theDeltaX, double theDeltaY)
-{
- std::shared_ptr<ModelAPI_Data> aData = data();
- if (!aData->isValid())
- return;
-
- // Recalculate a shift of flyout point in terms of local coordinates
- std::shared_ptr<GeomAPI_XY> aDir(new GeomAPI_XY(theDeltaX, theDeltaY));
- std::shared_ptr<GeomAPI_Ax3> aPlane = SketchPlugin_Sketch::plane(sketch());
- std::shared_ptr<GeomDataAPI_Point2D> aPointA = SketcherPrs_Tools::getFeaturePoint(
- data(), SketchPlugin_Constraint::ENTITY_A(), aPlane);
- std::shared_ptr<GeomDataAPI_Point2D> aPointB = SketcherPrs_Tools::getFeaturePoint(
- data(), SketchPlugin_Constraint::ENTITY_B(), aPlane);
-
- std::shared_ptr<GeomAPI_XY> aStartPnt;
- std::shared_ptr<GeomAPI_XY> aEndPnt;
- if (aPointA && aPointB) {
- aStartPnt = aPointA->pnt()->xy();
- aEndPnt = aPointB->pnt()->xy();
- } else if (aPointA) {
- FeaturePtr aLine = SketcherPrs_Tools::getFeatureLine(data(),
- SketchPlugin_Constraint::ENTITY_B());
- if (!aLine)
- return;
- std::shared_ptr<GeomAPI_Pnt2d> aPoint = aPointA->pnt();
- aStartPnt = aPoint->xy();
- aEndPnt = SketcherPrs_Tools::getProjectionPoint(aLine, aPoint)->xy();
- } else if (aPointB) {
- FeaturePtr aLine = SketcherPrs_Tools::getFeatureLine(data(),
- SketchPlugin_Constraint::ENTITY_A());
- if (!aLine)
- return;
- std::shared_ptr<GeomAPI_Pnt2d> aPoint = aPointB->pnt();
- aStartPnt = SketcherPrs_Tools::getProjectionPoint(aLine, aPoint)->xy();
- aEndPnt = aPoint->xy();
- } else
- return;
-
- std::shared_ptr<GeomAPI_Dir2d> aLineDir(new GeomAPI_Dir2d(aEndPnt->decreased(aStartPnt)));
- double dX = aDir->dot(aLineDir->xy());
- double dY = -aDir->cross(aLineDir->xy());
-
- std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
- myFlyoutUpdate = true;
- if (aPoint->isInitialized()) {
- aPoint->setValue(aPoint->x() + dX, aPoint->y() + dY);
- } else {
- aPoint->setValue(dX, dY);
- }
- myFlyoutUpdate = false;
-}
-
double SketchPlugin_ConstraintDistance::calculateCurrentDistance()
{
double aDistance = -1.;
}
}
} else if (theID == SketchPlugin_Constraint::FLYOUT_VALUE_PNT() && !myFlyoutUpdate) {
- myFlyoutUpdate = true;
// Recalculate flyout point in local coordinates of the distance constraint:
// the X coordinate is a length of projection of the flyout point on the
// line binding two distanced points
if (aEndPnt->distance(aStartPnt) < tolerance)
return;
+ myFlyoutUpdate = true;
std::shared_ptr<GeomAPI_Dir2d> aLineDir(new GeomAPI_Dir2d(aEndPnt->decreased(aStartPnt)));
std::shared_ptr<GeomAPI_XY> aFlyoutDir = aFlyoutPnt->xy()->decreased(aStartPnt);
/// Returns the AIS preview
SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
- /// Moves the feature
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
-
/// Called on change of any argument-attribute of this object
/// \param theID identifier of changed attribute
SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
/// Check the attributes related to distanced points/features are initialized
bool areAttributesInitialized();
-private:
+protected:
bool myFlyoutUpdate; ///< to avoid cyclic dependencies on automatic updates of flyout point
};
return anAIS;
}
-//*************************************************************************************
-void SketchPlugin_ConstraintDistanceHorizontal::move(double theDeltaX, double theDeltaY)
-{
- std::shared_ptr<ModelAPI_Data> aData = data();
- if (!aData->isValid())
- return;
-
- // Recalculate a shift of flyout point in terms of local coordinates
- std::shared_ptr<GeomAPI_XY> aDir(new GeomAPI_XY(theDeltaX, theDeltaY));
- std::shared_ptr<GeomAPI_Ax3> aPlane = SketchPlugin_Sketch::plane(sketch());
- std::shared_ptr<GeomDataAPI_Point2D> aPointA = SketcherPrs_Tools::getFeaturePoint(
- data(), SketchPlugin_Constraint::ENTITY_A(), aPlane);
- std::shared_ptr<GeomDataAPI_Point2D> aPointB = SketcherPrs_Tools::getFeaturePoint(
- data(), SketchPlugin_Constraint::ENTITY_B(), aPlane);
-
- if (!aPointA || !aPointB)
- return;
-
- std::shared_ptr<GeomAPI_XY> aStartPnt = aPointA->pnt()->xy();
- std::shared_ptr<GeomAPI_XY> aEndPnt = aPointB->pnt()->xy();
-
- std::shared_ptr<GeomAPI_Dir2d> aLineDir(new GeomAPI_Dir2d(aEndPnt->decreased(aStartPnt)));
- double dX = aDir->dot(aLineDir->xy());
- double dY = -aDir->cross(aLineDir->xy());
-
- std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
- myFlyoutUpdate = true;
- if (aPoint->isInitialized()) {
- aPoint->setValue(aPoint->x() + dX, aPoint->y() + dY);
- } else {
- aPoint->setValue(dX, dY);
- }
- myFlyoutUpdate = false;
-}
-
double SketchPlugin_ConstraintDistanceHorizontal::calculateCurrentDistance()
{
std::shared_ptr<ModelAPI_Data> aData = data();
aValueAttr->setValue(aDistance);
}
} else if (theID == SketchPlugin_Constraint::FLYOUT_VALUE_PNT() && !myFlyoutUpdate) {
- myFlyoutUpdate = true;
// Recalculate flyout point in local coordinates of the distance constraint:
// the X coordinate is a length of projection of the flyout point on the
// line binding two distanced points
std::shared_ptr<GeomAPI_XY> aStartPnt = aPointA->pnt()->xy();
std::shared_ptr<GeomAPI_XY> aEndPnt = aPointB->pnt()->xy();
-
if (aEndPnt->distance(aStartPnt) < tolerance)
return;
- std::shared_ptr<GeomAPI_Dir2d> aLineDir(new GeomAPI_Dir2d(aEndPnt->decreased(aStartPnt)));
- std::shared_ptr<GeomAPI_XY> aFlyoutDir = aFlyoutPnt->xy()->decreased(aStartPnt);
-
- double X = aFlyoutDir->dot(aLineDir->xy());
- double Y = -aFlyoutDir->cross(aLineDir->xy());
+ myFlyoutUpdate = true;
+ std::shared_ptr<GeomAPI_XY> aFlyoutDir = aFlyoutPnt->xy()->decreased(aEndPnt);
+ double X = aFlyoutDir->x(); // Dot on OX axis
+ double Y = aFlyoutDir->y(); // Cross to OX axis
aFlyoutAttr->setValue(X, Y);
myFlyoutUpdate = false;
}
/// Returns the AIS preview
SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
- /// Moves the feature
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
-
/// Called on change of any argument-attribute of this object
/// \param theID identifier of changed attribute
SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
protected:
/// Returns the current distance between the feature attributes
virtual double calculateCurrentDistance();
-
-private:
- bool myFlyoutUpdate; ///< to avoid cyclic dependencies on automatic updates of flyout point
};
#endif
return anAIS;
}
-//*************************************************************************************
-void SketchPlugin_ConstraintDistanceVertical::move(double theDeltaX, double theDeltaY)
-{
- std::shared_ptr<ModelAPI_Data> aData = data();
- if (!aData->isValid())
- return;
-
- // Recalculate a shift of flyout point in terms of local coordinates
- std::shared_ptr<GeomAPI_XY> aDir(new GeomAPI_XY(theDeltaX, theDeltaY));
- std::shared_ptr<GeomAPI_Ax3> aPlane = SketchPlugin_Sketch::plane(sketch());
- std::shared_ptr<GeomDataAPI_Point2D> aPointA = SketcherPrs_Tools::getFeaturePoint(
- data(), SketchPlugin_Constraint::ENTITY_A(), aPlane);
- std::shared_ptr<GeomDataAPI_Point2D> aPointB = SketcherPrs_Tools::getFeaturePoint(
- data(), SketchPlugin_Constraint::ENTITY_B(), aPlane);
-
- if (!aPointA || !aPointB)
- return;
-
- std::shared_ptr<GeomAPI_XY> aStartPnt = aPointA->pnt()->xy();
- std::shared_ptr<GeomAPI_XY> aEndPnt = aPointB->pnt()->xy();
-
- std::shared_ptr<GeomAPI_Dir2d> aLineDir(new GeomAPI_Dir2d(aEndPnt->decreased(aStartPnt)));
- double dX = aDir->dot(aLineDir->xy());
- double dY = -aDir->cross(aLineDir->xy());
-
- std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
- myFlyoutUpdate = true;
- if (aPoint->isInitialized()) {
- aPoint->setValue(aPoint->x() + dX, aPoint->y() + dY);
- } else {
- aPoint->setValue(dX, dY);
- }
- myFlyoutUpdate = false;
-}
-
double SketchPlugin_ConstraintDistanceVertical::calculateCurrentDistance()
{
std::shared_ptr<ModelAPI_Data> aData = data();
aValueAttr->setValue(aDistance);
}
} else if (theID == SketchPlugin_Constraint::FLYOUT_VALUE_PNT() && !myFlyoutUpdate) {
- myFlyoutUpdate = true;
// Recalculate flyout point in local coordinates of the distance constraint:
// the X coordinate is a length of projection of the flyout point on the
// line binding two distanced points
if (aEndPnt->distance(aStartPnt) < tolerance)
return;
- std::shared_ptr<GeomAPI_Dir2d> aLineDir(new GeomAPI_Dir2d(aEndPnt->decreased(aStartPnt)));
- std::shared_ptr<GeomAPI_XY> aFlyoutDir = aFlyoutPnt->xy()->decreased(aStartPnt);
-
- double X = aFlyoutDir->dot(aLineDir->xy());
- double Y = -aFlyoutDir->cross(aLineDir->xy());
+ std::shared_ptr<GeomAPI_XY> aFlyoutDir = aFlyoutPnt->xy()->decreased(aEndPnt);
+ myFlyoutUpdate = true;
+ double X = aFlyoutDir->y(); // Dot on OY axis
+ double Y = -aFlyoutDir->x(); // Cross to OY axis
aFlyoutAttr->setValue(X, Y);
myFlyoutUpdate = false;
}
/// Returns the AIS preview
SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
- /// Moves the feature
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
-
/// Called on change of any argument-attribute of this object
/// \param theID identifier of changed attribute
SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
protected:
/// Returns the current distance between the feature attributes
virtual double calculateCurrentDistance();
-
-private:
- bool myFlyoutUpdate; ///< to avoid cyclic dependencies on automatic updates of flyout point
};
#endif
return anAIS;
}
-void SketchPlugin_ConstraintLength::move(double theDeltaX, double theDeltaY)
-{
- std::shared_ptr<ModelAPI_Data> aData = data();
- if (!aData->isValid())
- return;
-
- AttributeRefAttrPtr aLineAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
- attribute(SketchPlugin_Constraint::ENTITY_A()));
- if (!aLineAttr || !aLineAttr->isObject())
- return;
- FeaturePtr aLine = ModelAPI_Feature::feature(aLineAttr->object());
- if (!aLine || aLine->getKind() != SketchPlugin_Line::ID())
- return;
-
- // Recalculate a shift of flyout point in terms of local coordinates
- std::shared_ptr<GeomAPI_XY> aDir(new GeomAPI_XY(theDeltaX, theDeltaY));
- std::shared_ptr<GeomAPI_XY> aStartPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aLine->attribute(SketchPlugin_Line::START_ID()))->pnt()->xy();
- std::shared_ptr<GeomAPI_XY> aEndPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aLine->attribute(SketchPlugin_Line::END_ID()))->pnt()->xy();
- std::shared_ptr<GeomAPI_Dir2d> aLineDir(new GeomAPI_Dir2d(aEndPnt->decreased(aStartPnt)));
- double dX = aDir->dot(aLineDir->xy());
- double dY = -aDir->cross(aLineDir->xy());
-
- myFlyoutUpdate = true;
- std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
- aPoint->setValue(aPoint->x() + dX, aPoint->y() + dY);
- myFlyoutUpdate = false;
-}
-
void SketchPlugin_ConstraintLength::attributeChanged(const std::string& theID) {
if (theID == SketchPlugin_Constraint::ENTITY_A())
{
aValueAttr->setValue(aLength);
}
} else if (theID == SketchPlugin_Constraint::FLYOUT_VALUE_PNT() && !myFlyoutUpdate) {
- myFlyoutUpdate = true;
// Recalculate flyout point in local coordinates of the line:
// the X coordinate is a length of projection of the flyout point on the line
// the Y coordinate is a distance from the point to the line
std::shared_ptr<GeomAPI_XY> aEndPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aLine->attribute(SketchPlugin_Line::END_ID()))->pnt()->xy();
+ myFlyoutUpdate = true;
std::shared_ptr<GeomAPI_Dir2d> aLineDir(new GeomAPI_Dir2d(aEndPnt->decreased(aStartPnt)));
std::shared_ptr<GeomAPI_XY> aFlyoutDir = aFlyoutPnt->xy()->decreased(aStartPnt);
double X = aFlyoutDir->dot(aLineDir->xy());
#include <list>
+class GeomAPI_Pnt2d;
class GeomDataAPI_Point2D;
/** \class SketchPlugin_ConstraintLength
/// Returns the AIS preview
SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
- /// Moves the feature
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
-
/// Called on change of any argument-attribute of this object
/// \param theID identifier of changed attribute
SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
return anAIS;
}
-void SketchPlugin_ConstraintRadius::move(double theDeltaX, double theDeltaY)
-{
- std::shared_ptr<ModelAPI_Data> aData = data();
- if (!aData->isValid())
- return;
-
- myFlyoutUpdate = true;
- std::shared_ptr<GeomDataAPI_Point2D> aFlyoutAttr = std::dynamic_pointer_cast<
- GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
- aFlyoutAttr->setValue(aFlyoutAttr->x() + theDeltaX, aFlyoutAttr->y() + theDeltaY);
- myFlyoutUpdate = false;
-}
-
void SketchPlugin_ConstraintRadius::attributeChanged(const std::string& theID) {
if (theID == SketchPlugin_Constraint::ENTITY_A()) {
std::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = std::dynamic_pointer_cast<
/// Returns the AIS preview
SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
- /// Moves the feature
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
-
/// Called on change of any argument-attribute of this object
/// \param theID identifier of changed attribute
SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
setResult(aResult, 1);
}
-void SketchPlugin_Ellipse::move(double theDeltaX, double theDeltaY)
-{
- std::shared_ptr<ModelAPI_Data> aData = data();
- if(!aData->isValid()) {
- return;
- }
-
- std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aData->attribute(CENTER_ID()));
- if(aPoint->isInitialized()) {
- aPoint->move(theDeltaX, theDeltaY);
- }
-}
-
bool SketchPlugin_Ellipse::isFixed() {
return data()->selection(EXTERNAL_ID())->context().get() != NULL;
}
/// Creates a new part document if needed
SKETCHPLUGIN_EXPORT virtual void execute();
- /// Moves the feature
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
-
/// Use plugin manager for features creation
SketchPlugin_Ellipse();
return true;
}
- /// Moves the feature
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) = 0;
-
/// Construction result is allways recomuted on the fly
SKETCHPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
}
}
-void SketchPlugin_IntersectionPoint::move(double theDeltaX, double theDeltaY)
-{
-}
-
void SketchPlugin_IntersectionPoint::attributeChanged(const std::string& theID)
{
if (theID == EXTERNAL_LINE_ID()) {
/// Creates a new part document if needed
SKETCHPLUGIN_EXPORT virtual void execute();
- /// Moves the feature
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
-
/// Called on change of any argument-attribute of this object: for external point
SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
}
}
-void SketchPlugin_Line::move(double theDeltaX, double theDeltaY)
-{
- std::shared_ptr<ModelAPI_Data> aData = data();
- if (!aData->isValid())
- return;
-
- std::shared_ptr<GeomDataAPI_Point2D> aPoint1 = std::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aData->attribute(START_ID()));
- aPoint1->move(theDeltaX, theDeltaY);
-
- std::shared_ptr<GeomDataAPI_Point2D> aPoint2 = std::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aData->attribute(END_ID()));
- aPoint2->move(theDeltaX, theDeltaY);
-}
-
std::string SketchPlugin_Line::processEvent(const std::shared_ptr<Events_Message>& theMessage)
{
std::string aFilledAttributeName;
/// Creates a new part document if needed
SKETCHPLUGIN_EXPORT virtual void execute();
- /// Moves the feature
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
-
/// Apply information of the message to current object. It fills start attribute of
/// the currrent feature by last attribute of the message feature, build coincidence
/// if message has selected object
/// Creates an arc-shape
SKETCHPLUGIN_EXPORT virtual void execute();
- /// Moves the feature
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY)
- {
- };
-
/// Reimplemented from ModelAPI_Feature::isMacro().
SKETCHPLUGIN_EXPORT virtual bool isMacro() const {return true;};
/// Creates a new part document if needed
SKETCHPLUGIN_EXPORT virtual void execute();
- /// Moves the feature
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY)
- {};
-
/// Reimplemented from ModelAPI_Feature::isMacro().
/// \returns true
SKETCHPLUGIN_EXPORT virtual bool isMacro() const {return true;};
/// Creates a new part document if needed
SKETCHPLUGIN_EXPORT virtual void execute();
- /// Moves the feature
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY)
- {}
-
/// Reimplemented from ModelAPI_Feature::isMacro().
/// \returns true
SKETCHPLUGIN_EXPORT virtual bool isMacro() const
}
}
-void SketchPlugin_Point::move(double theDeltaX, double theDeltaY)
-{
- std::shared_ptr<ModelAPI_Data> aData = data();
- if (!aData->isValid())
- return;
-
- std::shared_ptr<GeomDataAPI_Point2D> aPoint1 = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aData->attribute(SketchPlugin_Point::COORD_ID()));
- aPoint1->move(theDeltaX, theDeltaY);
-}
-
bool SketchPlugin_Point::isFixed() {
return data()->selection(EXTERNAL_ID())->context().get() != NULL;
}
/// Creates a new part document if needed
SKETCHPLUGIN_EXPORT virtual void execute();
- /// Moves the feature
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
-
/// Called on change of any argument-attribute of this object: for external point
SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
computeProjection(EXTERNAL_FEATURE_ID());
}
-void SketchPlugin_Projection::move(double theDeltaX, double theDeltaY)
-{
- // feature cannot be moved
-}
-
void SketchPlugin_Projection::attributeChanged(const std::string& theID)
{
if ((theID == EXTERNAL_FEATURE_ID() || theID == EXTERNAL_ID()) && !myIsComputing) {
/// Creates a new part document if needed
SKETCHPLUGIN_EXPORT virtual void execute();
- /// Moves the feature
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
-
/// Called on change of any argument-attribute of this object: for external point
SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
/// Request for initialization of data model of the feature: adding all attributes
SKETCHPLUGIN_EXPORT virtual void initAttributes();
- /// Moves the feature
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY)
- {
- }
-
/// Converts a 2D sketch space point into point in 3D space
/// \param theX an X coordinate
/// \param theY an Y coordinate
/// Returns the AIS preview
SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
- /// Moves the feature : Empty
- SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) {};
-
/// Apply information of the message to current object. It fills selected point and object
virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
/// Returns the AIS preview
SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
- /// Moves the feature : Empty
- SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) {};
-
/// Apply information of the message to current object. It fills selected point and object
virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
if (!aGroup)
return false;
+ std::shared_ptr<SketchPlugin_Constraint> aConstraint =
+ std::dynamic_pointer_cast<SketchPlugin_Constraint>(theMovedFeature);
+ if (aConstraint)
+ {
+ std::shared_ptr<GeomDataAPI_Point2D> aPntAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>
+ (aConstraint->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
+ aPntAttr->setValue(theTo);
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+ return true;
+ }
+
aGroup->blockEvents(true);
return aGroup->moveFeature(theMovedFeature, theFrom, theTo);
}
const std::shared_ptr<GeomAPI_Pnt2d>& theTo)
{
FeaturePtr anOwner = ModelAPI_Feature::feature(theMovedAttribute->owner());
+ std::shared_ptr<SketchPlugin_Constraint> aConstraint =
+ std::dynamic_pointer_cast<SketchPlugin_Constraint>(anOwner);
+ if (aConstraint)
+ {
+ theMovedAttribute->setValue(theTo);
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+ return true;
+ }
+
std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
std::dynamic_pointer_cast<SketchPlugin_Feature>(anOwner);
SketchGroupPtr aGroup;
#include <AIS_DisplaySpecialSymbol.hxx>
+//#ifdef OCCT_28850_FIXED
/// Creates an aspect to be shown in length/radius dimension presentations
/// \return an instance of aspect
{
SetDimensionAspect(createDimensionAspect());
myStyleListener = new SketcherPrs_DimensionStyleListener();
+
+#ifdef OCCT_28850_FIXED
+ if (theConstraint->getKind() == SketchPlugin_ConstraintDistanceHorizontal::ID())
+ SetDirection(true, mySketcherPlane->dirX()->impl<gp_Dir>());
+ else if (theConstraint->getKind() == SketchPlugin_ConstraintDistanceVertical::ID())
+ SetDirection(true, mySketcherPlane->dirY()->impl<gp_Dir>());
+#endif
}
SketcherPrs_LengthDimension::~SketcherPrs_LengthDimension()