2010-03-09 09:26:22 -06:00
|
|
|
// -*- C++ -*-
|
|
|
|
//
|
|
|
|
// This file is part of the Coriolis Software.
|
Update to Qt 5, requires cmake 2.8.9. New placer: Etesian.
Update to Qt 5:
* Change: Now requires at least cmake 2.8.9.
* Change: CMakeLists.txt needs small changes. Qt modules must be found
one by one (Core, Gui, Widgets). Must add "set(CMAKE_AUTOMOC ON)"
in the top file and replace "qt4" prefix in macros by "qt5".
Added simpler macro "setup_qt()" in FindBootstrap.cmake.
* Change: No longer need to include <QGtkStyle> is is choosen by default
according to the current desktop environment.
* Change: In <hurricane>, In HApplication, launch ExceptionWidget when
a std::exception is catched instead of silently discarting it.
New placer Tool: Etesian
* New: <etesian> analytical placer. Encapsulate Coloquinte from
Gabriel Gouvine.
* New: in <documentation>, add stub demonstration ToolEngine <smurf>.
Needs to be commented.
Miscellaneous:
* New: in <boostrap> and <unicorn>, added support for Etesian, the new
analytic placer. The tool itself will be added in the next commit.
* Bug: in <CellWidget>, when shifting the display buffer, we no longer
can copy the buffer on itself (we should never have). Now go through
a temporary one (PlaneId::AutoCopy) which is added to the
DrawingPlanes. Affect "goLeft()" and "goUp()".
* Bug: In <CellWidget>, remove the WA_PaintOnScreen flag/attribute.
When it's on, no PaintEvent is transmitted to the CellWidget
when it's the central widget of the <CellViewer> (QMainWindow).
It's something I still don't understand from the doc of Qt.
* Change: In <AreaCommand>, use the PlaneId enumeration instead of a
anonymous numerical index.
* Change: In <HApplication>, no longer catch and silently discard
standartd exceptions but launch the ExceptionWidget...
Suppress the now deprecated constructor with "Type" argument.
* Change: In <SelectionModel>, the "reset()" method is deprecated in
Qt5, instead enclose the "clear()" by a "beginResetModel()" and
"endResetModel()" pair.
* New: In <crlcore>, add support for ISPD05 benchmarks (in Bookshelf
format). Forked from ISPD04 and not finished yet.
* Change: In <Mauka>, distinguish the Action string identifier from
<Etesian>
* New: In <unicorn>, add entry for ISPD05 loader. Add entry for
<Etesian> analytic placer.
2014-03-22 05:50:36 -05:00
|
|
|
// Copyright (c) UPMC/LIP6 2008-2014, All Rights Reserved
|
2010-03-09 09:26:22 -06:00
|
|
|
//
|
2012-11-16 06:54:58 -06:00
|
|
|
// +-----------------------------------------------------------------+
|
2010-03-09 09:26:22 -06:00
|
|
|
// | 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 |
|
|
|
|
// | =============================================================== |
|
2012-11-16 06:54:58 -06:00
|
|
|
// | C++ Module : "./UnicornGui.cpp" |
|
|
|
|
// +-----------------------------------------------------------------+
|
2010-03-09 09:26:22 -06:00
|
|
|
|
|
|
|
|
2014-03-26 08:47:17 -05:00
|
|
|
#include <QAction>
|
|
|
|
#include <QMenu>
|
|
|
|
#include "hurricane/Warning.h"
|
|
|
|
#include "hurricane/viewer/CellWidget.h"
|
|
|
|
#include "crlcore/Catalog.h"
|
|
|
|
#include "crlcore/AllianceFramework.h"
|
|
|
|
#include "crlcore/GraphicToolEngine.h"
|
|
|
|
#include "crlcore/DefExport.h"
|
|
|
|
#include "unicorn/ImportCell.h"
|
|
|
|
#include "unicorn/OpenCellDialog.h"
|
|
|
|
#include "unicorn/SaveCellDialog.h"
|
|
|
|
#include "unicorn/ImportCellDialog.h"
|
|
|
|
#include "unicorn/ExportCellDialog.h"
|
|
|
|
#include "unicorn/UnicornGui.h"
|
2010-03-09 09:26:22 -06:00
|
|
|
|
|
|
|
|
|
|
|
namespace Unicorn {
|
|
|
|
|
|
|
|
using Hurricane::Warning;
|
|
|
|
using CRL::Catalog;
|
|
|
|
using CRL::AllianceFramework;
|
2010-08-22 07:39:05 -05:00
|
|
|
using CRL::DefExport;
|
2010-03-09 09:26:22 -06:00
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
// Class : "UnicornGui".
|
|
|
|
|
|
|
|
|
2010-06-22 08:59:40 -05:00
|
|
|
Banner UnicornGui::_banner ( "Unicorn"
|
|
|
|
, "1.0b"
|
|
|
|
, "Coriolis Main GUI"
|
|
|
|
, "2008"
|
|
|
|
, "Jean-Paul Chaput"
|
|
|
|
, ""
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2010-03-09 09:26:22 -06:00
|
|
|
UnicornGui::UnicornGui ( QWidget* parent )
|
2010-08-22 07:39:05 -05:00
|
|
|
: CellViewer (parent)
|
|
|
|
, _tools ()
|
|
|
|
, _importDialog(new ImportCellDialog(this))
|
|
|
|
, _exportDialog(new ExportCellDialog(this))
|
2010-03-09 09:26:22 -06:00
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
UnicornGui::~UnicornGui ()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
UnicornGui* UnicornGui::create ( QWidget* parent )
|
|
|
|
{
|
|
|
|
UnicornGui* unicorn = new UnicornGui ( parent );
|
|
|
|
|
|
|
|
unicorn->_postCreate ();
|
|
|
|
|
|
|
|
return unicorn;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UnicornGui::destroy ()
|
|
|
|
{
|
|
|
|
_preDestroy ();
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UnicornGui::_postCreate ()
|
|
|
|
{
|
|
|
|
setApplicationName ( tr("unicorn") );
|
|
|
|
setWindowIcon ( QIcon(":/images/diet-coke.png") );
|
|
|
|
|
|
|
|
QAction* openAction = findChild<QAction*>("viewer.menuBar.file.openCell");
|
|
|
|
if ( openAction ) {
|
|
|
|
connect ( openAction, SIGNAL(triggered()), this, SLOT(openCell()) );
|
|
|
|
}
|
2010-05-14 02:37:33 -05:00
|
|
|
|
|
|
|
QAction* saveAction = findChild<QAction*>("viewer.menuBar.file.saveCell");
|
|
|
|
if ( saveAction ) {
|
|
|
|
saveAction->setVisible ( true );
|
|
|
|
connect ( saveAction, SIGNAL(triggered()), this, SLOT(saveCell()) );
|
|
|
|
}
|
2010-08-22 07:39:05 -05:00
|
|
|
|
|
|
|
QAction* importAction = findChild<QAction*>("viewer.menuBar.file.importCell");
|
|
|
|
if ( importAction ) {
|
|
|
|
connect ( importAction, SIGNAL(triggered()), this, SLOT(importCell()) );
|
|
|
|
}
|
|
|
|
|
|
|
|
QAction* exportAction = findChild<QAction*>("viewer.menuBar.file.exportCell");
|
|
|
|
if ( exportAction ) {
|
|
|
|
connect ( exportAction, SIGNAL(triggered()), this, SLOT(exportCell()) );
|
|
|
|
}
|
2010-03-09 09:26:22 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UnicornGui::_preDestroy ()
|
|
|
|
{
|
|
|
|
set<GraphicTool*>::iterator itool = _tools.begin();
|
|
|
|
for ( ; itool != _tools.end() ; itool++ )
|
|
|
|
(*itool)->release ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Cell* UnicornGui::getCellFromDb ( const char* name )
|
|
|
|
{
|
|
|
|
return AllianceFramework::get()->getCell ( name, Catalog::State::Views );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UnicornGui::registerTool ( GraphicTool* tool )
|
|
|
|
{
|
|
|
|
assert ( tool != NULL );
|
|
|
|
|
|
|
|
if ( _tools.find(tool) != _tools.end() ) {
|
|
|
|
cerr << Warning ( "Tool %s already registered in Unicorn (ignored)."
|
|
|
|
, getString(tool->getName()).c_str() ) << endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_tools.insert ( tool );
|
|
|
|
|
|
|
|
const GraphicTool::DrawGoMap& drawGos = tool->getDrawGos ();
|
|
|
|
GraphicTool::DrawGoMap::const_iterator idrawGo = drawGos.begin();
|
|
|
|
|
|
|
|
for ( ; idrawGo != drawGos.end() ; idrawGo++ )
|
|
|
|
getCellWidget()->addDrawExtensionGo ( idrawGo->first
|
|
|
|
, idrawGo->second.getInit()
|
|
|
|
, idrawGo->second.getDraw()
|
|
|
|
);
|
|
|
|
|
|
|
|
tool->addToMenu ( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UnicornGui::openCell ()
|
|
|
|
{
|
|
|
|
UnicornGui* viewer = this;
|
|
|
|
QString cellName;
|
|
|
|
bool newViewer;
|
|
|
|
|
2010-05-14 02:37:33 -05:00
|
|
|
if ( OpenCellDialog::runDialog ( this, cellName, newViewer ) ) {
|
2010-03-09 09:26:22 -06:00
|
|
|
Cell* cell = getCellFromDb ( cellName.toStdString().c_str() );
|
|
|
|
if ( cell ) {
|
|
|
|
if ( newViewer ) {
|
|
|
|
viewer = UnicornGui::create ();
|
|
|
|
viewer->show ();
|
|
|
|
}
|
|
|
|
viewer->setCell ( cell );
|
|
|
|
} else
|
|
|
|
cerr << "[ERROR] Cell not found: " << cellName.toStdString() << endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-22 07:39:05 -05:00
|
|
|
void UnicornGui::importCell ()
|
|
|
|
{
|
|
|
|
QString cellName;
|
|
|
|
bool newViewer;
|
|
|
|
int format;
|
|
|
|
|
2014-03-26 08:47:17 -05:00
|
|
|
if ( _importDialog->runDialog( cellName, format, newViewer ) ) {
|
|
|
|
Cell* cell = ImportCell::load( cellName.toStdString(), format );
|
2010-08-22 07:39:05 -05:00
|
|
|
|
2014-03-26 08:47:17 -05:00
|
|
|
if (cell) {
|
2010-08-22 07:39:05 -05:00
|
|
|
UnicornGui* viewer = this;
|
2014-03-26 08:47:17 -05:00
|
|
|
if (newViewer) {
|
|
|
|
viewer = UnicornGui::create();
|
|
|
|
viewer->show();
|
2010-08-22 07:39:05 -05:00
|
|
|
}
|
2014-03-26 08:47:17 -05:00
|
|
|
viewer->setCell( cell );
|
|
|
|
}
|
2010-08-22 07:39:05 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-14 02:37:33 -05:00
|
|
|
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() );
|
2010-08-18 15:27:18 -05:00
|
|
|
AllianceFramework::get()->saveCell ( cell, Catalog::State::Views );
|
2010-05-14 02:37:33 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-16 06:54:58 -06:00
|
|
|
string UnicornGui::_getString () const
|
|
|
|
{
|
|
|
|
ostringstream s;
|
|
|
|
s << "<UnicornGui ";
|
|
|
|
Cell* cell = getCell();
|
|
|
|
if (cell) s << getString(cell->getName());
|
|
|
|
else s << "No_Cell_Loaded";
|
|
|
|
s << ">";
|
|
|
|
return s.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-09 09:26:22 -06:00
|
|
|
} // End of Unicorn namespace.
|
2012-11-16 06:54:58 -06:00
|
|
|
|
|
|
|
|
|
|
|
//INSPECTOR_P_SUPPORT(Unicorn::UnicornGui)
|