ModuleBase_WidgetChoice.h
ModuleBase_WidgetFileSelector.h
ModuleBase_DoubleSpinBox.h
+ ModuleBase_IPropertyPanel.h
)
SET(PROJECT_SOURCES
\r
#define CREATE_MODULE "createModule"\r
\r
-#endif //ModuleBase_IModule\r
\ No newline at end of file
+#endif //ModuleBase_IModule\r
--- /dev/null
+/*
+ * ModuleBase_IPropertyPanel.h
+ *
+ * Created on: Oct 01, 2014
+ * Author: vsv
+ */
+
+#ifndef ModuleBase_PROPERTYPANEL_H_
+#define ModuleBase_PROPERTYPANEL_H_
+
+#include "ModuleBase.h"
+
+#include <QDockWidget>
+#include <QKeyEvent>
+
+class ModuleBase_ModelWidget;
+
+class MODULEBASE_EXPORT ModuleBase_IPropertyPanel : public QDockWidget
+{
+Q_OBJECT
+public:
+ ModuleBase_IPropertyPanel(QWidget* theParent) : QDockWidget(theParent) {}
+
+ /// Returns currently active widget
+ virtual ModuleBase_ModelWidget* activeWidget() const = 0;
+
+signals:
+ /// The signal about key release on the control, that corresponds to the attribute
+ /// \param theEvent key release event
+ void keyReleased(QKeyEvent* theEvent);
+ /// The signal about the widget activation
+ /// \param theWidget the activated widget
+ void widgetActivated(ModuleBase_ModelWidget* theWidget);
+
+public slots:
+ /// Activate the next widget in the property panel
+ /// \param theWidget a widget. The next widget should be activated
+ virtual void activateNextWidget(ModuleBase_ModelWidget* theWidget) = 0;
+
+ /// Activate the next from current widget in the property panel
+ virtual void activateNextWidget() = 0;
+};
+
+#endif
\ No newline at end of file
#include "ModuleBase_OperationDescription.h"
#include "ModuleBase_ModelWidget.h"
+#include "ModuleBase_WidgetValueFeature.h"
+#include "ModuleBase_ViewerPrs.h"
+#include "ModuleBase_IPropertyPanel.h"
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_Result.h>
#include <ModelAPI_Validator.h>
+#include <GeomAPI_Pnt2d.h>
+
#include <Events_Loop.h>
#ifdef _DEBUG
ModuleBase_Operation::ModuleBase_Operation(const QString& theId, QObject* theParent)
: QObject(theParent),
myIsEditing(false),
- myIsModified(false)
+ myIsModified(false),
+ myPropertyPanel(NULL)
{
myDescription = new ModuleBase_OperationDescription(theId);
}
aCustom->storeValue();
}
-void ModuleBase_Operation::onWidgetActivated(ModuleBase_ModelWidget* theWidget)
-{
-}
-
void ModuleBase_Operation::startOperation()
{
if (!myIsEditing)
createFeature();
- //emit callSlot();
- //commit();
}
void ModuleBase_Operation::stopOperation()
void ModuleBase_Operation::setFeature(FeaturePtr theFeature)
{
myFeature = theFeature;
-}
-
-void ModuleBase_Operation::setEditingFeature(FeaturePtr theFeature)
-{
- setFeature(theFeature);
myIsEditing = true;
}
void ModuleBase_Operation::resume()
{
+ if (myPropertyPanel)
+ connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), this,
+ SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
emit resumed();
}
{
abortOperation();
emit aborted();
+ if (myPropertyPanel)
+ disconnect(myPropertyPanel, 0, this, 0);
stopOperation();
commitOperation();
emit committed();
+ if (myPropertyPanel)
+ disconnect(myPropertyPanel, 0, this, 0);
+
stopOperation();
ModelAPI_Session::get()->finishOperation();
abort();
}
}
+
+void ModuleBase_Operation::activateByPreselection()
+{
+ if (!myPropertyPanel)
+ return;
+ ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget();
+ if ((myPreSelection.size() > 0) && aActiveWgt) {
+ const ModuleBase_ViewerPrs& aPrs = myPreSelection.front();
+ ModuleBase_WidgetValueFeature aValue;
+ aValue.setObject(aPrs.object());
+ if (aActiveWgt->setValue(&aValue)) {
+ myPreSelection.remove(aPrs);
+ if(isValid()) {
+ //myActiveWidget = NULL;
+ commit();
+ } else {
+ myPropertyPanel->activateNextWidget();
+ //emit activateNextWidget(myActiveWidget);
+ }
+ }
+ // If preselection is enough to make a valid feature - apply it immediately
+ }
+}
+
+void ModuleBase_Operation::initSelection(
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
+{
+ myPreSelection = theSelected;
+}
+
+void ModuleBase_Operation::onWidgetActivated(ModuleBase_ModelWidget* theWidget)
+{
+ activateByPreselection();
+ //if (theWidget && myPropertyPanel) {
+ // myPropertyPanel->activateNextWidget();
+ //// //emit activateNextWidget(myActiveWidget);
+ //}
+}
+
+bool ModuleBase_Operation::setWidgetValue(ObjectPtr theFeature, double theX, double theY)
+{
+ ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget();
+ if (!aActiveWgt)
+ return false;
+ ModuleBase_WidgetValueFeature* aValue = new ModuleBase_WidgetValueFeature();
+ aValue->setObject(theFeature);
+ aValue->setPoint(boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY)));
+ bool isApplyed = aActiveWgt->setValue(aValue);
+
+ delete aValue;
+ myIsModified = (myIsModified || isApplyed);
+ return isApplyed;
+}
+
+
+void ModuleBase_Operation::setPropertyPanel(ModuleBase_IPropertyPanel* theProp)
+{
+ myPropertyPanel = theProp;
+ connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), this,
+ SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
+}
#define ModuleBase_Operation_H
#include <ModuleBase.h>
+#include <ModuleBase_ViewerPrs.h>
#include <ModelAPI_Feature.h>
+#include <ModelAPI_Document.h>
#include <QObject>
#include <QString>
#include <QStringList>
-#include <boost/shared_ptr.hpp>
-
-class ModelAPI_Document;
class ModuleBase_ModelWidget;
class ModuleBase_OperationDescription;
+class ModuleBase_IPropertyPanel;
class QKeyEvent;
virtual bool isNestedOperationsEnabled() const;
/// Sets the operation feature
- void setEditingFeature(FeaturePtr theFeature);
+ void setFeature(FeaturePtr theFeature);
/// Returns True if the current operation works with the given object (feature or result)
virtual bool hasObject(ObjectPtr theObj) const;
virtual void keyReleased(const int theKey) {};
- virtual void activateNextToCurrentWidget() {};
-
/// If operation needs to redisplay its result during operation
/// then this method has to return True
virtual bool hasPreview() const { return false; }
+ /// Initialisation of operation with preliminary selection
+ /// \param theSelected the list of selected presentations
+ /// \param theHighlighted the list of highlighted presentations
+ virtual void initSelection(const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted);
+
+ virtual void setPropertyPanel(ModuleBase_IPropertyPanel* theProp);
+
+ ModuleBase_IPropertyPanel* propertyPanel() const { return myPropertyPanel; }
+
signals:
void started(); /// the operation is started
void aborted(); /// the operation is aborted
void stopped(); /// the operation is aborted or committed
void resumed(); /// the operation is resumed
- /// Signals about the activating of the next widget
- /// \param theWidget the previous active widget
- void activateNextWidget(ModuleBase_ModelWidget* theWidget);
-
public slots:
/// Starts operation
/// Public slot. Verifies whether operation can be started and starts operation.
/// \returns the created feature
virtual FeaturePtr createFeature(const bool theFlushMessage = true);
- /// Sets the operation feature
- void setFeature(FeaturePtr theFeature);
-
/// Verifies whether this operator can be commited.
/// \return Returns TRUE if current operation can be committed, e.g. all parameters are filled
virtual bool canBeCommitted() const;
/// Returns pointer to the root document.
boost::shared_ptr<ModelAPI_Document> document() const;
+ ///
+ virtual void activateByPreselection();
+
+ /// Set value to the active widget
+ /// \param theFeature the feature
+ /// \param theX the horizontal coordinate
+ /// \param theY the vertical coordinate
+ /// \return true if the point is set
+ virtual bool setWidgetValue(ObjectPtr theFeature, double theX, double theY);
protected:
FeaturePtr myFeature; /// the operation feature to be handled
/// List of nested operations IDs
QStringList myNestedFeatures;
+ /// List of pre-selected object
+ std::list<ModuleBase_ViewerPrs> myPreSelection;
+
+ /// Access to property panel
+ ModuleBase_IPropertyPanel* myPropertyPanel;
};
#endif
#include "ModuleBase_WidgetShapeSelector.h"
#include "ModuleBase_IWorkshop.h"
+#include "ModuleBase_WidgetValue.h"
+#include "ModuleBase_WidgetValueFeature.h"
#include <Events_Loop.h>
#include <ModelAPI_Events.h>
myTextLine = new QLineEdit(myContainer);
myTextLine->setReadOnly(true);
myTextLine->setToolTip(aToolTip);
+ myTextLine->installEventFilter(this);
myBasePalet = myTextLine->palette();
myInactivePalet = myBasePalet;
if (!isAccepted(aObject))
return;
- mySelectedObject = aObject;
- if (mySelectedObject) {
- updateSelectionName();
- raisePanel();
- static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TOHIDE);
- ModelAPI_EventCreator::get()->sendUpdated(mySelectedObject, anEvent);
- Events_Loop::loop()->flush(anEvent);
- } else {
- myTextLine->setText("");
- }
- activateSelection(false);
- emit valuesChanged();
- emit focusOutWidget(this);
+ setObject(aObject);
}
}
+//********************************************************************
+void ModuleBase_WidgetShapeSelector::setObject(ObjectPtr theObj)
+{
+ if (mySelectedObject == theObj)
+ return;
+ mySelectedObject = theObj;
+ if (mySelectedObject) {
+ raisePanel();
+ static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TOHIDE);
+ ModelAPI_EventCreator::get()->sendUpdated(mySelectedObject, anEvent);
+ Events_Loop::loop()->flush(anEvent);
+ }
+ updateSelectionName();
+ activateSelection(false);
+ emit valuesChanged();
+ emit focusOutWidget(this);
+}
+
//********************************************************************
bool ModuleBase_WidgetShapeSelector::isAccepted(const ObjectPtr theResult) const
{
connect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
else
disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
-
-// if (myWorkshop->selectedObjects().size() > 0)
-// onSelectionChanged();
}
//********************************************************************
}
return ModuleBase_ModelWidget::eventFilter(theObj, theEvent);
}
+
+//********************************************************************
+bool ModuleBase_WidgetShapeSelector::setValue(ModuleBase_WidgetValue* theValue)
+{
+ if (theValue) {
+ ModuleBase_WidgetValueFeature* aFeatureValue =
+ dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
+ if (aFeatureValue && aFeatureValue->object()) {
+ ObjectPtr aObject = aFeatureValue->object();
+ if (isAccepted(aObject)) {
+ setObject(aObject);
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
return mySelectedObject;
}
- public slots:
+ /// Set the given wrapped value to the current widget
+ /// This value should be processed in the widget according to the needs
+ /// \param theValue the wrapped widget value
+ virtual bool setValue(ModuleBase_WidgetValue* theValue);
+
+public slots:
/// Activate or deactivate selection
void activateSelection(bool toActivate);
void raisePanel() const;
bool isAccepted(const ObjectPtr theObject) const;
+ // Set the given object as a value of the widget
+ void setObject(ObjectPtr theObj);
+
static TopAbs_ShapeEnum shapeType(const QString& theType);
QWidget* myContainer;
void PartSet_Module::launchOperation(const QString& theCmdId)
{
ModuleBase_Operation* anOperation = createOperation(theCmdId.toStdString());
- PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
- if (aPreviewOp) {
+ //PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
+ //if (aPreviewOp) {
XGUI_Selection* aSelection = myWorkshop->selector()->selection();
// Initialise operation with preliminary selection
std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
- aPreviewOp->initSelection(aSelected, aHighlighted);
- }
+ anOperation->initSelection(aSelected, aHighlighted);
+ //}
sendOperation(anOperation);
}
void PartSet_Module::onOperationStarted()
{
- PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop
- ->operationMgr()->currentOperation());
+ ModuleBase_Operation* aOperation = myWorkshop->operationMgr()->currentOperation();
+
+ PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(aOperation);
if (aPreviewOp) {
XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel();
connect(aPropPanel, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)), this,
SLOT(onStorePoint2D(ObjectPtr, const std::string&)), Qt::UniqueConnection);
+
XGUI_Displayer* aDisplayer = myWorkshop->displayer();
aDisplayer->openLocalContext();
aDisplayer->deactivateObjectsOutOfContext();
void PartSet_Module::onMousePressed(QMouseEvent* theEvent)
{
+
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop
->operationMgr()->currentOperation());
Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
// Initialise operation with preliminary selection
std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
- aSketchOp->initFeature(aFeature);
aSketchOp->initSelection(aSelected, aHighlighted);
+ PartSet_OperationFeatureCreate* aCreateOp = dynamic_cast<PartSet_OperationFeatureCreate*>(anOperation);
+ if (aCreateOp)
+ aCreateOp->initFeature(aFeature);
+ else {
+ PartSet_OperationFeatureEdit* aEditOp = dynamic_cast<PartSet_OperationFeatureEdit*>(anOperation);
+ if (aEditOp)
+ anOperation->setFeature(aFeature);
+ }
} else if (aFeature) {
- anOperation->setEditingFeature(aFeature);
+ anOperation->setFeature(aFeature);
//Deactivate result of current feature in order to avoid its selection
XGUI_Displayer* aDisplayer = myWorkshop->displayer();
std::list<ResultPtr> aResults = aFeature->results();
#include <ModuleBase_OperationDescription.h>
#include <ModuleBase_WidgetPoint2D.h>
#include <ModuleBase_WidgetValueFeature.h>
-#include <ModuleBase_ViewerPrs.h>
+#include "ModuleBase_IPropertyPanel.h"
#include <XGUI_Constants.h>
QObject* theParent,
FeaturePtr theFeature)
: PartSet_OperationSketchBase(theId, theParent),
- mySketch(theFeature),
- myActiveWidget(NULL)
+ mySketch(theFeature)
{
}
{
}
-void PartSet_OperationFeatureBase::initSelection(
- const std::list<ModuleBase_ViewerPrs>& theSelected,
- const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
-{
- myPreSelection = theSelected;
-}
-
-void PartSet_OperationFeatureBase::initFeature(FeaturePtr theFeature)
-{
- myInitFeature = theFeature;
-}
-
FeaturePtr PartSet_OperationFeatureBase::sketch() const
{
return mySketch;
if (!aVertex.IsNull()) {
aPoint = BRep_Tool::Pnt(aVertex);
PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
- PartSet_Tools::setConstraints(sketch(), feature(), myActiveWidget->attributeID(), aX, anY);
+ ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget();
+ PartSet_Tools::setConstraints(sketch(), feature(), aActiveWgt->attributeID(), aX, anY);
}
} else if (aShape.ShapeType() == TopAbs_EDGE) { // a line is selected
PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
bool isApplyed = setWidgetValue(aFeature, aX, anY);
if (isApplyed) {
flushUpdated();
- emit activateNextWidget(myActiveWidget);
+ myPropertyPanel->activateNextWidget();
}
commit();
}
-void PartSet_OperationFeatureBase::onWidgetActivated(ModuleBase_ModelWidget* theWidget)
-{
- myActiveWidget = theWidget;
- activateByPreselection();
- if (myInitFeature && myActiveWidget) {
- ModuleBase_WidgetPoint2D* aWgt = dynamic_cast<ModuleBase_WidgetPoint2D*>(myActiveWidget);
- if (aWgt && aWgt->initFromPrevious(myInitFeature)) {
- myInitFeature = FeaturePtr();
- emit activateNextWidget(myActiveWidget);
- }
- }
-}
-void PartSet_OperationFeatureBase::activateByPreselection()
-{
- if ((myPreSelection.size() > 0) && myActiveWidget) {
- const ModuleBase_ViewerPrs& aPrs = myPreSelection.front();
- ModuleBase_WidgetValueFeature aValue;
- aValue.setObject(aPrs.object());
- if (myActiveWidget->setValue(&aValue)) {
- myPreSelection.remove(aPrs);
- if(isValid()) {
- myActiveWidget = NULL;
- commit();
- } else {
- emit activateNextWidget(myActiveWidget);
- }
- }
- // If preselection is enough to make a valid feature - apply it immediately
- }
-}
-bool PartSet_OperationFeatureBase::setWidgetValue(ObjectPtr theFeature, double theX, double theY)
+/*bool PartSet_OperationFeatureBase::setWidgetValue(ObjectPtr theFeature, double theX, double theY)
{
- if (!myActiveWidget)
+ ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget();
+ if (!aActiveWgt)
return false;
ModuleBase_WidgetValueFeature* aValue = new ModuleBase_WidgetValueFeature();
aValue->setObject(theFeature);
aValue->setPoint(boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY)));
- bool isApplyed = myActiveWidget->setValue(aValue);
+ bool isApplyed = aActiveWgt->setValue(aValue);
delete aValue;
myIsModified = (myIsModified || isApplyed);
return isApplyed;
-}
+}*/
/// Destructor
virtual ~PartSet_OperationFeatureBase();
- /// Initialisation of operation with preliminary selection
- /// \param theSelected the list of selected presentations
- /// \param theHighlighted the list of highlighted presentations
- virtual void initSelection(const std::list<ModuleBase_ViewerPrs>& theSelected,
- const std::list<ModuleBase_ViewerPrs>& theHighlighted);
-
- /// Initializes the operation with previously created feature. It is used in sequental operations
- virtual void initFeature(FeaturePtr theFeature);
-
/// Returns the operation sketch feature
/// \returns the sketch instance
virtual FeaturePtr sketch() const;
const std::list<ModuleBase_ViewerPrs>& theHighlighted);
- public slots:
- /// Slots which listen the mode widget activation
- /// \param theWidget the model widget
- virtual void onWidgetActivated(ModuleBase_ModelWidget* theWidget);
-
protected:
- ///
- void activateByPreselection();
/// Set value to the active widget
/// \param theFeature the feature
/// \param theX the horizontal coordinate
/// \param theY the vertical coordinate
/// \return true if the point is set
- bool setWidgetValue(ObjectPtr theFeature, double theX, double theY);
+ //bool setWidgetValue(ObjectPtr theFeature, double theX, double theY);
protected:
- FeaturePtr myInitFeature; ///< the initial feature
FeaturePtr mySketch; ///< the sketch of the feature
-
- ModuleBase_ModelWidget* myActiveWidget; ///< the active widget
-
- std::list<ModuleBase_ViewerPrs> myPreSelection;
};
#endif
#include <ModuleBase_WidgetPoint2D.h>
#include <ModuleBase_WidgetValueFeature.h>
#include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_IPropertyPanel.h>
#include <XGUI_Constants.h>
if (!aVertex.IsNull()) {
aPoint = BRep_Tool::Pnt(aVertex);
PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
- PartSet_Tools::setConstraints(sketch(), feature(), myActiveWidget->attributeID(), aX, anY);
+ ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget();
+ PartSet_Tools::setConstraints(sketch(), feature(), aActiveWgt->attributeID(), aX, anY);
isClosedContour = true;
}
} else if (aShape.ShapeType() == TopAbs_EDGE) { // a line is selected
bool isApplyed = setWidgetValue(aFeature, aX, anY);
if (isApplyed) {
flushUpdated();
- emit activateNextWidget(myActiveWidget);
+ myPropertyPanel->activateNextWidget();
}
- if (myActiveWidget == NULL) {
+ if (!myPropertyPanel->activeWidget()) {
if(commit() && !isClosedContour) {
// if the point creation is finished, the next mouse release should commit the modification
// the next release can happens by double click in the viewer
}
}
-void PartSet_OperationFeatureCreate::activateNextToCurrentWidget()
-{
- emit activateNextWidget(myActiveWidget);
-}
-
void PartSet_OperationFeatureCreate::startOperation()
{
PartSet_OperationSketchBase::startOperation();
aFeature->addSub(aNewFeature);
}
- //myFeaturePrs->init(aNewFeature);
- //myFeaturePrs->setFeature(myInitFeature, SM_FirstPoint);
-//TODO emit featureConstructed(aNewFeature, FM_Activation);
if (theFlushMessage)
flushCreated();
return aNewFeature;
}
+
+
+void PartSet_OperationFeatureCreate::onWidgetActivated(ModuleBase_ModelWidget* theWidget)
+{
+ PartSet_OperationFeatureBase::onWidgetActivated(theWidget);
+ if (myInitFeature && theWidget) {
+ ModuleBase_WidgetPoint2D* aWgt = dynamic_cast<ModuleBase_WidgetPoint2D*>(theWidget);
+ if (aWgt && aWgt->initFromPrevious(myInitFeature)) {
+ myInitFeature = FeaturePtr();
+ if (myPropertyPanel)
+ myPropertyPanel->activateNextWidget();
+ }
+ }
+}
/// \param theKey a key value
virtual void keyReleased(const int theKey);
- /// alias for activateNextWidget(myActiveWidget);
- virtual void activateNextToCurrentWidget();
+ /// Initializes the operation with previously created feature. It is used in sequental operations
+ void initFeature(FeaturePtr theFeature) { myInitFeature = theFeature; }
+
+ public slots:
+ /// Slots which listen the mode widget activation
+ /// \param theWidget the model widget
+ virtual void onWidgetActivated(ModuleBase_ModelWidget* theWidget);
protected:
/// \brief Virtual method called when operation is started
/// Verifies whether this operator can be commited.
/// \return Returns TRUE if current operation can be committed, e.g. all parameters are filled
virtual bool canBeCommitted() const;
+
+protected:
+ /// Feature of previous operation (for sequintal operations)
+ FeaturePtr myInitFeature;
};
#endif
#include <ModuleBase_OperationDescription.h>
#include <ModuleBase_WidgetEditor.h>
#include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_IPropertyPanel.h>
#include <ModelAPI_Events.h>
: PartSet_OperationFeatureBase(theId, theParent, theFeature),
myIsBlockedSelection(false)
{
+ myIsEditing = true;
}
PartSet_OperationFeatureEdit::~PartSet_OperationFeatureEdit()
{
}
-void PartSet_OperationFeatureEdit::initFeature(FeaturePtr theFeature)
-{
- setEditingFeature(theFeature);
-}
void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, Handle(V3d_View) theView,
const std::list<ModuleBase_ViewerPrs>& theSelected,
const std::list<ModuleBase_ViewerPrs>& theHighlighted)
{
- if(myActiveWidget && myActiveWidget->isViewerSelector()) {
+ ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget();
+ if(aActiveWgt && aActiveWgt->isViewerSelector()) {
// Almost do nothing, all stuff in on PartSet_OperationFeatureBase::mouseReleased
PartSet_OperationFeatureBase::mousePressed(theEvent, theView, theSelected, theHighlighted);
return;
const std::list<ModuleBase_ViewerPrs>& theSelected,
const std::list<ModuleBase_ViewerPrs>& theHighlighted)
{
- if(myActiveWidget && myActiveWidget->isViewerSelector()) {
+ ModuleBase_ModelWidget* aActiveWgt = 0;
+ if (myPropertyPanel)
+ aActiveWgt = myPropertyPanel->activeWidget();
+ if(aActiveWgt && aActiveWgt->isViewerSelector()) {
// Almost do nothing, all stuff in on PartSet_OperationFeatureBase::mouseReleased
PartSet_OperationFeatureBase::mouseReleased(theEvent, theView, theSelected, theHighlighted);
} else {
/// Destructor
virtual ~PartSet_OperationFeatureEdit();
- /// Initializes the operation with previously created feature. It is used in sequental operations
- virtual void initFeature(FeaturePtr theFeature);
-
/// Processes the mouse pressed in the point
/// \param theEvent the mouse event
/// \param theView a viewer to have the viewer the eye position
mySketch(theFeature),
myIsBlockedSelection(false)
{
+ myIsEditing = true;
}
PartSet_OperationFeatureEditMulti::~PartSet_OperationFeatureEditMulti()
myFeatures = theSelected;
}
-void PartSet_OperationFeatureEditMulti::initFeature(FeaturePtr theFeature)
-{
- setEditingFeature(theFeature);
-}
-
FeaturePtr PartSet_OperationFeatureEditMulti::sketch() const
{
return mySketch;
gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView);
- blockSelection(true);
+/* blockSelection(true);
if (myCurPoint.myIsInitialized) {
double aCurX, aCurY;
PartSet_Tools::convertTo2D(myCurPoint.myPoint, sketch(), theView, aCurX, aCurY);
double aDeltaY = anY - aCurY;
boost::shared_ptr<SketchPlugin_Feature> aSketchFeature = boost::dynamic_pointer_cast<
- SketchPlugin_Feature>(feature());
+ SketchPlugin_Feature>(sketch());
aSketchFeature->move(aDeltaX, aDeltaY);
std::list<ModuleBase_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures
sendFeatures();
myCurPoint.setPoint(aPoint);
+ */
}
void PartSet_OperationFeatureEditMulti::mouseReleased(
/// Destructor
virtual ~PartSet_OperationFeatureEditMulti();
- /// Initializes the operation with previously created feature. It is used in sequental operations
- virtual void initFeature(FeaturePtr theFeature);
-
/// Initialisation of operation with preliminary selection
/// \param theSelected the list of selected presentations
/// \param theHighlighted the list of highlighted presentations
return aModes;
}
-/// Initializes the operation with previously created feature. It is used in sequental operations
-void PartSet_OperationSketch::initFeature(FeaturePtr theFeature)
-{
- if (theFeature)
- setEditingFeature(theFeature);
-}
-
FeaturePtr PartSet_OperationSketch::sketch() const
{
return feature();
/// \return the selection mode
virtual std::list<int> getSelectionModes(ObjectPtr theFeature) const;
- /// Initializes the operation with previously created feature. It is used in sequental operations
- virtual void initFeature(FeaturePtr theFeature);
-
/// Returns the operation sketch feature
/// \returns the sketch instance
virtual FeaturePtr sketch() const;
if (aFeature) {
QStringList aNested = this->nestedFeatures();
if (!aNested.isEmpty()) {
- if (aNested.contains(QString(aFeature->getKind().c_str())))
- emit restartRequired(theType, theFeature);
- else
+ if (!aNested.contains(QString(aFeature->getKind().c_str())))
return;
}
}
/// \return the selection mode
virtual std::list<int> getSelectionModes(ObjectPtr theFeature) const;
- /// Initializes the operation with previously created feature. It is used in sequental operations
- virtual void initFeature(FeaturePtr theFeature)
- {
- }
-
/// Initialisation of operation with preliminary selection
/// \param theSelected the list of selected presentations
/// \param theHighlighted the list of highlighted presentations
connect(theOperation, SIGNAL(stopped()), this, SLOT(onOperationStopped()));
connect(theOperation, SIGNAL(started()), this, SIGNAL(operationStarted()));
connect(theOperation, SIGNAL(resumed()), this, SIGNAL(operationResumed()));
- connect(theOperation, SIGNAL(activateNextWidget(ModuleBase_ModelWidget*)), this,
- SIGNAL(activateNextWidget(ModuleBase_ModelWidget*)));
theOperation->start();
onValidateOperation();
return isAccepted;
}
-void XGUI_OperationMgr::onWidgetActivated(ModuleBase_ModelWidget* theWidget)
-{
- ModuleBase_Operation* anOperation = currentOperation();
- if (anOperation)
- anOperation->onWidgetActivated(theWidget);
-}
void operationResumed();
/// Signal is emitted after the validate methods calls.
void operationValidated(bool);
- /// Signal about the necessety of the next widget activating
- /// \param theWidget the model widget
- void activateNextWidget(ModuleBase_ModelWidget* theWidget);
protected:
/// \param theEvent the mouse event
bool onKeyReleased(QKeyEvent* theEvent);
- /// SLOT, that reacts to the widget activation
- /// \param theWidget an activated widget
- void onWidgetActivated(ModuleBase_ModelWidget* theWidget);
-
protected slots:
/// Slot that is called by an operation stop. Removes the stopped operation form the stack.
/// If there is a suspended operation, restart it.
#endif
XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent)
- : QDockWidget(theParent)
+ : ModuleBase_IPropertyPanel(theParent), myActiveWidget(0)
{
this->setWindowTitle(tr("Property Panel"));
QAction* aViewAct = this->toggleViewAction();
void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& theWidgets)
{
myWidgets = theWidgets;
+ int aS = myWidgets.size();
if (theWidgets.empty()) return;
QList<ModuleBase_ModelWidget*>::const_iterator anIt = theWidgets.begin(), aLast =
connect(*anIt, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*)));
connect(*anIt, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)), this,
- SLOT(onActivateNextWidget(ModuleBase_ModelWidget*)));
+ SLOT(activateNextWidget(ModuleBase_ModelWidget*)));
connect(*anIt, SIGNAL(focusInWidget(ModuleBase_ModelWidget*)),
this, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)));
void XGUI_PropertyPanel::updateContentWidget(FeaturePtr theFeature)
{
+ int aS = myWidgets.size();
foreach(ModuleBase_ModelWidget* eachWidget, myWidgets)
{
eachWidget->setFeature(theFeature);
repaint();
}
-void XGUI_PropertyPanel::onActivateNextWidget(ModuleBase_ModelWidget* theWidget)
+
+void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget)
{
QObject* aSender = sender();
ModuleBase_ModelWidget* aNextWidget = 0;
}
isFoundWidget = (*anIt) == theWidget;
}
- emit widgetActivated(aNextWidget);
+ myActiveWidget = aNextWidget;
+ emit widgetActivated(myActiveWidget);
+}
+
+void XGUI_PropertyPanel::activateNextWidget()
+{
+ activateNextWidget(myActiveWidget);
}
void XGUI_PropertyPanel::setAcceptEnabled(bool isEnabled)
#include "XGUI.h"
#include <ModuleBase_ModelWidget.h>
+#include <ModuleBase_IPropertyPanel.h>
-#include <QDockWidget>
#include <QList>
class QKeyEvent;
class QVBoxLayout;
-class XGUI_EXPORT XGUI_PropertyPanel : public QDockWidget
+class XGUI_EXPORT XGUI_PropertyPanel : public ModuleBase_IPropertyPanel
{
Q_OBJECT
public:
/// Removes all widgets in the widget area of the property panel
void cleanContent();
+ /// Returns currently active widget
+ virtual ModuleBase_ModelWidget* activeWidget() const { return myActiveWidget; }
+
+ /// Activate the next widget in the property panel
+ /// \param theWidget a widget. The next widget should be activated
+ virtual void activateNextWidget(ModuleBase_ModelWidget* theWidget);
+
+ /// Activate the next from current widget in the property panel
+ virtual void activateNextWidget();
+
public slots:
void updateContentWidget(FeaturePtr theFeature);
- /// 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);
// Enables / disables "ok" ("accept") button
void setAcceptEnabled(bool);
signals:
- /// The signal about key release on the control, that corresponds to the attribute
- /// \param theEvent key release event
- void keyReleased(QKeyEvent* theEvent);
- /// The signal about the widget activation
- /// \param theWidget the activated widget
- void widgetActivated(ModuleBase_ModelWidget* theWidget);
-
/// Signal about the point 2d set to the feature
/// \param the feature
/// \param the attribute of the feature
QWidget* myCustomWidget;
QList<ModuleBase_ModelWidget*> myWidgets;
QVBoxLayout* myMainLayout;
+ ModuleBase_ModelWidget* myActiveWidget;
};
#endif /* XGUI_PROPERTYPANEL_H_ */
}
}
+ aOperation->setPropertyPanel(myPropertyPanel);
myPropertyPanel->setModelWidgets(aWidgets);
- myPropertyPanel->onActivateNextWidget(NULL);
+ myPropertyPanel->activateNextWidget(NULL);
// Widget activation (from the previous method) may commit the current operation
// if pre-selection is enougth for it. So we shouldn't update prop panel's title
if(myOperationMgr->isCurrentOperation(aOperation)) {
connect(aCancelBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onAbortOperation()));
connect(myPropertyPanel, SIGNAL(keyReleased(QKeyEvent*)), myOperationMgr,
SLOT(onKeyReleased(QKeyEvent*)));
- connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), myOperationMgr,
- SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
- connect(myOperationMgr, SIGNAL(activateNextWidget(ModuleBase_ModelWidget*)), myPropertyPanel,
- SLOT(onActivateNextWidget(ModuleBase_ModelWidget*)));
+ //connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), myOperationMgr,
+ // SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
+ //connect(myOperationMgr, SIGNAL(activateNextWidget(ModuleBase_ModelWidget*)), myPropertyPanel,
+ // SLOT(onActivateNextWidget(ModuleBase_ModelWidget*)));
connect(myOperationMgr, SIGNAL(operationValidated(bool)), myPropertyPanel,
SLOT(setAcceptEnabled(bool)));