pqPythonScriptEditor.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: pqPythonScriptEditor.h
5 
6  Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
7  All rights reserved.
8 
9  ParaView is a free software; you can redistribute it and/or modify it
10  under the terms of the ParaView license version 1.2.
11 
12  See License_v1.2.txt for the full ParaView license.
13  A copy of this license can be obtained by contacting
14  Kitware Inc.
15  28 Corporate Drive
16  Clifton Park, NY 12065
17  USA
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
23 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 =========================================================================*/
32 #ifndef _pqPythonScriptEditor_h
33 #define _pqPythonScriptEditor_h
34 
35 #include "pqPythonModule.h"
36 #include <QMainWindow>
37 
38 class QAction;
39 class QMenu;
40 class QTextEdit;
41 
42 class pqPythonManager;
44 
45 class PQPYTHON_EXPORT pqPythonScriptEditor : public QMainWindow
46 {
47  Q_OBJECT
48 
49 public:
50  typedef QMainWindow Superclass;
51  pqPythonScriptEditor(QWidget* parent = 0);
52 
53  void setSaveDialogDefaultDirectory(const QString& dir);
54  void setPythonManager(pqPythonManager* manager);
55 
56  /*
57  * Scroll the editor to the bottom of the scroll area
58  */
59  void scrollToBottom();
60 
61 public Q_SLOTS:
62 
63  void open(const QString& filename);
64  void setText(const QString& text);
65 
66  // Returns true if the new file was created. If the user was prompted to save
67  // data before creating a new file and clicked cancel, then no new file will
68  // be created and this method returns false.
69  bool newFile();
70 
71 Q_SIGNALS:
72  void fileSaved();
73 
74 protected:
75  void closeEvent(QCloseEvent* event) override;
76 
77 private Q_SLOTS:
78  void open();
79  bool save();
80  bool saveAs();
81  bool saveAsMacro();
82  void documentWasModified();
83 
84 private:
85  void createActions();
86  void createMenus();
87  void createStatusBar();
88  void readSettings();
89  void writeSettings();
90  bool maybeSave();
91  void loadFile(const QString& fileName);
92  bool saveFile(const QString& fileName);
93  void setCurrentFile(const QString& fileName);
94  QString strippedName(const QString& fullFileName);
95 
96  QTextEdit* TextEdit;
97  QString CurrentFile;
98  QString DefaultSaveDirectory;
99 
100  QMenu* fileMenu;
101  QMenu* editMenu;
102  QMenu* helpMenu;
103  QAction* newAct;
104  QAction* openAct;
105  QAction* saveAct;
106  QAction* saveAsAct;
107  QAction* saveAsMacroAct;
108  QAction* exitAct;
109  QAction* cutAct;
110  QAction* copyAct;
111  QAction* pasteAct;
112 
113  pqPythonManager* pythonManager;
114 
115  pqPythonSyntaxHighlighter* SyntaxHighlighter;
116 };
117 
118 #endif
#define PQPYTHON_EXPORT
void save(Archiver &ar, const vtkUnicodeString &str, const unsigned int vtkNotUsed(version))
pqPythonManager is a class to facilitate the use of a python interpreter by various paraview GUI comp...
This class is a helper object to attach to a QTextEdit to add Python syntax highlighting to the text ...