]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Start Dump Python extension task.
authorrnv <rnv@opencascade.com>
Tue, 28 Oct 2008 11:33:12 +0000 (11:33 +0000)
committerrnv <rnv@opencascade.com>
Tue, 28 Oct 2008 11:33:12 +0000 (11:33 +0000)
src/SalomeApp/Makefile.am
src/SalomeApp/SalomeApp_Application.cxx
src/SalomeApp/SalomeApp_Application.h
src/SalomeApp/SalomeApp_NoteBookDlg.cxx [new file with mode: 0644]
src/SalomeApp/SalomeApp_NoteBookDlg.h [new file with mode: 0644]
src/SalomeApp/resources/SalomeApp_msg_en.ts

index 33a8c5f4a2f03c2021da2733708f02ab7227255b..1efa60f51a296eaa993477df6d4668427b51e36d 100755 (executable)
@@ -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)
 
index 3dc0710f08220030ab6735e9bdce66d662870e3d..f9757e8754971731bfd553c89a0f368e923f59b7 100644 (file)
@@ -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 <LightApp_Application.h>
@@ -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<SalomeApp_Study*>( activeStudy() );
+  if ( appStudy ) {
+    _PTR(Study) aStudy = appStudy->studyDS();
+    SalomeApp_NoteBookDlg aDlg(desktop(),aStudy);
+    aDlg.exec();
+  }
+}
+
 /*!Private SLOT. On load script.*/
 void SalomeApp_Application::onLoadScript( )
 {
index c7c01846ebe38ba9c6aea58743d1e9b87da96fcf..6ae8220e0dd2958887769fbcb2624efc2fe97ba0 100644 (file)
@@ -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 (file)
index 0000000..b4e5516
--- /dev/null
@@ -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 <QWidget>
+#include <QDialog>
+#include <QGridLayout>
+#include <QTableWidget>
+#include <QTableWidgetItem>
+#include <QPushButton>
+#include <QFont>
+
+#include <string>
+#include <vector>
+
+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<string> 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 (file)
index 0000000..fc0f334
--- /dev/null
@@ -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 <QDialog>
+#include <QTableWidget>
+
+
+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
index 822063b55119c1f293eb69a26d5137cda26a7498..ebb4d05084fa697181c9ae5544e5922ca5f28000 100644 (file)
@@ -241,6 +241,18 @@ Do you want to reload it ?</translation>
         <source>PRP_DESK_FILE_DUMP_STUDY</source>
         <translation>Dumps study to the python script</translation>
     </message>
+    <message>
+        <source>TOT_DESK_FILE_NOTEBOOK</source>
+        <translation>Open Notebook</translation>
+    </message>
+    <message>
+        <source>MEN_DESK_FILE_NOTEBOOK</source>
+        <translation>Note&amp;book</translation>
+    </message>
+    <message>
+        <source>PRP_DESK_FILE_NOTEBOOK</source>
+        <translation>Open Notebook</translation>
+    </message>
     <message>
         <source>TOT_DESK_PROPERTIES</source>
         <translation>Study properties</translation>
@@ -328,4 +340,26 @@ Do you want to reload it ?</translation>
         <translation>Shutdown standalone servers</translation>
     </message>
 </context>
+<context>
+    <name>NoteBook_Table</name>
+        <message>
+           <source>VARNAME_COLUMN</source>
+           <translation>Variable Name</translation>
+        </message>
+        <message>
+           <source>VARVALUE_COLUMN</source>
+           <translation>Variable Value</translation>
+       </message>
+</context>
+<context>
+    <name>SalomeApp_NoteBookDlg</name>
+        <message>
+           <source>NOTEBOOK_TITLE</source>
+           <translation>Salome NoteBook</translation>
+        </message>
+        <message>
+           <source>BUT_UPDATE_STUDY</source>
+           <translation>Update Study</translation>y
+       </message>
+</context>
 </TS>