From 69c75b9ea94362948a6db787611fd250266b1e99 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Sat, 21 Mar 2015 17:29:04 +0100 Subject: [PATCH] Rewrite the Unicorn ImportCell to allow new formats to be hooked in. * New: In Hurricane, In CellWidget, add methods to emit CellPreModificated and CellPostModificated Qt signals (from non-Qt aware objects). * New: In Unicorn, In ImportCell, parsers are now dynamically hooked in the importer, allowing third party application (i.e. Chams) to add their own. See the ImportCell::addImporter() method. * Bug: In Unicorn, in FindUNICORN.cmake, seems to be unable to detect the UnicornGui.h. Not a blocking problem because the include dir is shared with other tools correctly detected. But still... --- crlcore/src/ccore/ToolEngine.cpp | 7 ++- crlcore/src/ccore/crlcore/DefImport.h | 23 +++----- etesian/src/CMakeLists.txt | 4 +- etesian/src/etesian/EtesianEngine.h | 1 - .../src/viewer/hurricane/viewer/CellViewer.h | 24 +++++---- unicorn/CMakeLists.txt | 1 + unicorn/cmake_modules/FindUNICORN.cmake | 2 +- unicorn/src/ImportCell.cpp | 49 ++++++++--------- unicorn/src/ImportCellDialog.cpp | 8 +++ unicorn/src/UnicornGui.cpp | 28 ++++++++-- unicorn/src/unicorn/ImportCell.h | 18 ++++++- unicorn/src/unicorn/ImportCellDialog.h | 3 +- unicorn/src/unicorn/UnicornGui.h | 53 ++++++++++--------- 13 files changed, 128 insertions(+), 93 deletions(-) diff --git a/crlcore/src/ccore/ToolEngine.cpp b/crlcore/src/ccore/ToolEngine.cpp index 7e821e40..e2b6555c 100644 --- a/crlcore/src/ccore/ToolEngine.cpp +++ b/crlcore/src/ccore/ToolEngine.cpp @@ -336,10 +336,9 @@ namespace CRL { ToolEngine* ToolEngine::get ( const Cell* cell, const Name& name ) { ToolEnginesRelation* relation = ToolEnginesRelation::getToolEnginesRelation(cell); - if (!relation) - return NULL; - else - { + if (not relation) { + return NULL; + } else { forEach ( ToolEngine*, itool, relation->getSlaveOwners().getSubSet()) { if (itool->getName() == name) return *itool; diff --git a/crlcore/src/ccore/crlcore/DefImport.h b/crlcore/src/ccore/crlcore/DefImport.h index 65a0267e..66cef2ca 100644 --- a/crlcore/src/ccore/crlcore/DefImport.h +++ b/crlcore/src/ccore/crlcore/DefImport.h @@ -1,15 +1,9 @@ - // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2010-2010, All Rights Reserved +// Copyright (c) UPMC 2010-2015, All Rights Reserved // -// =================================================================== -// -// $Id$ -// -// x-----------------------------------------------------------------x -// | | +// +-----------------------------------------------------------------+ // | C O R I O L I S | // | C a d e n c e D E F I m p o r t e r | // | | @@ -17,16 +11,13 @@ // | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | =============================================================== | // | C++ Header : "./crlcore/DefImport.h" | -// | *************************************************************** | -// | U p d a t e s | -// | | -// x-----------------------------------------------------------------x +// +-----------------------------------------------------------------+ -#ifndef __CRL_DEF_IMPORT__ -#define __CRL_DEF_IMPORT__ +#ifndef CRL_DEF_IMPORT_H +#define CRL_DEF_IMPORT_H -#include +#include namespace Hurricane { class Cell; @@ -47,4 +38,4 @@ namespace CRL { } // End of CRL namespace. -#endif // __CRL_DEF_IMPORT__ +#endif // CRL_DEF_IMPORT_H diff --git a/etesian/src/CMakeLists.txt b/etesian/src/CMakeLists.txt index d67555df..703fde79 100644 --- a/etesian/src/CMakeLists.txt +++ b/etesian/src/CMakeLists.txt @@ -58,11 +58,11 @@ PREFIX "" OUTPUT_NAME "Etesian" ) + target_link_libraries ( pyEtesian etesian + ${CORIOLIS_PYTHON_LIBRARIES} # add_executable ( etesian.bin ${etesiancpps} ) #target_link_libraries ( etesian.bin etesian ) - target_link_libraries ( pyEtesian etesian - ${CORIOLIS_PYTHON_LIBRARIES} ) install ( TARGETS etesian DESTINATION lib${LIB_SUFFIX} ) # install ( TARGETS etesian.bin DESTINATION bin ) diff --git a/etesian/src/etesian/EtesianEngine.h b/etesian/src/etesian/EtesianEngine.h index 1777122f..cdb1a7ca 100644 --- a/etesian/src/etesian/EtesianEngine.h +++ b/etesian/src/etesian/EtesianEngine.h @@ -51,7 +51,6 @@ namespace Etesian { // Class : "Etesian::EtesianEngine". class EtesianEngine : public CRL::ToolEngine { - public: public: static const Name& staticGetName (); static EtesianEngine* create ( Cell* ); diff --git a/hurricane/src/viewer/hurricane/viewer/CellViewer.h b/hurricane/src/viewer/hurricane/viewer/CellViewer.h index e8602756..2b4ba6eb 100644 --- a/hurricane/src/viewer/hurricane/viewer/CellViewer.h +++ b/hurricane/src/viewer/hurricane/viewer/CellViewer.h @@ -1,7 +1,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2015, All Rights Reserved +// Copyright (c) UPMC 2008-2015, All Rights Reserved // // +-----------------------------------------------------------------+ // | H U R R I C A N E | @@ -144,6 +144,8 @@ namespace Hurricane { void runStressScript (); inline void emitCellAboutToChange (); inline void emitCellChanged (); + inline void emitCellPreModificated (); + inline void emitCellPostModificated (); signals: void showSelectionToggled ( bool ); void stateChanged ( shared_ptr& ); @@ -190,15 +192,17 @@ namespace Hurricane { // Inline Functions. - inline bool CellViewer::isToolInterrupted () const { return _toolInterrupt; } - inline CellObserver* CellViewer::getCellObserver () { return &_cellObserver; } - inline CellWidget* CellViewer::getCellWidget () { return _cellWidget; } - inline const CellWidget* CellViewer::getCellWidget () const { return _cellWidget; } - inline ControllerWidget* CellViewer::getControllerWidget () { return _controller; } - inline void CellViewer::setApplicationName ( const QString& name ) { _applicationName = name; } - inline void CellViewer::setLayerVisible ( const Name& layer, bool visible ) { _cellWidget->setLayerVisible(layer,visible); } - inline void CellViewer::emitCellAboutToChange () { _flags |= InCellChange; emit cellPreModificated(); } - inline void CellViewer::emitCellChanged () { _flags &= ~InCellChange; emit cellPostModificated(); } + inline bool CellViewer::isToolInterrupted () const { return _toolInterrupt; } + inline CellObserver* CellViewer::getCellObserver () { return &_cellObserver; } + inline CellWidget* CellViewer::getCellWidget () { return _cellWidget; } + inline const CellWidget* CellViewer::getCellWidget () const { return _cellWidget; } + inline ControllerWidget* CellViewer::getControllerWidget () { return _controller; } + inline void CellViewer::setApplicationName ( const QString& name ) { _applicationName = name; } + inline void CellViewer::setLayerVisible ( const Name& layer, bool visible ) { _cellWidget->setLayerVisible(layer,visible); } + inline void CellViewer::emitCellAboutToChange () { _flags |= InCellChange; emit cellPreModificated(); } + inline void CellViewer::emitCellChanged () { _flags &= ~InCellChange; emit cellPostModificated(); } + inline void CellViewer::emitCellPreModificated () { emit cellPreModificated(); } + inline void CellViewer::emitCellPostModificated () { emit cellPostModificated(); } inline void CellViewer::setEnableRedrawInterrupt ( bool state ) { _cellWidget->setEnableRedrawInterrupt(state); } diff --git a/unicorn/CMakeLists.txt b/unicorn/CMakeLists.txt index 7fd76f47..d7ec65d6 100644 --- a/unicorn/CMakeLists.txt +++ b/unicorn/CMakeLists.txt @@ -35,6 +35,7 @@ #find_package(SOLSTICE REQUIRED) add_subdirectory(src) + add_subdirectory(cmake_modules) if(BUILD_DOC) find_package(Doxygen REQUIRED) diff --git a/unicorn/cmake_modules/FindUNICORN.cmake b/unicorn/cmake_modules/FindUNICORN.cmake index d424db0d..d303aa02 100644 --- a/unicorn/cmake_modules/FindUNICORN.cmake +++ b/unicorn/cmake_modules/FindUNICORN.cmake @@ -15,7 +15,7 @@ IF(UNIX) # # Look for an installation. # - FIND_PATH(UNICORN_INCLUDE_PATH NAMES unicorn/UnicornEngine.h PATHS + FIND_PATH(UNICORN_INCLUDE_PATH NAMES unicorn/UnicornGui.h PATHS # Look in other places. ${CORIOLIS_DIR_SEARCH} PATH_SUFFIXES include/coriolis diff --git a/unicorn/src/ImportCell.cpp b/unicorn/src/ImportCell.cpp index ab313d69..49500d7c 100644 --- a/unicorn/src/ImportCell.cpp +++ b/unicorn/src/ImportCell.cpp @@ -1,7 +1,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2014-2015, All Rights Reserved +// Copyright (c) UPMC 2014-2015, All Rights Reserved // // +-----------------------------------------------------------------+ // | C O R I O L I S | @@ -16,12 +16,8 @@ #include #include "hurricane/Error.h" -#include "crlcore/AcmSigda.h" -#include "crlcore/Ispd04Bookshelf.h" -#include "crlcore/Ispd05Bookshelf.h" -#include "crlcore/Iccad04Lefdef.h" -#include "crlcore/DefImport.h" #include "unicorn/ImportCell.h" +#include "unicorn/ImportCellDialog.h" namespace Unicorn { @@ -31,35 +27,34 @@ namespace Unicorn { using std::string; using Hurricane::Error; using Hurricane::Cell; - using CRL::AcmSigda; - using CRL::Ispd04; - using CRL::Ispd05; - using CRL::Iccad04Lefdef; - using CRL::DefImport; + + + ImportCell::ImportCell () + : _count (0) + , _lut () + , _dialog(NULL) + { } + + + void ImportCell::addImporter ( std::string menuName, std::function callback ) + { + _lut.insert( make_pair( _count, make_pair(menuName,callback) ) ); + _dialog->addFormat( menuName.c_str(), _count++ ); + } Cell* ImportCell::load ( const string& cellName, int format ) { Cell* cell = NULL; - switch ( format ) { - case AcmSigda: - cell = AcmSigda::load( cellName ); - break; - case Ispd04: - cell = Ispd04::load( cellName ); - break; - case Ispd05: - cell = Ispd05::load( cellName ); - break; - case Iccad04: - cell = Iccad04Lefdef::load( cellName, 0 ); - break; - case AllianceDef: - cell = DefImport::load( cellName.c_str() , DefImport::FitAbOnCells ); - break; + ImportLut::iterator iimport = _lut.find( format ); + if (iimport == _lut.end()) { + cerr << Error( "Importer id:%d for cell %s not found.", format, cellName.c_str() ) << endl; + return NULL; } + cell = iimport->second.second( cellName ); + if (not cell) { cerr << Error( "Cell not found: %s", cellName.c_str() ) << endl; } diff --git a/unicorn/src/ImportCellDialog.cpp b/unicorn/src/ImportCellDialog.cpp index 6410515f..b1f62541 100644 --- a/unicorn/src/ImportCellDialog.cpp +++ b/unicorn/src/ImportCellDialog.cpp @@ -81,11 +81,13 @@ namespace Unicorn { formatLabel->setFont ( Graphics::getNormalFont(true) ); hLayout2->addWidget ( formatLabel ); +#if 0 _formatComboBox->addItem ( tr("ACM/SIGDA (aka MCNC, .bench)"), ImportCell::AcmSigda ); _formatComboBox->addItem ( tr("ISPD'04 (Bookshelf)") , ImportCell::Ispd04 ); _formatComboBox->addItem ( tr("ISPD'05 (Bookshelf)") , ImportCell::Ispd05 ); _formatComboBox->addItem ( tr("ICCAD'04 (LEF/DEF)") , ImportCell::Iccad04 ); _formatComboBox->addItem ( tr("Alliance compliant DEF") , ImportCell::AllianceDef ); +#endif hLayout2->addWidget ( _formatComboBox ); QVBoxLayout* vLayout = new QVBoxLayout (); @@ -105,6 +107,12 @@ namespace Unicorn { } + void ImportCellDialog::addFormat ( QString menuName, int index ) + { + _formatComboBox->addItem( menuName, index ); + } + + const QString ImportCellDialog::getCellName () const { return _lineEdit->text(); } diff --git a/unicorn/src/UnicornGui.cpp b/unicorn/src/UnicornGui.cpp index ab9ec2a9..3831a6ac 100644 --- a/unicorn/src/UnicornGui.cpp +++ b/unicorn/src/UnicornGui.cpp @@ -25,6 +25,11 @@ #include "crlcore/Catalog.h" #include "crlcore/AllianceFramework.h" #include "crlcore/GraphicToolEngine.h" +#include "crlcore/AcmSigda.h" +#include "crlcore/Ispd04Bookshelf.h" +#include "crlcore/Ispd05Bookshelf.h" +#include "crlcore/Iccad04Lefdef.h" +#include "crlcore/DefImport.h" #include "crlcore/DefExport.h" #include "crlcore/GdsDriver.h" #include "unicorn/ImportCell.h" @@ -43,6 +48,11 @@ namespace Unicorn { using CRL::System; using CRL::Catalog; using CRL::AllianceFramework; + using CRL::AcmSigda; + using CRL::Ispd04; + using CRL::Ispd05; + using CRL::Iccad04Lefdef; + using CRL::DefImport; using CRL::DefExport; using CRL::GdsDriver; @@ -61,16 +71,24 @@ namespace Unicorn { UnicornGui::UnicornGui ( QWidget* parent ) - : CellViewer (parent) - , _tools () - , _importDialog(new ImportCellDialog(this)) - , _exportDialog(new ExportCellDialog(this)) + : CellViewer (parent) + , _tools () + , _importCell () + , _importDialog (new ImportCellDialog(this)) + , _exportDialog (new ExportCellDialog(this)) { addMenu ( "placeAndRoute" , "P&&R" , CellViewer::TopMenu ); addMenu ( "placeAndRoute.stepByStep", "&Step by Step" ); addToMenu( "placeAndRoute.========" ); _runUnicornInit(); + + _importCell.setDialog( _importDialog ); + _importCell.addImporter( "ACM/SIGDA (aka MCNC, .bench)", std::bind( &AcmSigda::load , placeholders::_1 ) ); + _importCell.addImporter( "ISPD'04 (Bookshelf)" , std::bind( &Ispd04::load , placeholders::_1 ) ); + _importCell.addImporter( "ISPD'05 (Bookshelf)" , std::bind( &Ispd05::load , placeholders::_1 ) ); + _importCell.addImporter( "ICCAD'04 (LEF/DEF)" , std::bind( &Iccad04Lefdef::load, placeholders::_1, 0 ) ); + _importCell.addImporter( "Alliance compliant DEF" , std::bind( &DefImport::load , placeholders::_1, DefImport::FitAbOnCells) ); } @@ -210,7 +228,7 @@ namespace Unicorn { int format; if ( _importDialog->runDialog( cellName, format, newViewer ) ) { - Cell* cell = ImportCell::load( cellName.toStdString(), format ); + Cell* cell = _importCell.load( cellName.toStdString(), format ); if (cell) { UnicornGui* viewer = this; diff --git a/unicorn/src/unicorn/ImportCell.h b/unicorn/src/unicorn/ImportCell.h index 41b777b4..011a8ac7 100644 --- a/unicorn/src/unicorn/ImportCell.h +++ b/unicorn/src/unicorn/ImportCell.h @@ -18,6 +18,8 @@ #define UNICORN_IMPORT_CELL_H #include +#include +#include namespace Hurricane { class Cell; @@ -25,15 +27,27 @@ namespace Hurricane { namespace Unicorn { + class ImportCellDialog; + class ImportCell { public: - enum Formats { AcmSigda=1, Ispd04, Ispd05, Iccad04, AllianceDef }; + typedef std::map< int, std::pair< std::string, std::function > > ImportLut; public: - static Hurricane::Cell* load ( const std::string&, int format ); + ImportCell (); + inline void setDialog ( ImportCellDialog* ); + Hurricane::Cell* load ( const std::string&, int format ); + void addImporter ( std::string, std::function ); + private: + int _count; + ImportLut _lut; + ImportCellDialog* _dialog; }; + inline void ImportCell::setDialog ( ImportCellDialog* dialog ) { _dialog = dialog; } + + } // Unicorn namespace. #endif diff --git a/unicorn/src/unicorn/ImportCellDialog.h b/unicorn/src/unicorn/ImportCellDialog.h index 1528bf9b..d4f54bbd 100644 --- a/unicorn/src/unicorn/ImportCellDialog.h +++ b/unicorn/src/unicorn/ImportCellDialog.h @@ -10,7 +10,7 @@ // | Author : Jean-Paul CHAPUT | // | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | =============================================================== | -// | C++ Header : "./ImportCellDialog.h" | +// | C++ Header : "./unicorn/ImportCellDialog.h" | // +-----------------------------------------------------------------+ @@ -32,6 +32,7 @@ namespace Unicorn { public: ImportCellDialog ( QWidget* parent=NULL ); + void addFormat ( QString menuName, int index ); bool runDialog ( QString& name, int& format, bool& newViewerRequest ); const QString getCellName () const; bool useNewViewer () const; diff --git a/unicorn/src/unicorn/UnicornGui.h b/unicorn/src/unicorn/UnicornGui.h index e648b543..3ad275ac 100644 --- a/unicorn/src/unicorn/UnicornGui.h +++ b/unicorn/src/unicorn/UnicornGui.h @@ -19,16 +19,18 @@ #ifndef UNICORN_UNICORN_H #define UNICORN_UNICORN_H -#include -#include -using namespace std; - -#include "hurricane/viewer/CellViewer.h" -#include "crlcore/Banner.h" +#include +#include +#include +#include +#include "hurricane/viewer/CellViewer.h" +#include "crlcore/Banner.h" namespace CRL { class GraphicTool; } +#include "unicorn/ImportCell.h" + namespace Unicorn { @@ -46,32 +48,35 @@ namespace Unicorn { class UnicornGui : public CellViewer { Q_OBJECT; public: - static UnicornGui* create ( QWidget* parent=NULL ); - void destroy (); - static inline Banner& getBanner (); - virtual Cell* getCellFromDb ( const char* name ); - void registerTool ( GraphicTool* ); - virtual std::string _getString () const; - public slots: - void openCell (); - void saveCell (); - void importCell (); - void exportCell (); - protected: - UnicornGui ( QWidget* parent ); - virtual ~UnicornGui (); - virtual void _postCreate (); - virtual void _preDestroy (); - void _runUnicornInit (); + static UnicornGui* create ( QWidget* parent=NULL ); + void destroy (); + static inline Banner& getBanner (); + virtual Cell* getCellFromDb ( const char* name ); + inline ImportCell* getImportCell (); + void registerTool ( GraphicTool* ); + virtual std::string _getString () const; + public slots: + void openCell (); + void saveCell (); + void importCell (); + void exportCell (); + protected: + UnicornGui ( QWidget* parent ); + virtual ~UnicornGui (); + virtual void _postCreate (); + virtual void _preDestroy (); + void _runUnicornInit (); protected: static Banner _banner; set _tools; + ImportCell _importCell; ImportCellDialog* _importDialog; ExportCellDialog* _exportDialog; }; - inline Banner& UnicornGui::getBanner () { return _banner; } + inline Banner& UnicornGui::getBanner () { return _banner; } + inline ImportCell* UnicornGui::getImportCell () { return &_importCell; } } // End of Unicorn namespace.