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 #pragma once
18 #include <list>
19 #include <map>
20 #include <functional>
21 #include <boost/any.hpp>
22 #include <QIcon>
23 #include <QMainWindow>
24 class QEvent;
25 class QKeyEvent;
26 class QAction;
27 class QMenu;
28 class QPrinter;
29 #include "hurricane/Commons.h"
30 #include "hurricane/Observer.h"
31 #include "hurricane/Name.h"
32 #include "hurricane/Occurrence.h"
33 #include "hurricane/viewer/MoveCommand.h"
34 #include "hurricane/viewer/ZoomCommand.h"
35 #include "hurricane/viewer/RulerCommand.h"
36 #include "hurricane/viewer/SelectCommand.h"
37 #include "hurricane/viewer/HierarchyCommand.h"
38 #include "hurricane/viewer/CellWidget.h"
39 
40 
41 namespace Hurricane {
42 
43 
44  class Cell;
45 //class MapView;
46  class GotoWidget;
47  class MousePositionWidget;
48  class ControllerWidget;
49  class ScriptWidget;
50  class CellViewer;
51 
52 
53 // -------------------------------------------------------------------
54 // Class : "CellObserver".
55 
56  // class CellObserver : public Observer<CellViewer> {
57  // public:
58  // inline CellObserver ( CellViewer* );
59  // virtual void notify ( unsigned int flags );
60  // private:
61  // CellObserver ( const CellObserver& );
62  // };
63 
64 
65  // inline CellObserver::CellObserver ( CellViewer* owner )
66  // : Observer<CellViewer>(owner)
67  // { }
68 
69 
70 // -------------------------------------------------------------------
71 // Class : "CellViewer".
72 
73  class CellViewer : public QMainWindow {
74  Q_OBJECT;
75 
76  public:
77  typedef QMainWindow Super;
78  public:
79  enum { CellHistorySize = 10 };
80  enum Flag { InCellChange = 0x0001 };
81  enum FunctionFlag { NoFlags = 0x0000
82  , TopMenu = 0x0001 };
83  private:
84  typedef std::map< const QString, boost::any > ActionLut;
85  typedef bool (QWidget::* SlotMethod)();
86  public:
87  static inline const std::vector<CellViewer*>&
88  getAllViewers ();
89  static void notify ( CellViewer*, unsigned int flags );
90  public:
91  CellViewer ( QWidget* parent=NULL );
92  virtual ~CellViewer ();
93  inline bool isToolInterrupted () const;
94  inline size_t getSettingsId () const;
95  void readQtSettings ();
96  void saveQtSettings ();
97  void refreshTitle ();
98  QMenu* createDebugMenu ();
99  bool hasMenu ( const QString& path ) const;
100  bool hasMenuAction ( const QString& path ) const;
101  QAction* getMenuAction ( const QString& path ) const;
102  QAction* addMenu ( const QString& path
103  , std::string text
104  , unsigned int flags=NoFlags
105  );
106  bool addToMenu ( const QString& path
107  , QString beforePath="" );
108  QAction* addToMenu ( const QString& path
109  , std::string text
110  , std::string textTip
111  , std::function< void() >
112  , QIcon icon=QIcon()
113  , QString beforePath="" );
114  QAction* addToMenu ( const QString& path
115  , std::string text
116  , std::string textTip
117  , std::string scriptPath
118  , QString beforePath="" );
119  QAction* addToMenu ( QString path
120  , QString text
121  , QString textTip
122  , const QKeySequence& shortCut
123  , QIcon icon =QIcon()
124  , QString beforePath="" );
125  inline void setEnableRedrawInterrupt ( bool );
126  inline void setApplicationName ( const QString& );
127  inline void setPixelThreshold ( int );
128  inline void setDbuMode ( int );
129  inline Observer<CellViewer>* getCellObserver ();
130  Cell* getCell () const;
131  virtual void setCell ( Cell* );
132  void renameCell ( const char* );
133  virtual Cell* getCellFromDb ( const char* );
134  inline CellWidget* getCellWidget ();
135  inline const CellWidget* getCellWidget () const;
136  inline ControllerWidget* getControllerWidget ();
137  void setAnonNetSelectable ( bool );
138  void select ( Occurrence& );
139  void unselect ( Occurrence& );
140  void unselectAll ();
141  inline void setLayerVisible ( const Name& layer, bool visible );
142  void reframe ( const Box& , bool historyEnable=true );
143  void runScript ( QString scriptPath );
144  virtual CellViewer* vcreate () const;
145  virtual void closeEvent ( QCloseEvent* );
146  virtual std::string _getString () const;
147  public slots:
148  void doAction ();
149  void doGoto ();
150  void selectionModeChanged ();
151  void setShowSelection ( bool );
152  void setCumulativeSelection ( bool );
153  void setState ( shared_ptr<CellWidget::State>& );
154  void removeHistory ( Cell* );
155  void openHistoryCell ();
156  void openDesignBlob ();
157  void saveDesignBlob ();
158  void printDisplay ();
159  void print ( QPrinter* );
160  void imageDisplay ();
161  void raiseToolInterrupt ();
162  void clearToolInterrupt ();
163  void runScriptWidget ();
164  void runStressScript ();
165  inline void emitCellAboutToChange ();
166  inline void emitCellChanged ();
167  inline void emitCellPreModificated ();
168  inline void emitCellPostModificated ();
169  signals:
170  void cellLoadedFromDisk ( Cell* );
171  void showSelectionToggled ( bool );
172  void stateChanged ( shared_ptr<CellWidget::State>& );
173  void redrawCellWidget ();
174  void cellPreModificated ();
175  void cellPostModificated ();
176  protected:
177  void createMenus ();
178  void refreshHistory ();
179  void rebuildHistory ();
180  private:
181  QString _getAbsWidgetPath ( const QString& relPath ) const;
182  QAction* _getParentMenu ( const QString& ) const;
183  void _runScript ( QString scriptPath );
184 
185  protected:
186  static std::vector<CellViewer*> _allViewers;
187  static QString _prefixWPath;
188  Observer<CellViewer> _cellObserver;
189  QString _applicationName;
190  QAction* _openAction;
191  QAction* _cellHistoryAction[CellHistorySize];
192  QAction* _showSelectionAction;
193  QMenu* _debugMenu;
194  ActionLut _actionCallbacks;
195  // MapView* _mapView;
196  MousePositionWidget* _mousePosition;
197  ControllerWidget* _controller;
198  ScriptWidget* _script;
199  GotoWidget* _goto;
200  CellWidget* _cellWidget;
201  MoveCommand _moveCommand;
202  ZoomCommand _zoomCommand;
203  RulerCommand _rulerCommand;
204  SelectCommand _selectCommand;
205  HierarchyCommand _hierarchyCommand;
206  list< shared_ptr<CellWidget::State> >
207  _cellHistory;
208  bool _firstShow;
209  bool _toolInterrupt;
210  unsigned int _flags;
211  QString _pyScriptName;
212  };
213 
214 
215 // Inline Functions.
216  inline const std::vector<CellViewer*>&
217  CellViewer::getAllViewers () { return _allViewers; }
218  inline bool CellViewer::isToolInterrupted () const { return _toolInterrupt; }
219  inline Observer<CellViewer>* CellViewer::getCellObserver () { return &_cellObserver; }
220  inline CellWidget* CellViewer::getCellWidget () { return _cellWidget; }
221  inline const CellWidget* CellViewer::getCellWidget () const { return _cellWidget; }
222  inline ControllerWidget* CellViewer::getControllerWidget () { return _controller; }
223  inline void CellViewer::setApplicationName ( const QString& name ) { _applicationName = name; }
224  inline void CellViewer::setLayerVisible ( const Name& layer, bool visible ) { _cellWidget->setLayerVisible(layer,visible); }
225  inline void CellViewer::emitCellAboutToChange () { _flags |= InCellChange; emit cellPreModificated(); }
226  inline void CellViewer::emitCellChanged () { _flags &= ~InCellChange; emit cellPostModificated(); }
227  inline void CellViewer::emitCellPreModificated () { emit cellPreModificated(); }
228  inline void CellViewer::emitCellPostModificated () { emit cellPostModificated(); }
229 
230  inline void CellViewer::setPixelThreshold ( int threshold )
231  { _cellWidget->setPixelThreshold( threshold ); }
232 
233  inline void CellViewer::setEnableRedrawInterrupt ( bool state )
234  { _cellWidget->setEnableRedrawInterrupt(state); }
235 
236  inline void CellViewer::setDbuMode ( int mode )
237  { _cellWidget->setDbuMode(mode); }
238 
239  inline size_t CellViewer::getSettingsId () const
240  {
241  for ( size_t i=0; i<_allViewers.size() ; ++i ) {
242  if (_allViewers[i] == this) return i;
243  }
244  return 0;
245  }
246 
247 
248 } // Hurricane namespace.
249 
250 
251 GETSTRING_POINTER_SUPPORT(Hurricane::CellViewer)
252 IOSTREAM_POINTER_SUPPORT(Hurricane::CellViewer)
A simple top level window embedding the CellWidget.
Definition: CellViewer.h:73
virtual Cell * getCellFromDb(const char *)
ControllerWidget * getControllerWidget()
Definition: CellViewer.h:222
CellWidget * getCellWidget()
Definition: CellViewer.h:220
void setEnableRedrawInterrupt(bool)
Definition: CellViewer.h:233
void unselect(Occurrence &)
virtual void setCell(Cell *)
void setAnonNetSelectable(bool)
CellViewer(QWidget *parent=NULL)
void setApplicationName(const QString &)
Definition: CellViewer.h:223
void select(Occurrence &)
bool isToolInterrupted() const
Definition: CellViewer.h:218
void renameCell(const char *)
void setLayerVisible(const Name &layer, bool visible)
Definition: CellViewer.h:224
Cell * getCell() const
The Widget to display a Cell.
Definition: CellWidget.h:81


Generated by doxygen 1.9.1 on Sun Dec 14 2025 Return to top of page
Hurricane Design Viewer Copyright © 2008-2020 Sorbonne Universite All rights reserved