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


Generated by doxygen 1.9.1 on Wed Nov 20 2024 Return to top of page
Hurricane Design Viewer Copyright © 2008-2020 Sorbonne Universite All rights reserved