# Hurricane Design Viewer

CellViewer.h
1 // -*- C++ -*-
2 //
3 // This file is part of the Coriolis Software.
4 // Copyright (c) UPMC 2008-2018, All Rights Reserved
5 //
6 // +-----------------------------------------------------------------+
7 // | H U R R I C A N E |
8 // | V L S I B a c k e n d D a t a - B a s e |
9 // | |
10 // | Author : Jean-Paul CHAPUT |
11 // | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
12 // | =============================================================== |
13 // | C++ Header : "./hurricane/viewer/CellViewer.h" |
14 // +-----------------------------------------------------------------+
15
16
17 #ifndef HURRICANE_CELL_VIEWER_H
18 #define HURRICANE_CELL_VIEWER_H
19
20 #include <list>
21 #include <map>
22 #include <functional>
23 #include <boost/any.hpp>
24
25 #include <QIcon>
26 #include <QMainWindow>
27 class QEvent;
28 class QKeyEvent;
29 class QAction;
30 class QMenu;
31 class QPrinter;
32
33 #include "hurricane/Commons.h"
34 #include "hurricane/Observer.h"
35 #include "hurricane/Name.h"
36 #include "hurricane/Occurrence.h"
37 #include "hurricane/viewer/MoveCommand.h"
38 #include "hurricane/viewer/ZoomCommand.h"
39 #include "hurricane/viewer/RulerCommand.h"
40 #include "hurricane/viewer/SelectCommand.h"
41 #include "hurricane/viewer/HierarchyCommand.h"
42 #include "hurricane/viewer/CellWidget.h"
43
44
45 namespace Hurricane {
46
47
48 class Cell;
49 //class MapView;
50 class GotoWidget;
51 class MousePositionWidget;
52 class ControllerWidget;
53 class ScriptWidget;
54 class CellViewer;
55
56
57 // -------------------------------------------------------------------
58 // Class : "CellObserver".
59
60 // class CellObserver : public Observer<CellViewer> {
61 // public:
62 // inline CellObserver ( CellViewer* );
63 // virtual void notify ( unsigned int flags );
64 // private:
65 // CellObserver ( const CellObserver& );
66 // };
67
68
69 // inline CellObserver::CellObserver ( CellViewer* owner )
70 // : Observer<CellViewer>(owner)
71 // { }
72
73
74 // -------------------------------------------------------------------
75 // Class : "CellViewer".
76
77 class CellViewer : public QMainWindow {
78 Q_OBJECT;
79
80 public:
81 enum { CellHistorySize = 10 };
82 enum Flag { InCellChange = 0x0001 };
83 enum FunctionFlag { NoFlags = 0x0000
84 , TopMenu = 0x0001 };
85 private:
86 typedef std::map< const QString, boost::any > ActionLut;
87 typedef bool (QWidget::* SlotMethod)();
88 public:
89 static void notify ( CellViewer*, unsigned int flags );
90 public:
91 CellViewer ( QWidget* parent=NULL );
92 virtual ~CellViewer ();
93 inline bool isToolInterrupted () const;
94 QMenu* createDebugMenu ();
95 bool hasMenu ( const QString& path ) const;
96 bool hasMenuAction ( const QString& path ) const;
97 QAction* getMenuAction ( const QString& path ) const;
98 QAction* addMenu ( const QString& path
99 , std::string text
100 , unsigned int flags=NoFlags
101 );
102 bool addToMenu ( const QString& path
103 , QString beforePath="" );
104 QAction* addToMenu ( const QString& path
105 , std::string text
106 , std::string textTip
107 , std::function< void() >
108 , QIcon icon=QIcon()
109 , QString beforePath="" );
110 QAction* addToMenu ( const QString& path
111 , std::string text
112 , std::string textTip
113 , std::string scriptPath
114 , QString beforePath="" );
115 QAction* addToMenu ( QString path
116 , QString text
117 , QString textTip
118 , const QKeySequence& shortCut
119 , QIcon icon =QIcon()
120 , QString beforePath="" );
121 inline void setEnableRedrawInterrupt ( bool );
122 inline void setApplicationName ( const QString& );
123 inline Observer<CellViewer>* getCellObserver ();
124 Cell* getCell () const;
125 virtual void setCell ( Cell* );
126 void renameCell ( const char* );
127 virtual Cell* getCellFromDb ( const char* );
128 inline CellWidget* getCellWidget ();
129 inline const CellWidget* getCellWidget () const;
130 inline ControllerWidget* getControllerWidget ();
131 void setAnonNetSelectable ( bool );
132 void select ( Occurrence& );
133 void unselect ( Occurrence& );
134 void unselectAll ();
135 inline void setLayerVisible ( const Name& layer, bool visible );
136 void runScript ( QString scriptPath );
137 virtual CellViewer* vcreate () const;
138 virtual std::string _getString () const;
139 public slots:
140 void doAction ();
141 void doGoto ();
142 void changeSelectionMode ();
143 void setShowSelection ( bool );
144 void setCumulativeSelection ( bool );
145 void setState ( shared_ptr<CellWidget::State>& );
146 void removeHistory ( Cell* );
147 void openHistoryCell ();
148 void openDesignBlob ();
149 void saveDesignBlob ();
150 void printDisplay ();
151 void print ( QPrinter* );
152 void imageDisplay ();
153 void raiseToolInterrupt ();
154 void clearToolInterrupt ();
155 void runScriptWidget ();
156 void runStressScript ();
157 inline void emitCellAboutToChange ();
158 inline void emitCellChanged ();
159 inline void emitCellPreModificated ();
160 inline void emitCellPostModificated ();
161 signals:
162 void cellLoadedFromDisk ( Cell* );
163 void showSelectionToggled ( bool );
164 void stateChanged ( shared_ptr<CellWidget::State>& );
165 void redrawCellWidget ();
166 void cellPreModificated ();
167 void cellPostModificated ();
168 protected:
169 void createMenus ();
170 void refreshTitle ();
171 void refreshHistory ();
172 void rebuildHistory ();
173 private:
174 QString _getAbsWidgetPath ( const QString& relPath ) const;
175 QAction* _getParentMenu ( const QString& ) const;
176 void _runScript ( QString scriptPath );
177
178 protected:
179 static QString _prefixWPath;
180 Observer<CellViewer> _cellObserver;
181 QString _applicationName;
182 QAction* _openAction;
183 QAction* _cellHistoryAction[CellHistorySize];
184 QAction* _showSelectionAction;
185 QMenu* _debugMenu;
186 ActionLut _actionCallbacks;
187 // MapView* _mapView;
188 MousePositionWidget* _mousePosition;
189 ControllerWidget* _controller;
190 ScriptWidget* _script;
191 GotoWidget* _goto;
192 CellWidget* _cellWidget;
193 MoveCommand _moveCommand;
194 ZoomCommand _zoomCommand;
195 RulerCommand _rulerCommand;
196 SelectCommand _selectCommand;
197 HierarchyCommand _hierarchyCommand;
198 list< shared_ptr<CellWidget::State> >
199 _cellHistory;
200 bool _firstShow;
201 bool _toolInterrupt;
202 unsigned int _flags;
203 UpdateState _updateState;
204 QString _pyScriptName;
205 };
206
207
208 // Inline Functions.
209 inline bool CellViewer::isToolInterrupted () const { return _toolInterrupt; }
210 inline Observer<CellViewer>* CellViewer::getCellObserver () { return &_cellObserver; }
211 inline CellWidget* CellViewer::getCellWidget () { return _cellWidget; }
212 inline const CellWidget* CellViewer::getCellWidget () const { return _cellWidget; }
213 inline ControllerWidget* CellViewer::getControllerWidget () { return _controller; }
214 inline void CellViewer::setApplicationName ( const QString& name ) { _applicationName = name; }
215 inline void CellViewer::setLayerVisible ( const Name& layer, bool visible ) { _cellWidget->setLayerVisible(layer,visible); }
216 inline void CellViewer::emitCellAboutToChange () { _flags |= InCellChange; emit cellPreModificated(); }
217 inline void CellViewer::emitCellChanged () { _flags &= ~InCellChange; emit cellPostModificated(); }
218 inline void CellViewer::emitCellPreModificated () { emit cellPreModificated(); }
219 inline void CellViewer::emitCellPostModificated () { emit cellPostModificated(); }
220
221 inline void CellViewer::setEnableRedrawInterrupt ( bool state )
222 { _cellWidget->setEnableRedrawInterrupt(state); }
223
224
225 } // Hurricane namespace.
226
227
228 GETSTRING_POINTER_SUPPORT(Hurricane::CellViewer)
229 IOSTREAM_POINTER_SUPPORT(Hurricane::CellViewer)
230
231
232 #endif
Hurricane::Occurrence
Hurricane::CellViewer::renameCell
void renameCell(const char *)
Hurricane::CellViewer::CellViewer
CellViewer(QWidget *parent=NULL)
Hurricane::CellViewer::getControllerWidget
ControllerWidget * getControllerWidget()
Definition: CellViewer.h:213
Hurricane::CellViewer::~CellViewer
virtual ~CellViewer()
Hurricane::Name
Hurricane::CellViewer::select
void select(Occurrence &)
Hurricane::Cell
Hurricane::CellViewer::setLayerVisible
void setLayerVisible(const Name &layer, bool visible)
Definition: CellViewer.h:215
Hurricane::CellViewer::setEnableRedrawInterrupt
void setEnableRedrawInterrupt(bool)
Definition: CellViewer.h:221
Hurricane::CellViewer::getCell
Cell * getCell() const
Hurricane::CellViewer::getCellFromDb
virtual Cell * getCellFromDb(const char *)
Hurricane::CellViewer::setCell
virtual void setCell(Cell *)
Hurricane::CellViewer::setAnonNetSelectable
void setAnonNetSelectable(bool)
Hurricane::CellViewer::unselect
void unselect(Occurrence &)
Hurricane::CellViewer::unselectAll
void unselectAll()
Hurricane::CellViewer
A simple top level window embedding the CellWidget.
Definition: CellViewer.h:77
Hurricane::CellViewer::isToolInterrupted
bool isToolInterrupted() const
Definition: CellViewer.h:209
Hurricane
Hurricane::CellViewer::setApplicationName
void setApplicationName(const QString &)
Definition: CellViewer.h:214
Hurricane::CellWidget
The Widget to display a Cell.
Definition: CellWidget.h:84
Hurricane::CellViewer::getCellWidget
CellWidget * getCellWidget()
Definition: CellViewer.h:211

Generated by doxygen 1.8.14 on Tue Jul 21 2020 | Return to top of page

Hurricane Design Viewer | Copyright © 2008-2016 UPMC All rights reserved