Reorganisation of menus in a more clear way.

This commit is contained in:
Jean-Paul Chaput 2019-03-05 23:23:14 +01:00
parent 89c730ec61
commit f107a68938
16 changed files with 171 additions and 123 deletions

View File

@ -217,9 +217,6 @@ layersExtensionsTable = \
)
for entry in layersExtensionsTable:
print entry
# Format of an entry in the table:
# (Symbolic_Name, CIF_Name, GDSII_Number)
gdsLayersTable = \

View File

@ -183,8 +183,10 @@ class PlaceCore ( chip.Configuration.ChipConfWrapper ):
# Plugin hook functions, unicornHook:menus, ScritMain:call
def unicornHook ( **kw ):
plugins.kwUnicornHook( 'plugins.chip'
, 'Chip Placement'
kw['beforeAction'] = 'placeAndRoute.stepByStep'
plugins.kwUnicornHook( 'placeAndRoute.placeChip'
, 'PLace Chip'
, 'Place a Complete Chip (pads && core)'
, sys.modules[__name__].__file__
, **kw

View File

@ -55,8 +55,10 @@ except Exception, e:
# Plugin hook functions, unicornHook:menus, ScritMain:call
def unicornHook ( **kw ):
plugins.kwUnicornHook( 'plugins.clockTree'
, 'ClockTree'
kw['beforeAction'] = 'placeAndRoute.placeChip'
plugins.kwUnicornHook( 'placeAndRoute.clockTree'
, 'Clock Tree'
, 'Build a buffered H-Tree for the clock'
, sys.modules[__name__].__file__
, **kw

View File

@ -78,9 +78,9 @@ def rsave ( cell, views=CRL.Catalog.State.Physical, depth=0 ):
# Plugin hook functions, unicornHook:menus, ScritMain:call
def unicornHook ( **kw ):
plugins.kwUnicornHook( 'plugins.rsave'
, 'R-Save Cell (layout)'
, 'Recursively Save Top Cell and it\'s Instances'
plugins.kwUnicornHook( 'tools.rsave'
, 'Recursive Save (layout)'
, 'Recursively save layout of the top cell and it\'s instances'
, sys.modules[__name__].__file__
, **kw
)

View File

@ -73,9 +73,9 @@ def rsave ( cell, depth=0 ):
# Plugin hook functions, unicornHook:menus, ScritMain:call
def unicornHook ( **kw ):
plugins.kwUnicornHook( 'plugins.rsaveAll'
, 'R-Save Cell (All)'
, 'Recursively Save Top Cell and it\'s Instances'
plugins.kwUnicornHook( 'tools.rsaveAll'
, 'Rercursive Save (all)'
, 'Recursively save layout <b>and</b> netlist of top cell and it\'s Instances'
, sys.modules[__name__].__file__
, **kw
)

View File

@ -52,7 +52,10 @@ def kwUnicornHook ( menuPath, menuName, menuTip, moduleFile, **kw ):
if moduleFile.endswith('.pyc') or moduleFile.endswith('.pyo'):
moduleFile = moduleFile[:-1]
editor.addToMenu( menuPath, menuName, menuTip, moduleFile )
if kw.has_key('beforeAction'):
editor.addToMenu( menuPath, menuName, menuTip, moduleFile, kw['beforeAction'] )
else:
editor.addToMenu( menuPath, menuName, menuTip, moduleFile )
return

View File

@ -126,15 +126,17 @@ namespace Etesian {
_viewer = viewer;
if (_viewer->hasMenuAction("placeAndRoute.etesianPlace")) {
if (_viewer->hasMenuAction("placeAndRoute.etesianPlaceBlock")) {
cerr << Warning( "GraphicEtesianEngine::addToMenu() - Etesian placer already hooked in." ) << endl;
return;
}
_viewer->addToMenu( "placeAndRoute.etesianPlace"
, "Etesian - Plac&e"
, "Run the <b>Etesian</b> placer"
_viewer->addToMenu( "placeAndRoute.etesianPlaceBlock"
, "Plac&e Block"
, "Place a block [<b>Etesian</b>]"
, std::bind(&GraphicEtesianEngine::_place,this)
, QIcon()
, "placeAndRoute.placeChip"
);
}

View File

@ -205,12 +205,17 @@ namespace Hurricane {
{ return findChild<QAction*>(_getAbsWidgetPath(relativePath)) != NULL; }
QMenu* CellViewer::_getParentMenu( const QString& absolutePath ) const
QAction* CellViewer::getMenuAction( const QString& relativePath ) const
{ return findChild<QAction*>(_getAbsWidgetPath(relativePath)); }
QAction* CellViewer::_getParentMenu( const QString& absolutePath ) const
{
QString parentPath = absolutePath.section('.',0,-2);
QMenu* parentMenu = findChild<QMenu*>(parentPath);
QString parentPath = absolutePath.section('.',0,-2);
QAction* parentMenu = findChild<QAction*>(parentPath);
if (parentMenu == NULL) {
if (parentPath != "viewer") {
cerr << "parentPath:\"" << parentPath.toStdString() << "\"" << endl;
cerr << Warning( "CellViewer::_getParentMenu() - Missing parent menu for %s."
, absolutePath.toStdString().c_str() ) << endl;
}
@ -220,35 +225,45 @@ namespace Hurricane {
}
QMenu* CellViewer::addMenu ( const QString& path, string text, unsigned int flags )
QAction* CellViewer::addMenu ( const QString& path, string text, unsigned int flags )
{
QString absolutePath = _getAbsWidgetPath( path );
QMenu* menu = findChild<QMenu*>(absolutePath);
QAction* actionMenu = findChild<QAction*>(absolutePath);
if (menu != NULL) return menu;
if (actionMenu != NULL) return actionMenu;
QMenu* menu = new QMenu ( tr(text.c_str()), this );
if (flags & TopMenu) {
menu = menuBar()->addMenu( tr(text.c_str()) );
menu->setObjectName( absolutePath );
actionMenu = menuBar()->addMenu( menu );
actionMenu->setObjectName( absolutePath );
} else {
QMenu* parentMenu = _getParentMenu( absolutePath );
menu->setStyleSheet( "font-family: Bitstream Vera Sans Mono" );
QAction* parentMenu = _getParentMenu( absolutePath );
if (parentMenu == NULL) return NULL;
menu = parentMenu->addMenu( tr(text.c_str()) );
menu->setObjectName( absolutePath );
actionMenu = parentMenu->menu()->addMenu( menu );
actionMenu->setObjectName( absolutePath );
}
return menu;
return actionMenu;
}
bool CellViewer::addToMenu ( const QString& path )
bool CellViewer::addToMenu ( const QString& path, QString beforePath )
{
if (not path.endsWith("====")) return false;
QMenu* menu = _getParentMenu( _getAbsWidgetPath(path) );
if (menu == NULL) return false;
QString absolutePath = _getAbsWidgetPath( path );
QAction* menuAction = _getParentMenu( absolutePath );
if (menuAction == NULL) return false;
QAction* before = getMenuAction( beforePath );
QAction* action = new QAction( this );
action->setSeparator ( true );
action->setObjectName( absolutePath );
menuAction->menu()->insertAction( before, action );
menu->addSeparator();
return true;
}
@ -257,12 +272,13 @@ namespace Hurricane {
, string text
, string textTip
, std::function< void() > callback
, QIcon icon )
, QIcon icon
, QString beforePath )
{
QString absolutePath = _getAbsWidgetPath( path );
QAction* action = findChild<QAction*>(absolutePath);
if (action == NULL) {
QMenu* parentMenu = _getParentMenu( absolutePath );
QAction* parentMenu = _getParentMenu( absolutePath );
if (parentMenu == NULL) return NULL;
action = new QAction( tr(text.c_str()), this );
@ -270,7 +286,9 @@ namespace Hurricane {
action->setStatusTip ( tr(textTip.c_str()) );
action->setVisible ( true );
if (not icon.isNull()) action->setIcon( icon );
parentMenu->addAction( action );
QAction* before = getMenuAction( beforePath );
parentMenu->menu()->insertAction( before, action );
_actionCallbacks.insert( make_pair(absolutePath,boost::any(callback)) );
connect( action, SIGNAL(triggered()), this, SLOT(doAction()) );
@ -282,7 +300,8 @@ namespace Hurricane {
QAction* CellViewer::addToMenu ( const QString& path
, string text
, string textTip
, string scriptPath )
, string scriptPath
, QString beforePath )
{
QString absolutePath = _getAbsWidgetPath( path );
QAction* action = findChild<QAction*>(absolutePath);
@ -292,9 +311,10 @@ namespace Hurricane {
action->setStatusTip ( tr(textTip.c_str()) );
action->setVisible ( true );
QMenu* parentMenu = _getParentMenu( absolutePath );
QAction* parentMenu = _getParentMenu( absolutePath );
if (parentMenu != NULL) {
parentMenu->addAction( action );
QAction* before = getMenuAction( beforePath );
parentMenu->menu()->insertAction( before, action );
} else if (absolutePath == "viewer") {
addAction( action );
}
@ -313,6 +333,7 @@ namespace Hurricane {
, QIcon icon
//, QWidget* receiver
//, SlotMethod slotMethod
, QString beforePath
)
{
QString absolutePath = _getAbsWidgetPath( path );
@ -325,9 +346,10 @@ namespace Hurricane {
action->setVisible ( true );
if (not icon.isNull()) action->setIcon( icon );
QMenu* parentMenu = _getParentMenu( absolutePath );
QAction* parentMenu = _getParentMenu( absolutePath );
if (parentMenu != NULL) {
parentMenu->addAction( action );
QAction* before = getMenuAction( beforePath );
parentMenu->menu()->insertAction( before, action );
} else if (absolutePath == "viewer") {
addAction( action );
}
@ -538,13 +560,13 @@ namespace Hurricane {
);
connect( action, SIGNAL(triggered()), this, SLOT(runScriptWidget()) );
action = addToMenu( "tools.stressScript"
, tr("Python Stress Script")
, tr("Run Python Stress Script (50 times...).")
, QKeySequence()
, QIcon(":/images/python-logo-v3.png")
);
connect( action, SIGNAL(triggered()), this, SLOT(runStressScript()) );
// action = addToMenu( "tools.stressScript"
// , tr("Python Stress Script")
// , tr("Run Python Stress Script (50 times...).")
// , QKeySequence()
// , QIcon(":/images/python-logo-v3.png")
// );
// connect( action, SIGNAL(triggered()), this, SLOT(runStressScript()) );
}

View File

@ -107,22 +107,27 @@ extern "C" {
cdebug_log(20,0) << "PyCellViewer_addToMenu()" << endl;
HTRY
METHOD_HEAD("CellViewer.addToMenu()")
char* path = NULL;
char* text = NULL;
char* textTip = NULL;
char* scriptPath = NULL;
if (not PyArg_ParseTuple(args,"s|sss:CellViewer.addToMenu()", &path, &text, &textTip, &scriptPath)) {
PyErr_SetString ( ConstructorError, "CellViewer.addToMenu(): Takes one or four arguments exactly." );
return NULL;
}
if (text != NULL) {
if (cw->addToMenu( path, text, textTip, scriptPath )) Py_RETURN_TRUE;
} else {
if (cw->addToMenu( path )) Py_RETURN_TRUE;
}
METHOD_HEAD("CellViewer.addToMenu()")
char* nullBefore = "";
char* path = NULL;
char* text = NULL;
char* textTip = NULL;
char* scriptPath = NULL;
char* before = NULL;
if (not PyArg_ParseTuple( args, "s|ssss:CellViewer.addToMenu()"
, &path, &text, &textTip, &scriptPath, &before)) {
PyErr_SetString ( ConstructorError, "CellViewer.addToMenu(): Takes either one or five arguments." );
return NULL;
}
if (before == NULL) before = nullBefore;
if (text != NULL) {
if (cw->addToMenu( path, text, textTip, scriptPath, before )) Py_RETURN_TRUE;
} else {
if (cw->addToMenu( path, before )) Py_RETURN_TRUE;
}
HCATCH
Py_RETURN_FALSE;

View File

@ -94,25 +94,30 @@ namespace Hurricane {
QMenu* createDebugMenu ();
bool hasMenu ( const QString& path ) const;
bool hasMenuAction ( const QString& path ) const;
QMenu* addMenu ( const QString& path
QAction* getMenuAction ( const QString& path ) const;
QAction* addMenu ( const QString& path
, std::string text
, unsigned int flags=NoFlags
);
bool addToMenu ( const QString& path );
bool addToMenu ( const QString& path
, QString beforePath="" );
QAction* addToMenu ( const QString& path
, std::string text
, std::string textTip
, std::string text
, std::string textTip
, std::function< void() >
, QIcon icon=QIcon() );
, QIcon icon=QIcon()
, QString beforePath="" );
QAction* addToMenu ( const QString& path
, std::string text
, std::string textTip
, std::string scriptPath );
, std::string text
, std::string textTip
, std::string scriptPath
, QString beforePath="" );
QAction* addToMenu ( QString path
, QString text
, QString textTip
, const QKeySequence& shortCut
, QIcon icon =QIcon());
, QIcon icon =QIcon()
, QString beforePath="" );
inline void setEnableRedrawInterrupt ( bool );
inline void setApplicationName ( const QString& );
inline Observer<CellViewer>* getCellObserver ();
@ -166,7 +171,7 @@ namespace Hurricane {
void rebuildHistory ();
private:
QString _getAbsWidgetPath ( const QString& relPath ) const;
QMenu* _getParentMenu ( const QString& ) const;
QAction* _getParentMenu ( const QString& ) const;
void _runScript ( QString scriptPath );
protected:

View File

@ -359,54 +359,60 @@ namespace Katana {
_viewer = viewer;
if (_viewer->hasMenuAction("placeAndRoute.katana.route")) {
if (not _viewer->hasMenuAction("beta"))
_viewer->addMenu( "beta", "Beta", CellViewer::TopMenu );
if (not _viewer->hasMenuAction("beta.placeAndRoute"))
_viewer->addMenu( "beta.placeAndRoute", "P&&R" );
if (_viewer->hasMenuAction("beta.placeAndRoute.route")) {
cerr << Warning( "GraphicKatanaEngine::addToMenu() - Katana detailed router already hooked in." ) << endl;
return;
}
_viewer->addMenu ( "placeAndRoute.katana" , "Katana" );
_viewer->addMenu ( "placeAndRoute.katana.stepByStep", "&Step by step" );
_viewer->addMenu ( "beta.placeAndRoute.stepByStep", "&Step by step" );
_viewer->addToMenu( "placeAndRoute.katana.route"
, "Katana - &Route"
_viewer->addToMenu( "beta.placeAndRoute.route"
, "&Route . . . . . [Katana]"
, "Route the design (global & detailed)"
, std::bind(&GraphicKatanaEngine::_route,this)
, QIcon()
, "beta.placeAndRoute.stepByStep"
);
_viewer->addToMenu( "placeAndRoute.katana.stepByStep.========" );
_viewer->addToMenu( "placeAndRoute.katana.stepByStep.detailedPreRoute"
, "Katana - Detailed Pre-Route"
_viewer->addToMenu( "beta.placeAndRoute.stepByStep.========" );
_viewer->addToMenu( "beta.placeAndRoute.stepByStep.detailedPreRoute"
, "Detailed Pre-Route . [Katana]"
, "Run the <b>Katana</b> detailed router on pre-routed nets"
, std::bind(&GraphicKatanaEngine::_runNegociatePreRouted,this)
);
_viewer->addToMenu( "placeAndRoute.katana.stepByStep.globalRoute"
, "Katana - &Global Route"
_viewer->addToMenu( "beta.placeAndRoute.stepByStep.globalRoute"
, "&Global Route . . . [Katana]"
, "Run the <b>Katana</b> global router"
, std::bind(&GraphicKatanaEngine::_globalRoute,this)
);
_viewer->addToMenu( "placeAndRoute.katana.stepByStep.detailedRoute"
, "Katana - &Detailed Route"
_viewer->addToMenu( "beta.placeAndRoute.stepByStep.detailedRoute"
, "&Detailed Route . . [Katana]"
, "Run the <b>Katana</b> detailed router"
, std::bind(&GraphicKatanaEngine::_detailRoute,this)
);
_viewer->addToMenu( "placeAndRoute.katana.stepByStep.finalize"
, "Katana - &Finalize Routing"
_viewer->addToMenu( "beta.placeAndRoute.stepByStep.finalize"
, "&Finalize Routing . [Katana]"
, "Closing Routing"
, std::bind(&GraphicKatanaEngine::_finalize,this)
);
_viewer->addToMenu( "placeAndRoute.katana.stepByStep.dumpMeasures"
, "Katana - Dump &Measures"
_viewer->addToMenu( "beta.placeAndRoute.stepByStep.dumpMeasures"
, "Dump &Measures . . [Katana]"
, "Dumping Measurements on the disk"
, std::bind(&GraphicKatanaEngine::_dumpMeasures,this)
);
_viewer->addToMenu( "placeAndRoute.katana.stepByStep.save"
, "Katana - &Save Design"
#if NO_NEED_OF_IT_NOW
_viewer->addToMenu( "beta.placeAndRoute.stepByStep.save"
, "&Save Design"
, "Save routed design (temporary hack)"
, std::bind(&GraphicKatanaEngine::_save,this)
);
#if NO_NEED_OF_IT_NOW
_viewer->addToMenu( "placeAndRoute.katana.stepByStep.runTest"
, "Katana - Run &Test"
_viewer->addToMenu( "beta.placeAndRoute.stepByStep.runTest"
, "Run &Test"
, "Run Test Program (symmetric routing of gmChamla)"
, std::bind(&GraphicKatanaEngine::_runTest,this)
);

View File

@ -285,57 +285,59 @@ namespace Kite {
}
_viewer->addToMenu( "placeAndRoute.route"
, "Kite - &Route"
, "Route the design (global & detailed)"
, "&Route"
, "Complete routing of the design (global, detailed and finalize) [<b>Kite</b>]"
, std::bind(&GraphicKiteEngine::_route,this)
, QIcon()
, "placeAndRoute.stepByStep"
);
_viewer->addToMenu( "placeAndRoute.stepByStep.========" );
_viewer->addToMenu( "placeAndRoute.stepByStep.wipeoutRouting"
, "Kite - Erase Previous Routing"
, "Erase Previous Routing"
, "Erase any previously routed wires"
, std::bind(&GraphicKiteEngine::_wipeoutRouting,this)
);
_viewer->addToMenu( "placeAndRoute.stepByStep.detailedPreRoute"
, "Kite - Detailed Pre-Route"
, "Run the <b>Kite</b> detailed router on pre-routed nets"
, "Detailed Pre-Route"
, "Run the detailed router on global pre-routed nets [<b>Kite</b>]"
, std::bind(&GraphicKiteEngine::_runNegociatePreRouted,this)
);
_viewer->addToMenu( "placeAndRoute.stepByStep.globalRoute"
, "Kite - &Global Route"
, "Run the <b>Knik</b> global router"
, "&Global Route"
, "Run the global router [<b>nik</b>]"
, std::bind(&GraphicKiteEngine::_globalRoute,this)
);
_viewer->addToMenu( "placeAndRoute.stepByStep.loadGlobalRouting"
, "Kite - &Load Global Routing"
, "Load a solution for the global routing (.kgr)"
, "&Load Global Routing"
, "Load a solution for the global routing (.kgr) [<b>Knik</b>]"
, std::bind(&GraphicKiteEngine::_loadGlobalSolution,this)
);
_viewer->addToMenu( "placeAndRoute.stepByStep.saveGlobalRouting"
, "Kite - &Save Global Routing"
, "Save a global router solution (.kgr)"
, "&Save Global Routing"
, "Save a global router solution (.kgr) [<b>Knik</b>]"
, std::bind(&GraphicKiteEngine::_saveGlobalSolution,this)
);
_viewer->addToMenu( "placeAndRoute.stepByStep.detailedRoute"
, "Kite - &Detailed Route"
, "Run the <b>Kite</b> detailed router"
, "&Detailed Route"
, "Run the detailed router [<b>Kite</b>]"
, std::bind(&GraphicKiteEngine::_detailRoute,this)
);
_viewer->addToMenu( "placeAndRoute.stepByStep.finalize"
, "Kite - &Finalize Routing"
, "Closing Routing"
, "&Finalize Routing"
, "Cleanup all routing related data structures [<b>Kite</b>]"
, std::bind(&GraphicKiteEngine::_finalize,this)
);
_viewer->addToMenu( "placeAndRoute.stepByStep.dumpMeasures"
, "Kite - Dump &Measures"
, "Dumping Measurements on the disk"
, "Dump &Measures"
, "Dumping Measurements on the disk [<b>Kite</b>]"
, std::bind(&GraphicKiteEngine::_dumpMeasures,this)
);
_viewer->addToMenu( "placeAndRoute.stepByStep.save"
, "Kite - &Save Design"
, "Save routed design (temporary hack)"
, std::bind(&GraphicKiteEngine::_save,this)
);
// _viewer->addToMenu( "placeAndRoute.stepByStep.save"
// , "&Save Design"
// , "Save routed design (temporary hack)"
// , std::bind(&GraphicKiteEngine::_save,this)
// );
}

View File

@ -141,9 +141,9 @@ def runDemo ( cell, editor ):
def unicornHook ( **kw ):
editor = kw['editor']
editor.addMenu( 'tutorials' , 'Tutorials', Viewer.CellViewer.TopMenu )
editor.addMenu( 'tutorials.plugins', 'Plugins' , Viewer.CellViewer.NoFlags )
plugins.kwUnicornHook( 'tutorials.plugins.runDemo'
, 'Tutorial - Run Demo (Python flavor)'
#editor.addMenu( 'tutorials.plugins', 'Plugins' , Viewer.CellViewer.NoFlags )
plugins.kwUnicornHook( 'tutorials.runDemo'
, 'Run Demo (Python flavor)'
, 'Launch runDemo() in the Tutorial Python plugin.'
, sys.modules[__name__].__file__
, **kw

View File

@ -67,7 +67,7 @@ def unicornConfigure ( **kw ):
print WarningMessage( 'The <plugins> menu has already been created.' )
return
editor.addMenu( 'plugins', 'Plu&gins', Viewer.CellViewer.TopMenu )
#editor.addMenu( 'plugins', 'Plu&gins', Viewer.CellViewer.TopMenu )
for pluginFile in os.listdir( pluginsDir ):
if pluginFile == "__init__.py": continue

View File

@ -186,6 +186,8 @@ namespace Unicorn {
, tr("Library Manager")
, tr("Browse through Views, Cells & Libraries")
, QKeySequence(tr("CTRL+M"))
, QIcon()
, "tools.script"
);
connect( action, SIGNAL(triggered()), _libraryManager, SLOT(toggleShow()) );
connect( this , SIGNAL(cellLoadedFromDisk(Cell*)), _libraryManager, SLOT(updateLibrary(Cell*)) );

View File

@ -186,9 +186,9 @@ if __name__ == '__main__':
unicorn = Unicorn.UnicornGui.create()
unicorn.setApplicationName ('cgt')
unicorn.registerTool (Katana.GraphicKatanaEngine.grab())
unicorn.registerTool (Etesian.GraphicEtesianEngine.grab())
unicorn.registerTool (Kite.GraphicKiteEngine.grab())
unicorn.registerTool (Katana.GraphicKatanaEngine.grab())
unicorn.registerTool (Bora.GraphicBoraEngine.grab())
#unicorn.setAnonNetSelectable(False)
unicorn.setLayerVisible ("grid" , False);