From f836905c6ff1d45b0258db2c7da0bfd15564afa5 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Fri, 14 May 2010 07:37:33 +0000 Subject: [PATCH] * ./unicorn: - Change: Rename COpenCellDialog in OpenCellDialog. - Change: In CgtMain, now the save parameter must be supplied with a design name. The same should be different from the input one to avoid overwrites. - New: SaveCellDialog to write back the Cell. Currently only writes the layout view. --- unicorn/src/CMakeLists.txt | 90 +++++----- unicorn/src/CgtMain.cpp | 8 +- ...COpenCellDialog.cpp => OpenCellDialog.cpp} | 24 +-- unicorn/src/SaveCellDialog.cpp | 166 ++++++++++++++++++ unicorn/src/UnicornGui.cpp | 27 ++- .../{COpenCellDialog.h => OpenCellDialog.h} | 8 +- unicorn/src/unicorn/SaveCellDialog.h | 61 +++++++ unicorn/src/unicorn/UnicornGui.h | 5 +- 8 files changed, 319 insertions(+), 70 deletions(-) rename unicorn/src/{COpenCellDialog.cpp => OpenCellDialog.cpp} (88%) create mode 100644 unicorn/src/SaveCellDialog.cpp rename unicorn/src/unicorn/{COpenCellDialog.h => OpenCellDialog.h} (87%) create mode 100644 unicorn/src/unicorn/SaveCellDialog.h diff --git a/unicorn/src/CMakeLists.txt b/unicorn/src/CMakeLists.txt index ffebc6da..394e9d1d 100644 --- a/unicorn/src/CMakeLists.txt +++ b/unicorn/src/CMakeLists.txt @@ -6,9 +6,11 @@ ) set ( mocincludes unicorn/UnicornGui.h - unicorn/COpenCellDialog.h + unicorn/OpenCellDialog.h + unicorn/SaveCellDialog.h ) - set ( cpps COpenCellDialog.cpp + set ( cpps OpenCellDialog.cpp + SaveCellDialog.cpp UnicornGui.cpp ) set ( cgtcpp CgtMain.cpp ) @@ -16,48 +18,48 @@ qt4_wrap_cpp ( MOCcpps ${mocincludes} ) qt4_add_resources ( RCC_SRCS Unicorn.qrc ) - add_library ( unicorn ${cpps} ${MOCcpps} ) - target_link_libraries ( unicorn ${SOLSTICE_GRAPHICAL_LIBRARIES} - ${SOLSTICE_LIBRARIES} - ${EQUINOX_GRAPHICAL_LIBRARIES} - ${EQUINOX_LIBRARIES} - ${KITE_GRAPHICAL_LIBRARIES} - ${KITE_LIBRARIES} - ${KATABATIC_GRAPHICAL_LIBRARIES} - ${KATABATIC_LIBRARIES} - ${KNIK_GRAPHICAL_LIBRARIES} - ${KNIK_LIBRARIES} - ${CORIOLIS_LIBRARIES} - ${HURRICANE_GRAPHICAL_LIBRARIES} - ${HURRICANE_LIBRARIES} - ${AGDS_LIBRARY} - ${CIF_LIBRARY} - ${LEFDEF_LIBRARIES} - ${OA_LIBRARIES} - ${QT_LIBRARIES} - ${Boost_LIBRARIES} + add_library ( unicorn ${cpps} ${MOCcpps} ) + target_link_libraries ( unicorn ${SOLSTICE_GRAPHICAL_LIBRARIES} + ${SOLSTICE_LIBRARIES} + ${EQUINOX_GRAPHICAL_LIBRARIES} + ${EQUINOX_LIBRARIES} + ${KITE_GRAPHICAL_LIBRARIES} + ${KITE_LIBRARIES} + ${KATABATIC_GRAPHICAL_LIBRARIES} + ${KATABATIC_LIBRARIES} + ${KNIK_GRAPHICAL_LIBRARIES} + ${KNIK_LIBRARIES} + ${CORIOLIS_LIBRARIES} + ${HURRICANE_GRAPHICAL_LIBRARIES} + ${HURRICANE_LIBRARIES} + ${AGDS_LIBRARY} + ${CIF_LIBRARY} + ${LEFDEF_LIBRARIES} + ${OA_LIBRARIES} + ${QT_LIBRARIES} + ${Boost_LIBRARIES} ) - add_executable ( cgt ${cgtcpp} ) - target_link_libraries ( cgt unicorn - ${SOLSTICE_GRAPHICAL_LIBRARIES} - ${SOLSTICE_LIBRARIES} - ${EQUINOX_GRAPHICAL_LIBRARIES} - ${EQUINOX_LIBRARIES} - ${KITE_GRAPHICAL_LIBRARIES} - ${KITE_LIBRARIES} - ${KATABATIC_GRAPHICAL_LIBRARIES} - ${KATABATIC_LIBRARIES} - ${KNIK_GRAPHICAL_LIBRARIES} - ${KNIK_LIBRARIES} - ${CORIOLIS_LIBRARIES} - ${HURRICANE_LIBRARIES} - ${HURRICANE_GRAPHICAL_LIBRARIES} - ${OA_LIBRARIES} - ${QT_LIBRARIES} - ${Boost_LIBRARIES} + add_executable ( cgt ${cgtcpp} ) + target_link_libraries ( cgt unicorn + ${SOLSTICE_GRAPHICAL_LIBRARIES} + ${SOLSTICE_LIBRARIES} + ${EQUINOX_GRAPHICAL_LIBRARIES} + ${EQUINOX_LIBRARIES} + ${KITE_GRAPHICAL_LIBRARIES} + ${KITE_LIBRARIES} + ${KATABATIC_GRAPHICAL_LIBRARIES} + ${KATABATIC_LIBRARIES} + ${KNIK_GRAPHICAL_LIBRARIES} + ${KNIK_LIBRARIES} + ${CORIOLIS_LIBRARIES} + ${HURRICANE_LIBRARIES} + ${HURRICANE_GRAPHICAL_LIBRARIES} + ${OA_LIBRARIES} + ${QT_LIBRARIES} + ${Boost_LIBRARIES} ) - install ( TARGETS unicorn DESTINATION /lib) - install ( TARGETS cgt DESTINATION /bin ) - install ( FILES ${includes} - ${mocIncludes} DESTINATION /include/coriolis/unicorn ) + install ( TARGETS unicorn DESTINATION /lib) + install ( TARGETS cgt DESTINATION /bin ) + install ( FILES ${includes} + ${mocIncludes} DESTINATION /include/coriolis/unicorn ) diff --git a/unicorn/src/CgtMain.cpp b/unicorn/src/CgtMain.cpp index 867007d8..9512d5b8 100644 --- a/unicorn/src/CgtMain.cpp +++ b/unicorn/src/CgtMain.cpp @@ -123,7 +123,6 @@ int main ( int argc, char *argv[] ) bool textMode; bool loadGlobal; bool saveGlobal; - bool saveDesign; poptions::options_description options ("Command line arguments & options"); options.add_options() @@ -158,7 +157,7 @@ int main ( int argc, char *argv[] ) "allowed to perform." ) ( "cell,c" , poptions::value() , "The name of the cell to load, whithout extension." ) - ( "save,s" , poptions::bool_switch(&saveDesign)->default_value(false) + ( "save,s" , poptions::value()->default_value("") , "Save the routed design.") ( "save-global" , poptions::bool_switch(&saveGlobal)->default_value(false) , "Save the global routing solution."); @@ -338,9 +337,8 @@ int main ( int argc, char *argv[] ) kite->dumpMeasures (); kite->destroy (); - if ( saveDesign ) { - string name = getString(cell->getName()) + "_kite"; - cell->setName ( name ); + if ( arguments.count("save") ) { + cell->setName ( arguments["save"].as().c_str() ); af->saveCell ( cell, Catalog::State::Physical ); } diff --git a/unicorn/src/COpenCellDialog.cpp b/unicorn/src/OpenCellDialog.cpp similarity index 88% rename from unicorn/src/COpenCellDialog.cpp rename to unicorn/src/OpenCellDialog.cpp index 33ec917f..6f858cc8 100644 --- a/unicorn/src/COpenCellDialog.cpp +++ b/unicorn/src/OpenCellDialog.cpp @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved // // =================================================================== // @@ -16,7 +16,7 @@ // | Author : Jean-Paul CHAPUT | // | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | =============================================================== | -// | C++ Module : "./COpenCellDialog.cpp" | +// | C++ Module : "./OpenCellDialog.cpp" | // | *************************************************************** | // | U p d a t e s | // | | @@ -40,7 +40,7 @@ using namespace std; #include "crlcore/Environment.h" #include "crlcore/AllianceFramework.h" -#include "unicorn/COpenCellDialog.h" +#include "unicorn/OpenCellDialog.h" namespace Unicorn { @@ -53,12 +53,12 @@ namespace Unicorn { // ------------------------------------------------------------------- -// Class : "COpenCellDialog". +// Class : "OpenCellDialog". - COpenCellDialog::COpenCellDialog ( QWidget* parent ) - : QDialog(parent) - , _lineEdit(NULL) + OpenCellDialog::OpenCellDialog ( QWidget* parent ) + : QDialog (parent) + , _lineEdit (NULL) , _viewerCheckBox(NULL) { setWindowTitle ( tr("Open Cell") ); @@ -126,21 +126,21 @@ namespace Unicorn { } - const QString COpenCellDialog::getCellName () const + const QString OpenCellDialog::getCellName () const { return _lineEdit->text(); } - bool COpenCellDialog::newViewerRequest () const + bool OpenCellDialog::newViewerRequest () const { return _viewerCheckBox->isChecked(); } - bool COpenCellDialog::runDialog ( QWidget* parent, QString& name, bool& newViewerRequest ) + bool OpenCellDialog::runDialog ( QWidget* parent, QString& name, bool& newViewerRequest ) { - COpenCellDialog* dialog = new COpenCellDialog ( parent ); + OpenCellDialog* dialog = new OpenCellDialog ( parent ); bool dialogResult = (dialog->exec() == Accepted); name = dialog->getCellName (); @@ -152,7 +152,7 @@ namespace Unicorn { } - void COpenCellDialog::formatChanged ( int index ) + void OpenCellDialog::formatChanged ( int index ) { Environment* environment = AllianceFramework::get()->getEnvironment(); switch ( index ) { diff --git a/unicorn/src/SaveCellDialog.cpp b/unicorn/src/SaveCellDialog.cpp new file mode 100644 index 00000000..e14f4db4 --- /dev/null +++ b/unicorn/src/SaveCellDialog.cpp @@ -0,0 +1,166 @@ + +// -*- 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 : "./SaveCellDialog.cpp" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + +#include +using namespace std; + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "hurricane/Warning.h" +#include "hurricane/viewer/Graphics.h" + +#include "crlcore/Environment.h" +#include "crlcore/AllianceFramework.h" +#include "unicorn/SaveCellDialog.h" + + +namespace Unicorn { + + + using Hurricane::Warning; + using Hurricane::Graphics; + using CRL::Environment; + using CRL::AllianceFramework; + + +// ------------------------------------------------------------------- +// Class : "SaveCellDialog". + + + SaveCellDialog::SaveCellDialog ( QWidget* parent ) + : QDialog (parent) + , _lineEdit(NULL) + { + setWindowTitle ( tr("Save Cell") ); + + QLabel* label = new QLabel (); + label->setText ( tr("Enter Cell name (without extention)") ); + label->setFont ( Graphics::getNormalFont(true) ); + + _lineEdit = new QLineEdit (); + _lineEdit->setMinimumWidth ( 400 ); + + 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 (); + QButtonGroup* formatGroup = new QButtonGroup (); + + QRadioButton* formatButton = new QRadioButton (); + formatButton->setText ( tr("vst/ap") ); + formatButton->setChecked ( true ); + formatGroup->setId ( formatButton, 0 ); + formatGroup->addButton ( formatButton ); + hLayout2->addWidget ( formatButton ); + + formatButton = new QRadioButton (); + formatButton->setText ( tr("DEF") ); + formatButton->setChecked ( false ); + formatGroup->setId ( formatButton, 1 ); + formatGroup->addButton ( formatButton ); + hLayout2->addWidget ( formatButton ); + + QVBoxLayout* vLayout = new QVBoxLayout (); + vLayout->setSizeConstraint ( QLayout::SetFixedSize ); + vLayout->addWidget ( label ); + vLayout->addWidget ( _lineEdit ); + vLayout->addLayout ( hLayout1 ); + vLayout->addWidget ( separator ); + vLayout->addLayout ( hLayout2 ); + + setLayout ( vLayout ); + //setModal ( true ); + + connect ( okButton, SIGNAL(clicked()) , this, SLOT(accept()) ); + connect ( cancelButton, SIGNAL(clicked()) , this, SLOT(reject()) ); + connect ( formatGroup , SIGNAL(buttonClicked(int)), this, SLOT(formatChanged(int)) ); + } + + + const QString SaveCellDialog::getCellName () const + { + return _lineEdit->text(); + } + + + void SaveCellDialog::setCellName ( const QString& name ) + { + return _lineEdit->setText ( name ); + } + + + bool SaveCellDialog::runDialog ( QWidget* parent, QString& name ) + { + auto_ptr dialog ( new SaveCellDialog(parent) ); + dialog->setCellName ( name ); + bool dialogResult = (dialog->exec() == Accepted); + + name = dialog->getCellName (); + + return dialogResult; + } + + + void SaveCellDialog::formatChanged ( int index ) + { + Environment* environment = AllianceFramework::get()->getEnvironment(); + switch ( index ) { + case 0: + environment->setOUT_LO ( "vst" ); + environment->setOUT_PH ( "ap" ); + break; + case 1: + environment->setOUT_LO ( "def" ); + environment->setOUT_PH ( "def" ); + break; + default: + cerr << Warning("Unknown output format: %d.",index) << endl; + } + } + + +} // End of Unicorn namespace. diff --git a/unicorn/src/UnicornGui.cpp b/unicorn/src/UnicornGui.cpp index e655c692..a43b11f2 100644 --- a/unicorn/src/UnicornGui.cpp +++ b/unicorn/src/UnicornGui.cpp @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved // // =================================================================== // @@ -33,7 +33,8 @@ #include "crlcore/AllianceFramework.h" #include "crlcore/GraphicToolEngine.h" -#include "unicorn/COpenCellDialog.h" +#include "unicorn/OpenCellDialog.h" +#include "unicorn/SaveCellDialog.h" #include "unicorn/UnicornGui.h" @@ -92,6 +93,12 @@ namespace Unicorn { if ( openAction ) { connect ( openAction, SIGNAL(triggered()), this, SLOT(openCell()) ); } + + QAction* saveAction = findChild("viewer.menuBar.file.saveCell"); + if ( saveAction ) { + saveAction->setVisible ( true ); + connect ( saveAction, SIGNAL(triggered()), this, SLOT(saveCell()) ); + } } @@ -140,7 +147,7 @@ namespace Unicorn { QString cellName; bool newViewer; - if ( COpenCellDialog::runDialog ( this, cellName, newViewer ) ) { + if ( OpenCellDialog::runDialog ( this, cellName, newViewer ) ) { Cell* cell = getCellFromDb ( cellName.toStdString().c_str() ); if ( cell ) { if ( newViewer ) { @@ -154,4 +161,18 @@ namespace Unicorn { } + void UnicornGui::saveCell () + { + Cell* cell = getCell(); + if ( cell == NULL ) return; + + QString cellName = getString(cell->getName()).c_str(); + + if ( SaveCellDialog::runDialog ( this, cellName ) ) { + renameCell ( cellName.toStdString().c_str() ); + AllianceFramework::get()->saveCell ( cell, Catalog::State::Physical ); + } + } + + } // End of Unicorn namespace. diff --git a/unicorn/src/unicorn/COpenCellDialog.h b/unicorn/src/unicorn/OpenCellDialog.h similarity index 87% rename from unicorn/src/unicorn/COpenCellDialog.h rename to unicorn/src/unicorn/OpenCellDialog.h index 5d087cc0..a95c44de 100644 --- a/unicorn/src/unicorn/COpenCellDialog.h +++ b/unicorn/src/unicorn/OpenCellDialog.h @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved // // =================================================================== // @@ -16,7 +16,7 @@ // | Author : Jean-Paul CHAPUT | // | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | =============================================================== | -// | C++ Header : "./COpenCellDialog.h" | +// | C++ Header : "./OpenCellDialog.h" | // | *************************************************************** | // | U p d a t e s | // | | @@ -35,7 +35,7 @@ class QLineEdit; namespace Unicorn { - class COpenCellDialog : public QDialog { + class OpenCellDialog : public QDialog { Q_OBJECT; public: @@ -43,7 +43,7 @@ namespace Unicorn { const QString getCellName () const; bool newViewerRequest () const; protected: - COpenCellDialog ( QWidget* parent=NULL ); + OpenCellDialog ( QWidget* parent=NULL ); protected slots: void formatChanged ( int ); diff --git a/unicorn/src/unicorn/SaveCellDialog.h b/unicorn/src/unicorn/SaveCellDialog.h new file mode 100644 index 00000000..079c23d2 --- /dev/null +++ b/unicorn/src/unicorn/SaveCellDialog.h @@ -0,0 +1,61 @@ + +// -*- 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 : "./SaveCellDialog.h" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + +#ifndef __UNICORN_SAVE_CELL_DIALOG_H__ +#define __UNICORN_SAVE_CELL_DIALOG_H__ + +#include + +class QCheckBox; +class QLineEdit; + + +namespace Unicorn { + + + class SaveCellDialog : public QDialog { + Q_OBJECT; + + public: + static bool runDialog ( QWidget* parent, QString& name ); + const QString getCellName () const; + public slots: + void setCellName ( const QString& ); + protected: + SaveCellDialog ( QWidget* parent=NULL ); + protected slots: + void formatChanged ( int ); + + protected: + QLineEdit* _lineEdit; + }; + + + + +} // End of Unicorn namespace. + + +#endif diff --git a/unicorn/src/unicorn/UnicornGui.h b/unicorn/src/unicorn/UnicornGui.h index d609d306..0cc54c51 100644 --- a/unicorn/src/unicorn/UnicornGui.h +++ b/unicorn/src/unicorn/UnicornGui.h @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved +// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved // // =================================================================== // @@ -61,9 +61,10 @@ namespace Unicorn { void registerTool ( GraphicTool* ); public slots: void openCell (); + void saveCell (); protected: UnicornGui ( QWidget* parent ); - virtual ~UnicornGui (); + virtual ~UnicornGui (); virtual void _postCreate (); virtual void _preDestroy (); protected: