1. Split init(feature, feature) on init(feature), setFeature(feature, selection mode). The cause is lenght constraint.
2. Mouse double click signal listen by operation.
3. Correct displayer to use the selection mode only in activateInLocalContext method. It was temporary realized in the redisplay().
4. Increase selection tolerance for dimension text.
return boost::shared_ptr<GeomDataAPI_Point2D>();
}
-void PartSet_FeatureLengthPrs::initFeature(FeaturePtr theSourceFeature)
+bool PartSet_FeatureLengthPrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
{
- if (feature() && theSourceFeature && theSourceFeature->getKind() == SKETCH_LINE_KIND)
+ bool aResult = false;
+ 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(theSourceFeature);
+ aRef->setFeature(theFeature);
// set length value
- aData = theSourceFeature->data();
+ 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 =
double aLenght = aPoint1->pnt()->distance(aPoint2->pnt());
PartSet_Tools::setFeatureValue(feature(), aLenght, CONSTRAINT_ATTR_VALUE);
+ aResult = true;
}
+ return aResult;
}
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 bool 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 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);
-
- /// Initializes current feature by the given
- /// \param theSourceFeature the feature, which attributes are used to initialize the current feature
- virtual void initFeature(FeaturePtr theSourceFeature);
};
#endif
return SKETCH_LINE_KIND;
}
-void PartSet_FeatureLinePrs::initFeature(FeaturePtr theFeature)
-{
- if (feature() && theFeature)
- {
- // 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);
- }
-}
-
PartSet_SelectionMode PartSet_FeatureLinePrs::setPoint(double theX, double theY,
const PartSet_SelectionMode& theMode)
{
return aMode;
}
+bool PartSet_FeatureLinePrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode)
+{
+ bool aResult = false;
+ 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);
+ aResult = true;
+ }
+ return aResult;
+}
+
std::string PartSet_FeatureLinePrs::getAttribute(const PartSet_SelectionMode& theMode) const
{
std::string aAttribute;
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 bool 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;
double& theX, double& theY);
protected:
- /// Initializes current feature by the given
- /// \param theSourceFeature the feature, which attributes are used to initialize the current feature
- virtual void initFeature(FeaturePtr theSourceFeature);
-
/// 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);
{
}
-void PartSet_FeaturePrs::init(FeaturePtr theFeature, FeaturePtr theSourceFeature)
+void PartSet_FeaturePrs::init(FeaturePtr theFeature)
{
myFeature = theFeature;
- if (theSourceFeature) {
- initFeature(theSourceFeature);
- }
}
FeaturePtr PartSet_FeaturePrs::sketch() const
/// Initializes some fields of feature accorging to the source feature
/// Saves the fiature as the presentation internal feature
/// \param theFeature the presentation feature
- /// \param theSourceFeature the feature, which attributes are used to initialize the feature
- void init(FeaturePtr theFeature, FeaturePtr theSourceFeature);
+ void init(FeaturePtr theFeature);
/// Returns the operation sketch feature
/// \returns the sketch instance
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
+ virtual bool setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode) { return false; };
+
/// 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;
/// \return the feature
FeaturePtr feature() const;
- /// Initializes current feature by the given
- /// \param theSourceFeature the feature, which attributes are used to initialize the current feature
- virtual void initFeature(FeaturePtr theSourceFeature) {};
-
/// 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;
#include <GeomAPI_Shape.h>
#include <AIS_ListOfInteractive.hxx>
-#include <AIS_DimensionSelectionMode.hxx>
+//#include <AIS_DimensionSelectionMode.hxx>
#include <QObject>
#include <QMouseEvent>
this, SLOT(onMouseMoved(QMouseEvent*)));
connect(myWorkshop->viewer(), SIGNAL(keyRelease(QKeyEvent*)),
this, SLOT(onKeyRelease(QKeyEvent*)));
+ connect(myWorkshop->viewer(), SIGNAL(mouseDoubleClick(QMouseEvent*)),
+ this, SLOT(onMouseDoubleClick(QMouseEvent*)));
+
}
PartSet_Module::~PartSet_Module()
}
}
+void PartSet_Module::onMouseDoubleClick(QMouseEvent* theEvent)
+{
+ PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
+ myWorkshop->operationMgr()->currentOperation());
+ if (aPreviewOp)
+ {
+ XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+ std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected();
+ std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted();
+ aPreviewOp->mouseDoubleClick(theEvent, myWorkshop->viewer()->activeView(), aSelected,
+ aHighlighted);
+ }
+}
+
void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ)
{
myWorkshop->viewer()->setViewProjection(theX, theY, theZ);
aPreview ? aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(),
aDisplayer->getAISObject(theFeature));
- int aSelectionMode = -1;
- if (theFeature->getKind() == SKETCH_CONSTRAINT_LENGTH_KIND) {
- aSelectionMode = AIS_DSM_Text;
- }
- aDisplayer->redisplay(theFeature, anAIS, aSelectionMode, false);
+ aDisplayer->redisplay(theFeature, anAIS, false);
}
else
aDisplayer->erase(theFeature, false);
aPreview ? aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(),
aDisplayer->getAISObject(aFeature));
if (!anAIS.IsNull())
- aDisplayer->redisplay(aFeature, anAIS, -1, false);
+ aDisplayer->redisplay(aFeature, anAIS, false);
aDisplayer->activateInLocalContext(aFeature, aModes, false);
}
aDisplayer->updateViewer();
/// \param theEvent the mouse event
void onKeyRelease(QKeyEvent* theEvent);
+ /// SLOT, that is called by the mouse double click in the viewer.
+ /// \param theEvent the mouse event
+ void onMouseDoubleClick(QMouseEvent* theEvent);
+
/// SLOT, to apply to the current viewer the operation
/// \param theX the X projection value
/// \param theY the Y projection value
#include <PartSet_Tools.h>
#include <PartSet_OperationSketch.h>
+#include <SketchPlugin_ConstraintLength.h>
#include <SketchPlugin_Feature.h>
#include <SketchPlugin_Sketch.h>
{
}
+std::string PartSet_OperationConstraint::Type()
+{
+ return SKETCH_CONSTRAINT_LENGTH_KIND;
+}
+
bool PartSet_OperationConstraint::isGranted(ModuleBase_IOperation* theOperation) const
{
return theOperation->getDescription()->operationId().toStdString() == PartSet_OperationSketch::Type();
#include <PartSet_OperationSketchBase.h>
-#include <SketchPlugin_ConstraintLength.h>
-
#include <QObject>
/*!
public:
/// Returns the operation type key
- static std::string Type() { return SKETCH_CONSTRAINT_LENGTH_KIND; }
+ static std::string Type();
public:
/// Constructor
XGUI_ViewerPrs aPrs = theSelected.front();
FeaturePtr aFeature = aPrs.feature();
- myFeaturePrs->init(feature(), aFeature);
- flushUpdated();
- setPointSelectionMode(SM_SecondPoint);
+ if (myFeaturePrs->setFeature(aFeature, myPointSelectionMode)) {
+ flushUpdated();
+ setPointSelectionMode(SM_SecondPoint);
+ }
}
}
break;
// it start a new line creation at a free point
restartOperation(feature()->getKind(), FeaturePtr()/*feature()*/);
}
- //else
- // abort();
- //restartOperation(feature()->getKind(), FeaturePtr());
+ // changed
+ // the modification is really need until the focus of editor do not accept the focus
+ if (myPointSelectionMode == SM_ThirdPoint) {
+ if (myEditor->isStarted())
+ myEditor->stop();
+ commit();
+ // it start a new line creation at a free point
+ restartOperation(feature()->getKind(), FeaturePtr()/*feature()*/);
+ }
}
break;
case Qt::Key_Escape: {
aFeature->addSub(aNewFeature);
}
- myFeaturePrs->init(aNewFeature, myInitFeature);
+ myFeaturePrs->init(aNewFeature);
+ if (myInitFeature)
+ myFeaturePrs->setFeature(myInitFeature, SM_FirstPoint);
emit featureConstructed(aNewFeature, FM_Activation);
if (theFlushMessage)
aFeature->addSub(aNewFeature);
}
- myFeaturePrs->init(aNewFeature, myInitFeature);
+ myFeaturePrs->init(aNewFeature);
+ myFeaturePrs->setFeature(myInitFeature, SM_FirstPoint);
emit featureConstructed(aNewFeature, FM_Activation);
if (theFlushMessage)
}
}
+#include <QLineEdit>
+void PartSet_OperationSketch::mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
+ const std::list<XGUI_ViewerPrs>& theSelected,
+ const std::list<XGUI_ViewerPrs>& theHighlighted)
+{
+ return;
+ if (!hasSketchPlane())
+ return;
+ if (!theSelected.empty()) {
+ XGUI_ViewerPrs aPrs = theSelected.front();
+ if (!aPrs.owner().IsNull()) {
+ Handle(AIS_DimensionOwner) anOwner = Handle(AIS_DimensionOwner)::DownCast(aPrs.owner());
+ if (!anOwner.IsNull() && anOwner->SelectionMode() == AIS_DSM_Text) {
+ Handle(SelectMgr_SelectableObject) anObject = anOwner->Selectable();
+ double aValue = 0;
+ if (!anObject.IsNull()) {
+ Handle(AIS_LengthDimension) aLenDim = Handle(AIS_LengthDimension)::DownCast(anObject);
+ if (!aLenDim.IsNull())
+ aValue = aLenDim->GetValue();
+ }
+
+ QLineEdit* aLine = new QLineEdit();
+ QPoint aViewPos = theEvent->globalPos();
+ QPoint aLinePos(aViewPos.x(), aViewPos.y());
+ aLine->move(aLinePos);
+ aLine->setText(QString::number(aValue));
+ aLine->show();
+ }
+ }
+ }
+}
+
void PartSet_OperationSketch::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
{
if (!hasSketchPlane() || !(theEvent->buttons() & Qt::LeftButton) || myFeatures.empty())
/// \param theEvent the mouse event
virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
+ /// Processes the mouse double click in the point
+ /// \param theEvent the mouse event
+ /// \param theView a viewer to have the viewer the eye position
+ /// \param theSelected the list of selected presentations
+ /// \param theHighlighted the list of highlighted presentations
+ virtual void mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
+ const std::list<XGUI_ViewerPrs>& theSelected,
+ const std::list<XGUI_ViewerPrs>& theHighlighted);
+
/// Returns the map of the operation previews including the nested feature previews
/// \return the map of feature to the feature preview
virtual std::map<FeaturePtr, boost::shared_ptr<GeomAPI_Shape> >
#include <SketchPlugin_Feature.h>
#include <V3d_View.hxx>
+#include <AIS_Shape.hxx>
#include <QKeyEvent>
return std::map<FeaturePtr, boost::shared_ptr<GeomAPI_Shape> >();
}
+#include <AIS_DimensionSelectionMode.hxx>
+#include <SketchPlugin_ConstraintLength.h>
std::list<int> PartSet_OperationSketchBase::getSelectionModes(FeaturePtr theFeature) const
{
std::list<int> aModes;
- aModes.push_back(TopAbs_VERTEX);
- aModes.push_back(TopAbs_EDGE);
+ if (theFeature->getKind() == SKETCH_CONSTRAINT_LENGTH_KIND) {
+ aModes.clear();
+ aModes.push_back(AIS_DSM_Text);
+ aModes.push_back(AIS_DSM_Line);
+ }
+ else {
+ aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)TopAbs_VERTEX));
+ aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)TopAbs_EDGE));
+ }
return aModes;
}
FeaturePtr PartSet_OperationSketchBase::createFeature(const bool theFlushMessage)
void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
{
}
+void PartSet_OperationSketchBase::mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
+ const std::list<XGUI_ViewerPrs>& theSelected,
+ const std::list<XGUI_ViewerPrs>& theHighlighted)
+{
+}
void PartSet_OperationSketchBase::keyReleased(const int theKey)
{
/// \param theView a viewer to have the viewer the eye position
virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
+ /// Processes the mouse double click in the point
+ /// \param theEvent the mouse event
+ /// \param theView a viewer to have the viewer the eye position
+ /// \param theSelected the list of selected presentations
+ /// \param theHighlighted the list of highlighted presentations
+ virtual void mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
+ const std::list<XGUI_ViewerPrs>& theSelected,
+ const std::list<XGUI_ViewerPrs>& theHighlighted);
+
/// Processes the key pressed in the view
/// \param theKey a key value
virtual void keyReleased(const int theKey);
const Quantity_NameOfColor SKETCH_PLANE_COLOR = Quantity_NOC_CHOCOLATE; /// the plane edge color
const int SKETCH_WIDTH = 4; /// the plane edge width
+const int CONSTRAINT_TEXT_HEIGHT = 28; /// the text height of the constraint
+const int CONSTRAINT_TEXT_SELECTION_TOLERANCE = 20; /// the text selection tolerance
+
Handle(AIS_InteractiveObject) PartSet_Presentation::createPresentation(
FeaturePtr theFeature,
FeaturePtr theSketch,
Handle(AIS_InteractiveObject) anAIS = thePrevPrs;
if (anAIS.IsNull())
{
- Handle(AIS_LengthDimension) aLenDim = new AIS_LengthDimension (aP1, aP2, aPlane);
+ Handle(AIS_LengthDimension) aDimAIS = new AIS_LengthDimension (aP1, aP2, aPlane);
Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
anAspect->MakeArrows3d (Standard_False);
anAspect->MakeText3d(false/*is text 3d*/);
- anAspect->TextAspect()->SetHeight(28);
+ anAspect->TextAspect()->SetHeight(CONSTRAINT_TEXT_HEIGHT);
anAspect->MakeTextShaded(false/*is test shaded*/);
- aLenDim->DimensionAspect()->MakeUnitsDisplayed(false/*is units displayed*/);
+ aDimAIS->DimensionAspect()->MakeUnitsDisplayed(false/*is units displayed*/);
/*if (isUnitsDisplayed)
{
- aLenDim->SetDisplayUnits (aDimDlg->GetUnits ());
+ aDimAIS->SetDisplayUnits (aDimDlg->GetUnits ());
}*/
- aLenDim->SetDimensionAspect (anAspect);
- aLenDim->SetFlyout(aFlyout);
+ aDimAIS->SetDimensionAspect (anAspect);
+ aDimAIS->SetFlyout(aFlyout);
+ aDimAIS->SetSelToleranceForText2d(CONSTRAINT_TEXT_SELECTION_TOLERANCE);
- anAIS = aLenDim;
+ anAIS = aDimAIS;
}
else {
// update presentation
aFeature, aSketch,
aPreview ? aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(), NULL);
if (!anAIS.IsNull())
- aDisplayer->redisplay(aFeature, anAIS, -1, false);
+ aDisplayer->redisplay(aFeature, anAIS, false);
std::list<int> aModes;
aModes.push_back(TopAbs_VERTEX);
aFeature, aSketch,
aPreview ? aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(), NULL);
if (!anAIS.IsNull())
- aDisplayer->redisplay(aFeature, anAIS, -1, true);
+ aDisplayer->redisplay(aFeature, anAIS, true);
int aVal = 90;
for (int j = 0; j < 10000000; j++)
aPreview ? aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(),
aPrevAIS);
if (!anAIS.IsNull())
- theWorkshop->displayer()->redisplay(aFeature, anAIS, -1, true);
+ theWorkshop->displayer()->redisplay(aFeature, anAIS, true);
//std::list<int> aModes;
//aModes.clear();
//aModes.push_back(TopAbs_VERTEX);
}
if (theFeature && aFeaturePrs)
- aFeaturePrs->init(theFeature, FeaturePtr());
+ aFeaturePrs->init(theFeature);
return aFeaturePrs;
}
bool XGUI_Displayer::redisplay(FeaturePtr theFeature,
Handle(AIS_InteractiveObject) theAIS,
- const int theSelectionMode,
const bool isUpdateViewer)
{
bool isCreated = false;
}
else {
myFeature2AISObjectMap[theFeature] = theAIS;
- if (theSelectionMode < 0)
- {
- aContext->Display(theAIS, false);
- }
- else
- {
- aContext->Display(theAIS, 0, theSelectionMode, false);
- }
+ aContext->Display(theAIS, false);
isCreated = true;
}
if (isUpdateViewer)
aContext->OpenLocalContext(false/*use displayed objects*/, true/*allow shape decomposition*/);
}
// display or redisplay presentation
- Handle(AIS_Shape) anAIS;
+ Handle(AIS_InteractiveObject) anAIS;
if (isVisible(theFeature))
- anAIS = Handle(AIS_Shape)::DownCast(myFeature2AISObjectMap[theFeature]);
+ anAIS = Handle(AIS_InteractiveObject)::DownCast(myFeature2AISObjectMap[theFeature]);
// Activate selection of objects from prs
if (!anAIS.IsNull()) {
std::list<int>::const_iterator anIt = theModes.begin(), aLast = theModes.end();
for (; anIt != aLast; anIt++)
{
- aContext->Activate(anAIS, AIS_Shape::SelectionMode((TopAbs_ShapeEnum)*anIt));
+ aContext->Activate(anAIS, (*anIt));
}
}
/// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
/// \returns true if the presentation is created
bool redisplay(FeaturePtr theFeature,
- Handle(AIS_InteractiveObject) theAIS,
- const int theSelectionMode, const bool isUpdateViewer = true);
+ Handle(AIS_InteractiveObject) theAIS, const bool isUpdateViewer = true);
/** Redisplay the shape if it was displayed
* \param theFeature a feature instance