My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
qucs.h
Go to the documentation of this file.
1 /***************************************************************************
2  qucs.h
3  --------
4  begin : Thu Aug 28 2003
5  copyright : (C) 2003 by Michael Margraf
6  email : michael.margraf@alumni.tu-berlin.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QUCS_H
19 #define QUCS_H
20 
21 #include <qmainwindow.h>
22 #include <qstring.h>
23 #include <qdir.h>
24 
25 class QucsDoc;
26 class Schematic;
27 class SimMessage;
28 class MouseActions;
29 class SearchDialog;
30 class QLabel;
31 class QAction;
32 class QPrinter;
33 class QToolBar;
34 class QLineEdit;
35 class QComboBox;
36 class QTabWidget;
37 class QPopupMenu;
38 class QListBox;
39 class QListBoxItem;
40 class QListView;
41 class QListViewItem;
42 class QIconView;
43 class QIconViewItem;
44 class VTabbedDockWidget;
45 class VTabWidget;
46 class OctaveWindow;
47 
48 typedef bool (Schematic::*pToggleFunc) ();
49 typedef void (MouseActions::*pMouseFunc) (Schematic*, QMouseEvent*);
50 typedef void (MouseActions::*pMouseFunc2) (Schematic*, QMouseEvent*, float, float);
51 
52 extern QDir QucsWorkDir;
53 extern QDir QucsHomeDir;
54 
55 
56 class QucsApp : public QMainWindow {
57  Q_OBJECT
58 public:
59  QucsApp();
60  ~QucsApp();
61 
62  bool closeAllFiles();
63  static int testFile(const QString&);
64  bool gotoPage(const QString&); // to load a document
65  QucsDoc *getDoc(int No=-1);
66  QucsDoc* findDoc (QString, int * Pos = 0);
67  QString fileType (const QString&);
68 
69  QString ProjName; // name of the project, that is open
70 
71  QLineEdit *editText; // for edit component properties on schematic
72  SearchDialog *SearchDia; // global in order to keep values
73 
74  // current mouse methods
75  void (MouseActions::*MouseMoveAction) (Schematic*, QMouseEvent*);
76  void (MouseActions::*MousePressAction) (Schematic*, QMouseEvent*, float, float);
77  void (MouseActions::*MouseDoubleClickAction) (Schematic*, QMouseEvent*);
78  void (MouseActions::*MouseReleaseAction) (Schematic*, QMouseEvent*);
79 
80 protected:
81  void closeEvent(QCloseEvent*);
82 
83 public slots:
84  void slotFileNew(); // generate a new schematic in the view TabBar
85  void slotTextNew(); // generate a new text editor in the view TabBar
86  void slotFileOpen(); // open a document
87  void slotFileSave(); // save a document
88  void slotFileSaveAs(); // save a document under a different filename
89  void slotFileSaveAll(); // save all open documents
90  void slotFileClose(); // close the actual file
91  void slotSymbolEdit(); // edit the symbol for the schematic
92  void slotFileSettings();// open dialog to change file settings
93  void slotFilePrint(); // print the current file
94  void slotFilePrintFit();// Print and fit to page
95  void slotFileQuit(); // exits the application
96  void slotEditCut(); // put marked object into clipboard and delete it
97  void slotEditCopy(); // put the marked object into the clipboard
98  void slotApplSettings();// open dialog to change application settings
99 
100  void slotIntoHierarchy();
101  void slotPopHierarchy();
102 
103  void slotShowAll();
104  void slotShowOne();
105  void slotZoomOut(); // Zoom out by 2
106 
107  void slotToPage();
108  void slotSelectComponent(QIconViewItem*);
109 
110  void slotEditElement();
111  void slotPowerMatching();
112  void slot2PortMatching();
113 
114  // for menu that appears by right click in content ListView
115  void slotShowContentMenu(QListViewItem*, const QPoint&, int);
116  void slotCMenuOpen();
117  void slotCMenuRename();
118  void slotCMenuDelete();
119  void slotCMenuDelGroup();
120 
121 private slots:
122  void slotMenuOpenProject();
123  void slotOpenProject(QListBoxItem*);
124  void slotMenuCloseProject();
125  void slotSelectSubcircuit(QListViewItem*);
126  void slotExpandContentList(QListViewItem*);
127  void slotOpenContent(QListViewItem*);
128  void slotSetCompView(int);
129  void slotProjNewButt();
130  void slotProjOpenButt();
131  void slotProjDelButt();
132  void slotMenuDelProject();
133  void slotChangeView(QWidget*);
134  void slotSimulate();
135  void slotAfterSimulation(int, SimMessage*);
136  void slotDCbias();
137  void slotChangePage(QString&, QString&);
138  void slotNextTab();
139  void slotHideEdit();
140 
141 signals:
142  void signalKillEmAll();
143 
144 public:
146  QTabWidget *DocumentTab;
147  QIconView *CompComps;
148 
149  // menu appearing by right mouse button click on content listview
150  QPopupMenu *ContentMenu;
151 
156  *symEdit, *intoH, *popH, *simulate, *dpl_sch, *undo, *redo, *dcbias;
157 
158  QAction *activeAction; // pointer to the action selected by the user
159 
160 private:
161  QPrinter *Printer; // printer is global (to remember the user settings)
162 
163 // ********* Widgets on the main area **********************************
164  VTabbedDockWidget *dock;
165  VTabWidget *TabView;
166  QDockWindow *octDock;
167  OctaveWindow *octave;
168 
169  QListBox *Projects;
170  QListView *Content;
171  QListViewItem *ConSchematics, *ConSources, *ConDisplays, *ConDatasets,
172  *ConOthers, *ConVerilog, *ConVerilogA, *ConOctave;
173 
174  QComboBox *CompChoose;
175 
176 // ********** Properties ************************************************
177  QPtrList<QString> HierarchyHistory; // keeps track of "go into subcircuit"
178  QString QucsFileFilter;
179 
180 // ********** Methods ***************************************************
181  void initView();
182  void initCursorMenu();
183  void initContentListView();
184 
185  void printCurrentDocument(bool);
186  bool saveFile(QucsDoc *Doc=0);
187  bool saveAs();
188  void readProjects();
189  void readProjectFiles();
190  void openProject(const QString&, const QString&);
191  bool deleteProject(const QString&, const QString&);
192  void updatePortNumber(QucsDoc*, int);
193  void fillComboBox(bool);
194  void switchSchematicDoc(bool);
195  void switchEditMode(bool);
196  void changeSchematicSymbolMode(Schematic*);
197  bool deleteDirectoryContent(QDir& Dir);
198  bool isTextDocument(QWidget *);
199 
200 
201 /* **************************************************
202  ***** The following methods are located in *****
203  ***** "qucs_init.cpp". *****
204  ************************************************** */
205 
206 public slots:
207  void slotShowWarnings();
208  void slotResetWarnings();
209  void printCursorPosition(int, int);
210 
211 private slots:
212  void slotViewToolBar(bool toggle); // toggle the toolbar
213  void slotViewStatusBar(bool toggle); // toggle the statusbar
214  void slotViewBrowseDock(bool toggle); // toggle the dock window
215  void slotViewOctaveDock(bool); // toggle the dock window
216  void slotToggleOctave(bool);
217  void slotToggleDock(bool);
218  void slotHelpAbout(); // shows an about dialog
219  void slotHelpAboutQt(); // shows the standard about dialog for Qt
220 
221 private:
222  void initActions(); // initializes all QActions of the application
223  void initMenuBar(); // creates the menu_bar and inserts the menuitems
224  void initToolBar(); // creates the toolbars
225  void initStatusBar(); // setup the statusbar
226 
227  QAction *helpAboutApp, *helpAboutQt, *viewToolBar, *viewStatusBar,
228  *viewBrowseDock, *viewOctaveDock;
229 
230  // menus contain the items of their menubar
231  QPopupMenu *fileMenu, *editMenu, *insMenu, *projMenu, *simMenu, *viewMenu,
232  *helpMenu, *alignMenu, *toolMenu;
233 
234  QToolBar *fileToolbar, *editToolbar, *viewToolbar, *workToolbar;
235 
236  QAccel *mainAccel; // to set more than one key to one action
237  QLabel *WarningLabel, *PositionLabel; // labels in status bar
238 
239 
240 
241 /* **************************************************
242  ***** The following methods are located in *****
243  ***** "qucs_actions.cpp". *****
244  ************************************************** */
245 
246 public:
247  void editFile(const QString&);
248 
258 
259 public slots:
260  void slotEditRotate(bool); // rotate the selected items
261  void slotEditMirrorX(bool); // mirror the selected items about X axis
262  void slotEditMirrorY(bool); // mirror the selected items about Y axis
263  void slotEditPaste(bool); // paste the clipboard into the document
264  void slotEditDelete(bool); // delete the selected items
265  void slotInsertEquation(bool);
266  void slotInsertGround(bool);
267  void slotInsertPort(bool);
268  void slotInsertEntity();
269  void slotSetWire(bool);
270  void slotSelect(bool);
271  void slotEditActivate(bool);
272  void slotInsertLabel(bool);
273  void slotSetMarker(bool);
274  void slotOnGrid(bool); // set selected elements on grid
275  void slotMoveText(bool); // move property text of components
276  void slotZoomIn(bool);
277  void slotEditUndo(); // makes the last operation undone
278  void slotEditRedo(); // makes the last undo undone
279  void slotEditFind(); // searches for a piece of text
280  void slotEditFindAgain(); // searches for the same piece of text again
281  void slotAlignTop(); // align selected elements with respect to top
282  void slotAlignBottom(); // align selected elements with respect to bottom
283  void slotAlignLeft(); // align selected elements with respect to left
284  void slotAlignRight(); // align selected elements with respect to right
285  void slotDistribHoriz();// distribute horizontally selected elements
286  void slotDistribVert(); // distribute vertically selected elements
287  void slotCenterHorizontal();
288  void slotCenterVertical();
289  void slotSelectAll();
290  void slotSelectMarker();
291  void slotShowLastMsg();
292  void slotShowLastNetlist();
293  void slotCallEditor();
294  void slotCallFilter();
295  void slotCallLine();
296  void slotCallLibrary();
297  void slotCallMatch();
298  void slotCallAtt();
299  void slotHelpIndex(); // shows a HTML docu: Help Index
300  void slotGettingStarted(); // shows a HTML docu: Getting started
301  void slotChangeProps();
302  void slotAddToProject();
303  void slotApplyCompText();
304 
305 private slots:
306  void slotCursorLeft();
307  void slotCursorRight();
308  void slotCursorUp();
309  void slotCursorDown();
310  void slotResizePropEdit(const QString&);
311  void slotCreateLib();
312  void slotImportData();
313  void slotExportGraphAsCsv();
314  void slotCreatePackage();
315  void slotExtractPackage();
316 
317 private:
318  void showHTML(const QString&);
319  bool performToggleAction(bool, QAction*, pToggleFunc, pMouseFunc, pMouseFunc2);
320  friend class SaveDialog;
321 };
322 #endif