Complete replacement of xtof viewer by jpc'one.
Still in early stage. Many features missings.
|
@ -2,13 +2,14 @@ include(${QT_USE_FILE})
|
||||||
|
|
||||||
include_directories(${HURRICANE_SOURCE_DIR}/src/hurricane)
|
include_directories(${HURRICANE_SOURCE_DIR}/src/hurricane)
|
||||||
|
|
||||||
set(includes CellWidget.h LayersWidget.h CellViewer.h)
|
set(includes ScreenUtilities.h DisplayStyle.h ScreenLayer.h LayersList.h CellWidget.h CellViewer.h)
|
||||||
set(exports CellViewer.h)
|
set(exports CellViewer.h)
|
||||||
set(cpps CellWidget.cpp LayersWidget.cpp CellViewer.cpp)
|
set(cpps ScreenUtilities.cpp DisplayStyle.cpp ScreenLayer.cpp LayersList.cpp CellWidget.cpp CellViewer.cpp)
|
||||||
|
|
||||||
QT4_WRAP_CPP(MOC_SRCS ${includes})
|
QT4_WRAP_CPP(MOC_SRCS ${includes})
|
||||||
|
QT4_ADD_RESOURCES(RCC_SRCS CellViewer.qrc)
|
||||||
|
|
||||||
add_library(hurricaneviewer SHARED ${cpps} ${MOC_SRCS})
|
add_library(hurricaneviewer SHARED ${cpps} ${MOC_SRCS} ${RCC_SRCS})
|
||||||
target_link_libraries(hurricaneviewer ${QT_LIBRARIES} hurricane)
|
target_link_libraries(hurricaneviewer ${QT_LIBRARIES} hurricane)
|
||||||
|
|
||||||
install(FILES ${exports} DESTINATION /include/hurricane)
|
install(FILES ${exports} DESTINATION /include/hurricane)
|
||||||
|
|
|
@ -1,860 +0,0 @@
|
||||||
// ****************************************************************************************************
|
|
||||||
// File: Cell.cpp
|
|
||||||
// Authors: R. Escassut
|
|
||||||
// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved
|
|
||||||
// ****************************************************************************************************
|
|
||||||
|
|
||||||
#include "Cell.h"
|
|
||||||
#include "DataBase.h"
|
|
||||||
#include "Library.h"
|
|
||||||
#include "Instance.h"
|
|
||||||
#include "Net.h"
|
|
||||||
#include "Pin.h"
|
|
||||||
#include "RoutingPad.h"
|
|
||||||
#include "Layer.h"
|
|
||||||
#include "Slice.h"
|
|
||||||
#include "Rubber.h"
|
|
||||||
#include "Marker.h"
|
|
||||||
#include "Symbol.h"
|
|
||||||
#include "Primitive.h"
|
|
||||||
#include "MapView.h"
|
|
||||||
#include "DisplaySlot.h"
|
|
||||||
#include "Component.h"
|
|
||||||
#include "UpdateSession.h"
|
|
||||||
#include "Error.h"
|
|
||||||
|
|
||||||
namespace Hurricane {
|
|
||||||
|
|
||||||
// ****************************************************************************************************
|
|
||||||
// Cell implementation
|
|
||||||
// ****************************************************************************************************
|
|
||||||
|
|
||||||
Cell::Cell(Library* library, const Name& name)
|
|
||||||
// *******************************************
|
|
||||||
: Inherit(),
|
|
||||||
_library(library),
|
|
||||||
_name(name),
|
|
||||||
_instanceMap(),
|
|
||||||
_quadTree(),
|
|
||||||
_slaveInstanceSet(),
|
|
||||||
_netMap(),
|
|
||||||
_sliceMap(),
|
|
||||||
_markerSet(),
|
|
||||||
_viewSet(),
|
|
||||||
_abutmentBox(),
|
|
||||||
_boundingBox(),
|
|
||||||
_isTerminal(true),
|
|
||||||
_isPad(false),
|
|
||||||
_symbol(NULL),
|
|
||||||
_nextOfLibraryCellMap(NULL),
|
|
||||||
_nextOfSymbolCellSet(NULL),
|
|
||||||
_slaveEntityMap()
|
|
||||||
{
|
|
||||||
if (!_library)
|
|
||||||
throw Error("Can't create " + _TName("Cell") + " : null library");
|
|
||||||
|
|
||||||
if (name.IsEmpty())
|
|
||||||
throw Error("Can't create " + _TName("Cell") + " : empty name");
|
|
||||||
|
|
||||||
if (_library->GetCell(_name))
|
|
||||||
throw Error("Can't create " + _TName("Cell") + " : already exists");
|
|
||||||
}
|
|
||||||
|
|
||||||
Cell* Cell::Create(Library* library, const Name& name)
|
|
||||||
// ***************************************************
|
|
||||||
{
|
|
||||||
Cell* cell = new Cell(library, name);
|
|
||||||
|
|
||||||
cell->_PostCreate();
|
|
||||||
|
|
||||||
return cell;
|
|
||||||
}
|
|
||||||
|
|
||||||
Box Cell::GetBoundingBox() const
|
|
||||||
// *****************************
|
|
||||||
{
|
|
||||||
if (_boundingBox.IsEmpty()) {
|
|
||||||
Box& boundingBox = (Box&)_boundingBox;
|
|
||||||
boundingBox = _abutmentBox;
|
|
||||||
boundingBox.Merge(_quadTree.GetBoundingBox());
|
|
||||||
for_each_slice(slice, GetSlices()) {
|
|
||||||
boundingBox.Merge(slice->GetBoundingBox());
|
|
||||||
end_for;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return _boundingBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Cell::IsLeaf() const
|
|
||||||
// **********************
|
|
||||||
{
|
|
||||||
return _instanceMap.IsEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Cell::IsCalledBy(Cell* cell) const
|
|
||||||
// ************************************
|
|
||||||
{
|
|
||||||
for_each_instance(instance, cell->GetInstances()) {
|
|
||||||
Cell* masterCell = instance->GetMasterCell();
|
|
||||||
if (masterCell == this) return true;
|
|
||||||
if (IsCalledBy(masterCell)) return true;
|
|
||||||
end_for;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::SetName(const Name& name)
|
|
||||||
// *********************************
|
|
||||||
{
|
|
||||||
if (name != _name) {
|
|
||||||
if (name.IsEmpty())
|
|
||||||
throw Error("Can't change " + _TName("Cell") + " name : empty name");
|
|
||||||
|
|
||||||
if (_library->GetCell(name))
|
|
||||||
throw Error("Can't change " + _TName("Cell") + " name : already exists");
|
|
||||||
|
|
||||||
_library->_GetCellMap()._Remove(this);
|
|
||||||
_name = name;
|
|
||||||
_library->_GetCellMap()._Insert(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::SetAbutmentBox(const Box& abutmentBox)
|
|
||||||
// **********************************************
|
|
||||||
{
|
|
||||||
if (abutmentBox != _abutmentBox) {
|
|
||||||
if (!_abutmentBox.IsEmpty() &&
|
|
||||||
(abutmentBox.IsEmpty() || !abutmentBox.Contains(_abutmentBox)))
|
|
||||||
_Unfit(_abutmentBox);
|
|
||||||
_abutmentBox = abutmentBox;
|
|
||||||
_Fit(_abutmentBox);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::SetSymbol(Symbol* symbol)
|
|
||||||
// *********************************
|
|
||||||
{
|
|
||||||
if (symbol != _symbol) {
|
|
||||||
OpenUpdateSession();
|
|
||||||
if (_symbol) {
|
|
||||||
_Unfit(_symbol->GetBoundingBox());
|
|
||||||
for_each_net(net, GetExternalNets()) {
|
|
||||||
net->SetPosition(Point(0, 0));
|
|
||||||
end_for;
|
|
||||||
}
|
|
||||||
_symbol->_GetCellSet()._Remove(this);
|
|
||||||
}
|
|
||||||
_symbol = symbol;
|
|
||||||
if (_symbol) {
|
|
||||||
_symbol->_GetCellSet()._Insert(this);
|
|
||||||
for_each_net(net, GetExternalNets()) {
|
|
||||||
Port* port = _symbol->GetPort(net->GetName());
|
|
||||||
if (port) net->SetPosition(port->GetPosition());
|
|
||||||
end_for;
|
|
||||||
}
|
|
||||||
_Fit(_symbol->GetBoundingBox());
|
|
||||||
}
|
|
||||||
CloseUpdateSession();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::FlattenNets(bool buildRings)
|
|
||||||
// ************************************
|
|
||||||
{
|
|
||||||
OpenUpdateSession ();
|
|
||||||
|
|
||||||
for_each_occurrence ( occurrence, GetHyperNetRootNetOccurrences() ) {
|
|
||||||
HyperNet hyperNet ( occurrence );
|
|
||||||
if ( !occurrence.GetPath().IsEmpty() ) {
|
|
||||||
DeepNet* deepNet = DeepNet::Create ( hyperNet );
|
|
||||||
if (deepNet) deepNet->_CreateRoutingPads ( buildRings );
|
|
||||||
} else {
|
|
||||||
RoutingPad* previousRP = NULL;
|
|
||||||
RoutingPad* currentRP = NULL;
|
|
||||||
Net* net = static_cast<Net*>(occurrence.GetEntity());
|
|
||||||
|
|
||||||
for_each_component ( component, net->GetComponents() ) {
|
|
||||||
Plug* primaryPlug = dynamic_cast<Plug*>( component );
|
|
||||||
if ( primaryPlug ) {
|
|
||||||
if ( !primaryPlug->GetBodyHook()->GetSlaveHooks().IsEmpty() ) {
|
|
||||||
cerr << "[ERROR] " << primaryPlug << "\n"
|
|
||||||
<< " has attached components, not managed yet." << endl;
|
|
||||||
} else {
|
|
||||||
primaryPlug->GetBodyHook()->Detach ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end_for
|
|
||||||
}
|
|
||||||
|
|
||||||
for_each_occurrence ( plugOccurrence, hyperNet.GetLeafPlugOccurrences() ) {
|
|
||||||
currentRP = CreateRoutingPad ( net, plugOccurrence );
|
|
||||||
currentRP->Materialize ();
|
|
||||||
if ( buildRings ) {
|
|
||||||
if ( previousRP ) {
|
|
||||||
currentRP->GetBodyHook()->Attach ( previousRP->GetBodyHook() );
|
|
||||||
}
|
|
||||||
Plug* plug = static_cast<Plug*>( plugOccurrence.GetEntity() );
|
|
||||||
if ( plugOccurrence.GetPath().IsEmpty() ) {
|
|
||||||
plug->GetBodyHook()->Attach ( currentRP->GetBodyHook() );
|
|
||||||
plug->GetBodyHook()->Detach ();
|
|
||||||
}
|
|
||||||
previousRP = currentRP;
|
|
||||||
}
|
|
||||||
|
|
||||||
end_for
|
|
||||||
}
|
|
||||||
|
|
||||||
for_each_component ( component, net->GetComponents() ) {
|
|
||||||
Pin* pin = dynamic_cast<Pin*>( component );
|
|
||||||
if ( pin ) {
|
|
||||||
currentRP = CreateRoutingPad ( pin );
|
|
||||||
if ( buildRings ) {
|
|
||||||
if ( previousRP ) {
|
|
||||||
currentRP->GetBodyHook()->Attach ( previousRP->GetBodyHook() );
|
|
||||||
}
|
|
||||||
pin->GetBodyHook()->Attach ( currentRP->GetBodyHook() );
|
|
||||||
pin->GetBodyHook()->Detach ();
|
|
||||||
}
|
|
||||||
previousRP = currentRP;
|
|
||||||
}
|
|
||||||
|
|
||||||
end_for
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end_for
|
|
||||||
}
|
|
||||||
|
|
||||||
CloseUpdateSession ();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::Materialize()
|
|
||||||
// *********************
|
|
||||||
{
|
|
||||||
for_each_instance(instance, GetInstances()) instance->Materialize(); end_for;
|
|
||||||
for_each_net(net, GetNets()) net->Materialize(); end_for;
|
|
||||||
for_each_marker(marker, GetMarkers()) marker->Materialize(); end_for;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::Unmaterialize()
|
|
||||||
// ***********************
|
|
||||||
{
|
|
||||||
for_each_instance(instance, GetInstances()) instance->Unmaterialize(); end_for;
|
|
||||||
for_each_net(net, GetNets()) net->Unmaterialize(); end_for;
|
|
||||||
for_each_marker(marker, GetMarkers()) marker->Unmaterialize(); end_for;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::_PostCreate()
|
|
||||||
// *********************
|
|
||||||
{
|
|
||||||
_library->_GetCellMap()._Insert(this);
|
|
||||||
|
|
||||||
Inherit::_PostCreate();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::_PreDelete()
|
|
||||||
// ********************
|
|
||||||
{
|
|
||||||
Inherit::_PreDelete();
|
|
||||||
|
|
||||||
while(_slaveEntityMap.size()) {
|
|
||||||
_slaveEntityMap.begin()->second->Delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_symbol) SetSymbol(NULL);
|
|
||||||
|
|
||||||
for_each_view(view, GetViews()) view->SetCell(NULL); end_for;
|
|
||||||
for_each_marker(marker, GetMarkers()) marker->Delete(); end_for;
|
|
||||||
for_each_instance(slaveInstance, GetSlaveInstances()) slaveInstance->Delete(); end_for;
|
|
||||||
for_each_instance(instance, GetInstances()) instance->Delete(); end_for;
|
|
||||||
for_each_net(net, GetNets()) net->Delete(); end_for;
|
|
||||||
for_each_slice(slice, GetSlices()) slice->_Delete(); end_for;
|
|
||||||
|
|
||||||
_library->_GetCellMap()._Remove(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
string Cell::_GetString() const
|
|
||||||
// ****************************
|
|
||||||
{
|
|
||||||
string s = Inherit::_GetString();
|
|
||||||
s.insert(s.length() - 1, " " + GetString(_name));
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
Record* Cell::_GetRecord() const
|
|
||||||
// ***********************
|
|
||||||
{
|
|
||||||
Record* record = Inherit::_GetRecord();
|
|
||||||
if (record) {
|
|
||||||
record->Add(GetSlot("Library", _library));
|
|
||||||
record->Add(GetSlot("Name", &_name));
|
|
||||||
record->Add(GetSlot("Instances", &_instanceMap));
|
|
||||||
record->Add(GetSlot("QuadTree", &_quadTree));
|
|
||||||
record->Add(GetSlot("SlaveInstances", &_slaveInstanceSet));
|
|
||||||
record->Add(GetSlot("Nets", &_netMap));
|
|
||||||
record->Add(GetSlot("Pins", &_pinMap));
|
|
||||||
record->Add(GetSlot("Slices", &_sliceMap));
|
|
||||||
record->Add(GetSlot("Markers", &_markerSet));
|
|
||||||
record->Add(GetSlot("Views", &_viewSet));
|
|
||||||
record->Add(GetSlot("AbutmentBox", &_abutmentBox));
|
|
||||||
record->Add(GetSlot("BoundingBox", &_boundingBox));
|
|
||||||
record->Add(GetSlot("IsTerminal", &_isTerminal));
|
|
||||||
record->Add(GetSlot("IsFlattenLeaf", &_isFlattenLeaf));
|
|
||||||
//record->Add(GetSlot("Symbol", _symbol));
|
|
||||||
}
|
|
||||||
return record;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::_Fit(const Box& box)
|
|
||||||
// ****************************
|
|
||||||
{
|
|
||||||
if (box.IsEmpty()) return;
|
|
||||||
if (_boundingBox.IsEmpty()) return;
|
|
||||||
if (_boundingBox.Contains(box)) return;
|
|
||||||
_boundingBox.Merge(box);
|
|
||||||
for_each_instance(instance, GetSlaveInstances()) {
|
|
||||||
instance->GetCell()->_Fit(instance->GetTransformation().GetBox(box));
|
|
||||||
end_for;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::_Unfit(const Box& box)
|
|
||||||
// ******************************
|
|
||||||
{
|
|
||||||
if (box.IsEmpty()) return;
|
|
||||||
if (_boundingBox.IsEmpty()) return;
|
|
||||||
if (!_boundingBox.IsConstrainedBy(box)) return;
|
|
||||||
_boundingBox.MakeEmpty();
|
|
||||||
for_each_instance(instance, GetSlaveInstances()) {
|
|
||||||
instance->GetCell()->_Unfit(instance->GetTransformation().GetBox(box));
|
|
||||||
end_for;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::_AddSlaveEntity(Entity* entity, Entity* slaveEntity)
|
|
||||||
// ************************************************************************
|
|
||||||
{
|
|
||||||
assert(entity->GetCell() == this);
|
|
||||||
|
|
||||||
_slaveEntityMap.insert(pair<Entity*,Entity*>(entity,slaveEntity));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::_RemoveSlaveEntity(Entity* entity, Entity* slaveEntity)
|
|
||||||
// ***************************************************************************
|
|
||||||
{
|
|
||||||
assert(entity->GetCell() == this);
|
|
||||||
|
|
||||||
pair<SlaveEntityMap::iterator,SlaveEntityMap::iterator>
|
|
||||||
bounds = _slaveEntityMap.equal_range(entity);
|
|
||||||
multimap<Entity*,Entity*>::iterator it = bounds.first;
|
|
||||||
for(; it != bounds.second ; it++ ) {
|
|
||||||
if (it->second == slaveEntity) {
|
|
||||||
_slaveEntityMap.erase(it);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::_GetSlaveEntities(SlaveEntityMap::iterator& begin, SlaveEntityMap::iterator& end)
|
|
||||||
// *********************************************************************************************************
|
|
||||||
{
|
|
||||||
begin = _slaveEntityMap.begin();
|
|
||||||
end = _slaveEntityMap.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::_GetSlaveEntities(Entity* entity, SlaveEntityMap::iterator& begin, SlaveEntityMap::iterator& end)
|
|
||||||
// *********************************************************************************************************
|
|
||||||
{
|
|
||||||
begin = _slaveEntityMap.lower_bound(entity);
|
|
||||||
end = _slaveEntityMap.upper_bound(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Cell::_IsDrawable(View* view) const
|
|
||||||
// *************************************
|
|
||||||
{
|
|
||||||
if (view->GetCell() == this) return true;
|
|
||||||
|
|
||||||
if (is_a<MapView*>(view)) return true;
|
|
||||||
|
|
||||||
return (1 < (double)view->GetScreenSize(_boundingBox.GetHeight()));
|
|
||||||
// return (100 < ((double)view->GetScreenSize(_boundingBox.GetWidth()) *
|
|
||||||
// (double)view->GetScreenSize(_boundingBox.GetHeight())));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Cell::_ContentIsDrawable(View* view) const
|
|
||||||
// ********************************************
|
|
||||||
{
|
|
||||||
if (IsTerminal()) return false;
|
|
||||||
|
|
||||||
if (view->GetCell() == this) return true;
|
|
||||||
|
|
||||||
if (is_a<MapView*>(view)) return false;
|
|
||||||
|
|
||||||
return (40 < (double)view->GetScreenSize(_boundingBox.GetHeight()));
|
|
||||||
// return (400 < ((double)view->GetScreenSize(_boundingBox.GetWidth()) *
|
|
||||||
// (double)view->GetScreenSize(_boundingBox.GetHeight())));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::_DrawPhantoms(View* view, const Box& updateArea, const Transformation& transformation)
|
|
||||||
// **********************************************************************************************
|
|
||||||
{
|
|
||||||
if (_IsDrawable(view)) { // To avoid irregular display of instances phantoms
|
|
||||||
if (!_ContentIsDrawable(view))
|
|
||||||
view->FillRectangle(transformation.GetBox(GetAbutmentBox()));
|
|
||||||
else {
|
|
||||||
for_each_instance(instance, GetInstancesUnder(updateArea)) {
|
|
||||||
instance->_DrawPhantoms(view, updateArea, transformation);
|
|
||||||
end_for;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::_DrawBoundaries(View* view, const Box& updateArea, const Transformation& transformation)
|
|
||||||
// ************************************************************************************************
|
|
||||||
{
|
|
||||||
if (_IsDrawable(view)) { // To avoid irregular display of instances phantoms
|
|
||||||
view->DrawRectangle(transformation.GetBox(GetAbutmentBox()));
|
|
||||||
if (_ContentIsDrawable(view)) {
|
|
||||||
for_each_instance(instance, GetInstancesUnder(updateArea)) {
|
|
||||||
instance->_DrawBoundaries(view, updateArea, transformation);
|
|
||||||
end_for;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::_DrawContent(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation)
|
|
||||||
// ****************************************************************************************************
|
|
||||||
{
|
|
||||||
if (_IsDrawable(view)) {
|
|
||||||
if (_ContentIsDrawable(view)) {
|
|
||||||
view->CheckForDisplayInterruption();
|
|
||||||
for_each_instance(instance, GetInstancesUnder(updateArea)) {
|
|
||||||
instance->_Draw(view, basicLayer, updateArea, transformation);
|
|
||||||
end_for;
|
|
||||||
}
|
|
||||||
for_each_slice(slice, GetSlices()) {
|
|
||||||
slice->_Draw(view, basicLayer, updateArea, transformation);
|
|
||||||
end_for;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::_DrawRubbers(View* view, const Box& updateArea, const Transformation& transformation)
|
|
||||||
// *********************************************************************************************
|
|
||||||
{
|
|
||||||
if (_IsDrawable(view)) {
|
|
||||||
if (_ContentIsDrawable(view)) {
|
|
||||||
for_each_instance(instance, GetInstancesUnder(updateArea)) {
|
|
||||||
instance->_DrawRubbers(view, updateArea, transformation);
|
|
||||||
end_for;
|
|
||||||
}
|
|
||||||
for_each_rubber(rubber, GetRubbersUnder(updateArea)) {
|
|
||||||
rubber->_Draw(view, NULL, updateArea, transformation);
|
|
||||||
end_for;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::_DrawMarkers(View* view, const Box& updateArea, const Transformation& transformation)
|
|
||||||
// *********************************************************************************************
|
|
||||||
{
|
|
||||||
if (_IsDrawable(view)) {
|
|
||||||
if (_ContentIsDrawable(view)) {
|
|
||||||
for_each_instance(instance, GetInstancesUnder(updateArea)) {
|
|
||||||
instance->_DrawMarkers(view, updateArea, transformation);
|
|
||||||
end_for;
|
|
||||||
}
|
|
||||||
for_each_marker(marker, GetMarkersUnder(updateArea)) {
|
|
||||||
marker->_Draw(view, NULL, updateArea, transformation);
|
|
||||||
end_for;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::_DrawDisplaySlots(View* view, const Box& area, const Box& updateArea, const Transformation& transformation)
|
|
||||||
// ********************************************************************************************************************
|
|
||||||
{
|
|
||||||
if (_IsDrawable(view)) {
|
|
||||||
if (_ContentIsDrawable(view)) {
|
|
||||||
for_each_instance(instance, GetInstancesUnder(updateArea)) {
|
|
||||||
instance->_DrawDisplaySlots(view, area, updateArea, transformation);
|
|
||||||
end_for;
|
|
||||||
}
|
|
||||||
for_each_display_slot(displaySlot, GetDisplaySlots(this)) {
|
|
||||||
view->_DrawDisplaySlot(displaySlot, area, updateArea, transformation);
|
|
||||||
end_for;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::_SaveHeaderTo(OutputFile& outputFile)
|
|
||||||
// *********************************************
|
|
||||||
{
|
|
||||||
outputFile.Register(this);
|
|
||||||
|
|
||||||
Inherit::_SaveHeaderTo(outputFile);
|
|
||||||
|
|
||||||
outputFile << " " << outputFile.GetId(GetLibrary());
|
|
||||||
outputFile << " " << GetName();
|
|
||||||
outputFile << " " << GetValueString(GetAbutmentBox().GetXMin());
|
|
||||||
outputFile << " " << GetValueString(GetAbutmentBox().GetYMin());
|
|
||||||
outputFile << " " << GetValueString(GetAbutmentBox().GetXMax());
|
|
||||||
outputFile << " " << GetValueString(GetAbutmentBox().GetYMax());
|
|
||||||
outputFile << " " << ((IsTerminal()) ? '1' : '0');
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::_SaveContentTo(OutputFile& outputFile)
|
|
||||||
// **********************************************
|
|
||||||
{
|
|
||||||
Inherit::_SaveContentTo(outputFile);
|
|
||||||
|
|
||||||
for_each_instance(instance, GetInstances()) {
|
|
||||||
instance->_SaveTo(outputFile);
|
|
||||||
end_for;
|
|
||||||
}
|
|
||||||
|
|
||||||
for_each_net(net, GetNets()) {
|
|
||||||
net->_SaveTo(outputFile);
|
|
||||||
end_for;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::_Realize(Hurricane::Builder* builder, InputFile& inputFile)
|
|
||||||
// *******************************************************************
|
|
||||||
{
|
|
||||||
assert(is_a<Cell::Builder*>(builder));
|
|
||||||
|
|
||||||
Cell::Builder* cellBuilder = (Cell::Builder*)builder;
|
|
||||||
|
|
||||||
SetAbutmentBox(cellBuilder->GetAbutmentBox());
|
|
||||||
SetTerminal(cellBuilder->IsTerminal());
|
|
||||||
|
|
||||||
// PROVISOIREMENT
|
|
||||||
string s = GetString(GetName());
|
|
||||||
Library* library = GetLibrary();
|
|
||||||
while (library) {
|
|
||||||
s = GetString(library->GetName()) + "/" + s;
|
|
||||||
library = library->GetLibrary();
|
|
||||||
}
|
|
||||||
cout << " Loading cell " << s << endl;
|
|
||||||
// PROVISOIREMENT
|
|
||||||
|
|
||||||
inputFile.Register(this);
|
|
||||||
|
|
||||||
Go::DisableAutoMaterialization();
|
|
||||||
|
|
||||||
OpenUpdateSession();
|
|
||||||
|
|
||||||
Inherit::_Realize(builder, inputFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::_Finalize(InputFile& inputFile)
|
|
||||||
// ***************************************
|
|
||||||
{
|
|
||||||
CloseUpdateSession();
|
|
||||||
|
|
||||||
Go::EnableAutoMaterialization();
|
|
||||||
|
|
||||||
Materialize();
|
|
||||||
|
|
||||||
Inherit::_Finalize(inputFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ****************************************************************************************************
|
|
||||||
// Cell::InstanceMap implementation
|
|
||||||
// ****************************************************************************************************
|
|
||||||
|
|
||||||
Cell::InstanceMap::InstanceMap()
|
|
||||||
// *****************************
|
|
||||||
: Inherit()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Name Cell::InstanceMap::_GetKey(Instance* instance) const
|
|
||||||
// ******************************************************
|
|
||||||
{
|
|
||||||
return instance->GetName();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned Cell::InstanceMap::_GetHashValue(Name name) const
|
|
||||||
// *******************************************************
|
|
||||||
{
|
|
||||||
return ( (unsigned int)( (unsigned long)name._GetSharedName() ) ) / 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
Instance* Cell::InstanceMap::_GetNextElement(Instance* instance) const
|
|
||||||
// *******************************************************************
|
|
||||||
{
|
|
||||||
return instance->_GetNextOfCellInstanceMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::InstanceMap::_SetNextElement(Instance* instance, Instance* nextInstance) const
|
|
||||||
// **************************************************************************************
|
|
||||||
{
|
|
||||||
instance->_SetNextOfCellInstanceMap(nextInstance);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ****************************************************************************************************
|
|
||||||
// Cell::SlaveInstanceSet implementation
|
|
||||||
// ****************************************************************************************************
|
|
||||||
|
|
||||||
Cell::SlaveInstanceSet::SlaveInstanceSet()
|
|
||||||
// ***************************************
|
|
||||||
: Inherit()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned Cell::SlaveInstanceSet::_GetHashValue(Instance* slaveInstance) const
|
|
||||||
// **************************************************************************
|
|
||||||
{
|
|
||||||
return ( (unsigned int)( (unsigned long)slaveInstance ) ) / 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
Instance* Cell::SlaveInstanceSet::_GetNextElement(Instance* slaveInstance) const
|
|
||||||
// *****************************************************************************
|
|
||||||
{
|
|
||||||
return slaveInstance->_GetNextOfCellSlaveInstanceSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::SlaveInstanceSet::_SetNextElement(Instance* slaveInstance, Instance* nextSlaveInstance) const
|
|
||||||
// ****************************************************************************************************
|
|
||||||
{
|
|
||||||
slaveInstance->_SetNextOfCellSlaveInstanceSet(nextSlaveInstance);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ****************************************************************************************************
|
|
||||||
// Cell::NetMap implementation
|
|
||||||
// ****************************************************************************************************
|
|
||||||
|
|
||||||
Cell::NetMap::NetMap()
|
|
||||||
// *******************
|
|
||||||
: Inherit()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Name Cell::NetMap::_GetKey(Net* net) const
|
|
||||||
// ***************************************
|
|
||||||
{
|
|
||||||
return net->GetName();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned Cell::NetMap::_GetHashValue(Name name) const
|
|
||||||
// **************************************************
|
|
||||||
{
|
|
||||||
return ( (unsigned int)( (unsigned long)name._GetSharedName() ) ) / 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
Net* Cell::NetMap::_GetNextElement(Net* net) const
|
|
||||||
// ***********************************************
|
|
||||||
{
|
|
||||||
return net->_GetNextOfCellNetMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::NetMap::_SetNextElement(Net* net, Net* nextNet) const
|
|
||||||
// *************************************************************
|
|
||||||
{
|
|
||||||
net->_SetNextOfCellNetMap(nextNet);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ****************************************************************************************************
|
|
||||||
// Cell::PinMap implementation
|
|
||||||
// ****************************************************************************************************
|
|
||||||
|
|
||||||
Cell::PinMap::PinMap()
|
|
||||||
// *******************
|
|
||||||
: Inherit()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Name Cell::PinMap::_GetKey(Pin* pin) const
|
|
||||||
// ***************************************
|
|
||||||
{
|
|
||||||
return pin->GetName();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned Cell::PinMap::_GetHashValue(Name name) const
|
|
||||||
// **************************************************
|
|
||||||
{
|
|
||||||
return ( (unsigned int)( (unsigned long)name._GetSharedName() ) ) / 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
Pin* Cell::PinMap::_GetNextElement(Pin* pin) const
|
|
||||||
// ***********************************************
|
|
||||||
{
|
|
||||||
return pin->_GetNextOfCellPinMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::PinMap::_SetNextElement(Pin* pin, Pin* nextPin) const
|
|
||||||
// *************************************************************
|
|
||||||
{
|
|
||||||
pin->_SetNextOfCellPinMap(nextPin);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ****************************************************************************************************
|
|
||||||
// Cell::SliceMap implementation
|
|
||||||
// ****************************************************************************************************
|
|
||||||
|
|
||||||
Cell::SliceMap::SliceMap()
|
|
||||||
// ***********************
|
|
||||||
: Inherit()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
const Layer* Cell::SliceMap::_GetKey(Slice* slice) const
|
|
||||||
// *****************************************************
|
|
||||||
{
|
|
||||||
return slice->GetLayer();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned Cell::SliceMap::_GetHashValue(const Layer* layer) const
|
|
||||||
// *************************************************************
|
|
||||||
{
|
|
||||||
return ( (unsigned int)( (unsigned long)layer ) ) / 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
Slice* Cell::SliceMap::_GetNextElement(Slice* slice) const
|
|
||||||
// *******************************************************
|
|
||||||
{
|
|
||||||
return slice->_GetNextOfCellSliceMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::SliceMap::_SetNextElement(Slice* slice, Slice* nextSlice) const
|
|
||||||
// ***********************************************************************
|
|
||||||
{
|
|
||||||
slice->_SetNextOfCellSliceMap(nextSlice);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ****************************************************************************************************
|
|
||||||
// Cell::MarkerSet implementation
|
|
||||||
// ****************************************************************************************************
|
|
||||||
|
|
||||||
Cell::MarkerSet::MarkerSet()
|
|
||||||
// *************************
|
|
||||||
: Inherit()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned Cell::MarkerSet::_GetHashValue(Marker* marker) const
|
|
||||||
// **********************************************************
|
|
||||||
{
|
|
||||||
return ( (unsigned int)( (unsigned long)marker ) ) / 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
Marker* Cell::MarkerSet::_GetNextElement(Marker* marker) const
|
|
||||||
// ***********************************************************
|
|
||||||
{
|
|
||||||
return marker->_GetNextOfCellMarkerSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::MarkerSet::_SetNextElement(Marker* marker, Marker* nextMarker) const
|
|
||||||
// ****************************************************************************
|
|
||||||
{
|
|
||||||
marker->_SetNextOfCellMarkerSet(nextMarker);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ****************************************************************************************************
|
|
||||||
// Cell::ViewSet implementation
|
|
||||||
// ****************************************************************************************************
|
|
||||||
|
|
||||||
Cell::ViewSet::ViewSet()
|
|
||||||
// *********************
|
|
||||||
: Inherit()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned Cell::ViewSet::_GetHashValue(View* view) const
|
|
||||||
// ****************************************************
|
|
||||||
{
|
|
||||||
return ( (unsigned int)( (unsigned long)view ) ) / 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
View* Cell::ViewSet::_GetNextElement(View* view) const
|
|
||||||
// ***************************************************
|
|
||||||
{
|
|
||||||
return view->_GetNextOfCellViewSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::ViewSet::_SetNextElement(View* view, View* nextView) const
|
|
||||||
// ******************************************************************
|
|
||||||
{
|
|
||||||
view->_SetNextOfCellViewSet(nextView);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ****************************************************************************************************
|
|
||||||
// Cell::Builder declaration
|
|
||||||
// ****************************************************************************************************
|
|
||||||
|
|
||||||
Cell::Builder::Builder(const string& token)
|
|
||||||
// ****************************************
|
|
||||||
: Inherit(token),
|
|
||||||
_library(NULL),
|
|
||||||
_name(),
|
|
||||||
_xMin(0),
|
|
||||||
_yMin(0),
|
|
||||||
_xMax(0),
|
|
||||||
_yMax(0),
|
|
||||||
_isTerminal(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::Builder::Scan(InputFile& inputFile, char*& arguments)
|
|
||||||
// *************************************************************
|
|
||||||
{
|
|
||||||
DBo* owner = inputFile.GetOwner();
|
|
||||||
|
|
||||||
if (!is_a<DataBase*>(owner))
|
|
||||||
throw Error("Can't create Cell : bad owner");
|
|
||||||
|
|
||||||
Inherit::Scan(inputFile, arguments);
|
|
||||||
|
|
||||||
unsigned libraryId;
|
|
||||||
unsigned n;
|
|
||||||
|
|
||||||
int r = sscanf(arguments, "%u%s%lf%lf%lf%lf%u%n", &libraryId, _name,
|
|
||||||
&_xMin, &_yMin, &_xMax, &_yMax, &_isTerminal, &n);
|
|
||||||
|
|
||||||
if (r != 7)
|
|
||||||
throw Error("Can't create Cell : syntax error");
|
|
||||||
|
|
||||||
arguments = &arguments[n];
|
|
||||||
|
|
||||||
DBo* dbo = inputFile.GetDBo(libraryId);
|
|
||||||
if (!dbo || !is_a<Library*>(dbo))
|
|
||||||
throw Error("Can't create Cell : bad library");
|
|
||||||
|
|
||||||
_library = (Library*)dbo;
|
|
||||||
}
|
|
||||||
|
|
||||||
DBo* Cell::Builder::CreateDBo()
|
|
||||||
// ****************************
|
|
||||||
{
|
|
||||||
return Cell::Create(GetLibrary(), GetName());
|
|
||||||
}
|
|
||||||
|
|
||||||
Cell::Builder CELL_BUILDER("C");
|
|
||||||
|
|
||||||
} // End of Hurricane namespace.
|
|
||||||
|
|
||||||
// ****************************************************************************************************
|
|
||||||
// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved
|
|
||||||
// ****************************************************************************************************
|
|
|
@ -1,93 +1,143 @@
|
||||||
#include <QtGui>
|
|
||||||
|
|
||||||
#include "CellWidget.h"
|
|
||||||
#include "LayersWidget.h"
|
|
||||||
|
|
||||||
#include "CellViewer.h"
|
// -*- C++ -*-
|
||||||
|
|
||||||
CellViewer::CellViewer(Cell* cell)
|
|
||||||
: QMainWindow()
|
# include <QAction>
|
||||||
|
# include <QMenu>
|
||||||
|
# include <QMenuBar>
|
||||||
|
# include <QDockWidget>
|
||||||
|
|
||||||
|
# include "Cell.h"
|
||||||
|
|
||||||
|
# include "CellWidget.h"
|
||||||
|
//# include "MapView.h"
|
||||||
|
# include "LayersList.h"
|
||||||
|
# include "CellViewer.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace H {
|
||||||
|
|
||||||
|
|
||||||
|
CellViewer::CellViewer ( Cell* cell ) : QMainWindow()
|
||||||
|
, _openAction(NULL)
|
||||||
|
, _nextCellAction(NULL)
|
||||||
|
, _previousCellAction(NULL)
|
||||||
|
, _nextAction(NULL)
|
||||||
|
, _saveAction(NULL)
|
||||||
|
, _exitAction(NULL)
|
||||||
|
, _refreshAction(NULL)
|
||||||
|
, _fitToContentsAction(NULL)
|
||||||
|
, _showBoundariesAction(NULL)
|
||||||
|
, _fileMenu(NULL)
|
||||||
|
, _viewMenu(NULL)
|
||||||
|
//, _mapView(NULL)
|
||||||
|
, _layersList(NULL)
|
||||||
|
, _cellWidget(NULL)
|
||||||
{
|
{
|
||||||
cellWidget = new CellWidget(cell);
|
createMenus ();
|
||||||
setCentralWidget(cellWidget);
|
createLayout ( cell );
|
||||||
|
|
||||||
createActions();
|
|
||||||
createMenus();
|
|
||||||
|
|
||||||
setWindowTitle(tr("Cell Viewer"));
|
|
||||||
resize(1000, 500);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CellViewer::~CellViewer() {
|
|
||||||
delete cellWidget;
|
|
||||||
delete layersWidget;
|
void CellViewer::createActions ()
|
||||||
|
{
|
||||||
|
if ( _openAction ) return;
|
||||||
|
|
||||||
|
_openAction = new QAction ( tr("&Open Cell"), this );
|
||||||
|
_openAction->setIcon ( QIcon(":/images/stock_open.png") );
|
||||||
|
_openAction->setStatusTip ( tr("Open (load) a new Cell") );
|
||||||
|
|
||||||
|
_nextCellAction = new QAction ( tr("Next Cell"), this );
|
||||||
|
_nextCellAction->setStatusTip ( tr("Go to the next Cell in history") );
|
||||||
|
|
||||||
|
_previousCellAction = new QAction ( tr("Previous Cell"), this );
|
||||||
|
_previousCellAction->setStatusTip ( tr("Go to the previous Cell in history") );
|
||||||
|
|
||||||
|
_nextAction = new QAction ( tr("&Next Breakpoint"), this );
|
||||||
|
_nextAction->setStatusTip ( tr("Proceed to the next breakpoint") );
|
||||||
|
|
||||||
|
_saveAction = new QAction ( tr("&Save Cell"), this );
|
||||||
|
_saveAction->setIcon ( QIcon(":/images/stock_save.png") );
|
||||||
|
_saveAction->setStatusTip ( tr("Save the current Cell") );
|
||||||
|
|
||||||
|
_exitAction = new QAction ( tr("&Exit"), this );
|
||||||
|
_exitAction->setStatusTip ( tr("Close Coriolis CellViewer") );
|
||||||
|
_exitAction->setShortcut ( QKeySequence(tr("CTRL+Q")) );
|
||||||
|
connect ( _exitAction, SIGNAL(triggered()), this, SLOT(close()) );
|
||||||
|
|
||||||
|
_refreshAction = new QAction ( tr("&Refresh"), this );
|
||||||
|
_refreshAction->setStatusTip ( tr("Force full redrawing of the display") );
|
||||||
|
_refreshAction->setShortcut ( QKeySequence(tr("CTRL+L")) );
|
||||||
|
|
||||||
|
_fitToContentsAction = new QAction ( tr("&Fit to Contents"), this );
|
||||||
|
_fitToContentsAction->setStatusTip ( tr("Adjust zoom to fit the whole cell's contents") );
|
||||||
|
_fitToContentsAction->setShortcut ( Qt::Key_F );
|
||||||
|
|
||||||
|
_showBoundariesAction = new QAction ( tr("&Boundaries"), this );
|
||||||
|
_showBoundariesAction->setCheckable ( true );
|
||||||
|
_showBoundariesAction->setStatusTip ( tr("Show/hide cell & instances abutment boxes") );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int scrollStep = getUnit(200);
|
|
||||||
|
|
||||||
void CellViewer::keyPressEvent(QKeyEvent *event) {
|
|
||||||
switch (event->key()) {
|
void CellViewer::createMenus ()
|
||||||
case Qt::Key_Left:
|
{
|
||||||
cellWidget->scroll(-scrollStep, 0);
|
if ( _fileMenu ) return;
|
||||||
break;
|
if ( !_openAction ) createActions ();
|
||||||
case Qt::Key_Right:
|
|
||||||
cellWidget->scroll(+scrollStep, 0);
|
_fileMenu = menuBar()->addMenu ( tr("File") );
|
||||||
break;
|
_fileMenu->addAction ( _openAction );
|
||||||
case Qt::Key_Down:
|
_fileMenu->addAction ( _nextCellAction );
|
||||||
cellWidget->scroll(0, -scrollStep);
|
_fileMenu->addAction ( _previousCellAction );
|
||||||
break;
|
_fileMenu->addAction ( _nextAction );
|
||||||
case Qt::Key_Up:
|
_fileMenu->addAction ( _saveAction );
|
||||||
cellWidget->scroll(0, +scrollStep);
|
_fileMenu->addAction ( _exitAction );
|
||||||
break;
|
|
||||||
default:
|
_viewMenu = menuBar()->addMenu ( tr("View") );
|
||||||
QWidget::keyPressEvent(event);
|
_viewMenu->addAction ( _refreshAction );
|
||||||
}
|
_viewMenu->addAction ( _fitToContentsAction );
|
||||||
|
_viewMenu->addAction ( _showBoundariesAction );
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
//void CellViewer::wheelEvent(QWheelEvent *event) {
|
|
||||||
// int numDegrees = event->delta() / 8;
|
|
||||||
// double numSteps = numDegrees / 15.0f;
|
|
||||||
// zoom(pow(ZoomInFactor, numSteps));
|
|
||||||
//}
|
|
||||||
|
|
||||||
void CellViewer::zoomIn() {
|
|
||||||
cellWidget->reframe(cellWidget->getScale() * 1.2);
|
void CellViewer::createLayout ( Cell* cell )
|
||||||
cellWidget->update();
|
{
|
||||||
|
if ( _cellWidget ) return;
|
||||||
|
|
||||||
|
_cellWidget = new CellWidget ( cell );
|
||||||
|
_layersList = _cellWidget->getLayersList ();
|
||||||
|
//_mapView = _cellWidget->getMapView ();
|
||||||
|
|
||||||
|
setCorner ( Qt::TopLeftCorner , Qt::LeftDockWidgetArea );
|
||||||
|
setCorner ( Qt::BottomLeftCorner , Qt::LeftDockWidgetArea );
|
||||||
|
setCorner ( Qt::TopRightCorner , Qt::RightDockWidgetArea );
|
||||||
|
setCorner ( Qt::BottomRightCorner, Qt::RightDockWidgetArea );
|
||||||
|
|
||||||
|
// QDockWidget* mapViewDock = new QDockWidget ( tr("Map") );
|
||||||
|
// mapViewDock->setObjectName ( "MapView" );
|
||||||
|
// mapViewDock->setWidget ( _mapView );
|
||||||
|
// mapViewDock->setAllowedAreas ( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
|
||||||
|
// addDockWidget ( Qt::RightDockWidgetArea, mapViewDock );
|
||||||
|
|
||||||
|
QDockWidget* layerMapDock = new QDockWidget ( tr("Layers") );
|
||||||
|
layerMapDock->setObjectName ( "LayersList" );
|
||||||
|
layerMapDock->setWidget ( _layersList );
|
||||||
|
layerMapDock->setAllowedAreas ( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
|
||||||
|
addDockWidget ( Qt::RightDockWidgetArea, layerMapDock );
|
||||||
|
|
||||||
|
setCentralWidget ( _cellWidget );
|
||||||
|
|
||||||
|
connect ( _refreshAction , SIGNAL(triggered()) , _cellWidget, SLOT(redraw ()) );
|
||||||
|
connect ( _fitToContentsAction , SIGNAL(triggered()) , _cellWidget, SLOT(fitToContents()) );
|
||||||
|
|
||||||
|
_showBoundariesAction->setChecked ( _cellWidget->showBoundaries() );
|
||||||
|
connect ( _showBoundariesAction, SIGNAL(toggled(bool)), _cellWidget, SLOT(setShowBoundaries(bool)) );
|
||||||
|
|
||||||
|
_cellWidget->redraw ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellViewer::zoomOut() {
|
|
||||||
cellWidget->reframe(cellWidget->getScale() / 1.2);
|
|
||||||
cellWidget->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CellViewer::fitToWindow() {
|
} // End of Hurricane namespace.
|
||||||
cellWidget->fitToContent();
|
|
||||||
cellWidget->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CellViewer::createActions() {
|
|
||||||
zoomInAct = new QAction(tr("Zoom &In (25%)"), this);
|
|
||||||
zoomInAct->setShortcut(tr("Ctrl++"));
|
|
||||||
zoomInAct->setEnabled(true);
|
|
||||||
connect(zoomInAct, SIGNAL(triggered()), this, SLOT(zoomIn()));
|
|
||||||
|
|
||||||
zoomOutAct = new QAction(tr("Zoom &Out (25%)"), this);
|
|
||||||
zoomOutAct->setShortcut(tr("Ctrl+-"));
|
|
||||||
zoomOutAct->setEnabled(true);
|
|
||||||
connect(zoomOutAct, SIGNAL(triggered()), this, SLOT(zoomOut()));
|
|
||||||
|
|
||||||
fitToWindowAct = new QAction(tr("Fit &To &Window"), this);
|
|
||||||
fitToWindowAct->setShortcut(tr("f"));
|
|
||||||
fitToWindowAct->setEnabled(true);
|
|
||||||
connect(fitToWindowAct, SIGNAL(triggered()), this, SLOT(fitToWindow()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void CellViewer::createMenus() {
|
|
||||||
viewMenu = new QMenu(tr("&View"), this);
|
|
||||||
viewMenu->addAction(zoomInAct);
|
|
||||||
viewMenu->addAction(zoomOutAct);
|
|
||||||
viewMenu->addAction(fitToWindowAct);
|
|
||||||
|
|
||||||
menuBar()->addMenu(viewMenu);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,39 +1,64 @@
|
||||||
#ifndef __CELL_VIEWER_H
|
|
||||||
#define __CELL_VIEWER_H
|
|
||||||
|
|
||||||
#include "Cell.h"
|
// -*- C++ -*-
|
||||||
using namespace Hurricane;
|
|
||||||
|
|
||||||
#include <QMainWindow>
|
|
||||||
|
|
||||||
class CellWidget;
|
# ifndef __CELLVIEWER_H__
|
||||||
class LayersWidget;
|
# define __CELLVIEWER_H__
|
||||||
|
|
||||||
class CellViewer : public QMainWindow {
|
|
||||||
Q_OBJECT
|
using namespace std;
|
||||||
|
|
||||||
|
# include <QMainWindow>
|
||||||
|
|
||||||
|
class QKeyEvent;
|
||||||
|
class QAction;
|
||||||
|
class QMenu;
|
||||||
|
|
||||||
|
# include "Commons.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace Hurricane {
|
||||||
|
|
||||||
|
|
||||||
|
class Cell;
|
||||||
|
class LayersList;
|
||||||
|
//class MapView;
|
||||||
|
class CellWidget;
|
||||||
|
|
||||||
|
|
||||||
|
class CellViewer : public QMainWindow {
|
||||||
|
Q_OBJECT;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QAction* _openAction;
|
||||||
|
QAction* _nextCellAction;
|
||||||
|
QAction* _previousCellAction;
|
||||||
|
QAction* _nextAction;
|
||||||
|
QAction* _saveAction;
|
||||||
|
QAction* _exitAction;
|
||||||
|
QAction* _refreshAction;
|
||||||
|
QAction* _fitToContentsAction;
|
||||||
|
QAction* _showBoundariesAction;
|
||||||
|
QMenu* _fileMenu;
|
||||||
|
QMenu* _viewMenu;
|
||||||
|
//MapView* _mapView;
|
||||||
|
LayersList* _layersList;
|
||||||
|
CellWidget* _cellWidget;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CellViewer(Cell* cell);
|
CellViewer ( Cell* cell );
|
||||||
~CellViewer();
|
|
||||||
private:
|
|
||||||
CellWidget* cellWidget;
|
|
||||||
LayersWidget* layersWidget;
|
|
||||||
|
|
||||||
QAction *zoomInAct;
|
|
||||||
QAction *zoomOutAct;
|
|
||||||
QAction *fitToWindowAct;
|
|
||||||
QMenu *viewMenu;
|
|
||||||
|
|
||||||
void createActions();
|
|
||||||
void createMenus();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void zoomIn();
|
|
||||||
void zoomOut();
|
|
||||||
void fitToWindow();
|
|
||||||
protected:
|
protected:
|
||||||
void keyPressEvent(QKeyEvent *event);
|
void createActions ();
|
||||||
|
void createMenus ();
|
||||||
|
void createLayout ( Cell* cell );
|
||||||
|
};
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
} // End of Hurricane namespace.
|
||||||
|
|
||||||
|
|
||||||
|
# endif
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
<RCC>
|
||||||
|
<qresource>
|
||||||
|
<file>images/stock_open.png</file>
|
||||||
|
<file>images/stock_save.png</file>
|
||||||
|
<file>images/palette_show_all.png</file>
|
||||||
|
<file>images/palette_hide_all.png</file>
|
||||||
|
<file>images/gtk-go-up.png</file>
|
||||||
|
<file>images/gtk-go-down.png</file>
|
||||||
|
<file>images/gtk-go-forward-rtl.png</file>
|
||||||
|
<file>images/gtk-go-forward-ltr.png</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
|
@ -0,0 +1,94 @@
|
||||||
|
|
||||||
|
// -*- C++ -*-
|
||||||
|
|
||||||
|
|
||||||
|
# include "DisplayStyle.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace Hurricane {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DisplayStyle::DrawingStyle::DrawingStyle ( const string& pattern
|
||||||
|
, int red
|
||||||
|
, int green
|
||||||
|
, int blue
|
||||||
|
, int borderWidth
|
||||||
|
) : _pattern(pattern)
|
||||||
|
, _color(QColor(red,green,blue))
|
||||||
|
, _pen(_color)
|
||||||
|
, _brush(Hurricane::getBrush(_pattern,red,green,blue))
|
||||||
|
{
|
||||||
|
if ( borderWidth ) {
|
||||||
|
_pen.setWidth ( borderWidth );
|
||||||
|
} else {
|
||||||
|
_pen.setStyle ( Qt::NoPen );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DisplayStyle::DisplayStyle () : _drawingStyles()
|
||||||
|
{
|
||||||
|
addDrawingStyle ( "fallback" , "FFFFFFFFFFFFFFFF", 0, 0, 0, 1 );
|
||||||
|
addDrawingStyle ( "background" , "FFFFFFFFFFFFFFFF", 50, 50, 50, 1 );
|
||||||
|
addDrawingStyle ( "foreground" , "FFFFFFFFFFFFFFFF", 255, 255, 255, 1 );
|
||||||
|
addDrawingStyle ( "rubber" , "FFFFFFFFFFFFFFFF", 192, 0, 192, 1 );
|
||||||
|
addDrawingStyle ( "phantom" , "FFFFFFFFFFFFFFFF", 139, 134, 130, 1 );
|
||||||
|
addDrawingStyle ( "boundaries" , "0000000000000000", 208, 199, 192, 1 );
|
||||||
|
addDrawingStyle ( "marker" , "FFFFFFFFFFFFFFFF", 80, 250, 80, 1 );
|
||||||
|
addDrawingStyle ( "selectionDraw", "FFFFFFFFFFFFFFFF", 255, 255, 255, 1 );
|
||||||
|
addDrawingStyle ( "selectionFill", "FFFFFFFFFFFFFFFF", 255, 255, 255, 1 );
|
||||||
|
addDrawingStyle ( "grid" , "FFFFFFFFFFFFFFFF", 255, 255, 255, 1 );
|
||||||
|
addDrawingStyle ( "spot" , "FFFFFFFFFFFFFFFF", 255, 255, 255, 1 );
|
||||||
|
addDrawingStyle ( "ghost" , "FFFFFFFFFFFFFFFF", 255, 255, 255, 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const string& DisplayStyle::getPattern ( const string& key ) const
|
||||||
|
{
|
||||||
|
return findDrawingStyle(key).getPattern();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const QColor& DisplayStyle::getColor ( const string& key ) const
|
||||||
|
{
|
||||||
|
return findDrawingStyle(key).getColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const QPen& DisplayStyle::getPen ( const string& key ) const
|
||||||
|
{
|
||||||
|
return findDrawingStyle(key).getPen();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const QBrush& DisplayStyle::getBrush ( const string& key ) const
|
||||||
|
{
|
||||||
|
return findDrawingStyle(key).getBrush();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const DisplayStyle::DrawingStyle& DisplayStyle::findDrawingStyle ( const string& key ) const
|
||||||
|
{
|
||||||
|
StyleIterator it = _drawingStyles.find ( key );
|
||||||
|
if ( it != _drawingStyles.end() ) return it->second;
|
||||||
|
|
||||||
|
return _drawingStyles.find("fallback")->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DisplayStyle::addDrawingStyle ( const string& key
|
||||||
|
, const string& pattern
|
||||||
|
, int red
|
||||||
|
, int green
|
||||||
|
, int blue
|
||||||
|
, int borderWidth
|
||||||
|
)
|
||||||
|
{
|
||||||
|
_drawingStyles [ key ] = DrawingStyle ( pattern, red, green, blue, borderWidth );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,101 @@
|
||||||
|
|
||||||
|
// -*- C++ -*-
|
||||||
|
|
||||||
|
|
||||||
|
# ifndef __DISPLAYSTYLE_H__
|
||||||
|
# define __DISPLAYSTYLE_H__
|
||||||
|
|
||||||
|
|
||||||
|
# include <string>
|
||||||
|
# include <map>
|
||||||
|
|
||||||
|
# include <QColor>
|
||||||
|
# include <QPen>
|
||||||
|
# include <QBrush>
|
||||||
|
|
||||||
|
# include "Commons.h"
|
||||||
|
|
||||||
|
# include "ScreenUtilities.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace Hurricane {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class DisplayStyle {
|
||||||
|
|
||||||
|
// Sub-Class.
|
||||||
|
protected:
|
||||||
|
class DrawingStyle {
|
||||||
|
// Attributes.
|
||||||
|
protected:
|
||||||
|
string _pattern;
|
||||||
|
QColor _color;
|
||||||
|
QPen _pen;
|
||||||
|
QBrush _brush;
|
||||||
|
// Constructor.
|
||||||
|
public:
|
||||||
|
DrawingStyle ( const string& pattern ="FFFFFFFFFFFFFFFF"
|
||||||
|
, int red =0
|
||||||
|
, int green =0
|
||||||
|
, int blue =0
|
||||||
|
, int borderWidth=0
|
||||||
|
);
|
||||||
|
// Accessors.
|
||||||
|
public:
|
||||||
|
inline const string& getPattern () const;
|
||||||
|
inline const QColor& getColor () const;
|
||||||
|
inline const QPen& getPen () const;
|
||||||
|
inline const QBrush& getBrush () const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef map<string,DrawingStyle> StyleMap;
|
||||||
|
typedef map<string,DrawingStyle>::const_iterator StyleIterator;
|
||||||
|
|
||||||
|
// Attributes.
|
||||||
|
protected:
|
||||||
|
StyleMap _drawingStyles;
|
||||||
|
|
||||||
|
// Constructor.
|
||||||
|
public:
|
||||||
|
DisplayStyle ();
|
||||||
|
|
||||||
|
// Accessors.
|
||||||
|
public:
|
||||||
|
const string& getPattern ( const string& key ) const;
|
||||||
|
const QColor& getColor ( const string& key ) const;
|
||||||
|
const QPen& getPen ( const string& key ) const;
|
||||||
|
const QBrush& getBrush ( const string& key ) const;
|
||||||
|
|
||||||
|
// Methods.
|
||||||
|
protected:
|
||||||
|
const DrawingStyle& findDrawingStyle ( const string& key ) const;
|
||||||
|
|
||||||
|
|
||||||
|
// Modifiers.
|
||||||
|
public:
|
||||||
|
void addDrawingStyle ( const string& key
|
||||||
|
, const string& pattern
|
||||||
|
, int red
|
||||||
|
, int green
|
||||||
|
, int blue
|
||||||
|
, int borderWidth
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Functions.
|
||||||
|
inline const string& DisplayStyle::DrawingStyle::getPattern () const { return _pattern; }
|
||||||
|
inline const QColor& DisplayStyle::DrawingStyle::getColor () const { return _color; }
|
||||||
|
inline const QPen& DisplayStyle::DrawingStyle::getPen () const { return _pen; }
|
||||||
|
inline const QBrush& DisplayStyle::DrawingStyle::getBrush () const { return _brush; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# endif
|
|
@ -0,0 +1,134 @@
|
||||||
|
|
||||||
|
// -*- C++ -*-
|
||||||
|
|
||||||
|
|
||||||
|
# include <vector>
|
||||||
|
|
||||||
|
# include <QBitmap>
|
||||||
|
# include <QPainter>
|
||||||
|
# include <QHBoxLayout>
|
||||||
|
# include <QVBoxLayout>
|
||||||
|
# include <QCheckBox>
|
||||||
|
# include <QPushButton>
|
||||||
|
|
||||||
|
# include "Name.h"
|
||||||
|
|
||||||
|
# include "ScreenLayer.h"
|
||||||
|
# include "LayersList.h"
|
||||||
|
# include "CellWidget.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace Hurricane {
|
||||||
|
|
||||||
|
|
||||||
|
ScreenLayerEntry::ScreenLayerEntry ( ScreenLayer* layer, LayersList* layersList )
|
||||||
|
: QWidget()
|
||||||
|
, _layersList(layersList)
|
||||||
|
{
|
||||||
|
QHBoxLayout* layout = new QHBoxLayout ();
|
||||||
|
layout->setContentsMargins ( 0, 0, 0, 0 );
|
||||||
|
|
||||||
|
_sample = layer->getSample();
|
||||||
|
layout->addWidget ( _sample );
|
||||||
|
|
||||||
|
_checkBox = new QCheckBox ( this );
|
||||||
|
_checkBox->setText ( getString(layer->getName()).c_str() );
|
||||||
|
_checkBox->setChecked ( true );
|
||||||
|
layout->addWidget ( _checkBox );
|
||||||
|
|
||||||
|
setLayout ( layout );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ScreenLayerEntry::setChecked ( bool state )
|
||||||
|
{
|
||||||
|
_checkBox->setChecked ( state );
|
||||||
|
_sample ->setVisible ( state );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ScreenLayerEntry::isChecked () const
|
||||||
|
{
|
||||||
|
return _checkBox->isChecked ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ScreenLayerEntry::toggle ()
|
||||||
|
{
|
||||||
|
_sample->setVisible ( _checkBox->isChecked() );
|
||||||
|
_layersList->getCellWidget()->redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
LayersList::LayersList ( CellWidget* cellWidget ) : QScrollArea()
|
||||||
|
, _cellWidget(cellWidget)
|
||||||
|
, _entries()
|
||||||
|
, _showAll(NULL)
|
||||||
|
, _hideAll(NULL)
|
||||||
|
{
|
||||||
|
QWidget* adaptator = new QWidget ();
|
||||||
|
QVBoxLayout* layout = new QVBoxLayout ();
|
||||||
|
|
||||||
|
vector<ScreenLayer*>& screenLayers = _cellWidget->getScreenLayers ();
|
||||||
|
|
||||||
|
for ( size_t i=0 ; i < screenLayers.size() ; i++ ) {
|
||||||
|
_entries.push_back ( new ScreenLayerEntry(screenLayers[i],this) );
|
||||||
|
layout->addWidget ( _entries.back() );
|
||||||
|
connect ( _entries.back()->getCheckBox(), SIGNAL(clicked()), _entries.back(), SLOT(toggle()) );
|
||||||
|
}
|
||||||
|
layout->addStretch ();
|
||||||
|
|
||||||
|
_showAll = new QPushButton ( this );
|
||||||
|
_showAll->setIcon ( QIcon(":/images/palette_show_all.png") );
|
||||||
|
_showAll->setFlat ( true );
|
||||||
|
|
||||||
|
_hideAll = new QPushButton ( this );
|
||||||
|
_hideAll->setIcon ( QIcon(":/images/palette_hide_all.png") );
|
||||||
|
_hideAll->setFlat ( true );
|
||||||
|
|
||||||
|
connect ( _showAll, SIGNAL(clicked()), this, SLOT(showAll()) );
|
||||||
|
connect ( _hideAll, SIGNAL(clicked()), this, SLOT(hideAll()) );
|
||||||
|
|
||||||
|
QHBoxLayout* bottomEntry = new QHBoxLayout ();
|
||||||
|
bottomEntry->setContentsMargins ( 0, 0, 0, 0 );
|
||||||
|
bottomEntry->addWidget ( _showAll );
|
||||||
|
bottomEntry->addWidget ( _hideAll );
|
||||||
|
layout->addLayout ( bottomEntry );
|
||||||
|
|
||||||
|
adaptator->setLayout ( layout );
|
||||||
|
setWidget ( adaptator );
|
||||||
|
setHorizontalScrollBarPolicy ( Qt::ScrollBarAlwaysOff );
|
||||||
|
setVerticalScrollBarPolicy ( Qt::ScrollBarAsNeeded );
|
||||||
|
setFrameStyle ( QFrame::Plain );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool LayersList::isVisible ( size_t index )
|
||||||
|
{
|
||||||
|
if ( index < _entries.size() )
|
||||||
|
return _entries[index]->isChecked ();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LayersList::showAll ()
|
||||||
|
{
|
||||||
|
for ( size_t i=0 ; i<_entries.size() ; i++ )
|
||||||
|
_entries[i]->setChecked ( true );
|
||||||
|
|
||||||
|
_cellWidget->redraw ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LayersList::hideAll ()
|
||||||
|
{
|
||||||
|
for ( size_t i=0 ; i<_entries.size() ; i++ )
|
||||||
|
_entries[i]->setChecked ( false );
|
||||||
|
|
||||||
|
_cellWidget->redraw ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // End of Hurricane namespace.
|
|
@ -0,0 +1,79 @@
|
||||||
|
|
||||||
|
// -*- C++ -*-
|
||||||
|
|
||||||
|
|
||||||
|
# ifndef __LAYERSLIST__
|
||||||
|
# define __LAYERSLIST__
|
||||||
|
|
||||||
|
# include <vector>
|
||||||
|
# include <QWidget>
|
||||||
|
# include <QScrollArea>
|
||||||
|
# include <QPixmap>
|
||||||
|
|
||||||
|
# include "Commons.h"
|
||||||
|
|
||||||
|
|
||||||
|
class QCheckBox;
|
||||||
|
class QPushButton;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Hurricane {
|
||||||
|
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
class LayerSample;
|
||||||
|
class ScreenLayer;
|
||||||
|
class LayersList;
|
||||||
|
class CellWidget;
|
||||||
|
|
||||||
|
|
||||||
|
class ScreenLayerEntry : public QWidget {
|
||||||
|
Q_OBJECT;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
LayersList* _layersList;
|
||||||
|
LayerSample* _sample;
|
||||||
|
QCheckBox* _checkBox;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ScreenLayerEntry ( ScreenLayer* layer, LayersList* layerList );
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool isChecked () const;
|
||||||
|
void setChecked ( bool state );
|
||||||
|
QCheckBox* getCheckBox () { return _checkBox; };
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void toggle ();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class LayersList : public QScrollArea {
|
||||||
|
Q_OBJECT;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
CellWidget* _cellWidget;
|
||||||
|
vector<ScreenLayerEntry*> _entries;
|
||||||
|
QPushButton* _showAll;
|
||||||
|
QPushButton* _hideAll;
|
||||||
|
|
||||||
|
public:
|
||||||
|
LayersList ( CellWidget* cellWidget );
|
||||||
|
|
||||||
|
public:
|
||||||
|
CellWidget* getCellWidget () { return _cellWidget; };
|
||||||
|
vector<ScreenLayerEntry*>& getEntries () { return _entries; };
|
||||||
|
bool isVisible ( size_t index );
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void showAll ();
|
||||||
|
void hideAll ();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // End of Hurricane namespace.
|
||||||
|
|
||||||
|
|
||||||
|
# endif
|
|
@ -1,45 +0,0 @@
|
||||||
#include "DataBase.h"
|
|
||||||
#include "Technology.h"
|
|
||||||
#include "BasicLayer.h"
|
|
||||||
using namespace Hurricane;
|
|
||||||
|
|
||||||
#include <QCheckBox>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QGridLayout>
|
|
||||||
|
|
||||||
#include "LayersWidget.h"
|
|
||||||
|
|
||||||
LayersWidget::LayersWidget(QWidget* parent)
|
|
||||||
: QWidget(parent),
|
|
||||||
widgets()
|
|
||||||
{
|
|
||||||
DataBase* db = getDataBase();
|
|
||||||
Technology* techno = db->getTechnology();
|
|
||||||
QGridLayout* mainLayout = new QGridLayout;
|
|
||||||
|
|
||||||
int line = 0;
|
|
||||||
for_each_basic_layer(basicLayer, techno->getBasicLayers()) {
|
|
||||||
QCheckBox* checkBox = new QCheckBox();
|
|
||||||
widgets.insert(checkBox);
|
|
||||||
mainLayout->addWidget(checkBox, line, 0, Qt::AlignRight);
|
|
||||||
//connect(checkBox, SIGNAL(toggled(bool)),
|
|
||||||
// renderArea, SLOT(setAntialiased(bool)));
|
|
||||||
|
|
||||||
string layerName = getString(basicLayer->getName());
|
|
||||||
QLabel* label = new QLabel(tr(layerName.c_str()));
|
|
||||||
widgets.insert(label);
|
|
||||||
mainLayout->addWidget(label, line, 1, Qt::AlignRight);
|
|
||||||
++line;
|
|
||||||
end_for;
|
|
||||||
}
|
|
||||||
setLayout(mainLayout);
|
|
||||||
setWindowTitle(tr("Layers"));
|
|
||||||
}
|
|
||||||
|
|
||||||
LayersWidget::~LayersWidget() {
|
|
||||||
for (set<QWidget*>::iterator wsit = widgets.begin();
|
|
||||||
wsit != widgets.end();
|
|
||||||
wsit++) {
|
|
||||||
delete *wsit;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
#ifndef LAYERS_WIDGET_H
|
|
||||||
#define LAYERS_WIDGET_H
|
|
||||||
|
|
||||||
#include <set>
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
class LayersWidget : public QWidget {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public :
|
|
||||||
LayersWidget(QWidget *parent = 0);
|
|
||||||
~LayersWidget();
|
|
||||||
private:
|
|
||||||
set<QWidget*> widgets;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
|
||||||
|
// -*- C++ -*-
|
||||||
|
|
||||||
|
|
||||||
|
# include <QPainter>
|
||||||
|
|
||||||
|
# include "BasicLayer.h"
|
||||||
|
|
||||||
|
# include "ScreenUtilities.h"
|
||||||
|
# include "ScreenLayer.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace Hurricane {
|
||||||
|
|
||||||
|
|
||||||
|
LayerSample::LayerSample ( ScreenLayer* layer )
|
||||||
|
: QWidget()
|
||||||
|
, _sample(QSize(20,20))
|
||||||
|
, _layer(layer)
|
||||||
|
{
|
||||||
|
setAttribute ( Qt::WA_StaticContents );
|
||||||
|
setSizePolicy ( QSizePolicy::Fixed, QSizePolicy::Fixed );
|
||||||
|
setFixedSize ( 20, 20 );
|
||||||
|
|
||||||
|
redraw ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LayerSample::redraw ()
|
||||||
|
{
|
||||||
|
QPainter painter ( &_sample );
|
||||||
|
|
||||||
|
painter.setPen ( Qt::NoPen );
|
||||||
|
painter.setBackground ( QBrush(Qt::black,Qt::SolidPattern) );
|
||||||
|
painter.eraseRect ( 0, 0, 20, 20 );
|
||||||
|
painter.setBrush ( _layer->getBrush() );
|
||||||
|
painter.drawRect ( 2, 2, 16, 16 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LayerSample::paintEvent ( QPaintEvent* )
|
||||||
|
{
|
||||||
|
QPainter painter ( this );
|
||||||
|
painter.drawPixmap ( 0, 0, _sample );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ScreenLayer::ScreenLayer ( BasicLayer* basicLayer
|
||||||
|
, size_t index
|
||||||
|
, bool isVisible
|
||||||
|
) : _layer(basicLayer)
|
||||||
|
, _index(index)
|
||||||
|
, _isVisible(isVisible)
|
||||||
|
, _brush(H::getBrush(_layer))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
const Name& ScreenLayer::getName () const
|
||||||
|
{
|
||||||
|
return _layer->getName ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LayerSample* ScreenLayer::getSample ()
|
||||||
|
{
|
||||||
|
return new LayerSample ( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // End of Hurricane namespace.
|
|
@ -0,0 +1,89 @@
|
||||||
|
|
||||||
|
// -*- C++ -*-
|
||||||
|
|
||||||
|
|
||||||
|
# ifndef __SCREENLAYER_H__
|
||||||
|
# define __SCREENLAYER_H__
|
||||||
|
|
||||||
|
# include <string>
|
||||||
|
# include <QBrush>
|
||||||
|
# include <QPixmap>
|
||||||
|
# include <QWidget>
|
||||||
|
|
||||||
|
class QPaintEvent;
|
||||||
|
|
||||||
|
# include "Commons.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace Hurricane {
|
||||||
|
|
||||||
|
|
||||||
|
class Name;
|
||||||
|
class BasicLayer;
|
||||||
|
class ScreenLayer;
|
||||||
|
|
||||||
|
|
||||||
|
class LayerSample : public QWidget {
|
||||||
|
Q_OBJECT;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QPixmap _sample;
|
||||||
|
ScreenLayer* _layer;
|
||||||
|
|
||||||
|
public:
|
||||||
|
LayerSample ( ScreenLayer* layer );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void redraw ();
|
||||||
|
void paintEvent ( QPaintEvent* );
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
inline void setVisible ( bool state );
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class ScreenLayer {
|
||||||
|
|
||||||
|
protected:
|
||||||
|
BasicLayer* _layer;
|
||||||
|
size_t _index;
|
||||||
|
bool _isVisible;
|
||||||
|
QBrush _brush;
|
||||||
|
|
||||||
|
// Constructor.
|
||||||
|
public:
|
||||||
|
ScreenLayer ( BasicLayer* layer, size_t index, bool isVisible );
|
||||||
|
|
||||||
|
// Predicates.
|
||||||
|
public:
|
||||||
|
bool isVisible () const { return _isVisible; };
|
||||||
|
// Accessors.
|
||||||
|
public:
|
||||||
|
size_t getIndex () const { return _index; };
|
||||||
|
BasicLayer* getBasicLayer () const { return _layer; };
|
||||||
|
const Name& getName () const;
|
||||||
|
|
||||||
|
// Methods.
|
||||||
|
public:
|
||||||
|
const QBrush& getBrush () const { return _brush; };
|
||||||
|
LayerSample* getSample ();
|
||||||
|
|
||||||
|
// Modifiers.
|
||||||
|
public:
|
||||||
|
inline void setVisible ( bool state ) { _isVisible=state; };
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
inline void LayerSample::setVisible ( bool state )
|
||||||
|
{
|
||||||
|
_layer->setVisible ( state );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // End of Hurricane namespace.
|
||||||
|
|
||||||
|
|
||||||
|
# endif
|
|
@ -0,0 +1,84 @@
|
||||||
|
|
||||||
|
// -*- C++ -*-
|
||||||
|
|
||||||
|
|
||||||
|
# include <QBitmap>
|
||||||
|
|
||||||
|
# include "BasicLayer.h"
|
||||||
|
|
||||||
|
# include "ScreenUtilities.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
|
||||||
|
inline bool charToBits ( uchar& b, char c, bool low=true )
|
||||||
|
{
|
||||||
|
bool isValid = true;
|
||||||
|
uchar value = 0xF;
|
||||||
|
|
||||||
|
if ( (c >= '0') && (c <= '9') ) value = (uchar)( c - '0' );
|
||||||
|
else {
|
||||||
|
if ( (c >= 'a') && (c <= 'f') ) value = (uchar)( c - 'a' + 10 );
|
||||||
|
else {
|
||||||
|
if ( (c >= 'A') && (c <= 'F') ) value = (uchar)( c - 'A' + 10 );
|
||||||
|
else
|
||||||
|
isValid = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
b &= (low) ? 0xF0 : 0x0F;
|
||||||
|
b += (low) ? value : (value<<4);
|
||||||
|
|
||||||
|
return isValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool getPattern ( uchar bits[], const string& pattern )
|
||||||
|
{
|
||||||
|
bool isValid = true;
|
||||||
|
|
||||||
|
for ( size_t i=0 ; i<pattern.size() ; i++ ) {
|
||||||
|
if ( i > 15 ) { isValid = false; break; }
|
||||||
|
isValid &= charToBits ( bits[i/2], pattern[i], i%2 );
|
||||||
|
}
|
||||||
|
return isValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace Hurricane {
|
||||||
|
|
||||||
|
|
||||||
|
QBrush getBrush ( const string& pattern, int red, int green, int blue )
|
||||||
|
{
|
||||||
|
if ( pattern != "FFFFFFFFFFFFFFFF" ) {
|
||||||
|
uchar bits[8];
|
||||||
|
|
||||||
|
if ( !getPattern(bits,pattern) )
|
||||||
|
cerr << "[WARNING] Invalid stipple pattern: \"0x" << pattern << "\"." << endl;
|
||||||
|
|
||||||
|
return QBrush ( QColor(red,green,blue), QBitmap::fromData(QSize(8,8),bits,QImage::Format_Mono) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return QBrush ( QColor(red,green,blue), Qt::SolidPattern );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QBrush getBrush ( const BasicLayer* layer )
|
||||||
|
{
|
||||||
|
return getBrush ( layer->getFillPattern()
|
||||||
|
, layer->getRedValue()
|
||||||
|
, layer->getGreenValue()
|
||||||
|
, layer->getBlueValue()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // End of Hurricane namespace.
|
|
@ -0,0 +1,31 @@
|
||||||
|
|
||||||
|
// -*- C++ -*-
|
||||||
|
|
||||||
|
|
||||||
|
# ifndef __SCREENUTILITIES_H__
|
||||||
|
# define __SCREENUTILITIES_H__
|
||||||
|
|
||||||
|
# include <string>
|
||||||
|
# include <QBrush>
|
||||||
|
|
||||||
|
# include "Commons.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace Hurricane {
|
||||||
|
|
||||||
|
|
||||||
|
class BasicLayer;
|
||||||
|
|
||||||
|
|
||||||
|
// Functions.
|
||||||
|
|
||||||
|
QBrush getBrush ( const string& pattern, int red, int green, int blue );
|
||||||
|
QBrush getBrush ( const BasicLayer* layer );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // End of Hurricane namespace.
|
||||||
|
|
||||||
|
|
||||||
|
# endif
|
After Width: | Height: | Size: 536 B |
After Width: | Height: | Size: 522 B |
After Width: | Height: | Size: 523 B |
After Width: | Height: | Size: 605 B |
After Width: | Height: | Size: 923 B |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 394 B |
After Width: | Height: | Size: 850 B |