return isDone;
}
-void ModuleBase_ModelWidget::updateObject(ObjectPtr theObj)
+void ModuleBase_ModelWidget::updateObject(ObjectPtr theObject)
{
- blockUpdateViewer(true);
-
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
-
- blockUpdateViewer(false);
+ ModuleBase_Tools::flushUpdated(theObject);
+ emit objectUpdated();
}
void ModuleBase_ModelWidget::moveObject(ObjectPtr theObj)
{
setValueState(ModifiedInPP);
}
-
-//**************************************************************
-void ModuleBase_ModelWidget::blockUpdateViewer(const bool theValue)
-{
- // the viewer update should be blocked in order to avoid the temporary feature content
- // when the solver processes the feature, the redisplay message can be flushed
- // what caused the display in the viewer preliminary states of object
- // e.g. fillet feature, angle value change
- std::shared_ptr<Events_Message> aMsg;
- if (theValue) {
- aMsg = std::shared_ptr<Events_Message>(
- new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED)));
- }
- else {
- // the viewer update should be unblocked
- aMsg = std::shared_ptr<Events_Message>(
- new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED)));
- }
- Events_Loop::loop()->send(aMsg);
-}
/// Sends Update and Redisplay for the given object
/// \param theObj is updating object
- static void updateObject(ObjectPtr theObj);
+ void updateObject(ObjectPtr theObj);
/// Sends Move event for the given object
/// \param theObj is object for moving
static void moveObject(ObjectPtr theObj);
- /// Sends a message about block/unblock viewer updating
- /// \param theValue a boolean value
- static void blockUpdateViewer(const bool theValue);
-
signals:
/// The signal about widget values are to be changed
void beforeValuesChanged();
/// The signal about value state modification
void valueStateChanged(int theState);
+ /// The signal is emitted after flush of updates singal for the widget
+ void objectUpdated();
+
protected:
/// Sets default value of widget. Normally, widget should fetch this value
/// from the xml. However, some widgets derived widgets could define it
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValueCustom() const = 0;
+ virtual bool storeValueCustom() = 0;
/// Restore value from attribute data to the widget's control
virtual bool restoreValueCustom() = 0;
}*/
}
- if (theFlushMessage)
+ if (theFlushMessage) {
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+ }
return myFeature;
}
// in order to redisplay object in the viewer, the update/redisplay signals should be flushed
// it is better to perform it not in setSelection of each widget, but do it here,
// after the preselection is processed
- ModuleBase_ModelWidget::updateObject(myFeature);
+ ModuleBase_Tools::flushUpdated(myFeature);
}
}
clearPreselection();
focusTo();
}
-bool ModuleBase_PagedContainer::storeValueCustom() const
+bool ModuleBase_PagedContainer::storeValueCustom()
{
// A rare case when plugin was not loaded.
if(!myFeature)
virtual void activateCustom();
/// Redefinition of virtual function
- virtual bool storeValueCustom() const;
+ virtual bool storeValueCustom();
/// Redefinition of virtual function
virtual bool restoreValueCustom();
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeRefList.h>
#include <ModelAPI_AttributeRefAttrList.h>
+#include <Events_Loop.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Result.h>
#include <ModelAPI_ResultParameter.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_Session.h>
+#include <ModelAPI_Events.h>
#include <TopoDS_Iterator.hxx>
return aShape;
}
+void flushUpdated(ObjectPtr theObject)
+{
+ blockUpdateViewer(true);
+
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+
+ blockUpdateViewer(false);
+}
+
+void blockUpdateViewer(const bool theValue)
+{
+ // the viewer update should be blocked in order to avoid the temporary feature content
+ // when the solver processes the feature, the redisplay message can be flushed
+ // what caused the display in the viewer preliminary states of object
+ // e.g. fillet feature, angle value change
+ std::shared_ptr<Events_Message> aMsg;
+ if (theValue) {
+ aMsg = std::shared_ptr<Events_Message>(
+ new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED)));
+ }
+ else {
+ // the viewer update should be unblocked
+ aMsg = std::shared_ptr<Events_Message>(
+ new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED)));
+ }
+ Events_Loop::loop()->send(aMsg);
+}
+
} // namespace ModuleBase_Tools
MODULEBASE_EXPORT std::shared_ptr<GeomAPI_Shape> getShape(const AttributePtr& theAttribute,
ModuleBase_IWorkshop* theWorkshop);
+/// Flush updated signal for the object. The viewer update is blocked in the process
+/// \param theObject parameter of the signal
+MODULEBASE_EXPORT void flushUpdated(ObjectPtr theObject);
+
+/// Sends a message about block/unblock viewer updating
+/// \param theValue a boolean value
+MODULEBASE_EXPORT void blockUpdateViewer(const bool theValue);
+
}
#endif
{
}
-bool ModuleBase_WidgetBoolValue::storeValueCustom() const
+bool ModuleBase_WidgetBoolValue::storeValueCustom()
{
DataPtr aData = myFeature->data();
std::shared_ptr<ModelAPI_AttributeBoolean> aBool = aData->boolean(attributeID());
protected:
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValueCustom() const;
+ virtual bool storeValueCustom();
virtual bool restoreValueCustom();
return myMainLayout;
}
-bool ModuleBase_WidgetCheckGroupBox::storeValueCustom() const
+bool ModuleBase_WidgetCheckGroupBox::storeValueCustom()
{
DataPtr aData = myFeature->data();
std::shared_ptr<ModelAPI_AttributeBoolean> aBool = aData->boolean(attributeID());
/// Methods to be redefined from ModuleBase_ModelWidget: start
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValueCustom() const;
+ virtual bool storeValueCustom();
/// Restore value from attribute data to the widget's control
virtual bool restoreValueCustom();
/// Methods to be redefined from ModuleBase_ModelWidget: end
{
}
-bool ModuleBase_WidgetChoice::storeValueCustom() const
+bool ModuleBase_WidgetChoice::storeValueCustom()
{
DataPtr aData = myFeature->data();
std::shared_ptr<ModelAPI_AttributeInteger> aIntAttr = aData->integer(attributeID());
protected:
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValueCustom() const;
+ virtual bool storeValueCustom();
virtual bool restoreValueCustom();
return aDone;
}
-bool ModuleBase_WidgetDoubleValue::storeValueCustom() const
+bool ModuleBase_WidgetDoubleValue::storeValueCustom()
{
DataPtr aData = myFeature->data();
AttributeDoublePtr aReal = aData->real(attributeID());
protected:
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValueCustom() const;
+ virtual bool storeValueCustom();
//! Read value of corresponded attribute from data model to the input control
// \return True in success
{
}
-bool ModuleBase_WidgetExprEditor::storeValueCustom() const
+bool ModuleBase_WidgetExprEditor::storeValueCustom()
{
// A rare case when plugin was not loaded.
if(!myFeature)
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValueCustom() const;
+ virtual bool storeValueCustom();
/// Redefinition of virtual method
virtual bool restoreValueCustom();
{
}
-bool ModuleBase_WidgetFileSelector::storeValueCustom() const
+bool ModuleBase_WidgetFileSelector::storeValueCustom()
{
// A rare case when plugin was not loaded.
if (!myFeature)
protected:
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValueCustom() const;
+ virtual bool storeValueCustom();
virtual bool restoreValueCustom();
return aDone;
}
-bool ModuleBase_WidgetIntValue::storeValueCustom() const
+bool ModuleBase_WidgetIntValue::storeValueCustom()
{
DataPtr aData = myFeature->data();
AttributeIntegerPtr anAttribute = aData->integer(attributeID());
protected:
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValueCustom() const;
+ virtual bool storeValueCustom();
//! Read value of corresponded attribute from data model to the input control
// \return True in success
protected:
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValueCustom() const
+ virtual bool storeValueCustom()
{
return true;
}
{
}
-bool ModuleBase_WidgetLineEdit::storeValueCustom() const
+bool ModuleBase_WidgetLineEdit::storeValueCustom()
{
// A rare case when plugin was not loaded.
if(!myFeature)
protected:
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValueCustom() const;
+ virtual bool storeValueCustom();
/// Redefinition of virtual method
virtual bool restoreValueCustom();
}
//********************************************************************
-bool ModuleBase_WidgetMultiSelector::storeValueCustom() const
+bool ModuleBase_WidgetMultiSelector::storeValueCustom()
{
// the value is stored on the selection changed signal processing
// A rare case when plugin was not loaded.
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValueCustom() const;
+ virtual bool storeValueCustom();
virtual bool restoreValueCustom();
}
//********************************************************************
-bool ModuleBase_WidgetShapeSelector::storeValueCustom() const
+bool ModuleBase_WidgetShapeSelector::storeValueCustom()
{
// the value is stored on the selection changed signal processing
return true;
protected:
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValueCustom() const;
+ virtual bool storeValueCustom();
virtual bool restoreValueCustom();
return aBodyIsVisualized;
}
+bool PartSet_PreviewPlanes::hasVisualizedSketch(ModuleBase_IWorkshop* theWorkshop)
+{
+ bool aSketchIsVisualized = false;
+
+ XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(theWorkshop);
+ XGUI_Displayer* aDisp = aWorkshop->displayer();
+ QObjectPtrList aDisplayed = aDisp->displayedObjects();
+ foreach (ObjectPtr anObj, aDisplayed) {
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObj);
+ if (aResult.get() != NULL) {
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aResult);
+ aSketchIsVisualized = aFeature.get() && aFeature->getKind() == SketchPlugin_Sketch::ID();
+ if (aSketchIsVisualized)
+ break;
+ }
+ }
+ return aSketchIsVisualized;
+}
+
void PartSet_PreviewPlanes::erasePreviewPlanes(ModuleBase_IWorkshop* theWorkshop)
{
if (myPreviewDisplayed) {
/// \return boolean value
static bool hasVisualizedBodies(ModuleBase_IWorkshop* theWorkshop);
+ /// Returns true if there is at least one Sketch visualized in the viewer
+ /// \param theWorkshop the application workshop
+ /// \return boolean value
+ static bool hasVisualizedSketch(ModuleBase_IWorkshop* theWorkshop);
+
/// Returns if the preview was displayed
/// \param theWorkshop the application workshop
/// \return boolean value
{
myIsMouseOverViewProcessed = false;
myIsMouseOverWindow = false;
- // it is important to validate operation here only if sketch entity create operation is active
- // because at this operation we reacts to the mouse leave/enter view port
- //operationMgr()->onValidateOperation();
#ifdef DEBUG_DO_NOT_BY_ENTER
return;
if (myIsPopupMenuActive)
return;
+ // it is important to validate operation here only if sketch entity create operation is active
+ // because at this operation we reacts to the mouse leave/enter view port
operationMgr()->onValidateOperation();
// 2. if the mouse IS NOT over window, reset the active widget value and hide the presentation
// in activate() the value of the point is initialized and it can be displayed
// but the default value is [0, 0]. So, we block update viewer contentent until
// onMouseRelease happens, which correct the point position
- ModuleBase_ModelWidget::blockUpdateViewer(true);
+ ModuleBase_Tools::blockUpdateViewer(true);
restartOperation();
aProcessed = true;
aPoint2DWdg->onMouseRelease(theWnd, theEvent);
}
// unblock viewer update
- ModuleBase_ModelWidget::blockUpdateViewer(false);
+ ModuleBase_Tools::blockUpdateViewer(false);
}
}
AttributeStringPtr aSourceFeatureTypeAttr = theSourceFeature->data()->string(aTypeAttributeId);
AttributeStringPtr aNewFeatureTypeAttr = theNewFeature->data()->string(aTypeAttributeId);
aNewFeatureTypeAttr->setValue(aSourceFeatureTypeAttr->value());
- ModuleBase_ModelWidget::updateObject(theNewFeature);
+ ModuleBase_Tools::flushUpdated(theNewFeature);
aChanged = true;
}
return aChanged;
#include <ModuleBase_IWorkshop.h>
#include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_Tools.h>
#include <V3d_View.hxx>
#include <gp_Pln.hxx>
// may be feature is not updated yet, execute is not performed and references features
// are not created. Case: rectangle macro feature
- ModuleBase_ModelWidget::updateObject(theFeature);
+ ModuleBase_Tools::flushUpdated(theFeature);
std::list<AttributePtr> anAttributes = theFeature->data()->attributes(
ModelAPI_AttributeRefList::typeId());
return ModuleBase_WidgetFileSelector::restoreValueCustom();
}
-bool PartSet_WidgetFileSelector::storeValueCustom() const
+bool PartSet_WidgetFileSelector::storeValueCustom()
{
// A rare case when plugin was not loaded.
if (!myFeature)
protected:
/// Reimplemented from ModuleBase_WidgetFileSelector::storeValueCustom()
- virtual bool storeValueCustom() const;
+ virtual bool storeValueCustom();
/// Reimplemented from ModuleBase_WidgetFileSelector::restoreValue()
virtual bool restoreValueCustom();
return true;
}
-bool PartSet_WidgetPoint2D::storeValueCustom() const
+bool PartSet_WidgetPoint2D::storeValueCustom()
{
std::shared_ptr<ModelAPI_Data> aData = myFeature->data();
if (!aData) // can be on abort of sketcher element
protected:
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValueCustom() const;
+ virtual bool storeValueCustom();
/// Restore value from attribute data to the widget's control
virtual bool restoreValueCustom();
return true;
}
-bool PartSet_WidgetSketchCreator::storeValueCustom() const
+bool PartSet_WidgetSketchCreator::storeValueCustom()
{
return true;
}
if (theSelectionControl) {
bool aBodyIsVisualized = myPreviewPlanes->hasVisualizedBodies(myWorkshop);
- if (!aBodyIsVisualized) {
+ bool aSketchIsVisualized = myPreviewPlanes->hasVisualizedSketch(myWorkshop);
+ if (!aBodyIsVisualized && !aSketchIsVisualized) {
// We have to select a plane before any operation
myPreviewPlanes->showPreviewPlanes(myWorkshop);
}
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValueCustom() const;
+ virtual bool storeValueCustom();
virtual bool restoreValueCustom();
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValueCustom() const
+ virtual bool storeValueCustom()
{
return true;
}
return aControls;
}
-bool SamplePanelPlugin_ModelWidget::storeValueCustom() const
+bool SamplePanelPlugin_ModelWidget::storeValueCustom()
{
AttributePtr anAttribute = myFeature->attribute(SamplePanelPlugin_Feature::VALUE_ID());
AttributeIntegerPtr aValueAttribute =
protected:
/// Saves the internal parameters to the given feature
/// \return True in success
- virtual bool storeValueCustom() const;
+ virtual bool storeValueCustom();
/// Restore value from attribute data to the widget's control
virtual bool restoreValueCustom();
#include <ModuleBase_ModelWidget.h>
#include <ModuleBase_OperationFeature.h>
+#include <ModuleBase_Tools.h>
+#include <QDebug>
+
#include <ModelAPI_Attribute.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Validator.h>
const QString INVALID_VALUE = "invalid_action";
+//#define DEBUG_ERROR_STATE
XGUI_ErrorMgr::XGUI_ErrorMgr(QObject* theParent, ModuleBase_IWorkshop* theWorkshop)
: ModuleBase_IErrorMgr(theParent),
}
updateActionState(anOkAction, anError);
updateToolTip(anActiveWidget, aWidgetError);
+
+#ifdef DEBUG_ERROR_STATE
+ QString anInfo = ModuleBase_Tools::objectInfo(theFeature);
+
+ QString aResultInfo = QString("valid = %1, anError = %2, aWidgetError = %3")
+ .arg(anError.isEmpty()).arg(anError).arg(aWidgetError);
+ qDebug(QString("XGUI_ErrorMgr::updateActions for %1, result: %2").arg(anInfo)
+ .arg(aResultInfo).toStdString().c_str());
+#endif
}
}
myPanelPage = new ModuleBase_PageWidget(aContent);
myPanelPage->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
- aMainLayout->addWidget(myPanelPage, aPanelRow++, kPanelColumn);
+ aMainLayout->addWidget(myPanelPage, aPanelRow, kPanelColumn);
// spit to make the preview button on the bottom of the panel
aMainLayout->setRowStretch(aPanelRow++, 1);
if (isToConnect) {
connect(aWidget, SIGNAL(valueStateChanged(int)), this, SLOT(onWidgetStateChanged(int)));
connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChanged()));
- }
+ connect(aWidget, SIGNAL(objectUpdated()), this, SLOT(onWidgetObjectUpdated()));
+ }
else {
disconnect(aWidget, SIGNAL(valueStateChanged(int)), this, SLOT(onWidgetStateChanged(int)));
disconnect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChanged()));
+ disconnect(aWidget, SIGNAL(objectUpdated()), this, SLOT(onWidgetObjectUpdated()));
}
}
}
}
}
+void XGUI_Workshop::onWidgetObjectUpdated()
+{
+ operationMgr()->onValidateOperation();
+}
+
ModuleBase_IModule* XGUI_Workshop::loadModule(const QString& theModule)
{
QString libName = QString::fromStdString(library(theModule.toStdString()));
/// differs in the new state of paged container
void onValuesChanged();
+ /// Listens the corresponded signal of model widget and updates Apply button state by feature
+ void onWidgetObjectUpdated();
+
/// Show property panel
void showPropertyPanel();
aLoop->registerListener(this, Events_LongOp::eventID());
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_PLUGIN_LOADED));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_SELFILTER_LOADED));
- aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_ERROR_CHANGED));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED));
// the viewer's update context is unblocked, the viewer's update works
XGUI_Displayer* aDisplayer = workshop()->displayer();
aDisplayer->enableUpdateViewer(true);
- } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_OBJECT_ERROR_CHANGED)) {
- std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
- std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
- std::set<ObjectPtr> anObjects = aUpdMsg->objects();
-
- ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
- (workshop()->operationMgr()->currentOperation());
- bool aFeatureChanged = false;
- if(aFOperation ) {
- FeaturePtr aFeature = aFOperation->feature();
- if (aFeature.get()) {
- std::set<ObjectPtr>::const_iterator aIt;
- for (aIt = anObjects.begin(); aIt != anObjects.end() && !aFeatureChanged; ++aIt) {
- aFeatureChanged = ModelAPI_Feature::feature(*aIt) == aFeature;
- }
- }
- if (aFeatureChanged)
- workshop()->operationMgr()->onValidateOperation();
- }
} else {
//Show error dialog if error message received.
std::shared_ptr<Events_Error> anAppError = std::dynamic_pointer_cast<Events_Error>(theMessage);