-
-
Notifications
You must be signed in to change notification settings - Fork 118
/
Copy pathqucs.h
476 lines (410 loc) · 16.4 KB
/
qucs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
/***************************************************************************
qucs.h
--------
begin : Thu Aug 28 2003
copyright : (C) 2003 by Michael Margraf
email : michael.margraf@alumni.tu-berlin.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QUCS_H
#define QUCS_H
#include <QMainWindow>
#include <QString>
#include <QHash>
#include <QStack>
#include <QFileSystemModel>
#include <QSortFilterProxyModel>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
class QucsDoc;
class Schematic;
class SimMessage;
class MouseActions;
class SearchDialog;
class OctaveWindow;
class MessageDock;
class ProjectView;
class TunerDialog;
class tunerElement;
class ExternSimDialog;
class QLabel;
class QAction;
class QLineEdit;
class QComboBox;
class QTabWidget;
class QDir;
class QMouseEvent;
class QCloseEvent;
class QMenu;
class QToolBar;
class QSettings;
class QListWidgetItem;
class QTreeWidget;
class QTreeWidgetItem;
class QListWidget;
class QShortcut;
class QListView;
class QModelIndex;
class QPushButton;
class QTextEdit;
class QFrame;
class SymbolWidget;
typedef bool (Schematic::*pToggleFunc) ();
typedef void (MouseActions::*pMouseFunc) (Schematic*, QMouseEvent*);
typedef void (MouseActions::*pMouseFunc2) (Schematic*, QMouseEvent*, float, float);
class QucsFileSystemModel : public QFileSystemModel {
Q_OBJECT
public:
explicit QucsFileSystemModel(QObject* parent = nullptr) : QFileSystemModel(parent) {};
QVariant data(const QModelIndex& index, int role) const override;
};
class QucsSortFilterProxyModel : public QSortFilterProxyModel {
Q_OBJECT
public:
explicit QucsSortFilterProxyModel(QObject *parent = nullptr) : QSortFilterProxyModel(parent) {};
protected:
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
};
class QucsApp : public QMainWindow {
Q_OBJECT
public:
QucsApp(bool netlist2Console);
~QucsApp();
bool closeAllFiles();
bool gotoPage(const QString&); // to load a document
QucsDoc *getDoc(int No=-1);
QucsDoc* findDoc (QString, int * Pos = 0);
QString fileType (const QString&);
static bool isTextDocument(QWidget *);
QString ProjName; // name of the project, that is open
//QHash<QString,QString> schNameHash; // QHash for the schematic files lookup
//QHash<QString,QString> spiceNameHash; // QHash for the spice files lookup
QLineEdit *editText; // for edit component properties on schematic
SearchDialog *SearchDia; // global in order to keep values
TunerDialog *tunerDia; // global in order to keep values
SimMessage *sim; // global in order to keep values
// current mouse methods
void (MouseActions::*MouseMoveAction) (Schematic*, QMouseEvent*);
void (MouseActions::*MousePressAction) (Schematic*, QMouseEvent*, float, float);
void (MouseActions::*MouseDoubleClickAction) (Schematic*, QMouseEvent*);
void (MouseActions::*MouseReleaseAction) (Schematic*, QMouseEvent*);
protected:
void closeEvent(QCloseEvent*);
public slots:
void slotFileNew(); // generate a new schematic in the view TabBar
void slotTextNew(); // generate a new text editor in the view TabBar
void slotSymbolNew(); // create new symbol
void slotFileOpen(); // open a document
void slotFileSave(); // save a document
void slotFileSaveAs(); // save a document under a different filename
void slotFileSaveAll(); // save all open documents
void slotFileClose(); // close the actual file
void slotFileExamples(); // show the examples in a file browser
void slotHelpTutorial(); // Open a pdf tutorial
void slotHelpReport(); // Open a pdf report
void slotHelpTechnical(); // Open a pdf technical document
void slotFileClose (int); // close the file with given index
void slotSymbolEdit(); // edit the symbol for the schematic
void slotFileSettings();// open dialog to change file settings
void slotFilePrint(); // print the current file
void slotFilePrintFit();// Print and fit to page
void slotFileQuit(); // exits the application
void slotApplSettings();// open dialog to change application settings
void slotRefreshSchPath(); // refresh the schematic path hash
void slotIntoHierarchy();
void slotPopHierarchy();
void slotShowAll();
void slotZoomToSelection();
void slotShowOne();
void slotZoomOut(); // Zoom out by 2
void slotToPage();
void slotSelectComponent(QListWidgetItem*);
void slotSearchComponent(const QString &);
void slotSearchClear();
void slotEditElement();
void slotPowerMatching();
void slot2PortMatching();
// for menu that appears by right click in content ListView
void slotShowContentMenu(const QPoint &);
void slotCMenuOpen();
void slotCMenuCopy();
void slotCMenuRename();
void slotCMenuDelete();
void slotCMenuInsert();
void slotUpdateTreeview();
void slotMenuProjClose();
void slotSimulate(QWidget *w = nullptr);
void slotSimulateWithSpice();
void slotTune(bool checked);
private slots:
void slotMenuProjOpen();
void slotMenuProjDel();
void slotListProjOpen(const QModelIndex &);
void slotSelectSubcircuit(const QModelIndex &);
void slotSelectLibComponent(QTreeWidgetItem*);
void slotOpenContent(const QModelIndex &);
void slotSetCompView(int);
void slotChangeSimulator(int);
void slotButtonProjNew();
void slotButtonProjOpen();
void slotButtonProjDel();
void slotChangeView();
void slotAfterSimulation(int, SimMessage*);
void slotDCbias();
void slotChangePage(const QString&, const QString&);
void slotHideEdit();
void slotFileChanged(bool);
void slotSimSettings();
void slotSaveNetlist();
void slotSaveCdlNetlist();
void slotAfterSpiceSimulation(ExternSimDialog *SimDlg);
void slotBuildVAModule();
/*void slotBuildXSPICEIfs(int mode = 0);
void slotEDDtoIFS();
void slotEDDtoMOD();*/
void slotShowModel();
void slotSearchLibComponent(const QString &);
void slotSearchLibClear();
signals:
void signalKillEmAll();
public:
MouseActions *view;
QTabWidget *DocumentTab;
QListWidget *CompComps;
QTreeWidget *libTreeWidget;
QTextEdit *CompDescr;
QLineEdit *LibCompSearch;
SymbolWidget *Symbol;
QPushButton *btnShowModel;
// menu appearing by right mouse button click on content listview
QMenu *ContentMenu;
// corresponding actions
QAction *ActionCMenuOpen, *ActionCMenuCopy, *ActionCMenuRename, *ActionCMenuDelete, *ActionCMenuInsert;
QAction *fileNew, *textNew, *symNew, *fileNewDpl, *fileOpen, *fileSave, *fileSaveAs,
*fileSaveAll, *fileClose, *fileExamples, *fileSettings, *filePrint, *fileQuit,
*projNew, *projOpen, *projDel, *projClose, *applSettings, *refreshSchPath,
*editCut, *editCopy, *magAll, *magSel, *magOne, *magMinus, *filePrintFit, *tune,
*symEdit, *intoH, *popH, *simulate, *save_netlist, *dpl_sch, *undo, *redo, *dcbias,
*saveCdlNetlist;
QAction *exportAsImage;
QAction *activeAction; // pointer to the action selected by the user
bool TuningMode;
QString windowTitle;
private:
// ********* Widgets on the main area **********************************
QDockWidget *dock;
QTabWidget *TabView;
QDockWidget *octDock;
OctaveWindow *octave;
MessageDock *messageDock;
QListView *Projects;
ProjectView *Content;
QLineEdit *CompSearch;
QPushButton *CompSearchClear;
QComboBox *CompChoose;
// ********** Properties ************************************************
QStack<QString> HierarchyHistory; // keeps track of "go into subcircuit"
QString QucsFileFilter;
QFileSystemModel *a_homeDirModel;
QucsSortFilterProxyModel *a_proxyModel;
int ccCurIdx; // CompChooser current index (used during search)
bool a_netlist2Console;
// ********** Methods ***************************************************
void initView();
void initCursorMenu();
int addDocumentTab(QFrame* widget, const QString& title = QString());
void setDocumentTabChanged(int index, bool changed);
void printCurrentDocument(bool);
bool saveFile(QucsDoc *Doc=0);
bool saveAs();
void openProject(const QString &);
bool deleteProject(const QString &);
void updatePortNumber(QucsDoc*, int);
int fillComboBox(bool);
void fillSimulatorsComboBox();
void switchSchematicDoc(bool);
void switchEditMode(bool);
void changeSchematicSymbolMode(Schematic*);
static bool recurRemove(const QString &);
void closeFile(int);
void updateRecentFilesList(QString s);
void successExportMessages(bool ok);
void fillLibrariesTreeView (void);
bool populateLibTreeFromDir(const QString &LibDirPath, QList<QTreeWidgetItem *> &topitems, bool relpath = false);
void saveSettings();
QWidget *getSchematicWidget(QucsDoc *Doc);
public:
void readProjects();
void updatePathList(void); // update the list of paths, pruning non-existing paths
void updatePathList(QStringList);
//void updateSchNameHash(void); // maps all schematic files in the path list
//void updateSpiceNameHash(void); // maps all spice files in the path list
/* **************************************************
***** The following methods are located in *****
***** "qucs_init.cpp". *****
************************************************** */
public slots:
void slotShowWarnings();
void slotResetWarnings();
void printCursorPosition(int, int, QString);
void slotUpdateUndo(bool); // update undo available state
void slotUpdateRedo(bool); // update redo available state
private slots:
void slotViewBrowseDock(bool toggle); // toggle the dock window
void slotViewOctaveDock(bool); // toggle the dock window
void slotToggleOctave(bool);
void slotToggleDock(bool);
void slotHelpAbout(); // shows an about dialog
private:
void initActions(); // initializes all QActions of the application
void initMenuBar(); // creates the menu_bar and inserts the menuitems
void initToolBar(); // creates the toolbars
void initStatusBar(); // setup the statusbar
QAction *helpAboutApp, *helpAboutQt,
*viewBrowseDock, *viewOctaveDock;
// menus contain the items of their menubar
enum { MaxRecentFiles = 8 };
QMenu *fileMenu, *editMenu, *insMenu, *projMenu, *simMenu, *viewMenu,
*helpMenu, *alignMenu, *toolMenu, *recentFilesMenu, *cmMenu;
QAction *fileRecentAction[MaxRecentFiles];
QAction *fileClearRecent;
// submenus for the PDF documents
QMenu *helpTechnical, *helpReport, *helpTutorial;
QComboBox *simulatorsCombobox;
QToolBar *fileToolbar, *editToolbar, *viewToolbar, *workToolbar, *simulateToolbar;
// Shortcuts for scrolling schematic / TextEdit
// This is rather cumbersome -> Make this with a QScrollView instead??
QShortcut *cursorUp, *cursorLeft, *cursorRight, *cursorDown;
QLabel *WarningLabel, *PositionLabel, *DiagramValuesLabel; // labels in status bar
// QLabel *SimulatorLabel;
/* **************************************************
***** The following methods are located in *****
***** "qucs_actions.cpp". *****
************************************************** */
public:
void editFile(const QString&);
QAction *insWire, *insLabel, *insGround, *insPort, *insEquation, *magPlus,
*editRotate, *editMirror, *editMirrorY, *editPaste, *select,
*editActivate, *wire, *editDelete, *setMarker, *setDiagramLimits, *resetDiagramLimits, *showGrid, *onGrid, *moveText,
*helpIndex, *helpGetStart, *callEditor, *callFilter, *callLine, *callActiveFilter,
*showMsg, *showNet, *alignTop, *alignBottom, *alignLeft, *alignRight,
*distrHor, *distrVert, *selectAll, *callMatch, *changeProps,
*addToProj, *editFind, *insEntity, *selectMarker,
*createLib, *callConverter, *graph2csv,
*callAtt, *centerHor, *centerVert, *loadModule, *buildModule, *callPwrComb, *callRFLayout, *callSPAR_Viewer;
QAction *helpQucsIndex;
QAction *simSettings;
QAction *buildVAModule;
public slots:
void slotEditRotate(bool); // rotate the selected items
void slotEditMirrorX(bool); // mirror the selected items about X axis
void slotEditMirrorY(bool); // mirror the selected items about Y axis
void slotEditCut(); // put marked object into clipboard and delete it
void slotEditCopy(); // put the marked object into the clipboard
void slotEditPaste(bool); // paste the clipboard into the document
void slotEditDelete(bool); // delete the selected items
void slotInsertEquation(bool);
void slotInsertGround(bool);
void slotInsertPort(bool);
void slotInsertEntity();
void slotSetWire(bool);
void slotEscape();
void slotSelect(bool);
void slotEditActivate(bool);
void slotInsertLabel(bool);
void slotSetMarker(bool);
void slotSetDiagramLimits(bool);
void slotResetDiagramLimits();
void slotShowGrid(); // turn the grid on or off
void slotOnGrid(bool); // set selected elements on grid
void slotMoveText(bool); // move property text of components
void slotZoomIn(bool);
void slotEditUndo(); // makes the last operation undone
void slotEditRedo(); // makes the last undo undone
void slotEditFind(); // searches for a piece of text
void slotAlignTop(); // align selected elements with respect to top
void slotAlignBottom(); // align selected elements with respect to bottom
void slotAlignLeft(); // align selected elements with respect to left
void slotAlignRight(); // align selected elements with respect to right
void slotDistribHoriz();// distribute horizontally selected elements
void slotDistribVert(); // distribute vertically selected elements
void slotCenterHorizontal();
void slotCenterVertical();
void slotSelectAll();
void slotSelectMarker();
void slotShowLastMsg();
void slotShowLastNetlist();
void slotCallEditor();
void slotCallFilter();
void slotCallActiveFilter();
void slotCallLine();
void slotCallMatch();
void slotCallAtt();
void slotCallPwrComb();
void slotCallSPAR_Viewer();
void slotCallRFLayout();
void slotHelpIndex(); // shows a HTML docu: Help Index
void slotHelpQucsIndex();
void slotGettingStarted(); // shows a HTML docu: Getting started
void slotChangeProps();
void slotAddToProject();
void slotApplyCompText();
void slotOpenRecent();
void slotSaveDiagramToGraphicsFile();
void slotSaveSchematicToGraphicsFile(bool diagram = false);
private slots:
void slotCursorLeft(bool left=true);
void slotCursorRight() {return slotCursorLeft(false);}
void slotCursorUp(bool up=true);
void slotCursorDown() {return slotCursorUp(false);}
void slotResizePropEdit(const QString&);
void slotCreateLib();
void slotImportData();
void slotExportGraphAsCsv();
void slotUpdateRecentFiles();
void slotClearRecentFiles();
void slotLoadModule();
void slotBuildModule();
private:
void buildWithOpenVAF();
bool performToggleAction(bool, QAction*, pToggleFunc, pMouseFunc, pMouseFunc2);
void launchTool(const QString&, const QString&,
const QStringList& = QStringList(),bool qucs_tool = false); // tool, description and args
friend class SaveDialog;
QString lastExportFilename;
};
/** \brief Provide a template to declare singleton classes.
*
* Classes implemented using this template will be singletons (i.e., only
* one instance of the class will exist per invokation). Primarily this
* is used to support static / access to an application-wide function, e.g.
* settings.
*
*/
template < typename T >
class QucsSingleton final
{
public:
static T& Get()
{
static T instance;
return instance;
}
// Prevent overriding default ctor, dtor, copying, or multiple instances.
private:
QucsSingleton() = default;
~QucsSingleton() = default;
QucsSingleton(const QucsSingleton&) = delete;
QucsSingleton& operator=(const QucsSingleton&) = delete;
QucsSingleton(QucsSingleton&&) = delete;
QucsSingleton& operator=(QucsSingleton&&) = delete;
};
#endif /* QUCS_H */