aFrame->setFrameStyle(QFrame::WinPanel | QFrame::Raised);
aLayout->addWidget(aFrame);
- QVBoxLayout* aBtnLayout = new QVBoxLayout(aFrame);
+ QHBoxLayout* aBtnLayout = new QHBoxLayout(aFrame);
ModuleBase_Tools::adjustMargins(aBtnLayout);
myButtonsBox = new QDialogButtonBox(
/// Set general buttons from dialog
/// \param theButtons the dialog buttons
- void setDialogButtons(QDialogButtonBox* theButtons) { myOkCancelBtn = theButtons; }
+ virtual void setDialogButtons(QDialogButtonBox* theButtons) { myOkCancelBtn = theButtons; }
protected:
{
QImage anIcon = ModuleBase_IconFactory::loadImage(theIcon);
QImage anAditional(theAdditionalIcon);
+ return composite(anAditional, anIcon);
+}
- if (anIcon.isNull())
+QPixmap composite(const QImage& theAdditionalIcon, QImage& theIcon)
+{
+ if (theIcon.isNull())
return QPixmap();
- int anAddWidth = anAditional.width();
- int anAddHeight = anAditional.height();
+ int anAddWidth = theAdditionalIcon.width();
+ int anAddHeight = theAdditionalIcon.height();
- int aWidth = anIcon.width();
- int aHeight = anIcon.height();
+ int aWidth = theIcon.width();
+ int aHeight = theIcon.height();
- int aStartWidthPos = aWidth - anAddWidth - 1;
- int aStartHeightPos = aHeight - anAddHeight - 1;
+ int aStartWidthPos = aWidth - anAddWidth;
+ int aStartHeightPos = aHeight - anAddHeight;
for (int i = 0; i < anAddWidth && i + aStartWidthPos < aWidth; i++)
{
for (int j = 0; j < anAddHeight && j + aStartHeightPos < aHeight; j++)
{
- if (qAlpha(anAditional.pixel(i, j)) > 0)
- anIcon.setPixel(i + aStartWidthPos, j + aStartHeightPos, anAditional.pixel(i, j));
+ if (qAlpha(theAdditionalIcon.pixel(i, j)) > 0)
+ theIcon.setPixel(i + aStartWidthPos, j + aStartHeightPos, theAdditionalIcon.pixel(i, j));
}
}
- return QPixmap::fromImage(anIcon);
+ return QPixmap::fromImage(theIcon);
}
QPixmap lighter(const QString& theIcon, const int theLighterValue)
/// \return resulting pixmap
MODULEBASE_EXPORT QPixmap composite(const QString& theAdditionalIcon, const QString& theIcon);
+/// Create composite pixmap.
+/// Pixmap \a theAdditionalIcon is drawn over pixmap \a dest with coordinates
+/// specified relatively to the upper left corner of \a theIcon.
+
+/// \param theAdditionalIcon additional pixmap
+/// \param theIcon background pixmap
+/// \return resulting pixmap
+MODULEBASE_EXPORT QPixmap composite(const QImage& theAdditionalIcon, QImage& theIcon);
+
/// Generates the pixmap lighter than the resources pixmap.
/// Pixmap \a theIcon is lighted according to the given value.
/// If the lighter value is greater than 100, this functions returns a lighter pixmap.
ParametersPlugin_WidgetParamsMgr::ParametersPlugin_WidgetParamsMgr(QWidget* theParent,
const Config_WidgetAPI* theData)
- : ModuleBase_ModelDialogWidget(theParent, theData)
+ : ModuleBase_ModelDialogWidget(theParent, theData),
+ isUpplyBlocked(false)
{
QVBoxLayout* aLayout = new QVBoxLayout(this);
onSelectionChanged();
}
+void ParametersPlugin_WidgetParamsMgr::setDialogButtons(QDialogButtonBox* theButtons)
+{
+ ModuleBase_ModelDialogWidget::setDialogButtons(theButtons);
+
+ QWidget* aBtnParentWgt = myOkCancelBtn->parentWidget();
+ QHBoxLayout* aBtnParentLayout = dynamic_cast<QHBoxLayout*>(aBtnParentWgt->layout());
+
+ QPushButton* aPreviewBtn = new QPushButton(tr("See preview"), aBtnParentWgt);
+ aBtnParentLayout->insertWidget(0, aPreviewBtn);
+ aBtnParentLayout->insertStretch(1, 1);
+ connect(aPreviewBtn, SIGNAL(clicked(bool)), SLOT(onShowPreview()));
+}
+
+
QList<QWidget*> ParametersPlugin_WidgetParamsMgr::getControls() const
{
QList<QWidget*> aList;
return true;
}
+void ParametersPlugin_WidgetParamsMgr::showEvent(QShowEvent* theEvent)
+{
+ ModuleBase_ModelDialogWidget::showEvent(theEvent);
+ SessionPtr aMgr = ModelAPI_Session::get();
+ isUpplyBlocked = aMgr->isAutoUpdateBlocked();
+ aMgr->blockAutoUpdate(true);
+ Events_Loop* aLoop = Events_Loop::loop();
+ aLoop->flush(aLoop->eventByName(EVENT_AUTOMATIC_RECOMPUTATION_DISABLE));
+}
+
+void ParametersPlugin_WidgetParamsMgr::hideEvent(QHideEvent* theEvent)
+{
+ ModuleBase_ModelDialogWidget::hideEvent(theEvent);
+ SessionPtr aMgr = ModelAPI_Session::get();
+ aMgr->blockAutoUpdate(isUpplyBlocked);
+}
+
+void ParametersPlugin_WidgetParamsMgr::onShowPreview()
+{
+ SessionPtr aMgr = ModelAPI_Session::get();
+ aMgr->blockAutoUpdate(false);
+ aMgr->blockAutoUpdate(true);
+}
\ No newline at end of file
/// \return a control list
virtual QList<QWidget*> getControls() const;
+ /// Set general buttons from dialog
+ /// \param theButtons the dialog buttons
+ virtual void setDialogButtons(QDialogButtonBox* theButtons);
+
protected:
/// Saves the internal parameters to the given feature
/// \return True in success
/// The method called when widget is activated
virtual void activateCustom();
+ virtual void showEvent(QShowEvent* theEvent);
+
+ virtual void hideEvent(QHideEvent* theEvent);
+
private slots:
/// Slot for reaction on double click in the table (start editing)
/// \param theIndex the clicked index
/// Slot for reaction on selection in the table
void onSelectionChanged();
+ // A slot for show preview button
+ void onShowPreview();
+
private:
/// Creates a new parameter feature
FeaturePtr createParameter() const;
QPushButton* myRemoveBtn;
QToolButton* myUpBtn;
QToolButton* myDownBtn;
+
+ bool isUpplyBlocked;
};
}
break;
case ModelAPI_StateMustBeUpdated: {
- anIcon = ModuleBase_Tools::lighter(anIconString);
+ anIcon = ModuleBase_Tools::composite(":icons/toWork.png", anIconString);
+ //anIcon = ModuleBase_Tools::lighter(anIconString);
}
break;
case ModelAPI_StateExecFailed: {
- anIcon = ModuleBase_Tools::composite(":icons/exec_state_failed.png", anIconString);
+ anIcon = ModuleBase_Tools::composite(":icons/isFailed.png", anIconString);
}
break;
case ModelAPI_StateInvalidArgument: {
}
}
- if (theObj->data() && theObj->data()->execState() == ModelAPI_StateMustBeUpdated)
- return QIcon(":pictures/constr_object_modified.png");
+ //if (theObj->data() && theObj->data()->execState() == ModelAPI_StateMustBeUpdated)
+ // return QIcon(":pictures/constr_object_modified.png");
std::string aGroup = theObj->groupName();
if (aGroup == ModelAPI_ResultPart::group())
#include <ModuleBase_IconFactory.h>
#include <ModuleBase_IWorkshop.h>
+#include <ModuleBase_Tools.h>
#include <PartSetPlugin_Part.h>
}
+QVariant PartSet_ObjectFolderNode::data(int theColumn, int theRole) const
+{
+ const QImage anAditional(":icons/hasWarning.png");
+
+ if ((theRole == Qt::DecorationRole) && (theColumn == 1)) {
+ ObjectPtr aObject;
+ bool aHasWarning = false;
+ foreach(ModuleBase_ITreeNode* aNode, myChildren) {
+ aObject = aNode->object();
+ if (aObject.get()) {
+ ModelAPI_ExecState aState = aObject->data()->execState();
+ if ((aState == ModelAPI_StateExecFailed) || (aState == ModelAPI_StateMustBeUpdated)) {
+ aHasWarning = true;
+ break;
+ }
+ }
+ }
+ if (aHasWarning) {
+ return QIcon(ModuleBase_Tools::composite(":icons/hasWarning.png",
+ ":pictures/features_folder.png"));
+ }
+ }
+ return PartSet_ObjectNode::data(theColumn, theRole);
+}
+
+
//////////////////////////////////////////////////////////////////////////////////
QVariant PartSet_StepNode::data(int theColumn, int theRole) const
{
/// \param theGroup a name of group where objects were deleted
virtual QTreeNodesList objectsDeleted(const DocumentPtr& theDoc, const QString& theGroup);
+ /// Returns the node representation according to theRole.
+ virtual QVariant data(int theColumn, int theRole) const;
+
private:
FeaturePtr getFeature(const std::string& theId) const;
<file>icons/group_face.png</file>
<file>icons/group_solid.png</file>
<file>icons/group_vertex.png</file>
+ <file>icons/toWork.png</file>
+ <file>icons/isFailed.png</file>
+ <file>icons/hasWarning.png</file>
</qresource>
</RCC>
myOperationMgr = new XGUI_OperationMgr(this, 0);
ModuleBase_IWorkshop* aWorkshop = moduleConnector();
// Has to be defined first in order to get errors and messages from other components
- myEventsListener = new XGUI_WorkshopListener(aWorkshop);
+ myEventsListener = new XGUI_WorkshopListener(this);
mySelectionActivate = new XGUI_SelectionActivate(aWorkshop);
SUIT_ResourceMgr* aResMgr = ModuleBase_Preferences::resourceMgr();
aCommand->connectTo(this, SLOT(onOpen()));
- aCommand = aGroup->addFeature("AUTOCOMPUTE_CMD", tr("Block auto-apply"),
+ aCommand = aGroup->addFeature("AUTOCOMPUTE_CMD", tr("Auto rebuild"),
tr("Blocks immediate apply of modifications"),
- QIcon(":pictures/autoapply.png"), QString(),
- QKeySequence(), true, true);
- aCommand->setChecked(ModelAPI_Session::get()->isAutoUpdateBlocked());
- aCommand->connectTo(this, SLOT(onAutoApply(bool)));
+ QIcon(":pictures/autoapply_start.png"), QKeySequence());
+ //aCommand->setChecked(ModelAPI_Session::get()->isAutoUpdateBlocked());
+ aCommand->connectTo(this, SLOT(onAutoApply()));
aCommand = aGroup->addFeature("PREF_CMD", tr("Preferences"), tr("Edit preferences"),
QIcon(":pictures/preferences.png"), QKeySequence::Preferences);
aCmd->setEnabled(myModule->canRedo());
}
else if (aId == "AUTOCOMPUTE_CMD") {
- aCmd->setChecked(aMgr->isAutoUpdateBlocked());
+ //aCmd->setChecked(aMgr->isAutoUpdateBlocked());
+ aCmd->setIcon(aMgr->isAutoUpdateBlocked() ?
+ QIcon(":pictures/autoapply_stop.png") :
+ QIcon(":pictures/autoapply_start.png"));
}
else
// Enable all commands
updateCommandStatus();
}
-void XGUI_Workshop::onAutoApply(bool isToggle)
+void XGUI_Workshop::onAutoApply()
{
SessionPtr aMgr = ModelAPI_Session::get();
- aMgr->blockAutoUpdate(isToggle);
-}
\ No newline at end of file
+ bool isBlocked = aMgr->isAutoUpdateBlocked();
+ aMgr->blockAutoUpdate(!isBlocked);
+}
+
+void XGUI_Workshop::updateAutoComputeState()
+{
+ SessionPtr aMgr = ModelAPI_Session::get();
+ bool isComputeBlocked = aMgr->isAutoUpdateBlocked();
+#ifdef HAVE_SALOME
+ QAction* aUpdateCmd;
+ QList<QAction*> aCommands = workshop()->salomeConnector()->commandList();
+ foreach(QAction* aCmd, aCommands) {
+ if (aCmd->data().toString() == "AUTOCOMPUTE_CMD") {
+ aUpdateCmd = aCmd;
+ break;
+ }
+ }
+ aUpdateCmd->setIcon(isComputeBlocked? QIcon(":pictures/autoapply_stop.png") :
+ QIcon(":pictures/autoapply_start.png"));
+#else
+ AppElements_MainMenu* aMenuBar = myMainWindow->menuObject();
+ AppElements_Command* aUpdateCmd = aMenuBar->feature("AUTOCOMPUTE_CMD");
+ aUpdateCmd->button()->setIcon(isComputeBlocked? QIcon(":pictures/autoapply_stop.png") :
+ QIcon(":pictures/autoapply_start.png"));
+#endif
+}
/// \param theDirectory a path to directory
void openDirectory(const QString& theDirectory);
+ void updateAutoComputeState();
+
signals:
/// Emitted when selection happens in Salome viewer
void salomeViewerSelection();
#endif
/// A slot calleon toggle of auto-compute button
- void onAutoApply(bool isToggle);
+ void onAutoApply();
/// Activates/deactivates the trihedron in the viewer AIS context
void onTrihedronVisibilityChanged(bool theState);
const std::string DebugFeatureKind = "";//"Extrusion";
#endif
-XGUI_WorkshopListener::XGUI_WorkshopListener(ModuleBase_IWorkshop* theWorkshop)
+XGUI_WorkshopListener::XGUI_WorkshopListener(XGUI_Workshop* theWorkshop)
: myWorkshop(theWorkshop),
myUpdatePrefs(false)
{
aLoop->registerListener(this, Events_Loop::eventByName("FinishOperation"));
aLoop->registerListener(this, Events_Loop::eventByName("AbortOperation"));
+ aLoop->registerListener(this, Events_Loop::eventByName(EVENT_AUTOMATIC_RECOMPUTATION_ENABLE));
+ aLoop->registerListener(this, Events_Loop::eventByName(EVENT_AUTOMATIC_RECOMPUTATION_DISABLE));
}
//******************************************************
// 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_AUTOMATIC_RECOMPUTATION_ENABLE)) ||
+ (theMessage->eventID() ==
+ Events_Loop::eventByName(EVENT_AUTOMATIC_RECOMPUTATION_DISABLE))) {
+ myWorkshop->updateAutoComputeState();
} else {
//Show error dialog if error message received.
std::shared_ptr<Events_InfoMessage> anIngfoMsg =
XGUI_Workshop* XGUI_WorkshopListener::workshop() const
{
- XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
- return aConnector->workshop();
+ return myWorkshop;
}
public:
/// Constructor. Used only if the workshop is launched in Salome environment
/// \param theWorkshop a reference to workshop.
- XGUI_WorkshopListener(ModuleBase_IWorkshop* theWorkshop);
+ XGUI_WorkshopListener(XGUI_Workshop* theWorkshop);
virtual ~XGUI_WorkshopListener();
/// Register this class in the events loop for several types of events
XGUI_Workshop* workshop() const;
private:
- ModuleBase_IWorkshop* myWorkshop; // the current workshop
+ XGUI_Workshop* myWorkshop; // the current workshop
bool myUpdatePrefs;
};
<file>pictures/move_out_after.png</file>
<file>pictures/move_out_before.png</file>
<file>pictures/selection.png</file>
- <file>pictures/autoapply.png</file>
+ <file>pictures/autoapply_start.png</file>
+ <file>pictures/autoapply_stop.png</file>
<file>pictures/whatis.png</file>
</qresource>
</RCC>