The PartSet presentation's functionality should be partially moved to SketchPlugin and a custom widget creation.
1. feature move() method is moved to the sketch plugin feature.
return SM_FirstPoint;
}
-void PartSet_ConstraintDistancePrs::move(double theDeltaX, double theDeltaY)
-{
-}
-
double PartSet_ConstraintDistancePrs::distanceToPoint(FeaturePtr theFeature,
double theX, double theY)
{
/// \return next attribute selection mode
virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
- /// \brief Move the full feature.
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- virtual void move(double theDeltaX, double theDeltaY);
-
/// Return the distance between the feature and the point
/// \param theFeature feature object
/// \param theX the horizontal coordinate of the point
return SM_FirstPoint;
}
-void PartSet_ConstraintLengthPrs::move(double theDeltaX, double theDeltaY)
-{
-}
-
double PartSet_ConstraintLengthPrs::distanceToPoint(FeaturePtr theFeature,
double theX, double theY)
{
/// \return next attribute selection mode
virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
- /// \brief Move the full feature.
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- virtual void move(double theDeltaX, double theDeltaY);
-
/// Return the distance between the feature and the point
/// \param theFeature feature object
/// \param theX the horizontal coordinate of the point
return SM_FirstPoint;
}
-void PartSet_ConstraintRadiusPrs::move(double theDeltaX, double theDeltaY)
-{
-}
-
double PartSet_ConstraintRadiusPrs::distanceToPoint(FeaturePtr theFeature,
double theX, double theY)
{
/// \return next attribute selection mode
virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
- /// \brief Move the full feature.
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- virtual void move(double theDeltaX, double theDeltaY);
-
/// Return the distance between the feature and the point
/// \param theFeature feature object
/// \param theX the horizontal coordinate of the point
return aMode;
}
-void PartSet_FeatureArcPrs::move(double theDeltaX, double theDeltaY)
-{
- boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
- if (!aData->isValid())
- return;
-
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_CENTER));
- aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
-
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_START));
- aPoint2->setValue(aPoint2->x() + theDeltaX, aPoint2->y() + theDeltaY);
-
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint3 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_END));
- aPoint3->setValue(aPoint3->x() + theDeltaX, aPoint3->y() + theDeltaY);
-}
-
double PartSet_FeatureArcPrs::distanceToPoint(FeaturePtr theFeature,
double theX, double theY)
{
static void projectPointOnFeature(FeaturePtr theFeature, FeaturePtr theSketch, gp_Pnt& thePoint,
Handle_V3d_View theView, double& theX, double& theY);
- /// \brief Move the full feature.
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- virtual void move(double theDeltaX, double theDeltaY);
-
/// Return the distance between the feature and the point
/// \param theFeature feature object
/// \param theX the horizontal coordinate of the point
return aMode;
}
-void PartSet_FeatureCirclePrs::move(double theDeltaX, double theDeltaY)
-{
- boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
- if (!aData->isValid())
- return;
-
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(CIRCLE_ATTR_CENTER));
- aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
-}
-
double PartSet_FeatureCirclePrs::distanceToPoint(FeaturePtr theFeature,
double theX, double theY)
{
/// \return next attribute selection mode
virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
- /// \brief Move the full feature.
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- virtual void move(double theDeltaX, double theDeltaY);
-
/// Return the distance between the feature and the point
/// \param theFeature feature object
/// \param theX the horizontal coordinate of the point
return aMode;
}
-void PartSet_FeatureLinePrs::move(double theDeltaX, double theDeltaY)
-{
- boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
- if (!aData->isValid())
- return;
-
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
- aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
-
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
- aPoint2->setValue(aPoint2->x() + theDeltaX, aPoint2->y() + theDeltaY);
-}
-
void PartSet_FeatureLinePrs::projectPointOnLine(FeaturePtr theFeature,
const PartSet_SelectionMode& theMode,
const gp_Pnt& thePoint, Handle(V3d_View) theView,
/// \return next attribute selection mode
virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
- /// \brief Move the full feature.
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- virtual void move(double theDeltaX, double theDeltaY);
-
/// Project the point on a feature
/// \param theFeature the feature to be projected on
/// \param theMode the selection mode
return aMode;
}
-void PartSet_FeaturePointPrs::move(double theDeltaX, double theDeltaY)
-{
- boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
- if (!aData->isValid())
- return;
-
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(POINT_ATTR_COORD));
- aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
-}
-
double PartSet_FeaturePointPrs::distanceToPoint(FeaturePtr theFeature,
double theX, double theY)
{
/// \return next attribute selection mode
virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
- /// \brief Move the full feature.
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- virtual void move(double theDeltaX, double theDeltaY);
-
/// Return the distance between the feature and the point
/// \param theFeature feature object
/// \param theX the horizontal coordinate of the point
/// \return next attribute selection mode
virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const = 0;
- /// \brief Move the full feature.
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- virtual void move(double theDeltaX, double theDeltaY) = 0;
-
/// Return the distance between the feature and the point
/// \param theFeature feature object
/// \param theX the horizontal coordinate of the point
double aX, anY;
PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
- /*double aDeltaX = aX - aCurX;
- double aDeltaY = anY - aCurY;
- PartSet_Tools::moveFeature(feature(), aDeltaX, aDeltaY);*/
if (feature()->getKind() == PartSet_ConstraintRadiusPrs::getKind()) {
boost::shared_ptr<PartSet_ConstraintRadiusPrs> anArcPrs =
boost::dynamic_pointer_cast<PartSet_ConstraintRadiusPrs>(myFeaturePrs);
}
}
myFeaturePrs->setPoint(aX, anY, SM_LastPoint);
-
-
- /*std::list<XGUI_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
- for (; anIt != aLast; anIt++) {
- FeaturePtr aFeature = (*anIt).feature();
- if (!aFeature || aFeature == feature())
- continue;
- PartSet_Tools::moveFeature(aFeature, aDeltaX, aDeltaY);
- }*/
}
sendFeatures();
double aDeltaX = aX - aCurX;
double aDeltaY = anY - aCurY;
- PartSet_Tools::moveFeature(feature(), aDeltaX, aDeltaY);
+ boost::shared_ptr<SketchPlugin_Feature> aSketchFeature =
+ boost::dynamic_pointer_cast<SketchPlugin_Feature>(feature());
+ aSketchFeature->move(aDeltaX, aDeltaY);
std::list<XGUI_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
for (; anIt != aLast; anIt++) {
FeaturePtr aFeature = (*anIt).feature();
if (!aFeature || aFeature == feature())
continue;
- PartSet_Tools::moveFeature(aFeature, aDeltaX, aDeltaY);
+ aSketchFeature = boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+ aSketchFeature->move(aDeltaX, aDeltaY);
}
}
sendFeatures();
return aDelta;
}
-void PartSet_Tools::moveFeature(FeaturePtr theFeature, double theDeltaX, double theDeltaY)
-{
- if (!theFeature)
- return;
-
- boost::shared_ptr<PartSet_FeaturePrs> aFeaturePrs = PartSet_Tools::createFeaturePrs(
- theFeature->getKind(), FeaturePtr(), theFeature);
- if (aFeaturePrs)
- aFeaturePrs->move(theDeltaX, theDeltaY);
-}
-
boost::shared_ptr<ModelAPI_Document> PartSet_Tools::document()
{
return ModelAPI_PluginManager::get()->rootDocument();
static FeaturePtr nearestFeature(QPoint thePoint, Handle_V3d_View theView, FeaturePtr theSketch,
const std::list<XGUI_ViewerPrs>& theFeatures);
- /// \brief Move the feature.
- /// \param theFeature the source feature
- /// \param theDeltaX the delta for X coordinate is moved
- /// \param theDeltaY the delta for Y coordinate is moved
- static void moveFeature(FeaturePtr theFeature, double theDeltaX, double theDeltaY);
-
/// Returns pointer to the root document.
static boost::shared_ptr<ModelAPI_Document> document();
}
return getPreview();
}
+
+void SketchPlugin_Arc::move(double theDeltaX, double theDeltaY)
+{
+ boost::shared_ptr<ModelAPI_Data> aData = data();
+ if (!aData->isValid())
+ return;
+
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_CENTER));
+ aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
+
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_START));
+ aPoint2->setValue(aPoint2->x() + theDeltaX, aPoint2->y() + theDeltaY);
+
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint3 =
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_END));
+ aPoint3->setValue(aPoint3->x() + theDeltaX, aPoint3->y() + theDeltaY);
+}
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);
+
/// Use plugin manager for features creation
SketchPlugin_Arc();
};
}
return getPreview();
}
+
+void SketchPlugin_Circle::move(double theDeltaX, double theDeltaY)
+{
+ boost::shared_ptr<ModelAPI_Data> aData = data();
+ if (!aData->isValid())
+ return;
+
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(CIRCLE_ATTR_CENTER));
+ aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
+}
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);
+
/// Use plugin manager for features creation
SketchPlugin_Circle();
};
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) {};
+
protected:
/// \brief Use plugin manager for features creation
SketchPlugin_Constraint() {}
/// Returns true if this feature must be displayed in the history (top level of Part tree)
SKETCHPLUGIN_EXPORT virtual bool isInHistory() {return false;}
+ /// 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;
+
protected:
/// Set the shape to the internal preview field
/// \param theShape a preview shape
}
return getPreview();
}
+
+void SketchPlugin_Line::move(double theDeltaX, double theDeltaY)
+{
+ boost::shared_ptr<ModelAPI_Data> aData = data();
+ if (!aData->isValid())
+ return;
+
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
+ aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
+
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
+ aPoint2->setValue(aPoint2->x() + theDeltaX, aPoint2->y() + theDeltaY);
+}
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);
+
/// Use plugin manager for features creation
SketchPlugin_Line();
};
}
return getPreview();
}
+
+void SketchPlugin_Point::move(double theDeltaX, double theDeltaY)
+{
+ boost::shared_ptr<ModelAPI_Data> aData = data();
+ if (!aData->isValid())
+ return;
+
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(POINT_ATTR_COORD));
+ aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
+}
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);
+
/// Use plugin manager for features creation
SketchPlugin_Point();
};
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) {};
+
/// Converts a 2D sketch space point into point in 3D space
SKETCHPLUGIN_EXPORT boost::shared_ptr<GeomAPI_Pnt> to3D(
const double theX, const double theY);