SMILX  1.01
milxQtWindow.h
1 /*=========================================================================
2  The Software is copyright (c) Commonwealth Scientific and Industrial Research Organisation (CSIRO)
3  ABN 41 687 119 230.
4  All rights reserved.
5 
6  Licensed under the CSIRO BSD 3-Clause License
7  You may not use this file except in compliance with the License.
8  You may obtain a copy of the License in the file LICENSE.md or at
9 
10  https://stash.csiro.au/projects/SMILI/repos/smili/browse/license.txt
11 
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  See the License for the specific language governing permissions and
16  limitations under the License.
17 =========================================================================*/
18 #ifndef MILXQTSUBWINDOW_H
19 #define MILXQTSUBWINDOW_H
20 
21 #include <QtGui/QtGui>
22 //VTK Headers
23 #include <QVTKWidget.h>
24 #include <vtkSmartPointer.h>
25 #include <vtkPointPicker.h>
26 //milxQt Specific
27 #include "milxQtAliases.h"
28 #include "milxQtConsole.h"
29 
40 class MILXQT_EXPORT milxQtWindow : public QVTKWidget
41 {
42  Q_OBJECT
43 
44 public:
49  milxQtWindow(QWidget *theParent = 0);
54  virtual ~milxQtWindow();
55 
56 public slots:
57  //Naming
62  void setName(const QString filename);
67  inline QString getName()
68  {
69  return name;
70  }
75  void rename();
80  inline QString strippedName()
81  {
82  return QFileInfo(name).fileName();
83  }
88  inline QString strippedBaseName()
89  {
90  return QFileInfo(name).baseName();
91  }
98  virtual inline QString strippedNamePrefix()
99  {
100  return prefix + QFileInfo(name).fileName();
101  }
106  inline void setNamePrefix(const QString newPrefix)
107  {
108  prefix = newPrefix;
109  }
110 
115  inline void addToContextMenu(QAction *act)
116  {
117  actionsToAdd.append(act);
118  }
123  inline void appendToContextMenu(QAction *act)
124  {
125  actionsToAppend.append(act);
126  }
131  inline void addToContextMenu(QMenu *newMenu)
132  {
133  addMenuToContextMenu(newMenu);
134  }
139  inline void addExtensionAction(QAction *act)
140  {
141  extActionsToAdd.append(act);
142  }
147  inline void addMenuToContextMenu(QMenu *newMenu)
148  {
149  menusToAdd.append(newMenu);
150  }
155  inline void appendMenuToContextMenu(QMenu *newMenu)
156  {
157  menusToAppend.append(newMenu);
158  }
159 
164  virtual void copyToContextMenu(QMenu *copyMenu);
165 
170  inline void setVerboseMode(bool verbose)
171  {
172  verboseMode = verbose;
173  }
178  inline void setDeletableOnClose(bool delOnClose)
179  {
180  deletableOnClose = delOnClose;
181  setAttribute(Qt::WA_DeleteOnClose, deletableOnClose);
182  }
187  inline bool isDeletableOnClose()
188  {
189  return deletableOnClose;
190  }
195  inline void setConsole(milxQtConsole *con)
196  {
197  consoleAssigned = true;
198  console = con;
199  }
200 
201  //Connectors
206  inline void consumeVTKEvent(vtkObject * obj, unsigned long, void * client_data, void *, vtkCommand * command)
207  {
208  command->AbortFlagOn();
209  }
213  inline void updateQtEvents()
214  {
215  qApp->processEvents();
216  }
217 
218 signals:
223  void closing(QWidget *win);
228  void nameChanged(const QString newName);
233  void working(int value);
238  void done(int value);
239 
240 protected:
241  QString name;
242  QString prefix;
243 
244  //Flags
245  bool verboseMode;
248 
249  //Context Menus
250  QMenu *contextMenu;
251  QList<QAction*> actionsToAdd;
252  QList<QAction*> actionsToAppend;
253  QList<QAction*> extActionsToAdd;
254  QList<QMenu*> menusToAdd;
255  QList<QMenu*> menusToAppend;
256 
258 
259  //Internal Members
264  void createConnections();
269  void closeEvent(QCloseEvent *clEvent);
274  void printError(QString msg);
279  void printWarning(QString msg);
284  void printDebug(QString msg);
289  void printInfo(QString msg);
290 
291 private:
292 
293 };
294 
295 #endif // MILXQTSUBWINDOW_H
void addToContextMenu(QMenu *newMenu)
Adds the menu to the context menu. Connections are assumed to be made before hand.
Definition: milxQtWindow.h:131
QList< QAction * > extActionsToAdd
Extension actions to add.
Definition: milxQtWindow.h:253
This file defines all the defines, aliases and frequently used functions and variables.
void updateQtEvents()
Update the Qt events, used to keep UI responsive.
Definition: milxQtWindow.h:213
virtual QString strippedNamePrefix()
Returns the stripped (path removed) name of the data with "Generic" prefix.
Definition: milxQtWindow.h:98
void setNamePrefix(const QString newPrefix)
Sets the prefix of the name of the data provided.
Definition: milxQtWindow.h:106
QMenu * contextMenu
Context Menu.
Definition: milxQtWindow.h:250
QString strippedName()
Returns the stripped (path removed) name of the data.
Definition: milxQtWindow.h:80
void setVerboseMode(bool verbose)
Verbose mode for message output.
Definition: milxQtWindow.h:170
This class represents the MILX Qt Window Display object using QVTK.
Definition: milxQtWindow.h:40
void setDeletableOnClose(bool delOnClose)
Set if the window deletable on close. Default is true.
Definition: milxQtWindow.h:178
QList< QMenu * > menusToAdd
Context Menu&#39;s to add.
Definition: milxQtWindow.h:254
bool consoleAssigned
Console assigned for output?
Definition: milxQtWindow.h:247
QString prefix
Prefix of the data.
Definition: milxQtWindow.h:242
void addToContextMenu(QAction *act)
Adds (prepends) the action to the context menu. Connections are assumed to be made before hand...
Definition: milxQtWindow.h:115
void appendToContextMenu(QAction *act)
Adds (appends) the action to the context menu. Connections are assumed to be made before hand...
Definition: milxQtWindow.h:123
void setConsole(milxQtConsole *con)
Set the console for log output.
Definition: milxQtWindow.h:195
void addExtensionAction(QAction *act)
Adds (in extension section) the action as an extension action. Connections are assumed to be made bef...
Definition: milxQtWindow.h:139
void appendMenuToContextMenu(QMenu *newMenu)
Adds (appends) the menu to the context menu. Connections are assumed to be made before hand...
Definition: milxQtWindow.h:155
#define MILXQT_EXPORT
Define Windows DLL importing.
Definition: milxQtAliases.h:80
bool deletableOnClose
Delete on close allowed? Allowed by default.
Definition: milxQtWindow.h:246
bool verboseMode
Verbose message output mode.
Definition: milxQtWindow.h:245
QList< QAction * > actionsToAppend
Context actions to append.
Definition: milxQtWindow.h:252
QString getName()
Returns the name of the data.
Definition: milxQtWindow.h:67
bool isDeletableOnClose()
Is the window deletable on close?
Definition: milxQtWindow.h:187
QList< QAction * > actionsToAdd
Context actions to add.
Definition: milxQtWindow.h:251
QString strippedBaseName()
Returns the stripped (path removed) base (no suffix) name of the data.
Definition: milxQtWindow.h:88
void addMenuToContextMenu(QMenu *newMenu)
Adds (prepends) the menu to the context menu. Connections are assumed to be made before hand...
Definition: milxQtWindow.h:147
milxQtConsole * console
Console for log outputs.
Definition: milxQtWindow.h:257
A console (tabbed) widget class for displaying information such as logs, terminals and consoles...
Definition: milxQtConsole.h:34
void consumeVTKEvent(vtkObject *obj, unsigned long, void *client_data, void *, vtkCommand *command)
Consume the event so that VTK interactor style doesn&#39;t get it. Safeguard for if remove observer direc...
Definition: milxQtWindow.h:206
QList< QMenu * > menusToAppend
Context Menu&#39;s to append.
Definition: milxQtWindow.h:255
QString name
Name of the data.
Definition: milxQtWindow.h:241