return theFeature->data()->attribute(attributeID())->isInitialized();
}
-bool ModuleBase_ModelWidget::canFocusTo(const std::string& theAttributeName) const
-{
- return theAttributeName == attributeID();
-}
-
-void ModuleBase_ModelWidget::focusTo()
+bool ModuleBase_ModelWidget::focusTo()
{
QList<QWidget*> aControls = getControls();
QList<QWidget*>::const_iterator anIt = aControls.begin(), aLast = aControls.end();
break;
}
}
+ return true;
}
std::string ModuleBase_ModelWidget::attributeID() const
virtual bool restoreValue(FeaturePtr theFeature) = 0;
- /// Returns whether the widget can accept focus, or if it corresponds to the given attribute
- /// \param theAttribute name
- bool canFocusTo(const std::string& theAttributeName) const;
-
/// Set focus to the first control of the current widget. The focus policy of the control is checked.
/// If the widget has the NonFocus focus policy, it is skipped.
- virtual void focusTo();
+ /// \return the state whether the widget can accept the focus
+ virtual bool focusTo();
/// Returns list of widget controls
/// \return a control list
QString aLabelText = QString::fromStdString(theData->widgetLabel());
QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
myLabel = new QLabel(aLabelText, myContainer);
- myLabel->setPixmap(QPixmap(aLabelIcon));
+ if (!aLabelIcon.isEmpty())
+ myLabel->setPixmap(QPixmap(aLabelIcon));
aControlLay->addWidget(myLabel);
mySpinBox = new QDoubleSpinBox(myContainer);
{
if (theObject == mySpinBox) {
if (theEvent->type() == QEvent::KeyRelease) {
+ QKeyEvent* aKeyEvent = (QKeyEvent*)theEvent;
+ if (aKeyEvent && aKeyEvent->key() == Qt::Key_Return) {
+ emit focusOutWidget(this);
+ }
emit keyReleased(attributeID(), (QKeyEvent*) theEvent);
return true;
}
return aValue;
}
-void ModuleBase_WidgetEditor::focusTo()
+bool ModuleBase_WidgetEditor::focusTo()
{
double aValue = mySpinBox->value();
bool isDone;
}
emit valuesChanged();
emit focusOutWidget(this);
+
+ return false;
}
void ModuleBase_WidgetEditor::editFeatureValue(FeaturePtr theFeature, const std::string theAttribute)
/// Set focus to the first control of the current widget. The focus policy of the control is checked.
/// If the widget has the NonFocus focus policy, it is skipped.
- virtual void focusTo();
+ /// \return the state whether the widget can accept the focus
+ virtual bool focusTo();
/// Creates an editor for the real value and set the new value to the feature
/// \param theFeature the model feature
{
if (theObject == myXSpin || theObject == myYSpin) {
if (theEvent->type() == QEvent::KeyRelease) {
+ QKeyEvent* aKeyEvent = (QKeyEvent*)theEvent;
+ if (aKeyEvent && aKeyEvent->key() == Qt::Key_Return) {
+ emit focusOutWidget(this);
+ }
emit keyReleased(attributeID(), (QKeyEvent*) theEvent);
return true;
}
SET(PROJECT_HEADERS
PartSet.h
PartSet_Constants.h
- PartSet_ConstraintDistancePrs.h
- PartSet_ConstraintLengthPrs.h
- PartSet_ConstraintRadiusPrs.h
PartSet_EditLine.h
- PartSet_FeatureArcPrs.h
- PartSet_FeatureCirclePrs.h
- PartSet_FeaturePrs.h
- PartSet_FeatureLinePrs.h
- PartSet_FeaturePointPrs.h
PartSet_Listener.h
PartSet_Module.h
PartSet_OperationFeatureCreate.h
)
SET(PROJECT_SOURCES
- PartSet_ConstraintDistancePrs.cpp
- PartSet_ConstraintLengthPrs.cpp
- PartSet_ConstraintRadiusPrs.cpp
PartSet_EditLine.cpp
- PartSet_FeaturePrs.cpp
- PartSet_FeatureArcPrs.cpp
- PartSet_FeatureCirclePrs.cpp
- PartSet_FeatureLinePrs.cpp
- PartSet_FeaturePointPrs.cpp
PartSet_Listener.cpp
PartSet_Module.cpp
PartSet_OperationFeatureCreate.cpp
/// This file contains various constants used in the PartSet module
-/// Types of viewer selection in an operation
-enum PartSet_SelectionMode
-{
- SM_FirstPoint,
- SM_SecondPoint,
- SM_ThirdPoint,
- SM_LastPoint,
- SM_DonePoint
-};
-
////const int CONSTRAINT_TEXT_HEIGHT = 28; /// the text height of the constraint
////const int CONSTRAINT_TEXT_SELECTION_TOLERANCE = 20; /// the text selection tolerance
+++ /dev/null
-// File: PartSet_FeaturePrs.h
-// Created: 16 Jun 2014
-// Author: Natalia ERMOLAEVA
-
-#include <PartSet_ConstraintDistancePrs.h>
-#include <PartSet_Tools.h>
-
-#include <PartSet_FeatureLinePrs.h>
-
-#include <SketchPlugin_Feature.h>
-#include <SketchPlugin_Sketch.h>
-#include <SketchPlugin_Line.h>
-#include <SketchPlugin_Point.h>
-#include <SketchPlugin_ConstraintDistance.h>
-
-#include <GeomDataAPI_Point2D.h>
-#include <GeomAPI_Pnt2d.h>
-#include <GeomAPI_Lin2d.h>
-#include <GeomAPI_Pln.h>
-
-#include <ModelAPI_Data.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_AttributeRefAttr.h>
-#include <ModelAPI_AttributeRefList.h>
-#include <ModelAPI_AttributeDouble.h>
-
-#include <AIS_InteractiveObject.hxx>
-#include <AIS_LengthDimension.hxx>
-
-#include <Precision.hxx>
-#include <gp_Pln.hxx>
-
-using namespace std;
-
-PartSet_ConstraintDistancePrs::PartSet_ConstraintDistancePrs(FeaturePtr theSketch)
-: PartSet_FeaturePrs(theSketch)
-{
-}
-
-std::string PartSet_ConstraintDistancePrs::getKind()
-{
- return SKETCH_CONSTRAINT_DISTANCE_KIND;
-}
-
-PartSet_SelectionMode PartSet_ConstraintDistancePrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
-{
- PartSet_SelectionMode aMode = theMode;
- if (!feature() || !theFeature)
- return aMode;
-
- std::string anArgument;
- if (theMode == SM_FirstPoint) {
- anArgument = CONSTRAINT_ATTR_ENTITY_A;
- aMode = SM_SecondPoint;
- }
- else if (theMode == SM_SecondPoint) {
- anArgument = CONSTRAINT_ATTR_ENTITY_B;
- aMode = SM_LastPoint;
- }
- if (theFeature->getKind() == SKETCH_POINT_KIND)
- {
- // set length feature
- boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
- boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(anArgument));
- aRef->setFeature(theFeature);
- }
-
- if (theMode == SM_SecondPoint) {
- // set length value
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint_A = getFeaturePoint(feature(), CONSTRAINT_ATTR_ENTITY_A);
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint_B = getFeaturePoint(feature(), CONSTRAINT_ATTR_ENTITY_B);
-
- if (aPoint_A && aPoint_B) {
- double aLenght = aPoint_A->pnt()->distance(aPoint_B->pnt());
- PartSet_Tools::setFeatureValue(feature(), aLenght, CONSTRAINT_ATTR_VALUE);
- }
- }
-
- return aMode;
-}
-
-PartSet_SelectionMode PartSet_ConstraintDistancePrs::setPoint(double theX, double theY,
- const PartSet_SelectionMode& theMode)
-{
- PartSet_SelectionMode aMode = theMode;
- switch (theMode)
- {
- case SM_LastPoint: {
- boost::shared_ptr<GeomDataAPI_Point2D> aFlyOutAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(feature()->data()->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT));
- aFlyOutAttr->setValue(boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY)));
-
- boost::shared_ptr<GeomAPI_Pnt2d> aFlyOutPnt = aFlyOutAttr->pnt();
-
- aMode = SM_DonePoint;
- }
- break;
- default:
- break;
- }
- return aMode;
-}
-
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_ConstraintDistancePrs::getFeaturePoint
- (FeaturePtr theFeature,
- const std::string& theAttribute)
-{
- boost::shared_ptr<GeomDataAPI_Point2D> aPointAttr;
-
- FeaturePtr aFeature = PartSet_Tools::feature(theFeature, theAttribute, SKETCH_POINT_KIND);
- if (aFeature)
- aPointAttr = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aFeature->data()->attribute(POINT_ATTR_COORD));
- return aPointAttr;
-}
-
-std::string PartSet_ConstraintDistancePrs::getAttribute(const PartSet_SelectionMode& theMode) const
-{
- return "";
-}
-
-PartSet_SelectionMode PartSet_ConstraintDistancePrs::getNextMode(const std::string& theAttribute) const
-{
- return SM_FirstPoint;
-}
-
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_ConstraintDistancePrs::featurePoint
- (const PartSet_SelectionMode& theMode)
-{
- return boost::shared_ptr<GeomDataAPI_Point2D>();
-}
+++ /dev/null
-// File: PartSet_ConstraintDistancePrs.h
-// Created: 16 Jun 2014
-// Author: Natalia ERMOLAEVA
-
-#ifndef PartSet_ConstraintDistancePrs_H
-#define PartSet_ConstraintDistancePrs_H
-
-#include "PartSet.h"
-
-#include "PartSet_FeaturePrs.h"
-#include "PartSet_Constants.h"
-
-class GeomDataAPI_Point2D;
-class Handle_AIS_InteractiveObject;
-
-/*!
- \class PartSet_ConstraintDistancePrs
- * \brief The class to define the circle feature manipulation. It is created for
- * the feature create operation to move out the feature properties set and use one operation
- * for any type of features.
-*/
-class PARTSET_EXPORT PartSet_ConstraintDistancePrs : public PartSet_FeaturePrs
-{
-public:
- /// Returns the feature type processed by this presentation
- /// \return the feature kind
- static std::string getKind();
-
- /// Constructor
- /// \param theSketch the sketch feature
- PartSet_ConstraintDistancePrs(FeaturePtr theSketch);
- /// Destructor
- virtual ~PartSet_ConstraintDistancePrs() {};
-
- /// Sets the feature to to a feature attribute depending on the selection mode
- /// \param theFeature a feature instance
- /// \param theMode the selection mode
- /// \return whether the feature is set
- virtual PartSet_SelectionMode setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode);
-
- /// Sets the point to the feature in an attribute depending on the selection mode
- /// \param theX the 2D point horizontal coordinate
- /// \param theY the 2D point vertical coordinate
- /// \param theMode the selection mode
- /// \return the new selection mode
- virtual PartSet_SelectionMode setPoint(double theX, double theY,
- const PartSet_SelectionMode& theMode);
-
- /// Returns the feature attribute name for the selection mode
- /// \param theMode the current operation selection mode. The feature attribute depends on the mode
- virtual std::string getAttribute(const PartSet_SelectionMode& theMode) const;
-
- /// Returns the next selection mode after the attribute
- /// \param theAttribute the feature attribute name
- /// \return next attribute selection mode
- virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
-
-protected:
- /// Returns the feature point in the selection mode position.
- /// \param theMode the current operation selection mode. The feature attribute depends on the mode
- virtual boost::shared_ptr<GeomDataAPI_Point2D> featurePoint(const PartSet_SelectionMode& theMode);
-
-private:
- /// Find the feature point
- /// \param theFeature the constraint feature
- /// \param theAttribute a distance constraint attribute name of feature
- /// \return the point in the feature
- static boost::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(FeaturePtr theFeature,
- const std::string& theAttribute);
-};
-
-#endif
+++ /dev/null
-// File: PartSet_FeaturePrs.h
-// Created: 16 Jun 2014
-// Author: Natalia ERMOLAEVA
-
-#include <PartSet_ConstraintLengthPrs.h>
-#include <PartSet_Tools.h>
-#include <PartSet_Constants.h>
-
-#include <PartSet_FeatureLinePrs.h>
-
-#include <SketchPlugin_Feature.h>
-#include <SketchPlugin_Sketch.h>
-#include <SketchPlugin_Line.h>
-#include <SketchPlugin_ConstraintLength.h>
-
-#include <GeomDataAPI_Point.h>
-#include <GeomDataAPI_Point2D.h>
-#include <GeomDataAPI_Dir.h>
-#include <GeomAPI_Pnt2d.h>
-#include <GeomAPI_Lin2d.h>
-#include <GeomAPI_Pln.h>
-
-#include <AIS_InteractiveObject.hxx>
-#include <AIS_LengthDimension.hxx>
-
-#include <ModelAPI_Data.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_AttributeRefAttr.h>
-#include <ModelAPI_AttributeRefList.h>
-#include <ModelAPI_AttributeDouble.h>
-
-#include <AIS_InteractiveObject.hxx>
-#include <gp_Pln.hxx>
-#include <gp_Pnt.hxx>
-#include <Precision.hxx>
-
-using namespace std;
-
-PartSet_ConstraintLengthPrs::PartSet_ConstraintLengthPrs(FeaturePtr theSketch)
-: PartSet_FeaturePrs(theSketch)
-{
-}
-
-std::string PartSet_ConstraintLengthPrs::getKind()
-{
- return SKETCH_CONSTRAINT_LENGTH_KIND;
-}
-
-PartSet_SelectionMode PartSet_ConstraintLengthPrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
-{
- PartSet_SelectionMode aMode = theMode;
- if (feature() && theFeature && theFeature->getKind() == SKETCH_LINE_KIND && theMode == SM_FirstPoint)
- {
- // set length feature
- boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
- boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
- aRef->setFeature(theFeature);
-
- // set length value
- aData = theFeature->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
-
- double aLenght = aPoint1->pnt()->distance(aPoint2->pnt());
- PartSet_Tools::setFeatureValue(feature(), aLenght, CONSTRAINT_ATTR_VALUE);
- aMode = SM_LastPoint;
- }
- return aMode;
-}
-
-PartSet_SelectionMode PartSet_ConstraintLengthPrs::setPoint(double theX, double theY,
- const PartSet_SelectionMode& theMode)
-{
- PartSet_SelectionMode aMode = theMode;
- switch (theMode)
- {
- case SM_LastPoint: {
- boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
- boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
- FeaturePtr aFeature;
- if (anAttr) {
- aFeature = anAttr->feature();
- if (aFeature->getKind() != SKETCH_LINE_KIND) {
- aFeature = FeaturePtr();
- }
- }
- boost::shared_ptr<GeomAPI_Pnt2d> aPoint = boost::shared_ptr<GeomAPI_Pnt2d>
- (new GeomAPI_Pnt2d(theX, theY));
- boost::shared_ptr<GeomAPI_Lin2d> aFeatureLin = PartSet_FeatureLinePrs::createLin2d(aFeature);
- boost::shared_ptr<GeomAPI_Pnt2d> aResult = aFeatureLin->project(aPoint);
- double aDistance = aPoint->distance(aResult);
-
- if (!aFeatureLin->isRight(aPoint))
- aDistance = -aDistance;
-
- //AttributeDoublePtr aFlyoutAttr =
- // boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE));
- //aFlyoutAttr->setValue(aDistance);
-
- aMode = SM_DonePoint;
- }
- break;
- default:
- break;
- }
- return aMode;
-}
-
-std::string PartSet_ConstraintLengthPrs::getAttribute(const PartSet_SelectionMode& theMode) const
-{
- return "";
-}
-
-PartSet_SelectionMode PartSet_ConstraintLengthPrs::getNextMode(const std::string& theAttribute) const
-{
- return SM_FirstPoint;
-}
-
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_ConstraintLengthPrs::featurePoint
- (const PartSet_SelectionMode& theMode)
-{
- return boost::shared_ptr<GeomDataAPI_Point2D>();
-}
+++ /dev/null
-// File: PartSet_ConstraintLengthPrs.h
-// Created: 16 Jun 2014
-// Author: Natalia ERMOLAEVA
-
-#ifndef PartSet_ConstraintLengthPrs_H
-#define PartSet_ConstraintLengthPrs_H
-
-#include "PartSet.h"
-
-#include "PartSet_FeaturePrs.h"
-#include "PartSet_Constants.h"
-
-class GeomDataAPI_Point2D;
-class Handle_AIS_InteractiveObject;
-
-/*!
- \class PartSet_ConstraintLengthPrs
- * \brief The class to define the circle feature manipulation. It is created for
- * the feature create operation to move out the feature properties set and use one operation
- * for any type of features.
-*/
-class PARTSET_EXPORT PartSet_ConstraintLengthPrs : public PartSet_FeaturePrs
-{
-public:
- /// Returns the feature type processed by this presentation
- /// \return the feature kind
- static std::string getKind();
-
- /// Constructor
- /// \param theSketch the sketch feature
- PartSet_ConstraintLengthPrs(FeaturePtr theSketch);
- /// Destructor
- virtual ~PartSet_ConstraintLengthPrs() {};
-
- /// Sets the feature to to a feature attribute depending on the selection mode
- /// \param theFeature a feature instance
- /// \param theMode the selection mode
- /// \return whether the feature is set
- virtual PartSet_SelectionMode setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode);
-
- /// Sets the point to the feature in an attribute depending on the selection mode
- /// \param theX the 2D point horizontal coordinate
- /// \param theY the 2D point vertical coordinate
- /// \param theMode the selection mode
- /// \return the new selection mode
- virtual PartSet_SelectionMode setPoint(double theX, double theY,
- const PartSet_SelectionMode& theMode);
-
- /// Returns the feature attribute name for the selection mode
- /// \param theMode the current operation selection mode. The feature attribute depends on the mode
- virtual std::string getAttribute(const PartSet_SelectionMode& theMode) const;
-
- /// Returns the next selection mode after the attribute
- /// \param theAttribute the feature attribute name
- /// \return next attribute selection mode
- virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
-
-protected:
- /// Returns the feature point in the selection mode position.
- /// \param theMode the current operation selection mode. The feature attribute depends on the mode
- virtual boost::shared_ptr<GeomDataAPI_Point2D> featurePoint(const PartSet_SelectionMode& theMode);
-};
-
-#endif
+++ /dev/null
-// File: PartSet_FeaturePrs.h
-// Created: 16 Jun 2014
-// Author: Natalia ERMOLAEVA
-
-#include <PartSet_ConstraintRadiusPrs.h>
-#include <PartSet_Tools.h>
-
-#include <PartSet_FeatureCirclePrs.h>
-#include <PartSet_FeatureArcPrs.h>
-
-#include <SketchPlugin_Feature.h>
-#include <SketchPlugin_Sketch.h>
-#include <SketchPlugin_Line.h>
-#include <SketchPlugin_Circle.h>
-#include <SketchPlugin_Arc.h>
-#include <SketchPlugin_ConstraintRadius.h>
-
-#include <GeomDataAPI_Point.h>
-#include <GeomDataAPI_Point2D.h>
-#include <GeomDataAPI_Dir.h>
-#include <GeomAPI_Pnt2d.h>
-#include <GeomAPI_Lin2d.h>
-#include <GeomAPI_Pln.h>
-#include <GeomAPI_Dir.h>
-
-#include <GeomAlgoAPI_EdgeBuilder.h>
-
-#include <ModelAPI_Data.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_AttributeRefAttr.h>
-#include <ModelAPI_AttributeRefList.h>
-#include <ModelAPI_AttributeDouble.h>
-
-#include <AIS_InteractiveObject.hxx>
-#include <AIS_RadiusDimension.hxx>
-#include <Precision.hxx>
-#include <gp_Circ.hxx>
-#include <V3d_View.hxx>
-
-using namespace std;
-
-PartSet_ConstraintRadiusPrs::PartSet_ConstraintRadiusPrs(FeaturePtr theSketch)
-: PartSet_FeaturePrs(theSketch)
-{
-}
-
-std::string PartSet_ConstraintRadiusPrs::getKind()
-{
- return SKETCH_CONSTRAINT_RADIUS_KIND;
-}
-
-PartSet_SelectionMode PartSet_ConstraintRadiusPrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
-{
- PartSet_SelectionMode aMode = theMode;
- if (!feature() || theMode != SM_FirstPoint || !theFeature) {
- return aMode;
- }
- std::string aKind = theFeature->getKind();
- if (aKind == SKETCH_CIRCLE_KIND || aKind == SKETCH_ARC_KIND) {
- // set length feature
- boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
- boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
- aRef->setFeature(theFeature);
-
- double aLength = 50;
- bool isValid;
- if (aKind == SKETCH_CIRCLE_KIND) {
- aLength = PartSet_Tools::featureValue(theFeature, CIRCLE_ATTR_RADIUS, isValid);
- }
- else if (aKind == SKETCH_ARC_KIND) {
- aLength = PartSet_FeatureArcPrs::radius(theFeature);
- }
-
- PartSet_Tools::setFeatureValue(feature(), aLength, CONSTRAINT_ATTR_VALUE);
- aMode = SM_LastPoint;
- }
- return aMode;
-}
-
-PartSet_SelectionMode PartSet_ConstraintRadiusPrs::setPoint(double theX, double theY,
- const PartSet_SelectionMode& theMode)
-{
- PartSet_SelectionMode aMode = theMode;
- switch (theMode)
- {
- case SM_LastPoint: {
- boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
-
- boost::shared_ptr<GeomAPI_Pnt2d> aPoint = boost::shared_ptr<GeomAPI_Pnt2d>
- (new GeomAPI_Pnt2d(theX, theY));
-
- //PartSet_Tools::setFeaturePoint(feature(), theX, theY, SKETCH_CONSTRAINT_ATTR_CIRCLE_POINT);
-
- //double aDistance = 40;
- //AttributeDoublePtr aFlyoutAttr =
- // boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE));
- //aFlyoutAttr->setValue(aDistance);
-
- aMode = SM_LastPoint;
- }
- break;
- default:
- break;
- }
- return aMode;
-}
-
-void PartSet_ConstraintRadiusPrs::projectPointOnFeature(FeaturePtr theFeature, FeaturePtr theSketch,
- gp_Pnt& thePoint, Handle(V3d_View) theView,
- double& theX, double& theY)
-{
- boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
- boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
- if (!anAttr)
- return;
- FeaturePtr aFeature = anAttr->feature();
- if (!aFeature)
- return;
-
- gp_Circ aCircle;
- gp_Pnt anAnchorPoint;
- if (aFeature->getKind() == SKETCH_CIRCLE_KIND) {
- PartSet_FeatureCirclePrs::projectPointOnFeature(aFeature, theSketch, thePoint, theView, theX, theY);
- }
- else if (aFeature->getKind() == SKETCH_ARC_KIND) {
- PartSet_FeatureArcPrs::projectPointOnFeature(aFeature, theSketch, thePoint, theView, theX, theY);
- }
- // TODO: a bug in AIS_RadiusDimension:
- // The anchor point can't be myCirc.Location() - an exception is raised.
- // But we need exactly this case...
- // We want to show a radius dimension starting from the circle centre and
- // ending at the user-defined point.
- // Also, if anchor point coincides with myP2, the radius dimension is not displayed at all.
- double aDelta = 1/1000.0;
- theX += aDelta;
- theY += aDelta;
-}
-
-std::string PartSet_ConstraintRadiusPrs::getAttribute(const PartSet_SelectionMode& theMode) const
-{
- return "";
-}
-
-PartSet_SelectionMode PartSet_ConstraintRadiusPrs::getNextMode(const std::string& theAttribute) const
-{
- return SM_FirstPoint;
-}
-
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_ConstraintRadiusPrs::featurePoint
- (const PartSet_SelectionMode& theMode)
-{
- return boost::shared_ptr<GeomDataAPI_Point2D>();
-}
+++ /dev/null
-// File: PartSet_ConstraintRadiusPrs.h
-// Created: 16 Jun 2014
-// Author: Natalia ERMOLAEVA
-
-#ifndef PartSet_ConstraintRadiusPrs_H
-#define PartSet_ConstraintRadiusPrs_H
-
-#include "PartSet.h"
-
-#include "PartSet_FeaturePrs.h"
-#include "PartSet_Constants.h"
-
-#include <gp_Pnt.hxx>
-
-class GeomDataAPI_Point2D;
-class Handle_AIS_InteractiveObject;
-class Handle_V3d_View;
-
-/*!
- \class PartSet_ConstraintRadiusPrs
- * \brief The class to define the circle feature manipulation. It is created for
- * the feature create operation to move out the feature properties set and use one operation
- * for any type of features.
-*/
-class PARTSET_EXPORT PartSet_ConstraintRadiusPrs : public PartSet_FeaturePrs
-{
-public:
- /// Returns the feature type processed by this presentation
- /// \return the feature kind
- static std::string getKind();
-
- /// Constructor
- /// \param theSketch the sketch feature
- PartSet_ConstraintRadiusPrs(FeaturePtr theSketch);
- /// Destructor
- virtual ~PartSet_ConstraintRadiusPrs() {};
-
- /// Sets the feature to to a feature attribute depending on the selection mode
- /// \param theFeature a feature instance
- /// \param theMode the selection mode
- /// \return whether the feature is set
- virtual PartSet_SelectionMode setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode);
-
- /// Sets the point to the feature in an attribute depending on the selection mode
- /// \param theX the 2D point horizontal coordinate
- /// \param theY the 2D point vertical coordinate
- /// \param theMode the selection mode
- /// \return the new selection mode
- virtual PartSet_SelectionMode setPoint(double theX, double theY,
- const PartSet_SelectionMode& theMode);
-
- /// Returns the feature attribute name for the selection mode
- /// \param theMode the current operation selection mode. The feature attribute depends on the mode
- virtual std::string getAttribute(const PartSet_SelectionMode& theMode) const;
-
- /// Returns the next selection mode after the attribute
- /// \param theAttribute the feature attribute name
- /// \return next attribute selection mode
- virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
-
- /// Project the view point on the feature. The output coordinates belong to the feature
- /// \param theFeature a feature
- /// \param theSketch the sketch feature
- /// \param thePoint a viewer point
- /// \param theView the OCC view
- /// \theX the output horizontal coordinate of a projected point
- /// \theY the output vertical coordinate of a projected point
- static void projectPointOnFeature(FeaturePtr theFeature, FeaturePtr theSketch, gp_Pnt& thePoint,
- Handle_V3d_View theView, double& theX, double& theY);
-
-protected:
- /// Returns the feature point in the selection mode position.
- /// \param theMode the current operation selection mode. The feature attribute depends on the mode
- virtual boost::shared_ptr<GeomDataAPI_Point2D> featurePoint(const PartSet_SelectionMode& theMode);
-};
-
-#endif
+++ /dev/null
-// File: PartSet_FeaturePrs.h
-// Created: 04 Jun 2014
-// Author: Natalia ERMOLAEVA
-
-#include <PartSet_FeatureArcPrs.h>
-#include <PartSet_Tools.h>
-
-#include <SketchPlugin_Feature.h>
-#include <SketchPlugin_Sketch.h>
-#include <SketchPlugin_Arc.h>
-
-#include <GeomDataAPI_Point2D.h>
-#include <GeomAPI_Pnt2d.h>
-#include <GeomAPI_Circ2d.h>
-
-#include <ModelAPI_Data.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_AttributeRefAttr.h>
-#include <ModelAPI_AttributeRefList.h>
-
-#include <V3d_View.hxx>
-
-#include <Precision.hxx>
-
-using namespace std;
-
-PartSet_FeatureArcPrs::PartSet_FeatureArcPrs(FeaturePtr theSketch)
-: PartSet_FeaturePrs(theSketch)
-{
-}
-
-std::string PartSet_FeatureArcPrs::getKind()
-{
- return SKETCH_ARC_KIND;
-}
-
-PartSet_SelectionMode PartSet_FeatureArcPrs::setPoint(double theX, double theY,
- const PartSet_SelectionMode& theMode)
-{
- PartSet_SelectionMode aMode = theMode;
- switch (theMode)
- {
- case SM_FirstPoint: {
- PartSet_Tools::setFeaturePoint(feature(), theX, theY, ARC_ATTR_CENTER);
- aMode = SM_SecondPoint;
- }
- break;
- case SM_SecondPoint: {
- PartSet_Tools::setFeaturePoint(feature(), theX, theY, ARC_ATTR_START);
- aMode = SM_ThirdPoint;
- }
- break;
- case SM_ThirdPoint: {
- PartSet_Tools::setFeaturePoint(feature(), theX, theY, ARC_ATTR_END);
- aMode = SM_DonePoint;
- }
- break;
- default:
- break;
- }
- return aMode;
-}
-
-std::string PartSet_FeatureArcPrs::getAttribute(const PartSet_SelectionMode& theMode) const
-{
- std::string aAttribute;
- switch (theMode)
- {
- case SM_FirstPoint:
- aAttribute = ARC_ATTR_CENTER;
- break;
- case SM_SecondPoint:
- aAttribute = ARC_ATTR_START;
- break;
- case SM_ThirdPoint:
- aAttribute = ARC_ATTR_END;
- break;
- default:
- break;
- }
- return aAttribute;
-}
-
-PartSet_SelectionMode PartSet_FeatureArcPrs::getNextMode(const std::string& theAttribute) const
-{
- PartSet_SelectionMode aMode;
-
- if (theAttribute == ARC_ATTR_CENTER)
- aMode = SM_SecondPoint;
- else if (theAttribute == ARC_ATTR_START)
- aMode = SM_ThirdPoint;
- else if (theAttribute == ARC_ATTR_END)
- aMode = SM_DonePoint;
- return aMode;
-}
-
-void PartSet_FeatureArcPrs::projectPointOnFeature(FeaturePtr theFeature, FeaturePtr theSketch,
- gp_Pnt& thePoint, Handle(V3d_View) theView,
- double& theX, double& theY)
-{
- FeaturePtr aSketch = theSketch;
- if (aSketch) {
- double aX, anY;
- PartSet_Tools::convertTo2D(thePoint, aSketch, theView, aX, anY);
-
- // circle origin point and radius
- boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aCenter = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aData->attribute(ARC_ATTR_CENTER));
- boost::shared_ptr<GeomDataAPI_Point2D> aStart = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aData->attribute(ARC_ATTR_START));
-
- boost::shared_ptr<GeomAPI_Circ2d> aCirc(new GeomAPI_Circ2d(aCenter->pnt(), aStart->pnt()));
- boost::shared_ptr<GeomAPI_Pnt2d> aGeomPoint2d(new GeomAPI_Pnt2d(aX, anY));
- boost::shared_ptr<GeomAPI_Pnt2d> aPnt2d = aCirc->project(aGeomPoint2d);
- if (aPnt2d) {
- theX = aPnt2d->x();
- theY = aPnt2d->y();
- }
- }
-}
-
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeatureArcPrs::featurePoint
- (const PartSet_SelectionMode& theMode)
-{
- std::string aPointArg;
- switch (theMode)
- {
- case SM_FirstPoint:
- aPointArg = ARC_ATTR_CENTER;
- break;
- case SM_SecondPoint:
- aPointArg = ARC_ATTR_START;
- break;
- case SM_ThirdPoint:
- aPointArg = ARC_ATTR_END;
- break;
- default:
- break;
- }
- boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aData->attribute(aPointArg));
- return aPoint;
-}
-
-double PartSet_FeatureArcPrs::radius(FeaturePtr theFeature)
-{
- if (!theFeature)
- return 0;
-
- boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
-
- boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_CENTER));
- boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(ARC_ATTR_START));
-
- return aCenterAttr->pnt()->distance(aStartAttr->pnt());
-}
+++ /dev/null
-// File: PartSet_FeatureArcPrs.h
-// Created: 04 Jun 2014
-// Author: Natalia ERMOLAEVA
-
-#ifndef PartSet_FeatureArcPrs_H
-#define PartSet_FeatureArcPrs_H
-
-#include "PartSet.h"
-
-#include "PartSet_FeaturePrs.h"
-#include "PartSet_Constants.h"
-
-#include <gp_Pnt.hxx>
-
-class GeomDataAPI_Point2D;
-class Handle_V3d_View;
-
-/*!
- \class PartSet_FeatureArcPrs
- * \brief The class to define the circle arc feature manipulation. It is created for
- * the feature create operation to move out the feature properties set and use one operation
- * for any type of features.
-*/
-class PARTSET_EXPORT PartSet_FeatureArcPrs : public PartSet_FeaturePrs
-{
-public:
- /// Returns the feature type processed by this presentation
- /// \return the feature kind
- static std::string getKind();
-
- /// Constructor
- /// \param theSketch the sketch feature
- PartSet_FeatureArcPrs(FeaturePtr theSketch);
- /// Destructor
- virtual ~PartSet_FeatureArcPrs() {};
-
- /// Sets the point to the feature in an attribute depending on the selection mode
- /// \param theX the 2D point horizontal coordinate
- /// \param theY the 2D point vertical coordinate
- /// \param theMode the selection mode
- /// \return the new selection mode
- virtual PartSet_SelectionMode setPoint(double theX, double theY,
- const PartSet_SelectionMode& theMode);
-
- /// Returns the feature attribute name for the selection mode
- /// \param theMode the current operation selection mode. The feature attribute depends on the mode
- virtual std::string getAttribute(const PartSet_SelectionMode& theMode) const;
-
- /// Returns the next selection mode after the attribute
- /// \param theAttribute the feature attribute name
- /// \return next attribute selection mode
- virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
-
- /// Project the view point on the feature. The output coordinates belong to the feature
- /// \param theFeature a feature
- /// \param theSketch the sketch feature
- /// \param thePoint a viewer point
- /// \param theView the OCC view
- /// \theX the output horizontal coordinate of a projected point
- /// \theY the output vertical coordinate of a projected point
- static void projectPointOnFeature(FeaturePtr theFeature, FeaturePtr theSketch, gp_Pnt& thePoint,
- Handle_V3d_View theView, double& theX, double& theY);
-
- /// Computes the feature's radius
- /// \param theFeature an arc feature
- /// \return the double value
- static double radius(FeaturePtr theFeature);
-
-protected:
- /// Returns the feature point in the selection mode position.
- /// \param theMode the current operation selection mode. The feature attribute depends on the mode
- virtual boost::shared_ptr<GeomDataAPI_Point2D> featurePoint(const PartSet_SelectionMode& theMode);
-};
-
-#endif
+++ /dev/null
-// File: PartSet_FeaturePrs.h
-// Created: 04 Jun 2014
-// Author: Natalia ERMOLAEVA
-
-#include <PartSet_FeatureCirclePrs.h>
-#include <PartSet_Tools.h>
-
-#include <SketchPlugin_Feature.h>
-#include <SketchPlugin_Sketch.h>
-#include <SketchPlugin_Circle.h>
-
-#include <GeomDataAPI_Point2D.h>
-#include <GeomDataAPI_Dir.h>
-#include <GeomAPI_Pnt2d.h>
-#include <GeomAPI_Circ2d.h>
-#include <GeomAPI_Dir2d.h>
-#include <GeomAPI_Dir.h>
-
-#include <ModelAPI_Data.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_AttributeRefAttr.h>
-#include <ModelAPI_AttributeRefList.h>
-
-#include <V3d_View.hxx>
-#include <Precision.hxx>
-
-using namespace std;
-
-PartSet_FeatureCirclePrs::PartSet_FeatureCirclePrs(FeaturePtr theSketch)
-: PartSet_FeaturePrs(theSketch)
-{
-}
-
-std::string PartSet_FeatureCirclePrs::getKind()
-{
- return SKETCH_CIRCLE_KIND;
-}
-
-PartSet_SelectionMode PartSet_FeatureCirclePrs::setPoint(double theX, double theY,
- const PartSet_SelectionMode& theMode)
-{
- PartSet_SelectionMode aMode = theMode;
- switch (theMode)
- {
- case SM_FirstPoint: {
- PartSet_Tools::setFeaturePoint(feature(), theX, theY, CIRCLE_ATTR_CENTER);
- aMode = SM_SecondPoint;
- }
- break;
- case SM_SecondPoint: {
- boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aData->attribute(CIRCLE_ATTR_CENTER));
- boost::shared_ptr<GeomAPI_Pnt2d> aCoordPoint(new GeomAPI_Pnt2d(theX, theY));
- double aRadius = aCoordPoint->distance(aPoint->pnt());
- PartSet_Tools::setFeatureValue(feature(), aRadius, CIRCLE_ATTR_RADIUS);
-
- aMode = SM_DonePoint;
- }
- break;
- default:
- break;
- }
- return aMode;
-}
-
-std::string PartSet_FeatureCirclePrs::getAttribute(const PartSet_SelectionMode& theMode) const
-{
- std::string aAttribute;
- switch (theMode)
- {
- case SM_FirstPoint:
- aAttribute = CIRCLE_ATTR_CENTER;
- break;
- case SM_SecondPoint:
- aAttribute = CIRCLE_ATTR_RADIUS;
- break;
- default:
- break;
- }
- return aAttribute;
-}
-
-PartSet_SelectionMode PartSet_FeatureCirclePrs::getNextMode(const std::string& theAttribute) const
-{
- PartSet_SelectionMode aMode;
-
- if (theAttribute == CIRCLE_ATTR_CENTER)
- aMode = SM_SecondPoint;
- else if (theAttribute == CIRCLE_ATTR_RADIUS)
- aMode = SM_DonePoint;
- return aMode;
-}
-
-void PartSet_FeatureCirclePrs::projectPointOnFeature(FeaturePtr theFeature, FeaturePtr theSketch,
- gp_Pnt& thePoint, Handle(V3d_View) theView,
- double& theX, double& theY)
-{
- FeaturePtr aSketch = theSketch;
- if (aSketch) {
- double aX, anY;
- PartSet_Tools::convertTo2D(thePoint, aSketch, theView, aX, anY);
-
- // circle origin point and radius
- boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aCenter = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aData->attribute(CIRCLE_ATTR_CENTER));
- bool isValid;
- double aRadius = PartSet_Tools::featureValue(theFeature, CIRCLE_ATTR_RADIUS, isValid);
-
- boost::shared_ptr<GeomAPI_Dir2d> aNormal(new GeomAPI_Dir2d(aX, anY));
- boost::shared_ptr<GeomAPI_Circ2d> aCirc(new GeomAPI_Circ2d(aCenter->pnt(), aNormal, aRadius));
- boost::shared_ptr<GeomAPI_Pnt2d> aGeomPoint2d(new GeomAPI_Pnt2d(aX, anY));
- boost::shared_ptr<GeomAPI_Pnt2d> aPnt2d = aCirc->project(aGeomPoint2d);
- if (aPnt2d) {
- theX = aPnt2d->x();
- theY = aPnt2d->y();
- }
- }
-}
-
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeatureCirclePrs::featurePoint
- (const PartSet_SelectionMode& theMode)
-{
- std::string aPointArg;
- switch (theMode)
- {
- case SM_FirstPoint:
- aPointArg = CIRCLE_ATTR_CENTER;
- break;
- default:
- break;
- }
- boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aData->attribute(aPointArg));
- return aPoint;
-}
+++ /dev/null
-// File: PartSet_FeatureCirclePrs.h
-// Created: 04 Jun 2014
-// Author: Natalia ERMOLAEVA
-
-#ifndef PartSet_FeatureCirclePrs_H
-#define PartSet_FeatureCirclePrs_H
-
-#include "PartSet.h"
-
-#include "PartSet_FeaturePrs.h"
-#include "PartSet_Constants.h"
-
-#include <gp_Pnt.hxx>
-
-class GeomDataAPI_Point2D;
-class Handle_V3d_View;
-
-/*!
- \class PartSet_FeatureCirclePrs
- * \brief The class to define the circle feature manipulation. It is created for
- * the feature create operation to move out the feature properties set and use one operation
- * for any type of features.
-*/
-class PARTSET_EXPORT PartSet_FeatureCirclePrs : public PartSet_FeaturePrs
-{
-public:
- /// Returns the feature type processed by this presentation
- /// \return the feature kind
- static std::string getKind();
-
- /// Constructor
- /// \param theSketch the sketch feature
- PartSet_FeatureCirclePrs(FeaturePtr theSketch);
- /// Destructor
- virtual ~PartSet_FeatureCirclePrs() {};
-
- /// Sets the point to the feature in an attribute depending on the selection mode
- /// \param theX the 2D point horizontal coordinate
- /// \param theY the 2D point vertical coordinate
- /// \param theMode the selection mode
- /// \return the new selection mode
- virtual PartSet_SelectionMode setPoint(double theX, double theY,
- const PartSet_SelectionMode& theMode);
-
- /// Returns the feature attribute name for the selection mode
- /// \param theMode the current operation selection mode. The feature attribute depends on the mode
- virtual std::string getAttribute(const PartSet_SelectionMode& theMode) const;
-
- /// Returns the next selection mode after the attribute
- /// \param theAttribute the feature attribute name
- /// \return next attribute selection mode
- virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
-
- /// Project the view point on the feature. The output coordinates belong to the feature
- /// \param theFeature a feature
- /// \param theSketch the sketch feature
- /// \param thePoint a viewer point
- /// \param theView the OCC view
- /// \theX the output horizontal coordinate of a projected point
- /// \theY the output vertical coordinate of a projected point
- static void projectPointOnFeature(FeaturePtr theFeature, FeaturePtr theSketch, gp_Pnt& thePoint,
- Handle_V3d_View theView, double& theX, double& theY);
-
-protected:
- /// Returns the feature point in the selection mode position.
- /// \param theMode the current operation selection mode. The feature attribute depends on the mode
- virtual boost::shared_ptr<GeomDataAPI_Point2D> featurePoint(const PartSet_SelectionMode& theMode);
-};
-
-#endif
+++ /dev/null
-// File: PartSet_FeaturePrs.h
-// Created: 04 Jun 2014
-// Author: Natalia ERMOLAEVA
-
-#include <PartSet_FeatureLinePrs.h>
-#include <PartSet_Tools.h>
-
-#include <SketchPlugin_Feature.h>
-#include <SketchPlugin_Sketch.h>
-#include <SketchPlugin_ConstraintCoincidence.h>
-#include <SketchPlugin_Line.h>
-#include <SketchPlugin_Constraint.h>
-
-#include <GeomDataAPI_Point2D.h>
-#include <GeomAPI_Lin2d.h>
-#include <GeomAPI_Pnt2d.h>
-
-#include <ModelAPI_Data.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_AttributeRefAttr.h>
-#include <ModelAPI_AttributeRefList.h>
-
-#include <Precision.hxx>
-#include <V3d_View.hxx>
-
-using namespace std;
-
-PartSet_FeatureLinePrs::PartSet_FeatureLinePrs(FeaturePtr theSketch)
-: PartSet_FeaturePrs(theSketch)
-{
-}
-
-std::string PartSet_FeatureLinePrs::getKind()
-{
- return SKETCH_LINE_KIND;
-}
-
-PartSet_SelectionMode PartSet_FeatureLinePrs::setPoint(double theX, double theY,
- const PartSet_SelectionMode& theMode)
-{
- PartSet_SelectionMode aMode = theMode;
- switch (theMode)
- {
- case SM_FirstPoint: {
- PartSet_Tools::setFeaturePoint(feature(), theX, theY, LINE_ATTR_START);
- PartSet_Tools::setFeaturePoint(feature(), theX, theY, LINE_ATTR_END);
- aMode = SM_SecondPoint;
- }
- break;
- case SM_SecondPoint: {
- PartSet_Tools::setFeaturePoint(feature(), theX, theY, LINE_ATTR_END);
- aMode = SM_DonePoint;
- }
- break;
- default:
- break;
- }
- return aMode;
-}
-
-PartSet_SelectionMode PartSet_FeatureLinePrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
-{
- PartSet_SelectionMode aMode = theMode;
- if (feature() && theFeature && theMode == SM_FirstPoint)
- {
- // use the last point of the previous feature as the first of the new one
- boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
- boost::shared_ptr<GeomDataAPI_Point2D> anInitPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aData->attribute(LINE_ATTR_END));
- PartSet_Tools::setFeaturePoint(feature(), anInitPoint->x(), anInitPoint->y(), LINE_ATTR_START);
- PartSet_Tools::setFeaturePoint(feature(), anInitPoint->x(), anInitPoint->y(), LINE_ATTR_END);
-
- aData = feature()->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aData->attribute(LINE_ATTR_START));
- PartSet_Tools::createConstraint(sketch(), anInitPoint, aPoint);
- aMode = SM_SecondPoint;
- }
- return aMode;
-}
-
-std::string PartSet_FeatureLinePrs::getAttribute(const PartSet_SelectionMode& theMode) const
-{
- std::string aAttribute;
- switch (theMode)
- {
- case SM_FirstPoint:
- aAttribute = LINE_ATTR_START;
- break;
- case SM_SecondPoint:
- aAttribute = LINE_ATTR_END;
- break;
- default:
- break;
- }
- return aAttribute;
-}
-
-PartSet_SelectionMode PartSet_FeatureLinePrs::getNextMode(const std::string& theAttribute) const
-{
- PartSet_SelectionMode aMode;
-
- if (theAttribute == LINE_ATTR_START)
- aMode = SM_SecondPoint;
- else if (theAttribute == LINE_ATTR_END)
- aMode = SM_DonePoint;
- return aMode;
-}
-
-void PartSet_FeatureLinePrs::projectPointOnLine(FeaturePtr theFeature,
- const PartSet_SelectionMode& theMode,
- const gp_Pnt& thePoint, Handle(V3d_View) theView,
- double& theX, double& theY)
-{
- if (theFeature && theFeature->getKind() == getKind()) {
- double X0, X1;
- double Y0, Y1;
-
- PartSet_Tools::convertTo2D(thePoint, sketch(), theView, X1, Y1);
- boost::shared_ptr<GeomAPI_Pnt2d> aPoint = boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(X1, Y1));
- boost::shared_ptr<GeomAPI_Lin2d> aFeatureLin = PartSet_FeatureLinePrs::createLin2d(theFeature);
-
- switch (theMode) {
- case SM_FirstPoint: {
- boost::shared_ptr<GeomAPI_Pnt2d> aResult = aFeatureLin->project(aPoint);
- theX = aResult->x();
- theY = aResult->y();
- }
- break;
- case SM_SecondPoint: {
- getLinePoint(feature(), LINE_ATTR_START, X0, Y0);
- boost::shared_ptr<GeomAPI_Lin2d> aCurrentLin = boost::shared_ptr<GeomAPI_Lin2d>
- (new GeomAPI_Lin2d(X0, Y0, X1, Y1));
- boost::shared_ptr<GeomAPI_Pnt2d> aResult = aFeatureLin->intersect(aCurrentLin);
- boost::shared_ptr<GeomAPI_Pnt2d> aPoint0 = boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(X0, Y0));
- if (aResult->distance(aPoint0) < Precision::Confusion()) { // the start point is nearest to the line
- // if the first point of a line belongs to the given line
- // we need to project the second point on the same line
- aResult = aFeatureLin->project(aPoint);
- }
- theX = aResult->x();
- theY = aResult->y();
- }
- break;
- default:
- break;
- }
- }
-}
-
-boost::shared_ptr<GeomAPI_Lin2d> PartSet_FeatureLinePrs::createLin2d(FeaturePtr theFeature)
-{
- boost::shared_ptr<GeomAPI_Lin2d> aFeatureLin;
- if (!theFeature || theFeature->getKind() != PartSet_FeatureLinePrs::getKind())
- return aFeatureLin;
-
- double aStartX, aStartY, anEndX, anEndY;
- getLinePoint(theFeature, LINE_ATTR_START, aStartX, aStartY);
- getLinePoint(theFeature, LINE_ATTR_END, anEndX, anEndY);
-
- aFeatureLin = boost::shared_ptr<GeomAPI_Lin2d>
- (new GeomAPI_Lin2d(aStartX, aStartY, anEndX, anEndY));
- return aFeatureLin;
-}
-
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeatureLinePrs::featurePoint
- (const PartSet_SelectionMode& theMode)
-{
- std::string aPointArg;
- switch (theMode)
- {
- case SM_FirstPoint:
- aPointArg = LINE_ATTR_START;
- break;
- case SM_SecondPoint:
- aPointArg = LINE_ATTR_END;
- break;
- default:
- break;
- }
- boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aData->attribute(aPointArg));
- return aPoint;
-}
-
-void PartSet_FeatureLinePrs::getLinePoint(FeaturePtr theFeature, const std::string& theAttribute,
- double& theX, double& theY)
-{
- if (!theFeature || theFeature->getKind() != PartSet_FeatureLinePrs::getKind())
- return;
- boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(theAttribute));
- theX = aPoint->x();
- theY = aPoint->y();
-}
+++ /dev/null
-// File: PartSet_FeatureLinePrs.h
-// Created: 04 Jun 2014
-// Author: Natalia ERMOLAEVA
-
-#ifndef PartSet_FeatureLinePrs_H
-#define PartSet_FeatureLinePrs_H
-
-#include "PartSet.h"
-
-#include "PartSet_FeaturePrs.h"
-#include "PartSet_Constants.h"
-
-#include <gp_Pnt.hxx>
-
-class GeomDataAPI_Point2D;
-class GeomAPI_Lin2d;
-class Handle_V3d_View;
-
-/*!
- \class PartSet_FeatureLinePrs
- * \brief The class to define the line feature manipulation. It is created for
- * the feature create operation to move out the feature properties set and use one operation
- * for any type of features.
-*/
-class PARTSET_EXPORT PartSet_FeatureLinePrs : public PartSet_FeaturePrs
-{
-public:
- /// Returns the feature type processed by this presentation
- /// \return the feature kind
- static std::string getKind();
-
- /// Constructor
- /// \param theSketch the sketch feature
- PartSet_FeatureLinePrs(FeaturePtr theSketch);
- /// Destructor
- virtual ~PartSet_FeatureLinePrs() {};
-
- /// Sets the point to the feature in an attribute depending on the selection mode
- /// \param theX the 2D point horizontal coordinate
- /// \param theY the 2D point vertical coordinate
- /// \param theMode the selection mode
- /// \return the new selection mode
- virtual PartSet_SelectionMode setPoint(double theX, double theY,
- const PartSet_SelectionMode& theMode);
-
- /// Sets the feature to to a feature attribute depending on the selection mode
- /// \param theFeature a feature instance
- /// \param theMode the selection mode
- /// \return whether the feature is set
- virtual PartSet_SelectionMode setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode);
-
- /// Returns the feature attribute name for the selection mode
- /// \param theMode the current operation selection mode. The feature attribute depends on the mode
- virtual std::string getAttribute(const PartSet_SelectionMode& theMode) const;
-
- /// Returns the next selection mode after the attribute
- /// \param theAttribute the feature attribute name
- /// \return next attribute selection mode
- virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
-
- /// Project the point on a feature
- /// \param theFeature the feature to be projected on
- /// \param theMode the selection mode
- /// \param thePoint the clicked point
- /// \param theView the viewer
- /// \param theX the output horizontal coordinate
- /// \param theY the output vertical coordinate
- void projectPointOnLine(FeaturePtr theFeature, const PartSet_SelectionMode& theMode,
- const gp_Pnt& thePoint, Handle_V3d_View theView,
- double& theX, double& theY);
-
- /// Creates a lin 2d object on a base of the line feature
- /// \param theFeature the line feature
- static boost::shared_ptr<GeomAPI_Lin2d> createLin2d(FeaturePtr theFeature);
- /// \brief Get the line point 2d coordinates.
- /// \param theFeature the line feature
- /// \param theAttribute the start or end attribute of the line
- /// \param theX the horizontal coordinate
- /// \param theY the vertical coordinate
- static void getLinePoint(FeaturePtr theFeature, const std::string& theAttribute,
- double& theX, double& theY);
-
-protected:
- /// Returns the feature point in the selection mode position.
- /// \param theMode the current operation selection mode. The feature attribute depends on the mode
- virtual boost::shared_ptr<GeomDataAPI_Point2D> featurePoint(const PartSet_SelectionMode& theMode);
-};
-
-#endif
+++ /dev/null
-// File: PartSet_FeaturePrs.h
-// Created: 04 Jun 2014
-// Author: Natalia ERMOLAEVA
-
-#include <PartSet_FeaturePointPrs.h>
-#include <PartSet_Tools.h>
-
-#include <SketchPlugin_Feature.h>
-#include <SketchPlugin_Sketch.h>
-#include <SketchPlugin_Point.h>
-
-#include <GeomAPI_Pnt2d.h>
-#include <GeomDataAPI_Point2D.h>
-
-#include <ModelAPI_Data.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_AttributeRefAttr.h>
-#include <ModelAPI_AttributeRefList.h>
-
-#include <Precision.hxx>
-
-using namespace std;
-
-PartSet_FeaturePointPrs::PartSet_FeaturePointPrs(FeaturePtr theSketch)
-: PartSet_FeaturePrs(theSketch)
-{
-}
-
-std::string PartSet_FeaturePointPrs::getKind()
-{
- return SKETCH_POINT_KIND;
-}
-
-PartSet_SelectionMode PartSet_FeaturePointPrs::setPoint(double theX, double theY,
- const PartSet_SelectionMode& theMode)
-{
- PartSet_SelectionMode aMode = theMode;
- switch (theMode)
- {
- case SM_FirstPoint: {
- PartSet_Tools::setFeaturePoint(feature(), theX, theY, POINT_ATTR_COORD);
- aMode = SM_DonePoint;
- }
- break;
- default:
- break;
- }
- return aMode;
-}
-
-std::string PartSet_FeaturePointPrs::getAttribute(const PartSet_SelectionMode& theMode) const
-{
- std::string aAttribute;
- switch (theMode)
- {
- case SM_FirstPoint:
- aAttribute = POINT_ATTR_COORD;
- break;
- default:
- break;
- }
- return aAttribute;
-}
-
-PartSet_SelectionMode PartSet_FeaturePointPrs::getNextMode(const std::string& theAttribute) const
-{
- PartSet_SelectionMode aMode;
-
- if (theAttribute == POINT_ATTR_COORD)
- aMode = SM_DonePoint;
- return aMode;
-}
-
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeaturePointPrs::featurePoint
- (const PartSet_SelectionMode& theMode)
-{
- std::string aPointArg;
- switch (theMode)
- {
- case SM_FirstPoint:
- aPointArg = POINT_ATTR_COORD;
- break;
- default:
- break;
- }
- boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aData->attribute(aPointArg));
- return aPoint;
-}
+++ /dev/null
-// File: PartSet_FeaturePointPrs.h
-// Created: 04 Jun 2014
-// Author: Natalia ERMOLAEVA
-
-#ifndef PartSet_FeaturePointPrs_H
-#define PartSet_FeaturePointPrs_H
-
-#include "PartSet.h"
-
-#include "PartSet_FeaturePrs.h"
-#include "PartSet_Constants.h"
-
-class GeomDataAPI_Point2D;
-
-/*!
- \class PartSet_FeaturePointPrs
- * \brief The class to define the point feature manipulation. It is created for
- * the feature create operation to move out the feature properties set and use one operation
- * for any type of features.
-*/
-class PARTSET_EXPORT PartSet_FeaturePointPrs : public PartSet_FeaturePrs
-{
-public:
- /// Returns the feature type processed by this presentation
- /// \return the feature kind
- static std::string getKind();
-
- /// Constructor
- /// \param theSketch the sketch feature
- PartSet_FeaturePointPrs(FeaturePtr theSketch);
- /// Destructor
- virtual ~PartSet_FeaturePointPrs() {};
-
- /// Sets the point to the feature in an attribute depending on the selection mode
- /// \param theX the 2D point horizontal coordinate
- /// \param theY the 2D point vertical coordinate
- /// \param theMode the selection mode
- /// \return the new selection mode
- virtual PartSet_SelectionMode setPoint(double theX, double theY,
- const PartSet_SelectionMode& theMode);
-
- /// Returns the feature attribute name for the selection mode
- /// \param theMode the current operation selection mode. The feature attribute depends on the mode
- virtual std::string getAttribute(const PartSet_SelectionMode& theMode) const;
-
- /// Returns the next selection mode after the attribute
- /// \param theAttribute the feature attribute name
- /// \return next attribute selection mode
- virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
-
-protected:
- /// Returns the feature point in the selection mode position.
- /// \param theMode the current operation selection mode. The feature attribute depends on the mode
- virtual boost::shared_ptr<GeomDataAPI_Point2D> featurePoint(const PartSet_SelectionMode& theMode);
-};
-
-#endif
+++ /dev/null
-// File: PartSet_FeaturePrs.h
-// Created: 04 Jun 2014
-// Author: Natalia ERMOLAEVA
-
-#include <PartSet_FeaturePrs.h>
-#include <PartSet_Tools.h>
-
-#include <SketchPlugin_Feature.h>
-#include <SketchPlugin_Sketch.h>
-
-#include <GeomDataAPI_Point2D.h>
-
-#include <ModelAPI_Data.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_AttributeRefAttr.h>
-#include <ModelAPI_AttributeRefList.h>
-
-#include <Precision.hxx>
-
-using namespace std;
-
-PartSet_FeaturePrs::PartSet_FeaturePrs(FeaturePtr theFeature)
-: mySketch(theFeature)
-{
-}
-
-PartSet_FeaturePrs::~PartSet_FeaturePrs()
-{
-}
-
-void PartSet_FeaturePrs::init(FeaturePtr theFeature)
-{
- myFeature = theFeature;
-}
-
-FeaturePtr PartSet_FeaturePrs::sketch() const
-{
- return mySketch;
-}
-
-FeaturePtr PartSet_FeaturePrs::feature() const
-{
- return myFeature;
-}
-
-PartSet_SelectionMode PartSet_FeaturePrs::setFeature(FeaturePtr theFeature,
- const PartSet_SelectionMode& theMode)
-{
- return SM_FirstPoint;
-}
+++ /dev/null
-// File: PartSet_FeaturePrs.h
-// Created: 04 Jun 2014
-// Author: Natalia ERMOLAEVA
-
-#ifndef PartSet_FeaturePrs_H
-#define PartSet_FeaturePrs_H
-
-#include "PartSet.h"
-
-#include "PartSet_Constants.h"
-
-class GeomDataAPI_Point2D;
-
-/*!
- \class PartSet_FeaturePrs
- * \brief The abstract class to define the specific feature manipulation. It is created for
- * the feature create operation to move out the feature properties set and use one operation
- * for any type of features.
-*/
-class PARTSET_EXPORT PartSet_FeaturePrs
-{
-public:
- /// Constructor
- /// \param theSketch the sketch feature
- PartSet_FeaturePrs(FeaturePtr theSketch);
- /// Destructor
- virtual ~PartSet_FeaturePrs();
-
- /// Initializes some fields of feature accorging to the source feature
- /// Saves the fiature as the presentation internal feature
- /// \param theFeature the presentation feature
- void init(FeaturePtr theFeature);
-
- /// Returns the operation sketch feature
- /// \returns the sketch instance
- FeaturePtr sketch() const;
-
- /// Sets the point to the feature in an attribute depending on the selection mode
- /// \param theX the 2D point horizontal coordinate
- /// \param theY the 2D point vertical coordinate
- /// \param theMode the selection mode
- /// \return the new selection mode
- virtual PartSet_SelectionMode setPoint(double theX, double theY,
- const PartSet_SelectionMode& theMode) = 0;
-
- /// Sets the feature to to a feature attribute depending on the selection mode
- /// \param theFeature a feature instance
- /// \param theMode the selection mode
- /// \return whether the feature is set
- /// \return the new selection mode
- virtual PartSet_SelectionMode setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode);
-
- /// Returns the feature attribute name for the selection mode
- /// \param theMode the current operation selection mode. The feature attribute depends on the mode
- virtual std::string getAttribute(const PartSet_SelectionMode& theMode) const = 0;
-
- /// Returns the next selection mode after the attribute
- /// \param theAttribute the feature attribute name
- /// \return next attribute selection mode
- virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const = 0;
-
-protected:
- /// Returns the operation feature
- /// \return the feature
- FeaturePtr feature() const;
-
- /// Returns the feature point in the selection mode position.
- /// \param theMode the current operation selection mode. The feature attribute depends on the mode
- virtual boost::shared_ptr<GeomDataAPI_Point2D> featurePoint(const PartSet_SelectionMode& theMode) = 0;
-
-private:
- FeaturePtr mySketch; ///< the sketch of the feature
- FeaturePtr myFeature; ///< the feature
-};
-
-#endif
myWorkshop->operationMgr()->currentOperation());
if (aPreviewOp) {
XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel();
- connect(aPreviewOp, SIGNAL(focusActivated(const std::string&)),
- aPropPanel, SLOT(onFocusActivated(const std::string&)));
-
connect(aPropPanel, SIGNAL(storedPoint2D(FeaturePtr, const std::string&)),
this, SLOT(onStorePoint2D(FeaturePtr, const std::string&)), Qt::UniqueConnection);
}
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
if (aPreviewOp) {
XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel();
- disconnect(aPreviewOp, SIGNAL(focusActivated(const std::string&)),
- aPropPanel, SLOT(onFocusActivated(const std::string&)));
//disconnect(aPropPanel, SIGNAL(storedPoint2D(FeaturePtr, const std::string&)),
// this, SLOT(onStorePoint2D(FeaturePtr, const std::string&)));
}
#include <PartSet_Tools.h>
#include <PartSet_OperationSketch.h>
-#include <PartSet_FeaturePointPrs.h>
-#include <PartSet_FeatureLinePrs.h>
-#include <PartSet_FeatureCirclePrs.h>
-#include <PartSet_FeatureArcPrs.h>
#include <SketchPlugin_Feature.h>
#include <SketchPlugin_Point.h>
#include <SketchPlugin_ConstraintRadius.h>
#include <SketchPlugin_ConstraintParallel.h>
#include <SketchPlugin_ConstraintPerpendicular.h>
+#include <SketchPlugin_ConstraintCoincidence.h>
#include <GeomAPI_Pnt2d.h>
theId == SKETCH_CONSTRAINT_LENGTH_KIND ||
theId == SKETCH_CONSTRAINT_RADIUS_KIND ||
theId == SKETCH_CONSTRAINT_PARALLEL_KIND ||
- theId == SKETCH_CONSTRAINT_PERPENDICULAR_KIND;
+ theId == SKETCH_CONSTRAINT_PERPENDICULAR_KIND ||
+ theId == SKETCH_CONSTRAINT_COINCIDENCE_KIND;
}
bool PartSet_OperationFeatureCreate::canBeCommitted() const
PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
// move to selected line
if (feature()->getKind() == SKETCH_LINE_KIND) {
- //boost::shared_ptr<PartSet_FeatureLinePrs> aLinePrs =
- // boost::dynamic_pointer_cast<PartSet_FeatureLinePrs>(myFeaturePrs);
- //if (aLinePrs) {
- // FeaturePtr aFeature = aPrs.feature();
- //aLinePrs->projectPointOnLine(aFeature, myPointSelectionMode, aPoint, theView, aX, anY);
- //}
+ //FeaturePtr aFeature = aPrs.feature();
+ //projectPointOnLine(aFeature, myPointSelectionMode, aPoint, theView, aX, anY);
}
}
}
}
- /*if (feature()->getKind() == SKETCH_ARC_KIND) {
- boost::shared_ptr<PartSet_FeatureArcPrs> anArcPrs =
- boost::dynamic_pointer_cast<PartSet_FeatureArcPrs>(myFeaturePrs);
- if (anArcPrs) {
- anArcPrs->projectPointOnFeature(feature(), sketch(), aPoint, theView, aX, anY);
- }
- }*/
bool isApplyed = false;
if (isPointWidget())
isApplyed = setWidgetPoint(aX, anY);
double aX, anY;
gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView);
PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
- /*if (myPointSelectionMode == SM_ThirdPoint) {
- if (feature()->getKind() == SKETCH_ARC_KIND) {
- boost::shared_ptr<PartSet_FeatureArcPrs> anArcPrs =
- boost::dynamic_pointer_cast<PartSet_FeatureArcPrs>(myFeaturePrs);
- if (anArcPrs) {
- anArcPrs->projectPointOnFeature(feature(), sketch(), aPoint, theView, aX, anY);
- }
- }
- }*/
setWidgetPoint(aX, anY);
flushUpdated();
}
return aNewFeature;
}
-/*void PartSet_OperationFeatureCreate::setPointSelectionMode(const PartSet_SelectionMode& theMode,
- const bool isToEmitSignal)
-{
- myPointSelectionMode = theMode;
- if (isToEmitSignal) {
- std::string aName = myFeaturePrs->getAttribute(theMode);
- if (aName.empty() && theMode == SM_DonePoint) {
- aName = XGUI::PROP_PANEL_OK;
- }
- emit focusActivated(aName);
- }
-}*/
-
bool PartSet_OperationFeatureCreate::isPointWidget() const
{
- return dynamic_cast<ModuleBase_WidgetPoint2D*>(myActiveWidget);
+ return dynamic_cast<ModuleBase_WidgetPoint2D*>(myActiveWidget) ||
+ dynamic_cast<ModuleBase_WidgetPoint2dDistance*>(myActiveWidget);
}
bool PartSet_OperationFeatureCreate::setWidgetPoint(double theX, double theY)
#include <QObject>
-class PartSet_FeaturePrs;
class GeomDataAPI_Point2D;
class QMouseEvent;
class QKeyEvent;
virtual FeaturePtr createFeature(const bool theFlushMessage = true);
protected:
- ///< Set the point selection mode. Emit signal about focus change if necessary.
- /// \param theMode a new selection mode
- /// \param isToEmitSignal the neccessity to emit signal
- //void setPointSelectionMode(const PartSet_SelectionMode& theMode,
- // const bool isToEmitSignal = true);
-
/// Returns true if the active widget is the point selector widget
/// \return the boolean value
bool isPointWidget() const;
bool setWidgetFeature(const FeaturePtr& theFeature);
private:
- //boost::shared_ptr<PartSet_FeaturePrs> myFeaturePrs; ///< the feature presentation
FeaturePtr myInitFeature; ///< the initial feature
FeaturePtr mySketch; ///< the sketch of the feature
- //PartSet_SelectionMode myPointSelectionMode; ///< point selection mode
ModuleBase_ModelWidget* myActiveWidget; ///< the active widget
};
#include <SketchPlugin_Line.h>
#include <V3d_View.hxx>
+#include <AIS_DimensionOwner.hxx>
+#include <AIS_DimensionSelectionMode.hxx>
#ifdef _DEBUG
#include <QDebug>
const std::list<XGUI_ViewerPrs>& theSelected,
const std::list<XGUI_ViewerPrs>& theHighlighted)
{
- // changed
+ // TODO the functionality is important only for constraint feature. Should be moved in another place
if (!theSelected.empty()) {
- bool isValid;
- double aValue = PartSet_Tools::featureValue(feature(), CONSTRAINT_ATTR_VALUE, isValid);
- if (isValid) {
- ModuleBase_WidgetEditor::editFeatureValue(feature(), CONSTRAINT_ATTR_VALUE);
- flushUpdated();
+ XGUI_ViewerPrs aFeaturePrs = theSelected.front();
+ if (!aFeaturePrs.owner().IsNull()) {
+ Handle(AIS_DimensionOwner) anOwner = Handle(AIS_DimensionOwner)::DownCast(aFeaturePrs.owner());
+ if (!anOwner.IsNull() && anOwner->SelectionMode() == AIS_DSM_Text) {
+ bool isValid;
+ double aValue = PartSet_Tools::featureValue(feature(), CONSTRAINT_ATTR_VALUE, isValid);
+ if (isValid) {
+ ModuleBase_WidgetEditor::editFeatureValue(feature(), CONSTRAINT_ATTR_VALUE);
+ flushUpdated();
+ }
+ }
}
}
}
if (theHighlighted.size() == 1) {
FeaturePtr aFeature = theHighlighted.front().feature();
if (aFeature) {
- std::string anOperationType = getOperationType(aFeature);
+ std::string anOperationType = PartSet_OperationFeatureEdit::Type();
if (theSelected.size() > 1)
anOperationType = PartSet_OperationFeatureEditMulti::Type();
restartOperation(anOperationType, aFeature);
if (!hasSketchPlane()) {
}
else {
+ /// TODO: OCC bug: 25034 - the highlighted list should be filled not only for AIS_Shape
+ /// but for other IO, for example constraint dimensions.
+ /// It is empty and we have to use the process mouse release to start edition operation
+ /// for these objects
if (theSelected.size() == 1) {
FeaturePtr aFeature = theSelected.front().feature();
if (aFeature)
- restartOperation(getOperationType(aFeature), aFeature);
+ restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature);
}
}
}
emit closeLocalContext();
emit planeSelected(aDir->x(), aDir->y(), aDir->z());
}
-
-std::string PartSet_OperationSketch::getOperationType(FeaturePtr theFeature)
-{
- return PartSet_OperationFeatureEdit::Type();
-}
/// \param theShape the shape
void setSketchPlane(const TopoDS_Shape& theShape);
- /// Returns the operation type, which is feature or constraint edit opeation
- /// \param theFeature a feature instance
- std::string getOperationType(FeaturePtr theFeature);
-
private:
std::list<XGUI_ViewerPrs> myFeatures; ///< the features to apply the edit operation
};
/// theName the operation name
/// theFeature the operation argument
void launchOperation(std::string theName, FeaturePtr theFeature);
- /// signal about the focus activated
- /// theName the attribute name
- void focusActivated(const std::string& theAttibuteName);
-
/// Signal about the feature construing is finished
/// \param theFeature the result feature
/// \param theMode the mode of the feature modification
#include <XGUI_Displayer.h>
#include <XGUI_ViewerPrs.h>
#include <XGUI_ViewerProxy.h>
-#include <PartSet_FeaturePrs.h>
#include <PartSet_Tools.h>
#include <PartSet_OperationSketchBase.h>
#include <SketchPlugin_Feature.h>
#include <SketchPlugin_Sketch.h>
#include <SketchPlugin_ConstraintCoincidence.h>
+#include <SketchPlugin_ConstraintDistance.h>
+#include <SketchPlugin_ConstraintLength.h>
+#include <SketchPlugin_ConstraintRadius.h>
#include <SketchPlugin_Constraint.h>
-#include <PartSet_FeatureLinePrs.h>
-#include <PartSet_FeaturePointPrs.h>
-#include <PartSet_FeatureCirclePrs.h>
-#include <PartSet_FeatureArcPrs.h>
-
-#include <PartSet_ConstraintLengthPrs.h>
-#include <PartSet_ConstraintRadiusPrs.h>
-#include <PartSet_ConstraintDistancePrs.h>
-
#include <XGUI_ViewerPrs.h>
#include <V3d_View.hxx>
thePoint = gp_Pnt(aPoint->x(), aPoint->y(), aPoint->z());
}
-boost::shared_ptr<PartSet_FeaturePrs> PartSet_Tools::createFeaturePrs(const std::string& theKind,
- FeaturePtr theSketch,
- FeaturePtr theFeature)
-{
- boost::shared_ptr<PartSet_FeaturePrs> aFeaturePrs;
-
- if (theKind == PartSet_FeaturePointPrs::getKind()) {
- aFeaturePrs = boost::shared_ptr<PartSet_FeaturePrs>(new PartSet_FeaturePointPrs(theSketch));
- }
- else if (theKind == PartSet_FeatureLinePrs::getKind()) {
- aFeaturePrs = boost::shared_ptr<PartSet_FeaturePrs>(new PartSet_FeatureLinePrs(theSketch));
- }
- else if (theKind == PartSet_FeatureCirclePrs::getKind()) {
- aFeaturePrs = boost::shared_ptr<PartSet_FeaturePrs>(new PartSet_FeatureCirclePrs(theSketch));
- }
- else if (theKind == PartSet_FeatureArcPrs::getKind()) {
- aFeaturePrs = boost::shared_ptr<PartSet_FeaturePrs>(new PartSet_FeatureArcPrs(theSketch));
- }
- else if (theKind == PartSet_ConstraintLengthPrs::getKind()) {
- aFeaturePrs = boost::shared_ptr<PartSet_FeaturePrs>(new PartSet_ConstraintLengthPrs(theSketch));
- }
- else if (theKind == PartSet_ConstraintRadiusPrs::getKind()) {
- aFeaturePrs = boost::shared_ptr<PartSet_ConstraintRadiusPrs>(new PartSet_ConstraintRadiusPrs(theSketch));
- }
- else if (theKind == PartSet_ConstraintDistancePrs::getKind()) {
- aFeaturePrs = boost::shared_ptr<PartSet_ConstraintDistancePrs>(new PartSet_ConstraintDistancePrs(theSketch));
- }
-
-
- if (theFeature && aFeaturePrs)
- aFeaturePrs->init(theFeature);
-
- return aFeaturePrs;
-}
-
FeaturePtr PartSet_Tools::nearestFeature(QPoint thePoint, Handle_V3d_View theView,
FeaturePtr theSketch,
const std::list<XGUI_ViewerPrs>& theFeatures)
bool PartSet_Tools::isConstraintFeature(const std::string& theKind)
{
- return theKind == PartSet_ConstraintLengthPrs::getKind() ||
- theKind == PartSet_ConstraintDistancePrs::getKind() ||
- theKind == PartSet_ConstraintRadiusPrs::getKind();
+ return theKind == SKETCH_CONSTRAINT_DISTANCE_KIND ||
+ theKind == SKETCH_CONSTRAINT_LENGTH_KIND ||
+ theKind == SKETCH_CONSTRAINT_RADIUS_KIND;
}
class GeomAPI_Pln;
class GeomAPI_Pnt2d;
class GeomAPI_Pnt;
-class PartSet_FeaturePrs;
/*!
\class PartSet_Tools
static void convertTo3D(const double theX, const double theY, FeaturePtr theSketch,
gp_Pnt& thePoint);
- /// Creates the feature presentation
- /// \param theKind a feature kind
- /// \param theSketch the sketch of the feature
- /// \param theFeature the feature
- static boost::shared_ptr<PartSet_FeaturePrs> createFeaturePrs(const std::string& theKind,
- FeaturePtr theSketch,
- FeaturePtr theFeature = FeaturePtr());
-
/// Returns a feature that is under the mouse point
/// \param thePoint a screen point
/// \param theView a 3D view
// compute a circle point in 3D view
boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr =
boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(CIRCLE_ATTR_CENTER));
- boost::shared_ptr<GeomAPI_Pnt> aCenter(aSketch->to3D(aCenterAttr->x(), aCenterAttr->y()));
- // make a visible point
- boost::shared_ptr<GeomAPI_Shape> aCenterPointShape = GeomAlgoAPI_PointBuilder::point(aCenter);
- aShapes.push_back(aCenterPointShape);
-
- // make a visible circle
- boost::shared_ptr<GeomDataAPI_Dir> aNDir =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aSketch->data()->attribute(SKETCH_ATTR_NORM));
- bool aHasPlane = aNDir && !(aNDir->x() == 0 && aNDir->y() == 0 && aNDir->z() == 0);
- if (aHasPlane) {
- boost::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(aNDir->x(), aNDir->y(), aNDir->z()));
- // compute the circle radius
- AttributeDoublePtr aRadiusAttr =
- boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(data()->attribute(CIRCLE_ATTR_RADIUS));
- double aRadius = aRadiusAttr->value();
-
- boost::shared_ptr<GeomAPI_Shape> aCircleShape =
- GeomAlgoAPI_EdgeBuilder::lineCircle(aCenter, aNormal, aRadius);
- aShapes.push_back(aCircleShape);
+ if (aCenterAttr->isInitialized()) {
+ boost::shared_ptr<GeomAPI_Pnt> aCenter(aSketch->to3D(aCenterAttr->x(), aCenterAttr->y()));
+ // make a visible point
+ boost::shared_ptr<GeomAPI_Shape> aCenterPointShape = GeomAlgoAPI_PointBuilder::point(aCenter);
+ aShapes.push_back(aCenterPointShape);
+
+ // make a visible circle
+ boost::shared_ptr<GeomDataAPI_Dir> aNDir =
+ boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aSketch->data()->attribute(SKETCH_ATTR_NORM));
+ bool aHasPlane = aNDir && !(aNDir->x() == 0 && aNDir->y() == 0 && aNDir->z() == 0);
+ if (aHasPlane) {
+ boost::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(aNDir->x(), aNDir->y(), aNDir->z()));
+ // compute the circle radius
+ AttributeDoublePtr aRadiusAttr =
+ boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(data()->attribute(CIRCLE_ATTR_RADIUS));
+ double aRadius = aRadiusAttr->value();
+
+ boost::shared_ptr<GeomAPI_Shape> aCircleShape =
+ GeomAlgoAPI_EdgeBuilder::lineCircle(aCenter, aNormal, aRadius);
+ aShapes.push_back(aCircleShape);
+ }
}
boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes);
setPreview(aCompound);
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_Data.h>
-#include <SketchPlugin_Point.h>
+#include <SketchPlugin_Line.h>
+
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_ParallelRelation.hxx>
+#include <Geom_Plane.hxx>
SketchPlugin_ConstraintParallel::SketchPlugin_ConstraintParallel()
{
return getPreview();
}
+
+Handle_AIS_InteractiveObject SketchPlugin_ConstraintParallel::getAISShape(Handle_AIS_InteractiveObject thePrevious)
+{
+ Handle(AIS_InteractiveObject) anAIS = thePrevious;
+ if (!sketch())
+ return anAIS;
+
+ boost::shared_ptr<ModelAPI_Data> aData = data();
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr1 =
+ boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr2 =
+ boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_B));
+ if (!anAttr1 || !anAttr1->isFeature() ||
+ !anAttr2 || !anAttr2->isFeature())
+ return anAIS;
+ boost::shared_ptr<SketchPlugin_Line> aLine1Feature =
+ boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr1->feature());
+ boost::shared_ptr<SketchPlugin_Line> aLine2Feature =
+ boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr2->feature());
+ if (!aLine1Feature || !aLine2Feature)
+ return anAIS;
+
+ boost::shared_ptr<GeomAPI_Shape> aLine1 = aLine1Feature->preview();
+ boost::shared_ptr<GeomAPI_Shape> aLine2 = aLine2Feature->preview();
+ Handle(Geom_Plane) aPlane = new Geom_Plane(sketch()->plane()->impl<gp_Pln>());
+
+ if (anAIS.IsNull())
+ {
+ Handle(AIS_ParallelRelation) aParallel =
+ new AIS_ParallelRelation(aLine1->impl<TopoDS_Shape>(), aLine2->impl<TopoDS_Shape>(), aPlane);
+
+ anAIS = aParallel;
+ }
+ else
+ {
+ Handle(AIS_ParallelRelation) aParallel = Handle(AIS_ParallelRelation)::DownCast(anAIS);
+ if (!aParallel.IsNull())
+ {
+ aParallel->SetFirstShape(aLine1->impl<TopoDS_Shape>());
+ aParallel->SetSecondShape(aLine2->impl<TopoDS_Shape>());
+ aParallel->SetPlane(aPlane);
+ aParallel->Redisplay(Standard_True);
+ }
+ }
+ return anAIS;
+}
+
/// \brief Returns the sketch preview
SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
+ /// Returns the AIS preview
+ SKETCHPLUGIN_EXPORT virtual Handle_AIS_InteractiveObject getAISShape(Handle_AIS_InteractiveObject thePrevious);
+
/// \brief Use plugin manager for features creation
SketchPlugin_ConstraintParallel();
};
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_Data.h>
-#include <SketchPlugin_Point.h>
+#include <SketchPlugin_Line.h>
+
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_PerpendicularRelation.hxx>
+#include <Geom_Plane.hxx>
SketchPlugin_ConstraintPerpendicular::SketchPlugin_ConstraintPerpendicular()
{
return getPreview();
}
+Handle_AIS_InteractiveObject SketchPlugin_ConstraintPerpendicular::getAISShape(Handle_AIS_InteractiveObject thePrevious)
+{
+ Handle(AIS_InteractiveObject) anAIS = thePrevious;
+ if (!sketch())
+ return anAIS;
+
+ boost::shared_ptr<ModelAPI_Data> aData = data();
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr1 =
+ boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr2 =
+ boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_B));
+ if (!anAttr1 || !anAttr1->isFeature() ||
+ !anAttr2 || !anAttr2->isFeature())
+ return anAIS;
+ boost::shared_ptr<SketchPlugin_Line> aLine1Feature =
+ boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr1->feature());
+ boost::shared_ptr<SketchPlugin_Line> aLine2Feature =
+ boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr2->feature());
+ if (!aLine1Feature || !aLine2Feature)
+ return anAIS;
+
+ boost::shared_ptr<GeomAPI_Shape> aLine1 = aLine1Feature->preview();
+ boost::shared_ptr<GeomAPI_Shape> aLine2 = aLine2Feature->preview();
+ Handle(Geom_Plane) aPlane = new Geom_Plane(sketch()->plane()->impl<gp_Pln>());
+
+ if (anAIS.IsNull())
+ {
+ Handle(AIS_PerpendicularRelation) aPerpendicular =
+ new AIS_PerpendicularRelation(aLine1->impl<TopoDS_Shape>(), aLine2->impl<TopoDS_Shape>(), aPlane);
+
+ anAIS = aPerpendicular;
+ }
+ else
+ {
+ Handle(AIS_PerpendicularRelation) aPerpendicular = Handle(AIS_PerpendicularRelation)::DownCast(anAIS);
+ if (!aPerpendicular.IsNull())
+ {
+ aPerpendicular->SetFirstShape(aLine1->impl<TopoDS_Shape>());
+ aPerpendicular->SetSecondShape(aLine2->impl<TopoDS_Shape>());
+ aPerpendicular->SetPlane(aPlane);
+ aPerpendicular->Redisplay(Standard_True);
+ }
+ }
+ return anAIS;
+}
+
/// \brief Returns the sketch preview
SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
+ /// Returns the AIS preview
+ SKETCHPLUGIN_EXPORT virtual Handle_AIS_InteractiveObject getAISShape(Handle_AIS_InteractiveObject thePrevious);
+
/// \brief Use plugin manager for features creation
SketchPlugin_ConstraintPerpendicular();
};
if (!aData->isValid())
return;
- //boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
- // boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT));
- //aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT));
+ aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
}
<plugin>
<workbench id="Sketch">
<group id="Basic">
- <feature id="Sketch" nested="SketchPoint SketchLine SketchCircle SketchArc SketchConstraintLength SketchConstraintRadius SketchConstraintDistance SketchConstraintParallel SketchConstraintPerpendicular" title="Sketch" tooltip="Create a new sketch or edit an existing sketch" icon=":icons/sketch.png">
+ <feature id="Sketch" nested="SketchPoint SketchLine SketchCircle SketchArc SketchConstraintLength SketchConstraintRadius SketchConstraintDistance SketchConstraintParallel SketchConstraintPerpendicular SketchConstraintCoincidence" title="Sketch" tooltip="Create a new sketch or edit an existing sketch" icon=":icons/sketch.png">
<label title="Select a plane on which to create a sketch" tooltip="Select a plane on which to create a sketch"/>
<!--icon=":pictures/x_point.png"-->
</feature>
<point_selector id="ArcStartPoint" title="Start point" tooltip="Start point of the arc"/>
<point_selector id="ArcEndPoint" title="End point" tooltip="End point of the arc"/>
</feature>
- <feature id="SketchConstraintCoincidence" title="Points coincidence" tooltip="Create constraint for the coincidence of two points" internal="1"/>
- <feature id="SketchConstraintDistance" title="Distance between objects" tooltip="Create constraint for the distance from a point to an object">
+ <feature id="SketchConstraintCoincidence" title="Coincident" tooltip="Create constraint for the coincidence of two points">
+ <label title="Select two points to become coincident" tooltip="Select two points to become coincident"/>
+ <feature_selector id="ConstraintEntityA" label="First point" tooltip="Select an entity in the viewer" keysequence="SketchPoint"/>
+ <feature_selector id="ConstraintEntityB" label="Last point" tooltip="Select an entity in the viewer" keysequence="SketchPoint"/>
+ </feature>
+ <feature id="SketchConstraintDistance" title="Distance" tooltip="Create constraint for the distance from a point to an object">
<label title="Select point and another feature (point or point on line) between which to calculate distance" tooltip="Select point and another feature (point or point on line) between which to calculate distance"/>
<feature_selector id="ConstraintEntityA" label="First point" tooltip="Select an entity in the viewer" keysequence="SketchPoint"/>
<feature_selector id="ConstraintEntityB" label="Last point" tooltip="Select an entity in the viewer" keysequence="SketchPoint"/>
<point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
- <doublevalue_editor id="ConstraintValue"/>
+ <doublevalue_editor label="Value" tooltip="Constraint value" id="ConstraintValue"/>
</feature>
- <feature id="SketchConstraintLength" title="Length of a line" tooltip="Create constraint for the given length of a line segment">
+ <feature id="SketchConstraintLength" title="Length" tooltip="Create constraint for the given length of a line segment">
<label title="Select a line entity on which to calculate lenght" tooltip="Select a line entity on which to calculate lenght"/>
<feature_selector id="ConstraintEntityA" label="Line" tooltip="Select an entity in the viewer" keysequence="SketchLine"/>
<point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
- <doublevalue_editor id="ConstraintValue"/>
+ <doublevalue_editor label="Value" tooltip="Constraint value" id="ConstraintValue"/>
</feature>
- <feature id="SketchConstraintRadius" title="Radius of a circle or an arc" tooltip="Create constraint for the given radius of a circle or an arc">
+ <feature id="SketchConstraintRadius" title="Radius" tooltip="Create constraint for the given radius of a circle or an arc">
<label title="Select two points on a circle or an arc of circle on which to calculate radius" tooltip="Select two points on a circle or an arc of circle on which to calculate radius"/>
<feature_selector id="ConstraintEntityA" label="Circle or Arc" tooltip="Select an entity in the viewer" keysequence="SketchCircle SketchArc"/>
<point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
- <doublevalue_editor id="ConstraintValue"/>
+ <doublevalue_editor label="Value" tooltip="Constraint value" id="ConstraintValue"/>
</feature>
- <feature id="SketchConstraintParallel" title="Parallelism of a lines" tooltip="Create constraint defining two parallel lines">
+ <feature id="SketchConstraintParallel" title="Parallel" tooltip="Create constraint defining two parallel lines">
<feature_selector id="ConstraintEntityA" label="First line" tooltip="Select an entity in the viewer" keysequence="SketchLine"/>
<feature_selector id="ConstraintEntityB" label="Last line" tooltip="Select an entity in the viewer" keysequence="SketchLine"/>
</feature>
- <feature id="SketchConstraintPerpendicular" title="Orthgonality of a lines" tooltip="Create constraint defining two perpendicular lines">
+ <feature id="SketchConstraintPerpendicular" title="Perpendicular" tooltip="Create constraint defining two perpendicular lines">
<feature_selector id="ConstraintEntityA" label="First line" tooltip="Select an entity in the viewer" keysequence="SketchLine"/>
<feature_selector id="ConstraintEntityB" label="Last line" tooltip="Select an entity in the viewer" keysequence="SketchLine"/>
</feature>
{
// Several points may be coincident, it is not necessary to store all constraints between them.
// Try to find sequence of coincident points which connects the points of new constraint
- if (aConstrType == SLVS_C_POINTS_COINCIDENT &&
- !addCoincidentPoints(aConstrEnt[0], aConstrEnt[1]))
+ if (aConstrType == SLVS_C_POINTS_COINCIDENT)
{
- myExtraCoincidence.insert(theConstraint); // the constraint is stored for further purposes
- return false;
+ if (aConstrEnt[0] == aConstrEnt[1]) // no need to add self coincidence
+ {
+ return false;
+ }
+ if (!addCoincidentPoints(aConstrEnt[0], aConstrEnt[1]))
+ {
+ myExtraCoincidence.insert(theConstraint); // the constraint is stored for further purposes
+ return false;
+ }
}
// Create SolveSpace constraint structure
connect(*anIt, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)),
this, SLOT(onActivateNextWidget(ModuleBase_ModelWidget*)));
+ connect(*anIt, SIGNAL(activated(ModuleBase_ModelWidget*)),
+ this, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)));
+
ModuleBase_WidgetPoint2D* aPointWidget = dynamic_cast<ModuleBase_WidgetPoint2D*>(*anIt);
if (aPointWidget)
connect(aPointWidget, SIGNAL(storedPoint2D(FeaturePtr, const std::string&)),
setTabOrder(anOkBtn, aCancelBtn);
}
}
- ModuleBase_ModelWidget* aWidget = theWidgets.first();
- if (aWidget) {
- activateWidget(aWidget);
- }
+ onActivateNextWidget(0);
}
}
repaint();
}
-void XGUI_PropertyPanel::onFocusActivated(const std::string& theAttributeName)
-{
- if (theAttributeName == XGUI::PROP_PANEL_OK) {
- QPushButton* aBtn = findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
- aBtn->setFocus();
- }
- if (theAttributeName == XGUI::PROP_PANEL_CANCEL) {
- QPushButton* aBtn = findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
- aBtn->setFocus();
- }
- else {
- foreach(ModuleBase_ModelWidget* eachWidget, myWidgets) {
- if (eachWidget->canFocusTo(theAttributeName)) {
- eachWidget->focusTo();
- break;
- }
- }
- }
-}
-
void XGUI_PropertyPanel::onActivateNextWidget(ModuleBase_ModelWidget* theWidget)
{
ModuleBase_ModelWidget* aNextWidget = 0;
-
QList<ModuleBase_ModelWidget*>::const_iterator anIt = myWidgets.begin(),
aLast = myWidgets.end();
- for (;anIt != aLast; anIt++)
+ bool isFoundWidget = false;
+ for (;anIt != aLast && !aNextWidget; anIt++)
{
- if ((*anIt) == theWidget) {
- anIt++;
- if (anIt != aLast)
+ if (isFoundWidget || !theWidget) {
+ if ((*anIt)->focusTo()) {
aNextWidget = *anIt;
- break;
+ }
}
+ isFoundWidget = (*anIt) == theWidget;
}
- activateWidget(aNextWidget);
-}
-
-void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget)
-{
- emit widgetActivated(theWidget);
- // it is important that the signal widgetActivated goes before the focusTo() calling
- // in order to handle next possible signal in the focusTo() method
- // (e.g. the widget editor sends a signal about the widget deactivation)
- if (theWidget)
- theWidget->focusTo();
+ emit widgetActivated(aNextWidget);
}
public slots:
void updateContentWidget(FeaturePtr theFeature);
- /// slot to set the focus to the widget visualized an attribute with the given name
- /// \param theAttributteName
- void onFocusActivated(const std::string& theAttributeName);
/// slot to activate the next widget in the property panel
/// \param theWidget a widget. The next widget should be activated
void onActivateNextWidget(ModuleBase_ModelWidget* theWidget);
/// \param the attribute of the feature
void storedPoint2D(FeaturePtr theFeature, const std::string& theAttribute);
-protected:
- /// Activate the widget, which means the focus on the widget.
- /// The signal about the widget activation is emitted
- /// \param theWidget
- void activateWidget(ModuleBase_ModelWidget* theWidget);
-
private:
QWidget* myCustomWidget;