#include <QtxSearchTool.h>
#include <QtxWorkstack.h>
#include <QtxMap.h>
-#include <QtxWebBrowser.h>
+#include <QtxWebBrowser.h>
#include <LogWindow.h>
#include <QTimer>
#include <QHeaderView>
#include <QTreeView>
+#include <QMimeData>
#include <QShortcut>
#include <utilities.h>
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
-
+
QtxWebBrowser::setData("browser:icon", aResMgr->loadPixmap( "LightApp", tr( "BROWSER_ICON" ) ) );
QtxWebBrowser::setData("browser:title", tr( "BROWSER_TITLE" ) );
QtxWebBrowser::setData("toolbar:title", tr( "BROWSER_TOOLBAR_TITLE" ) );
if ( QFile::exists( indexFile ) )
helpData.insert( tr( "%1 module Users's Guide" ).arg( aModule ), indexFile );
}
-
+
IMapConstIterator<QString, QString > fileIt;
for ( fileIt = helpData.begin(); fileIt != helpData.end(); fileIt++ ) {
QString helpFileName = fileIt.key();
a->setData( fileIt.value() );
if ( !helpSubMenu.isEmpty() ){
int helpSubMenuId = createMenu( helpSubMenu, helpMenu, -1, 0 );
- createMenu( a, helpSubMenuId, -1 );
+ createMenu( a, helpSubMenuId, -1 );
}
else
createMenu( a, helpMenu, -1, 0 );
static QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), 0 );
connect( mru, SIGNAL( activated( const QString& ) ), this, SLOT( onMRUActivated( const QString& ) ) );
registerAction( MRUId, mru );
-
+
// default icon for neutral point ('SALOME' module)
QPixmap defIcon = resMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
if ( defIcon.isNull() )
defIcon = QPixmap( imageEmptyIcon );
-
+
//! default icon for any module
QPixmap modIcon = resMgr->loadPixmap( "LightApp", tr( "APP_MODULE_ICO" ), false );
if ( modIcon.isNull() )
modIcon = QPixmap( imageEmptyIcon );
-
+
QStringList modList;
modules( modList, false );
{
if ( !isLibExists( *it ) )
continue;
-
+
QString modName = moduleName( *it );
if ( !isModuleAccessible( *it ) )
{
icon = modIcon;
INFOS ( "****************************************************************" << std::endl
- << "* Icon for " << (*it).toLatin1().constData()
+ << "* Icon for " << (*it).toLatin1().constData()
<< " not found. Using the default one." << std::endl
<< "****************************************************************" << std::endl );
}
moduleAction->insertModule( *it, icon );
}
- connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ),
+ connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ),
this, SLOT( onModuleActivation( const QString& ) ) );
registerAction( ModulesListId, moduleAction );
}
0, desk, false, this, SLOT( onStylePreferences() ) );
createAction( FullScreenId, tr( "TOT_FULLSCREEN" ), QIcon(), tr( "MEN_DESK_FULLSCREEN" ), tr( "PRP_FULLSCREEN" ),
- Qt::Key_F11, desk, false, this, SLOT( onFullScreen() ) );
+ Qt::Key_F11, desk, false, this, SLOT( onFullScreen() ) );
int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1 );
bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
if( useExtBrowser ) {
- if ( !anApp.isEmpty() )
- {
- RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
- rs->start();
- }
- else
- {
- if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
- SUIT_MessageBox::Yes | SUIT_MessageBox::No,
- SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
-
- showPreferences( tr( "PREF_APP" ) );
- }
- } else {
+ if ( !anApp.isEmpty() ) {
+ RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
+ rs->start();
+ }
+ else {
+ if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
+ SUIT_MessageBox::Yes | SUIT_MessageBox::No,
+ SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
+
+ showPreferences( tr( "PREF_APP" ) );
+ }
+ }
+ else {
QtxWebBrowser::loadUrl(getFile() + helpFile);
}
}
#endif
bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
-
- if(useExtBrowser) {
+
+ if(useExtBrowser) {
QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
-
- if ( !anApp.isEmpty() )
- {
- RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile, theContext );
- rs->start();
- }
- else
- {
- if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
- SUIT_MessageBox::Yes | SUIT_MessageBox::No,
- SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
- showPreferences( tr( "PREF_APP" ) );
- }
- } else {
+
+ if ( !anApp.isEmpty() ) {
+ RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile, theContext );
+ rs->start();
+ }
+ else {
+ if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
+ SUIT_MessageBox::Yes | SUIT_MessageBox::No,
+ SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
+ showPreferences( tr( "PREF_APP" ) );
+ }
+ }
+ else {
QtxWebBrowser::loadUrl(getFile() + helpFile, theContext );
}
}
#else
vm = new OCCViewer_Viewer( true );
#endif
- vm->setBackgroundColor( OCCViewer_ViewFrame::TOP_LEFT,
+ vm->setBackgroundColor( OCCViewer_ViewFrame::TOP_LEFT,
resMgr->colorValue( "OCCViewer", "xz_background", vm->backgroundColor() ) );
- vm->setBackgroundColor( OCCViewer_ViewFrame::TOP_RIGHT,
- resMgr->colorValue( "OCCViewer", "yz_background", vm->backgroundColor() ) );
-
+ vm->setBackgroundColor( OCCViewer_ViewFrame::TOP_RIGHT,
+ resMgr->colorValue( "OCCViewer", "yz_background", vm->backgroundColor() ) );
+
vm->setBackgroundColor( OCCViewer_ViewFrame::BOTTOM_LEFT,
resMgr->colorValue( "OCCViewer", "xy_background", vm->backgroundColor() ) );
- vm->setBackgroundColor( OCCViewer_ViewFrame::BOTTOM_RIGHT,
- resMgr->colorValue( "OCCViewer", "background", vm->backgroundColor() ) );
-
- vm->setTrihedronSize( resMgr->doubleValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ),
- resMgr->booleanValue( "OCCViewer", "relative_size", vm->trihedronRelative() ));
+ vm->setBackgroundColor( OCCViewer_ViewFrame::BOTTOM_RIGHT,
+ resMgr->colorValue( "OCCViewer", "background", vm->backgroundColor() ) );
+
+ vm->setTrihedronSize( resMgr->doubleValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ),
+ resMgr->booleanValue( "OCCViewer", "relative_size", vm->trihedronRelative() ));
int u( 1 ), v( 1 );
vm->isos( u, v );
u = resMgr->integerValue( "OCCViewer", "iso_number_u", u );
{
SUIT_ResourceMgr* resMgr = resourceMgr();
- SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
- desktop(),
- new LightApp_WgViewModel( vmType, w ) );
+ SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
+ desktop(),
+ new LightApp_WgViewModel( vmType, w ) );
vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
-
+
addViewManager( vm );
SUIT_ViewWindow* vw = vm->createViewWindow();
if ( vw && desktop() ) {
updateObjectBrowser( true );
}
+/*!Private SLOT. Support drag-and-drop operation.*/
+void LightApp_Application::onDropped (const QMimeData *data, Qt::DropAction action,
+ int row, int column, const QModelIndex& parent)
+{
+ if (action == Qt::IgnoreAction)
+ return;
+
+ if (!data->hasFormat("application/vnd.text.list"))
+ return;
+
+ if (column > 0)
+ return;
+
+ if (!parent.isValid())
+ // dropping into the top level of the model is not allowed
+ return;
+
+ SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>(objectBrowser()->model());
+
+ SUIT_DataObject* obj = treeModel->object(parent);
+ if (!obj)
+ return;
+
+ LightApp_DataObject* parentObj = dynamic_cast<LightApp_DataObject*>(obj);
+ if (!parentObj)
+ return;
+
+ // decode mime data
+ QByteArray encodedData = data->data("application/vnd.text.list");
+ QDataStream stream (&encodedData, QIODevice::ReadOnly);
+ QStringList newItems;
+
+ while (!stream.atEnd()) {
+ QString text;
+ stream >> text;
+ if (!text.isEmpty())
+ newItems << text;
+ }
+
+ DataObjectList listObjs;
+ foreach (QString text, newItems) {
+ SUIT_DataObject* anObji = findObject(text);
+ if (anObji)
+ listObjs.append(anObji);
+ }
+
+ // tmp: clear selection to avoid problem with persistent data model indexes
+ //mySelMgr->clearSelected();
+
+ LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(parentObj->module());
+ if (aModule)
+ aModule->dropObjects(listObjs, action, parentObj, row);
+}
+
/*!Private SLOT. On preferences.*/
void LightApp_Application::onPreferences()
{
treeModel->registerColumn( 0, EntryCol, LightApp_DataObject::EntryId );
treeModel->setAppropriate( EntryCol, Qtx::Toggled );
+ // Mantis issue 0020136: Drag&Drop in OB
+ SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
+ connect( proxyModel, SIGNAL(dropped(const QMimeData*, Qt::DropAction, int, int, const QModelIndex&)),
+ this, SLOT(onDropped(const QMimeData*, Qt::DropAction, int, int, const QModelIndex&)) );
+
// temporary commented
/*
OB_ListView* ob_list = dynamic_cast<OB_ListView*>( const_cast<QListView*>( ob->listView() ) );
pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" );
- int autoSaveInterval = pref->addPreference( tr( "PREF_AUTO_SAVE" ), studyGroup,
+ int autoSaveInterval = pref->addPreference( tr( "PREF_AUTO_SAVE" ), studyGroup,
LightApp_Preferences::IntSpin, "Study", "auto_save_interval" );
pref->setItemProperty( "min", 0, autoSaveInterval );
pref->setItemProperty( "max", 1440, autoSaveInterval );
int genGroup = pref->addPreference( tr( "PREF_GROUP_COMMON" ), viewTab );
pref->addPreference( tr( "PREF_DROP_DOWN_BUTTONS" ), genGroup,
- LightApp_Preferences::Bool, "viewers", "drop_down_buttons" );
-
+ LightApp_Preferences::Bool, "viewers", "drop_down_buttons" );
+
int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), viewTab );
int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), viewTab );
LightApp_Preferences::DblSpin, "OCCViewer", "trihedron_size" );
pref->setItemProperty( "min", 1.0E-06, occTS );
pref->setItemProperty( "max", 1000, occTS );
-
+
pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), occGroup, LightApp_Preferences::Bool, "OCCViewer", "relative_size" );
int occStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), occGroup,
if ( !resMgr )
return;
- if ( sec == "viewers" && param == "drop_down_buttons" )
+ if ( sec == "viewers" && param == "drop_down_buttons" )
{
ViewManagerList vmlist = viewManagers();
foreach( SUIT_ViewManager* vm, vmlist )
{
QVector<SUIT_ViewWindow*> vwlist = vm->getViews();
foreach( SUIT_ViewWindow* vw, vwlist )
- if ( vw ) vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
+ if ( vw ) vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
}
}
}
if ( sec == "ExternalBrowser" && param == "use_external_browser" ) {
- if ( resMgr->booleanValue("ExternalBrowser", "use_external_browser", false ) )
+ if ( resMgr->booleanValue("ExternalBrowser", "use_external_browser", false ) )
{
- if(QtxWebBrowser::webBrowser())
- QtxWebBrowser::webBrowser()->close();
+ if(QtxWebBrowser::webBrowser())
+ QtxWebBrowser::webBrowser()->close();
}
}
desktop()->setDockOptions( dopts );
desktop()->setOpaqueResize( opaqueResize );
if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
- dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
+ dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
}
}
*/
void LightApp_Application::contextMenuPopup( const QString& type, QMenu* thePopup, QString& title )
{
- //Add "Rename" item
+ //Add "Rename" item
LightApp_SelectionMgr* selMgr = LightApp_Application::selectionMgr();
bool cacheIsOn = selMgr->isSelectionCacheEnabled();
selMgr->setSelectionCacheEnabled( true );
if ( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) )
a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) );
}
-
+
if ( selMgr && ob ) {
SALOME_ListIO selected;
selMgr->selectedObjects( selected );
Handle(SALOME_InteractiveObject) anIObject = selected.First();
SUIT_DataObject* obj = findObject(anIObject->getEntry());
if(obj && obj->renameAllowed()) {
- QAction* a = new QAction(tr("MEN_RENAME_OBJ"), thePopup);
- connect( a, SIGNAL( triggered(bool) ), ob, SLOT( onStartEditing() ) );
- if ( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) )
- a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) );
-
- QList<QAction*> acts = thePopup->actions();
- QAction* firstAction = acts.count() > 0 ? acts.first() : 0;
- thePopup->insertAction(firstAction,a);
+ QAction* a = new QAction(tr("MEN_RENAME_OBJ"), thePopup);
+ connect( a, SIGNAL( triggered(bool) ), ob, SLOT( onStartEditing() ) );
+ if ( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) )
+ a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) );
+
+ QList<QAction*> acts = thePopup->actions();
+ QAction* firstAction = acts.count() > 0 ? acts.first() : 0;
+ thePopup->insertAction(firstAction,a);
}
}
}
if ( objectBrowser() )
objectBrowser()->updateTree();
-
+
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
if ( aResMgr && activeStudy() ) {
int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
if (aStudy )
aStudy->removeViewMgr(vm->getGlobalId());
-
+
STD_Application::removeViewManager( vm );
delete vm;
}
}
/*!
- Copy of current selection
+ Copy of current selection
*/
void LightApp_Application::onCopy()
{
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
// File: LightApp_Application.h
// Created: 6/20/2005 18:39:25 PM
// Author: OCC team
-//
+
#ifndef LIGHTAPP_APPLICATION_H
#define LIGHTAPP_APPLICATION_H
CloseId, CloseAllId, GroupAllId,
PreferencesId, MRUId, ModulesListId,
NewGLViewId, NewPlot2dId, NewOCCViewId, NewVTKViewId, NewQxGraphViewId,
- NewQxSceneViewId = NewQxGraphViewId, StyleId, FullScreenId,
+ NewQxSceneViewId = NewQxGraphViewId, StyleId, FullScreenId,
UserID };
protected:
private slots:
void onSelection();
void onRefresh();
+ void onDropped( const QMimeData*, Qt::DropAction,
+ int, int, const QModelIndex& );
void onPreferences();
void onPreferenceChanged( QString&, QString&, QString& );
void onRenameWindow();
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
// File : LightApp_DataObject.cxx
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
-//
+
#include "LightApp_DataObject.h"
#include "LightApp_Study.h"
#include "LightApp_DataModel.h"
#include "LightApp_Application.h"
#include <CAM_Module.h>
-#include <SUIT_DataObjectKey.h>
+#include <SUIT_DataObjectKey.h>
#include <QVariant>
+#include <iostream>
+
/*!
\class LightApp_DataObject::Key
\brief Represents unique data object key for the LightApp_DataObject
*/
/*!
- \brief Constructor.
+ \brief Constructor.
\param parent parent data object
*/
LightApp_DataObject::LightApp_DataObject( SUIT_DataObject* parent )
-: CAM_DataObject( parent ),
- myCompObject( 0 ),
+: CAM_DataObject( parent ),
+ myCompObject( 0 ),
myCompDataType( "" )
{
}
*/
QVariant LightApp_DataObject::customData(Qtx::CustomDataType type) {
switch(type) {
- case Qtx::IdType:
+ case Qtx::IdType:
return EntryId;
break;
default:
return r && r->study() && componentDataType() != r->study()->getVisualComponentName();
}
+/*!
+ \brief Check if the object is dragable.
+
+ This method can be re-implemented in the subclasses.
+
+ \return \c true if it is possible to drag this object
+*/
+bool LightApp_DataObject::isDragable() const
+{
+ LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(module());
+ if (aModule) {
+ return aModule->isDragable(this);
+ }
+ return false;
+}
+
+/*!
+ \brief Check if the drop operation fo this object is possible.
+
+ This method can be re-implemented in the subclasses.
+
+ \param obj object being dropped
+ \return \c true if it is possible to drop an object \c obj
+ to this object
+*/
+bool LightApp_DataObject::isDropAccepted()
+{
+ LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(module());
+ if (aModule) {
+ return aModule->isDropAccepted(this);
+ }
+ return false;
+}
/*!
\brief Check if this object is can't be renamed in place
LightApp_RootObject* r = dynamic_cast<LightApp_RootObject*>( root() );
if(r && r->study())
app = dynamic_cast<LightApp_Application*>(r->study()->application());
-
+
return ( m && m->renameAllowed( entry() ) ) ||
( app && app->renameAllowed( entry() ) );
}
{
LightApp_Module* m = dynamic_cast<LightApp_Module*>( module() );
LightApp_RootObject* r = dynamic_cast<LightApp_RootObject*>( root() );
- LightApp_Application* app = (r && r->study()) ? dynamic_cast<LightApp_Application*>(r->study()->application()) : 0;
+ LightApp_Application* app =
+ (r && r->study()) ? dynamic_cast<LightApp_Application*>(r->study()->application()) : 0;
return ( m && m->renameObject( entry(), name ) ) ||
( app && app->renameObject( entry(), name ) );
}
else {
// both not integer ID
- int r = QString::localeAwareCompare( idsLeft[i], idsRight[i] );
+ int r = QString::localeAwareCompare( idsLeft[i], idsRight[i] );
if ( !calculated && r != 0 ) {
result = r < 0;
calculated = true;
}
}
// we should reach this if the entries are exactly equal
- return result;
+ return result;
}
return QString::localeAwareCompare( leftStr, rightStr ) < 0;
}
/*!
\brief Insert new child object to the children list at specified position.
-
+
Adds component in the study for this module object if it is not done yet.
-
+
\param obj object to be inserted
\param pos position at which data object should be inserted
*/
*/
LightApp_RootObject::LightApp_RootObject( LightApp_Study* study )
: CAM_DataObject( 0 ),
- LightApp_DataObject( 0 ),
- myStudy( study )
+ LightApp_DataObject( 0 ),
+ myStudy( study )
{
}
\param study pointer to the study
*/
void LightApp_RootObject::setStudy( LightApp_Study* study )
-{
- myStudy = study;
+{
+ myStudy = study;
}
/*
\return pointer to the study
*/
LightApp_Study* LightApp_RootObject::study() const
-{
- return myStudy;
-}
+{
+ return myStudy;
+}
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
// File : LightApp_DataObject.h
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
-//
+
#ifndef LIGHTAPP_DATAOBJECT_H
#define LIGHTAPP_DATAOBJECT_H
public:
//! Column id
- enum {
+ enum {
EntryId = VisibilityId + 1 //!< entry column
};
virtual QVariant customData(Qtx::CustomDataType type);
virtual bool isVisible() const;
+ virtual bool isDragable() const;
+ virtual bool isDropAccepted();
virtual bool renameAllowed( const int = NameId ) const;
virtual bool setName( const QString& );
LightApp_RootObject( LightApp_Study* );
virtual ~LightApp_RootObject();
-
+
void setStudy( LightApp_Study* );
LightApp_Study* study() const;
-
+
private:
LightApp_Study* myStudy;
};
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
// File: LightApp_Module.cxx
// Created: 6/20/2005 16:30:56 AM
// Author: OCC team
-//
+
#include "LightApp_Module.h"
#include "CAM_Application.h"
#include <QString>
#include <QStringList>
+#include <iostream>
/*!Constructor.*/
LightApp_Module::LightApp_Module( const QString& name )
{
}
+/*!
+ virtual method
+ \return true if module allows dragging the given object
+*/
+bool LightApp_Module::isDragable(const SUIT_DataObject* /*what*/) const
+{
+ return false;
+}
+
+/*!
+ virtual method
+ \return true if module allows dropping one or more objects (currently selected) on the object \c where
+*/
+bool LightApp_Module::isDropAccepted(const SUIT_DataObject* /*where*/) const
+{
+ return false;
+}
+
+/*!
+ virtual method
+*/
+void LightApp_Module::dropObjects(const DataObjectList& what, Qt::DropAction action,
+ const SUIT_DataObject* parent, const int row)
+{
+}
+
/*!
\brief Return \c true if object can be renamed
*/
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
// File: LightApp_Module.h
// Created: 6/20/2005 16:25:06 AM
// Author: OCC team
-//
+
#ifndef LIGHTAPP_MODULE_H
#define LIGHTAPP_MODULE_H
#include "LightApp_Preferences.h"
#include <CAM_Module.h>
+#include <SUIT_DataObject.h>
+
class LightApp_Application;
class LightApp_Selection;
class LightApp_Operation;
class LightApp_SelectionMgr;
class SUIT_Study;
-class SUIT_DataObject;
+//class SUIT_DataObject;
class SUIT_Operation;
class SUIT_ViewManager;
class CAM_Application;
virtual void update( const int );
// Update viewer or/and object browser etc. in accordance with update flags
- // ( see SalomeApp_UpdateFlags enumeration ). Derived modules can redefine this method
+ // (see SalomeApp_UpdateFlags enumeration). Derived modules can redefine this method
// for their own purposes
virtual void updateObjBrowser( bool = true, SUIT_DataObject* = 0 );
- // Update object bropwser ( for updating model or whole object browser use update() method
- // can be used )
+ // Update object browser (for updating model or whole object browser use update() method)
virtual void selectionChanged();
virtual void preferencesChanged( const QString&, const QString& );
virtual bool canCopy() const;
virtual bool canPaste() const;
+ virtual bool isDragable(const SUIT_DataObject* what) const;
+ virtual bool isDropAccepted(const SUIT_DataObject* where) const;
+ virtual void dropObjects(const DataObjectList& what, Qt::DropAction action,
+ const SUIT_DataObject* parent, const int row);
virtual void copy();
virtual void paste();
virtual bool renameAllowed( const QString& ) const;
virtual bool reusableOperation( const int id );
int addPreference( const QString& label );
- int addPreference( const QString& label, const int pId, const int = LightApp_Preferences::Auto,
+ int addPreference( const QString& label, const int pId,
+ const int type = LightApp_Preferences::Auto,
const QString& section = QString(),
const QString& param = QString() );
QVariant preferenceProperty( const int, const QString& ) const;
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
// File : OB_Browser.cxx
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
-//
+
#include "OB_Browser.h"
//#include "OB_Filter.h"
myView->setSelectionMode( QAbstractItemView::ExtendedSelection );
myView->setAllColumnsShowFocus( true );
+ // Mantis issue 0020136: Drag&Drop in OB
+ myView->setDragEnabled(TRUE);
+ myView->setAcceptDrops(TRUE);
+ myView->setDropIndicatorShown(TRUE);
+ myView->setDragDropMode(QAbstractItemView::DragDrop);
+ //myView->setDragDropMode(QAbstractItemView::InternalMove);
+
mySearchTool = new QtxSearchTool( this, myView );
mySearchTool->setFrameStyle( QFrame::NoFrame | QFrame::Plain );
mySearchTool->setActivators( QtxSearchTool::StandardKey | QtxSearchTool::SlashKey );
connect( myView, SIGNAL( selectionChanged() ),
this, SIGNAL( selectionChanged() ) );
-
}
/*!
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
// File : OB_Browser.h
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
-//
+
#ifndef OB_BROWSER_H
#define OB_BROWSER_H
QtxSearchTool* searchTool() const;
bool isSearchToolEnabled() const;
void setSearchToolEnabled( const bool );
-
+
int autoOpenLevel() const;
void setAutoOpenLevel( const int );
void openLevels( const int = -1 );
unsigned long getModifiedTime() const;
void setModified();
-
+
// san - moved to SUIT_TreeModel
//OB_Updater* getUpdater() const;
//virtual void setUpdater( OB_Updater* theUpdate = 0 );
private slots:
void onExpandAll();
void onCollapseAll();
- //void onDestroyed( SUIT_DataObject* );
- //void onDoubleClicked ( QListViewItem* );
- //void onDropped( QPtrList<QListViewItem>, QListViewItem*, int );
-
+ //void onDestroyed( SUIT_DataObject* );
+ //void onDoubleClicked ( QListViewItem* );
+ //void onDropped( QPtrList<QListViewItem>, QListViewItem*, int );
+
protected:
//void adjustWidth( QListViewItem* );
//virtual void updateText();
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
// File : SUIT_DataObject.cxx
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
-//
#include <QVariant>
}
/*!
- \brief Check if the drop operation fo this object is possible.
+ \brief Check if the drop operation for this object is possible.
This method can be re-implemented in the subclasses.
Default implementation returns \c false (drop operation is not allowed).
- \param obj object being dropped
- \return \c true if it is possible to drop an object \c obj
- to this object
+ \return \c true if it is possible to drop one or more objects (currently selected) to this object
*/
-
-bool SUIT_DataObject::isDropAccepted( SUIT_DataObject* /*obj*/ )
+bool SUIT_DataObject::isDropAccepted()
{
return false;
}
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
// File : SUIT_DataObject.h
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
-//
+
#ifndef SUIT_DATAOBJECT_H
#define SUIT_DATAOBJECT_H
#pragma warning( disable:4251 )
#endif
-class SUIT_EXPORT SUIT_DataObject
+class SUIT_EXPORT SUIT_DataObject
{
public:
class Signal;
//! Color role
- typedef enum {
+ typedef enum {
Text, //!< editor foreground (text) color
Base, //!< editor background color
Foreground, //!< foreground (text) color
//! Column id
enum
- {
+ {
NameId, //!< name column
VisibilityId //!< visibility state column
};
virtual void children( DataObjectList&, const bool = false ) const;
virtual DataObjectList children( const bool = false );
-
+
void appendChild( SUIT_DataObject* );
virtual void insertChild( SUIT_DataObject*, int );
virtual void removeChild( SUIT_DataObject*, const bool = false );
virtual bool expandable() const;
virtual bool isVisible() const;
virtual bool isDragable() const;
- virtual bool isDropAccepted( SUIT_DataObject* obj );
+ virtual bool isDropAccepted();
virtual bool isEnabled() const;
virtual bool isSelectable() const;
virtual bool compare( const QVariant&, const QVariant&, const int = NameId ) const;
virtual SUIT_DataObjectKey* key() const;
- virtual int groupId() const;
+ virtual int groupId() const;
virtual QVariant customData(Qtx::CustomDataType /*type*/);
static Signal* signal();
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
// File: SUIT_TreeModel.cxx
// Author: Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
-//
+
#include "SUIT_Session.h"
#include "SUIT_TreeModel.h"
#include "SUIT_TreeSync.h"
#include "SUIT_DataObject.h"
#include "SUIT_ResourceMgr.h"
-
#include <QApplication>
#include <QHash>
+#include <QMimeData>
SUIT_AbstractModel::SUIT_AbstractModel() : mySearcher( 0 )
{
return QVariant();
SUIT_DataObject* obj = object( index );
+ if ( !obj )
+ return QVariant();
QColor c;
QVariant val;
*/
Qt::ItemFlags SUIT_TreeModel::flags( const QModelIndex& index ) const
{
+ /*
if ( !index.isValid() )
return 0;
if ( obj->renameAllowed( index.column() ) )
f = f | Qt::ItemIsEditable;
}
+
return f;
+ */
+
+ Qt::ItemFlags f = 0;
+
+ if (!index.isValid())
+ //return Qt::ItemIsDropEnabled; // items can be dropped into the top level of the model
+ return f;
+
+ SUIT_DataObject* obj = object(index);
+
+ if (obj) {
+ // data object is enabled
+ if (obj->isEnabled())
+ f = f | Qt::ItemIsEnabled;
+
+ // data object is selectable
+ if (obj->isSelectable())
+ f = f | Qt::ItemIsSelectable;
+
+ // data object is checkable
+ if (obj->isCheckable(index.column()))
+ f = f | Qt::ItemIsUserCheckable;
+
+ // data object can be renamed
+ if (obj->renameAllowed(index.column()))
+ f = f | Qt::ItemIsEditable;
+
+ // data object can be dragged
+ if (obj->isDragable())
+ f = f | Qt::ItemIsDragEnabled;
+
+ // another data object(s) can be dropped on this one
+ if (obj->isDropAccepted())
+ f = f | Qt::ItemIsDropEnabled;
+ }
+
+ return f;
+}
+
+Qt::DropActions SUIT_TreeModel::supportedDropActions() const
+{
+ return Qt::CopyAction | Qt::MoveAction;
+}
+
+//This function is never called
+bool SUIT_TreeModel::removeRows(int row, int count, const QModelIndex &parent)
+{
+ qDebug("Remove");
+ if (parent.isValid())
+ return FALSE;
+
+ beginRemoveRows(parent, row, row + count - 1);
+
+ for (int i = 0; i < count; ++i){
+ //delete m_pAllData->takeAt(row);
+ }
+
+ endRemoveRows();
+ return TRUE;
}
/*!
updateTree( parent );
}
+/*!
+ \brief Drag and Drop support.
+*/
+QStringList SUIT_TreeModel::mimeTypes() const
+{
+ QStringList types;
+ types << "application/vnd.text.list";
+ return types;
+}
+
+/*!
+ \brief Called when the data objects are exported(dragged) from the tree.
+ \param indexes the list of exported objects
+*/
+QMimeData* SUIT_TreeModel::mimeData (const QModelIndexList &indexes) const
+{
+ QMimeData *mimeData = new QMimeData();
+ QByteArray encodedData;
+
+ QDataStream stream (&encodedData, QIODevice::WriteOnly);
+
+ foreach (QModelIndex index, indexes) {
+ if (index.isValid()) {
+ if (index.column() == 0) {
+ SUIT_DataObject* aDObj = object(index);
+ QString anEntry = aDObj->text(SUIT_DataObject::VisibilityId + 1);
+ stream << anEntry;
+ }
+ }
+ }
+
+ mimeData->setData("application/vnd.text.list", encodedData);
+ return mimeData;
+}
+
+bool SUIT_TreeModel::dropMimeData (const QMimeData* data, Qt::DropAction action,
+ int row, int column, const QModelIndex& parent)
+{
+ emit dropped(data, action, row, column, parent);
+
+ return true;
+}
+
/*!
\class SUIT_ProxyModel
- \brief Proxy model which can be used above the SUIT_TreeMovel class
+ \brief Proxy model which can be used above the SUIT_TreeModel class
to enable custom sorting/filtering of the data.
The SUIT_TreeModel class does not support custom sorting/filtering of the data.
SUIT_TreeModel* model = new SUIT_TreeModel( this );
connect( model, SIGNAL( modelUpdated() ), this, SIGNAL( modelUpdated() ) );
connect( model, SIGNAL( clicked(SUIT_DataObject*, int) ), this, SIGNAL(clicked(SUIT_DataObject*, int) ) );
+ connect( model, SIGNAL( dropped(const QMimeData*, Qt::DropAction, int, int, const QModelIndex&) ),
+ //this, SIGNAL( dropped(const QMimeData*, Qt::DropAction, int, int, const QModelIndex&) ));
+ this, SLOT( onDropped(const QMimeData*, Qt::DropAction, int, int, const QModelIndex&) ));
setSourceModel( model );
setDynamicSortFilter( true );
}
SUIT_TreeModel* model = new SUIT_TreeModel( root, this );
connect( model, SIGNAL( modelUpdated() ), this, SIGNAL( modelUpdated() ) );
connect( model, SIGNAL( clicked(SUIT_DataObject*, int) ), this, SIGNAL(clicked(SUIT_DataObject*, int) ) );
+ connect( model, SIGNAL( dropped(const QMimeData*, Qt::DropAction, int, int, const QModelIndex&) ),
+ //this, SIGNAL( dropped(const QMimeData*, Qt::DropAction, int, int, const QModelIndex&) ));
+ this, SLOT( onDropped(const QMimeData*, Qt::DropAction, int, int, const QModelIndex&) ));
setSourceModel( model );
setDynamicSortFilter( true );
}
{
connect( *model, SIGNAL( modelUpdated() ), this, SIGNAL( modelUpdated() ) );
connect( *model, SIGNAL( clicked(SUIT_DataObject*, int) ), this, SIGNAL(clicked(SUIT_DataObject*, int) ) );
+ connect( *model, SIGNAL( dropped(const QMimeData*, Qt::DropAction, int, int, const QModelIndex&) ),
+ //this, SIGNAL( dropped(const QMimeData*, Qt::DropAction, int, int, const QModelIndex&) ));
+ this, SLOT( onDropped(const QMimeData*, Qt::DropAction, int, int, const QModelIndex&) ));
setSourceModel( *model );
setDynamicSortFilter( true );
}
treeModel()->emitClicked(obj,index);
}
+void SUIT_ProxyModel::onDropped (const QMimeData* data, Qt::DropAction action,
+ int row, int column, const QModelIndex& parent)
+{
+ emit dropped(data, action, row, column, mapFromSource(parent));
+}
+
/*!
\class SUIT_ItemDelegate
\brief An SUIT_DataObject-based item delegate class.
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
// File: SUIT_TreeModel.h
// Author: Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
-//
+
#ifndef SUIT_TREEMODEL_H
#define SUIT_TREEMODEL_H
class SUIT_DataObject;
class SUIT_TreeModel;
+class QMimeData;
class SUIT_EXPORT SUIT_DataSearcher
{
virtual Qt::ItemFlags flags( const QModelIndex& ) const;
virtual QVariant headerData( int, Qt::Orientation, int = Qt::DisplayRole ) const;
+ virtual Qt::DropActions supportedDropActions() const;
+ virtual bool removeRows(int row, int count, const QModelIndex &parent);
+
virtual QModelIndex index( int, int, const QModelIndex& = QModelIndex() ) const;
virtual QModelIndex parent( const QModelIndex& ) const;
virtual void updateTreeModel(SUIT_DataObject*,TreeItem*);
+ virtual QStringList mimeTypes() const;
+ virtual QMimeData* mimeData (const QModelIndexList& indexes) const;
+ virtual bool dropMimeData (const QMimeData *data, Qt::DropAction action,
+ int row, int column, const QModelIndex &parent);
+
public slots:
virtual void updateTree( const QModelIndex& );
virtual void updateTree( SUIT_DataObject* = 0 );
signals:
void modelUpdated();
void clicked( SUIT_DataObject*, int );
+ void dropped( const QMimeData*, Qt::DropAction, int, int, const QModelIndex& );
private:
void initialize();
virtual void updateTree( const QModelIndex& );
virtual void updateTree( SUIT_DataObject* = 0 );
void setSortingEnabled( bool );
+ void onDropped( const QMimeData*, Qt::DropAction, int, int, const QModelIndex& );
signals:
void modelUpdated();
void clicked( SUIT_DataObject*, int );
+ void dropped( const QMimeData*, Qt::DropAction, int, int, const QModelIndex& );
protected:
SUIT_AbstractModel* treeModel() const;
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
// File: SalomeApp_DataModel.cxx
// Created: 10/25/2004 10:36:06 AM
// Author: Sergey LITONIN
-//
+
#include "SalomeApp_DataModel.h"
#include "SalomeApp_Study.h"
#include "SalomeApp_DataObject.h"
_PTR(AttributeExpandable) aAttrExp = anAttr;
expandable = aAttrExp->IsExpandable();
}
-
+
if ( expandable ) {
- _PTR(ChildIterator) it ( myStudy->NewChildIterator( obj ) );
- for ( ; it->More(); it->Next() )
- ch.append( it->Value() );
+ // tmp??
+ _PTR(UseCaseBuilder) aUseCaseBuilder = myStudy->GetUseCaseBuilder();
+ if (aUseCaseBuilder->HasChildren(obj)) {
+ _PTR(UseCaseIterator) it ( aUseCaseBuilder->GetUseCaseIterator( obj ) );
+ for ( ; it->More(); it->Next() )
+ ch.append( it->Value() );
+ }
+ else {
+ _PTR(ChildIterator) it ( myStudy->NewChildIterator( obj ) );
+ for ( ; it->More(); it->Next() )
+ ch.append( it->Value() );
+ }
}
return ch;
bool SalomeApp_DataObject::hasChildren() const
{
bool ok = false;
- _PTR(ChildIterator) it ( myObject->GetStudy()->NewChildIterator( myObject ) );
- for ( ; it->More() && !ok; it->Next() ) {
- _PTR(SObject) obj = it->Value();
- if ( obj ) {
- _PTR(SObject) refObj;
- //if ( obj->ReferencedObject( refObj ) ) continue; // omit references
- if ( obj->GetName() != "" ) ok = true;
+
+ // tmp??
+ _PTR(UseCaseBuilder) aUseCaseBuilder = myObject->GetStudy()->GetUseCaseBuilder();
+ if (aUseCaseBuilder->IsUseCaseNode(myObject)) {
+ ok = aUseCaseBuilder->HasChildren(myObject);
+ // TODO: check name as below?
+ }
+ else {
+ _PTR(ChildIterator) it ( myObject->GetStudy()->NewChildIterator( myObject ) );
+ for ( ; it->More() && !ok; it->Next() ) {
+ _PTR(SObject) obj = it->Value();
+ if ( obj ) {
+ _PTR(SObject) refObj;
+ //if ( obj->ReferencedObject( refObj ) ) continue; // omit references
+ if ( obj->GetName() != "" ) ok = true;
+ }
}
}
return ok;
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
// File : SalomeApp_DataObject.h
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
-//
+
#ifndef SALOMEAPP_DATAOBJECT_H
#define SALOMEAPP_DATAOBJECT_H
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
// File: SalomeApp_Module.cxx
// Created: 10/25/2004 11:39:56 AM
// Author: Sergey LITONIN
-//
+
#include "SalomeApp_Module.h"
#include "SalomeApp_DataModel.h"
#include "SalomeApp_Application.h"
if ( SUIT_ViewManager* vman = app->activeViewManager() )
vmod = vman->getViewModel();
app->updateVisibilityState( listObj, vmod );
-}
\ No newline at end of file
+}
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
// File: SalomeApp_Module.h
// Created: 10/25/2004 11:33:06 AM
// Author: Sergey LITONIN
-//
+
#ifndef SALOMEAPP_MODULE_H
#define SALOMEAPP_MODULE_H
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#include "SalomeApp_Study.h"
myStudy=aStudy;
fillEntryMap();
}
-
+
SUIT_DataObject* findObject( const char* theID ) const
{
EntryMap::const_iterator it = entry2SuitObject.find( theID );
virtual bool event(QEvent *event)
{
- if (event->type() == QEvent::User )
+ if (event->type() == QEvent::User )
{
//START_TIMING(notify);
notifyObserverID_real(static_cast<ObserverEvent *>(event)->_anID.c_str(),static_cast<ObserverEvent *>(event)->_event);
void notifyObserverID_real(const std::string& theID, long event)
{
SalomeApp_DataObject* suit_obj = 0;
-
- switch(event) {
- case 1:
+
+ switch(event) {
+ case 1:
{ //Add sobject
- EntryMapIter it = entry2SuitObject.find( theID );
- if ( it != entry2SuitObject.end() )
- {
- MESSAGE("Entry " << theID << " is already added. Problem ??");
+ _PTR(SObject) aSObj = myStudyDS->FindObjectID(theID);
+ _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
+
+ if (!aSComp || aSComp->IsNull()) {
+ MESSAGE("Entry " << theID << " has not father component. Problem ??");
return;
}
- _PTR(SObject) obj = myStudyDS->FindObjectID( theID );
- int last2Pnt_pos = theID.rfind( ":" );
- std::string parent_id = theID.substr( 0, last2Pnt_pos );
- int tag = atoi( theID.substr( last2Pnt_pos+1 ).c_str() );
-
- if ( parent_id.length() == 3 ) // "0:1" - root item?
- {
- // It's probably a SComponent
- _PTR(SComponent) aSComp = obj->GetFatherComponent();
- if ( aSComp && !aSComp->IsNull() && aSComp->GetID() == theID )
- suit_obj = new SalomeApp_ModuleObject( aSComp );
- else
- suit_obj = new SalomeApp_DataObject( obj );
- }
- else
- {
- suit_obj = new SalomeApp_DataObject( obj );
- }
-
- it = entry2SuitObject.find( parent_id );
- if ( it != entry2SuitObject.end() )
- {
- SalomeApp_DataObject* father = it->second;
- father->insertChildAtTag( suit_obj, tag );
- }
- else
- {
+
+ // Mantis issue 0020136: Drag&Drop in OB
+ _PTR(UseCaseBuilder) aUseCaseBuilder = myStudyDS->GetUseCaseBuilder();
+ if (aUseCaseBuilder->IsUseCaseNode(aSComp)) { // BEGIN: work with tree nodes structure
+ if (!aUseCaseBuilder->IsUseCaseNode(aSObj)) {
+ // tree node is not yet set, it is a normal situation
+ return;
+ }
+
+ _PTR(SObject) aFatherSO = aUseCaseBuilder->GetFather(aSObj);
+ if (!aFatherSO || aFatherSO->IsNull()) {
+ MESSAGE("Father SObject is not found. Problem ??");
+ return;
+ }
+
+ std::string parent_id = aFatherSO->GetID();
+ EntryMapIter it = entry2SuitObject.find(parent_id.c_str());
+
+ if (it == entry2SuitObject.end()) {
+ MESSAGE("Father data object is not found. Problem ??");
+ return;
+ }
+
+ SalomeApp_DataObject* aFatherDO = it->second;
+
+ it = entry2SuitObject.find(theID);
+ if (it != entry2SuitObject.end()) { // this SOobject is already added somethere
+ // tmp??
+ suit_obj = it->second;
+ SUIT_DataObject* oldFather = suit_obj->parent();
+ if (oldFather) {
+ oldFather->removeChild(suit_obj, false);
+
+ suit_obj->updateItem(); // tmp??
+ if (SalomeApp_DataObject* oldFatherSA = dynamic_cast<SalomeApp_DataObject*>(oldFather)) {
+ oldFatherSA->updateItem(); // tmp??
+ }
+
+ //entry2SuitObject.erase(it);
+ ////delete suit_obj;
+ //suit_obj = new SalomeApp_DataObject(aSObj);
+ //entry2SuitObject[theID] = suit_obj;
+ }
+ }
+ else {
+ suit_obj = new SalomeApp_DataObject(aSObj);
+ entry2SuitObject[theID] = suit_obj;
+ }
+
+ // define position in the data tree (in aFatherDO) to insert the aSObj
+ int pos = -1;
+ //int childDataObjCount = aFatherDO->childCount();
+ _PTR(UseCaseIterator) aUseCaseIter = aUseCaseBuilder->GetUseCaseIterator(aFatherSO);
+ for (int cur = 0; aUseCaseIter->More() && pos < 0; cur++, aUseCaseIter->Next()) {
+ if (aUseCaseIter->Value()->GetID() == theID) {
+ pos = cur;
+ break;
+ }
+ }
+
+ //aFatherDO->insertChildAtPos(suit_obj, pos);
+ aFatherDO->insertChild(suit_obj, pos);
+ aFatherDO->updateItem(); // tmp??
+
+ } // END: work with tree nodes structure
+ else { // BEGIN: work with study structure
+ EntryMapIter it = entry2SuitObject.find( theID );
+ if ( it != entry2SuitObject.end() ) {
+ MESSAGE("Entry " << theID << " is already added. Problem ??");
+ return;
+ }
+
+ int last2Pnt_pos = theID.rfind( ":" );
+ std::string parent_id = theID.substr( 0, last2Pnt_pos );
+ int tag = atoi( theID.substr( last2Pnt_pos+1 ).c_str() );
+
if ( parent_id.length() == 3 ) // "0:1" - root item?
{
- // This should be for a module
- SUIT_DataObject* father=myStudy->root();
- father->appendChild(suit_obj);
+ // It's probably a SComponent
+ if ( theID == aSComp->GetID() )
+ suit_obj = new SalomeApp_ModuleObject( aSComp );
+ else
+ suit_obj = new SalomeApp_DataObject( aSObj );
}
else
{
- MESSAGE("SHOULD NEGER GET HERE!!!");
-
- //Try to find the SalomeApp_DataObject object parent
- std::string root_id = parent_id.substr( 0, 4 );
- std::string obj_id = parent_id.substr( 4 );
-
- std::string anID;
- std::string::size_type debut = 0;
- std::string::size_type fin;
- SalomeApp_DataObject* anObj = dynamic_cast<SalomeApp_DataObject*>( myStudy->root() );
- while ( 1 )
+ suit_obj = new SalomeApp_DataObject( aSObj );
+ }
+
+ it = entry2SuitObject.find( parent_id );
+ if ( it != entry2SuitObject.end() ) {
+ SalomeApp_DataObject* father = it->second;
+ father->insertChildAtTag( suit_obj, tag );
+ }
+ else {
+ if ( parent_id.length() == 3 ) // "0:1" - root item?
{
- fin = obj_id.find_first_of( ':', debut );
- if ( fin == std::string::npos )
- {
- //last id
- anObj = dynamic_cast<SalomeApp_DataObject*>( anObj->childObject( atoi( obj_id.substr( debut ).c_str() )-1 ) );
- entry2SuitObject[parent_id] = anObj;
- break;
- }
- anID = root_id + obj_id.substr( 0, fin );
- EntryMapIter it2 = entry2SuitObject.find( anID );
- if ( it2 == entry2SuitObject.end() )
- {
- //the ID is not known in entry2SuitObject
- anObj = dynamic_cast<SalomeApp_DataObject*>( anObj->childObject( atoi( obj_id.substr( debut, fin-debut ).c_str() )-1 ) );
- entry2SuitObject[anID] = anObj;
+ // This should be for a module
+ SUIT_DataObject* father=myStudy->root();
+ father->appendChild(suit_obj);
+ }
+ else
+ {
+ MESSAGE("SHOULD NEVER GET HERE!!!");
+
+ //Try to find the SalomeApp_DataObject object parent
+ std::string root_id = parent_id.substr( 0, 4 );
+ std::string obj_id = parent_id.substr( 4 );
+
+ std::string anID;
+ std::string::size_type debut = 0;
+ std::string::size_type fin;
+ SalomeApp_DataObject* anObj = dynamic_cast<SalomeApp_DataObject*>( myStudy->root() );
+ while ( 1 ) {
+ fin = obj_id.find_first_of( ':', debut );
+ if ( fin == std::string::npos ) {
+ //last id
+ anObj = dynamic_cast<SalomeApp_DataObject*>(anObj->childObject(atoi(obj_id.substr(debut).c_str())-1));
+ entry2SuitObject[parent_id] = anObj;
+ break;
+ }
+ anID = root_id + obj_id.substr( 0, fin );
+ EntryMapIter it2 = entry2SuitObject.find( anID );
+ if ( it2 == entry2SuitObject.end() ) {
+ //the ID is not known in entry2SuitObject
+ anObj = dynamic_cast<SalomeApp_DataObject*>(anObj->childObject(atoi(obj_id.substr(debut, fin-debut).c_str())-1));
+ entry2SuitObject[anID] = anObj;
+ }
+ else
+ anObj = it2->second;
+ debut = fin+1;
}
- else
- anObj = it2->second;
- debut = fin+1;
+ anObj->insertChildAtTag( suit_obj, tag );
}
- anObj->insertChildAtTag( suit_obj, tag );
}
- }
- entry2SuitObject[theID] = suit_obj;
+ entry2SuitObject[theID] = suit_obj;
+ } // END: work with study structure
break;
- }
- case 2:
+ }
+ case 2:
{ // Remove sobject
EntryMapIter it = entry2SuitObject.find( theID );
if ( it != entry2SuitObject.end() )
{
suit_obj = it->second;
- // VSR: object is not removed, since SALOMEDS::SObject is not actually removed, only its attributes are cleared;
+ // VSR: object is not removed, since SALOMEDS::SObject is not actually removed,
+ // only its attributes are cleared;
// thus, the object can be later reused
suit_obj->updateItem();
//SUIT_DataObject* father=suit_obj->parent();
}
break;
}
- case 0:
+ case 0:
{ //modify sobject
//MESSAGE("Want to modify an object " << theID);
EntryMapIter it = entry2SuitObject.find( theID );
case 5: //IOR of the object modified
{
EntryMapIter it = entry2SuitObject.find( theID );
- if ( it != entry2SuitObject.end() )
+ if ( it != entry2SuitObject.end() )
suit_obj = it->second;
-
+
/* Define visibility state */
- bool isComponent = dynamic_cast<SalomeApp_ModuleObject*>( suit_obj ) != 0;
+ bool isComponent = dynamic_cast<SalomeApp_ModuleObject*>( suit_obj ) != 0;
if ( suit_obj && !isComponent ) {
QString moduleTitle = ((CAM_Application*)myStudy->application())->moduleTitle(suit_obj->componentDataType());
if (!moduleTitle.isEmpty()) {
LightApp_Displayer* aDisplayer = LightApp_Displayer::FindDisplayer(moduleTitle,false);
- if(aDisplayer) {
+ if (aDisplayer) {
if(aDisplayer->canBeDisplayed(theID.c_str())) {
myStudy->setVisibilityState( theID.c_str(), Qtx::HiddenState );
//MESSAGE("Object with entry : "<< theID <<" CAN be displayed !!!");
- } else
+ }
+ else
MESSAGE("Object with entry : "<< theID <<" CAN'T be displayed !!!");
}
}
}
default:MESSAGE("Unknown event: " << event);break;
} //switch
- } //notifyObserverID
+ } //notifyObserverID_real
-private:
+private:
void fillEntryMap()
{
entry2SuitObject.clear();
}
}
}
-
+
private:
_PTR(Study) myStudyDS;
SalomeApp_Study* myStudy;
SalomeApp_Study::SalomeApp_Study( SUIT_Application* app )
: LightApp_Study( app ), myObserver( 0 )
{
-}
+}
/*!
Destructor.
#ifdef WITH_SALOMEDS_OBSERVER
myObserver = new Observer_i(myStudyDS,this);
- //attach an observer to the study with notification of modifications
+ //attach an observer to the study with notification of modifications
myStudyDS->attach(myObserver->_this(),true);
#endif
-
+
return aRet;
}
ModelList dm_s;
dataModels( dm_s );
QListIterator<CAM_DataModel*> it( dm_s );
- while ( it.hasNext() )
+ while ( it.hasNext() )
openDataModel( studyName(), it.next() );
-
+
// this will build a SUIT_DataObject-s tree under myRoot member field
// passing "false" in order NOT to rebuild existing data models' trees - it was done in previous step
- // but tree that corresponds to not-loaded data models will be updated any way.
- ((SalomeApp_Application*)application())->updateObjectBrowser( false );
+ // but tree that corresponds to not-loaded data models will be updated any way.
+ ((SalomeApp_Application*)application())->updateObjectBrowser( false );
#ifdef WITH_SALOMEDS_OBSERVER
dynamic_cast<SalomeApp_RootObject*>( root() )->setToSynchronize(false);
myObserver = new Observer_i(myStudyDS,this);
- //attach an observer to the study with notification of modifications
+ //attach an observer to the study with notification of modifications
myStudyDS->attach(myObserver->_this(),true);
#endif
bool res = CAM_Study::openDocument( theFileName );
-
+
emit opened( this );
study->IsSaved(true);
SalomeApp_VisualState( (SalomeApp_Application*)application() ).restoreState( savePoints[savePoints.size()-1] );
}
- ((SalomeApp_Application*)application())->updateObjectBrowser( true );
+ ((SalomeApp_Application*)application())->updateObjectBrowser( true );
return res;
}
// this will build a SUIT_DataObject-s tree under myRoot member field
// passing "false" in order NOT to rebuild existing data models' trees - it was done in previous step
- // but tree that corresponds to not-loaded data models will be updated any way.
- ((SalomeApp_Application*)application())->updateObjectBrowser( false );
+ // but tree that corresponds to not-loaded data models will be updated any way.
+ ((SalomeApp_Application*)application())->updateObjectBrowser( false );
#ifdef WITH_SALOMEDS_OBSERVER
dynamic_cast<SalomeApp_RootObject*>( root() )->setToSynchronize(false);
myObserver = new Observer_i(myStudyDS,this);
- //attach an observer to the study with notification of modifications
+ //attach an observer to the study with notification of modifications
myStudyDS->attach(myObserver->_this(),true);
#endif
bool store = application()->resourceMgr()->booleanValue( "Study", "store_visual_state", false );
if ( store )
SalomeApp_VisualState( (SalomeApp_Application*)application() ).storeState();
-
+
ModelList list; dataModels( list );
QListIterator<CAM_DataModel*> it( list );
bool isMultiFile = resMgr->booleanValue( "Study", "multi_file", false );
bool isAscii = resMgr->booleanValue( "Study", "ascii_file", false );
- bool res = (isAscii ?
+ bool res = (isAscii ?
SalomeApp_Application::studyMgr()->SaveAsASCII( theFileName.toStdString(), studyDS(), isMultiFile ) :
SalomeApp_Application::studyMgr()->SaveAs ( theFileName.toStdString(), studyDS(), isMultiFile ))
&& CAM_Study::saveDocumentAs( theFileName );
-
+
res = res && saveStudyData(theFileName);
if ( res )
if ( SalomeApp_DataModel* aModel = (SalomeApp_DataModel*)it.next() ) {
listOfFiles.clear();
aModel->save(listOfFiles);
- if ( !listOfFiles.isEmpty() )
+ if ( !listOfFiles.isEmpty() )
saveModuleData(aModel->module()->name(), listOfFiles);
}
}
bool isMultiFile = resMgr->booleanValue( "Study", "multi_file", false );
bool isAscii = resMgr->booleanValue( "Study", "ascii_file", false );
- bool res = (isAscii ?
+ bool res = (isAscii ?
SalomeApp_Application::studyMgr()->SaveASCII( studyDS(), isMultiFile ) :
SalomeApp_Application::studyMgr()->Save ( studyDS(), isMultiFile )) && CAM_Study::saveDocument();
res = res && saveStudyData(studyName());
if ( res )
- emit saved( this );
+ emit saved( this );
return res;
}
if (!isAnyChanged)
isAnyChanged = LightApp_Study::isModified();
- return isAnyChanged;
+ return isAnyChanged;
}
/*!
if (!isAllSaved)
isAllSaved = LightApp_Study::isSaved();
- return isAllSaved;
+ return isAllSaved;
}
/*!
if (!aModule) {
// Check SComponent existance
_PTR(Study) aStudy = studyDS();
- if (!aStudy)
+ if (!aStudy)
return;
_PTR(SComponent) aComp = aStudy->FindComponent(dm->module()->name().toStdString());
if (!aComp) {
*/
void SalomeApp_Study::components( QStringList& comps ) const
{
- for( _PTR(SComponentIterator) it ( studyDS()->NewComponentIterator() ); it->More(); it->Next() )
+ for( _PTR(SComponentIterator) it ( studyDS()->NewComponentIterator() ); it->More(); it->Next() )
{
_PTR(SComponent) aComponent ( it->Value() );
// skip the magic "Interface Applicative" component
QString SalomeApp_Study::centry( const QString& comp ) const
{
QString e;
- for( _PTR(SComponentIterator) it ( studyDS()->NewComponentIterator() ); it->More() && e.isEmpty(); it->Next() )
+ for( _PTR(SComponentIterator) it ( studyDS()->NewComponentIterator() ); it->More() && e.isEmpty(); it->Next() )
{
_PTR(SComponent) aComponent ( it->Value() );
if ( aComponent && comp == aComponent->ComponentDataType().c_str() )
catch (std::exception& e) {
std::cerr << e.what() << std::endl;
}
+ catch (CORBA::Exception& e) {
+ std::cerr << "Caught CORBA::Exception" << std::endl;
+ CORBA::Any tmp;
+ tmp<<= e;
+ CORBA::TypeCode_var tc = tmp.type();
+ const char *p = tc->name();
+ std::cerr << "notify(): CORBA exception of the kind : " << p << " is caught" << std::endl;
+ }
catch (...) {
std::cerr << "Unknown exception caught in Qt handler: it's probably a bug in SALOME platform" << std::endl;
}