// Created: 2 Jul 2014
// Author: Mikhail PONIKAROV
-#ifndef Model_Validator_HeaderFile
-#define Model_Validator_HeaderFile
+#ifndef Model_Validator_H_
+#define Model_Validator_H_
#include <Model.h>
#include <ModelAPI_Validator.h>
#include <map>
+ #include <set>
/**\class Model_ValidatorsFactory
* \ingroup DataModel
*/
class Model_ValidatorsFactory: public ModelAPI_ValidatorsFactory
{
+ private:
std::map<std::string, ModelAPI_Validator*> myIDs; ///< map from ID to registered validator
- std::map<std::string, ModelAPI_Validator*> myFeatures; ///< validators by feature ID
- std::map<std::string, std::map<std::string, std::pair<ModelAPI_Validator*,
- std::list<std::string> > > > myAttrs; ///< validators and arguments by feature and attribute IDs
+ /// validators IDs by feature ID
+ std::map<std::string, std::set<std::string> > myFeatures;
+ /// set of pairs: validators IDs, list of arguments
+ typedef std::set<std::pair<std::string, std::list<std::string> > > AttrValidators;
+ /// validators IDs and arguments by feature and attribute IDs
+ std::map<std::string, std::map<std::string, AttrValidators> > myAttrs;
public:
/// Registers the instance of the validator by the ID
MODEL_EXPORT virtual void registerValidator(
const std::list<std::string>& theArguments);
/// Provides a validator for the feature, returns NULL if no validator
- MODEL_EXPORT virtual const ModelAPI_Validator* validator(const std::string& theFeatureID) const;
+ MODEL_EXPORT virtual void validators(const std::string& theFeatureID,
+ std::list<ModelAPI_Validator*>& theResult) const;
/// Provides a validator for the attribute, returns NULL if no validator
- MODEL_EXPORT virtual const ModelAPI_Validator* validator(
- const std::string& theFeatureID, const std::string& theAttrID) const;
+ MODEL_EXPORT virtual void validators(
+ const std::string& theFeatureID, const std::string& theAttrID,
+ std::list<ModelAPI_Validator*>& theValidators,
+ std::list<std::list<std::string> >& theArguments) const;
+
+ /// Returns registered validator by its Id
+ virtual const ModelAPI_Validator* validator(const std::string& theID) const;
/// Returns the result of "validate" method for attribute of validator.
/// If validator is not exists, returns true: everything is valid by default.
#include <Config_PointerMessage.h>
#include <Config_ModuleReader.h>
+ #include <SUIT_ResourceMgr.h>
+
#include <QApplication>
#include <QFileDialog>
#include <QMessageBox>
#include <dlfcn.h>
#endif
+ SUIT_ResourceMgr* XGUI_Workshop::myResourceMgr = 0;
QMap<QString, QString> XGUI_Workshop::myIcons;
myObjectBrowser(0),
myDisplayer(0)
{
+ if (!myResourceMgr) {
+ myResourceMgr = new SUIT_ResourceMgr("NewGeom");
+ myResourceMgr->setCurrentFormat("xml");
+ }
myMainWindow = mySalomeConnector? 0 : new XGUI_MainWindow();
myDisplayer = new XGUI_Displayer(this);
salomeConnector()->addEditMenuSeparator();
return;
}
- XGUI_Workbench* aPage = myMainWindow->menuObject()->generalPage();
-
// File commands group
- XGUI_MenuGroupPanel* aGroup = aPage->addGroup("Default");
+ XGUI_MenuGroupPanel* aGroup = myMainWindow->menuObject()->generalPage();
XGUI_Command* aCommand;
QIcon(":pictures/close.png"), QKeySequence::Close);
aCommand->connectTo(this, SLOT(onExit()));
//FIXME: SBH's test action. Can be used for some GUI tests.
- //#ifdef _DEBUG
- // aCommand = aGroup->addFeature("TEST_CMD", "Test!", "Private debug button",
- // QIcon(":pictures/close.png"));
- // aCommand->connectTo(myActionsMgr, SLOT(update()));
- //#endif
+// #ifdef _DEBUG
+// aCommand = aGroup->addFeature("TEST_CMD", "Test!", "Private debug button",
+// QIcon(":pictures/close.png"), QKeySequence(), true);
+// aCommand->connectTo(myMainWindow, SLOT(dockPythonConsole()));
+// #endif
}
//******************************************************
return;
}
- if (theMessage->eventID() == Events_Loop::loop()->eventByName("LongOperation")) {
+ if (theMessage->eventID() == Events_LongOp::eventID()) {
if (Events_LongOp::isPerformed())
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
- else
+ //QTimer::singleShot(10, this, SLOT(onStartWaiting()));
+ else
QApplication::restoreOverrideCursor();
return;
}
if (myOperationMgr->startOperation(anOperation)) {
myPropertyPanel->updateContentWidget(anOperation->feature());
if (!anOperation->getDescription()->hasXmlRepresentation()) {
- anOperation->commit();
- updateCommandStatus();
+ if (anOperation->commit())
+ updateCommandStatus();
}
}
return;
}
}
+ //******************************************************
+ void XGUI_Workshop::onStartWaiting()
+ {
+ if (Events_LongOp::isPerformed()) {
+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+ }
+ }
+
//******************************************************
void XGUI_Workshop::onFeatureUpdatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg)
{
ModuleBase_ModelWidget* aWidget;
for (; anIt != aLast; anIt++) {
aWidget = *anIt;
+ aWidget->setFeature(aOperation->feature());
//QObject::connect(aWidget, SIGNAL(valuesChanged()), aOperation, SLOT(storeCustomValue()));
QObject::connect(aWidget, SIGNAL(valuesChanged()),
this, SLOT(onWidgetValuesChanged()));
// Init default values
if (!aOperation->isEditOperation() && aWidget->hasDefaultValue()) {
- aWidget->storeValue(aOperation->feature());
+ //aWidget->storeValue(aOperation->feature());
+
+ aWidget->storeValue();
}
}
QString aWchName = QString::fromStdString(theMessage->workbenchId());
QString aNestedFeatures = QString::fromStdString(theMessage->nestedFeatures());
bool isUsePropPanel = theMessage->isUseInput();
- QString aId = QString::fromStdString(theMessage->id());
+ QString aFeatureId = QString::fromStdString(theMessage->id());
if (isSalomeMode()) {
QAction* aAction = salomeConnector()->addFeature(aWchName,
- aId,
+ aFeatureId,
QString::fromStdString(theMessage->text()),
QString::fromStdString(theMessage->tooltip()),
QIcon(theMessage->icon().c_str()),
QKeySequence(), isUsePropPanel);
- salomeConnector()->setNestedActions(aId, aNestedFeatures.split(" "));
+ salomeConnector()->setNestedActions(aFeatureId, aNestedFeatures.split(" "));
myActionsMgr->addCommand(aAction);
myModule->featureCreated(aAction);
} else {
if (!aGroup) {
aGroup = aPage->addGroup(aGroupName);
}
- //Create feature...
- XGUI_Command* aCommand = aGroup->addFeature(aId,
+ // Check if hotkey sequence is already defined:
+ QKeySequence aHotKey = myActionsMgr->registerShortcut(
+ QString::fromStdString(theMessage->keysequence()));
+ // Create feature...
+ XGUI_Command* aCommand = aGroup->addFeature(aFeatureId,
QString::fromStdString(theMessage->text()),
QString::fromStdString(theMessage->tooltip()),
QIcon(theMessage->icon().c_str()),
- QKeySequence(), isUsePropPanel);
+ aHotKey, isUsePropPanel);
aCommand->setNestedCommands(aNestedFeatures.split(" ", QString::SkipEmptyParts));
myActionsMgr->addCommand(aCommand);
myModule->featureCreated(aCommand);
} else {
XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
foreach (XGUI_Workbench* aWb, aMenuBar->workbenches()) {
- if (aWb != aMenuBar->generalPage()) {
- foreach(XGUI_Command* aCmd, aWb->features())
- aCommands.append(aCmd);
- }
+ foreach(XGUI_Command* aCmd, aWb->features())
+ aCommands.append(aCmd);
}
}
return aCommands;
for (; anIt != aLast; anIt++) {
ModuleBase_ModelWidget* aCustom = *anIt;
if (aCustom && (/*!aCustom->isInitialized(aFeature) ||*/ aCustom == aSenderWidget)) {
- aCustom->storeValue(aFeature);
+ //aCustom->storeValue(aFeature);
+ aCustom->storeValue();
}
}
}
QList<QAction*> aActions = getModuleCommands();
foreach(QAction* aAction, aActions) {
QString aId = aAction->data().toString();
- const ModelAPI_Validator* aValidator = aFactory->validator(aId.toStdString());
- if (aValidator) {
- const ModuleBase_SelectionValidator* aSelValidator =
- dynamic_cast<const ModuleBase_SelectionValidator*>(aValidator);
- if (aSelValidator) {
- aAction->setEnabled(aSelValidator->isValid(aSelection));
+ std::list<ModelAPI_Validator*> aValidators;
+ aFactory->validators(aId.toStdString(), aValidators);
+ std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
+ for(; aValidator != aValidators.end(); aValidator++) {
+ if (*aValidator) {
+ const ModuleBase_SelectionValidator* aSelValidator =
+ dynamic_cast<const ModuleBase_SelectionValidator*>(*aValidator);
+ if (aSelValidator) {
+ aAction->setEnabled(aSelValidator->isValid(aSelection));
+ }
}
}
}
{
PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
-
- aFactory->registerValidator("ModuleBase_ResulPointValidator", new ModuleBase_ResulPointValidator);
- aFactory->registerValidator("ModuleBase_ResulLineValidator", new ModuleBase_ResulLineValidator);
- aFactory->registerValidator("ModuleBase_ResulArcValidator", new ModuleBase_ResulArcValidator);
}
{
for (int i = 0; i < theDoc->size(theGroup); i++)
myDisplayer->display(theDoc->object(theGroup, i), false);
-}
+}