From f17bbf567d486f3fa71aa78f18206f6b17dcddbe Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Sun, 22 Aug 2010 12:39:05 +0000 Subject: [PATCH] * ./unicorn: - New: Adds graphic support for Import/Export files (ACM/SIGDA, ISPD04, ICCAD04 and LEF/DEF). - New: To avoid buggy database deletion, and also to speed up, now exits with a system exit. Previous behavior could be acticated with the "--delete-db" boolean switch. --- unicorn/src/CMakeLists.txt | 7 +- unicorn/src/CgtMain.cpp | 8 ++ unicorn/src/ExportCellDialog.cpp | 138 +++++++++++++++++++++++ unicorn/src/ImportCellDialog.cpp | 146 +++++++++++++++++++++++++ unicorn/src/UnicornGui.cpp | 90 ++++++++++++++- unicorn/src/unicorn/ExportCellDialog.h | 59 ++++++++++ unicorn/src/unicorn/ImportCellDialog.h | 60 ++++++++++ unicorn/src/unicorn/UnicornGui.h | 7 ++ 8 files changed, 512 insertions(+), 3 deletions(-) create mode 100644 unicorn/src/ExportCellDialog.cpp create mode 100644 unicorn/src/ImportCellDialog.cpp create mode 100644 unicorn/src/unicorn/ExportCellDialog.h create mode 100644 unicorn/src/unicorn/ImportCellDialog.h diff --git a/unicorn/src/CMakeLists.txt b/unicorn/src/CMakeLists.txt index aba1c07c..38ba57fc 100644 --- a/unicorn/src/CMakeLists.txt +++ b/unicorn/src/CMakeLists.txt @@ -2,7 +2,8 @@ include ( ${QT_USE_FILE} ) - include_directories ( ${HURRICANE_INCLUDE_DIR} + include_directories ( ${UNICORN_SOURCE_DIR}/src + ${HURRICANE_INCLUDE_DIR} ${CORIOLIS_INCLUDE_DIR} ${BOOKSHELF_INCLUDE_DIR} ${CONFIGURATION_INCLUDE_DIR} @@ -15,9 +16,13 @@ set ( mocincludes unicorn/UnicornGui.h unicorn/OpenCellDialog.h unicorn/SaveCellDialog.h + unicorn/ImportCellDialog.h + unicorn/ExportCellDialog.h ) set ( cpps OpenCellDialog.cpp SaveCellDialog.cpp + ImportCellDialog.cpp + ExportCellDialog.cpp UnicornGui.cpp ) set ( cgtcpp CgtMain.cpp ) diff --git a/unicorn/src/CgtMain.cpp b/unicorn/src/CgtMain.cpp index a2cfcee5..b4b350a1 100644 --- a/unicorn/src/CgtMain.cpp +++ b/unicorn/src/CgtMain.cpp @@ -102,6 +102,7 @@ int main ( int argc, char *argv[] ) try { bfs::path::default_name_check ( bfs::portable_posix_name ); + bool destroyDatabase; float edgeCapacity; float expandStep; unsigned long eventsLimit; @@ -121,6 +122,8 @@ int main ( int argc, char *argv[] ) boptions::options_description options ("Command line arguments & options"); options.add_options() ( "help,h" , "Print this help." ) + ( "destroy-db" , boptions::bool_switch(&destroyDatabase)->default_value(false) + , "Perform a complete deletion of the database (may be buggy).") ( "trace-level,l" , boptions::value(&traceLevel) , "Set the level of trace, trace messages with a level superior to " " will be printed on ." ) @@ -385,6 +388,8 @@ int main ( int argc, char *argv[] ) //DebugSession::addToTrace ( cell, "NET2530" ); //DebugSession::addToTrace ( cell, "NET8464" ); //DebugSession::addToTrace ( cell, "NET8242" ); + // ibm02. + //DebugSession::addToTrace ( cell, "net18015" ); // Python Script test. @@ -506,6 +511,9 @@ int main ( int argc, char *argv[] ) returnCode = (kiteSuccess) ? 0 : 1; } } + + if ( not destroyDatabase ) exit ( 0 ); + cmess1 << " o Full database deletion (may be buggy)." << endl; } catch ( Error& e ) { cerr << e.what() << endl; diff --git a/unicorn/src/ExportCellDialog.cpp b/unicorn/src/ExportCellDialog.cpp new file mode 100644 index 00000000..69e4564a --- /dev/null +++ b/unicorn/src/ExportCellDialog.cpp @@ -0,0 +1,138 @@ + +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved +// +// =================================================================== +// +// $Id$ +// +// x-----------------------------------------------------------------x +// | | +// | C O R I O L I S | +// | U n i c o r n - M a i n G U I | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | =============================================================== | +// | C++ Module : "./ExportCellDialog.cpp" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + +#include +using namespace std; + +#include +#include +#include +#include +#include +#include +#include + +#include "hurricane/Warning.h" +#include "hurricane/viewer/Graphics.h" + +#include "unicorn/ExportCellDialog.h" + + +namespace Unicorn { + + + using Hurricane::Warning; + using Hurricane::Graphics; + + +// ------------------------------------------------------------------- +// Class : "ExportCellDialog". + + + ExportCellDialog::ExportCellDialog ( QWidget* parent ) + : QDialog (parent) + , _lineEdit (new QLineEdit()) + , _formatComboBox(new QComboBox()) + { + setWindowTitle ( tr("Export Cell") ); + + QLabel* label = new QLabel (); + label->setText ( tr("Enter Cell name (without extention)") ); + label->setFont ( Graphics::getNormalFont(true) ); + + QPushButton* okButton = new QPushButton (); + okButton->setText ( "OK" ); + okButton->setDefault ( true ); + + QPushButton* cancelButton = new QPushButton (); + cancelButton->setText ( "Cancel" ); + + QHBoxLayout* hLayout1 = new QHBoxLayout (); + hLayout1->addStretch (); + hLayout1->addWidget ( okButton ); + hLayout1->addStretch (); + hLayout1->addWidget ( cancelButton ); + hLayout1->addStretch (); + + QFrame* separator = new QFrame (); + separator->setFrameShape ( QFrame::HLine ); + separator->setFrameShadow ( QFrame::Sunken ); + + QHBoxLayout* hLayout2 = new QHBoxLayout (); + + QLabel* formatLabel = new QLabel (); + formatLabel->setText ( tr("Export Format") ); + formatLabel->setFont ( Graphics::getNormalFont(true) ); + hLayout2->addWidget ( formatLabel ); + + _formatComboBox->addItem ( tr("Alliance compliant DEF") , AllianceDef ); + hLayout2->addWidget ( _formatComboBox ); + + QVBoxLayout* vLayout = new QVBoxLayout (); + vLayout->setSizeConstraint ( QLayout::SetFixedSize ); + vLayout->addWidget ( label ); + vLayout->addWidget ( _lineEdit ); + vLayout->addLayout ( hLayout2 ); + vLayout->addWidget ( separator ); + vLayout->addLayout ( hLayout1 ); + + setLayout ( vLayout ); + //setModal ( true ); + + connect ( okButton, SIGNAL(clicked()), this, SLOT(accept()) ); + connect ( cancelButton, SIGNAL(clicked()), this, SLOT(reject()) ); + } + + + const QString ExportCellDialog::getCellName () const + { return _lineEdit->text(); } + + + void ExportCellDialog::setCellName ( const QString& name ) + { _lineEdit->setText ( name ); } + + + bool ExportCellDialog::runDialog ( QString& name, int& format ) + { + setCellName ( name ); + bool dialogResult = (exec() == Accepted); + + name = getCellName (); + format = getFormat (); + + return dialogResult; + } + + + int ExportCellDialog::getFormat () const + { + int index = _formatComboBox->currentIndex(); + if ( index < 0 ) return 0; + + return _formatComboBox->itemData(index).toInt(); + } + + +} // End of Unicorn namespace. diff --git a/unicorn/src/ImportCellDialog.cpp b/unicorn/src/ImportCellDialog.cpp new file mode 100644 index 00000000..83a4401b --- /dev/null +++ b/unicorn/src/ImportCellDialog.cpp @@ -0,0 +1,146 @@ + +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved +// +// =================================================================== +// +// $Id$ +// +// x-----------------------------------------------------------------x +// | | +// | C O R I O L I S | +// | U n i c o r n - M a i n G U I | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | =============================================================== | +// | C++ Module : "./ImportCellDialog.cpp" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + +#include +using namespace std; + +#include +#include +#include +#include +#include +#include +#include + +#include "hurricane/Warning.h" +#include "hurricane/viewer/Graphics.h" + +#include "unicorn/ImportCellDialog.h" + + +namespace Unicorn { + + + using Hurricane::Warning; + using Hurricane::Graphics; + + +// ------------------------------------------------------------------- +// Class : "ImportCellDialog". + + + ImportCellDialog::ImportCellDialog ( QWidget* parent ) + : QDialog (parent) + , _lineEdit (new QLineEdit()) + , _viewerCheckBox(new QCheckBox()) + , _formatComboBox(new QComboBox()) + { + setWindowTitle ( tr("Import Cell") ); + + QLabel* label = new QLabel (); + label->setText ( tr("Enter Cell name (without extention)") ); + label->setFont ( Graphics::getNormalFont(true) ); + + _lineEdit->setMinimumWidth ( 400 ); + _viewerCheckBox->setText ( tr("Import in new Viewer") ); + + QPushButton* okButton = new QPushButton (); + okButton->setText ( "OK" ); + okButton->setDefault ( true ); + + QPushButton* cancelButton = new QPushButton (); + cancelButton->setText ( "Cancel" ); + + QHBoxLayout* hLayout1 = new QHBoxLayout (); + hLayout1->addStretch (); + hLayout1->addWidget ( okButton ); + hLayout1->addStretch (); + hLayout1->addWidget ( cancelButton ); + hLayout1->addStretch (); + + QFrame* separator = new QFrame (); + separator->setFrameShape ( QFrame::HLine ); + separator->setFrameShadow ( QFrame::Sunken ); + + QHBoxLayout* hLayout2 = new QHBoxLayout (); + + QLabel* formatLabel = new QLabel (); + formatLabel->setText ( tr("Import Format") ); + formatLabel->setFont ( Graphics::getNormalFont(true) ); + hLayout2->addWidget ( formatLabel ); + + _formatComboBox->addItem ( tr("ACM/SIGDA (aka MCNC, .bench)"), AcmSigda ); + _formatComboBox->addItem ( tr("ISPD'04 (Bookshelf)") , Ispd04 ); + _formatComboBox->addItem ( tr("ICCAD'04 (LEF/DEF)") , Iccad04 ); + _formatComboBox->addItem ( tr("Alliance compliant DEF") , AllianceDef ); + hLayout2->addWidget ( _formatComboBox ); + + QVBoxLayout* vLayout = new QVBoxLayout (); + vLayout->setSizeConstraint ( QLayout::SetFixedSize ); + vLayout->addWidget ( label ); + vLayout->addWidget ( _lineEdit ); + vLayout->addLayout ( hLayout2 ); + vLayout->addWidget ( _viewerCheckBox ); + vLayout->addWidget ( separator ); + vLayout->addLayout ( hLayout1 ); + + setLayout ( vLayout ); + //setModal ( true ); + + connect ( okButton, SIGNAL(clicked()), this, SLOT(accept()) ); + connect ( cancelButton, SIGNAL(clicked()), this, SLOT(reject()) ); + } + + + const QString ImportCellDialog::getCellName () const + { return _lineEdit->text(); } + + + bool ImportCellDialog::useNewViewer () const + { return _viewerCheckBox->isChecked(); } + + + bool ImportCellDialog::runDialog ( QString& name, int& format, bool& newViewerRequest ) + { + bool dialogResult = (exec() == Accepted); + + name = getCellName (); + newViewerRequest = useNewViewer (); + format = getFormat (); + + return dialogResult; + } + + + int ImportCellDialog::getFormat () const + { + int index = _formatComboBox->currentIndex(); + if ( index < 0 ) return 0; + + return _formatComboBox->itemData(index).toInt(); + } + + +} // End of Unicorn namespace. diff --git a/unicorn/src/UnicornGui.cpp b/unicorn/src/UnicornGui.cpp index e5b87f65..9a75efeb 100644 --- a/unicorn/src/UnicornGui.cpp +++ b/unicorn/src/UnicornGui.cpp @@ -32,9 +32,16 @@ #include "crlcore/Catalog.h" #include "crlcore/AllianceFramework.h" #include "crlcore/GraphicToolEngine.h" +#include "crlcore/AcmSigda.h" +#include "crlcore/Ispd04Bookshelf.h" +#include "crlcore/Iccad04Lefdef.h" +#include "crlcore/DefImport.h" +#include "crlcore/DefExport.h" #include "unicorn/OpenCellDialog.h" #include "unicorn/SaveCellDialog.h" +#include "unicorn/ImportCellDialog.h" +#include "unicorn/ExportCellDialog.h" #include "unicorn/UnicornGui.h" @@ -44,6 +51,11 @@ namespace Unicorn { using Hurricane::Warning; using CRL::Catalog; using CRL::AllianceFramework; + using CRL::AcmSigda; + using CRL::Ispd04; + using CRL::Iccad04Lefdef; + using CRL::DefImport; + using CRL::DefExport; // ------------------------------------------------------------------- @@ -60,8 +72,10 @@ namespace Unicorn { UnicornGui::UnicornGui ( QWidget* parent ) - : CellViewer(parent) - , _tools () + : CellViewer (parent) + , _tools () + , _importDialog(new ImportCellDialog(this)) + , _exportDialog(new ExportCellDialog(this)) { } @@ -101,6 +115,16 @@ namespace Unicorn { saveAction->setVisible ( true ); connect ( saveAction, SIGNAL(triggered()), this, SLOT(saveCell()) ); } + + QAction* importAction = findChild("viewer.menuBar.file.importCell"); + if ( importAction ) { + connect ( importAction, SIGNAL(triggered()), this, SLOT(importCell()) ); + } + + QAction* exportAction = findChild("viewer.menuBar.file.exportCell"); + if ( exportAction ) { + connect ( exportAction, SIGNAL(triggered()), this, SLOT(exportCell()) ); + } } @@ -163,6 +187,68 @@ namespace Unicorn { } + void UnicornGui::importCell () + { + QString cellName; + bool newViewer; + int format; + + if ( _importDialog->runDialog ( cellName, format, newViewer ) ) { + Cell* cell = NULL; + + switch ( format ) { + case ImportCellDialog::AcmSigda: + cell = AcmSigda::load ( cellName.toStdString() ); + break; + case ImportCellDialog::Ispd04: + cell = Ispd04::load ( cellName.toStdString() ); + break; + case ImportCellDialog::Iccad04: + cell = Iccad04Lefdef::load ( cellName.toStdString() , 0 ); + break; + case ImportCellDialog::AllianceDef: + cell = DefImport::load ( cellName.toStdString().c_str() , DefImport::FitAbOnCells ); + break; + } + + if ( cell ) { + UnicornGui* viewer = this; + if ( newViewer ) { + viewer = UnicornGui::create (); + viewer->show (); + } + viewer->setCell ( cell ); + } else + cerr << "[ERROR] Cell not found: " << cellName.toStdString() << endl; + } + } + + + void UnicornGui::exportCell () + { + Cell* cell = getCell(); + if ( cell == NULL ) return; + + QString cellName= getString(cell->getName()).c_str(); + int format; + + if ( _exportDialog->runDialog ( cellName, format ) ) { + renameCell ( cellName.toStdString().c_str() ); + switch ( format ) { + // case ImportCellDialog::AcmSigda: + // break; + // case ImportCellDialog::Ispd04: + // break; + // case ImportCellDialog::Iccad04: + // break; + case ExportCellDialog::AllianceDef: + DefExport::drive ( cell, DefExport::WithLEF ); + break; + } + } + } + + void UnicornGui::saveCell () { Cell* cell = getCell(); diff --git a/unicorn/src/unicorn/ExportCellDialog.h b/unicorn/src/unicorn/ExportCellDialog.h new file mode 100644 index 00000000..ac235265 --- /dev/null +++ b/unicorn/src/unicorn/ExportCellDialog.h @@ -0,0 +1,59 @@ + +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved +// +// =================================================================== +// +// $Id$ +// +// x-----------------------------------------------------------------x +// | | +// | C O R I O L I S | +// | U n i c o r n - M a i n G U I | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | =============================================================== | +// | C++ Header : "./ExportCellDialog.h" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + +#ifndef __UNICORN_EXPORT_CELL_DIALOG_H__ +#define __UNICORN_EXPORT_CELL_DIALOG_H__ + +#include + +class QCheckBox; +class QComboBox; +class QLineEdit; + + +namespace Unicorn { + + + class ExportCellDialog : public QDialog { + Q_OBJECT; + + public: + enum Formats { AllianceDef=1 }; + public: + ExportCellDialog ( QWidget* parent=NULL ); + bool runDialog ( QString& name, int& format ); + const QString getCellName () const; + int getFormat () const; + void setCellName ( const QString& ); + protected: + QLineEdit* _lineEdit; + QComboBox* _formatComboBox; + }; + + +} // End of Unicorn namespace. + + +#endif diff --git a/unicorn/src/unicorn/ImportCellDialog.h b/unicorn/src/unicorn/ImportCellDialog.h new file mode 100644 index 00000000..d166cf3f --- /dev/null +++ b/unicorn/src/unicorn/ImportCellDialog.h @@ -0,0 +1,60 @@ + +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved +// +// =================================================================== +// +// $Id$ +// +// x-----------------------------------------------------------------x +// | | +// | C O R I O L I S | +// | U n i c o r n - M a i n G U I | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | =============================================================== | +// | C++ Header : "./ImportCellDialog.h" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + +#ifndef __UNICORN_IMPORT_CELL_DIALOG_H__ +#define __UNICORN_IMPORT_CELL_DIALOG_H__ + +#include + +class QCheckBox; +class QComboBox; +class QLineEdit; + + +namespace Unicorn { + + + class ImportCellDialog : public QDialog { + Q_OBJECT; + + public: + enum Formats { AcmSigda=1, Ispd04, Iccad04, AllianceDef }; + public: + ImportCellDialog ( QWidget* parent=NULL ); + bool runDialog ( QString& name, int& format, bool& newViewerRequest ); + const QString getCellName () const; + bool useNewViewer () const; + int getFormat () const; + protected: + QLineEdit* _lineEdit; + QCheckBox* _viewerCheckBox; + QComboBox* _formatComboBox; + }; + + +} // End of Unicorn namespace. + + +#endif diff --git a/unicorn/src/unicorn/UnicornGui.h b/unicorn/src/unicorn/UnicornGui.h index 69efa2dc..c97902a8 100644 --- a/unicorn/src/unicorn/UnicornGui.h +++ b/unicorn/src/unicorn/UnicornGui.h @@ -49,6 +49,9 @@ namespace Unicorn { using CRL::Banner; using CRL::GraphicTool; + class ImportCellDialog; + class ExportCellDialog; + class UnicornGui : public CellViewer { Q_OBJECT; @@ -61,6 +64,8 @@ namespace Unicorn { public slots: void openCell (); void saveCell (); + void importCell (); + void exportCell (); protected: UnicornGui ( QWidget* parent ); virtual ~UnicornGui (); @@ -69,6 +74,8 @@ namespace Unicorn { protected: static Banner _banner; set _tools; + ImportCellDialog* _importDialog; + ExportCellDialog* _exportDialog; };