-using namespace std;
-
-// VISU VISUGUI : GUI of VISU component
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// Copyright (C) 2003 CEA/DEN, EDF R&D
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// 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 : VisuGUI_EditContainerDlg.cxx
// Author : VSV
// Module : VISU
-
-
+//
#include "VisuGUI_EditContainerDlg.h"
-#include "VisuGUI.h"
-#include "VISU_Table_i.hh"
-#include "QAD_Application.h"
-#include "QAD_Desktop.h"
+#include "VisuGUI.h"
+#include "VisuGUI_Tools.h"
-#include <qlayout.h>
-#include <qcheckbox.h>
-#include <qgroupbox.h>
+#include "VISU_Table_i.hh"
+#include "SalomeApp_Application.h"
+#include "SUIT_Desktop.h"
+#include "SUIT_Session.h"
+#include "SUIT_MessageBox.h"
+#include "SUIT_ResourceMgr.h"
-#include CORBA_SERVER_HEADER(VISU_Gen)
-#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+#include <QLayout>
+#include <QCheckBox>
+#include <QGroupBox>
+#include <QPushButton>
+#include <QLabel>
+#include <QTreeWidget>
+#include <QToolButton>
+#include <QKeyEvent>
-extern VisuGUI *visuGUI;
+using namespace std;
/* XPM */
static QPixmap MYRightPix(right_xpm);
-VisuGUI_EditContainerDlg::VisuGUI_EditContainerDlg()
- : QDialog( QAD_Application::getDesktop(), "VisuGUI_EditContainerDlg", true,
- WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+VisuGUI_EditContainerDlg::VisuGUI_EditContainerDlg (VisuGUI* theModule, bool theIsModal)
+ : QDialog(VISU::GetDesktop(theModule), Qt::WindowTitleHint | Qt::WindowSystemMenuHint ),
+ myVisuGUI(theModule)
{
- setCaption( "Edit Plot 2D Presentation" );
- setSizeGripEnabled( true );
- QVBoxLayout* TopLayout = new QVBoxLayout(this, 6, 11);
+ setModal( theIsModal );
+ if (!theIsModal) {
+ setAttribute( Qt::WA_DeleteOnClose, true );
+ }
+ setWindowTitle("Edit Plot 2D Presentation");
+ setSizeGripEnabled(true);
+
+ QVBoxLayout* TopLayout = new QVBoxLayout (this );
+ TopLayout->setMargin( 6 );
+ TopLayout->setSpacing( 11);
/***************************************************************/
- QFrame* aControlFrame = new QFrame(this);
+ QFrame* aControlFrame = new QFrame (this);
aControlFrame->setFrameStyle(QFrame::Box | QFrame::Sunken);
- QGridLayout* aControlLay = new QGridLayout(aControlFrame);
- aControlLay->setSpacing( 6 );
- aControlLay->setMargin( 11 );
- aControlLay->addRowSpacing( 1, 30 );
- aControlLay->addRowSpacing( 4, 30 );
- aControlLay->setRowStretch( 1, 1 );
- aControlLay->setRowStretch( 4, 1 );
- aControlLay->addColSpacing( 0, 180 );
- aControlLay->addColSpacing( 2, 180 );
-
- QLabel* aSelectLbl = new QLabel(tr("Study"), aControlFrame);
+ QGridLayout* aControlLay = new QGridLayout (aControlFrame);
+ aControlLay->setSpacing(6);
+ aControlLay->setMargin(11);
+ //aControlLay->addRowSpacing(1, 30);
+ //aControlLay->addRowSpacing(4, 30);
+ aControlLay->setRowStretch(1, 1);
+ aControlLay->setRowStretch(4, 1);
+ //aControlLay->addColSpacing(0, 180);
+ //aControlLay->addColSpacing(2, 180);
+
+ QLabel* aSelectLbl = new QLabel (tr("LBL_STUDY"), aControlFrame);
aControlLay->addWidget(aSelectLbl, 0, 0);
- myStudyLst = new QListView(aControlFrame);
- myStudyLst->setSelectionMode(QListView::Extended);
- myStudyLst->addColumn(tr("Table"), 80);
- myStudyLst->addColumn(tr("Curve"), 50);
- myStudyLst->addColumn(tr(""), 0);
- myStudyLst->setAllColumnsShowFocus(true);
- myStudyLst->setMinimumHeight(130);
- connect(myStudyLst, SIGNAL( selectionChanged()), this, SLOT( onLeftSelected() ));
- aControlLay->addMultiCellWidget(myStudyLst, 1, 4, 0, 0);
+ myStudyLst = new QTreeWidget (aControlFrame);
+ myStudyLst->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ myStudyLst->setColumnCount( 3 );
+ QStringList aLabels;
+ aLabels.append( tr("TXT_TABLE") );
+ aLabels.append( tr("TXT_CURVE") );
+ aLabels.append( "" );
+ myStudyLst->setHeaderLabels( aLabels );
+ myStudyLst->setColumnWidth( 0, 80 );
+ myStudyLst->setColumnWidth( 1, 50 );
+ myStudyLst->setColumnWidth( 2, 0 );
+
+ //myStudyLst->addColumn(tr("TXT_TABLE"), 80);
+ //myStudyLst->addColumn(tr("TXT_CURVE"), 50);
+ //myStudyLst->addColumn(tr(""), 0);
- myRightBtn = new QToolButton(aControlFrame);
- myRightBtn->setIconSet(MYRightPix);
+ myStudyLst->setAllColumnsShowFocus(true);
+ //myStudyLst->setMinimumHeight(130);
+ connect(myStudyLst, SIGNAL(itemSelectionChanged()), this, SLOT(onLeftSelected()));
+ aControlLay->addWidget(myStudyLst, 1, 0, 5, 1);
+
+ myRightBtn = new QToolButton (aControlFrame);
+ myRightBtn->setIcon(MYRightPix);
myRightBtn->setEnabled(false);
- connect(myRightBtn, SIGNAL( clicked()), this, SLOT( onRightClicked() ));
+ connect(myRightBtn, SIGNAL(clicked()), this, SLOT(onRightClicked()));
aControlLay->addWidget(myRightBtn, 2, 1);
-
+
myLeftBtn = new QToolButton(aControlFrame);
- myLeftBtn->setIconSet(MYLeftPix);
+ myLeftBtn->setIcon(MYLeftPix);
myLeftBtn->setEnabled(false);
- connect(myLeftBtn, SIGNAL( clicked()), this, SLOT( onLeftClicked() ));
+ connect(myLeftBtn, SIGNAL(clicked()), this, SLOT(onLeftClicked()));
aControlLay->addWidget(myLeftBtn, 3, 1);
-
- QLabel* aForceLbl = new QLabel(tr("Container"), aControlFrame);
+
+ QLabel* aForceLbl = new QLabel (tr("LBL_CONTAINER"), aControlFrame);
aControlLay->addWidget(aForceLbl, 0, 2);
- myContainerLst = new QListView(aControlFrame);
- myContainerLst->setSelectionMode(QListView::Extended);
- myContainerLst->addColumn(tr("Table"), 80);
- myContainerLst->addColumn(tr("Curve"), 50);
- myContainerLst->addColumn(tr(""), 0);
- myContainerLst->setMinimumWidth(130);
- connect(myContainerLst, SIGNAL( selectionChanged()), this, SLOT( onRightSelected() ));
- aControlLay->addMultiCellWidget(myContainerLst, 1, 4, 2, 2);
+ myContainerLst = new QTreeWidget(aControlFrame);
+ myContainerLst->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ //myContainerLst->addColumn(tr("TXT_TABLE"), 80);
+ //myContainerLst->addColumn(tr("TXT_CURVE"), 50);
+ //myContainerLst->addColumn(tr(""), 0);
+ myContainerLst->setColumnCount( 3 );
+ myContainerLst->setHeaderLabels( aLabels );
+ myContainerLst->setColumnWidth( 0, 80 );
+ myContainerLst->setColumnWidth( 1, 50 );
+ myContainerLst->setColumnWidth( 2, 0 );
+
- TopLayout->addWidget( aControlFrame );
+ //myContainerLst->setMinimumWidth(130);
+ connect(myContainerLst, SIGNAL(itemSelectionChanged()), this, SLOT(onRightSelected()));
+ aControlLay->addWidget(myContainerLst, 1, 2, 5, 1);
+
+ TopLayout->addWidget(aControlFrame);
// Common buttons ===========================================================
- QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
- GroupButtons->setColumnLayout(0, Qt::Vertical );
- GroupButtons->layout()->setSpacing( 0 );
- GroupButtons->layout()->setMargin( 0 );
- QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
- GroupButtonsLayout->setAlignment( Qt::AlignTop );
- GroupButtonsLayout->setSpacing( 6 );
- GroupButtonsLayout->setMargin( 11 );
-
- QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
- buttonOk->setAutoDefault( TRUE );
- buttonOk->setDefault( TRUE );
- GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
- GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
-
- QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
- buttonCancel->setAutoDefault( TRUE );
- GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
-
- TopLayout->addWidget( GroupButtons );
-
- connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
- connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
+ QGroupBox* GroupButtons = new QGroupBox(this);
+ //GroupButtons->setColumnLayout(0, Qt::Vertical);
+ //GroupButtons->layout()->setSpacing(0);
+ //GroupButtons->layout()->setMargin(0);
+ QGridLayout* GroupButtonsLayout = new QGridLayout(GroupButtons);
+ GroupButtonsLayout->setAlignment(Qt::AlignTop);
+ GroupButtonsLayout->setSpacing(6);
+ GroupButtonsLayout->setMargin(11);
+
+ QPushButton* buttonOk = new QPushButton(tr("&OK"), GroupButtons);
+ buttonOk->setAutoDefault(TRUE);
+ buttonOk->setDefault(TRUE);
+ GroupButtonsLayout->addWidget(buttonOk, 0, 0);
+ GroupButtonsLayout->addItem(new QSpacerItem(5, 5, QSizePolicy::Expanding,
+ QSizePolicy::Minimum), 0, 1);
+
+ QPushButton* buttonCancel = new QPushButton(tr("&Cancel") , GroupButtons);
+ buttonCancel->setAutoDefault(TRUE);
+ GroupButtonsLayout->addWidget(buttonCancel, 0, 2);
+
+ QPushButton* buttonHelp = new QPushButton(tr("&Help") , GroupButtons);
+ buttonHelp->setAutoDefault(TRUE);
+ GroupButtonsLayout->addWidget(buttonHelp, 0, 3);
+
+ TopLayout->addWidget(GroupButtons);
+
+ connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
+ connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
+ connect(buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp()));
}
-
-void VisuGUI_EditContainerDlg::initFromPrsObject(VISU::Container_i* theContainer) {
- SALOMEDS::Study_var aStudy = visuGUI->GetStudyDocument();
- SALOMEDS::SComponent_var aVisuSO = aStudy->FindComponent("VISU");
- if (aVisuSO->_is_nil()) {
+void VisuGUI_EditContainerDlg::initFromPrsObject (VISU::Container_i* theContainer)
+{
+ _PTR(Study) aStudy = VISU::GetCStudy(VISU::GetAppStudy(myVisuGUI));
+ _PTR(SComponent) aVisuSO = aStudy->FindComponent("VISU");
+ if (!aVisuSO) {
return;
}
- QValueList<CurveStruct> aStudyCurves;
- QValueList<CurveStruct> aContainerCurves;
+ QList<CurveStruct> aStudyCurves;
+ QList<CurveStruct> aContainerCurves;
// Find curves in container
for (int i = 1; i <= theContainer->GetNbCurves(); i++) {
VISU::Curve_i* aCurve = theContainer->GetCurve(i);
if (aCurve == NULL) continue;
CurveStruct aEntry;
aEntry.CurveName = aCurve->GetTitle();
- aEntry.CurveEntry = aCurve->GetEntry();
- SALOMEDS::SObject_var aTableSO = aStudy->FindObjectID(aCurve->GetTableID());
- if (CORBA::is_nil(aTableSO)) continue;
+ aEntry.CurveEntry = aCurve->GetEntry().c_str();
+ _PTR(SObject) aTableSO = aStudy->FindObjectID(aCurve->GetTableID());
+ if (!aTableSO) continue;
aEntry.TableName = getSObjectName(aTableSO);
aContainerCurves.append(aEntry);
- new QListViewItem(myContainerLst, aEntry.TableName, aEntry.CurveName, aEntry.CurveEntry);
+ QStringList aList;
+ aList.append( aEntry.TableName );
+ aList.append( aEntry.CurveName );
+ aList.append( aEntry.CurveEntry );
+ new QTreeWidgetItem(myContainerLst, aList);
}
// Find curves in study
- SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aVisuSO );
+ _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aVisuSO);
for (aIter->InitEx(true); aIter->More(); aIter->Next()) {
- SALOMEDS::SObject_var aSObject = aIter->Value();
- CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
+ _PTR(SObject) aSObject = aIter->Value();
+ CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObject);
VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
if (!CORBA::is_nil(aVisuObj)) {
if (aVisuObj->GetType() == VISU::TCURVE) {
- SALOMEDS::SObject_var aTableSO = aSObject->GetFather();
+ _PTR(SObject) aTableSO = aSObject->GetFather();
CurveStruct aEntry;
aEntry.TableName = getSObjectName(aTableSO);
aEntry.CurveName = getSObjectName(aSObject);
- aEntry.CurveEntry = aSObject->GetID();
+ aEntry.CurveEntry = aSObject->GetID().c_str();
aStudyCurves.append(aEntry);
}
}
}
//Show Curves which are not in Curve
- QValueList<CurveStruct>::iterator it;
- QValueList<CurveStruct>::iterator it2;
+ QList<CurveStruct>::iterator it;
+ QList<CurveStruct>::iterator it2;
bool isExist = false;
- for (it = aStudyCurves.begin(); it != aStudyCurves.end(); ++it ) {
- for (it2 = aContainerCurves.begin(); it2 != aContainerCurves.end(); ++it2 ) {
+ for (it = aStudyCurves.begin(); it != aStudyCurves.end(); ++it) {
+ for (it2 = aContainerCurves.begin(); it2 != aContainerCurves.end(); ++it2) {
if (isExist = ((*it).CurveEntry == (*it2).CurveEntry))
break;
}
if (!isExist)
- new QListViewItem(myStudyLst, (*it).TableName, (*it).CurveName, (*it).CurveEntry);
+ {
+ QStringList aList;
+ aList.append( (*it).TableName );
+ aList.append( (*it).CurveName );
+ aList.append( (*it).CurveEntry );
+ new QTreeWidgetItem(myStudyLst, aList );
+ }
}
}
-
-void VisuGUI_EditContainerDlg::storeToPrsObject(VISU::Container_i* theContainer) {
+void VisuGUI_EditContainerDlg::storeToPrsObject (VISU::Container_i* theContainer)
+{
theContainer->Clear();
- SALOMEDS::Study_var aStudy = visuGUI->GetStudyDocument();
- QListViewItem* anItem = myContainerLst->firstChild();
- while (anItem) {
- SALOMEDS::SObject_var aCurveSO = aStudy->FindObjectID(anItem->text(2));
- if (!aCurveSO->_is_nil()) {
- CORBA::Object_var aObject = VISU::SObjectToObject(aCurveSO);
+ _PTR(Study) aStudy = VISU::GetCStudy(VISU::GetAppStudy(myVisuGUI));
+ QTreeWidgetItem* anItem;
+ for ( int i= 0; i< myContainerLst->topLevelItemCount(); i++ )
+ {
+ anItem = myContainerLst->topLevelItem( i );
+ if ( !anItem )
+ continue;
+ _PTR(SObject) aCurveSO = aStudy->FindObjectID((const char*)anItem->text(2).toLatin1());
+ if (aCurveSO) {
+ CORBA::Object_var aObject = VISU::ClientSObjectToObject(aCurveSO);
if (!CORBA::is_nil(aObject)) {
- VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>( VISU::GetServant(aObject).in() );
+ VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aObject).in());
if (aCurve) theContainer->AddCurve(aCurve->_this());
}
}
- anItem = anItem->nextSibling();
}
}
+QString VisuGUI_EditContainerDlg::getSObjectName (_PTR(SObject) theSObject)
+{
+ if (!theSObject) return QString("");
-QString VisuGUI_EditContainerDlg::getSObjectName(SALOMEDS::SObject_var theSObject) {
- if (theSObject->_is_nil()) return QString("");
-
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributeName_var aName;
- if ( theSObject->FindAttribute(anAttr, "AttributeName") ) {
- aName = SALOMEDS::AttributeName::_narrow( anAttr );
- return QString(strdup( aName->Value() ));
- }
+ _PTR(GenericAttribute) anAttr;
+ if (theSObject->FindAttribute(anAttr, "AttributeName")) {
+ _PTR(AttributeName) aName (anAttr);
+ return QString(aName->Value().c_str());
+ }
return QString("");
}
-
-void VisuGUI_EditContainerDlg::onLeftClicked() {
- QListViewItem* anItem = myContainerLst->firstChild();
+void VisuGUI_EditContainerDlg::onLeftClicked()
+{
+ /*QListViewItem* anItem = myContainerLst->firstChild();
while (anItem) {
if (anItem->isSelected()) {
QListViewItem* anTmpItem = anItem;
} else {
anItem = anItem->nextSibling();
}
+ }*/
+ QList<QTreeWidgetItem*> selItem = myContainerLst->selectedItems();
+ QList<QTreeWidgetItem*>::Iterator anIt = selItem.begin();
+
+ QList<QTreeWidgetItem*> topSelectedItems;
+ for ( ; anIt != selItem.end(); anIt++ )
+ {
+ int index = myContainerLst->indexOfTopLevelItem( *anIt );
+ if ( index != -1 )
+ topSelectedItems.append( myContainerLst->takeTopLevelItem( index ) );
}
-}
+ myStudyLst->addTopLevelItems(topSelectedItems);
+}
-void VisuGUI_EditContainerDlg::onRightClicked() {
- QListViewItem* anItem = myStudyLst->firstChild();
+void VisuGUI_EditContainerDlg::onRightClicked()
+{
+ /*QListViewItem* anItem = myStudyLst->firstChild();
while (anItem) {
if (anItem->isSelected()) {
QListViewItem* anTmpItem = anItem;
} else {
anItem = anItem->nextSibling();
}
+ }*/
+ QList<QTreeWidgetItem*> selItem = myStudyLst->selectedItems();
+ QList<QTreeWidgetItem*>::Iterator anIt = selItem.begin();
+
+ QList<QTreeWidgetItem*> topSelectedItems;
+ for ( ; anIt != selItem.end(); anIt++ )
+ {
+ int index = myStudyLst->indexOfTopLevelItem( *anIt );
+ if ( index != -1 )
+ topSelectedItems.append( myStudyLst->takeTopLevelItem( index ) );
}
+
+ myContainerLst->addTopLevelItems(topSelectedItems);
+}
+
+void VisuGUI_EditContainerDlg::onLeftSelected()
+{
+ myRightBtn->setEnabled( myStudyLst->selectedItems().count() > 0 );
}
+void VisuGUI_EditContainerDlg::onRightSelected()
+{
+ myLeftBtn->setEnabled( myContainerLst->selectedItems().count() > 0 );
+}
-void VisuGUI_EditContainerDlg::onLeftSelected() {
- QListViewItem* anItem = myStudyLst->firstChild();
- bool isSelected = false;
- while (anItem) {
- if (anItem->isSelected()) {
- isSelected = true;
- break;
- }
- anItem = anItem->nextSibling();
+void VisuGUI_EditContainerDlg::onHelp()
+{
+ QString aHelpFileName = "creating_xy_plot_page.html";
+ SalomeApp_Application* app = (SalomeApp_Application*)(SUIT_Session::session()->activeApplication());
+ if (app)
+ app->onHelpContextModule(myVisuGUI ? app->moduleName(myVisuGUI->moduleName()) : QString(""), aHelpFileName);
+ else {
+ QString platform;
+#ifdef WIN32
+ platform = "winapplication";
+#else
+ platform = "application";
+#endif
+ SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"),
+ QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+ arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName),
+ QObject::tr("BUT_OK"));
}
- myRightBtn->setEnabled(isSelected);
}
+void VisuGUI_EditContainerDlg::keyPressEvent( QKeyEvent* e )
+{
+ QDialog::keyPressEvent( e );
+ if ( e->isAccepted() )
+ return;
-void VisuGUI_EditContainerDlg::onRightSelected() {
- QListViewItem* anItem = myContainerLst->firstChild();
- bool isSelected = false;
- while (anItem) {
- if (anItem->isSelected()) {
- isSelected = true;
- break;
+ if ( e->key() == Qt::Key_F1 )
+ {
+ e->accept();
+ onHelp();
}
- anItem = anItem->nextSibling();
- }
- myLeftBtn->setEnabled(isSelected);
}