class ModuleBase_IModule;
class ModuleBase_ISelection;
class ModuleBase_IViewer;
+class ModuleBase_IPropertyPanel;
class ModuleBase_Operation;
class ModuleBase_FilterFactory;
//! Returns current viewer
virtual ModuleBase_IViewer* viewer() const = 0;
+ //! Returns property panel
+ virtual ModuleBase_IPropertyPanel* propertyPanel() const = 0;
+
/// A filter to process an attribute validators
/// \return a filter
Handle(ModuleBase_FilterValidated) validatorFilter();
XGUI_Workshop* aWorkshop = aConnector->workshop();
ModuleBase_ModelWidget* aWgt = NULL;
if (theType == "sketch-start-label") {
- PartSet_WidgetSketchLabel* aLabelWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, theParentId);
+ PartSet_WidgetSketchLabel* aLabelWgt = new PartSet_WidgetSketchLabel(theParent,
+ theWidgetApi, theParentId, mySketchMgr->isConstraintsShown());
aLabelWgt->setWorkshop(aWorkshop);
connect(aLabelWgt, SIGNAL(planeSelected(const std::shared_ptr<GeomAPI_Pln>&)),
mySketchMgr, SLOT(onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>&)));
+ connect(aLabelWgt, SIGNAL(showConstraintToggled(bool)),
+ mySketchMgr, SLOT(onShowConstraintsToggle(bool)));
aWgt = aLabelWgt;
} else if (theType == "sketch-2dpoint_selector") {
PartSet_WidgetPoint2D* aPointWgt = new PartSet_WidgetPoint2D(theParent, theWidgetApi, theParentId);
XGUI_Displayer* aDisplayer = aWorkshop->displayer();
Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
- double aLen = aView->Convert(25);
+ double aLen = aView->Convert(15);
SketcherPrs_Tools::setArrowSize(aLen);
bool isModified = false;
#include "PartSet_WidgetPoint2d.h"
#include "PartSet_WidgetPoint2dDistance.h"
#include "PartSet_Tools.h"
+#include "PartSet_WidgetSketchLabel.h"
#include <ModuleBase_WidgetEditor.h>
#include <SketchPlugin_ConstraintEqual.h>
#include <SketchPlugin_ConstraintTangent.h>
#include <SketchPlugin_ConstraintCoincidence.h>
+#include <SketchPlugin_ConstraintFillet.h>
+#include <SketchPlugin_ConstraintMirror.h>
#include <SelectMgr_IndexedMapOfOwner.hxx>
#include <StdSelect_BRepOwner.hxx>
: QObject(theModule), myModule(theModule), myIsDragging(false), myDragDone(false),
myIsPropertyPanelValueChanged(false), myIsMouseOverWindow(false),
myIsMouseOverViewProcessed(true), myPreviousUpdateViewerEnabled(true),
- myIsPopupMenuActive(false)
+ myIsPopupMenuActive(false), myIsConstraintsShown(true)
{
ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
ModuleBase_IViewer* aViewer = anIWorkshop->viewer();
}
-QStringList PartSet_SketcherMgr::sketchOperationIdList()
+const QStringList& PartSet_SketcherMgr::sketchOperationIdList()
{
static QStringList aIds;
if (aIds.size() == 0) {
aIds << SketchPlugin_ConstraintEqual::ID().c_str();
aIds << SketchPlugin_ConstraintTangent::ID().c_str();
aIds << SketchPlugin_ConstraintCoincidence::ID().c_str();
+ aIds << SketchPlugin_ConstraintFillet::ID().c_str();
+ aIds << SketchPlugin_ConstraintMirror::ID().c_str();
}
return aIds;
}
+const QStringList& PartSet_SketcherMgr::constraintsIdList()
+{
+ static QStringList aIds;
+ if (aIds.size() == 0) {
+ aIds << SketchPlugin_ConstraintLength::ID().c_str();
+ aIds << SketchPlugin_ConstraintDistance::ID().c_str();
+ aIds << SketchPlugin_ConstraintRigid::ID().c_str();
+ aIds << SketchPlugin_ConstraintRadius::ID().c_str();
+ aIds << SketchPlugin_ConstraintPerpendicular::ID().c_str();
+ aIds << SketchPlugin_ConstraintParallel::ID().c_str();
+ aIds << SketchPlugin_ConstraintHorizontal::ID().c_str();
+ aIds << SketchPlugin_ConstraintVertical::ID().c_str();
+ aIds << SketchPlugin_ConstraintEqual::ID().c_str();
+ aIds << SketchPlugin_ConstraintTangent::ID().c_str();
+ aIds << SketchPlugin_ConstraintCoincidence::ID().c_str();
+ aIds << SketchPlugin_ConstraintMirror::ID().c_str();
+ }
+ return aIds;
+}
+
+
bool PartSet_SketcherMgr::isSketchOperation(ModuleBase_Operation* theOperation)
{
return theOperation && theOperation->id().toStdString() == SketchPlugin_Sketch::ID();
connectToPropertyPanel(true);
}
-void PartSet_SketcherMgr::stopNestedSketch(ModuleBase_Operation* theOperation)
+void PartSet_SketcherMgr::stopNestedSketch(ModuleBase_Operation* theOp)
{
connectToPropertyPanel(false);
myIsPropertyPanelValueChanged = false;
{
if (isNestedCreateOperation(theOperation))
visualizeFeature(theOperation, true);
+
+ if (constraintsIdList().contains(theOperation->id())) {
+ // Show constraints if a constraint was created
+ onShowConstraintsToggle(true);
+ }
}
bool PartSet_SketcherMgr::canUndo() const
aConnector->workshop()->selector()->setSelectedOwners(anOwnersToSelect, false);
}
}
+
+void PartSet_SketcherMgr::onShowConstraintsToggle(bool theOn)
+{
+ if (myIsConstraintsShown == theOn)
+ return;
+ if (myCurrentSketch.get() == NULL)
+ return;
+
+ myIsConstraintsShown = theOn;
+
+ ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
+ XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
+
+ const QStringList& aConstrIds = constraintsIdList();
+ for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
+ FeaturePtr aSubFeature = myCurrentSketch->subFeature(i);
+ if (aConstrIds.contains(QString(aSubFeature->getKind().c_str()))) {
+ if (myIsConstraintsShown)
+ aDisplayer->display(aSubFeature, false);
+ else
+ aDisplayer->erase(aSubFeature, false);
+ }
+ }
+ aDisplayer->updateViewer();
+}
/// \param isChecked if true, the feature is a construction
void setAuxiliary(const bool isChecked);
+
+ bool isConstraintsShown() const { return myIsConstraintsShown; }
+
+
+ /// Returns list of strings which contains id's of sketch operations
+ static const QStringList& sketchOperationIdList();
+
+ /// Returns list of strings which contains id's of constraints operations
+ static const QStringList& constraintsIdList();
+
public slots:
/// Process sketch plane selected event
void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
void onBeforeContextMenu();
void onAfterContextMenu();
+ void onShowConstraintsToggle(bool);
+
private:
/// Launches the operation from current highlighting
void launchEditing();
- /// Returns list of strings which contains id's of sketch operations
- static QStringList sketchOperationIdList();
-
/// Converts mouse position to 2d coordinates.
/// Member myCurrentSketch has to be correctly defined
void get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent,
Handle(ModuleBase_ShapeInPlaneFilter) myPlaneFilter;
FeatureToSelectionMap myCurrentSelection;
bool myPreviousUpdateViewerEnabled;
+
+ bool myIsConstraintsShown;
};
#include <QTimer>
#include <QApplication>
#include <QVBoxLayout>
+#include <QCheckBox>
PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent,
const Config_WidgetAPI* theData,
- const std::string& theParentId)
+ const std::string& theParentId,
+ bool toShowConstraints)
: ModuleBase_WidgetValidated(theParent, theData, theParentId),
myPreviewDisplayed(false),
myWorkshop(NULL)
QVBoxLayout* aLayout = new QVBoxLayout(this);
ModuleBase_Tools::zeroMargins(aLayout);
aLayout->addWidget(myLabel);
+
+ myShowConstraints = new QCheckBox(tr("Show constraints"), this);
+ aLayout->addWidget(myShowConstraints);
+
setLayout(aLayout);
+ connect(myShowConstraints, SIGNAL(toggled(bool)), this, SIGNAL(showConstraintToggled(bool)));
+ myShowConstraints->setChecked(toShowConstraints);
}
PartSet_WidgetSketchLabel::~PartSet_WidgetSketchLabel()
aDisp->activateObjects(aModes);
}
+
+void PartSet_WidgetSketchLabel::showConstraints(bool theOn)
+{
+ myShowConstraints->setChecked(theOn);
+ emit showConstraintToggled(theOn);
+}
class QTimer;
class XGUI_OperationMgr;
class XGUI_Workshop;
+class QCheckBox;
/// the plane edge width
#define SKETCH_WIDTH "4"
/// \param theData the widget configuation. The attribute of the model widget is obtained from
/// \param theParentId is Id of a parent of the current attribute
PartSet_WidgetSketchLabel(QWidget* theParent, const Config_WidgetAPI* theData,
- const std::string& theParentId);
+ const std::string& theParentId, bool toShowConstraints);
virtual ~PartSet_WidgetSketchLabel();
virtual void setHighlighted(bool) { /*do nothing*/ };
virtual void enableFocusProcessing();
+ void showConstraints(bool theOn);
+
signals:
/// Signal on plane selection
void planeSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
+ void showConstraintToggled(bool);
+
protected:
/// Creates a backup of the current values of the attribute
/// It should be realized in the specific widget because of different
bool myPreviewDisplayed;
QTimer* mySelectionTimer;
+
+ QCheckBox* myShowConstraints;
};
#endif
static const gp_Pnt MyDefEnd(1,0,0);
static const gp_Pln MyDefPln(gp_Pnt(0,0,0), gp_Dir(0,0,1));
-static const double MyTextHeight = 20;
-
IMPLEMENT_STANDARD_HANDLE(SketcherPrs_LengthDimension, AIS_LengthDimension);
IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_LengthDimension, AIS_LengthDimension);
int SketcherPrs_PositionMgr::getPositionIndex(ObjectPtr theLine,
- Handle(SketcherPrs_SymbolPrs) thePrs)
+ const SketcherPrs_SymbolPrs* thePrs)
{
if (myShapes.count(theLine) == 1) {
PositionsMap& aPosMap = myShapes[theLine];
- if (aPosMap.count(thePrs.Access()) == 1) {
- return aPosMap[thePrs.Access()];
+ if (aPosMap.count(thePrs) == 1) {
+ return aPosMap[thePrs];
} else {
int aInd = aPosMap.size();
- aPosMap[thePrs.Access()] = aInd;
+ aPosMap[thePrs] = aInd;
return aInd;
}
} else {
PositionsMap aPosMap;
- aPosMap[thePrs.Access()] = 0;
+ aPosMap[thePrs] = 0;
myShapes[theLine] = aPosMap;
return 0;
}
}
gp_Pnt SketcherPrs_PositionMgr::getPosition(ObjectPtr theShape,
- Handle(SketcherPrs_SymbolPrs) thePrs,
+ const SketcherPrs_SymbolPrs* thePrs,
double theStep)
{
std::shared_ptr<GeomAPI_Shape> aShape = SketcherPrs_Tools::getShape(theShape);
return aP;
}
-void SketcherPrs_PositionMgr::deleteConstraint(Handle(SketcherPrs_SymbolPrs) thePrs)
+void SketcherPrs_PositionMgr::deleteConstraint(const SketcherPrs_SymbolPrs* thePrs)
{
std::map<ObjectPtr, PositionsMap>::iterator aIt;
+ std::list<ObjectPtr> aToDel;
for (aIt = myShapes.begin(); aIt != myShapes.end(); ++aIt) {
PositionsMap& aPosMap = aIt->second;
- if (aPosMap.count(thePrs.Access()) > 0)
- aPosMap.erase(aPosMap.find(thePrs.Access()));
- }
- for (aIt = myShapes.begin(); aIt != myShapes.end(); ++aIt) {
- if (aIt->second.size() == 0) {
- myShapes.erase(aIt);
- aIt = myShapes.begin();
+ if (aPosMap.count(thePrs) > 0) {
+ aPosMap.erase(aPosMap.find(thePrs));
+ if (aPosMap.size() == 0)
+ aToDel.push_back(aIt->first);
}
}
+ std::list<ObjectPtr>::const_iterator aListIt;
+ for (aListIt = aToDel.cbegin(); aListIt != aToDel.cend(); ++aListIt) {
+ myShapes.erase(*aListIt);
+ }
}
/// \param theLine constrained object
/// \param thePrs a presentation of constraint
/// \param theStep step between symbols
- gp_Pnt getPosition(ObjectPtr theLine, Handle(SketcherPrs_SymbolPrs) thePrs, double theStep = 20);
+ gp_Pnt getPosition(ObjectPtr theLine, const SketcherPrs_SymbolPrs* thePrs, double theStep = 20);
/// Deletes constraint object from internal structures. Has to be called on constraint delete.
/// \param thePrs a constraint presentation
- void deleteConstraint(Handle(SketcherPrs_SymbolPrs) thePrs);
+ void deleteConstraint(const SketcherPrs_SymbolPrs* thePrs);
private:
/// Constructor
/// Returns position index of the given constraint
/// \param theLine constrained object
/// \param thePrs a presentation of constraint
- int getPositionIndex(ObjectPtr theLine, Handle(SketcherPrs_SymbolPrs) thePrs);
+ int getPositionIndex(ObjectPtr theLine, const SketcherPrs_SymbolPrs* thePrs);
private:
- typedef std::map<void*, int> PositionsMap;
+ typedef std::map<const SketcherPrs_SymbolPrs*, int> PositionsMap;
/// The map which contains position of presentation
PositionsMap myIndexes;
#include <ModelAPI_AttributeDouble.h>
static const gp_Circ MyDefCirc(gp_Ax2(gp_Pnt(0,0,0), gp_Dir(0,0,1)), 1);
-static const double MyTextHeight = 20;
IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Radius, AIS_RadiusDimension);
IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Radius, AIS_RadiusDimension);
#include "SketcherPrs_SymbolPrs.h"
#include "SketcherPrs_Tools.h"
+#include "SketcherPrs_PositionMgr.h"
#include <GeomAPI_Edge.h>
SetAutoHilight(Standard_False);
}
+SketcherPrs_SymbolPrs::~SketcherPrs_SymbolPrs()
+{
+ SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
+ aMgr->deleteConstraint(this);
+}
+
+
Handle(Image_AlienPixMap) SketcherPrs_SymbolPrs::icon()
{
Standard_EXPORT SketcherPrs_SymbolPrs(SketchPlugin_Constraint* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+ virtual ~SketcherPrs_SymbolPrs();
+
//! Method which clear all selected owners belonging
//! to this selectable object ( for fast presentation draw )
Standard_EXPORT virtual void ClearSelected();
}
-static double MyArrowSize = 40.;
+static double MyArrowSize = 30.;
double getArrowSize()
{
return MyArrowSize;
class SketchPlugin_Line;
class GeomDataAPI_Point2D;
+#define MyTextHeight 20
+
namespace SketcherPrs_Tools {
SKETCHERPRS_EXPORT ObjectPtr getResult(SketchPlugin_Constraint* theFeature,
#include "XGUI_Selection.h"
#include "XGUI_OperationMgr.h"
#include "XGUI_Displayer.h"
+#include "XGUI_PropertyPanel.h"
#include <AIS_Shape.hxx>
return myWorkshop->viewer();
}
+ModuleBase_IPropertyPanel* XGUI_ModuleConnector::propertyPanel() const
+{
+ return myWorkshop->propertyPanel();
+}
+
ModuleBase_Operation* XGUI_ModuleConnector::currentOperation() const
{
return myWorkshop->operationMgr()->currentOperation();
{
return myWorkshop->operationMgr()->canStartOperation(theId);
}
+
//! Returns current viewer
virtual ModuleBase_IViewer* viewer() const;
+ //! Returns property panel
+ virtual ModuleBase_IPropertyPanel* propertyPanel() const;
+
//! Returns currently active operation
virtual ModuleBase_Operation* currentOperation() const;