1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: SalomeApp_NoteBook.h
21 // Author : Roman NIKOLAEV, Open CASCADE S.A.S.
24 #ifndef SALOMEAPP_NOTEBOOK_H
25 #define SALOMEAPP_NOTEBOOK_H
27 #include "SalomeApp.h"
29 #include "SALOMEDSClient_ClientFactory.hxx"
30 #include CORBA_SERVER_HEADER(SALOMEDS)
33 #include <QTableWidget>
38 class QTableWidgetItem;
41 struct NoteBoox_Variable
43 NoteBoox_Variable() {}
44 NoteBoox_Variable( const QString& theName, const QString& theValue )
53 typedef QMap< int, NoteBoox_Variable > VariableMap;
55 class SALOMEAPP_EXPORT NoteBook_TableRow : public QWidget
58 NoteBook_TableRow(int, NoteBook_Table* parentTable, QWidget* parent=0 );
59 virtual ~NoteBook_TableRow();
61 int GetIndex() const { return myIndex; }
63 void AddToTable(QTableWidget *theTable);
65 void SetName(const QString theName);
66 void SetValue(const QString theValue);
68 QString GetValue() const;
69 QString GetName() const;
74 QTableWidgetItem* GetVariableItem();
75 QTableWidgetItem* GetNameItem();
76 QTableWidgetItem* GetHeaderItem();
78 static bool IsRealValue(const QString theValue, double* theResult = 0);
79 static bool IsIntegerValue(const QString theValue, int* theResult = 0);
80 static bool IsBooleanValue(const QString theValue, bool* theResult = 0);
81 bool IsValidStringValue(const QString theName);
85 NoteBook_Table* myParentTable;
86 QTableWidgetItem* myRowHeader;
87 QTableWidgetItem* myVariableName;
88 QTableWidgetItem* myVariableValue;
91 class SALOMEAPP_EXPORT NoteBook_Table : public QTableWidget
95 NoteBook_Table(QWidget * parent = 0);
96 virtual ~NoteBook_Table();
99 static QString Variable2String(const std::string& theVarName);
101 bool IsValid() const;
103 void AddRow( const QString& theName = QString::null, const QString& theValue = QString::null );
105 NoteBook_TableRow* GetRowByItem(const QTableWidgetItem* theItem) const;
106 bool IsLastRow(const NoteBook_TableRow* aRow) const;
108 void RemoveSelected();
110 void SetProcessItemChangedSignalFlag(const bool enable);
111 bool GetProcessItemChangedSignalFlag()const;
113 bool IsUniqueName(const NoteBook_TableRow* theRow) const;
114 QList<NoteBook_TableRow*> GetRows() const;
116 const bool IsModified() const { return myIsModified; }
117 const QList<int>& GetRemovedRows() const { return myRemovedRows; }
118 const VariableMap& GetVariableMap() const { return myVariableMap; }
119 const VariableMap& GetVariableMapRef() const { return myVariableMapRef; }
120 void RenumberRowItems();
124 QList<NoteBook_TableRow*> myRows;
127 void onItemChanged(QTableWidgetItem* theItem);
130 int getUniqueIndex() const;
133 bool isProcessItemChangedSignal;
136 QList<int> myRemovedRows;
137 VariableMap myVariableMapRef;
138 VariableMap myVariableMap;
141 class SALOMEAPP_EXPORT SalomeApp_NoteBook : public QWidget
145 SalomeApp_NoteBook(QWidget * parent);
146 virtual ~SalomeApp_NoteBook();
150 QString getDumpedStudyName() { return myDumpedStudyName; }
151 void setDumpedStudyName(QString theName) { myDumpedStudyName = theName; }
153 QString getDumpedStudyScript() { return myDumpedStudyScript; }
154 void setDumpedStudyScript(QString theScript) { myDumpedStudyScript = theScript; }
156 bool isDumpedStudySaved() { return myIsDumpedStudySaved; }
157 void setIsDumpedStudySaved(bool isSaved) { myIsDumpedStudySaved = isSaved; }
162 void onUpdateStudy();
163 void onVarUpdate( QString theVarName );
166 NoteBook_Table* myTable;
167 QPushButton* myRemoveButton;
168 QPushButton* myUpdateStudyBtn;
170 QString myDumpedStudyScript; // path to script of dumped study
171 QString myDumpedStudyName;
172 bool myIsDumpedStudySaved;
175 #endif //SALOMEAPP_NOTEBOOK_H