Qucs-GUI  0.0.19
/home/travis/build/Qucs/qucs/qucs/qucs/qucs.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                                    qucs.h
00003                                   --------
00004     begin                : Thu Aug 28 2003
00005     copyright            : (C) 2003 by Michael Margraf
00006     email                : michael.margraf@alumni.tu-berlin.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef QUCS_H
00019 #define QUCS_H
00020 
00021 #include <QMainWindow>
00022 #include <QString>
00023 #include <QHash>
00024 #include <QStack>
00025 
00026 class QucsDoc;
00027 class Schematic;
00028 class SimMessage;
00029 class MouseActions;
00030 class SearchDialog;
00031 class OctaveWindow;
00032 class MessageDock;
00033 class ProjectView;
00034 
00035 class QLabel;
00036 class QAction;
00037 class QLineEdit;
00038 class QComboBox;
00039 class QTabWidget;
00040 class QDir;
00041 class QMouseEvent;
00042 class QCloseEvent;
00043 class QMenu;
00044 class QToolBar;
00045 class QSettings;
00046 class QListWidgetItem;
00047 class QTreeWidget;
00048 class QTreeWidgetItem;
00049 class QListWidget;
00050 class QShortcut;
00051 class QListView;
00052 class QFileSystemModel;
00053 class QModelIndex;
00054 class QPushButton;
00055 
00056 typedef bool (Schematic::*pToggleFunc) ();
00057 typedef void (MouseActions::*pMouseFunc) (Schematic*, QMouseEvent*);
00058 typedef void (MouseActions::*pMouseFunc2) (Schematic*, QMouseEvent*, float, float);
00059 
00060 class QucsApp : public QMainWindow {
00061   Q_OBJECT
00062 public:
00063   QucsApp();
00064  ~QucsApp();
00065   bool closeAllFiles();
00066   bool gotoPage(const QString&);   // to load a document
00067   QucsDoc *getDoc(int No=-1);
00068   QucsDoc* findDoc (QString, int * Pos = 0);
00069   QString fileType (const QString&);
00070 
00071   QString ProjName;   // name of the project, that is open
00072   QHash<QString,QString> schNameHash; // QHash for the schematic files lookup
00073   QHash<QString,QString> spiceNameHash; // QHash for the spice files lookup
00074 
00075   QLineEdit *editText;  // for edit component properties on schematic
00076   SearchDialog *SearchDia;  // global in order to keep values
00077 
00078   // current mouse methods
00079   void (MouseActions::*MouseMoveAction) (Schematic*, QMouseEvent*);
00080   void (MouseActions::*MousePressAction) (Schematic*, QMouseEvent*, float, float);
00081   void (MouseActions::*MouseDoubleClickAction) (Schematic*, QMouseEvent*);
00082   void (MouseActions::*MouseReleaseAction) (Schematic*, QMouseEvent*);
00083 
00084 protected:
00085   void closeEvent(QCloseEvent*);
00086 
00087 public slots:
00088   void slotFileNew();     // generate a new schematic in the view TabBar
00089   void slotTextNew();     // generate a new text editor in the view TabBar
00090   void slotFileOpen();    // open a document
00091   void slotFileSave();    // save a document
00092   void slotFileSaveAs();  // save a document under a different filename
00093   void slotFileSaveAll(); // save all open documents
00094   void slotFileClose();   // close the actual file
00095   void slotFileExamples();   // show the examples in a file browser
00096   void slotHelpTutorial();   // Open a pdf tutorial
00097   void slotHelpReport();   // Open a pdf report
00098   void slotHelpTechnical();   // Open a pdf technical document
00099   void slotFileClose (int); // close the file with given index
00100   void slotSymbolEdit();  // edit the symbol for the schematic
00101   void slotFileSettings();// open dialog to change file settings
00102   void slotFilePrint();   // print the current file
00103   void slotFilePrintFit();// Print and fit to page
00104   void slotFileQuit();    // exits the application
00105   void slotApplSettings();// open dialog to change application settings
00106   void slotRefreshSchPath(); // refresh the schematic path hash
00107 
00108   void slotIntoHierarchy();
00109   void slotPopHierarchy();
00110 
00111   void slotShowAll();
00112   void slotShowOne();
00113   void slotZoomOut(); // Zoom out by 2
00114 
00115   void slotToPage();
00116   void slotSelectComponent(QListWidgetItem*);
00117   void slotSearchComponent(const QString &);
00118   void slotSearchClear();
00119 
00120   void slotEditElement();
00121   void slotPowerMatching();
00122   void slot2PortMatching();
00123 
00124   // for menu that appears by right click in content ListView
00125   void slotShowContentMenu(const QPoint &);
00126 
00127   void slotCMenuOpen();
00128   void slotCMenuCopy();
00129   void slotCMenuRename();
00130   void slotCMenuDelete();
00131   void slotCMenuInsert();
00132 
00133   void slotUpdateTreeview();
00134 private slots:
00135   void slotMenuProjOpen();
00136   void slotMenuProjClose();
00137   void slotMenuProjDel();
00138   void slotListProjOpen(const QModelIndex &);
00139   void slotSelectSubcircuit(const QModelIndex &);
00140   void slotSelectLibComponent(QTreeWidgetItem*);
00141   void slotOpenContent(const QModelIndex &);
00142   void slotSetCompView(int);
00143   void slotButtonProjNew();
00144   void slotButtonProjOpen();
00145   void slotButtonProjDel();
00146   void slotChangeView(QWidget*);
00147   void slotSimulate();
00148   void slotAfterSimulation(int, SimMessage*);
00149   void slotDCbias();
00150   void slotChangePage(QString&, QString&);
00151   void slotHideEdit();
00152   void slotFileChanged(bool);
00153 signals:
00154   void signalKillEmAll();
00155 
00156 public:
00157   MouseActions *view;
00158   QTabWidget *DocumentTab;
00159   QListWidget *CompComps;
00160   QTreeWidget *libTreeWidget;
00161 
00162   // menu appearing by right mouse button click on content listview
00163   QMenu *ContentMenu;
00164 
00165   // corresponding actions
00166   QAction *ActionCMenuOpen, *ActionCMenuCopy, *ActionCMenuRename, *ActionCMenuDelete, *ActionCMenuInsert;
00167 
00168   QAction *fileNew, *textNew, *fileNewDpl, *fileOpen, *fileSave, *fileSaveAs,
00169           *fileSaveAll, *fileClose, *fileExamples, *fileSettings, *filePrint, *fileQuit,
00170           *projNew, *projOpen, *projDel, *projClose, *applSettings, *refreshSchPath,
00171           *editCut, *editCopy, *magAll, *magOne, *magMinus, *filePrintFit,
00172           *symEdit, *intoH, *popH, *simulate, *dpl_sch, *undo, *redo, *dcbias;
00173 
00174   QAction *exportAsImage;
00175 
00176   QAction *activeAction;    // pointer to the action selected by the user
00177 
00178 private:
00179 // ********* Widgets on the main area **********************************
00180   QDockWidget     *dock;
00181   QTabWidget      *TabView;
00182   QDockWidget     *octDock;
00183   OctaveWindow    *octave;
00184   MessageDock     *messageDock;
00185 
00186   QListView       *Projects;
00187   ProjectView     *Content;
00188 
00189   QLineEdit       *CompSearch;
00190   QPushButton     *CompSearchClear;
00191   QComboBox       *CompChoose;
00192 
00193 // ********** Properties ************************************************
00194   QStack<QString> HierarchyHistory; // keeps track of "go into subcircuit"
00195   QString  QucsFileFilter;
00196   QFileSystemModel *m_homeDirModel;
00197   QFileSystemModel *m_projModel;
00198   int ccCurIdx; // CompChooser current index (used during search)
00199 
00200 // ********** Methods ***************************************************
00201   void initView();
00202   void initCursorMenu();
00203 
00204   void printCurrentDocument(bool);
00205   bool saveFile(QucsDoc *Doc=0);
00206   bool saveAs();
00207   void openProject(const QString &);
00208   bool deleteProject(const QString &);
00209   void updatePortNumber(QucsDoc*, int);
00210   void fillComboBox(bool);
00211   void switchSchematicDoc(bool);
00212   void switchEditMode(bool);
00213   void changeSchematicSymbolMode(Schematic*);
00214   bool recurRemove(const QString &);
00215   bool isTextDocument(QWidget *);
00216   void closeFile(int);
00217 
00218   void updateRecentFilesList(QString s);
00219   void successExportMessages(bool ok);
00220   void fillLibrariesTreeView (void);
00221 
00222 public:
00223 
00224   void readProjects();
00225   void updatePathList(void); // update the list of paths, pruning non-existing paths
00226   void updatePathList(QStringList);
00227   void updateSchNameHash(void); // maps all schematic files in the path list
00228   void updateSpiceNameHash(void); // maps all spice files in the path list
00229 
00230 /* **************************************************
00231    *****  The following methods are located in  *****
00232    *****  "qucs_init.cpp".                      *****
00233    ************************************************** */
00234 
00235 public slots:
00236   void slotShowWarnings();
00237   void slotResetWarnings();
00238   void printCursorPosition(int, int);
00239   void slotUpdateUndo(bool);  // update undo available state
00240   void slotUpdateRedo(bool);  // update redo available state
00241 
00242 private slots:
00243   void slotViewToolBar(bool toggle);    // toggle the toolbar
00244   void slotViewStatusBar(bool toggle);  // toggle the statusbar
00245   void slotViewBrowseDock(bool toggle); // toggle the dock window
00246   void slotViewOctaveDock(bool); // toggle the dock window
00247   void slotToggleOctave(bool);
00248   void slotToggleDock(bool);
00249   void slotHelpAbout();     // shows an about dialog
00250 
00251 private:
00252   void initActions();    // initializes all QActions of the application
00253   void initMenuBar();    // creates the menu_bar and inserts the menuitems
00254   void initToolBar();    // creates the toolbars
00255   void initStatusBar();  // setup the statusbar
00256 
00257   QAction *helpAboutApp, *helpAboutQt, *viewToolBar, *viewStatusBar,
00258           *viewBrowseDock, *viewOctaveDock;
00259 
00260   // menus contain the items of their menubar
00261   enum { MaxRecentFiles = 8 };
00262   QMenu *fileMenu, *editMenu, *insMenu, *projMenu, *simMenu, *viewMenu,
00263              *helpMenu, *alignMenu, *toolMenu, *recentFilesMenu;
00264   QAction *fileRecentAction[MaxRecentFiles];
00265   QAction *fileClearRecent;
00266 
00267   // submenus for the PDF documents
00268   QMenu *helpTechnical, *helpReport, *helpTutorial;
00269 
00270   QToolBar *fileToolbar, *editToolbar, *viewToolbar, *workToolbar;
00271 
00272   // Shortcuts for scolling schematic / TextEdit
00273   // This is rather cumbersome -> Make this with a QScrollView instead??
00274   QShortcut *cursorUp, *cursorLeft, *cursorRight, *cursorDown;
00275 
00276   QLabel *WarningLabel, *PositionLabel;  // labels in status bar
00277 
00278 
00279 
00280 /* **************************************************
00281    *****  The following methods are located in  *****
00282    *****  "qucs_actions.cpp".                   *****
00283    ************************************************** */
00284 
00285 public:
00286   void editFile(const QString&);
00287 
00288   QAction *insWire, *insLabel, *insGround, *insPort, *insEquation, *magPlus,
00289           *editRotate, *editMirror, *editMirrorY, *editPaste, *select,
00290           *editActivate, *wire, *editDelete, *setMarker, *onGrid, *moveText,
00291           *helpIndex, *helpGetStart, *callEditor, *callFilter, *callLine, *callActiveFilter,
00292           *showMsg, *showNet, *alignTop, *alignBottom, *alignLeft, *alignRight,
00293           *distrHor, *distrVert, *selectAll, *callLib, *callMatch, *changeProps,
00294           *addToProj, *editFind, *insEntity, *selectMarker,
00295           *createLib, *importData, *graph2csv, *createPkg, *extractPkg,
00296           *callAtt, *callRes, *centerHor, *centerVert, *loadModule, *buildModule;
00297 
00298 public slots:
00299   void slotEditRotate(bool);  // rotate the selected items
00300   void slotEditMirrorX(bool); // mirror the selected items about X axis
00301   void slotEditMirrorY(bool); // mirror the selected items about Y axis
00302   void slotEditCut();         // put marked object into clipboard and delete it
00303   void slotEditCopy();        // put the marked object into the clipboard
00304   void slotEditPaste(bool);   // paste the clipboard into the document
00305   void slotEditDelete(bool);  // delete the selected items
00306   void slotInsertEquation(bool);
00307   void slotInsertGround(bool);
00308   void slotInsertPort(bool);
00309   void slotInsertEntity();
00310   void slotSetWire(bool);
00311   void slotEscape();
00312   void slotSelect(bool);
00313   void slotEditActivate(bool);
00314   void slotInsertLabel(bool);
00315   void slotSetMarker(bool);
00316   void slotOnGrid(bool);      // set selected elements on grid
00317   void slotMoveText(bool);    // move property text of components
00318   void slotZoomIn(bool);
00319   void slotEditUndo();    // makes the last operation undone
00320   void slotEditRedo();    // makes the last undo undone
00321   void slotEditFind();    // searches for a piece of text
00322   void slotAlignTop();    // align selected elements with respect to top
00323   void slotAlignBottom(); // align selected elements with respect to bottom
00324   void slotAlignLeft();   // align selected elements with respect to left
00325   void slotAlignRight();  // align selected elements with respect to right
00326   void slotDistribHoriz();// distribute horizontally selected elements
00327   void slotDistribVert(); // distribute vertically selected elements
00328   void slotCenterHorizontal();
00329   void slotCenterVertical();
00330   void slotSelectAll();
00331   void slotSelectMarker();
00332   void slotShowLastMsg();
00333   void slotShowLastNetlist();
00334   void slotCallEditor();
00335   void slotCallFilter();
00336   void slotCallActiveFilter();
00337   void slotCallLine();
00338   void slotCallLibrary();
00339   void slotCallMatch();
00340   void slotCallAtt();
00341   void slotCallRes();
00342   void slotHelpIndex();       // shows a HTML docu: Help Index
00343   void slotGettingStarted();  // shows a HTML docu: Getting started
00344   void slotChangeProps();
00345   void slotAddToProject();
00346   void slotApplyCompText();
00347   void slotOpenRecent();
00348   void slotSaveDiagramToGraphicsFile();
00349   void slotSaveSchematicToGraphicsFile(bool diagram = false);
00350 
00351 private slots:
00352   void slotCursorLeft(bool left=true);
00353   void slotCursorRight() {return slotCursorLeft(false);}
00354   void slotCursorUp(bool up=true);
00355   void slotCursorDown() {return slotCursorUp(false);}
00356   void slotResizePropEdit(const QString&);
00357   void slotCreateLib();
00358   void slotImportData();
00359   void slotExportGraphAsCsv();
00360   void slotCreatePackage();
00361   void slotExtractPackage();
00362   void slotUpdateRecentFiles();
00363   void slotClearRecentFiles();
00364   void slotLoadModule();
00365   void slotBuildModule();
00366 
00367 private:
00368   void showHTML(const QString&);
00369   bool performToggleAction(bool, QAction*, pToggleFunc, pMouseFunc, pMouseFunc2);
00370   void launchTool(const QString&, const QString&, const QString& = ""); // tool, description and args
00371   friend class SaveDialog;
00372   QString lastExportFilename;
00373 };
00374 
00375 #endif /* QUCS_H */
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines