#include "NewGeom_DataModel.h"
+#include "NewGeom_Module.h"
-NewGeom_DataModel::NewGeom_DataModel(CAM_Module* theModule)
- : LightApp_DataModel(theModule)
+NewGeom_DataModel::NewGeom_DataModel(NewGeom_Module* theModule)
+ : LightApp_DataModel(theModule), myModule(theModule)
{
}
#include "NewGeom.h"
#include <LightApp_DataModel.h>
+class NewGeom_Module;
+
class NewGeom_EXPORT NewGeom_DataModel : public LightApp_DataModel
{
Q_OBJECT
public:
- NewGeom_DataModel(CAM_Module* theModule);
+ NewGeom_DataModel(NewGeom_Module* theModule);
virtual ~NewGeom_DataModel();
virtual bool open(const QString& thePath, CAM_Study* theStudy, QStringList theFiles);
private:
QString myStudyPath;
-
+ NewGeom_Module* myModule;
};
#endif
virtual void createPreferences();
virtual void preferencesChanged(const QString& theSection, const QString& theParam);
+ XGUI_Workshop* workshop() const { return myWorkshop; }
+
public slots:
virtual bool activateModule(SUIT_Study* theStudy);
virtual bool deactivateModule(SUIT_Study* theStudy);
#include <QString>
#include <SUIT_PreferenceMgr.h>
+/**
+* An interface class which provides incapsulation of SUIT_PreferenceMgr class instance
+* It is used in order to make common interface to Preference manager in Salome
+* and this application
+*/
class XGUI_IPrefMgr
{
public:
+ /**
+ * Add preference item into preference dialog box
+ * \param theLbl - label of the item
+ * \param pId - id of container item
+ * \param theType - type of the item
+ * \param theSection - resouce section name
+ * \param theName - name of the resource
+ * Returns Id of the ctreated item
+ */
virtual int addPreference(const QString& theLbl, int pId,
SUIT_PreferenceMgr::PrefItemType theType,
const QString& theSection, const QString& theName ) = 0;
+ /// Returns incapsulated preference manager
virtual SUIT_PreferenceMgr* prefMgr() const = 0;
};
#include <QTimer>
#include <QCloseEvent>
+
XGUI_MainWindow::XGUI_MainWindow(QWidget* parent)
: QMainWindow(parent),
- myPythonConsole(0)
+ myPythonConsole(0), myIsModified(false)
{
- setWindowTitle(tr("New Geom"));
+ myTitle = tr("New Geom");
+ updateTitle();
createMainMenu();
QMdiArea* aMdiArea = new QMdiArea(this);
aMdiArea->setContextMenuPolicy(Qt::ActionsContextMenu);
addDockWidget(Qt::TopDockWidgetArea, aMenuDock);
}
+
+void XGUI_MainWindow::updateTitle()
+{
+ QString aTitle = myTitle;
+ if (!myCurrentDir.isNull())
+ aTitle += ":" + myCurrentDir;
+ if (myIsModified)
+ aTitle += "*";
+ setWindowTitle(aTitle);
+}
+
+void XGUI_MainWindow::setCurrentDir(const QString& theDir, bool toUpdate)
+{
+ myCurrentDir = theDir;
+ if (toUpdate)
+ updateTitle();
+}
+
+void XGUI_MainWindow::setModifiedState(bool isModified, bool toUpdate)
+{
+ myIsModified = isModified;
+ if (toUpdate)
+ updateTitle();
+}
+
CloseEventWatcher::CloseEventWatcher(QObject* theParent)
: QObject(theParent)
{
void createSubWindow();
+ /// Add name of current directory into title of desktop window
+ void setCurrentDir(const QString& theDir, bool toUpdate = true);
+
+ /// Add asterisk to a title of the window
+ void setModifiedState(bool isModified, bool toUpdate = true);
+
+ /// Returns current state of modification
+ bool isModifiedState() const { return myIsModified; }
+
+ void updateTitle();
+
private slots:
void cascadeWindows();
void onViewCreated(XGUI_ViewWindow* theWindow);
XGUI_MainMenu* myMenuBar;
XGUI_Viewer* myViewer;
+ QString myTitle;
+ QString myCurrentDir;
+ bool myIsModified;
+
PyConsole_EnhConsole* myPythonConsole;
};
virtual void accept();
private:
- void createEditors();
- void createViewerPage(int thePageId);
- void createMenuPage(int thePageId);
- //void createCustomPage(int thePageId);
-
- void updateCustomProps();
+ /// Create editors for aplication properties
+ void createEditors();
+
+ /// Create a viewer page in dialog box
+ void createViewerPage(int thePageId);
+
+ /// Create menu properties page in the dialog box
+ void createMenuPage(int thePageId);
XGUI_PreferencesMgr* myPreferences;
bool myIsChanged;
if (!aFeatureMsg->isInternal()) {
addFeature(aFeatureMsg);
}
- return;
}
// Process creation of Part
- if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
+ else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
const ModelAPI_ObjectUpdatedMessage* aUpdMsg =
dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
onFeatureCreatedMsg(aUpdMsg);
mySalomeConnector->createPreferences();
myUpdatePrefs = false;
}
- return;
}
- if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_PLUGIN_LOADED)) {
+ else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_PLUGIN_LOADED)) {
myUpdatePrefs = true;
- return;
}
// Redisplay feature
- if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)) {
+ else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)) {
const ModelAPI_ObjectUpdatedMessage* aUpdMsg =
dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
onFeatureRedisplayMsg(aUpdMsg);
- return;
}
//Update property panel on corresponding message. If there is no current operation (no
//property panel), or received message has different feature to the current - do nothing.
- if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) {
+ else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) {
const ModelAPI_ObjectUpdatedMessage* anUpdateMsg =
dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
onFeatureUpdatedMsg(anUpdateMsg);
- return;
}
- if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) {
+ else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) {
const ModelAPI_ObjectDeletedMessage* aDelMsg =
dynamic_cast<const ModelAPI_ObjectDeletedMessage*>(theMessage);
onObjectDeletedMsg(aDelMsg);
- return;
}
- if (theMessage->eventID() == Events_LongOp::eventID()) {
+ else if (theMessage->eventID() == Events_LongOp::eventID()) {
if (Events_LongOp::isPerformed())
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
//QTimer::singleShot(10, this, SLOT(onStartWaiting()));
else
QApplication::restoreOverrideCursor();
- return;
}
//An operation passed by message. Start it, process and commit.
- if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OPERATION_LAUNCHED)) {
+ else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OPERATION_LAUNCHED)) {
const Config_PointerMessage* aPartSetMsg =
dynamic_cast<const Config_PointerMessage*>(theMessage);
//myPropertyPanel->cleanContent();
updateCommandStatus();
}
}
- return;
+ } else {
+ //Show error dialog if error message received.
+ const Events_Error* anAppError = dynamic_cast<const Events_Error*>(theMessage);
+ if (anAppError) {
+ emit errorOccurred(QString::fromLatin1(anAppError->description()));
+ }
}
- //Show error dialog if error message received.
- const Events_Error* anAppError = dynamic_cast<const Events_Error*>(theMessage);
- if (anAppError) {
- emit errorOccurred(QString::fromLatin1(anAppError->description()));
+ if (!isSalomeMode()) {
+ PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+ DocumentPtr aDoc = aMgr->rootDocument();
+ if (aDoc->isModified() != myMainWindow->isModifiedState())
+ myMainWindow->setModifiedState(aDoc->isModified());
}
}
/*
* Saves document with given name.
*/
-void XGUI_Workshop::saveDocument(QString theName)
+void XGUI_Workshop::saveDocument(const QString& theName, std::list<std::string>& theFileNames)
{
QApplication::restoreOverrideCursor();
PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
DocumentPtr aDoc = aMgr->rootDocument();
- std::list<std::string> aFileNames;
- aDoc->save(theName.toLatin1().constData(), aFileNames);
+ aDoc->save(theName.toLatin1().constData(), theFileNames);
QApplication::restoreOverrideCursor();
}
if (myCurrentDir.isEmpty()) {
return onSaveAs();
}
- saveDocument(myCurrentDir);
+ std::list<std::string> aFiles;
+ saveDocument(myCurrentDir, aFiles);
updateCommandStatus();
+ myMainWindow->setModifiedState(false);
return true;
}
}
}
myCurrentDir = aTempDir;
+ if (!isSalomeMode()) {
+ myMainWindow->setCurrentDir(myCurrentDir, false);
+ myMainWindow->setModifiedState(false);
+ }
return onSave();
}
return myModule;
}
+ /// Returns current directory whic contains data files
+ QString currentDataDir() const { return myCurrentDir; }
+
+ /// Returns current directory whic contains data files
+ void setCurrentDataDir(const QString& theDir) { myCurrentDir = theDir; }
+
+ /**
+ * Save the current document into a directory
+ * \param theName - path to the directory
+ * \param theFileNames - returned file names created in this directory
+ */
+ void saveDocument(const QString& theName, std::list<std::string>& theFileNames);
+
signals:
void salomeViewerSelection();
void errorOccurred(const QString&);
//Event-loop processing methods:
void addFeature(const Config_FeatureMessage*);
void connectWithOperation(ModuleBase_Operation* theOperation);
- void saveDocument(QString theName);
void onFeatureUpdatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg);
void onFeatureCreatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg);