/// The signal about widget values changed
void valuesChanged();
+ /// The signal about widget values changed
+ void controlValuesChanged();
+
/// The signal about key release on the control, that corresponds to the attribute
/// \param theEvent key release event
void keyReleased(QKeyEvent* theEvent);
aControlLay->setStretch(1, 1);
connect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged()));
+ connect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(controlValuesChanged()));
}
ModuleBase_WidgetDoubleValue::~ModuleBase_WidgetDoubleValue()
${CMAKE_SOURCE_DIR}/src/SketchPlugin
${CMAKE_SOURCE_DIR}/src/FeaturesPlugin
${CMAKE_SOURCE_DIR}/src/GeomAPI
+ ${CMAKE_SOURCE_DIR}/src/AppElements
${CAS_INCLUDE_DIRS}
${SUIT_INCLUDE}
)
void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation)
{
- if (theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) {
+ if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
mySketchMgr->startSketch(theOperation);
}
+ else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
+ mySketchMgr->startNestedSketch(theOperation);
+ }
+
if (myDocumentShapeFilter.IsNull())
myDocumentShapeFilter = new PartSet_GlobalFilter(myWorkshop);
myWorkshop->viewer()->addSelectionFilter(myDocumentShapeFilter);
void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation)
{
- if (theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) {
+ if (PartSet_SketcherMgr::isSketchOperation(theOperation) ||
+ PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
mySketchMgr->stopSketch(theOperation);
}
+ else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) {
+ mySketchMgr->stopNestedSketch(theOperation);
+ }
myWorkshop->viewer()->removeSelectionFilter(myDocumentShapeFilter);
}
bool PartSet_Module::canDisplayObject(const ObjectPtr& theObject) const
{
bool aCanDisplay = false;
+ if (!mySketchMgr->canDisplayObject(theObject))
+ return aCanDisplay;
CompositeFeaturePtr aSketchFeature = mySketchMgr->activeSketch();
if (aSketchFeature.get() != NULL) {
FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
void PartSet_Module::addViewerItems(QMenu* theMenu) const
{
- if (!isSketchOperationActive() && !isSketchFeatureOperationActive())
+ if (!PartSet_SketcherMgr::isSketchOperation(myWorkshop->currentOperation()) &&
+ !isSketchFeatureOperationActive())
return;
ModuleBase_ISelection* aSelection = myWorkshop->selection();
QObjectPtrList aObjects = aSelection->selectedPresentations();
void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
{
ModuleBase_IPropertyPanel* aPanel = theOperation->propertyPanel();
- if ((theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) &&
- (theOperation->isEditOperation())) {
+ if (PartSet_SketcherMgr::isSketchOperation(theOperation) && (theOperation->isEditOperation())) {
// we have to manually activate the sketch label in edit mode
aPanel->activateWidget(aPanel->modelWidgets().first());
return;
if (theOperation->isEditOperation()) {
// TODO: #391 - to be removed
std::string aId = theOperation->id().toStdString();
- if (PartSet_SketcherMgr::sketchOperationIdList().contains(QString(aId.c_str()))) {
- if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
- (aId == SketchPlugin_ConstraintLength::ID()) ||
- (aId == SketchPlugin_ConstraintDistance::ID())) {
- // Find and activate widget for management of point for dimension line position
- QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
- foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
- PartSet_WidgetPoint2D* aPntWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
- if (aPntWgt) {
- aPanel->activateWidget(aPntWgt);
- return;
- }
+ if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation) &&
+ PartSet_SketcherMgr::isDistanceOperation(theOperation)) {
+ // Find and activate widget for management of point for dimension line position
+ QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
+ foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
+ PartSet_WidgetPoint2D* aPntWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
+ if (aPntWgt) {
+ aPanel->activateWidget(aPntWgt);
+ return;
}
- }
+ }
}
}
}
// An edit operation is enable only if the current opeation is the sketch operation
if (mySketchMgr->activeSketch()) {
if (PartSet_Tools::sketchPlane(mySketchMgr->activeSketch()))
- isSketcherOp = (aOperation->id().toStdString() == SketchPlugin_Sketch::ID());
+ isSketcherOp = PartSet_SketcherMgr::isSketchOperation(aOperation);
}
if (isSketcherOp) {
// Editing of constraints can be done on selection
return 0;
}
-bool PartSet_Module::isSketchOperationActive() const
-{
- ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
-
- bool isSketchOp = aOperation && aOperation->id().toStdString() == SketchPlugin_Sketch::ID();
- return isSketchOp;
-}
-
bool PartSet_Module::isSketchFeatureOperationActive() const
{
bool isCurrentSketchOp = false;
void PartSet_Module::deleteObjects()
{
- bool isSketchOp = isSketchOperationActive();
+ bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(myWorkshop->currentOperation());
if (!isSketchOp && !isSketchFeatureOperationActive())
return;
#include <XGUI_ModuleConnector.h>
#include <XGUI_PropertyPanel.h>
+#include <AppElements_MainWindow.h>
+
#include <ModuleBase_IViewer.h>
#include <ModuleBase_IWorkshop.h>
#include <ModuleBase_IViewWindow.h>
PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule)
- : QObject(theModule), myModule(theModule), myIsDragging(false), myDragDone(false)
+ : QObject(theModule), myModule(theModule), myIsDragging(false), myDragDone(false),
+ myIsMouseOverWindow(false), myIsPropertyPanelValueChanged(false)
{
ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
ModuleBase_IViewer* aViewer = anIWorkshop->viewer();
myPlaneFilter.Nullify();
}
+void PartSet_SketcherMgr::onMouseMoveOverWindow(bool theOverWindow)
+{
+ myIsMouseOverWindow = theOverWindow;
+ if (theOverWindow)
+ myIsPropertyPanelValueChanged = false;
+
+ updateVisibilityOfCreatedFeature();
+}
+
+void PartSet_SketcherMgr::onValuesChangedInPropertyPanel()
+{
+ myIsPropertyPanelValueChanged = true;
+
+ updateVisibilityOfCreatedFeature();
+}
+
void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
{
get2dPoint(theWnd, theEvent, myClickedPoint);
if (!PartSet_Tools::sketchPlane(myCurrentSketch))
return;
- bool isSketcher = (aOperation->id().toStdString() == SketchPlugin_Sketch::ID());
- bool isSketchOpe = sketchOperationIdList().contains(aOperation->id());
+ bool isSketcher = isSketchOperation(aOperation);
+ bool isSketchOpe = isNestedSketchOperation(aOperation);
// Avoid non-sketch operations
if ((!isSketchOpe) && (!isSketcher))
return;
ModuleBase_Operation* aOp = aWorkshop->currentOperation();
if (aOp) {
- if (sketchOperationIdList().contains(aOp->id())) {
- get2dPoint(theWnd, theEvent, myClickedPoint);
+ if (isNestedSketchOperation(aOp)) {
+ get2dPoint(theWnd, theEvent, myClickedPoint);
// Only for sketcher operations
if (myIsDragging) {
ModuleBase_Operation* aOperation = myModule->workshop()->currentOperation();
if (!aOperation)
return;
- if (aOperation->id().toStdString() == SketchPlugin_Sketch::ID())
+ if (isSketchOperation(aOperation))
return; // No edit operation activated
Handle(V3d_View) aView = theWnd->v3dView();
connect(aPropertyPanel, SIGNAL(beforeWidgetActivated(ModuleBase_ModelWidget*)),
this, SLOT(onBeforeWidgetActivated(ModuleBase_ModelWidget*)));
}
+
+ AppElements_MainWindow* aMainWindow = aWorkshop->mainWindow();
+ connect(aMainWindow, SIGNAL(mouseMoveOverWindow(bool)), this, SLOT(onMouseMoveOverWindow(bool)));
}
void PartSet_SketcherMgr::onBeforeWidgetActivated(ModuleBase_ModelWidget* theWidget)
}
}
-bool PartSet_SketcherMgr::isDistanceOperation(ModuleBase_Operation* theOperation) const
-{
- std::string aId = theOperation ? theOperation->id().toStdString() : "";
-
- return (aId == SketchPlugin_ConstraintLength::ID()) ||
- (aId == SketchPlugin_ConstraintDistance::ID()) ||
- (aId == SketchPlugin_ConstraintRadius::ID());
-}
-
void PartSet_SketcherMgr::get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent,
Point& thePoint)
{
return aIds;
}
+bool PartSet_SketcherMgr::isSketchOperation(ModuleBase_Operation* theOperation)
+{
+ return theOperation && theOperation->id().toStdString() == SketchPlugin_Sketch::ID();
+}
+
+bool PartSet_SketcherMgr::isNestedSketchOperation(ModuleBase_Operation* theOperation)
+{
+ return theOperation &&
+ PartSet_SketcherMgr::sketchOperationIdList().contains(theOperation->id());
+}
+
+bool PartSet_SketcherMgr::isDistanceOperation(ModuleBase_Operation* theOperation)
+{
+ std::string aId = theOperation ? theOperation->id().toStdString() : "";
+
+ return (aId == SketchPlugin_ConstraintLength::ID()) ||
+ (aId == SketchPlugin_ConstraintDistance::ID()) ||
+ (aId == SketchPlugin_ConstraintRadius::ID());
+}
+
void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
{
// Display all sketcher sub-Objects
aDisplayer->updateViewer();
}
+void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* )
+{
+ connectToPropertyPanel(true);
+}
+
+void PartSet_SketcherMgr::stopNestedSketch(ModuleBase_Operation* )
+{
+ connectToPropertyPanel(false);
+}
+
+bool PartSet_SketcherMgr::canDisplayObject(const ObjectPtr& theObject) const
+{
+ return myIsMouseOverWindow || myIsPropertyPanelValueChanged;
+}
void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
{
}
}
}
+
+void PartSet_SketcherMgr::connectToPropertyPanel(const bool isToConnect)
+{
+ ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(anIWorkshop);
+ XGUI_Workshop* aWorkshop = aConnector->workshop();
+ XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel();
+ if (aPropertyPanel) {
+ const QList<ModuleBase_ModelWidget*>& aWidgets = aPropertyPanel->modelWidgets();
+ foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
+ if (isToConnect)
+ connect(aWidget, SIGNAL(controlValuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
+ else
+ disconnect(aWidget, SIGNAL(controlValuesChanged()), this, SLOT(onValuesChangedInPropertyPanel()));
+ }
+ }
+}
+
+void PartSet_SketcherMgr::updateVisibilityOfCreatedFeature()
+{
+ ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
+ ModuleBase_Operation* aOperation = aWorkshop->currentOperation();
+ if (!aOperation || aOperation->isEditOperation())
+ return;
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
+ XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
+
+ FeaturePtr aFeature = aOperation->feature();
+ std::list<ResultPtr> aResults = aFeature->results();
+ std::list<ResultPtr>::const_iterator aIt;
+ for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
+ if (canDisplayObject(aFeature)) {
+ aDisplayer->display(*aIt, false);
+ }
+ else {
+ aDisplayer->erase(*aIt, false);
+ }
+ }
+ aDisplayer->updateViewer();
+}
\ No newline at end of file
virtual ~PartSet_SketcherMgr();
- /// Returns list of strings which contains id's of sketch operations
- static QStringList sketchOperationIdList();
+ /// Returns true if the operation is the sketch
+ /// \param theOperation an operation
+ /// \return the boolean result
+ static bool isSketchOperation(ModuleBase_Operation* theOperation);
+
+ /// Returns true if the operation id is in the sketch operation id list
+ /// \param theOperation an operation
+ /// \return the boolean result
+ static bool isNestedSketchOperation(ModuleBase_Operation* theOperation);
+
+ /// Returns whethe the current operation is a sketch distance - lenght, distance or radius
+ /// \param the operation
+ /// \return a boolean value
+ static bool isDistanceOperation(ModuleBase_Operation* theOperation);
/// Launches the operation from current highlighting
void launchEditing();
/// Stops sketch operation
void stopSketch(ModuleBase_Operation* );
+ /// Starts sketch operation
+ void startNestedSketch(ModuleBase_Operation* );
+
+ /// Stops sketch operation
+ void stopNestedSketch(ModuleBase_Operation* );
+
+ /// Returns whether the object can be displayed at the bounds of the active operation.
+ /// Display only current operation results for usual operation and ask the sketcher manager
+ /// if it is a sketch operation
+ /// \param theObject a model object
+ bool canDisplayObject(const ObjectPtr& theObject) const;
+
public slots:
/// Process sketch plane selected event
void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
private slots:
+ /// Process the signal about mouse moving into or out of the window
+ /// \param heOverWindow true, if the moving happens to window
+ void onMouseMoveOverWindow(bool theOverWindow);
+ void onValuesChangedInPropertyPanel();
void onMousePressed(ModuleBase_IViewWindow*, QMouseEvent*);
void onMouseReleased(ModuleBase_IViewWindow*, QMouseEvent*);
void onMouseMoved(ModuleBase_IViewWindow*, QMouseEvent*);
void onBeforeWidgetActivated(ModuleBase_ModelWidget* theWidget);
private:
- /// Returns whethe the current operation is a sketch distance - lenght, distance or radius
- /// \param the operation
- /// \return a boolean value
- bool isDistanceOperation(ModuleBase_Operation* theOperation) const;
+ /// 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
const FeatureToSelectionMap& theSelection,
SelectMgr_IndexedMapOfOwner& anOwnersToSelect);
+ /// Connects or disconnects to the value changed signal of the property panel widgets
+ /// \param isToConnect a boolean value whether connect or disconnect
+ void connectToPropertyPanel(const bool isToConnect);
+
+ void updateVisibilityOfCreatedFeature();
+
private:
PartSet_Module* myModule;
bool myPreviousSelectionEnabled; // the previous selection enabled state in the viewer
bool myIsDragging;
bool myDragDone;
+ bool myIsMouseOverWindow; /// the state that mouse is over view
+ bool myIsPropertyPanelValueChanged; /// the state that value in the property panel is changed
Point myCurrentPoint;
Point myClickedPoint;
return thePoint2D->to3D(aC->pnt(), aX->dir(), aY->dir());
}
-bool PartSet_Tools::isConstraintFeature(const std::string& theKind)
-{
- return theKind == SketchPlugin_ConstraintDistance::ID()
- || theKind == SketchPlugin_ConstraintLength::ID()
- || theKind == SketchPlugin_ConstraintRadius::ID()
- || theKind == SketchPlugin_ConstraintRigid::ID();
-}
-
ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShape,
const ObjectPtr& theObject,
CompositeFeaturePtr theSketch)
/// \return API object of point 3D
static std::shared_ptr<GeomAPI_Pnt> point3D(std::shared_ptr<GeomAPI_Pnt2d> thePoint2D,
CompositeFeaturePtr theSketch);
- /// Check whether there is a constraint with the feature kind given
- /// \param theKind a feature kind
- /// \return the boolean value
- static bool isConstraintFeature(const std::string& theKind);
/// Creates a line (arc or circle) by given edge
/// Created line will have fixed constraint
aGroupLay->addWidget(myXSpin, 0, 1);
connect(myXSpin, SIGNAL(valueChanged(double)), this, SLOT(onValuesChanged()));
+ connect(myXSpin, SIGNAL(valueChanged(double)), this, SIGNAL(controlValuesChanged()));
}
{
QLabel* aLabel = new QLabel(myGroupBox);
aGroupLay->addWidget(myYSpin, 1, 1);
connect(myYSpin, SIGNAL(valueChanged(double)), this, SLOT(onValuesChanged()));
+ connect(myYSpin, SIGNAL(valueChanged(double)), this, SIGNAL(controlValuesChanged()));
}
}
// Reconnect to local slot
disconnect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged()));
connect(mySpinBox, SIGNAL(valueChanged(double)), this, SLOT(onValuesChanged()));
+ connect(mySpinBox, SIGNAL(valueChanged(double)), this, SLOT(controlValuesChanged()));
}
PartSet_WidgetPoint2dDistance::~PartSet_WidgetPoint2dDistance()