From 16aee5a6804c7265875db031dd2df6c32203cb25 Mon Sep 17 00:00:00 2001 From: rnv Date: Tue, 28 Oct 2008 11:33:12 +0000 Subject: [PATCH] Start Dump Python extension task. --- src/SalomeApp/Makefile.am | 9 +- src/SalomeApp/SalomeApp_Application.cxx | 24 +++ src/SalomeApp/SalomeApp_Application.h | 3 +- src/SalomeApp/SalomeApp_NoteBookDlg.cxx | 201 ++++++++++++++++++++ src/SalomeApp/SalomeApp_NoteBookDlg.h | 98 ++++++++++ src/SalomeApp/resources/SalomeApp_msg_en.ts | 34 ++++ 6 files changed, 365 insertions(+), 4 deletions(-) create mode 100644 src/SalomeApp/SalomeApp_NoteBookDlg.cxx create mode 100644 src/SalomeApp/SalomeApp_NoteBookDlg.h diff --git a/src/SalomeApp/Makefile.am b/src/SalomeApp/Makefile.am index 33a8c5f4a..1efa60f51 100755 --- a/src/SalomeApp/Makefile.am +++ b/src/SalomeApp/Makefile.am @@ -49,7 +49,8 @@ salomeinclude_HEADERS = \ SalomeApp_StudyPropertiesDlg.h \ SalomeApp_CheckFileDlg.h \ SalomeApp_VisualState.h \ - SalomeApp_ExitDlg.h + SalomeApp_ExitDlg.h \ + SalomeApp_NoteBookDlg.h dist_libSalomeApp_la_SOURCES = \ SalomeApp_Module.cxx \ @@ -69,7 +70,8 @@ dist_libSalomeApp_la_SOURCES = \ SalomeApp_ListView.cxx \ SalomeApp_CheckFileDlg.cxx \ SalomeApp_VisualState.cxx \ - SalomeApp_ExitDlg.cxx + SalomeApp_ExitDlg.cxx \ + SalomeApp_NoteBookDlg.cxx MOC_FILES = \ SalomeApp_Application_moc.cxx \ @@ -80,7 +82,8 @@ MOC_FILES = \ SalomeApp_StudyPropertiesDlg_moc.cxx \ SalomeApp_ListView_moc.cxx \ SalomeApp_CheckFileDlg_moc.cxx \ - SalomeApp_ExitDlg_moc.cxx + SalomeApp_ExitDlg_moc.cxx \ + SalomeApp_NoteBookDlg_moc.cxx nodist_libSalomeApp_la_SOURCES = $(MOC_FILES) diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 3dc0710f0..f9757e875 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -30,6 +30,8 @@ #include "SalomeApp_VisualState.h" #include "SalomeApp_StudyPropertiesDlg.h" #include "SalomeApp_LoadStudiesDlg.h" +#include "SalomeApp_NoteBookDlg.h" + #include "SalomeApp_ExitDlg.h" #include @@ -235,6 +237,11 @@ void SalomeApp_Application::createActions() tr( "MEN_DESK_FILE_DUMP_STUDY" ), tr( "PRP_DESK_FILE_DUMP_STUDY" ), Qt::CTRL+Qt::Key_D, desk, false, this, SLOT( onDumpStudy() ) ); + //! NoteBook + createAction(NoteBookId, tr( "TOT_DESK_FILE_NOTEBOOK" ), QIcon(), + tr( "MEN_DESK_FILE_NOTEBOOK" ), tr( "PRP_DESK_FILE_NOTEBOOK" ), + Qt::CTRL+Qt::Key_B, desk, false, this, SLOT(onNoteBook())); + //! Load script createAction( LoadScriptId, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), QIcon(), tr( "MEN_DESK_FILE_LOAD_SCRIPT" ), tr( "PRP_DESK_FILE_LOAD_SCRIPT" ), @@ -272,6 +279,7 @@ void SalomeApp_Application::createActions() createMenu( FileLoadId, fileMenu, 0 ); //SRN: BugID IPAL9021, add a menu item "Load" createMenu( DumpStudyId, fileMenu, 10, -1 ); + createMenu( NoteBookId, fileMenu, 10, -1 ); createMenu( separator(), fileMenu, -1, 10, -1 ); createMenu( LoadScriptId, fileMenu, 10, -1 ); createMenu( separator(), fileMenu, -1, 10, -1 ); @@ -576,6 +584,11 @@ void SalomeApp_Application::updateCommandsStatus() if ( a ) a->setEnabled( activeStudy() ); + // Note Book + a = action(NoteBookId); + if( a ) + a->setEnabled( activeStudy() ); + // Load script menu a = action( LoadScriptId ); if ( a ) @@ -701,6 +714,17 @@ void SalomeApp_Application::onDumpStudy( ) } } +/*!Private SLOT. On NoteBook*/ +void SalomeApp_Application::onNoteBook() +{ + SalomeApp_Study* appStudy = dynamic_cast( activeStudy() ); + if ( appStudy ) { + _PTR(Study) aStudy = appStudy->studyDS(); + SalomeApp_NoteBookDlg aDlg(desktop(),aStudy); + aDlg.exec(); + } +} + /*!Private SLOT. On load script.*/ void SalomeApp_Application::onLoadScript( ) { diff --git a/src/SalomeApp/SalomeApp_Application.h b/src/SalomeApp/SalomeApp_Application.h index c7c01846e..6ae8220e0 100644 --- a/src/SalomeApp/SalomeApp_Application.h +++ b/src/SalomeApp/SalomeApp_Application.h @@ -62,7 +62,7 @@ class SALOMEAPP_EXPORT SalomeApp_Application : public LightApp_Application public: enum { MenuToolsId = 5 }; enum { DumpStudyId = LightApp_Application::UserID, LoadScriptId, PropertiesId, - CatalogGenId, RegDisplayId, SaveGUIStateId, FileLoadId, UserID }; + CatalogGenId, RegDisplayId, SaveGUIStateId, FileLoadId, NoteBookId, UserID }; protected: enum { OpenRefresh = LightApp_Application::OpenReload + 1 }; @@ -139,6 +139,7 @@ private slots: void onDblClick( SUIT_DataObject* ); void onProperties(); void onDumpStudy(); + void onNoteBook(); void onLoadScript(); void onDeleteGUIState(); diff --git a/src/SalomeApp/SalomeApp_NoteBookDlg.cxx b/src/SalomeApp/SalomeApp_NoteBookDlg.cxx new file mode 100644 index 000000000..b4e551677 --- /dev/null +++ b/src/SalomeApp/SalomeApp_NoteBookDlg.cxx @@ -0,0 +1,201 @@ +// Copyright (C) 2008 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// 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. +// +// 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: SalomeApp_NoteBookDlg.cxx +// Author : Roman NIKOLAEV, Open CASCADE S.A.S. +// Module : GUI + +#include "SalomeApp_NoteBookDlg.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace std; + +#define DEFAULT_MARGIN 11 +#define DEFAULT_SPACING 6 +#define SPACER_SIZE 30 +#define COLUMN_SIZE 175 + + +/////////////////////////////////////////////////////////////////////////// +// NoteBook_TableRow class // +/////////////////////////////////////////////////////////////////////////// +NoteBook_TableRow::NoteBook_TableRow(QWidget* parent): + QWidget(parent), + myRowHeader(new QTableWidgetItem()), + myVariableName(new QTableWidgetItem()), + myVariableValue(new QTableWidgetItem()) +{ +} + +NoteBook_TableRow::~NoteBook_TableRow() +{ +} + +void NoteBook_TableRow::AddToTable(QTableWidget *theTable) +{ + int aPosition = theTable->rowCount(); + int aRowCount = aPosition+1; + theTable->setRowCount(aRowCount); + myRowHeader->setText(QString::number(aRowCount)); + + theTable->setVerticalHeaderItem(aPosition,myRowHeader); + theTable->setItem(aPosition,0,myVariableName); + theTable->setItem(aPosition,1,myVariableValue); +} + +void NoteBook_TableRow::setEditable(bool enable) +{ + +} + +void NoteBook_TableRow::SetName(const QString theName) +{ + myVariableName->setText(theName); +} +void NoteBook_TableRow::SetValue(const QString theValue) +{ + myVariableValue->setText(theValue); +} + +/////////////////////////////////////////////////////////////////////////// +// NoteBook_Table class // +/////////////////////////////////////////////////////////////////////////// +NoteBook_Table::NoteBook_Table(QWidget * parent) + :QTableWidget(parent) +{ + setColumnCount(2); + + //Add Headers Columns + QFont aFont = QFont( "Liberation Sans", 10); + aFont.setBold(true); + + //"Name" column + QTableWidgetItem * aNameHeader = new QTableWidgetItem(); + aNameHeader->setText(tr("VARNAME_COLUMN")); + aNameHeader->setFont(aFont); + setHorizontalHeaderItem(0,aNameHeader); + setColumnWidth ( 0, COLUMN_SIZE); + + //"Value" Column + QTableWidgetItem * aValueHeader = new QTableWidgetItem(); + aValueHeader->setText(tr("VARVALUE_COLUMN")); + aValueHeader->setFont(aFont); + setHorizontalHeaderItem(1,aValueHeader); + setColumnWidth ( 1, COLUMN_SIZE); + setSortingEnabled(false); + + connect(this,SIGNAL(itemChanged(QTableWidgetItem*)),this,SLOT(onItemChanged(QTableWidgetItem*))); +} + +NoteBook_Table::~NoteBook_Table(){} + +void NoteBook_Table::Init(_PTR(Study) theStudy) +{ + + //Add all variables into the table + vector aVariables = theStudy->GetVariableNames(); + for(int iVar = 0; iVar < aVariables.size() ; iVar++ ) { + NoteBook_TableRow* aRow = new NoteBook_TableRow(this); + aRow->SetName(QString(aVariables[iVar].c_str())); + aRow->AddToTable(this); + } + + //Add empty row + + NoteBook_TableRow* aRow = new NoteBook_TableRow(this); + aRow->AddToTable(this); +} + +void NoteBook_Table::onItemChanged(QTableWidgetItem* theItem) +{ + +} + + +/////////////////////////////////////////////////////////////////////////// +// SalomeApp_NoteBookDlg class // +/////////////////////////////////////////////////////////////////////////// +SalomeApp_NoteBookDlg::SalomeApp_NoteBookDlg(QWidget * parent, _PTR(Study) theStudy): + QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), + myStudy(theStudy) +{ + setModal(true); + setObjectName("SalomeApp_NoteBookDlg"); + setWindowTitle(tr("NOTEBOOK_TITLE")); + QGridLayout* aLayout = new QGridLayout(this); + aLayout->setMargin(DEFAULT_MARGIN); + aLayout->setSpacing(DEFAULT_SPACING); + + //Table + myTable = new NoteBook_Table(this); + aLayout->addWidget(myTable, 0, 0, 1, 5); + + //Buttons + myOkBtn = new QPushButton(tr("BUT_OK")); + aLayout->addWidget(myOkBtn, 1, 0, 1, 1); + + myApplyBtn = new QPushButton(tr("BUT_APPLY")); + aLayout->addWidget(myApplyBtn, 1, 1, 1, 1); + + myUpdateStudyBtn = new QPushButton(tr("BUT_UPDATE_STUDY")); + aLayout->addWidget(myUpdateStudyBtn, 1, 2, 1, 1); + + + QSpacerItem* spacer = + new QSpacerItem(SPACER_SIZE, SPACER_SIZE, QSizePolicy::Expanding, QSizePolicy::Minimum); + aLayout->addItem(spacer, 1, 3, 1, 1); + + + myCancelBtn = new QPushButton(tr("BUT_CANCEL")); + aLayout->addWidget(myCancelBtn, 1, 4, 1, 1); + + connect( myOkBtn, SIGNAL(clicked()), this, SLOT(onOK()) ); + connect( myApplyBtn, SIGNAL(clicked()), this, SLOT(onApply()) ); + connect( myUpdateStudyBtn, SIGNAL(clicked()), this, SLOT(onUpdateStudy()) ); + connect( myCancelBtn, SIGNAL(clicked()), this, SLOT(reject()) ); + + myTable->Init(myStudy); +} + + +SalomeApp_NoteBookDlg::~SalomeApp_NoteBookDlg(){} + +void SalomeApp_NoteBookDlg::onOK() +{ + +} + +void SalomeApp_NoteBookDlg::onApply() +{ + +} + +void SalomeApp_NoteBookDlg::onUpdateStudy() +{ + +} diff --git a/src/SalomeApp/SalomeApp_NoteBookDlg.h b/src/SalomeApp/SalomeApp_NoteBookDlg.h new file mode 100644 index 000000000..fc0f33480 --- /dev/null +++ b/src/SalomeApp/SalomeApp_NoteBookDlg.h @@ -0,0 +1,98 @@ +// Copyright (C) 2008 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// 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. +// +// 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: SalomeApp_NoteBookDlg.h +// Author : Roman NIKOLAEV, Open CASCADE S.A.S. +// Module : GUI + +#ifndef SALOMEAPP_NOTEBOOKDLG_H +#define SALOMEAPP_NOTEBOOKDLG_H + +#include "SalomeApp.h" + +#include "SALOMEDSClient_ClientFactory.hxx" +#include CORBA_SERVER_HEADER(SALOMEDS) + +#include +#include + + +class QWidget; +class QPushButton; +class QTableWidgetItem; + + +class SALOMEAPP_EXPORT NoteBook_TableRow : public QWidget +{ + public: + NoteBook_TableRow(QWidget* parent=0); + virtual ~NoteBook_TableRow(); + + void setEditable(bool enable); + void AddToTable(QTableWidget *theTable); + + void SetName(const QString theName); + void SetValue(const QString theValue); + + private: + QTableWidgetItem* myRowHeader; + QTableWidgetItem* myVariableName; + QTableWidgetItem* myVariableValue; + +}; + +class SALOMEAPP_EXPORT NoteBook_Table : public QTableWidget +{ + Q_OBJECT + public: + NoteBook_Table(QWidget * parent = 0); + virtual ~NoteBook_Table(); + + void Init(_PTR(Study) theStudy); + + public slots: + void onItemChanged(QTableWidgetItem* theItem); + + private: + bool isInitialized; +}; + +class SALOMEAPP_EXPORT SalomeApp_NoteBookDlg : public QDialog +{ + Q_OBJECT + public: + SalomeApp_NoteBookDlg(QWidget * parent , _PTR(Study) theStudy); + virtual ~SalomeApp_NoteBookDlg(); + + public slots: + void onOK(); + void onApply(); + void onUpdateStudy(); + + private: + NoteBook_Table* myTable; + QPushButton* myOkBtn; + QPushButton* myApplyBtn; + QPushButton* myCancelBtn; + QPushButton* myUpdateStudyBtn; + + _PTR(Study) myStudy; + +}; + +#endif //SALOMEAPP_NOTEBOOKDLG_H diff --git a/src/SalomeApp/resources/SalomeApp_msg_en.ts b/src/SalomeApp/resources/SalomeApp_msg_en.ts index 822063b55..ebb4d0508 100644 --- a/src/SalomeApp/resources/SalomeApp_msg_en.ts +++ b/src/SalomeApp/resources/SalomeApp_msg_en.ts @@ -241,6 +241,18 @@ Do you want to reload it ? PRP_DESK_FILE_DUMP_STUDY Dumps study to the python script + + TOT_DESK_FILE_NOTEBOOK + Open Notebook + + + MEN_DESK_FILE_NOTEBOOK + Note&book + + + PRP_DESK_FILE_NOTEBOOK + Open Notebook + TOT_DESK_PROPERTIES Study properties @@ -328,4 +340,26 @@ Do you want to reload it ? Shutdown standalone servers + + NoteBook_Table + + VARNAME_COLUMN + Variable Name + + + VARVALUE_COLUMN + Variable Value + + + + SalomeApp_NoteBookDlg + + NOTEBOOK_TITLE + Salome NoteBook + + + BUT_UPDATE_STUDY + Update Studyy + + -- 2.39.2