void setEditingMode(bool isEditing) { myIsEditing = isEditing; }
bool isEditingMode() const { return myIsEditing; }
+ /// Set Enable/Disable state of Ok button
+ virtual void setOkEnabled(bool theEnabled) = 0;
+
+ /// Returns state of Ok button
+ virtual bool isOkEnabled() const = 0;
+
+ /// Set Enable/Disable state of Ok button
+ virtual void setCancelEnabled(bool theEnabled) = 0;
+
+ /// Returns state of Ok button
+ virtual bool isCancelEnabled() const = 0;
+
signals:
/// The signal about key release on the control, that corresponds to the attribute
/// \param theEvent key release event
#include <XGUI_ModuleConnector.h>
#include <XGUI_SelectionMgr.h>
#include <XGUI_Selection.h>
+#include <XGUI_PropertyPanel.h>
+#include <XGUI_OperationMgr.h>
#include <ModuleBase_DoubleSpinBox.h>
#include <ModuleBase_Tools.h>
myXSpin->setToolTip("X");
aGroupLay->addWidget(myXSpin, 0, 1);
- connect(myXSpin, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged()));
+ connect(myXSpin, SIGNAL(valueChanged(double)), this, SLOT(onValuesChanged()));
}
{
QLabel* aLabel = new QLabel(myGroupBox);
myYSpin->setToolTip("X");
aGroupLay->addWidget(myYSpin, 1, 1);
- connect(myYSpin, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged()));
+ connect(myYSpin, SIGNAL(valueChanged(double)), this, SLOT(onValuesChanged()));
}
}
{
bool isBlocked = this->blockSignals(true);
+ myXSpin->blockSignals(true);
myXSpin->setValue(theX);
+ myXSpin->blockSignals(false);
+
+ myYSpin->blockSignals(true);
myYSpin->setValue(theY);
+ myYSpin->blockSignals(false);
this->blockSignals(isBlocked);
emit valuesChanged();
double _Y = aPoint->y();
#endif
bool isBlocked = this->blockSignals(true);
+ myXSpin->blockSignals(true);
myXSpin->setValue(aPoint->x());
+ myXSpin->blockSignals(false);
+
+ myYSpin->blockSignals(true);
myYSpin->setValue(aPoint->y());
+ myYSpin->blockSignals(false);
this->blockSignals(isBlocked);
return true;
}
return aControls;
}
-//bool PartSet_WidgetPoint2D::initFromPrevious(ObjectPtr theObject)
-//{
-// if (myOptionParam.length() == 0)
-// return false;
-// std::shared_ptr<ModelAPI_Data> aData = theObject->data();
-// std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-// aData->attribute(myOptionParam));
-// if (aPoint) {
-// bool isBlocked = this->blockSignals(true);
-// myXSpin->setValue(aPoint->x());
-// myYSpin->setValue(aPoint->y());
-// this->blockSignals(isBlocked);
-//
-// emit valuesChanged();
-// emit storedPoint2D(theObject, myOptionParam);
-// return true;
-// }
-// return false;
-//}
void PartSet_WidgetPoint2D::activate()
{
void PartSet_WidgetPoint2D::onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
{
+ myWorkshop->operationMgr()->setLockValidating(true);
+ myWorkshop->propertyPanel()->setOkEnabled(false);
+
gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWnd->v3dView());
double aX, anY;
return myYSpin->value();
}
+void PartSet_WidgetPoint2D::onValuesChanged()
+{
+ myWorkshop->operationMgr()->setLockValidating(false);
+ emit valuesChanged();
+}
void onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
void onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
+private slots:
+ void onValuesChanged();
+
private:
bool getPoint2d(const Handle(V3d_View)& theView, const TopoDS_Shape& theShape,
double& theX, double& theY) const;
#include <XGUI_ViewerProxy.h>
#include <XGUI_Workshop.h>
+#include <XGUI_PropertyPanel.h>
+#include <XGUI_OperationMgr.h>
#include <GeomAPI_Pnt2d.h>
#include <Config_WidgetAPI.h>
: ModuleBase_WidgetDoubleValue(theParent, theData, theParentId)
{
myFirstPntName = theData->getProperty("first_point");
+
+ // Reconnect to local slot
+ disconnect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged()));
+ connect(mySpinBox, SIGNAL(valueChanged(double)), this, SLOT(onValuesChanged()));
}
PartSet_WidgetPoint2dDistance::~PartSet_WidgetPoint2dDistance()
{
}
-//bool PartSet_WidgetPoint2dDistance::setValue(ModuleBase_WidgetValue* theValue)
-//{
-// bool isDone = false;
-//
-// if (theValue) {
-// ModuleBase_WidgetValueFeature* aFeatureValue =
-// dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
-// if (aFeatureValue) {
-// std::shared_ptr<GeomAPI_Pnt2d> aPnt = aFeatureValue->point();
-// ObjectPtr aObject = aFeatureValue->object();
-// FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObject);
-// if (aFeature && aPnt) {
-// setPoint(aFeature, aPnt);
-// isDone = true;
-// }
-// }
-// }
-// return isDone;
-//}
-
void PartSet_WidgetPoint2dDistance::setPoint(FeaturePtr theFeature,
const std::shared_ptr<GeomAPI_Pnt2d>& thePnt)
{
AttributeDoublePtr aReal = aData->real(attributeID());
if (aReal && (aReal->value() != aRadius)) {
aReal->setValue(aRadius);
+ mySpinBox->blockSignals(true);
mySpinBox->setValue(aRadius);
+ mySpinBox->blockSignals(false);
+ emit valuesChanged();
}
}
void PartSet_WidgetPoint2dDistance::onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
{
+ myWorkshop->operationMgr()->setLockValidating(true);
+ myWorkshop->propertyPanel()->setOkEnabled(false);
+
gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWnd->v3dView());
double aX, aY;
setPoint(feature(), aPnt);
}
+void PartSet_WidgetPoint2dDistance::onValuesChanged()
+{
+ myWorkshop->operationMgr()->setLockValidating(false);
+ emit valuesChanged();
+}
/// Set the second point which defines a value in the widget as a distance with a first point defined by feature
void setPoint(FeaturePtr theFeature, const std::shared_ptr<GeomAPI_Pnt2d>& thePnt);
+private slots:
+ void onValuesChanged();
+
private:
XGUI_Workshop* myWorkshop;
std::string myFirstPntName;
#include <QKeyEvent>
XGUI_OperationMgr::XGUI_OperationMgr(QObject* theParent)
- : QObject(theParent)
+ : QObject(theParent), myIsValidationLock(false)
{
}
if (!hasOperation())
return;
ModuleBase_Operation* anOperation = currentOperation();
- if(anOperation) {
+ if(anOperation && (!myIsValidationLock)) {
bool isValid = anOperation->isValid();
emit operationValidated(isValid);
}
/// Returns true if the operation can be aborted
bool canAbortOperation();
+ /// Blocking/unblocking enabling of Ok button in property panel.
+ /// It is used when operation can not be validated even all attributes are valid
+ void setLockValidating(bool toLock) { myIsValidationLock = toLock; }
+
+ /// Returns state of validation locking
+ bool isValidationLocked() const { return myIsValidationLock; }
+
public slots:
/// Slot that commits the current operation.
void onCommitOperation();
typedef QList<ModuleBase_Operation*> Operations; ///< definition for a list of operations
Operations myOperations; ///< a stack of started operations. The active operation is on top,
// others are suspended and started by the active is finished
+
+ /// Lock/Unlock access to Ok button in property panel
+ bool myIsValidationLock;
};
#endif
else if (!isEditingMode())
emit noMoreWidgets();
}
+
+void XGUI_PropertyPanel::setOkEnabled(bool theEnabled)
+{
+ QPushButton* anOkBtn = findChild<QPushButton*>(PROP_PANEL_OK);
+ anOkBtn->setEnabled(theEnabled);
+}
+
+bool XGUI_PropertyPanel::isOkEnabled() const
+{
+ QPushButton* anOkBtn = findChild<QPushButton*>(PROP_PANEL_OK);
+ return anOkBtn->isEnabled();
+}
+
+void XGUI_PropertyPanel::setCancelEnabled(bool theEnabled)
+{
+ QPushButton* anCancelBtn = findChild<QPushButton*>(PROP_PANEL_CANCEL);
+ anCancelBtn->setEnabled(theEnabled);
+}
+
+bool XGUI_PropertyPanel::isCancelEnabled() const
+{
+ QPushButton* anCancelBtn = findChild<QPushButton*>(PROP_PANEL_CANCEL);
+ return anCancelBtn->isEnabled();
+}
+
+
void setStretchEnabled(bool isEnabled);
+ /// Set Enable/Disable state of Ok button
+ virtual void setOkEnabled(bool theEnabled);
+
+ /// Returns state of Ok button
+ virtual bool isOkEnabled() const;
+
+ /// Set Enable/Disable state of Ok button
+ virtual void setCancelEnabled(bool theEnabled);
+
+ /// Returns state of Ok button
+ virtual bool isCancelEnabled() const;
+
public slots:
void updateContentWidget(FeaturePtr theFeature);
// Enables / disables "ok" ("accept") button
FeaturePtr aFeature = anOperation->feature();
ModuleBase_ModelWidget* aSenderWidget = dynamic_cast<ModuleBase_ModelWidget*>(sender());
- //if (aCustom)
- // aCustom->storeValue(aFeature);
const QList<ModuleBase_ModelWidget*>& aWidgets = myPropertyPanel->modelWidgets();
QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
for (; anIt != aLast; anIt++) {
ModuleBase_ModelWidget* aCustom = *anIt;
- if (aCustom && (/*!aCustom->isInitialized(aFeature) ||*/aCustom == aSenderWidget)) {
- //aCustom->storeValue(aFeature);
+ if (aCustom && (aCustom == aSenderWidget)) {
aCustom->storeValue();
}
}