#include "NewGeom_DataModel.h"
#include "NewGeom_Module.h"
+#include <XGUI_Workshop.h>
+
+#include <LightApp_Study.h>
+#include <CAM_Application.h>
+#include <SUIT_Tools.h>
+
+#include <QFile>
+
+
NewGeom_DataModel::NewGeom_DataModel(NewGeom_Module* theModule)
: LightApp_DataModel(theModule), myModule(theModule)
{
bool NewGeom_DataModel::open(const QString& thePath, CAM_Study* theStudy, QStringList theFiles)
{
+ LightApp_DataModel::open( thePath, theStudy, theFiles );
+ if (theFiles.size() == 0)
+ return false;
+
+ QString aFile = theFiles.first();
+
+ SessionPtr aMgr = ModelAPI_Session::get();
+ aMgr->load(qPrintable(aFile));
+ myModule->setIsOpened(true);
+ myStudyPath = aFile;
return true;
}
bool NewGeom_DataModel::save(QStringList& theFiles)
{
+ LightApp_DataModel::save( theFiles );
+ XGUI_Workshop* aWorkShop = myModule->workshop();
+ std::list<std::string> aFileNames;
+
+ LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( myModule->application()->activeStudy() );
+ std::string aTmpDir = aStudy->GetTmpDir(qPrintable(myStudyPath), true );
+ theFiles.append(QString(aTmpDir.c_str()));
+
+ aWorkShop->saveDocument(QString(aTmpDir.c_str()), aFileNames);
+ std::list<std::string>::iterator aIt;
+ for (aIt = aFileNames.begin(); aIt != aFileNames.end(); ++aIt) {
+ QString aName((*aIt).c_str());
+ aName.replace(QChar('\\'), QChar('/'));
+ int aN = aName.lastIndexOf('/');
+ theFiles.append(aName.right(aName.length() - aN - 1));
+ }
return true;
}
bool NewGeom_DataModel::isModified() const
{
- return false;
+ SessionPtr aMgr = ModelAPI_Session::get();
+ return aMgr->isModified();
}
bool NewGeom_DataModel::isSaved() const
{
- return true;
+ return !isModified();
}
void NewGeom_DataModel::update(LightApp_DataObject* theObj, LightApp_Study* theStudy)
#include <XGUI_PropertyPanel.h>
#include <XGUI_ContextMenuMgr.h>
#include <XGUI_Preferences.h>
+#include <XGUI_ObjectsBrowser.h>
#include <LightApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <QDockWidget>
#include <QAction>
+#include <QTimer>
+
extern "C" {
NewGeom_EXPORT CAM_Module* createModule()
//******************************************************
NewGeom_Module::NewGeom_Module()
: LightApp_Module("NewGeom"),
- mySelector(0)
+ mySelector(0), myIsOpened(0)
{
myWorkshop = new XGUI_Workshop(this);
myProxyViewer = new NewGeom_SalomeViewer(this);
myWorkshop->propertyPanel()->hide();
QtxPopupMgr* aMgr = popupMgr(); // Create popup manager
action(myEraseAll)->setEnabled(false);
+
+ if (myIsOpened) {
+ myWorkshop->objectBrowser()->rebuildDataTree();
+ myWorkshop->updateCommandStatus();
+ myIsOpened = false;
+ QTimer::singleShot(1000, myWorkshop, SLOT(displayAllResults()));
+ }
}
return isDone;
}
XGUI_Workshop* workshop() const { return myWorkshop; }
+ void setIsOpened(bool theOpened) { myIsOpened = theOpened; }
+
public slots:
virtual bool activateModule(SUIT_Study* theStudy);
virtual bool deactivateModule(SUIT_Study* theStudy);
NewGeom_SalomeViewer* myProxyViewer;
QMap<QString, QStringList> myNestedActions;
+
+ bool myIsOpened;
};
#endif
//**********************************************
Handle(AIS_InteractiveContext) NewGeom_SalomeViewer::AISContext() const
{
- return mySelector->viewer()->getAISContext();
+ if (mySelector && mySelector->viewer())
+ return mySelector->viewer()->getAISContext();
+ Handle(AIS_InteractiveContext) aNull;
+ return aNull;
}
//**********************************************
bool isUpdateViewer)
{
Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
if (!anAISIO.IsNull()) {
return;
Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
boost::shared_ptr<GeomAPI_AISObject> anObject = myResult2AISObjectMap[theObject];
if (anObject) {
Handle(AIS_InteractiveObject) anAIS = anObject->impl<Handle(AIS_InteractiveObject)>();
}
if (!aAISIO.IsNull()) {
Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
aContext->Redisplay(aAISIO, isUpdateViewer);
//if (aContext->HasOpenedContext()) {
// aContext->Load(aAISIO, -1, true/*allow decomposition*/);
const bool isUpdateViewer)
{
Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
// Open local context if there is no one
if (!aContext->HasOpenedContext()) {
aContext->ClearCurrents(false);
{
if (isVisible(theObject)) {
Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap[theObject];
Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
{
if (isVisible(theObject)) {
Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap[theObject];
Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
const bool isUpdateViewer)
{
Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
Handle(AIS_Shape) anAIS;
QList<ObjectPtr>::const_iterator anIt = theResults.begin(), aLast = theResults.end();
}
void XGUI_Displayer::eraseAll(const bool isUpdateViewer)
- {
- Handle(AIS_InteractiveContext) ic = AISContext();
+{
+ Handle(AIS_InteractiveContext) ic = AISContext();
+ if (ic.IsNull())
+ return;
ResultToAISMap::iterator aIt;
for (aIt = myResult2AISObjectMap.begin(); aIt != myResult2AISObjectMap.end(); aIt++) {
void XGUI_Displayer::eraseDeletedResults(const bool isUpdateViewer)
{
Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
ResultToAISMap::const_iterator aFIt = myResult2AISObjectMap.begin(), aFLast =
myResult2AISObjectMap.end();
{
QString aTitle = myTitle;
if (!myCurrentDir.isNull())
- aTitle += ":" + myCurrentDir;
+ aTitle += " - " + myCurrentDir;
if (myIsModified)
aTitle += "*";
setWindowTitle(aTitle);
void activateLastPart();
+ /// Display all results of the current document
+ void displayAllResults();
+
protected:
//Event-loop processing methods:
void addFeature(const Config_FeatureMessage*);
QList<QAction*> getModuleCommands() const;
- void displayAllResults();
void displayDocumentResults(DocumentPtr theDoc);
void displayGroupResults(DocumentPtr theDoc, std::string theGroup);