From 97916fd05be8a0b6bb03ba61340de188ce25f1e8 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Thu, 3 Apr 2008 15:07:41 +0000 Subject: [PATCH] Complete replacement of xtof viewer by jpc'one. Still in early stage. Many features missings. --- hurricane/src/viewer/CMakeLists.txt | 7 +- hurricane/src/viewer/Cell.cpp | 860 ----- hurricane/src/viewer/CellViewer.cpp | 206 +- hurricane/src/viewer/CellViewer.h | 83 +- hurricane/src/viewer/CellViewer.qrc | 12 + hurricane/src/viewer/CellWidget.cpp | 3211 +++-------------- hurricane/src/viewer/CellWidget.h | 1756 +-------- hurricane/src/viewer/DisplayStyle.cpp | 94 + hurricane/src/viewer/DisplayStyle.h | 101 + hurricane/src/viewer/LayersList.cpp | 134 + hurricane/src/viewer/LayersList.h | 79 + hurricane/src/viewer/LayersWidget.cpp | 45 - hurricane/src/viewer/LayersWidget.h | 19 - hurricane/src/viewer/ScreenLayer.cpp | 72 + hurricane/src/viewer/ScreenLayer.h | 89 + hurricane/src/viewer/ScreenUtilities.cpp | 84 + hurricane/src/viewer/ScreenUtilities.h | 31 + hurricane/src/viewer/View.cpp | 1811 ---------- hurricane/src/viewer/images/gtk-go-down.png | Bin 0 -> 536 bytes .../src/viewer/images/gtk-go-forward-ltr.png | Bin 0 -> 522 bytes .../src/viewer/images/gtk-go-forward-rtl.png | Bin 0 -> 523 bytes hurricane/src/viewer/images/gtk-go-up.png | Bin 0 -> 605 bytes .../src/viewer/images/palette_hide_all.png | Bin 0 -> 923 bytes .../src/viewer/images/palette_show_all.png | Bin 0 -> 1398 bytes hurricane/src/viewer/images/stock_open.png | Bin 0 -> 394 bytes hurricane/src/viewer/images/stock_save.png | Bin 0 -> 850 bytes 26 files changed, 1637 insertions(+), 7057 deletions(-) delete mode 100644 hurricane/src/viewer/Cell.cpp create mode 100644 hurricane/src/viewer/CellViewer.qrc create mode 100644 hurricane/src/viewer/DisplayStyle.cpp create mode 100644 hurricane/src/viewer/DisplayStyle.h create mode 100644 hurricane/src/viewer/LayersList.cpp create mode 100644 hurricane/src/viewer/LayersList.h delete mode 100644 hurricane/src/viewer/LayersWidget.cpp delete mode 100644 hurricane/src/viewer/LayersWidget.h create mode 100644 hurricane/src/viewer/ScreenLayer.cpp create mode 100644 hurricane/src/viewer/ScreenLayer.h create mode 100644 hurricane/src/viewer/ScreenUtilities.cpp create mode 100644 hurricane/src/viewer/ScreenUtilities.h delete mode 100644 hurricane/src/viewer/View.cpp create mode 100644 hurricane/src/viewer/images/gtk-go-down.png create mode 100644 hurricane/src/viewer/images/gtk-go-forward-ltr.png create mode 100644 hurricane/src/viewer/images/gtk-go-forward-rtl.png create mode 100644 hurricane/src/viewer/images/gtk-go-up.png create mode 100644 hurricane/src/viewer/images/palette_hide_all.png create mode 100644 hurricane/src/viewer/images/palette_show_all.png create mode 100644 hurricane/src/viewer/images/stock_open.png create mode 100644 hurricane/src/viewer/images/stock_save.png diff --git a/hurricane/src/viewer/CMakeLists.txt b/hurricane/src/viewer/CMakeLists.txt index 021b690c..13d331d0 100644 --- a/hurricane/src/viewer/CMakeLists.txt +++ b/hurricane/src/viewer/CMakeLists.txt @@ -2,13 +2,14 @@ include(${QT_USE_FILE}) 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(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_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) install(FILES ${exports} DESTINATION /include/hurricane) diff --git a/hurricane/src/viewer/Cell.cpp b/hurricane/src/viewer/Cell.cpp deleted file mode 100644 index f93ea795..00000000 --- a/hurricane/src/viewer/Cell.cpp +++ /dev/null @@ -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(occurrence.GetEntity()); - - for_each_component ( component, net->GetComponents() ) { - Plug* primaryPlug = dynamic_cast( 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( 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( 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,slaveEntity)); -} - -void Cell::_RemoveSlaveEntity(Entity* entity, Entity* slaveEntity) -// *************************************************************************** -{ - assert(entity->GetCell() == this); - - pair - bounds = _slaveEntityMap.equal_range(entity); - multimap::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(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(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(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(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(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 -// **************************************************************************************************** diff --git a/hurricane/src/viewer/CellViewer.cpp b/hurricane/src/viewer/CellViewer.cpp index 2da1e23b..007f02ae 100644 --- a/hurricane/src/viewer/CellViewer.cpp +++ b/hurricane/src/viewer/CellViewer.cpp @@ -1,93 +1,143 @@ -#include -#include "CellWidget.h" -#include "LayersWidget.h" -#include "CellViewer.h" +// -*- C++ -*- -CellViewer::CellViewer(Cell* cell) - : QMainWindow() + +# include +# include +# include +# include + +# 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); - setCentralWidget(cellWidget); - - createActions(); - createMenus(); - - setWindowTitle(tr("Cell Viewer")); - resize(1000, 500); + createMenus (); + createLayout ( cell ); } -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()) { - case Qt::Key_Left: - cellWidget->scroll(-scrollStep, 0); - break; - case Qt::Key_Right: - cellWidget->scroll(+scrollStep, 0); - break; - case Qt::Key_Down: - cellWidget->scroll(0, -scrollStep); - break; - case Qt::Key_Up: - cellWidget->scroll(0, +scrollStep); - break; - default: - QWidget::keyPressEvent(event); - } + +void CellViewer::createMenus () +{ + if ( _fileMenu ) return; + if ( !_openAction ) createActions (); + + _fileMenu = menuBar()->addMenu ( tr("File") ); + _fileMenu->addAction ( _openAction ); + _fileMenu->addAction ( _nextCellAction ); + _fileMenu->addAction ( _previousCellAction ); + _fileMenu->addAction ( _nextAction ); + _fileMenu->addAction ( _saveAction ); + _fileMenu->addAction ( _exitAction ); + + _viewMenu = menuBar()->addMenu ( tr("View") ); + _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); - cellWidget->update(); + +void CellViewer::createLayout ( Cell* cell ) +{ + 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() { - 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); -} +} // End of Hurricane namespace. diff --git a/hurricane/src/viewer/CellViewer.h b/hurricane/src/viewer/CellViewer.h index cd304103..91599265 100644 --- a/hurricane/src/viewer/CellViewer.h +++ b/hurricane/src/viewer/CellViewer.h @@ -1,39 +1,64 @@ -#ifndef __CELL_VIEWER_H -#define __CELL_VIEWER_H -#include "Cell.h" -using namespace Hurricane; +// -*- C++ -*- -#include -class CellWidget; -class LayersWidget; +# ifndef __CELLVIEWER_H__ +# define __CELLVIEWER_H__ -class CellViewer : public QMainWindow { - Q_OBJECT + +using namespace std; + +# include + +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: - CellViewer(Cell* cell); - ~CellViewer(); - private: - CellWidget* cellWidget; - LayersWidget* layersWidget; + CellViewer ( Cell* cell ); - QAction *zoomInAct; - QAction *zoomOutAct; - QAction *fitToWindowAct; - QMenu *viewMenu; - - void createActions(); - void createMenus(); - - private slots: - void zoomIn(); - void zoomOut(); - void fitToWindow(); protected: - void keyPressEvent(QKeyEvent *event); + void createActions (); + void createMenus (); + void createLayout ( Cell* cell ); + }; -}; -#endif + +} // End of Hurricane namespace. + + +# endif diff --git a/hurricane/src/viewer/CellViewer.qrc b/hurricane/src/viewer/CellViewer.qrc new file mode 100644 index 00000000..65078a51 --- /dev/null +++ b/hurricane/src/viewer/CellViewer.qrc @@ -0,0 +1,12 @@ + + + images/stock_open.png + images/stock_save.png + images/palette_show_all.png + images/palette_hide_all.png + images/gtk-go-up.png + images/gtk-go-down.png + images/gtk-go-forward-rtl.png + images/gtk-go-forward-ltr.png + + diff --git a/hurricane/src/viewer/CellWidget.cpp b/hurricane/src/viewer/CellWidget.cpp index f46ab916..e563198f 100644 --- a/hurricane/src/viewer/CellWidget.cpp +++ b/hurricane/src/viewer/CellWidget.cpp @@ -1,2765 +1,714 @@ -// ************************************************************************************************* -// ************************************************************************************************* -// File: CellWidget.cpp -// ************************************************************************************************* -// ************************************************************************************************* -#include "CellWidget.h" - -#include "Cell.h" -#include "Boxes.h" -//#include "Command.h" -#include "DataBase.h" -#include "Exception.h" -#include "Layer.h" -#include "Record.h" -//#include "Selector.h" -#include "Slice.h" -#include "Slot.h" -#include "Technology.h" -#include "Transformation.h" -using namespace Hurricane; - -#include -#include -#include - -#include -#include - -//OPEN_MY_NAMESPACE - -namespace { - -QBrush getBrush(const string &pattern, int redValue, int greenValue, int blueValue) { - if (pattern == "FFFFFFFFFFFFFFFF") { - return QBrush(QColor(redValue, greenValue, blueValue)); - } else { - uchar bits[8]; - for (int i = 0; i < 8; i++) { - int high = pattern[i * 2]; - if (('0' <= high) && (high <= '9')) { - high = high - '0'; - } else { - if (('a' <= high) && (high <= 'f')) { - high = 10 + high - 'a'; - } else { - if (('A' <= high) && (high <= 'F')) { - high = 10 + high - 'A'; - } else { - high = '0'; - } - } - } - int low = pattern[(i * 2) + 1]; - if (('0' <= low) && (low <= '9')) { - low = low - '0'; - } else { - if (('a' <= low) && (low <= 'f')) { - low = 10 + low - 'a'; - } else { - if (('A' <= low) && (low <= 'F')) { - low = 10 + low - 'A'; - } else { - low = '0'; - } - } - } - bits[i] = (uchar)((high * 16) + low); - } - - return QBrush(QColor(redValue, greenValue, blueValue), QBitmap::fromData(QSize(8,8), bits, QImage::Format_Mono)); - } -} - -static QColor backgroundColor = QColor( 50, 50, 50 ); -static QColor foregroundColor = QColor( 255, 255, 255 ); -static QColor rubberColor = QColor( 192, 0, 192 ); -static QColor phantomColor = QColor( 139, 134, 130 ); -static QColor boundaryColor = QColor( 208, 199, 192 ); -static QColor markerColor = QColor( 80, 250, 80 ); -static QColor selectionDrawColor = QColor( 255, 255, 255 ); -static QColor selectionFillColor = QColor( 255, 255, 255 ); -static QColor gridColor = QColor( 255, 255, 255 ); -static QColor spotColor = QColor( 255, 255, 255 ); -static QColor ghostColor = QColor( 255, 255, 255 ); - -static QPen boundariesPen = QPen(boundaryColor); -static QBrush boundariesBrush = QBrush(boundaryColor); -static QPen phantomsPen = QPen(phantomColor); -static QBrush phantomsBrush = QBrush(phantomColor); -static QBrush defaultBrush = QBrush(); -static QPen defaultPen = QPen(); - -} +// -*- C++ -*- -Cell* -CellWidget::getCell() const { - return _cell; -} +# include +# include +# include +# include +# include +# include -// ************************************************************************************************* -// getLabel() -// ************************************************************************************************* +# include "DataBase.h" +# include "Technology.h" +# include "BasicLayer.h" +# include "Cell.h" +# include "Instance.h" +# include "Slice.h" +# include "Segment.h" +# include "Contact.h" -///static -///Label -///getLabel(const QColor& color) -///{ -/// return getLabel(color.red()) + ":" + getLabel(color.green()) + ":" + getLabel(color.blue()); -///} -/// - - -// ************************************************************************************************* -// CellWidget::_sPoints -// ************************************************************************************************* - -//QPointArray CellWidget::_sPoints; +# include "ScreenLayer.h" +# include "LayersList.h" +// # include "MapView.h" +# include "CellWidget.h" -// ************************************************************************************************* -// CellWidget::CellWidget() -// ************************************************************************************************* -CellWidget::CellWidget(Cell* cell, - QWidget* parent, - const char* name) -: Inherit(parent), - _cell(cell), - _center(0, 0), - _scale(1), - _screenDx(0), - _screenDy(0), - _brushDx(0), - _brushDy(0), - _alreadyExposed(false), - _invalidRegion(), - _clipBox(), - _clipX(), - _clipY(), - _painter(NULL), - _backgroundColor(20, 20, 20), - _foregroundColor(255, 255, 255), - _doubleBuffering(false), - _automaticScrolling(false), - _visibleLayerMask(~0), - //_commandMap(), - //_startedCommand(NULL), - _gridOrigin(), - _gridXStep(getUnit(1)), - _gridYStep(getUnit(1)), - _gridIsVisible(true), - _gridAxesAreVisible(false), - _gridDisplayThreshold(8), - _gridColor(QColor(155, 155, 155)), - _snapGrid(true), - _drawSnapPoint(false), - _snapPoint(), - _displayDepth(1), - _displaySize(2), - //_selectorSet(), - _selectionLimit(100000), - _selectionColor(255, 255, 255), - _selectionIsVisible(true), - //_highlightorSet(), - _highlightionLimit(10000), - _highlightionIsVisible(true), - //_trackBox(NULL), - _peekList(), - _basicLayersBrush(), - _basicLayersPen() +namespace Hurricane { + + +const int CellWidget::_stripWidth = 100; + + + + +CellWidget::CellWidget ( Cell* cell ) : QWidget() + , _styles() + , _activeStyle(NULL) + , _screenLayers() + , _layersList(NULL) + , _displayArea(0,0,6*_stripWidth,6*_stripWidth) + , _visibleArea(_stripWidth,_stripWidth,4*_stripWidth,4*_stripWidth) + , _scale(1.0) + , _offsetVA(_stripWidth,_stripWidth) + , _drawingBuffer(6*_stripWidth,6*_stripWidth) + , _painter() + , _lastMousePosition(0,0) + , _cell(cell) + , _mouseGo(false) + , _openCell(true) + , _showBoundaries(true) { - setFocusPolicy(Qt::StrongFocus); // to accepts focus by tabbing and clicking - setMouseTracking(true); // to have move events even a mouse button isn't pressed + setAttribute ( Qt::WA_OpaquePaintEvent ); + setAttribute ( Qt::WA_NoSystemBackground ); + setAttribute ( Qt::WA_PaintOnScreen ); + setAttribute ( Qt::WA_StaticContents ); + setSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding ); + setFocusPolicy ( Qt::StrongFocus ); +//setAutoFillBackground ( false ); - DataBase* database = getDataBase(); - if (database) { - Technology* technology = database->getTechnology(); - if (technology) { - for_each_basic_layer(basiclayer, technology->getBasicLayers()) { - _basicLayersBrush[basiclayer] = - ::getBrush(basiclayer->getFillPattern(), - basiclayer->getRedValue(), - basiclayer->getGreenValue(), - basiclayer->getBlueValue()); - _basicLayersPen[basiclayer] = - QPen(QColor(basiclayer->getRedValue(), basiclayer->getGreenValue(), basiclayer->getBlueValue())); - end_for; - } - } - } -} - - - -// ************************************************************************************************* -// CellWidget::~CellWidget() -// ************************************************************************************************* - -CellWidget::~CellWidget() -{ - clearPeeks(); - //clearHighlightion(); - //clearSelection(); - - //forEachCommand(command, getCommands()) { - // command->uninstallFrom(this); - // endFor; - //} - - //if (_trackBox) { - // _trackBox->_setCellWidget(NULL); - //} -} - - - -// ************************************************************************************************* -// CellWidget::getLabel() -// CellWidget::getRecord() -// CellWidget::getSlot() -// ************************************************************************************************* - -//Label -//CellWidget::getLabel() const -//{ -// Label label = Label::create(getTypeName(*this)); -// -// View* view = getView(); -// if (view) { -// label.add(" ", view); -// } -// -// return label; -//} -// -//Record* -//CellWidget::getRecord() const -//{ -// Record* record = new Record(this); -// -// if (record) { -// record->addHeader("Widget"); -// -// record->addHeader("CellWidget"); -// -// record->addSlot("View", getView()); -// record->addSlot("Center", getCenter()); -// record->addSlot("Scale", getScale()); -// record->addSlot("BackgroundColor", My::getLabel(getBackgroundColor())); -// record->addSlot("ForegroundColor", My::getLabel(getForegroundColor())); -// record->addSlot("DoubleBuffering", doubleBuffering()); -// record->addSlot("AutomaticScrolling", automaticScrolling()); -// record->addSlot("VisibleLayers", getVisibleLayers()); -// record->addSlot("Commands", getCommands()); -// record->addSlot("GridOrigin", getGridOrigin()); -// record->addSlot("GridXStep", getValueString(getGridXStep())); -// record->addSlot("GridYStep", getValueString(getGridYStep())); -// record->addSlot("GridDisplayThreshold", getGridDisplayThreshold()); -// record->addSlot("GridIsVisible", gridIsVisible()); -// record->addSlot("GridAxesAreVisible", gridAxesAreVisible()); -// record->addSlot("GridIsDrawable", gridIsDrawable()); -// record->addSlot("GridColor", My::getLabel(getGridColor())); -// record->addSlot("SnapGrid", snapGrid()); -// record->addSlot("DisplayDepth", getDisplayDepth()); -// record->addSlot("DisplaySize", getDisplaySize()); -// record->addSlot("SelectionIsVisible", selectionIsVisible()); -// record->addSlot("Selection", getSelection()); -// record->addSlot("SelectionBox", getSelectionBox()); -// unsigned limit = getSelectionLimit(); -// if (limit) { -// record->addSlot("SelectionLimit", limit); -// } -// else { -// record->addSlot("SelectionLimit", "NONE"); -// } -// record->addSlot("SelectionColor", My::getLabel(getSelectionColor())); -// record->addSlot("HighlightionIsVisible", highlightionIsVisible()); -// record->addSlot("Highlightion", getHighlightion()); -// record->addSlot("HighlightionBox", getHighlightionBox()); -// record->addSlot("TrackBox", getTrackBox()); -// } -// -// return record; -//} -// -//Slot* -//CellWidget::getSlot(const string& name) const -//{ -// return new StandardSlot(name, this); -//} -// - - -// ************************************************************************************************* -// CellWidget::getCenter() -// CellWidget::getScale() -// ************************************************************************************************* - -const Point& -CellWidget::getCenter() const -{ - return _center; -} - -double -CellWidget::getScale() const -{ - return _scale; -} - - - -// ************************************************************************************************* -// CellWidget::getX() -// CellWidget::getY() -// CellWidget::getSize() -// CellWidget::getPoint() -// CellWidget::getBox() -// ************************************************************************************************* - -Unit -CellWidget::getX(int screenX) const -{ - return getUnit((screenX - _screenDx) / _scale); -} - -Unit -CellWidget::getY(int screenY) const -{ - return getUnit(((height() - screenY) - _screenDy) / _scale); -} - -Unit -CellWidget::getSize(int screenSize) const -{ - return getUnit(screenSize / _scale); -} - -Point -CellWidget::getPoint(const QPoint& screenPoint) const -{ - return Point(getX(screenPoint.x()), getY(screenPoint.y())); -} - -Box -CellWidget::getBox(const QRect& screenRect) const -{ - if (screenRect.isEmpty()) { - return Box(); - } - - return Box(getX(screenRect.left()), - getY(screenRect.bottom()), - getX(screenRect.right()), - getY(screenRect.top())); -} - - - -// ************************************************************************************************* -// CellWidget::getScreenX() -// CellWidget::getScreenY() -// CellWidget::getScreenSize() -// CellWidget::getScreenPoint() -// CellWidget::getScreenBox() -// ************************************************************************************************* - -int -CellWidget::getScreenX(const Unit& x) const -{ - return _screenDx + (int)rint(getValue(x) * _scale); -} - -int -CellWidget::getScreenY(const Unit& y) const -{ - return height() - (int)rint(_screenDy + (getValue(y) * _scale)); -} - -int -CellWidget::getScreenSize(const Unit& size) const -{ - return (int)rint(getValue(size) * _scale); -} - -QPoint -CellWidget::getScreenPoint(const Point& point) const -{ - return QPoint(getScreenX(point.getX()), getScreenY(point.getY())); -} - -QRect -CellWidget::getScreenRect(const Box& box) const -{ - if (box.isEmpty()) { - return QRect(); - } - - int screenX1 = getScreenX(box.getXMin()); - int screenY1 = getScreenY(box.getYMin()); - int screenX2 = getScreenX(box.getXMax()); - int screenY2 = getScreenY(box.getYMax()); - - return QRect(QPoint(min(screenX1, screenX2), min(screenY1, screenY2)), - QPoint(max(screenX1, screenX2), max(screenY1, screenY2))); -} - - - -// ************************************************************************************************* -// CellWidget::getSnapPoint() -// ************************************************************************************************* - -Point -CellWidget::getSnapPoint(const Point& point) const -{ - return (_snapGrid) ? getGridPoint(point) : point; -} - -Point -CellWidget::getSnapPoint(int screenX, - int screenY) const -{ - return getSnapPoint(Point(getX(screenX), getY(screenY))); -} - - - -// ************************************************************************************************* -// CellWidget::getVisibleLayers() -// ************************************************************************************************* - -BasicLayers -CellWidget::getVisibleLayers() const -{ - DataBase* database = getDataBase(); - if (database) { + // Build ScreenLayer vector here from BasicLayers. + DataBase* database = getDataBase(); + if (database) { Technology* technology = database->getTechnology(); if (technology) { - return technology->getBasicLayers(_visibleLayerMask); - } - } - return NULL; -} - - - -// ************************************************************************************************* -// CellWidget::getCommand() -// CellWidget::getCommands() -// ************************************************************************************************* - -//Command* -//CellWidget::getCommand(int button) const -//{ -// CommandMap::const_iterator i = _commandMap.find(button); -// -// return (i != _commandMap.end()) ? (*i).second : NULL; -//} -// -//Commands -//CellWidget::getCommands() const -//{ -// return _commandMap; -//} -// - - -// ************************************************************************************************* -// CellWidget::getGridX() -// CellWidget::getGridY() -// CellWidget::getGridPoint() -// ************************************************************************************************* - -Unit -CellWidget::getGridX(const Unit& x, - int sign) const -{ - if (!((-1 <= sign) && (sign <= 1))) { - //throw Error(INVALID_REQUEST, __FILE__, __LINE__); - } - - Unit cx = x; - Unit xo = _gridOrigin.getX(); - - if (cx != xo) { - cx -= xo; - switch (sign) { - case -1 : { - if (0 < cx) { - return ((cx / _gridXStep) * _gridXStep) + xo; - } - else { - if (cx < 0) { - return (((cx / _gridXStep) - 1) * _gridXStep) + xo; - } - } - return cx + xo; - } - case 0 : { - Unit x1 = (cx / _gridXStep) * _gridXStep; - Unit x2 = ((x1 < cx) ? (x1 + _gridXStep) : (x1 - _gridXStep)); - return ((labs(x1 - cx) <= labs(x2 - cx)) ? x1 : x2) + xo; - } - case 1 : { - if (0 < cx) { - return (((cx / _gridXStep) + 1) * _gridXStep) + xo; - } - else { - if (cx < 0) { - return ((cx / _gridXStep) * _gridXStep) + xo; - } - } - return cx + xo; - } - } - } - - return cx; -} - -Unit -CellWidget::getGridY(const Unit& y, - int sign) const -{ - if (!((-1 <= sign) && (sign <= 1))) { - //throw Error(INVALID_REQUEST, __FILE__, __LINE__); - } - - Unit cy = y; - Unit yo = _gridOrigin.getY(); - - if (cy != yo) { - cy -= yo; - switch (sign) { - case -1 : { - if (0 < cy) { - return ((cy / _gridYStep) * _gridYStep) + yo; - } - else { - if (cy < 0) { - return (((cy / _gridYStep) - 1) * _gridYStep) + yo; - } - } - return cy + yo; - } - case 0 : { - Unit y1 = (cy / _gridYStep) * _gridYStep; - Unit y2 = ((y1 < cy) ? (y1 + _gridYStep) : (y1 - _gridYStep)); - return ((labs(y1 - cy) <= labs(y2 - cy)) ? y1 : y2) + yo; - } - case 1 : { - if (0 < cy) { - return (((cy / _gridYStep) + 1) * _gridYStep) + yo; - } - else { - if (cy < 0) { - return ((cy / _gridYStep) * _gridYStep) + yo; - } - } - return cy + yo; - } - } - } - - return cy; -} - -Point -CellWidget::getGridPoint(const Point& point, - int xSign, - int ySign) const -{ - return Point(getGridX(point.getX(), xSign), getGridY(point.getY(), ySign)); -} - - - -// ************************************************************************************************* -// CellWidget::getWorld() -// ************************************************************************************************* - -//Box -//CellWidget::getWorld() const -//{ -// Box world = Box(getX(0), getY(0), getX(width()), getY(height())); -// -// View* view = getView(); -// -// if (view) { -// world.merge(view->getBoundingBox()); -// } -// -// return world; -//} - - - -// ************************************************************************************************* -// CellWidget::getSelectors() -// CellWidget::getSelection() -// CellWidget::getSelectionBox() -// CellWidget::getHighlightors() -// CellWidget::getHighlightion() -// CellWidget::getHighlightionBox() -// ************************************************************************************************* - -//Selectors -//CellWidget::getSelectors() const -//{ -// return _selectorSet; -//} - -//Occurrences -//CellWidget::getSelection() const -//{ -// return getSelectors().getAssociates(getOccurrence()); -//} - -//Box -//CellWidget::getSelectionBox() const -//{ -// Box selectionBox; -// -// forEachOccurrence(occurrence, getSelection()) { -// selectionBox.merge(occurrence.getBoundingBox()); -// endFor; -// } -// -// return selectionBox; -//} -// -//Highlightors -//CellWidget::getHighlightors() const -//{ -// return _highlightorSet; -//} -// -//Occurrences -//CellWidget::getHighlightion() const -//{ -// return getHighlightors().getAssociates(getOccurrence()); -//} -// -//Box -//CellWidget::getHighlightionBox() const -//{ -// Box highlightionBox; -// -// forEachOccurrence(occurrence, getHighlightion()) { -// highlightionBox.merge(occurrence.getBoundingBox()); -// endFor; -// } -// -// return highlightionBox; -//} -// - - -// ************************************************************************************************* -// CellWidget::getFont() -// CellWidget::getPen() -// CellWidget::getBrush() -// CellWidget::getBrushOrigin() -// ************************************************************************************************* - -const QFont& -CellWidget::getFont() -{ - return (_painter) ? _painter->font() : QPainter(this).font(); -} - -const QPen& -CellWidget::getPen() -{ - return (_painter) ? _painter->pen() : QPainter(this).pen(); -} - - -const QPen& -CellWidget::getPen(const BasicLayer* basiclayer) { - map::const_iterator pmit = _basicLayersPen.find(basiclayer); - if (pmit != _basicLayersPen.end()) { - return pmit->second; - } - return defaultPen; -} - -const QBrush& -CellWidget::getBrush() -{ - return (_painter) ? _painter->brush() : QPainter(this).brush(); -} - -const QBrush& -CellWidget::getBrush(BasicLayer* basiclayer) { - map::const_iterator bmit = _basicLayersBrush.find(basiclayer); - if (bmit != _basicLayersBrush.end()) { - return bmit->second; - } - return defaultBrush; -} - -const QPoint -CellWidget::getBrushOrigin() -{ - return (_painter) ? _painter->brushOrigin() : QPainter(this).brushOrigin(); -} - - - -// ************************************************************************************************* -// CellWidget::hasRecord() -// ************************************************************************************************* - -bool -CellWidget::hasRecord() const -{ - return true; -} - - - -// ************************************************************************************************* -// CellWidget::setTrackBox() -// ************************************************************************************************* - -//void -//CellWidget::setTrackBox(TrackBox* trackBox) -//{ -// if (trackBox != _trackBox) { -// if (_trackBox) { -// _trackBox->_setCellWidget(NULL); -// } -// _trackBox = trackBox; -// if (_trackBox) { -// _trackBox->_setCellWidget(this); -// } -// } -//} -// - - -// ************************************************************************************************* -// CellWidget::allowAutomaticScrolling() -// ************************************************************************************************* - -bool -CellWidget::allowAutomaticScrolling() const -{ - return true; -} - - - -// ************************************************************************************************* -// CellWidget::isVisible() -// CellWidget::isDrawable() -// ************************************************************************************************* - -bool -CellWidget::isVisible(BasicLayer* layer) const -{ - if (!layer) { - //throw Error(NULL_LAYER, __FILE__, __LINE__); - } - - return (_visibleLayerMask & layer->getMask()); -} - -bool -CellWidget::isDrawable(BasicLayer* layer) const -{ - if (!layer) { - //throw Error(NULL_LAYER, __FILE__, __LINE__); - } - - return (layer->getDisplayThreshold() <= _scale); -} - - - -// ************************************************************************************************* -// CellWidget::isOnGridX() -// CellWidget::isOnGridY() -// CellWidget::isOnGridPoint() -// ************************************************************************************************* - -bool -CellWidget::isOnGridX(const Unit& x, - unsigned n) const -{ - if (!n) { - //throw Error(INVALID_REQUEST, __FILE__, __LINE__); - } - - Unit delta = labs(x - _gridOrigin.getX()); - - if (delta < 0) { - delta = -delta; - } - - Unit step = _gridXStep * n; - - return (delta == ((delta / step) * step)); -} - -bool -CellWidget::isOnGridY(const Unit& y, - unsigned n) const -{ - if (!n) { - //throw Error(INVALID_REQUEST, __FILE__, __LINE__); - } - - Unit delta = labs(y - _gridOrigin.getY()); - - if (delta < 0) { - delta = -delta; - } - - Unit step = _gridYStep * n; - - return (delta == ((delta / step) * step)); -} - -bool -CellWidget::isOnGridPoint(const Point& point, - unsigned xN, - unsigned yN) const -{ - return isOnGridX(point.getX(), xN) && isOnGridY(point.getX(), yN); -} - - - -// ************************************************************************************************* -// CellWidget::isSelected() -// CellWidget::isSelectable() -// CellWidget::isHighlighted() -// CellWidget::isHighlightable() -// ************************************************************************************************* - -//bool -//CellWidget::isSelected(const Occurrence& occurrence) const -//{ -// Selector* selector = -// dynamic_cast(occurrence.getProperty(Selector::getPropertyName())); -// -// return (selector) ? selector->_contains((CellWidget*)this) : false; -//} -// -//bool -//CellWidget::isSelectable(const Occurrence& occurrence) const -//{ -// return occurrence.isSelectable() && (occurrence.getView() == getView()); -//} -// -//bool -//CellWidget::isHighlighted(const Occurrence& occurrence) const -//{ -// Highlightor* highlightor = -// dynamic_cast(occurrence.getProperty(Highlightor::getPropertyName())); -// -// return (highlightor) ? highlightor->_contains((CellWidget*)this) : false; -//} -// -//bool -//CellWidget::isHighlightable(const Occurrence& occurrence) const -//{ -// return occurrence.isHighlightable() && (occurrence.getView() == getView()); -//} - - - -// ************************************************************************************************* -// CellWidget::setBackgroundColor() -// CellWidget::setForegroundColor() -// ************************************************************************************************* - -void -CellWidget::setBackgroundColor(const QColor& color) -{ - if (color != _backgroundColor) { - _backgroundColor = color; - invalidate(); - } -} - -void -CellWidget::setForegroundColor(const QColor& color) -{ - if (color != _foregroundColor) { - _foregroundColor = color; - invalidate(); - } -} - - - -// ************************************************************************************************* -// CellWidget::setVisible() -// ************************************************************************************************* - -void -CellWidget::setVisible(BasicLayer* layer, - bool visible) -{ - if (isVisible(layer) != visible) { - if (visible) { - _visibleLayerMask |= layer->getMask(); - } - else { - _visibleLayerMask &= ~layer->getMask(); - } - - onSetVisible(layer, visible); - - Cell* cell = getCell(); - - //if (view && !view->getSlices(layer).isEmpty() && isDrawable(layer)) { - // invalidate(); - //} - - if (cell && !cell->getSlices(layer->getMask()).IsEmpty() && isDrawable(layer)) { - invalidate(); - } - } -} - - - -// ************************************************************************************************* -// CellWidget::setGridOrigin() -// CellWidget::setGridXStep() -// CellWidget::setGridYStep() -// CellWidget::setGridStep() -// CellWidget::setGridSteps() -// CellWidget::setGridDisplayThreshold() -// CellWidget::setGridColor() -// ************************************************************************************************* - -void -CellWidget::setGridOrigin(const Point& origin) -{ - if (origin != _gridOrigin) { - bool gridIsDrawn = gridIsVisible() && gridIsDrawable(); - - _gridOrigin = origin; - - if (gridIsDrawn || (gridIsVisible() && gridIsDrawable())) { - invalidate(); - } - } -} - -void -CellWidget::setGridXStep(const Unit& step) -{ - if (!step) { - //throw Error(INVALID_REQUEST, __FILE__, __LINE__); - } - - if (step != _gridXStep) { - bool gridIsDrawn = gridIsVisible() && gridIsDrawable(); - - _gridXStep = step; - - if (gridIsDrawn || (gridIsVisible() && gridIsDrawable())) { - invalidate(); - } - } -} - -void -CellWidget::setGridYStep(const Unit& step) -{ - if (!step) { - //throw Error(INVALID_REQUEST, __FILE__, __LINE__); - } - - if (step != _gridYStep) { - bool gridIsDrawn = gridIsVisible() && gridIsDrawable(); - - _gridYStep = step; - - if (gridIsDrawn || (gridIsVisible() && gridIsDrawable())) { - invalidate(); - } - } -} - -void -CellWidget::setGridStep(const Unit& step) -{ - if (!step) { - //throw Error(INVALID_REQUEST, __FILE__, __LINE__); - } - - if ((step != _gridXStep) || (step != _gridYStep)) { - bool gridIsDrawn = gridIsVisible() && gridIsDrawable(); - - _gridXStep = step; - _gridYStep = step; - - if (gridIsDrawn || (gridIsVisible() && gridIsDrawable())) { - invalidate(); - } - } -} - -void -CellWidget::setGridSteps(const Unit& xStep, - const Unit& yStep) -{ - if (!xStep || !yStep) { - //throw Error(INVALID_REQUEST, __FILE__, __LINE__); - } - - if ((xStep != _gridXStep) || (yStep != _gridYStep)) { - bool gridIsDrawn = gridIsVisible() && gridIsDrawable(); - - _gridXStep = xStep; - _gridYStep = yStep; - - if (gridIsDrawn || (gridIsVisible() && gridIsDrawable())) { - invalidate(); - } - } -} - -void -CellWidget::setGridDisplayThreshold(unsigned threshold) -{ - if (threshold < 3) { - //throw Error(INVALID_REQUEST, __FILE__, __LINE__); - } - - _gridDisplayThreshold = threshold; - - invalidate(); -} - -void -CellWidget::setGridColor(const QColor& color) -{ - if (_gridColor != color) { - _gridColor = color; - if (gridIsVisible() && gridIsDrawable()) { - invalidate(); - } - } -} - - - -// ************************************************************************************************* -// CellWidget::setGridVisible() -// CellWidget::setGridAxesVisible() -// CellWidget::setSnapGrid() -// ************************************************************************************************* - -void -CellWidget::setGridVisible(bool visible) -{ - if (_gridIsVisible != visible) { - _gridIsVisible = visible; - if (gridIsDrawable()) { - invalidate(); - } - } -} - -void -CellWidget::setGridAxesVisible(bool visible) -{ - if (_gridAxesAreVisible != visible) { - _gridAxesAreVisible = visible; - if (gridIsDrawable()) { - invalidate(); - } - } -} - -void -CellWidget::setSnapGrid(bool enable) -{ - if (_snapGrid != enable) { - if (_snapGrid && _drawSnapPoint) { - drawSnapPoint(); - _drawSnapPoint = false; - } - _snapGrid = enable; - if (_snapGrid && !_drawSnapPoint) { - _drawSnapPoint = true; - drawSnapPoint(); - } - } -} - - - -// ************************************************************************************************* -// CellWidget::setDisplayDepth() -// CellWidget::setDisplayDepth() -// ************************************************************************************************* - -void -CellWidget::setDisplayDepth(unsigned displayDepth) -{ - if (displayDepth != _displayDepth) { - _displayDepth = displayDepth; - invalidate(); - } -} - -void -CellWidget::setDisplaySize(unsigned displaySize) -{ - if (displaySize != _displaySize) { - _displaySize = displaySize; - } -} - - - -// ************************************************************************************************* -// CellWidget::setFont() -// CellWidget::setPen() -// CellWidget::setBrush() -// CellWidget::setBrushOrigin() -// ************************************************************************************************* - -void -CellWidget::setFont(const QFont& font) -{ - if (_painter) { - _painter->setFont(font); - } -} - -void -CellWidget::setPen(const QPen& pen, - double brightness) -{ - if (!((0.1 <= brightness) && (brightness <= 1.0))) { - //throw Error(INVALID_REQUEST, __FILE__, __LINE__); - } - - if (_painter) { - if (pen == Qt::NoPen) { - _painter->setPen(pen); - } - else { - QPen correctedPen = pen; - - if (brightness < 1) { - QColor bgColor = getBackgroundColor(); - int r = bgColor.red(); - int g = bgColor.green(); - int b = bgColor.blue(); - - QColor color = pen.color(); - r = r + (int)((color.red() - r) * brightness); - g = g + (int)((color.green() - g) * brightness); - b = b + (int)((color.blue() - b) * brightness); - - correctedPen = QPen(QColor(r, g, b)); - } - - _painter->setPen(correctedPen); - } - } -} - -void -CellWidget::setBrush(const QBrush& brush, - double brightness) -{ - if (!((0.1 <= brightness) && (brightness <= 1.0))) { - //throw Error(INVALID_REQUEST, __FILE__, __LINE__); - } - - if (_painter) { - if (brush == Qt::NoBrush) { - _painter->setBrush(brush); - } - else { - QBrush correctedBrush = brush; - - if (brightness < 1) { - QColor bgColor = getBackgroundColor(); - int r = bgColor.red(); - int g = bgColor.green(); - int b = bgColor.blue(); - - QColor color = brush.color(); - r = r + (int)((color.red() - r) * brightness); - g = g + (int)((color.green() - g) * brightness); - b = b + (int)((color.blue() - b) * brightness); - - correctedBrush = QBrush(QColor(r, g, b), brush.style()); - } - - _painter->setBrush(correctedBrush); - } - } -} - -void -CellWidget::setBrushOrigin(const QPoint& origin) -{ - if (_painter) { - _painter->setBrushOrigin(_brushDx + origin.x(), _brushDy + origin.y()); - } -} - - - -// ************************************************************************************************* -// CellWidget::setSelectionColor() -// CellWidget::setSelectionVisible() -// CellWidget::setHighlightionVisible() -// ************************************************************************************************* - -//void -//CellWidget::setSelectionColor(const QColor& color) -//{ -// if (color != _selectionColor) { -// _selectionColor = color; -// if (selectionIsVisible()) { -// invalidate(getSelectionBox()); -// } -// } -//} -// -//void -//CellWidget::setSelectionVisible(bool visible) -//{ -// if (_selectionIsVisible != visible) { -// _selectionIsVisible = visible; -// invalidate(getSelectionBox()); -// } -//} -// -//void -//CellWidget::setHighlightionVisible(bool visible) -//{ -// if (_highlightionIsVisible != visible) { -// _highlightionIsVisible = visible; -// invalidate(getHighlightionBox()); -// } -//} -// - - -// ************************************************************************************************* -// CellWidget::setAutomaticScrolling() -// ************************************************************************************************* - -void -CellWidget::setAutomaticScrolling(bool enable) -{ - if (!allowAutomaticScrolling()) { - //throw Error(INVALID_REQUEST, __FILE__, __LINE__); - } - - _automaticScrolling = enable; -} - - - -// ************************************************************************************************* -// CellWidget::showAllLayers() -// CellWidget::hideAllLayers() -// ************************************************************************************************* - -void -CellWidget::showAllLayers() -{ - DataBase* database = getDataBase(); - if (database) { - Technology* technology = database->getTechnology(); - if (technology) { - for_each_basic_layer(layer, technology->getBasicLayers()) { - setVisible(layer, true); + for_each_basic_layer ( layer, technology->getBasicLayers() ) { + _screenLayers.push_back ( new ScreenLayer(layer,_screenLayers.size(),true) ); end_for; - } - } + } } + } + +//_mapView = new MapView ( this ); + _layersList = new LayersList ( this ); + + _styles [ "Alliance" ] = DisplayStyle (); + _activeStyle = &_styles [ "Alliance" ]; + + fitToContents (); + _openCell = false; } -void -CellWidget::hideAllLayers() + +CellWidget::~CellWidget () { - DataBase* database = getDataBase(); - if (database) { - Technology* technology = database->getTechnology(); - if (technology) { - for_each_basic_layer(layer, technology->getBasicLayers()) { - setVisible(layer, false); + cerr << "CellWidget::~CellWidget()" << endl; + + for ( size_t i=0 ; i < _screenLayers.size() ; i++ ) + delete _screenLayers[i]; +} + + +void CellWidget::pushCursor ( Qt::CursorShape cursor ) +{ + setCursor ( cursor ); + _cursors.push_back ( cursor ); +} + + +void CellWidget::popCursor () +{ + _cursors.pop_back (); + if ( !_cursors.empty() ) + setCursor ( _cursors.back() ); + else + unsetCursor (); +} + + +QSize CellWidget::minimumSizeHint () const +{ + return QSize(_stripWidth*4,_stripWidth*4); +} + + +void CellWidget::redraw ( QRect redrawArea ) +{ +//cerr << "CellWidget::redraw ()" << endl; + + pushCursor ( Qt::BusyCursor ); + + _painter.begin ( &_drawingBuffer ); + + _painter.setPen ( Qt::NoPen ); + _painter.setBackground ( _activeStyle->getBrush("background") ); + _painter.setClipRect ( redrawArea ); + _painter.eraseRect ( redrawArea ); + + Box redrawBox = getBox ( redrawArea ); + +// cerr << " Box: " << redrawBox << endl; +// cerr << " Rect: " << redrawArea.x() << "," +// << redrawArea.y() << " " +// << redrawArea.width() << "x" +// << redrawArea.height() << endl; + + for ( size_t i=0 ; i<_screenLayers.size() ; i++ ) { + if ( isDrawable(_screenLayers[i]) ) { + _painter.setBrush ( _screenLayers[i]->getBrush() ); + drawCell ( _cell, _screenLayers[i]->getBasicLayer(), redrawBox, Transformation() ); + } + } + + if ( _showBoundaries ) { + _painter.setPen ( getPen ("boundaries") ); + _painter.setBrush ( getBrush("boundaries") ); + drawBoundaries ( _cell, redrawBox, Transformation() ); + } + + _painter.end (); + + update (); + popCursor (); + +// cerr << "*******************************************************" << endl; +} + + +void CellWidget::addStyle ( const string& key, DisplayStyle& displayStyle ) +{ + if ( _styles.find(key) != _styles.end() ) + cerr << "[WARNING] CellWidget::addStyle(): overriding style \"" << key << "\"." << endl; + + _styles [ key ] = displayStyle; + _activeStyle = & _styles [ key ]; +} + + +void CellWidget::setStyle ( const string& key ) +{ + if ( _styles.find(key) == _styles.end() ) { + cerr << "[WARNING] CellWidget::setStyle(): no style named \"" << key << "\"." << endl; + return; + } + + _activeStyle = & _styles [ key ]; +} + + +void CellWidget::drawBoundaries ( const Cell* cell + , const Box& redrawArea + , const Transformation& transformation + ) +{ +// cerr << "CellWidget::drawBoudaries ()" << endl; + +// QRect rect = getScreenRect(transformation.getBox(cell->getAbutmentBox())); + +// cerr << " Box: " << transformation.getBox(cell->getAbutmentBox()) << endl; +// cerr << " Rect: " << rect.x() << "+" << rect.y() +// << "," << rect.width() << "x" << rect.height() << endl; + + drawBox ( transformation.getBox(cell->getAbutmentBox()) ); + for_each_instance ( instance, cell->getInstances() ) { + drawBoundaries ( instance, redrawArea, transformation ); + end_for; + } +} + + +void CellWidget::drawBoundaries ( const Instance* instance + , const Box& redrawArea + , const Transformation& transformation + ) +{ + Box masterArea = redrawArea; + Transformation masterTransformation = instance->getTransformation(); + + instance->getTransformation().getInvert().applyOn ( masterArea ); + transformation.applyOn ( masterTransformation ); + + drawBoundaries ( instance->getMasterCell(), masterArea, masterTransformation ); +} + + +bool CellWidget::isDrawable ( const ScreenLayer* screenLayer ) +{ + return screenLayer->isVisible() + && ( screenLayer->getBasicLayer()->getDisplayThreshold() < _scale*100 ); +} + + +void CellWidget::drawCell ( const Cell* cell + , const BasicLayer* basicLayer + , const Box& redrawArea + , const Transformation& transformation + ) +{ + for_each_instance ( instance, cell->getInstancesUnder(redrawArea) ) { + drawInstance ( instance, basicLayer, redrawArea, transformation ); + end_for; + } + + for_each_slice ( slice, cell->getSlices() ) { + drawSlice ( slice, basicLayer, redrawArea, transformation ); + end_for; + } +} + + +void CellWidget::drawInstance ( const Instance* instance + , const BasicLayer* basicLayer + , const Box& redrawArea + , const Transformation& transformation + ) +{ + Box masterArea = redrawArea; + Transformation masterTransformation = instance->getTransformation(); + + instance->getTransformation().getInvert().applyOn ( masterArea ); + transformation.applyOn ( masterTransformation ); + + drawCell ( instance->getMasterCell(), basicLayer, masterArea, masterTransformation ); +} + + +void CellWidget::drawSlice ( const Slice* slice + , const BasicLayer* basicLayer + , const Box& redrawArea + , const Transformation& transformation + ) +{ + if ( slice->getLayer()->contains(basicLayer) ) { + if ( slice->getBoundingBox().intersect(redrawArea) ) { + for_each_go ( go, slice->getGosUnder(redrawArea) ) { + drawGo ( go, basicLayer, redrawArea, transformation ); end_for; - } - } + } } + } } - -// ************************************************************************************************* -// CellWidget::select() -// CellWidget::unselect() -// CellWidget::clearSelection() -// ************************************************************************************************* - -//bool -//CellWidget::select(const Occurrence& occurrence) -//{ -// if (!isSelectable(occurrence)) { -// throw Error(INVALID_REQUEST, __FILE__, __LINE__); -// } -// -// if (_selectionLimit && (_selectionLimit <= getSelectors().getCount())) { -// return false; -// } -// -// Property* property = occurrence.getProperty(Selector::getPropertyName()); -// -// Selector* selector = NULL; -// -// if (!property) { -// selector = new Selector(occurrence); -// } -// else { -// if (!dynamic_cast(property)) { -// throw Error(BAD_PROPERTY_TYPE, __FILE__, __LINE__); -// } -// selector = (Selector*)property; -// } -// -// selector->_attachTo(this); -// -// invalidate(occurrence.getBoundingBox()); -// -// return true; -//} - -//void -//CellWidget::unselect(const Occurrence& occurrence) -//{ -// if (!isSelectable(occurrence)) { -// throw Error(INVALID_REQUEST, __FILE__, __LINE__); -// } -// -// Property* property = occurrence.getProperty(Selector::getPropertyName()); -// -// if (property) { -// if (!dynamic_cast(property)) { -// throw Error(BAD_PROPERTY_TYPE, __FILE__, __LINE__); -// } -// -// ((Selector*)property)->_detachFrom(this); -// -// invalidate(occurrence.getBoundingBox()); -// } -//} -// -//void -//CellWidget::clearSelection() -//{ -// Occurrences selection = getSelection(); -// -// bool _cumulativeMode = false; // HOOPS !!! -// if (_cumulativeMode) { -// invalidate(getSelectionBox()); -// } -// -// while (!selection.isEmpty()) { -// unselect(selection.getFirst()); -// } -//} -// -// -// -//// ************************************************************************************************* -//// CellWidget::highlight() -//// CellWidget::unhighlight() -//// CellWidget::clearHighlightion() -//// ************************************************************************************************* -// -//bool -//CellWidget::highlight(const Occurrence& occurrence) -//{ -// if (!isHighlightable(occurrence)) { -// throw Error(INVALID_REQUEST, __FILE__, __LINE__); -// } -// -// unsigned count = getHighlightors().getCount(); -// -// if (_highlightionLimit && (_highlightionLimit <= count)) { -// return false; -// } -// -// Property* property = occurrence.getProperty(Highlightor::getPropertyName()); -// -// Highlightor* highlightor = NULL; -// -// if (!property) { -// highlightor = new Highlightor(occurrence); -// } -// else { -// if (!dynamic_cast(property)) { -// throw Error(BAD_PROPERTY_TYPE, __FILE__, __LINE__); -// } -// highlightor = (Highlightor*)property; -// } -// -// highlightor->_attachTo(this); -// -// if (!count) { -// invalidate(); -// } -// else { -// invalidate(occurrence.getBoundingBox()); -// } -// -// return true; -//} -// -//void -//CellWidget::unhighlight(const Occurrence& occurrence) -//{ -// if (!isHighlightable(occurrence)) { -// throw Error(INVALID_REQUEST, __FILE__, __LINE__); -// } -// -// Property* property = occurrence.getProperty(Highlightor::getPropertyName()); -// -// if (property) { -// if (!dynamic_cast(property)) { -// throw Error(BAD_PROPERTY_TYPE, __FILE__, __LINE__); -// } -// -// ((Highlightor*)property)->_detachFrom(this); -// -// if (getHighlightors().isEmpty()) { -// invalidate(); -// } -// else { -// invalidate(occurrence.getBoundingBox()); -// } -// } -//} -// -//void -//CellWidget::clearHighlightion() -//{ -// Occurrences highlightion = getHighlightion(); -// -// bool _cumulativeMode = false; // HOOPS !!! -// if (_cumulativeMode) { -// invalidate(getHighlightionBox()); -// } -// -// while (!highlightion.isEmpty()) { -// unhighlight(highlightion.getFirst()); -// } -//} -// -// - -// ************************************************************************************************* -// CellWidget::clearPeeks() -// CellWidget::addPeek() -// ************************************************************************************************* - -void -CellWidget::clearPeeks() +void CellWidget::drawGo ( const Go* go + , const BasicLayer* basicLayer + , const Box& redrawArea + , const Transformation& transformation + ) { - for (list::iterator plit = _peekList.begin(); - plit != _peekList.end(); - ++plit) { - invalidate(*plit); - } -// for_each_box(peek, getCollection(_peekList)) { -// invalidate(peek); -// end_for; -// } -// - _peekList.clear(); + const Segment* segment = dynamic_cast(go); + if (segment) { + drawSegment ( segment, basicLayer, redrawArea, transformation ); + return; + } + + const Contact* contact = dynamic_cast(go); + if (contact) { + drawContact ( contact, basicLayer, redrawArea, transformation ); + return; + } } -void -CellWidget::addPeek(const Box& peek) + +void CellWidget::drawSegment ( const Segment* segment + , const BasicLayer* basicLayer + , const Box& redrawArea + , const Transformation& transformation + ) { - if (!peek.isEmpty()) { - invalidate(peek); - _peekList.push_back(peek); - } + if ( 1 < getScreenLength(segment->getWidth()) ) { + drawBox ( transformation.getBox(segment->getBoundingBox(basicLayer)) ); + } else { + drawLine ( transformation.getPoint(segment->getSourcePosition()), + transformation.getPoint(segment->getTargetPosition()) ); + } } - -// ************************************************************************************************* -// CellWidget::invalidate() -// ************************************************************************************************* - -void -CellWidget::invalidate() +void CellWidget::drawContact ( const Contact* contact + , const BasicLayer* basicLayer + , const Box& redrawArea + , const Transformation& transformation + ) { - _invalidRegion = QRegion(rect()); + drawBox ( transformation.getBox(contact->getBoundingBox(basicLayer)) ); } -void -CellWidget::invalidate(const QRect& screenRect) + +void CellWidget::drawBox ( const Box& box ) { - QRect visibleScreenRect = screenRect.intersect(rect()); - - if (!visibleScreenRect.isEmpty()) { - bool _cumulativeMode = false; // HOOPS !!! - if (!_cumulativeMode) { - _invalidRegion = _invalidRegion.unite(QRegion(visibleScreenRect)); - } - else { - _invalidRegion = QRegion(_invalidRegion.boundingRect().unite(visibleScreenRect)); - } - } + _painter.drawRect ( getScreenRect(box) ); } -void -CellWidget::invalidate(const Box& box) + +void CellWidget::drawLine ( const Point& p1, const Point& p2 ) { - if (!box.isEmpty()) { - int safetyMargin = 2; // 2 pixel - invalidate(getScreenRect(box.getInflated(getSize(safetyMargin)))); - } + _painter.drawLine ( getScreenPoint(p1), getScreenPoint(p2) ); } -void -CellWidget::fitToContent(unsigned screenMargin) { - Box area(getX(0), getY(0), getX(width()), getY(height())); - if (_cell) { - area = _cell->getBoundingBox(); - } - reframe(area); - area.inflate(screenMargin); - reframe(area); -} - - - - -// ************************************************************************************************* -// CellWidget::reframe() -// ************************************************************************************************* - -void -CellWidget::reframe() +void CellWidget::goLeft ( int dx ) { - reframe(_center, _scale); + if ( !dx ) dx = geometry().size().width() / 4; + if ( _offsetVA.rx() - dx >= 0 ) { + _offsetVA.rx() -= dx; + update (); + } else { + shiftLeft ( dx ); + } } -void -CellWidget::reframe(double scale) + +void CellWidget::goRight ( int dx ) { - reframe(_center, scale); + if ( !dx ) dx = geometry().size().width() / 4; + +//cerr << "CellWidget::goRight() - dx: " << dx << " (offset: " << _offsetVA.rx() << ")" << endl; + + if ( _offsetVA.rx() + dx < 2*_stripWidth ) { + _offsetVA.rx() += dx; + update (); + } else { + shiftRight ( dx ); + } } -void -CellWidget::reframe(const Point& center) + +void CellWidget::goUp ( int dy ) { - reframe(center, _scale); + if ( !dy ) dy = geometry().size().height() / 4; + if ( _offsetVA.ry() - dy >= 0 ) { + _offsetVA.ry() -= dy; + update (); + } else { + shiftUp ( dy ); + } } -void -CellWidget::reframe(const Point& center, - double scale) + +void CellWidget::goDown ( int dy ) { - if (0 < scale) { - _center = center; - _scale = scale; - _screenDx = -(int)rint((getValue(_center.getX()) - (width() / (_scale*2))) * _scale); - _screenDy = -(int)rint((getValue(_center.getY()) - (height() / (_scale*2))) * _scale); - _brushDx = 0; - _brushDy = 0; - invalidate(); - } + if ( !dy ) dy = geometry().size().height() / 4; + if ( _offsetVA.ry() + dy < 2*_stripWidth ) { + _offsetVA.ry() += dy; + update (); + } else { + shiftDown ( dy ); + } } -void -CellWidget::reframe(const Box& box) + +void CellWidget::screenReframe () { - if (!box.isEmpty()) { - Point center = box.getCenter(); + _offsetVA.rx() = _stripWidth; + _offsetVA.ry() = _stripWidth; - double scale = min((double)width() / getValue(box.getWidth()), - (double)height() / getValue(box.getHeight())); + Unit xmin = (Unit)( _visibleArea.getXMin() - ((float)_offsetVA.x()/_scale) ); + Unit xmax = (Unit)( xmin + ((float)_drawingBuffer.width()/_scale) ) ; + Unit ymax = (Unit)( _visibleArea.getYMax() + ((float)_offsetVA.y()/_scale) ); + Unit ymin = (Unit)( ymax - ((float)_drawingBuffer.height()/_scale) ) ; + + _displayArea = Box ( xmin, ymin, xmax, ymax ); - reframe(center, scale); - } + redraw (); } - -// ************************************************************************************************* -// CellWidget::scroll() -// ************************************************************************************************* - -void -CellWidget::scroll(const Unit& dx, - const Unit& dy) +void CellWidget::setScale ( float scale ) { - if ((getSize(width()) < labs(dx)) || (getSize(height()) < labs(dy))) { - reframe(getCenter().getTranslated(-dx, -dy)); - redraw(); - } else { - int sdx = getScreenSize(dx); - int sdy = getScreenSize(dy); + _scale = scale; - if (sdx || sdy) { - QCursor oldCursor = cursor(); - setCursor(Qt::WaitCursor); + Point center = _visibleArea.getCenter(); - if (_snapGrid) { - drawSnapPoint(); - } + _visibleArea.makeEmpty (); + _visibleArea.merge ( (Unit)( center.getX() - width () / (_scale*2) ) + , (Unit)( center.getY() - height() / (_scale*2) ) + , (Unit)( center.getX() + width () / (_scale*2) ) + , (Unit)( center.getY() + height() / (_scale*2) ) + ); - //forEachCommand(command, getCommands()) { - // _callDrawOf(command); - // endFor; - //} +//cerr << "_visibleArea: " << _visibleArea << " (offset: " << _offsetVA.x() << ")" << endl; +//cerr << " " << center << endl; - _screenDx += sdx; - _screenDy += sdy; - - _brushDx += sdx; - _brushDy -= sdy; - - _center = getPoint(QPoint(width() / 2, height() / 2)); - - int w = width(); - int h = height(); - - if (0 < sdx) { - if (0 < sdy) { - //bitBlt(this, sdx, 0, this, 0, sdy, w - sdx, h - sdy); - invalidate(QRect(-1, -1, sdx + 1, h + 1)); - //_redraw(); - invalidate(QRect(sdx - 1, h - sdy - 1, w + 1, h + 1)); - //_redraw(); - update(); - } else { - //bitBlt(this, sdx, -sdy, this, 0, 0, w - sdx, h + sdy, CopyROP); - invalidate(QRect(-1, -1, sdx + 1, h + 1)); - //_redraw(); - invalidate(QRect(sdx - 1, -1, w + 1, -sdy + 1)); - //_redraw(); - update(); - } - } - else { - if (0 < sdy) { - //bitBlt(this, 0, 0, this, -sdx, sdy, w + sdx, h - sdy, CopyROP); - invalidate(QRect(w + sdx - 1, -1, w + 1, h + 1)); - // _redraw(); - invalidate(QRect(-1, h - sdy - 1, w + sdx + 1, h + 1)); - //_redraw(); - update(); - } - else { - //bitBlt(this, 0, -sdy, this, -sdx, 0, w + sdx, h + sdy); - invalidate(QRect(w + sdx - 1, -1, w + 1, h + 1)); - //_redraw(); - invalidate(QRect(-1, -1, w + sdx + 1, -sdy + 1)); - //_redraw(); - update(); - } - } - - //forEachCommand(command, reverse(getCommands())) { - // _callDrawOf(command); - // endFor; - //} - - if (_snapGrid) { - drawSnapPoint(); - } - - setCursor(oldCursor); - } - } + screenReframe (); } - -// ************************************************************************************************* -// CellWidget::redraw() -// ************************************************************************************************* - -void -CellWidget::redraw() +void CellWidget::reframe ( const Box& box ) { - if (!_invalidRegion.isEmpty()) { - QCursor oldCursor = cursor(); - setCursor(Qt::WaitCursor); +//cerr << "CellWidget::reframe() - " << box << endl; +//cerr << " widget size := " << _drawingBuffer.width() << "x" << _drawingBuffer.height() << endl; + + int width = this->width (); + int height = this->height (); - if (_snapGrid) { - drawSnapPoint(); - } + float scaleX = width / (float)box.getWidth (); + float scaleY = height / (float)box.getHeight(); + _scale = min ( scaleX, scaleY ); - //forEachCommand(command, getCommands()) { - // _callDrawOf(command); - // endFor; - //} +//cerr << " _scale := " << _scale << endl; - if (!_alreadyExposed) { - fitToContent(); - _alreadyExposed = true; - } + Point center = box.getCenter(); - _redraw(); + width /= 2; + height /= 2; - //forEachCommand(command, reverse(getCommands())) { - // _callDrawOf(command); - // endFor; - //} + _visibleArea = Box ( (Unit)( center.getX() - width / _scale ) + , (Unit)( center.getY() - height / _scale ) + , (Unit)( center.getX() + width / _scale ) + , (Unit)( center.getY() + height / _scale ) + ); + screenReframe (); - if (_snapGrid) { - drawSnapPoint(); - } - - setCursor(oldCursor); - - _invalidRegion = QRegion(); - } +//cerr << " _displayArea: " << _displayArea << " (offset: " << _offsetVA.x() << ")" << endl; } - -// ************************************************************************************************* -// CellWidget::abortStartedCommand() -// ************************************************************************************************* - -//void -//CellWidget::abortStartedCommand() -//{ -// if (_startedCommand) { -// _startedCommand->abortOn(this); -// } -// -// if (_trackBox) { -// _trackBox->stop(_snapPoint); -// } -//} - - - -// ************************************************************************************************* -// CellWidget::preRedraw() -// CellWidget::postRedraw() -// ************************************************************************************************* - -void -CellWidget::preRedraw(const Box& area) +void CellWidget::fitToContents () { + reframe ( _cell->getBoundingBox() ); } -void -CellWidget::postRedraw(const Box& area) + +void CellWidget::shiftLeft ( int dx ) { +//cerr << "CellWidget::shiftLeft() - " << dx << " (offset: " << _offsetVA.rx() << ")" << endl; + + int leftShift = ( 1 + ( dx - _offsetVA.rx() ) / _stripWidth ) * _stripWidth; + + _displayArea.translate ( - (Unit)( leftShift / _scale ) , 0 ); + _visibleArea.translate ( - (Unit)( leftShift / _scale ) , 0 ); + _offsetVA.rx() -= dx - leftShift; + + if ( leftShift >= _drawingBuffer.width() ) { + redraw (); + } else { + //cerr << "Left Shift " << leftShift << " (offset: " << _offsetVA.rx() << ")" << endl; + _painter.begin ( &_drawingBuffer ); + _painter.drawPixmap ( leftShift, 0 + , _drawingBuffer + , 0, 0 + , _drawingBuffer.width()-leftShift, _drawingBuffer.height() + ); + _painter.end (); + + redraw ( QRect ( QPoint ( 0, 0 ) + , QSize ( leftShift, _drawingBuffer.height() )) ); + } + + assert ( _offsetVA.rx() >= 0 ); } -void CellWidget::drawContent(const Cell* cell, const BasicLayer* basicLayer, const Hurricane::Box& updateArea, const Transformation& transformation) const { - for_each_instance(instance, cell->getInstancesUnder(updateArea)) { - drawContent(instance, basicLayer, updateArea, transformation); - end_for; - } - - for_each_slice(slice, cell->getSlices()) { - drawSlice(slice, basicLayer, updateArea, transformation); - end_for; - } -} - - -void CellWidget::drawContent(const Instance* instance, const BasicLayer* basicLayer, const Hurricane::Box& updateArea, const Transformation& transformation) const { - Box masterArea = updateArea; - Transformation masterTransformation = instance->getTransformation(); - instance->getTransformation().getInvert().applyOn(masterArea); - transformation.applyOn(masterTransformation); - drawContent(instance->getMasterCell(), basicLayer, masterArea, masterTransformation); -} - - -void CellWidget::drawSlice(const Slice* slice, const BasicLayer* basicLayer, const Hurricane::Box& updateArea, const Transformation& transformation) const { - if (slice->getLayer()->contains(basicLayer)) { - if (slice->getBoundingBox().intersect(updateArea)) { - //if ((basicLayer == _layer->_getSymbolicBasicLayer()) || (3 < view->getScale())) - for_each_go(go, slice->getGosUnder(updateArea)) { - drawGo(go, basicLayer, updateArea, transformation); - end_for; - } - } - } -} - -void CellWidget::drawGo(const Go* go, const BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation) const { - const Segment* segment = dynamic_cast(go); - if (segment) { - drawSegment(segment, basicLayer, updateArea, transformation); - return; - } - const Contact* contact = dynamic_cast(go); - if (contact) { - drawContact(contact, basicLayer, updateArea, transformation); - return; - } -} - -void CellWidget::drawSegment(const Segment* segment, const BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation) const { - if (1 < getScreenSize(segment->getWidth())) { - drawRectangle(transformation.getBox(segment->getBoundingBox(basicLayer))); - } else { - drawLine(transformation.getPoint(segment->getSourcePosition()), - transformation.getPoint(segment->getTargetPosition())); - } -} - -void CellWidget::drawContact(const Contact* contact, const BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation) const { - drawRectangle(transformation.getBox(contact->getBoundingBox(basicLayer))); -} - -void CellWidget::drawPhantoms(const Cell* cell, const Hurricane::Box& updateArea, const Transformation& transformation) const { - for_each_instance(instance, cell->getInstancesUnder(updateArea)) { - drawPhantoms(instance, updateArea, transformation); - end_for; - } -} - -void CellWidget::drawPhantoms(const Instance* instance, const Hurricane::Box& updateArea, const Transformation& transformation) const { - Hurricane::Box masterArea = updateArea; - Transformation masterTransformation = instance->getTransformation(); - instance->getTransformation().getInvert().applyOn(masterArea); - transformation.applyOn(masterTransformation); - drawPhantoms(instance->getMasterCell(), masterArea, masterTransformation); -} - -void CellWidget::drawBoundaries(const Cell* cell, const Hurricane::Box& updateArea, const Transformation& transformation) const { - drawRectangle(transformation.getBox(cell->getAbutmentBox())); - for_each_instance(instance, cell->getInstances()) { - drawBoundaries(instance, updateArea, transformation); - end_for; - } -} - -void CellWidget::drawBoundaries(const Instance* instance, const Hurricane::Box& updateArea, const Transformation& transformation) const { - Hurricane::Box masterArea = updateArea; - Transformation masterTransformation = instance->getTransformation(); - instance->getTransformation().getInvert().applyOn(masterArea); - transformation.applyOn(masterTransformation); - drawBoundaries(instance->getMasterCell(), masterArea, masterTransformation); -} - - - -// ************************************************************************************************* -// CellWidget::drawLine() -// CellWidget::drawPolyline() -// CellWidget::drawRectangle() -// CellWidget::drawPolygon() -// CellWidget::drawText() -// ************************************************************************************************* - -void -CellWidget::drawLine(const Unit& xo, - const Unit& yo, - const Unit& xe, - const Unit& ye) const +void CellWidget::shiftRight ( int dx ) { - if (_painter) { - double dxo = getValue(xo); - double dyo = getValue(yo); - int co = getClipCode(dxo, dyo); - double dxe = getValue(xe); - double dye = getValue(ye); - int ce = getClipCode(dxe, dye); - if (clipLine(dxo, dyo, co, dxe, dye, ce)) { - int ixo = getScreenX(getUnit(dxo)); - int iyo = getScreenY(getUnit(dyo)); - int ixe = getScreenX(getUnit(dxe)); - int iye = getScreenY(getUnit(dye)); - _painter->save(); - if (_painter->pen() == Qt::NoPen) { - _painter->setPen(_painter->brush().color()); - } - _painter->drawLine(ixo, iyo, ixe, iye); - //_painter->moveTo(ixo, iyo); - //_painter->lineTo(ixe, iye); - _painter->restore(); - } - } +//cerr << "CellWidget::shiftRight() - " << dx << " (offset: " << _offsetVA.rx() << ")" << endl; + + int rightShift = ( ( _offsetVA.rx() + dx ) / _stripWidth ) * _stripWidth; + + _displayArea.translate ( (Unit)( rightShift / _scale ) , 0 ); + _visibleArea.translate ( (Unit)( rightShift / _scale ) , 0 ); + _offsetVA.rx() += dx - rightShift; + +//cerr << " _displayArea: " << _displayArea << endl; + + if ( rightShift >= _drawingBuffer.width() ) { + redraw (); + } else { + //cerr << " Right Shift " << rightShift << " (offset: " << _offsetVA.rx() << ")" << endl; + _painter.begin ( &_drawingBuffer ); + _painter.drawPixmap ( 0, 0 + , _drawingBuffer + , rightShift, 0 + , _drawingBuffer.width()-rightShift, _drawingBuffer.height() + ); + _painter.end (); + + redraw ( QRect ( QPoint ( _drawingBuffer.width()-rightShift, 0 ) + , QSize ( rightShift, _drawingBuffer.height() )) ); + } + + assert ( _offsetVA.rx() >= 0 ); } -//void -//CellWidget::drawPolyline(const Points& points) -//{ -// if (_painter) { -// unsigned sCount; -// -// if (clipLines(points, _sPoints, sCount, false)) { -// _painter->save(); -// if (_painter->pen() == NoPen) { -// _painter->setPen(_painter->brush().color()); -// } -// _painter->drawPolyline(_sPoints, 0, sCount); -// _painter->restore(); -// } -// } -//} -void -CellWidget::drawRectangle(const Box& box) const +void CellWidget::shiftUp ( int dy ) { - if (_painter) { - Box ibox = box.getIntersection(_clipBox); +//cerr << "CellWidget::shiftUp() - " << dy << " (offset: " << _offsetVA.ry() << ")" << endl; - if (!ibox.isEmpty()) { - int x = getScreenX(ibox.getXMin()); - int y = getScreenY(ibox.getYMax()); - int w = getScreenX(ibox.getXMax()) - x + 1; - int h = getScreenY(ibox.getYMin()) - y + 1; - _painter->drawRect(x, y, w, h); - } - } + int upShift = ( 1 + ( dy - _offsetVA.ry() ) / _stripWidth ) * _stripWidth; + + _displayArea.translate ( 0, (Unit)( upShift / _scale ) ); + _visibleArea.translate ( 0, (Unit)( upShift / _scale ) ); + _offsetVA.ry() -= dy - upShift; + + if ( upShift >= _drawingBuffer.height() ) { + redraw (); + } else { + //cerr << "Left Shift " << upShift << " (offset: " << _offsetVA.ry() << ")" << endl; + _painter.begin ( &_drawingBuffer ); + _painter.drawPixmap ( 0, upShift + , _drawingBuffer + , 0, 0 + , _drawingBuffer.width(), _drawingBuffer.height()-upShift + ); + _painter.end (); + + redraw ( QRect ( QPoint ( 0, 0 ) + , QSize ( _drawingBuffer.width(), upShift )) ); + } + + assert ( _offsetVA.ry() >= 0 ); } -//void -//CellWidget::drawPolygon(const Points& points) -//{ -// if (_painter) { -// unsigned sCount; -// -// if (clipLines(points, _sPoints, sCount, true)) { -// _painter->drawPolygon(_sPoints, true, 0, sCount); -// } -// } -//} -//void -//CellWidget::drawText(const Box& frame, -// const string& text, -// const Direction& direction) -//{ -// if (_painter && !frame.isEmpty()) { -// int x = getScreenX(frame.getXMin()); -// int y = getScreenY(frame.getYMax()); -// int w = getScreenX(frame.getXMax()) - x + 1; -// int h = getScreenY(frame.getYMin()) - y + 1; -// switch (direction) { -// case NORTH: { -// int ow = w; -// w = h; -// h = ow; -// int ox = x; -// x = - (y + w); -// y = ox; -// break; -// } -// /* -// case WEST: { -// x = - (x + w); -// y = - (y + h); -// break; -// } -// */ -// case SOUTH: { -// int ow = w; -// w = h; -// h = ow; -// int ox = x; -// x = y; -// y = - (ox + h); -// break; -// } -// } -// QFontMetrics metrics(_painter->font()); -// if ((metrics.width(text) <= w) && (metrics.height() <= h)) { -// _painter->save(); -// switch (direction) { -// case NORTH: _painter->rotate(-90); break; -// /* -// case WEST: _painter->rotate(180); break; -// */ -// case SOUTH: _painter->rotate(90); break; -// } -// if (_painter->pen() == NoPen) { -// _painter->setPen(_painter->brush().color()); -// } -// _painter->drawText(x, y, w, h, Qt::AlignCenter, text); -// _painter->restore(); -// } -// } -//} -// - - -// ************************************************************************************************* -// CellWidget::drawSnapPoint() -// ************************************************************************************************* - -void -CellWidget::drawSnapPoint() +void CellWidget::shiftDown ( int dy ) { - if (_drawSnapPoint) { - int sx = getScreenX(_snapPoint.getX()); - int sy = getScreenY(_snapPoint.getY()); +//cerr << "CellWidget::shiftDown() - " << dy << " (offset: " << _offsetVA.ry() << ")" << endl; - if (((-3 <= sx) && (sx <= (width() + 3))) && - ((-3 <= sy) && (sy <= (height() + 3)))) { - QPainter painter(this); - painter.setPen(getForegroundColor()); - painter.setBrush(Qt::NoBrush); - //painter.setRasterOp(Qt::XorROP); - painter.drawRect(sx - 3, sy - 3, 7, 7); - } - } + int downShift = ( ( _offsetVA.ry() + dy ) / _stripWidth ) * _stripWidth; + + _displayArea.translate ( 0, - (Unit)( downShift / _scale ) ); + _visibleArea.translate ( 0, - (Unit)( downShift / _scale ) ); + _offsetVA.ry() += dy - downShift; + + if ( downShift >= _drawingBuffer.height() ) { + redraw (); + } else { + //cerr << "Right Shift " << downShift << " (offset: " << _offsetVA.ry() << ")" << endl; + _painter.begin ( &_drawingBuffer ); + _painter.drawPixmap ( 0, 0 + , _drawingBuffer + , 0, downShift + , _drawingBuffer.width(), _drawingBuffer.height()-downShift + ); + _painter.end (); + + redraw ( QRect ( QPoint ( 0, _drawingBuffer.height()-downShift ) + , QSize ( _drawingBuffer.width(), downShift )) ); + } + + assert ( _offsetVA.ry() >= 0 ); } - -// ************************************************************************************************* -// CellWidget::resizeEvent() -// CellWidget::enterEvent() -// CellWidget::leaveEvent() -// CellWidget::mousePressEvent() -// CellWidget::mouseMoveEvent() -// CellWidget::mouseReleaseEvent() -// CellWidget::focusInEvent() -// CellWidget::focusOutEvent() -// CellWidget::paintEvent() -// ************************************************************************************************* - -void -CellWidget::resizeEvent(QResizeEvent* event) +void CellWidget::paintEvent ( QPaintEvent* ) { - reframe(); +//cerr << "CellWidget::paintEvent()" << endl; + + QPainter painter ( this ); + painter.drawPixmap ( 0, 0, _drawingBuffer, _offsetVA.rx(), _offsetVA.ry(), width(), height() ); } -//void -//CellWidget::enterEvent(QEvent* event) -//{ -// if (getView()) { -// forEachCommand(command, getCommands()) { -// command->onArm(this); -// endFor; -// } -// } -// -// if (_snapGrid) { -// _drawSnapPoint = true; -// drawSnapPoint(); -// } -//} -// -//void -//CellWidget::leaveEvent(QEvent* event) -//{ -// if (_snapGrid) { -// drawSnapPoint(); -// _drawSnapPoint = false; -// } -// -// if (getView()) { -// forEachCommand(command, getCommands()) { -// command->onDisarm(this); -// endFor; -// } -// } -//} -//void -//CellWidget::mousePressEvent(QMouseEvent* event) -//{ -// if (!_startedCommand) { -// Point position = getSnapPoint(event->x(), event->y()); -// if (getView()) { -// _startedCommand = getCommand(event->button()); -// -// if (_startedCommand) { -// _startedCommand->onStart(this, position, event->state()); -// } -// } -// if (_trackBox) { -// _trackBox->start(position); -// } -// } -//} -// -//void -//CellWidget::mouseMoveEvent(QMouseEvent* event) -//{ -// if (_startedCommand && automaticScrolling() && _startedCommand->automaticScrolling()) { -// int sx = event->x(); -// int sy = event->y(); -// Unit dx = 0; -// if (sx < 0) { -// dx = getUnit(width() / 40); -// } -// else { -// if (width() < sx) { -// dx = - getUnit(width() / 40); -// } -// } -// Unit dy = 0; -// if (sy < 0) { -// dy = - getUnit(height() / 40); -// } -// else { -// if (height() < sy) { -// dy = getUnit(height() / 40); -// } -// } -// if (dx || dy) { -// scroll(dx, dy); -// } -// } -// -// Point position = getSnapPoint(event->x(), event->y()); -// -// if (position != _snapPoint) { -// if (_snapGrid) { -// drawSnapPoint(); -// } -// _snapPoint = position; -// if (_snapGrid) { -// drawSnapPoint(); -// } -// if (getView()) { -// forEachCommand(command, getCommands()) { -// command->onTrack(this, position); -// endFor; -// } -// -// if (_startedCommand) { -// _startedCommand->onUpdate(this, position, event->state()); -// } -// } -// if (_trackBox) { -// _trackBox->update(position); -// } -// } -//} -// -//void -//CellWidget::mouseReleaseEvent(QMouseEvent* event) -//{ -// if (_startedCommand && (_startedCommand->getButton() == event->button())) { -// Point position = getSnapPoint(event->x(), event->y()); -// if (getView()) { -// _startedCommand->onStop(this, position); -// _startedCommand = NULL; -// } -// if (_trackBox) { -// _trackBox->stop(position); -// } -// } -//} -// -//void -//CellWidget::focusInEvent(QFocusEvent* event) -//{ -// // overriden to avoid repaint when the widget gains the focus -//} -// -//void -//CellWidget::focusOutEvent(QFocusEvent* event) -//{ -// // overriden to avoid repaint when the widget loose the focus -//} - -void -CellWidget::paintEvent(QPaintEvent* event) +void CellWidget::resizeEvent ( QResizeEvent* ) { - invalidate(event->rect()); + QSize uaDelta ( 0, 0 ); + QSize uaSize = geometry().size(); - redraw(); + uaSize.rwidth () += 2*_stripWidth; + uaSize.rheight() += 2*_stripWidth; + + if ( uaSize.width () > _drawingBuffer.width () ) + uaDelta.rwidth () = uaSize.width () - _drawingBuffer.width (); + + if ( uaSize.height() > _drawingBuffer.height() ) + uaDelta.rheight() = uaSize.height() - _drawingBuffer.height(); + +//cerr << "New UA widget size: " << uaSize.width() << "x" << uaSize.height() << endl; + + if ( uaDelta.width() || uaDelta.height() ) { + _displayArea.inflate ( 0, 0, (Unit)(uaDelta.width()/_scale), (Unit)(uaDelta.height()/_scale) ); + _visibleArea.inflate ( 0, 0, (Unit)(uaDelta.width()/_scale), (Unit)(uaDelta.height()/_scale) ); + //cerr << "new " << _displayArea << endl; + + //cerr << "Previous buffer size: " << _drawingBuffer.width () << "x" + // << _drawingBuffer.height() << endl; + + QSize bufferSize ( ( ( uaSize.width () / _stripWidth ) + 1 ) * _stripWidth + , ( ( uaSize.height() / _stripWidth ) + 1 ) * _stripWidth ); + _drawingBuffer = QPixmap ( bufferSize ); + + //cerr << "Effective buffer resize to: " << bufferSize.width() << "x" + // << bufferSize.height() << endl; + } + redraw (); } - -// ************************************************************************************************* -// CellWidget::onSetVisible() -// ************************************************************************************************* - -void -CellWidget::onSetVisible(Layer* layer, - bool visible) +void CellWidget::keyPressEvent ( QKeyEvent* event ) { + switch ( event->key() ) { + case Qt::Key_Up: goUp (); break; + case Qt::Key_Down: goDown (); break; + case Qt::Key_Left: goLeft (); break; + case Qt::Key_Right: goRight (); break; + case Qt::Key_Z: setScale ( _scale*2.0 ); break; + case Qt::Key_M: setScale ( _scale/2.0 ); break; + } } - -// ************************************************************************************************* -// CellWidget:getClipCode() -// ************************************************************************************************* - -int -CellWidget::getClipCode(double x, - double y) const +void CellWidget::mouseMoveEvent ( QMouseEvent* event ) { - if (x < _clipX[0]) { - if (y < _clipY[0]) { - return 28; - } - if (_clipY[3] < y) { - return 22; - } - return 4; - } +//cerr << "CellWidget::mouseMoveEvent()" << endl; - if (_clipX[3] < x) { - if (y < _clipY[0]) { - return 25; - } - if (_clipY[3] < y) { - return 19; - } - return 1; - } + if ( _mouseGo ) { + int dx = event->x() - _lastMousePosition.x(); + //cerr << "dX (px): " << dx << " _offsetVA.rx() " << _offsetVA.rx() << endl; + if ( dx > 0 ) goLeft ( dx ); + if ( dx < 0 ) goRight ( -dx ); - if (y < _clipY[0]) { - return 8; - } + int dy = event->y() - _lastMousePosition.y(); + //cerr << "dY (px): " << dy << " _offsetVA.ry() " << _offsetVA.ry() << endl; + if ( dy > 0 ) goUp ( dy ); + if ( dy < 0 ) goDown ( -dy ); - if (_clipY[3] < y) { - return 2; - } - - return 0; + _lastMousePosition = event->pos(); + } } - -// ************************************************************************************************* -// CellWidget::clipLine() -// CellWidget::clipLines() -// ************************************************************************************************* - -bool -CellWidget::clipLine(double& xo, - double& yo, - int co, - double& xe, - double& ye, - int ce, - int u) const +void CellWidget::mousePressEvent ( QMouseEvent* event ) { - if (co & ce & -17) { - return false; - } - - if (!co & !ce) { - return true; - } - - if (co & 1) { - yo += ((ye - yo) / (xe - xo)) * (_clipX[3] - xo); - xo = _clipX[3]; - co = getClipCode(xo, yo); - return clipLine(xo, yo, co, xe, ye, ce, u + 1); - } - - if (co & 2) { - xo += ((xe - xo) / (ye - yo)) * (_clipY[3] - yo); - yo = _clipY[3]; - co = getClipCode(xo, yo); - return clipLine(xo, yo, co, xe, ye, ce, u + 1); - } - - if (co & 4) { - yo += ((ye - yo) / (xe - xo)) * (_clipX[0] - xo); - xo = _clipX[0]; - co = getClipCode(xo, yo); - return clipLine(xo, yo, co, xe, ye, ce, u + 1); - } - - if (co & 8) { - xo += ((xe - xo) / (ye - yo)) * (_clipY[0] - yo); - yo = _clipY[0]; - co = getClipCode(xo, yo); - return clipLine(xo, yo, co, xe, ye, ce, u + 1); - } - - if (ce & 1) { - ye -= ((ye - yo) / (xe - xo)) * (xe - _clipX[3]); - xe = _clipX[3]; - ce = getClipCode(xe, ye); - return clipLine(xo, yo, co, xe, ye, ce, u + 1); - } - - if (ce & 2) { - xe -= ((xe - xo) / (ye - yo)) * (ye - _clipY[3]); - ye = _clipY[3]; - ce = getClipCode(xe, ye); - return clipLine(xo, yo, co, xe, ye, ce, u + 1); - } - - if (ce & 4) { - ye -= ((ye - yo) / (xe - xo)) * (xe - _clipX[0]); - xe = _clipX[0]; - ce = getClipCode(xe, ye); - return clipLine(xo, yo, co, xe, ye, ce, u + 1); - } - - if (ce & 8) { - xe -= ((xe - xo) / (ye - yo)) * (ye - _clipY[0]); - ye = _clipY[0]; - ce = getClipCode(xe, ye); - return clipLine(xo, yo, co, xe, ye, ce, u + 1); - } - - return true; + if ( ( event->button() == Qt::LeftButton ) && !_mouseGo ) { + _mouseGo = true; + _lastMousePosition = event->pos(); + pushCursor ( Qt::ClosedHandCursor ); + } } -//bool -//CellWidget::clipLines(const Points& points, -// QPointArray& sPoints, -// unsigned& sCount, -// bool closed) const -//{ -// sCount = 0; -// -// if (points.isEmpty()) { -// return false; -// } -// -// int co, ce; -// double xo, yo, xe, ye; -// bool firstPoint = true; -// -// forEachPoint(point, points) { -// xe = getValue(point.getX()); -// ye = getValue(point.getY()); -// ce = getClipCode(xe, ye); -// if (firstPoint) { -// if (!ce) { -// int sx = getScreenX(getUnit(xe)); -// int sy = getScreenY(getUnit(ye)); -// sPoints.putPoints(sCount++, 1, sx, sy); -// } -// firstPoint = false; -// } -// else { -// static int tcc[] = {0,-3,-6,1,3,0,1,0,6,1,0,0,1,0,0,0}; -// static int cra[] = {-1,-1,-1,3,-1,-1,2,-1,-1,1,-1,-1,0,-1,-1,-1}; -// -// double xco = xo; -// double yco = yo; -// double xce = xe; -// double yce = ye; -// if (clipLine(xco, yco, co, xce, yce, ce)) { -// if (co) { -// int sx = getScreenX(getUnit(xco)); -// int sy = getScreenY(getUnit(yco)); -// sPoints.putPoints(sCount++, 1, sx, sy); -// } -// int sx = getScreenX(getUnit(xce)); -// int sy = getScreenY(getUnit(yce)); -// sPoints.putPoints(sCount++, 1, sx, sy); -// } -// else { -// if (ce & 16) { -// if (!(co & ce & ~16)) { -// int c; -// if (!(co & 16)) { -// c = ce + tcc[co]; -// } -// else { -// bool done = false; -// double xto = xo; -// double yto = yo; -// double xte = xe; -// double yte = ye; -// while (!done) { -// double x = (xto + xte) / 2; -// double y = (yto + yte) / 2; -// c = getClipCode(x, y); -// if (!(c & 16)) { -// if (c & ce) { -// c = ce + tcc[co & ~16]; -// } -// else { -// c = co + tcc[ce & ~16]; -// } -// done = true; -// } -// else { -// if (c == ce) { -// xte = x; -// yte = y; -// } -// else { -// if (c != co) { -// done = true; -// } -// else { -// xto = x; -// yto = y; -// } -// } -// } -// } -// } -// int sx = getScreenX(getUnit(_clipX[cra[c&~16]])); -// int sy = getScreenY(getUnit(_clipY[cra[c&~16]])); -// sPoints.putPoints(sCount++, 1, sx, sy); -// } -// } -// else { -// if (co & 16) { -// if (!(co & ce)) ce = co + tcc[ce]; -// } -// else { -// ce |= co; -// if (tcc[ce] == 1) ce |= 16; -// } -// } -// } -// if (ce & 16) { -// int sx = getScreenX(getUnit(_clipX[cra[ce&~16]])); -// int sy = getScreenY(getUnit(_clipY[cra[ce&~16]])); -// sPoints.putPoints(sCount++, 1, sx, sy); -// } -// } -// xo = xe; -// yo = ye; -// co = ce; -// endFor; -// } -// -// if (closed && sCount) { -// sPoints.putPoints(sCount++, 1, sPoints[0].x(), sPoints[0].y()); -// } -// -// return sCount; -//} -// - -// ************************************************************************************************* -// CellWidget::_setStartedCommand() -// CellWidget::_setClipBox() -// ************************************************************************************************* - -//void -//CellWidget::_setStartedCommand(Command* command) -//{ -// _startedCommand = command; -//} - -void -CellWidget::_setClipBox(const Box& area) +void CellWidget::mouseReleaseEvent ( QMouseEvent* event ) { - _clipBox = Box(area).inflate(getSize(2)); - - _clipX[0] = getValue(_clipBox.getXMin()); - _clipX[1] = getValue(_clipBox.getXMax()); - _clipX[2] = getValue(_clipBox.getXMin()); - _clipX[3] = getValue(_clipBox.getXMax()); - _clipY[0] = getValue(_clipBox.getYMin()); - _clipY[1] = getValue(_clipBox.getYMin()); - _clipY[2] = getValue(_clipBox.getYMax()); - _clipY[3] = getValue(_clipBox.getYMax()); + if ( ( event->button() == Qt::LeftButton ) && _mouseGo ) { + _mouseGo = false; + popCursor (); + } } - -// ************************************************************************************************* -// CellWidget::_redraw() -// ************************************************************************************************* - -void -CellWidget::_redraw() +QPoint CellWidget::getScreenPoint ( Unit x, Unit y ) const { - if (!_invalidRegion.isEmpty()) { - QRect invalidRect = _invalidRegion.boundingRect(); - - if (_doubleBuffering) { - _invalidRegion = invalidRect; - } - - Box area = getBox(invalidRect).inflate(getSize(1)); - - _setClipBox(area); - - QPaintDevice* device = this; - - if (_doubleBuffering) { - //device = _getPixmap(); - } - - QPainter painter(device); - QPainter* oldPainter = _painter; - _painter = &painter; - - QRegion deepRegion; - for (list::iterator plit = _peekList.begin(); - plit != _peekList.end(); - ++plit) { - deepRegion = deepRegion.unite(QRegion(getScreenRect(*plit))); - } -// forEachBox(peek, _peekList) { -// deepRegion = deepRegion.unite(QRegion(getScreenRect(peek))); -// endFor; -// } - deepRegion = deepRegion.intersect(_invalidRegion); - Box deepArea = getBox(deepRegion.boundingRect()); - - _painter->setClipRegion(_invalidRegion); - - _painter->fillRect(invalidRect, QBrush(getBackgroundColor())); - - preRedraw(area); - - QRegion region = _invalidRegion.subtract(deepRegion); - - Cell* cell = getCell(); - if (cell) { - - - _painter->save(); - - - double brightness = 1.0; - //if (highlightionIsVisible() && !getHighlightion().isEmpty()) { - // brightness = 0.4; - //} - - setPen(boundariesPen, brightness); - setBrush(boundariesBrush, brightness); - //drawBoundaries(cell, area, Transformation()); - - - for_each_basic_layer(layer, getVisibleLayers()) { - if (isDrawable(layer)) { - //setFont(getFont(layer)); - //setPen(layer->getPen(), brightness); - setPen(getPen(layer), brightness); - //setBrush(layer->getBrush(), brightness); - setBrush(getBrush(layer), brightness); - //setBrushOrigin(layer->getBrushOrigin()); - if (deepRegion.isEmpty()) { - drawContent(cell, layer, area, Transformation()); - // view->_draw(this, layer, area, Transformation()); - } else { - _painter->setClipRegion(region); - drawContent(cell, layer, area, Transformation()); - //view->_draw(this, layer, area, Transformation()); - _painter->setClipRegion(deepRegion); - unsigned displayDepth = _displayDepth; - _displayDepth = (unsigned)-1; - //view->_draw(this, layer, deepArea, Transformation()); - drawContent(cell, layer, deepArea, Transformation()); - _displayDepth = displayDepth; - _painter->setClipRegion(_invalidRegion); - } - //_painter->flush(); - } - end_for; - } -// if (highlightionIsVisible() && !getHighlightion().isEmpty()) { -// Technology* technology = getDatabase()->getTechnology(); -// if (technology) { -// forEachLayer(layer, technology->getLayers()) { -// if (isDrawable(layer)) { -// setFont(layer->getFont()); -// setPen(layer->getPen()); -// setBrush(layer->getBrush()); -// setBrushOrigin(layer->getBrushOrigin()); -// forEachOccurrence(occurrence, getHighlightion()) { -// Figure* figure = dynamic_cast(occurrence.getEntity()); -// if (figure && -// figure->isMaterialized() && -// (figure->getLayerMask() & layer->getMask())) { -// Box boundingBox = occurrence.getBoundingBox(); -// if (boundingBox.overlaps(area)) { -// Transformation transformation = -// occurrence.getPath().getTransformation(); -// Box correctedArea = -// transformation.getInverted().getBox(area); -// figure->_draw(this, layer, correctedArea, transformation); -// } -// } -// endFor; -// } -// _painter->flush(); -// } -// endFor; -// } -// } -// } -// if (selectionIsVisible()) { -// QColor selectionColor = getSelectionColor(); -// setPen(selectionColor); -// setBrush(QBrush(selectionColor, Dense4Pattern)); -// setBrushOrigin(QPoint(0, 0)); -// forEachOccurrence(occurrence, getSelection()) { -// Figure* figure = dynamic_cast(occurrence.getEntity()); -// if (figure) { -// Box boundingBox = occurrence.getBoundingBox(); -// if (boundingBox.overlaps(area)) { -// figure->_highlight(this, occurrence.getPath().getTransformation()); -// } -// } -// endFor; -// } -// } - _painter->restore(); - if (gridIsVisible() && gridIsDrawable()) { - Unit xMin = getGridX(getX(0)); - Unit yMin = getGridY(getY(height())); - Unit xMax = getGridX(getX(width())); - Unit yMax = getGridY(getY(0)); - setPen(getGridColor()); - for (Unit x = xMin; x <= xMax; x += _gridXStep) { - int sx = getScreenX(x); - if (_gridAxesAreVisible && (x == getGridOrigin().getX())) { - //_painter->moveTo(sx, 0); - //_painter->lineTo(sx, height()); - _painter->drawLine(sx, 0, sx, height()); - } - for (Unit y = yMin; y <= yMax; y += _gridYStep) { - int sy = getScreenY(y); - if (_gridAxesAreVisible && (y == getGridOrigin().getY())) { - //_painter->moveTo(0, sy); - //_painter->lineTo(width(), sy); - _painter->drawLine(0, sy, width(), sy); - } - if (!(isOnGridX(x, 10) && isOnGridY(y, 10))) { - _painter->drawPoint(sx, sy); - } - else { - //_painter->moveTo(sx - 2, sy); - //_painter->lineTo(sx + 2, sy); - _painter->drawLine(sx - 2, sy, sx + 2, sy); - //_painter->moveTo(sx, sy - 2); - //_painter->lineTo(sx, sy + 2); - _painter->drawLine(sx, sy - 2, sx, sy + 2); - } - } - } - } - } - - postRedraw(area); - - if (device != this) { - int x = invalidRect.x(); - int y = invalidRect.y(); - int w = invalidRect.width(); - int h = invalidRect.height(); - //bitBlt(this, x, y, device, x, y, w, h, CopyROP, true); - } - - _setClipBox(getBox(rect())); - - _painter = oldPainter; - - _invalidRegion = QRegion(); - } + return QPoint ( getScreenX(x), getScreenY(y) ); } - -// ************************************************************************************************* -// CellWidget::_callDrawOf() -// ************************************************************************************************* - -//void -//CellWidget::_callDrawOf(Command* command) -//{ -// assert(command); -// assert(command->isInstalledOn(this)); -// -// if (getView()) { -// QPainter painter(this); -// -// _painter = &painter; -// -// _painter->setRasterOp(XorROP); -// _painter->setPen(getForegroundColor()); -// _painter->setBrush(NoBrush); -// -// command->onDraw(this); -// } -//} -// +QPoint CellWidget::getScreenPoint ( const Point& point ) const +{ + return getScreenPoint ( point.getX(), point.getY() ); +} -// ************************************************************************************************* -// CellWidget::_insertCommand() -// CellWidget::_removeCommand() -// ************************************************************************************************* - -//void -//CellWidget::_insertCommand(Command* command) -//{ -// _commandMap[command->getButton()] = command; -//} -// -//void -//CellWidget::_removeCommand(Command* command) -//{ -// _commandMap.erase(command->getButton()); -//} -// -// -// -//// ************************************************************************************************* -//// CellWidget::_insertSelector() -//// CellWidget::_removeSelector() -//// ************************************************************************************************* -// -//void -//CellWidget::_insertSelector(Selector* selector) -//{ -// _selectorSet.insert(selector); -//} -// -//void -//CellWidget::_removeSelector(Selector* selector) -//{ -// _selectorSet.erase(selector); -//} -// -// -// -//// ************************************************************************************************* -//// CellWidget::_insertHighlightor() -//// CellWidget::_removeHighlightor() -//// ************************************************************************************************* -// -//void -//CellWidget::_insertHighlightor(Highlightor* highlightor) -//{ -// _highlightorSet.insert(highlightor); -//} -// -//void -//CellWidget::_removeHighlightor(Highlightor* highlightor) -//{ -// _highlightorSet.erase(highlightor); -//} -// +QRect CellWidget::getScreenRect ( Unit x1, Unit y1, Unit x2, Unit y2 ) const +{ + return QRect ( getScreenX(x1) + , getScreenY(y2) + , getScreenX(x2) - getScreenX(x1) + , getScreenY(y1) - getScreenY(y2) + ); +} -//CLOSE_MY_NAMESPACE +QRect CellWidget::getScreenRect ( const Box& box ) const +{ + return getScreenRect ( box.getXMin() + , box.getYMin() + , box.getXMax() + , box.getYMax() + ); +} -// ************************************************************************************************* -// ************************************************************************************************* + +void CellWidget::setShowBoundaries ( bool state ) +{ + if ( _showBoundaries != state ) { + _showBoundaries = state; + redraw (); + } +} + + +} // End of Hurricane namespace. diff --git a/hurricane/src/viewer/CellWidget.h b/hurricane/src/viewer/CellWidget.h index d0d5e5e2..6e3e3174 100644 --- a/hurricane/src/viewer/CellWidget.h +++ b/hurricane/src/viewer/CellWidget.h @@ -1,1641 +1,235 @@ -// ************************************************************************************************* -// ************************************************************************************************* -// File: CellWidget.h -// ************************************************************************************************* -// ************************************************************************************************* -#ifndef H_CellWidget -#define H_CellWidget - -#include - -#include "Box.h" -//#include "Commands.h" -#include "Slice.h" -#include "Segment.h" -#include "Contact.h" -#include "Layers.h" -#include "BasicLayer.h" -#include "Occurrences.h" -#include "Points.h" -using namespace Hurricane; -//#include "Selectors.h" - -//OPEN_MY_NAMESPACE - -//class View; -//class TrackBox; +// -*- C++ -*- -// ************************************************************************************************* -// CellWidget -// ************************************************************************************************* +# ifndef __CELLWIDGET_H__ +# define __CELLWIDGET_H__ -class /* Q_EXPORT */ CellWidget : public QWidget { +# include - Q_OBJECT +# include +# include - public: - ~CellWidget(); +# include +# include +# include +# include +# include - Cell* getCell() const; - //View* getView() const ; - const Point& getCenter() const; - double getScale() const; - Unit getX(int screenX) const; - Unit getY(int screenY) const; - Unit getSize(int screenSize) const; - Point getPoint(const QPoint& screenPoint) const; - Box getBox(const QRect& screenRect) const; - int getScreenX(const Unit& x) const; - int getScreenY(const Unit& y) const; - int getScreenSize(const Unit& size) const; - QPoint getScreenPoint(const Point& point) const; - QRect getScreenRect(const Box& box) const; - Point getSnapPoint(const Point& point) const; - Point getSnapPoint(int screenX, int screenY) const; - const QColor& getBackgroundColor() const; - const QColor& getForegroundColor() const; - const Layer::Mask& getVisibleLayerMask() const; - BasicLayers getVisibleLayers() const; - //Command* getCommand(int button) const; - //Command* getStartedCommand() const; - //Commands getCommands() const; - const Point& getGridOrigin() const; - const Unit& getGridXStep() const; - const Unit& getGridYStep() const; - unsigned getGridDisplayThreshold() const; - const QColor& getGridColor() const; - Unit getGridX(const Unit& x, - int sign = 0) const; - Unit getGridY(const Unit& y, - int sign = 0) const; - Point getGridPoint(const Point& point, - int xSign = 0, - int ySign = 0) const; - unsigned getDisplayDepth() const; - unsigned getDisplaySize() const; - Occurrences getSelection() const; - Box getSelectionBox() const; - unsigned getSelectionLimit() const; - const QColor& getSelectionColor() const; - Occurrences getHighlightion() const; - Box getHighlightionBox() const; - unsigned getHighlightionLimit() const; - const QFont& getFont(); - const QPen& getPen(); - const QPen& getPen(const BasicLayer* layer); - const QBrush& getBrush(); - const QBrush& getBrush(BasicLayer* layer); - const QPoint getBrushOrigin(); - //TrackBox* getTrackBox() const; - - bool doubleBuffering() const; - bool automaticScrolling() const; - bool isVisible(BasicLayer* layer) const; - bool isDrawable(BasicLayer* layer) const; - bool gridIsVisible() const; - bool gridAxesAreVisible() const; - bool gridIsDrawable() const; - bool isOnGridX(const Unit& x, - unsigned n = 1) const; - bool isOnGridY(const Unit& y, - unsigned n = 1) const; - bool isOnGridPoint(const Point& point, - unsigned xN = 1, - unsigned yN = 1) const; - bool snapGrid() const; - bool selectionIsVisible() const; - bool isSelected(const Occurrence& occurrence) const; - bool isSelectable(const Occurrence& occurrence) const; - bool highlightionIsVisible() const; - bool isHighlighted(const Occurrence& occurrence) const; - bool isHighlightable(const Occurrence& occurrence) const; - - void setBackgroundColor(const QColor& color); - void setForegroundColor(const QColor& color); - void setDoubleBuffering(bool enable); - void setAutomaticScrolling(bool enable); - void setVisible(BasicLayer* layer, - bool visible); - void setGridOrigin(const Point& origin); - void setGridXStep(const Unit& step); - void setGridYStep(const Unit& step); - void setGridStep(const Unit& step); - void setGridSteps(const Unit& xStep, - const Unit& yStep); - void setGridDisplayThreshold(unsigned threshold); - void setGridColor(const QColor& color); - void setGridVisible(bool visible); - void setGridAxesVisible(bool visible); - void setSnapGrid(bool enable); - void setDisplayDepth(unsigned displayDepth); - void setDisplaySize(unsigned displaySize); - void setSelectionLimit(unsigned limit); - void setSelectionColor(const QColor& color); - void setSelectionVisible(bool visible); - void setHighlightionLimit(unsigned limit); - void setHighlightionVisible(bool visible); - void setFont(const QFont& font); - void setPen(const QPen& pen, - double brightness = 1.0); - void setBrush(const QBrush& brush, - double brightness = 1.0); - void setBrushOrigin(const QPoint& origin); - //void setTrackBox(TrackBox* trackBox); - - void showAllLayers(); - void hideAllLayers(); - bool select(const Occurrence& occurrence); - void unselect(const Occurrence& occurrence); - //void clearSelection(); - //bool highlight(const Occurrence& occurrence); - //void unhighlight(const Occurrence& occurrence); - //void clearHighlightion(); - void clearPeeks(); - void addPeek(const Box& box); - - void invalidate(); - void invalidate(const QRect& screenRect); - void invalidate(const Box& box); - void fitToContent(unsigned screenMargin = 5) ; - void reframe(double scale); - void reframe(const Point& center); - void reframe(const Point& center, - double scale); - void reframe(const Box& box); - void scroll(const Unit& dx, - const Unit& dy); - void redraw(); - void abortStartedCommand(); +class QCursor; +class QResizeEvent; +class QMouseEvent; +class QKeyEvent; +class QAction; - void drawContent(const Cell* cell, const BasicLayer* basicLayer, const Hurricane::Box& updateArea, const Transformation& transformation) const; - void drawContent(const Instance* instance, const BasicLayer* basicLayer, const Hurricane::Box& updateArea, const Transformation& transformation) const; - void drawSlice(const Slice* slice, const BasicLayer* basicLayer, const Hurricane::Box& updateArea, const Transformation& transformation) const; - void drawPhantoms(const Cell* cell, const Box& updateArea, const Transformation& transformation) const; - void drawPhantoms(const Instance* instance, const Box& updateArea, const Transformation& transformation) const; - void drawBoundaries(const Cell* cell, const Box& updateArea, const Transformation& transformation) const; - void drawBoundaries(const Instance* instance, const Box& updateArea, const Transformation& transformation) const; - void drawGo(const Go* go, const BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation) const; - void drawSegment(const Segment* segment, const BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation) const; - void drawContact(const Contact* contact, const BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation) const; +# include "Commons.h" +# include "Point.h" +# include "Box.h" +# include "Transformation.h" - void drawLine(const Unit& xo, - const Unit& yo, - const Unit& xe, - const Unit& ye) const; - void drawLine(const Point& origin, - const Point& extremity) const; - void drawPolyline(const Points& points); - - void drawRectangle(const Unit& xMin, - const Unit& yMin, - const Unit& xMax, - const Unit& yMax) const; - void drawRectangle(const Box& box) const; - void drawPolygon(const Points& points); - //void drawText(const Box& frame, - // const string& text, - // const Direction& direction); - //void drawText(const Box& frame, -// const Name& name, -// const Direction& direction); -#ifndef DOXYGEN - public: - typedef QWidget Inherit; - - //Label getLabel() const; - Record* getRecord() const; - Slot* getSlot(const string& name) const; - Box getWorld() const; - //Selectors getSelectors() const; - //Highlightors getHighlightors() const; - - bool hasRecord() const; - bool allowAutomaticScrolling() const; - - void reframe(); - - void preRedraw(const Box& area); - void postRedraw(const Box& area); - - void drawSnapPoint(); - - CellWidget(Cell* cell, - QWidget* parent = NULL, - const char* name = NULL); - - protected: - - void resizeEvent(QResizeEvent* event); - //void enterEvent(QEvent* event); - //void leaveEvent(QEvent* event); - //void mousePressEvent(QMouseEvent* event); - //void mouseMoveEvent(QMouseEvent* event); - //void mouseReleaseEvent(QMouseEvent* event); - //void focusInEvent(QFocusEvent* event); - //void focusOutEvent(QFocusEvent* event); - void paintEvent(QPaintEvent* event); - - void onSetVisible(Layer* layer, - bool visible); - - private: - CellWidget(const CellWidget& porthole); - // not implemented to forbid copy - - CellWidget& operator=(const CellWidget& porthole); - // not implemented to forbid assignment - - int getClipCode(double x, - double y) const; - bool clipLine(double& xo, - double& yo, - int co, - double& xe, - double& ye, - int ce, - int u = 0) const; -// bool clipLines(const Points& points, -// QPointArray& sPoints, -// unsigned& sCount, -// bool closed = false) const; -// -// typedef map CommandMap; -// typedef set SelectorSet; -// typedef set HighlightorSet; - typedef list PeekList; - - Cell* _cell; - Point _center; - double _scale; - int _screenDx; - int _screenDy; - int _brushDx; - int _brushDy; - bool _alreadyExposed; - QRegion _invalidRegion; - Box _clipBox; - double _clipX[4]; - double _clipY[4]; - QPainter* _painter; - QColor _backgroundColor; - QColor _foregroundColor; - bool _doubleBuffering; - bool _automaticScrolling; - Layer::Mask _visibleLayerMask; - //CommandMap _commandMap; - //Command* _startedCommand; - Point _gridOrigin; - Unit _gridXStep; - Unit _gridYStep; - bool _gridIsVisible; - bool _gridAxesAreVisible; - unsigned _gridDisplayThreshold; - QColor _gridColor; - bool _snapGrid; - bool _drawSnapPoint; - Point _snapPoint; - unsigned _displayDepth; - unsigned _displaySize; - //SelectorSet _selectorSet; - unsigned _selectionLimit; - QColor _selectionColor; - bool _selectionIsVisible; - //HighlightorSet _highlightorSet; - unsigned _highlightionLimit; - bool _highlightionIsVisible; - //static QPointArray _sPoints; - //TrackBox* _trackBox; - PeekList _peekList; - map _basicLayersBrush; - map _basicLayersPen; - - protected: - //restricted: - //QPixmap* _getPixmap() const ; - - //void _setStartedCommand(Command* command); - //void _setTrackBox(TrackBox* trackBox); - void _setClipBox(const Box& area); - - void _redraw(); - //void _callDrawOf(Command* command); - - // void _insertCommand(Command* command); - // void _removeCommand(Command* command); - // void _insertSelector(Selector* selector); - // void _removeSelector(Selector* selector); - // void _insertHighlightor(Highlightor* highlightor); - // void _removeHighlightor(Highlightor* highlightor); -#endif // DOXYGEN - -}; +# include "DisplayStyle.h" -// ************************************************************************************************* -// getLabel() -// getRecord() -// getSlot() -// ************************************************************************************************* -#ifndef DOXYGEN -//inline -//Label -//getLabel(const CellWidget& porthole) -//{ -// return porthole.getLabel(); -//} -// -//inline -//Label -//getLabel(const CellWidget* porthole) -//{ -// return (!porthole) ? Label("nil") : porthole->getLabel(); -//} -// -//inline -//Record* -//getRecord(const CellWidget& porthole) -//{ -// return porthole.getRecord(); -//} -// -//inline -//Record* -//getRecord(const CellWidget* porthole) -//{ -// return (!porthole) ? NULL : porthole->getRecord(); -//} -// -//inline -//Slot* -//getSlot(const string& name, -// const CellWidget& porthole) -//{ -// return porthole.getSlot(name); -//} -// -//inline -//Slot* -//getSlot(const string& name, -// const CellWidget* porthole) -//{ -// return (!porthole) ? getSlot(name, getLabel("nil")) : porthole->getSlot(name); -//} -#endif // DOXYGEN +namespace Hurricane { + + class BasicLayer; + class Go; + class Cell; + class Instance; + class Slice; + class Segment; + class Contact; + + class ScreenLayer; + class LayersList; +//class MapView; + + + class CellWidget : public QWidget { + Q_OBJECT; + + // Attributes. + protected: + static const int _stripWidth; + map _styles; + DisplayStyle* _activeStyle; + vector _screenLayers; + vector _cursors; +// MapView* _mapView; + LayersList* _layersList; + Box _displayArea; + Box _visibleArea; + float _scale; + QPoint _offsetVA; + QPixmap _drawingBuffer; + QPainter _painter; + QPoint _lastMousePosition; + Cell* _cell; + bool _mouseGo; + bool _openCell; + bool _showBoundaries; + + public: + CellWidget ( Cell* cell ); + virtual ~CellWidget (); + + public slots: + void redraw ( QRect redrawArea ); + inline void redraw (); + void goLeft ( int dx = 0 ); + void goRight ( int dx = 0 ); + void goUp ( int dy = 0 ); + void goDown ( int dy = 0 ); + void fitToContents (); + void setScale ( float scale ); + void setShowBoundaries ( bool state ); + void reframe ( const Box& box ); + void screenReframe (); + void shiftLeft ( int dx ); + void shiftRight ( int dx ); + void shiftUp ( int dy ); + void shiftDown ( int dy ); + + // Qt QWidget Overloads. + public: + void pushCursor ( Qt::CursorShape cursor ); + void popCursor (); + QSize minimumSizeHint () const; + void paintEvent ( QPaintEvent* ); + void resizeEvent ( QResizeEvent* ); + void keyPressEvent ( QKeyEvent* ); + void mouseMoveEvent ( QMouseEvent* ); + void mousePressEvent ( QMouseEvent* ); + void mouseReleaseEvent ( QMouseEvent* ); + + // Geometric conversions. + public: + QRect getScreenRect ( Unit x1, Unit y1, Unit x2, Unit y2 ) const; + QRect getScreenRect ( const Box& box ) const; + QPoint getScreenPoint ( Unit x, Unit y ) const; + QPoint getScreenPoint ( const Point& point ) const; + inline int getScreenX ( Unit x ) const; + inline int getScreenY ( Unit y ) const; + inline int getScreenLength ( Unit length ) const; + inline Unit getX ( int x ) const; + inline Unit getY ( int y ) const; + inline Unit getLength ( int length ) const; + inline Box getBox ( const QRect& rect ) const; + + // Painter control & Hurricane objects drawing primitives. + public: + void addStyle ( const string& key, DisplayStyle& displayStyle ); + void setStyle ( const string& key ); + inline const QPen& getPen ( const string& key ); + inline const QBrush& getBrush ( const string& key ); + void drawBoundaries ( const Cell* , const Box&, const Transformation& ); + void drawBoundaries ( const Instance*, const Box&, const Transformation& ); + bool isDrawable ( const ScreenLayer* screenLayer ); + void drawCell ( const Cell* , const BasicLayer*, const Box&, const Transformation& ); + void drawInstance ( const Instance*, const BasicLayer*, const Box&, const Transformation& ); + void drawSlice ( const Slice* , const BasicLayer*, const Box&, const Transformation& ); + void drawGo ( const Go* , const BasicLayer*, const Box&, const Transformation& ); + void drawSegment ( const Segment* , const BasicLayer*, const Box&, const Transformation& ); + void drawContact ( const Contact* , const BasicLayer*, const Box&, const Transformation& ); + void drawBox ( const Box& ); + void drawLine ( const Point&, const Point& ); + + // Accessors. + public: +// MapView* getMapView () { return _mapView; }; + LayersList* getLayersList () { return _layersList; }; + vector& getScreenLayers () { return _screenLayers; }; + inline Cell* getCell () const; + inline bool showBoundaries () const; + + // Modifiers. + public: + }; -// ************************************************************************************************* -// hasRecord() -// ************************************************************************************************* -#ifndef DOXYGEN -//inline -//bool -//hasRecord(const CellWidget& porthole) -//{ -// return porthole.hasRecord(); -//} -// -//inline -//bool -//hasRecord(const CellWidget* porthole) -//{ -// return (!porthole) ? false : porthole->hasRecord(); -//} -#endif // DOXYGEN - - - -// ************************************************************************************************* -// operator<<() -// ************************************************************************************************* - -#ifndef DOXYGEN -//inline -//ostream& -//operator<<(ostream& stream, -// const CellWidget& porthole) -//{ -// return stream << porthole.getLabel(); -//} -// -//inline -//ostream& -//operator<<(ostream& stream, -// const CellWidget* porthole) -//{ -// return (!porthole) ? (stream << "nil") : (stream << "&" << porthole->getLabel()); -//} -#endif // DOXYGEN - - - -// ************************************************************************************************* -// CellWidget::getBackgroundColor() -// CellWidget::getForegroundColor() -// CellWidget::getStartedCommand() -// CellWidget::getGridOrigin() -// CellWidget::getGridXStep() -// CellWidget::getGridYStep() -// CellWidget::getGridDisplayThreshold() -// CellWidget::getGridColor() -// CellWidget::getDisplayDepth() -// CellWidget::getDisplaySize() -// CellWidget::getSelectionColor() -// CellWidget::getSelectionLimit() -// CellWidget::getHighlightionLimit() -// CellWidget::getTrackBox() -// ************************************************************************************************* - -inline -const QColor& -CellWidget::getBackgroundColor() const +inline void CellWidget::redraw () { - return _backgroundColor; + redraw ( QRect(QPoint(0,0),_drawingBuffer.size()) ); } -inline -const QColor& -CellWidget::getForegroundColor() const + +inline int CellWidget::getScreenX ( Unit x ) const { - return _foregroundColor; + return (int)rint ( (float)( x - _displayArea.getXMin() ) * _scale ); } -inline -const Layer::Mask& -CellWidget::getVisibleLayerMask() const + +inline int CellWidget::getScreenY ( Unit y ) const { - return _visibleLayerMask; + return (int)rint ( (float)( _displayArea.getYMax() - y ) * _scale ); } -// -//inline -//Command* -//CellWidget::getStartedCommand() const -//{ -// return _startedCommand; -//} -inline -const Point& -CellWidget::getGridOrigin() const +inline int CellWidget::getScreenLength ( Unit length ) const { - return _gridOrigin; + return (int)rint ( (float)length * _scale ); } -inline -const Unit& -CellWidget::getGridXStep() const + +inline Unit CellWidget::getX ( int x ) const { - return _gridXStep; + return (Unit)(x/_scale) + _displayArea.getXMin(); } -inline -const Unit& -CellWidget::getGridYStep() const + +inline Unit CellWidget::getY ( int y ) const { - return _gridYStep; + return _displayArea.getYMax() - (Unit)(y/_scale); } -inline -unsigned -CellWidget::getGridDisplayThreshold() const + +inline Unit CellWidget::getLength ( int length ) const { - return _gridDisplayThreshold; + return (int)( (float)length / _scale ); } -inline -const QColor& -CellWidget::getGridColor() const + +inline Box CellWidget::getBox ( const QRect& rect ) const { - return _gridColor; + return Box ( getX(rect.x()) + , getY(rect.y()) + , getX(rect.x()+rect.width ()) + , getY(rect.y()+rect.height())); } -inline -unsigned -CellWidget::getDisplayDepth() const + +inline const QPen& CellWidget::getPen ( const string& key ) { - return _displayDepth; + return _activeStyle->getPen ( key ); } -inline -unsigned -CellWidget::getDisplaySize() const + +inline const QBrush& CellWidget::getBrush ( const string& key ) { - return _displaySize; + return _activeStyle->getBrush ( key ); } -inline -const QColor& -CellWidget::getSelectionColor() const + +inline Cell* CellWidget::getCell () const { - return _selectionColor; + return _cell; } -inline -unsigned -CellWidget::getSelectionLimit() const + +inline bool CellWidget::showBoundaries () const { - return _selectionLimit; -} - -inline -unsigned -CellWidget::getHighlightionLimit() const -{ - return _highlightionLimit; -} - -//inline -//TrackBox* -//CellWidget::getTrackBox() const -//{ -// return _trackBox; -//} - - - -// ************************************************************************************************* -// CellWidget::doubleBuffering() -// CellWidget::automaticScrolling() -// CellWidget::gridIsVisible() -// CellWidget::gridAxesAreVisible() -// CellWidget::gridIsDrawable() -// CellWidget::snapGrid() -// CellWidget::selectionIsVisible() -// CellWidget::highlightionIsVisible() -// ************************************************************************************************* - -inline -bool -CellWidget::doubleBuffering() const -{ - return _doubleBuffering; -} - -inline -bool -CellWidget::automaticScrolling() const -{ - return _automaticScrolling; -} - -inline -bool -CellWidget::gridIsVisible() const -{ - return _gridIsVisible; -} - -inline -bool -CellWidget::gridAxesAreVisible() const -{ - return _gridAxesAreVisible; -} - -inline -bool -CellWidget::gridIsDrawable() const -{ - return ((int)_gridDisplayThreshold < getScreenSize(min(_gridXStep, _gridYStep))); -} - -inline -bool -CellWidget::snapGrid() const -{ - return _snapGrid; -} - -inline -bool -CellWidget::selectionIsVisible() const -{ - return _selectionIsVisible; -} - -inline -bool -CellWidget::highlightionIsVisible() const -{ - return _highlightionIsVisible; + return _showBoundaries; } -// ************************************************************************************************* -// CellWidget::setDoubleBuffering() -// CellWidget::setSelectionLimit() -// CellWidget::setHighlightionLimit() -// ************************************************************************************************* -inline -void -CellWidget::setDoubleBuffering(bool enable) -{ - _doubleBuffering = enable; -} +} // End of Hurricane namespace. -inline -void -CellWidget::setSelectionLimit(unsigned limit) -{ - _selectionLimit = limit; -} -inline -void -CellWidget::setHighlightionLimit(unsigned limit) -{ - _highlightionLimit = limit; -} - - - -// ************************************************************************************************* -// CellWidget::drawLine() -// CellWidget::drawRectangle() -// CellWidget::drawText() -// ************************************************************************************************* - -inline -void -CellWidget::drawLine(const Point& origin, - const Point& extremity) const -{ - drawLine(origin.getX(), origin.getY(), extremity.getX(), extremity.getY()); -} - -inline -void -CellWidget::drawRectangle(const Unit& xMin, - const Unit& yMin, - const Unit& xMax, - const Unit& yMax) const -{ - drawRectangle(Box(xMin, yMin, xMax, yMax)); -} - -//inline -//void -//CellWidget::drawText(const Box& frame, -// const Name& name, -// const Direction& direction) -//{ -// drawText(frame, name.getString(), direction); -//} - - - -// ************************************************************************************************* -// CellWidget::_setTrackBox() -// ************************************************************************************************* - -//#ifndef DOXYGEN -//inline -//void -//CellWidget::_setTrackBox(TrackBox* trackBox) -//{ -// _trackBox = trackBox; -//} -//#endif // DOXYGEN -// - - -// ************************************************************************************************* -// File documentation -// ************************************************************************************************* - -/*!\file - \brief This file contains the definition of the CellWidget class. - \paragraph Concept of CellWidget: - \nn A porthole is a Qt widget used to display a cell view. - \nn When a porthole is bound to a given cell view the content of this cell view is - displayed according to some porthole characteristics (zoom factor, grid, visible - layers, selection, highlightion, ...). - \nn The display reflects exactly the current state of the cell view (there isn't a - parallel display list). - \nn A porthole can display one and only one cell view, but a cell view can be displayed - simultaneously in multiple portholes. The fact that each porthole has its own - characteristics provides the capability to show different aspects of the same cell - view within separated portholes. - \paragraph Concept of MainCellWidget: - \nn The MainCellWidget class implements the concept of main porthole. - \nn The porthole class being an abstract class, to display a cell view you should create - a main porthole (or a specialization) and insert this widget in your graphic - interface (as all other widgets). - \nn Furthermore, you can attach to each main porthole a map porthole used to visualize - which part of the cell view is currently drawn in the main porthole and, can attach - a palette used to control the visibility of each layer and you can also two main - scroll bars. - \paragraph Concept of MapCellWidget: - \nn The MapCellWidget class implements the concept of map porthole. - \nn A map porthole is used to visualize which part of the cell view is currently - displayed by a main porthole. - \see View, MainCellWidget, MapCellWidget, Palette or Command. - \author \remye - */ - - - -// ************************************************************************************************* -// CellWidget documentation -// ************************************************************************************************* - -/*!\class CellWidget - \brief This abstract class introduces the concept of porthole - \concept A porthole is a Qt widget used to display a cell view. - \nn When a porthole is bound to a given cell view the content of this cell view is - displayed according to some porthole characteristics (zoom factor, grid, visible - layers, selection, highlightion, ...) as we will discover in the following. - \nn The display reflects exactly the current state of the cell view (there isn't a - parallel display list). - \nn A porthole can display one and only one cell view, but a cell view can be displayed - simultaneously in multiple portholes. The fact that each porthole has its own - characteristics provides the capability to show different aspects of the same cell - view within separated portholes. - \paragraph Specialization: - \nn The database provides two kind of portholes: the MainCellWidget which is used to - display the totality or some part of a cell view; and the MapCellWidget which is - associated to a main porthole to show which part of the cell view is currently - displayed in this main porthole. - \nn Note that, if you need to create a new kind of porthole you should inherit of one - of those types and not directly of the base class. - \paragraph Selection: - \nn Each porthole manages a collection of selected occurrences. The selection being - managed by portholes and not by cell views it's possible to have differents - selections for differents portholes bound to the same cell view. - \nn The selection is managed with the help of occurrence properties which is a very - secure mechanism. So, when an occurrence is no longer valid, this occurrence is - automaticaly unselected from each porthole it was selected in. - \paragraph Highlightion: - \nn Each porthole manages a collection of highlighted occurrences. The highlightion - being managed by portholes and not by cell views it's possible to have differents - highlightions for differents portholes bound to the same cell view. - \nn The highlightion is managed with the help of occurrence properties which is a very - secure mechanism. So, when an occurrence is no longer valid, this occurrence is - automaticaly unhighlighted from each porthole it was highlighted in. - \paragraph Commands: - \nn The database provides some command facilities. A command is an object which models - the behaviour to be obtained in reaction to mouse events within a porthole. - \nn Furthermore, coordinates which are manipulated by commands are cell view - coordinates and not screen coordinates (the translation being done by the porthole). - \nn %Commands are very powerfull objects which make the task more easier by managing - automaticaly important features of portholes like double buffering, automatic - scrolling, synchronization of the xor more when drawing ghost shapes... - \paragraph Palette: - \nn A palette can be used to control the visibility of the layers in a given main - porthole. - \paragraph Main scroll bars: - \nn You can also attach to each main porthole an horizontal and/or a vertical scroll - bar. - \paragraph Updates: - \nn A lot of functions provided by this class change the characteristics of the display. - \nn So, to avoid useless intermediate drawings or screen flickerings those functions - don't update the display immediately but post some invalidation regions which are - cumulated until a real request of redraw is asked. - \nn Furthermore, when a redraw is asked, something is done only when the invalidated - region isn't empty. - \paragraph Drawing: - \nn The CellWidget class provides some convenience functions to draw shapes which are - defined in cell view coordinates (and not in screen ones) according to the center, - scale and clipping region. - \nn So, no need to manage screen transformations, clipping or something like that. No - need to manage colors, pens, brushes or something else because all is controled by - the porthole which know when it is drawing a given layer or when it is drawing a - command ghost (in xor mode). - \paragraph Usage: - \nn The following piece of code illustrate the manner to build a very simple graphical - interface using a main porthole, a map porthole, two main scroll bars and a palette. - Furthermore, some commands are installed in the different portholes. The returned - editor being a widget it can be embedded in another parent widget which can add, for - example, a menu bar, a status bar or some additionnal decorations... - \code - * QWidget* getEditor(View* view) - * { - * QHBox* editor = new QHBox(); - * - * QFrame* mainFrame = new QFrame(editor); - * mainFrame->setFrameStyle(QFrame::Panel | QFrame::Sunken); - * mainFrame->setLineWidth(2); - * mainFrame->setMinimumSize(120, 120); - * editor->setStretchFactor(mainFrame, 1); - * - * QGridLayout* mainLayout = new QGridLayout(mainFrame, 2, 2); - * mainLayout->setMargin(2); - * - * MainCellWidget* mainCellWidget = new MainCellWidget(mainFrame); - * mainLayout->addWidget(mainCellWidget, 0, 0); - * - * MainScrollBar* hScrollBar = new MainScrollBar(mainFrame); - * hScrollBar->setOrientation(Qt::Horizontal); - * mainLayout->addWidget(hScrollBar, 1, 0); - * - * MainScrollBar* vScrollBar = new MainScrollBar(mainFrame); - * vScrollBar->setOrientation(Qt::Vertical); - * mainLayout->addWidget(vScrollBar, 0, 1); - * - * QVBox* vBox = new QVBox(editor); - * editor->setStretchFactor(vBox, 0); - * vBox->setMinimumWidth(120); - * vBox->setMaximumWidth(120); - * vBox->setSpacing(5); - * - * QFrame* mapFrame = new QFrame(vBox); - * mapFrame->setFrameStyle(QFrame::Panel | QFrame::Sunken); - * mapFrame->setLineWidth(2); - * mapFrame->setMinimumSize(120, 120); - * mapFrame->setMaximumSize(120, 120); - * - * QGridLayout* mapLayout = new QGridLayout(mapFrame, 1, 1); - * mapLayout->setMargin(2); - * - * MapCellWidget* mapCellWidget = new MapCellWidget(mapFrame); - * mapLayout->addWidget(mapCellWidget, 0, 0); - * - * Palette* palette = new Palette(vBox); - * - * mainCellWidget->setView(view); - * mainCellWidget->setMapCellWidget(mapCellWidget); - * mainCellWidget->setPalette(palette); - * mainCellWidget->setHScrollBar(hScrollBar); - * mainCellWidget->setVScrollBar(vScrollBar); - * - * mapCellWidget->hideAllLayers(); - * Layer* phantom = getDatabase()->getTechnology()->getLayer("PHANTOM"); - * if (phantom) { - * mapCellWidget->setVisible(phantom, true); - * } - * - * getZoomCommand().installOn(mainCellWidget); - * getSelectCommand().installOn(mainCellWidget); - * getPanCommand().installOn(mainCellWidget); - * - * getZoomCommand().installOn(mapCellWidget); - * getPanCommand().installOn(mapCellWidget); - * - * editor->resize(700, 500); - * editor->setMargin(5); - * editor->setSpacing(5); - * editor->show(); - * - * return editor; - * } - \endcode - \nn - \see View, MainCellWidget, MapCellWidget, MainScrollBar, Palette or Command. - \author \remye - */ - -/*!\function CellWidget::~CellWidget() - \behaviour This is the destructor. - */ - -//@{ -/*!\function View* CellWidget::getView() const - \behaviour This function returns the view displayed in this porthole. - */ - -/*!\function const Point& CellWidget::getCenter() const - \behaviour This function returns the center of this porthole. - \nn This center is in fact the point of the cell view which is located on the center of - this porthole. - \note Returns the point \c [0,0] if the porthole isn't bound to a cell view. - */ - -/*!\function double CellWidget::getScale() const - \behaviour This function returns the scale used by this porthole to display its contents. - \note Returns \c 1.0 if the porthole isn't bound to a cell view. - */ - -/*!\function Unit CellWidget::getX(int screenX) const - \behaviour This function returns the cell view abscissa corresponding to a screen abscissa. - \parameter screenX The screen abscissa for which the request is asked. - */ - -/*!\function Unit CellWidget::getY(int screenY) const - \behaviour This function returns the cell view ordinate corresponding to a screen ordinate. - \parameter screenY The screen ordinate for which the request is asked. - */ - -/*!\function Unit CellWidget::getSize(int screenSize) const - \behaviour This function returns the cell view dimension corresponding to a screen dimension. - \parameter screenSize The screen dimension for which the request is asked. - */ - -/*!\function Point CellWidget::getPoint(const QPoint& screenPoint) const - \behaviour This function returns the cell view location corresponding to a screen location. - \parameter screenPoint The screen location for which the request is asked. - */ - -/*!\function Box CellWidget::getBox(const QRect& screenRect) const - \behaviour This function returns the cell view box corresponding to a screen rectangle. - \parameter screenRect The screen rectangle for which the request is asked. - */ - -/*!\function int CellWidget::getScreenX(const Unit& x) const - \behaviour This function returns the screeen abscissa corresponding to a cell view abscissa. - \parameter x The cell view abscissa for which the request is asked. - */ - -/*!\function int CellWidget::getScreenY(const Unit& y) const - \behaviour This function returns the screeen ordinate corresponding to a cell view ordinate. - \parameter y The cell view ordinate for which the request is asked. - */ - -/*!\function int CellWidget::getScreenSize(const Unit& size) const - \behaviour This function returns the screeen dimension corresponding to a cell view dimension. - \parameter size The cell view dimension for which the request is asked. - */ - -/*!\function QPoint CellWidget::getScreenPoint(const Point& point) const - \behaviour This function returns the screeen location corresponding to a cell view location. - \parameter point The cell view location for which the request is asked. - */ - -/*!\function QRect CellWidget::getScreenRect(const Box& box) const - \behaviour This function returns the screeen rectangle corresponding to a cell view box. - \parameter box The cell view box for which the request is asked. - */ - -/*!\function Point CellWidget::getSnapPoint(const Point& point) const - \behaviour This convenience function returns the cell view location associated to a given cell - view location in respect to the snap grid status. - \nn So when snap grid is enabled the returned location correspond to the nearest grid - point of the given location else the returned location is the given location itself. - \parameter point The cell view location for which the request is asked. - */ - -/*!\function Point CellWidget::getSnapPoint(int screenX, int screenY) const - \behaviour This convenience function returns the cell view location associated to the specified - screen coordinates in respect to the snap grid status. - \nn So when snap grid is enabled the returned location correspond to the nearest grid - point of the location obtained from the specified screen coordinates else the - returned location is directly the location obtained from the specified screen - coordinates. - \parameter screenX The screen abscissa for which the request is asked. - \parameter screenY The screen ordinate for which the request is asked. - */ - -/*!\function const QColor& CellWidget::getBackgroundColor() const - \behaviour This function returns the background color of this porthole. - */ - -/*!\function const QColor& CellWidget::getForegroundColor() const - \behaviour This function returns the foreground color of this porthole. - */ - -/*!\function const LayerMask& CellWidget::getVisibleLayerMask() const - \behaviour This function returns the mask representing the visible layers of this porthole. - */ - -/*!\function Layers CellWidget::getVisibleLayers() const - \behaviour This function returns the collection of visible layers (can be empty). - \note The layers are sorted from the deepest one to the higher one. - */ - -/*!\function Command* CellWidget::getCommand(int button) const - \behaviour This function returns the command which is installed on a given button. - \parameter button The button for which we want to get the associated command. - */ - -/*!\function Command* CellWidget::getStartedCommand() const - \behaviour This function returns the command of this porthole which has started. - \note Returns \NULL when no command has started. - */ - -/*!\function Commands CellWidget::getCommands() const - \behaviour This function returns the collection of commands installed on this porthole. - */ - -/*!\function const Point& CellWidget::getGridOrigin() const - \behaviour This function returns the origin of the grid. - */ - -/*!\function const Unit& CellWidget::getGridXStep() const - \behaviour This function returns the horizontal grid step. - */ - -/*!\function const Unit& CellWidget::getGridYStep() const - \behaviour This function returns the vertical grid step. - */ - -/*!\function unsigned CellWidget::getGridDisplayThreshold() const - \behaviour This function returns the display threshold used to control the drawability of the - grid. - \nn The threshold is a minimal number of pixels allowed between two consecutives grid - points on screen. When the number of pixels is less than the threshold the grid - isn't drawn (even it is visible). - */ - -/*!\function const QColor& CellWidget::getGridColor() const - \behaviour This function returns the grid color of this porthole. - */ - -/*!\function Unit CellWidget::getGridX(const Unit& x, int sign) const - \behaviour This function returns the grid abscissa corresponding to a given cell view abscissa. - \parameter x The cell view abscissa for which the request is asked. - \parameter sign Indicates which grid position should be used. When the sign is -1 we - consider the lower grid position, when the sign is 0 we consider the - nearest position and when the sign is 1 we consider the upper grid - position (all other values are forbidden). - \exception INVALID_REQUEST This exception is thrown when the \c sign doesn't correspond to a - legal value. - */ - -/*!\function Unit CellWidget::getGridY(const Unit& y, int sign) const - \behaviour This function returns the grid ordinate corresponding to a given cell view ordinate. - \parameter y The cell view ordinate for which the request is asked. - \parameter sign Indicates which grid position should be used. When the sign is -1 we - consider the lower grid position, when the sign is 0 we consider the - nearest position and when the sign is 1 we consider the upper grid - position (all other values are forbidden). - \exception INVALID_REQUEST This exception is thrown when the \c sign doesn't correspond to a - legal value. - */ - -/*!\function Point CellWidget::getGridPoint(const Point& point, int xSign, int ySign) const - \behaviour This function returns the grid location corresponding to a given cell view location. - \parameter point The cell view location for which the request is asked. - \parameter xSign and - \parameter ySign Indicate which grid position should be used in the associated - direction. When the sign is -1 we consider the lower grid position, - when the sign is 0 we consider the nearest position and when the - sign is 1 we consider the upper grid position (all other values are - forbidden). - \exception INVALID_REQUEST This exception is thrown when the \c xSign or \c ySign doesn't - correspond to a legal value. - */ - -/*!\function unsigned CellWidget::getDisplayDepth() const - \behaviour This function returns the display depth of this porthole. - \note The display depth represent the maximal number of hierarchy levels that should be - drawn in this porthole. - */ - -/*!\function unsigned CellWidget::getDisplaySize() const - \behaviour This function returns the display size of this porthole. - \note To be drawn in a given porthole the maximal size of the bounding box of a figure - (on the screen) should be greather than the display size (defined in pixels). - */ - -/*!\function Occurrences CellWidget::getSelection() const - \behaviour This function returns the collection of occurrences selected in this porthole. - */ - -/*!\function Box CellWidget::getSelectionBox() const - \behaviour This function returns the box enclosing the selection of this porthole. - */ - -/*!\function unsigned CellWidget::getSelectionLimit() const - \behaviour This function returns the maximal number of occurrences that could be selected in - this porthole. - */ - -/*!\function const QColor& CellWidget::getSelectionColor() const - \behaviour This function returns the selection color of this porthole. - */ - -/*!\function Occurrences CellWidget::getHighlightion() const - \behaviour This function returns the collection of occurrences highlighted in this porthole. - */ - -/*!\function Box CellWidget::getHighlightionBox() const - \behaviour This function returns the box enclosing the highlightion of this porthole. - */ - -/*!\function unsigned CellWidget::getHighlightionLimit() const - \behaviour This function returns the maximal number of occurrences that could be highlighted in - this porthole. - */ - -/*!\function const QFont& CellWidget::getFont() const - \behaviour This function returns the current font of this porthole. - \note This is this font which is used by the drawing and filling functions. - */ - -/*!\function const QPen& CellWidget::getPen() const - \behaviour This function returns the current pen of this porthole. - \note This is this pen which is used by the drawing and filling functions. - */ - -/*!\function const QBrush& CellWidget::getBrush() const - \behaviour This function returns the current brush of this porthole. - \note This is this brush which is used by the drawing and filling functions. - */ - -/*!\function const QPoint& CellWidget::getBrushOrigin() const - \behaviour This function returns the current brush origin of this porthole. - \note This is this brush origin which is used by the drawing and filling functions. - */ - -/*!\function TrackBox* CellWidget::getTrackBox() const - \behaviour This function returns the track box associated to this porthole. - */ -//@} - -//@{ -/*!\function bool CellWidget::doubleBuffering() const - \behaviour This function returns \TRUE when the double buffering is enabled. - */ - -/*!\function bool CellWidget::automaticScrolling() const - \behaviour This function returns \TRUE when the automatic scrolling is enabled. - */ - -/*!\function bool CellWidget::isVisible(Layer* layer) const - \behaviour This function returns \TRUE when the specified layer is visible. - \parameter layer The layer for which the request is asked. - \note A visible layer is not systematicaly drawn. The display depends also of the layer - display threshold and the current scale. - */ - -/*!\function bool CellWidget::isDrawable(Layer* layer) const - \behaviour This function returns \TRUE when the layer can be drawn according to the layer - display threshold and the current scale. - \note A non visible layer can be drawable and a visible layer can be not drawable. So to - known if the layer should really be drawn you need to check its visibility and its - drawability. - */ - -/*!\function bool CellWidget::gridIsVisible() const - \behaviour This function returns \TRUE when the grid is visible. - \note A visible grid is not systematicaly drawn. The display depends also of the grid - display threshold and the current scale. - */ - -/*!\function bool CellWidget::gridAxesAreVisible() const - \behaviour This function returns \TRUE when the grid axes are visible. - \note Those grid axes are drawn only when this function returns \TRUE and the grid is - drawn. - */ - -/*!\function bool CellWidget::gridIsDrawable() const - \behaviour This function returns \TRUE when the grid can be drawn according to the grid - display threshold and the current scale. - \note A non visible grid can be drawable and a visible grid can be not drawable. So to - known if the grid should really be drawn you need to check its visibility and its - drawability. - */ - -/*!\function bool CellWidget::isOnGridX(const Unit& x, unsigned n) const - \behaviour This function returns \TRUE when the specified cell view abscissa is on a grid - position. - \parameter x The cell view abscissa for which the request is asked. - \parameter n This argument allows to do not take into account each grid position - but only those which are multiples of n (a null value is forbidden). - \exception INVALID_REQUEST This exception is thrown when \c n is null. - */ - -/*!\function bool CellWidget::isOnGridY(const Unit& y, unsigned n) const - \behaviour This function returns \TRUE when the specified cell view ordinate is on a grid - position. - \parameter y The cell view ordinate for which the request is asked. - \parameter n This argument allows to do not take into account each grid position - but only those which are multiples of n (a null value is forbidden). - \exception INVALID_REQUEST This exception is thrown when \c n is null. - */ - -/*!\function bool CellWidget::isOnGridPoint(const Point& point, unsigned xN, unsigned yN) const - \behaviour This function returns \TRUE when the specified cell view location is on a grid - location. - \parameter point The cell view location for which the request is asked. - \parameter xN and - \parameter yN Allow to do not take into account each grid position but only those - which are multiples of xN horizontaly and yN verticaly (null values - are forbidden). - \exception INVALID_REQUEST This exception is thrown when \c xN or \c yN is null. - */ - -/*!\function bool CellWidget::snapGrid() const - \behaviour This function returns \TRUE when the snap grid is enabled. - */ - -/*!\function bool CellWidget::selectionIsVisible() const - \behaviour This function returns \TRUE when the selection is visible. - */ - -/*!\function bool CellWidget::isSelected(const Occurrence& occurrence) const - \behaviour This function returns \TRUE when the specified occurrence is selected in this - porthole. - */ - -/*!\function bool CellWidget::isSelectable(const Occurrence& occurrence) const - \behaviour This function returns \TRUE when the specified occurrence can be selected in this - porthole (meaning that the occurrence is selectable and the view owning the - occurrence is the view bound to this porthole). - */ - -/*!\function bool CellWidget::highlightionIsVisible() const - \behaviour This function returns \TRUE when the highlightion is visible. - */ - -/*!\function bool CellWidget::isHighlighted(const Occurrence& occurrence) const - \behaviour This function returns \TRUE when the specified occurrence is highlighted in this - porthole. - */ - -/*!\function bool CellWidget::isHighlightable(const Occurrence& occurrence) const - \behaviour This function returns \TRUE when the specified occurrence can be highlighted in this - porthole (meaning that the occurrence is highlightable and the view owning the - occurrence is the view bound to this porthole). - */ -//@} - -//@{ -/*!\function void CellWidget::setBackgroundColor(const QColor& color) - \behaviour This function sets the background color of this porthole to the specified value. - \parameter color The new background color. - */ - -/*!\function void CellWidget::setForegroundColor(const QColor& color) - \behaviour This function sets the foreground color of this porthole to the specified value. - \parameter color The new foreground color. - */ - -/*!\function void CellWidget::setDoubleBuffering(bool enable) - \behaviour This function enables or disables the double buffering. - \parameter enable The new status. - */ - -/*!\function void CellWidget::setAutomaticScrolling(bool enable) - \behaviour This function enables or disables the automatic scrolling. - \parameter enable The new status. - \exception INVALID_REQUEST This exception is thrown when this porthole is a map - porthole. - */ - -/*!\function void CellWidget::setVisible(Layer* layer, bool visible) - \behaviour This function sets the visibility status of the specified layer in this porthole to - the specified value. - \parameter layer The layer for which the request is asked. - \parameter visible The new status. - */ - -/*!\function void CellWidget::setGridOrigin(const Point& origin) - \behaviour This function sets the origin of the grid of this porthole to the specified value. - \parameter origin The new grid origin. - */ - -/*!\function void CellWidget::setGridXStep(const Unit& step) - \behaviour This function sets the horizontal grid step of this porthole to the specified value. - \parameter step The new horizontal grid step. - \exception INVALID_REQUEST This exception is thrown when the \c step is null. - */ - -/*!\function void CellWidget::setGridYStep(const Unit& step) - \behaviour This function sets the vertical grid step of this porthole to the specified value. - \parameter step The new vertical grid step. - \exception INVALID_REQUEST This exception is thrown when the \c step is null. - */ - -/*!\function void CellWidget::setGridStep(const Unit& step) - \behaviour This function sets the horizontal and vertical grid steps of this porthole to the - specified value. - \parameter step The new horizontal and vertical grid step. - \exception INVALID_REQUEST This exception is thrown when the \c step is null. - */ - -/*!\function void CellWidget::setGridSteps(const Unit& xStep, const Unit& yStep) - \behaviour This function sets the horizontal and vertical grid step of this porthole to the - specified values. - \parameter xStep The new horizontal grid step. - \parameter yStep The new vertical grid step. - \exception INVALID_REQUEST This exception is thrown when \c xStep or \c yStep is null. - is null. - */ - -/*!\function void CellWidget::setGridDisplayThreshold(unsigned threshold) - \behaviour This function sets the grid display threshold of this porthole to the specified - value. - \parameter threshold The new display threshold. - \exception INVALID_REQUEST This exception is thrown when the new display threshold is too - small (less than 3 pixels). - */ - -/*!\function void CellWidget::setGridColor(const QColor& color) - \behaviour This function sets the grid color of this porthole to the specified value. - \parameter color The new grid color. - */ - -/*!\function void CellWidget::setGridVisible(bool visible) - \behaviour This function sets the visibility status of the grid in this porthole to the - specified value. - \parameter visible The new status. - */ - -/*!\function void CellWidget::setGridAxesVisible(bool visible) - \behaviour This function sets the visibility status of the grid axes in this porthole to the - specified value. - \parameter visible The new status. - */ - -/*!\function void CellWidget::setSnapGrid(bool enable) - \behaviour This function enables or disables the snap grid. - \parameter enable The new status. - */ - -/*!\function void CellWidget::setDisplayDepth(unsigned displayDepth) - \behaviour This function sets the display depth of this porthole to the specified value. - \parameter displayDepth The new display depth. - */ - -/*!\function void CellWidget::setDisplaySize(unsigned displaySize) - \behaviour This function sets the display size of this porthole to the specified value. - \parameter displaySize The new display size. - */ - -/*!\function void CellWidget::setSelectionLimit(unsigned limit) - \behaviour This function sets the selection limit of this porthole to the specified value. - \parameter limit The new selection limit (a null value indicating no limit). - */ - -/*!\function void CellWidget::setSelectionColor(const QColor& color) - \behaviour This function sets the selection color of this porthole to the specified value. - \parameter color The new selection color. - */ - -/*!\function void CellWidget::setSelectionVisible(bool visible) - \behaviour This function sets the visibility status of the selection in this porthole to the - specified value. - \parameter visible The new status. - */ - -/*!\function void CellWidget::setHighlightionLimit(unsigned limit) - \behaviour This function sets the highlightion limit of this porthole to the specified value. - \parameter limit The new highlightion limit (a null value indicating no limit). - */ - -/*!\function void CellWidget::setHighlightionVisible(bool visible) - \behaviour This function sets the visibility status of the highlightion in this porthole to the - specified value. - \parameter visible The new status. - */ - -/*!\function void CellWidget::setFont(const QFont& font) - \behaviour This function sets the font of this porthole to the specified value. - \parameter font The new font. - \note When a layer (or a ghost) is displayed, the graphical characteristics of this layer - (or this ghost) have been positionned. So, in principle, unless very specific needs, - there is no need to call this function. If you do so, dont forget to restore the - previous font after use. - */ - -/*!\function void CellWidget::setPen(const QPen& pen, double brightness) - \behaviour This function sets the pen of this porthole to the specified value. - \parameter pen The new pen. - \parameter brightness The brightness of the new pen. - \exception INVALID_REQUEST This exception is thrown if the brightness isn't in the range - [0.1 1.0]. - \notes When a layer (or a ghost) is displayed, the graphical characteristics of this layer - (or this ghost) have been positionned. So, in principle, unless very specific needs, - there is no need to call this function. If you do so, dont forget to restore the - previous pen after use. - */ - -/*!\function void CellWidget::setBrush(const QBrush& brush, double brightness) - \behaviour This function sets the brush of this porthole to the specified value. - \parameter brush The new brush. - \parameter brightness The brightness of the new brush. - \exception INVALID_REQUEST This exception is thrown if the brightness isn't in the range - [0.1 1.0]. - \notes When a layer (or a ghost) is displayed, the graphical characteristics of this layer - (or this ghost) have been positionned. So, in principle, unless very specific needs, - there is no need to call this function. If you do so, dont forget to restore the - previous brush after use. - */ - -/*!\function void CellWidget::setBrushOrigin(const QPoint& origin) - \behaviour This function sets the brush origin of this porthole to the specified value. - \parameter origin The new brush origin. - \note When a layer (or a ghost) is displayed, the graphical characteristics of this layer - (or this ghost) have been positionned. So, in principle, unless very specific needs, - there is no need to call this function. If you do so, dont forget to restore the - previous brush origin after use. - */ - -/*!\function void CellWidget::setTrackBox(TrackBox* track) - \behaviour This function bounds this porthole with the specified track box. - \parameter track The track box to bound with this porthole (can be \NULL). - */ -//@} - -//@{ -/*!\function void CellWidget::showAllLayers() - \behaviour This function sets the visibility status of all layers to \TRUE for this porthole. - */ - -/*!\function void CellWidget::hideAllLayers() - \behaviour This function sets the visibility status of all layers to \FALSE for this porthole. - */ - -/*!\function bool CellWidget::select(const Occurrence& occurrence) - \behaviour This function selects the specified occurrence in this porthole. - \parameter occurrence The occurrence to select. - */ - -/*!\function void CellWidget::unselect(const Occurrence& occurrence) - \behaviour This function unselects the specified occurrence from this porthole. - \parameter occurrence The occurrence to unselect. - */ - -/*!\function void CellWidget::clearSelection() - \behaviour This function clears the selection. - */ - -/*!\function bool CellWidget::highlight(const Occurrence& occurrence) - \behaviour This function highlights the specified occurrence in this porthole. - \parameter occurrence The occurrence to highlight. - */ - -/*!\function void CellWidget::unhighlight(const Occurrence& occurrence) - \behaviour This function unhighlights the specified occurrence from this porthole. - \parameter occurrence The occurrence to unhighlight. - */ - -/*!\function void CellWidget::clearHighlightion() - \behaviour This function clears the highlightion. - */ - -/*!\function void CellWidget::clearPeeks() - */ - -/*!\function void CellWidget::addPeek(const Box& box) - */ - -/*!\function void CellWidget::invalidate() - \behaviour This function post an invalidation region representing the visible part of the cell - view bound to this porthole. - \example - \code - * void MyCellWidget::refresh() - * { - * invalidate(); - * redraw(); - * } - \endcode - */ - -/*!\function void CellWidget::invalidate(const QRect& screenRect) - \behaviour This convenience function post an invalidation region representing the cell view - box corresponding to a given screen rect. - \parameter screenRect The screen rectangle to invalidate. - */ - -/*!\function void CellWidget::invalidate(const Box& box) - \behaviour This function post an invalidation region representing a given cell view box. - \parameter box The cell view box to invalidate. - */ - -/*!\function void CellWidget::fitToContent(unsigned screenMargin) - \behaviour This function makes the entire cell view visible in this porthole. - \parameter screenMargin Represent the minimal number of pixel we want around the bounding - box of the cell view. - */ - -/*!\function void CellWidget::reframe(double scale) - \behaviour This function sets the scale used to display the content of this porthole to the - specified value. - \parameter scale The new scale. - \examples - \code - * void MyCellWidget::zoomIn() - * { - * reframe(getScale() * 1.2)); - * redraw(); - * } - \endcode - \code - * void MyCellWidget::zoomOut() - * { - * reframe(getScale() / 1.2)); - * redraw(); - * } - \endcode - \note This function does nothing if the new scale is null. - */ - -/*!\function void CellWidget::reframe(const Point& center) - \behaviour This function sets the center of this porthole to the specified value. - \parameter center The new center. - \example - \code - * void MyCellWidget::pan(const Point& point) - * { - * reframe(point); - * redraw(); - * } - \endcode - */ - -/*!\function void CellWidget::reframe(const Point& center, double scale) - \behaviour This function sets the center and the scale of this porthole to the specified - values. - \parameter center The new center. - \parameter scale The new scale. - \note This function does nothing if the new scale is null. - */ - -/*!\function void CellWidget::reframe(const Box& box) - \behaviour This function allows you to map a cell view region into this porthole. - \remark The aspect ratios of the cell view region and the porthole can be differents - but the function ensures that the entire region will becomes visible. - \parameter box The region for which the request is asked. - \note This function does nothing if the region is inverted. - */ - -/*!\function void CellWidget::scroll(const Unit& dx, const Unit& dy) - \behaviour This function scrolls the content of this porthole of the specified quantities. - \parameter dx The horizontal quantity. - \parameter dy The verticaly quantity. - \note The display is updated immediately (it is not differed as it will be with the - reframe or fitToContent functions). So, it is not needed to call the redraw - function to see the effects. - */ - -/*!\function void CellWidget::redraw() - \behaviour This function is called or should be called to redraw the invalidated region. - \important Nothing is done if the invalidated region is empty. - */ - -/*!\function void CellWidget::abortStartedCommand() - \behaviour This function aborts the started command. - \important Nothing is done if no command has started. - */ - -/*!\function void CellWidget::drawLine(const Unit& xo, const Unit& yo, const Unit& xe, const Unit& ye) - \behaviour This function draws the line joining the points defined by the specified - coordinates with the current pen. - \parameter xo The abscissa of the line origin. - \parameter yo The ordinate of the line origin. - \parameter xe The abscissa of the line extremity. - \parameter ye The ordinate of the line extremity. - */ - -/*!\function void CellWidget::drawLine(const Point& origin, const Point& extremity) - \behaviour This function draws the line joining the specified points with the current pen. - \parameter origin The origin of the line. - \parameter extremity The extremity of the line. - */ - -/*!\function void CellWidget::drawPolyline(const Points& points) - \behaviour This function draws the polyline joining the specified points with the current pen. - \parameter points The collection of points defining the polyline. - */ - -/*!\function void CellWidget::drawRectangle(const Unit& xMin, const Unit& yMin, const Unit& xMax, const Unit& yMax) - \behaviour This function draws the rectangle defined by the specified values with the current - pen and brush. - \parameter xMin The left bound of the rectangle. - \parameter yMin The bottom bound of the rectangle. - \parameter xMax The right bound of the rectangle. - \parameter yMax The top bound of the rectangle. - */ - -/*!\function void CellWidget::drawRectangle(const Box& box) - \behaviour This convenience function behaves essentially like the above function. - \parameter box The box which defines the limits of the rectangle. - */ - -/*!\function void CellWidget::drawPolygon(const Points& points) - \behaviour This function draws the polygon defined by the specified points with the current - pen and brush. - \parameter points The collection of points which defining the polygon. - */ - -/*!\function void CellWidget::drawText(const Box& frame, const string& text, const Direction& direction) - \behaviour This function draws the string defined by the specified text, in the specified - direction, inside the specified frame, with the specified area style and using the - current font and pen. - \nn Texts are displayed using a fixed size font. The appearence of each text depend to - the scale factor of this porthole. The frame is used to control the display of a - text. So, to be really drawn, the screen dimensions of a text should be smaller than - the dimensions of the frame. - \parameter frame Defines the maximal dimensions of the text. - \parameter text Defines the string that should be drawn. - \parameter direction Defines the direction of the text. - */ - -/*!\function void CellWidget::drawText(const Box& frame, const Name& name, const Direction& direction) - \behaviour This convenience function behaves essentially like the above function. - \parameter frame Defines the maximal dimensions of the name. - \parameter name Defines the string that should be drawn. - \parameter direction Defines the direction of the text. - */ -//@} - - - -//CLOSE_MY_NAMESPACE -// -//USING_MY_NAMESPACE - -#endif // H_CellWidget - -// ************************************************************************************************* +# endif diff --git a/hurricane/src/viewer/DisplayStyle.cpp b/hurricane/src/viewer/DisplayStyle.cpp new file mode 100644 index 00000000..e60c859d --- /dev/null +++ b/hurricane/src/viewer/DisplayStyle.cpp @@ -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 ); +} + + +} diff --git a/hurricane/src/viewer/DisplayStyle.h b/hurricane/src/viewer/DisplayStyle.h new file mode 100644 index 00000000..acf65c02 --- /dev/null +++ b/hurricane/src/viewer/DisplayStyle.h @@ -0,0 +1,101 @@ + +// -*- C++ -*- + + +# ifndef __DISPLAYSTYLE_H__ +# define __DISPLAYSTYLE_H__ + + +# include +# include + +# include +# include +# include + +# 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 StyleMap; + typedef map::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 diff --git a/hurricane/src/viewer/LayersList.cpp b/hurricane/src/viewer/LayersList.cpp new file mode 100644 index 00000000..52c178c6 --- /dev/null +++ b/hurricane/src/viewer/LayersList.cpp @@ -0,0 +1,134 @@ + +// -*- C++ -*- + + +# include + +# include +# include +# include +# include +# include +# include + +# 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& 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. diff --git a/hurricane/src/viewer/LayersList.h b/hurricane/src/viewer/LayersList.h new file mode 100644 index 00000000..d3abed24 --- /dev/null +++ b/hurricane/src/viewer/LayersList.h @@ -0,0 +1,79 @@ + +// -*- C++ -*- + + +# ifndef __LAYERSLIST__ +# define __LAYERSLIST__ + +# include +# include +# include +# include + +# 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 _entries; + QPushButton* _showAll; + QPushButton* _hideAll; + + public: + LayersList ( CellWidget* cellWidget ); + + public: + CellWidget* getCellWidget () { return _cellWidget; }; + vector& getEntries () { return _entries; }; + bool isVisible ( size_t index ); + + public slots: + void showAll (); + void hideAll (); + }; + + +} // End of Hurricane namespace. + + +# endif diff --git a/hurricane/src/viewer/LayersWidget.cpp b/hurricane/src/viewer/LayersWidget.cpp deleted file mode 100644 index 8038944a..00000000 --- a/hurricane/src/viewer/LayersWidget.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "DataBase.h" -#include "Technology.h" -#include "BasicLayer.h" -using namespace Hurricane; - -#include -#include -#include - -#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::iterator wsit = widgets.begin(); - wsit != widgets.end(); - wsit++) { - delete *wsit; - } -} diff --git a/hurricane/src/viewer/LayersWidget.h b/hurricane/src/viewer/LayersWidget.h deleted file mode 100644 index a797029b..00000000 --- a/hurricane/src/viewer/LayersWidget.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef LAYERS_WIDGET_H -#define LAYERS_WIDGET_H - -#include -using namespace std; - -#include - -class LayersWidget : public QWidget { - Q_OBJECT - - public : - LayersWidget(QWidget *parent = 0); - ~LayersWidget(); - private: - set widgets; -}; - -#endif diff --git a/hurricane/src/viewer/ScreenLayer.cpp b/hurricane/src/viewer/ScreenLayer.cpp new file mode 100644 index 00000000..1d895cba --- /dev/null +++ b/hurricane/src/viewer/ScreenLayer.cpp @@ -0,0 +1,72 @@ + +// -*- C++ -*- + + +# include + +# 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. diff --git a/hurricane/src/viewer/ScreenLayer.h b/hurricane/src/viewer/ScreenLayer.h new file mode 100644 index 00000000..520fe1a8 --- /dev/null +++ b/hurricane/src/viewer/ScreenLayer.h @@ -0,0 +1,89 @@ + +// -*- C++ -*- + + +# ifndef __SCREENLAYER_H__ +# define __SCREENLAYER_H__ + +# include +# include +# include +# include + +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 diff --git a/hurricane/src/viewer/ScreenUtilities.cpp b/hurricane/src/viewer/ScreenUtilities.cpp new file mode 100644 index 00000000..ba63a9c4 --- /dev/null +++ b/hurricane/src/viewer/ScreenUtilities.cpp @@ -0,0 +1,84 @@ + +// -*- C++ -*- + + +# include + +# 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 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. diff --git a/hurricane/src/viewer/ScreenUtilities.h b/hurricane/src/viewer/ScreenUtilities.h new file mode 100644 index 00000000..6f349fc7 --- /dev/null +++ b/hurricane/src/viewer/ScreenUtilities.h @@ -0,0 +1,31 @@ + +// -*- C++ -*- + + +# ifndef __SCREENUTILITIES_H__ +# define __SCREENUTILITIES_H__ + +# include +# include + +# 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 diff --git a/hurricane/src/viewer/View.cpp b/hurricane/src/viewer/View.cpp deleted file mode 100644 index 1bfd319f..00000000 --- a/hurricane/src/viewer/View.cpp +++ /dev/null @@ -1,1811 +0,0 @@ -// **************************************************************************************************** -// File: View.cpp -// Authors: R. Escassut -// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved -// **************************************************************************************************** -// 21-10-2003 Alignment BULL-LIP6 (Lip6 addded DisplaySlots) (added VisualMaps) - -#include "View.h" -#include "DataBase.h" -#include "Cell.h" -#include "Technology.h" -#include "CompositeLayer.h" -#include "Selector.h" -#include "VisualMap.h" -#include "DisplaySlot.h" -#include "Go.h" -#include "Command.h" -#include "Error.h" -#include "Interruption.h" - -namespace Hurricane { - - - -// **************************************************************************************************** -// Variables -// **************************************************************************************************** - -static View* DRAG_VIEW = NULL; -static unsigned DRAG_BUTTON = 0; -static bool IN_AUTO_SCROLL = false; - -static unsigned SIZE = 0; -static GdkPoint* POINTS = NULL; - -GdkColor View::_backgroundColor = { 0, 50*255, 50*255, 50*255 }; -GdkColor View::_foregroundColor = { 0, 255*255, 255*255, 255*255 }; -GdkColor View::_rubberColor = { 0, 192*255, 0*255, 192*255 }; -GdkColor View::_phantomColor = { 0, 139*255, 134*255, 130*255 }; -GdkColor View::_boundaryColor = { 0, 208*255, 199*255, 192*255 }; -GdkColor View::_markerColor = { 0, 80*255, 250*255, 80*255 }; -GdkColor View::_selectionDrawColor = { 0, 255*255, 255*255, 255*255 }; -GdkColor View::_selectionFillColor = { 0, 255*255, 255*255, 255*255 }; -GdkColor View::_gridColor = { 0, 255*255, 255*255, 255*255 }; -GdkColor View::_spotColor = { 0, 255*255, 255*255, 255*255 }; -GdkColor View::_ghostColor = { 0, 255*255, 255*255, 255*255 }; - - -// **************************************************************************************************** -// Utilitarians -// **************************************************************************************************** - -static GdkPixmap* GetPixmap(const ScreenUnit& width, const ScreenUnit& height) -// *************************************************************************** -{ - static int WIDTH = 0; - static int HEIGHT = 0; - static GdkPixmap* PIXMAP = NULL; - if (!PIXMAP || (WIDTH < width) || (HEIGHT < height)) { - if (PIXMAP) gdk_pixmap_unref(PIXMAP); - WIDTH = width; - HEIGHT = height; - GdkWindow* window = gtk_get_window(); - PIXMAP = gdk_pixmap_new(window, WIDTH, HEIGHT, gdk_window_get_visual(window)->depth); - } - return PIXMAP; -} - - - -// **************************************************************************************************** -// Callbacks -// **************************************************************************************************** - -static void OnExpose(GtkWidget* drawingArea, GdkEventExpose* event, View* view) -// **************************************************************************** -{ - GdkRectangle area = event->area; - view->_OnExpose(area.x, area.y, area.width, area.height, (event->count == 0)); -} - -static void OnConfigure(GtkWidget* drawingArea, GdkEventConfigure* event, View* view) -// ********************************************************************************** -{ - view->_OnResize(event->width, event->height); -} - -static void OnEnterNotify(GtkWidget* drawingArea, GdkEventCrossing* event, View* view) -// *********************************************************************************** -{ - if (!DRAG_VIEW || (DRAG_VIEW == view)) { - ScreenUnit screenX = (ScreenUnit)event->x; - ScreenUnit screenY = (ScreenUnit)event->y; - Point position(GetOnGridUnit(view->GetX(screenX)), GetOnGridUnit(view->GetY(screenY))); - view->_OnMouseEnter(position); - } -} - -static void OnMotionNotify(GtkWidget* drawingArea, GdkEventMotion* event, View* view) -// ********************************************************************************** -{ - if (!DRAG_VIEW || (DRAG_VIEW == view)) { - ScreenUnit screenX = (ScreenUnit)event->x; - ScreenUnit screenY = (ScreenUnit)event->y; - - if ((DRAG_VIEW == view) && view->AutoScrollIsEnabled()) { - ScreenUnit screenDx = 0; - if (screenX < 0) - screenDx = screenX; - else - if (view->GetScreenWidth() < screenX) - screenDx = screenX - view->GetScreenWidth(); - ScreenUnit screenDy = 0; - if (screenY < 0) - screenDy = screenY; - else - if (view->GetScreenHeight() < screenY) - screenDy = screenY - view->GetScreenHeight(); - if (screenDx || screenDy) { - IN_AUTO_SCROLL = true; - view->Scroll(- view->GetSize(screenDx), view->GetSize(screenDy)); - view->Update(); - IN_AUTO_SCROLL = false; - } - screenX = (ScreenUnit)event->x; - screenY = (ScreenUnit)event->y; - } - - Point position(GetOnGridUnit(view->GetX(screenX)), GetOnGridUnit(view->GetY(screenY))); - view->_OnMouseMove(position, event->state); - } - - // to enable next pointer motion notify event - gint x, y; - GdkModifierType mt; - gdk_window_get_pointer(drawingArea->window, &x, &y, &mt); - // see GDK_POINTER_MOTION_HINT_MASK to understand previous lines -} - -static void OnLeaveNotify(GtkWidget* drawingArea, GdkEventCrossing* event, View* view) -// *********************************************************************************** -{ - if (!DRAG_VIEW || (DRAG_VIEW == view)) { - ScreenUnit screenX = (ScreenUnit)event->x; - ScreenUnit screenY = (ScreenUnit)event->y; - Point position(GetOnGridUnit(view->GetX(screenX)), GetOnGridUnit(view->GetY(screenY))); - view->_OnMouseLeave(position); - } -} - -static void OnButtonPress(GtkWidget* drawingArea, GdkEventButton* event, View* view) -// ********************************************************************************* -{ - unsigned button = event->button; - ScreenUnit screenX = (ScreenUnit)event->x; - ScreenUnit screenY = (ScreenUnit)event->y; - Point position(GetOnGridUnit(view->GetX(screenX)), GetOnGridUnit(view->GetY(screenY))); - if ( ( button == 4 ) || ( button == 5 ) ) - { - view->_OnButtonPress(button, position, event->state); - } - else if (!DRAG_VIEW) { - DRAG_BUTTON = button; - view->_OnButtonPress(button, position, event->state); - DRAG_VIEW = view; - } -} - -static void OnButtonRelease(GtkWidget* drawingArea, GdkEventButton* event, View* view) -// *********************************************************************************** -{ - unsigned button = event->button; - ScreenUnit screenX = (ScreenUnit)event->x; - ScreenUnit screenY = (ScreenUnit)event->y; - Point position(GetOnGridUnit(view->GetX(screenX)), GetOnGridUnit(view->GetY(screenY))); - if ( ( button == 4 ) || ( button == 5 ) ) - { - view->_OnButtonRelease(button, position, event->state); - } - else if (DRAG_VIEW && ( button == DRAG_BUTTON ) ) { - view->_OnButtonRelease(button, position, event->state); - DRAG_VIEW = NULL; - } -} - - - -// **************************************************************************************************** -// View implementation -// **************************************************************************************************** - -View::View() -// ********* -: Inherit(), - _frame(NULL), - _drawingArea(NULL), - _center(0, 0), - _scale(1), - _backCenter(0, 0), - _backScale(1), - _screenDx(0), - _screenDy(0), - _screenWidth(1), - _screenHeight(1), - _hasBeenExposed(false), - _screenUpdateArea(), - _clipBox(), - _drawable(NULL), - _backgroundGC(NULL), - _foregroundGC(NULL), - _phantomGC(NULL), - _boundaryGC(NULL), - _rubberGC(NULL), - _markerGC(NULL), - _selectionDrawGC(NULL), - _selectionFillGC(NULL), - _gridGC(NULL), - _spotGC(NULL), - _ghostGC(NULL), - _drawGC(NULL), - _fillGC(NULL), - _commandMap(), - _gridIsVisible(true), - _gridDisplayThreshold(6), - _autoScrollIsEnabled(true), - _doubleBufferingIsEnabled(false), - _phantomsAreVisible(true), - _boundariesAreVisible(true), - _rubbersAreVisible(false), - _markersAreVisible(true), - _cutPointsAreVisible(false), - _selectionIsVisible(true), - _displaySlotsAreVisible(true), - _visualMapsAreVisible(false), - _spotIsVisible(false), - _spotIsDrawable(false), - _spotPosition(), - _visibleBasicLayersMask(~0), - _selectorSet(), - _rubberDisplayType(), - _isTextVisible(false), - _nextOfCellViewSet(NULL) -{ -} - -Unit View::GetX(const ScreenUnit& screenX) const -// ********************************************* -{ - return GetUnit((screenX - _screenDx) / _scale); -} - -Unit View::GetY(const ScreenUnit& screenY) const -// ********************************************* -{ - return GetUnit(((_screenHeight - screenY) - _screenDy) / _scale); -} - -Unit View::GetSize(const ScreenUnit& screenSize) const -// *************************************************** -{ - return GetUnit(screenSize / _scale); -} - -Point View::GetPoint(const ScreenPoint& screenPoint) const -// ******************************************************* -{ - return Point(GetX(screenPoint.GetX()), GetY(screenPoint.GetY())); -} - -Box View::GetBox(const ScreenBox& screenBox) const -// *********************************************** -{ - return Box(GetX(screenBox.GetXMin()), - GetY(screenBox.GetYMin()), - GetX(screenBox.GetXMax()), - GetY(screenBox.GetYMax())); -} - -ScreenUnit View::GetScreenX(const Unit& x) const -// ********************************************* -{ - return _screenDx + (ScreenUnit)(GetValue(x) * _scale); -} - -ScreenUnit View::GetScreenY(const Unit& y) const -// ********************************************* -{ - return _screenHeight - (_screenDy + (ScreenUnit)(GetValue(y) * _scale)); -} - -ScreenUnit View::GetScreenSize(const Unit& size) const -// *************************************************** -{ - return (ScreenUnit)(GetValue(size) * _scale); -} - -ScreenPoint View::GetScreenPoint(const Point& point) const -// ******************************************************* -{ - return Point(GetScreenX(point.GetX()), GetScreenY(point.GetY())); -} - -ScreenBox View::GetScreenBox(const Box& box) const -// *********************************************** -{ - return Box(GetScreenX(box.GetXMin()), - GetScreenY(box.GetYMin()), - GetScreenX(box.GetXMax()), - GetScreenY(box.GetYMax())); -} - -Box View::GetClientArea() const -// **************************** -{ - Box area(-1, -1, 1, 1); - Cell* cell = GetCell(); - if (cell) { - Box boundingBox = cell->GetBoundingBox(); - if (!boundingBox.IsEmpty()) area = boundingBox; - } - GetTransformation().ApplyOn(area); - return area; -} - -Box View::GetVisibleArea() const -// ***************************** -{ - return Box(GetX(0), GetY(0), GetX(_screenWidth), GetY(_screenHeight)); -} - -Command* View::GetCommand(unsigned button) const -// ********************************************* -{ - CommandMap::const_iterator it = _commandMap.find(button); - return (it != _commandMap.end()) ? (*it).second : NULL; -} - -BasicLayers View::GetVisibleBasicLayers() const -// ******************************************** -{ - Technology* technology = GetDataBase()->GetTechnology(); - return (technology) ? technology->GetBasicLayers(_visibleBasicLayersMask) : BasicLayers(); -} - -bool View::IsVisible(BasicLayer* basicLayer) const -// *********************************************** -{ - if (!basicLayer) - throw Error("Can't evaluate if is visible : null basic layer"); - - return (basicLayer->GetMask() & _visibleBasicLayersMask); -} - -bool View::IsSelected(Go* go) const -// ******************************** -{ - if (!go) - throw Error("Can't evaluate if is selected : null go"); - - Occurrence occurrence = go; - return IsSelected(occurrence); -} - -bool View::IsSelected(const Occurrence& occurrence) const -// **************************************************** -{ - for_each_selector(selector, GetSelectors()) { - if (selector->GetOccurrence() == occurrence) return true; - end_for; - } - return false; -} - -void View::SetCell(Cell* newCell) -// ****************************** -{ - Cell* oldCell = GetCell(); - if (newCell != oldCell) { - - UnselectAll(); - - for_each_command(command, GetCommands()) command->UninstallFrom(this); end_for; - - _SetCell(newCell); - _SetTransformation(Transformation()); - - if (_hasBeenExposed) FitToContent(); - - _backCenter = _center; - _backScale = _scale; - } -} - -void View::SetTransformation(const Transformation& newTransformation) -// ****************************************************************** -{ - Transformation oldTransformation = GetTransformation(); - if (newTransformation != oldTransformation) { - _SetTransformation(newTransformation); - if (GetCell()) FitToContent(); - _backCenter = _center; - _backScale = _scale; - } -} - -void View::ShowGrid() -// ****************** -{ - if (!_gridIsVisible) { - _gridIsVisible = true; - if (GridIsDrawable()) Invalidate(); - } -} - -void View::HideGrid() -// ****************** -{ - if (_gridIsVisible) { - _gridIsVisible = false; - if (GridIsDrawable()) Invalidate(); - } -} - -void View::SetGridDisplayThreshold(const ScreenUnit& threshold) -// ************************************************************ -{ - if (threshold < 3) - throw Error("Can't set grid display threshold : too small value"); - - if (threshold != _gridDisplayThreshold) { - _gridDisplayThreshold = threshold; - Invalidate(); - } -} - -void View::SetVisibleBasicLayersMask(const Layer::Mask& visibleBasicLayersMask) -// **************************************************************************** -{ - if (_visibleBasicLayersMask != visibleBasicLayersMask) { - _visibleBasicLayersMask = visibleBasicLayersMask; - Invalidate(); - } -} - -void View::ShowPhantoms() -// ********************** -{ - if (!_phantomsAreVisible) { - _phantomsAreVisible = true; - Invalidate(); - } -} - -void View::HidePhantoms() -// ********************** -{ - if (_phantomsAreVisible) { - _phantomsAreVisible = false; - Invalidate(); - } -} - -void View::ShowBoundaries() -// ************************ -{ - if (!_boundariesAreVisible) { - _boundariesAreVisible = true; - Invalidate(); - } -} - -void View::HideBoundaries() -// ************************ -{ - if (_boundariesAreVisible) { - _boundariesAreVisible = false; - Invalidate(); - } -} - -void View::ShowCutPoints() -// *********************** -{ - if (!_cutPointsAreVisible) { - _cutPointsAreVisible = true; - Invalidate(); - } -} - -void View::HideCutPoints() -// *********************** -{ - if (_cutPointsAreVisible) { - _cutPointsAreVisible = false; - Invalidate(); - } -} - -void View::ShowRubbers() -// ********************* -{ - if (!_rubbersAreVisible) { - _rubbersAreVisible = true; - Invalidate(); - } -} - -void View::HideRubbers() -// ********************* -{ - if (_rubbersAreVisible) { - _rubbersAreVisible = false; - Invalidate(); - } -} - -void View::ShowMarkers() -// ********************* -{ - if (!_markersAreVisible) { - _markersAreVisible = true; - Invalidate(); - } -} - -void View::HideMarkers() -// ********************* -{ - if (_markersAreVisible) { - _markersAreVisible = false; - Invalidate(); - } -} - -void View::ShowSelection() -// *********************** -{ - if (!_selectionIsVisible) { - _selectionIsVisible = true; - if (HasSomethingSelected()) Invalidate(); - } -} - -void View::HideSelection() -// *********************** -{ - if (_selectionIsVisible) { - _selectionIsVisible = false; - if (HasSomethingSelected()) Invalidate(); - } -} - -void View::ShowDisplaySlots() -// ************************** -{ - if (!_displaySlotsAreVisible) { - _displaySlotsAreVisible = true; - Invalidate(); - } -} - -void View::HideDisplaySlots() -// ************************** -{ - if (_displaySlotsAreVisible) { - _displaySlotsAreVisible = false; - Invalidate(); - } -} - -void View::ShowVisualMaps() -// ************************** -{ - if (!_visualMapsAreVisible) { - _visualMapsAreVisible = true; - Invalidate(); - } -} - -void View::HideVisualMaps() -// ************************** -{ - if (_visualMapsAreVisible) { - _visualMapsAreVisible = false; - Invalidate(); - } -} - -void View::Show(BasicLayer* basicLayer) -// ************************************ -{ - if (!basicLayer) - throw Error("Can't show basic layer : null basic layer"); - - if (!IsVisible(basicLayer)) { - _visibleBasicLayersMask |= basicLayer->GetMask(); - Invalidate(); - } -} - -void View::Hide(BasicLayer* basicLayer) -// ************************************ -{ - if (!basicLayer) - throw Error("Can't hide basic layer : null basic layer"); - - if (IsVisible(basicLayer)) { - _visibleBasicLayersMask &= ~basicLayer->GetMask(); - Invalidate(); - } -} - -void View::ShowAllLayers() -// *********************** -{ - SetVisibleBasicLayersMask(~0); -} - -void View::HideAllLayers() -// *********************** -{ - SetVisibleBasicLayersMask(0); -} - -void View::Select(Go* go) -// ********************** -{ - if (!go) - throw Error("Can't select go : null go"); - - Occurrence occurrence = go; - Select(occurrence); -} - -void View::Unselect(Go* go) -// ************************ -{ - if (!go) - throw Error("Can't unselect go : null go"); - - Occurrence occurrence = go; - Unselect(occurrence); -} - -void View::Select(Occurrence& occurrence) -// ************************************ -{ - if (!occurrence.IsValid()) - throw Error("Can't select occurrence : invalid occurrence"); - - if (occurrence.GetOwnerCell() != GetCell()) - throw Error("Can't select occurrence : incompatible occurrence"); - - Selector* selector = (Selector*)occurrence.GetProperty(Selector::GetPropertyName()); - if (!selector) - selector = Selector::_Create(occurrence); - else - if (!is_a(selector)) - throw Error("Abnormal property named " + GetString(Selector::GetPropertyName())); - - selector->_AttachTo(this); - Invalidate(GetTransformation().GetBox(occurrence.GetBoundingBox())); -} - -void View::Unselect(Occurrence& occurrence) -// ************************************** -{ - if (!occurrence.IsValid()) - throw Error("Can't unselect occurrence : invalid occurrence"); - - if (occurrence.GetOwnerCell() != GetCell()) - throw Error("Can't unselect occurrence : incompatible occurrence"); - - Selector* selector = (Selector*)occurrence.GetProperty(Selector::GetPropertyName()); - if (selector) { - if (!is_a(selector)) - throw Error("Abnormal property named " + GetString(Selector::GetPropertyName())); - - selector->_DetachFrom(this); - Invalidate(GetTransformation().GetBox(occurrence.GetBoundingBox())); - } -} - -void View::UnselectAll() -// ********************* -{ - Box boundingBox; - - for_each_selector(selector, GetSelectors()) { - boundingBox.Merge(selector->GetOccurrence().GetBoundingBox()); - selector->_DetachFrom(this); - end_for; - } - - if (!boundingBox.IsEmpty()) - Invalidate(GetTransformation().GetBox(boundingBox)); -} - -void View::Invalidate(const ScreenUnit& screenXo, const ScreenUnit& screenYo, const ScreenUnit& screenXe, const ScreenUnit& screenYe) -// **************************************************************************************************** -{ - if (_drawingArea && _drawingArea->window) { - ScreenBox screenBox = Box(0, 0, _screenWidth, _screenHeight).Inflate(1); - ScreenBox updateBox = Box(screenXo, screenYo, screenXe, screenYe).Inflate(1); - _screenUpdateArea.Merge(screenBox.GetIntersection(updateBox)); - } -} - -void View::Invalidate() -// ******************** -{ - if (_drawingArea && _drawingArea->window) - _screenUpdateArea = ScreenBox(0, 0, _screenWidth, _screenHeight); -} - -void View::Invalidate(const Box& area) -// *********************************** -{ - if (!area.IsEmpty()) - Invalidate(GetScreenX(area.GetXMin()), - GetScreenY(area.GetYMin()), - GetScreenX(area.GetXMax()), - GetScreenY(area.GetYMax())); -} - -bool View::Update(bool useDoubleBuffering) -// *************************************** -{ - if (_screenUpdateArea.IsEmpty()) return false; - - if (!_drawingArea) return false; - - GdkWindow* window = _drawingArea->window; - - if (!window) return false; - - _HideSpot(); - - for_each_command(command, GetCommands()) { - if (!DRAG_VIEW || (DRAG_VIEW == this)) - DrawGhost(command); - end_for; - } - - _drawable = window; - _drawGC = _foregroundGC; - _fillGC = _foregroundGC; - - _clipBox = Box(GetX(-2), GetY(_screenHeight + 2), GetX(_screenWidth + 2), GetY(-2)); - - if (IN_AUTO_SCROLL || useDoubleBuffering || _doubleBufferingIsEnabled) - _drawable = GetPixmap(_screenWidth, _screenHeight); - - _screenUpdateArea.Inflate(5); - - static GdkCursor* sprayCanCursor = gdk_cursor_new(GDK_SPRAYCAN); - gdk_window_set_cursor(window, sprayCanCursor); - - _Repaint(GetBox(_screenUpdateArea)); - - static GdkCursor* leftPtrCursor = gdk_cursor_new(GDK_LEFT_PTR); - gdk_window_set_cursor(window, leftPtrCursor); - - if (_drawable != window) { - if (IN_AUTO_SCROLL) _screenUpdateArea = Box(0, 0, _screenWidth, _screenHeight); - gdk_window_copy_area - (window, - _foregroundGC, - _screenUpdateArea.GetXMin(), _screenUpdateArea.GetYMin(), - _drawable, - _screenUpdateArea.GetXMin(), _screenUpdateArea.GetYMin(), - _screenUpdateArea.GetWidth(), _screenUpdateArea.GetHeight()); - } - - _fillGC = _foregroundGC; - _drawGC = _foregroundGC; - _drawable = window; - - _screenUpdateArea = ScreenBox(); - - for_each_command(command, GetCommands()) { - if (!DRAG_VIEW || (DRAG_VIEW == this)) - DrawGhost(command); - end_for; - } - - _ShowSpot(); - - return true; -} - -void View::Refresh(bool useDoubleBuffering) -// **************************************** -{ - Invalidate(); - Update(useDoubleBuffering); -} - -void View::CheckForDisplayInterruption() -// ************************************* -{ - if (_DisplayHasBeenAborted()) throw Interruption("Display"); -} - -void View::VerticalScroll(const Unit& dy) -// ************************************** -{ - Reframe(Point(_center).Translate(0, -dy)); -} - -void View::HorizontalScroll(const Unit& dx) -// **************************************** -{ - Reframe(Point(_center).Translate(-dx, 0)); -} - -void View::Scroll(const Unit& dx, const Unit& dy) -// ********************************************** -{ - Reframe(Point(_center).Translate(-dx, -dy)); -} - -void View::Reframe(const Point& center) -// ************************************ -{ - Reframe(center, _scale); -} - -void View::Reframe(const Point& center, double scale) -// ************************************************** -{ - if ((0 < scale) && ((center != _center) || (scale != _scale))) { - _backCenter = _center; - _backScale = _scale; - _center = center; - _scale = scale; - _screenDx = -(int)((GetValue(_center.GetX()) - (_screenWidth / (_scale * 2))) * _scale); - _screenDy = -(int)((GetValue(_center.GetY()) - (_screenHeight / (_scale * 2))) * _scale); - Invalidate(); - } -} - -void View::Reframe(const Box& area) -// ******************************** -{ - if (!area.IsEmpty() && !area.IsFlat()) - Reframe( - area.GetCenter(), - min(_screenWidth / GetValue(area.GetWidth()), _screenHeight / GetValue(area.GetHeight()))); -} - -void View::ReframeBack() -// ********************* -{ - // _backCenter is mofified inside the Reframe function - // so we should give a copy to have a good behaviour - Reframe(Point(_backCenter), _backScale); -} - -void View::FitToContent() -// ********************** -{ - Box area = GetClientArea(); - - Point center = _center; - double scale = _scale; - - Reframe(area); - area.Inflate(GetSize(10)); - Reframe(area); - - _backCenter = center; - _backScale = scale; - - _hasBeenExposed = true; -} - -void View::DrawGhost(Command* command) -// *********************************** -{ - if (command) { - GdkGC* oldDrawGC = _drawGC; - GdkGC* oldFillGC = _fillGC; - _drawGC = _ghostGC; - _fillGC = _ghostGC; - command->_OnDrawGhost(this); - _drawGC = oldDrawGC; - _fillGC = oldFillGC; - } -} - -void View::DrawPoint(const Unit& x, const Unit& y, const ScreenUnit& screenSize) -// ***************************************************************************** -{ - if (!_drawable) return; - - if (x < _clipBox.GetXMin()) return; - else if (_clipBox.GetXMax() < x) return; - if (y < _clipBox.GetYMin()) return; - else if (_clipBox.GetYMax() < y) return; - - ScreenUnit screenX = GetScreenX(x); - ScreenUnit screenY = GetScreenY(y); - - static gint ANGLE = 360 * 64; - gdk_draw_arc(_drawable, - _drawGC, - true, - screenX - screenSize, - screenY - screenSize, - (screenSize * 2), - (screenSize * 2), - 0, - ANGLE); -} - -void View::DrawPoint(const Point& position, const ScreenUnit& screenSize) -// ********************************************************************** -{ - DrawPoint(position.GetX(), position.GetY(), screenSize); -} - -void View::DrawLine(const Unit& xo, const Unit& yo, const Unit& xe, const Unit& ye) -// ******************************************************************************** -{ - if (!_drawable) return; - - Unit cXo = xo; - Unit cYo = yo; - Unit cXe = xe; - Unit cYe = ye; - - if (_ClipLine(cXo, cYo, cXe, cYe)) { - gdk_draw_line(_drawable, - _drawGC, - GetScreenX(cXo), - GetScreenY(cYo), - GetScreenX(cXe), - GetScreenY(cYe)); - } -} - -void View::DrawLine(const Point& origin, const Point& extremity) -// ************************************************************* -{ - DrawLine(origin.GetX(), origin.GetY(), extremity.GetX(), extremity.GetY()); -} - -void View::DrawLines(const vector& points, unsigned size) -// ************************************************************* -{ - // PROVISOIREMENT : doit faire le clipping - - if (!_drawable || !size) return; - - if (SIZE < size) { - if (POINTS) delete[] POINTS; - SIZE = size; - POINTS = new GdkPoint[SIZE]; - } - - for (unsigned i = 0; i < size; i++) { - POINTS[i].x = GetScreenX(points[i].GetX()); - POINTS[i].y = GetScreenY(points[i].GetY()); - } - - gdk_draw_lines(_drawable, _drawGC, POINTS, size); -} - -void View::DrawPolygon(const vector& points, unsigned size) -// *************************************************************** -{ - // PROVISOIREMENT : doit faire le clipping - - if (!_drawable || !size) return; - - if (SIZE < size) { - if (POINTS) delete[] POINTS; - SIZE = size; - POINTS = new GdkPoint[SIZE]; - } - - for (unsigned i = 0; i < size; i++) { - POINTS[i].x = GetScreenX(points[i].GetX()); - POINTS[i].y = GetScreenY(points[i].GetY()); - } - - gdk_draw_polygon(_drawable, _drawGC, false, POINTS, size); -} - -void View::DrawRectangle(const Unit& xo, const Unit& yo, const Unit& xe, const Unit& ye) -// ************************************************************************************* -{ - DrawRectangle(Box(xo, yo, xe, ye)); -} - -void View::DrawRectangle(const Point& origin, const Point& extremity) -// ****************************************************************** -{ - DrawRectangle(Box(origin, extremity)); -} - -void View::DrawRectangle(const Box& box) -// ************************************* -{ - if (!_drawable) return; - - Box cBox = box; - - if (_ClipBox(cBox)) { - Box screenBox = GetScreenBox(cBox); - gdk_draw_rectangle(_drawable, - _drawGC, - false, - screenBox.GetXMin(), - screenBox.GetYMin(), - screenBox.GetWidth(), - screenBox.GetHeight()); - } -} - -void View::DrawCircle(const Unit& x, const Unit& y, const Unit& radius) -// ******************************************************************** -{ - if (!_drawable) return; - - ScreenUnit screenX = GetScreenX(x); - ScreenUnit screenY = GetScreenY(y); - ScreenUnit screenRadius = GetScreenSize(radius); - - static gint ANGLE = 360 * 64; - gdk_draw_arc(_drawable, - _drawGC, - false, - screenX - screenRadius, - screenY - screenRadius, - (screenRadius * 2), - (screenRadius * 2), - 0, - ANGLE); -} - -void View::DrawCircle(const Point& center, const Unit& radius) -// *********************************************************** -{ - DrawCircle(center.GetX(), center.GetY(), radius); -} - -void View::DrawString(const string& text, const Unit& x, const Unit& y) -// ******************************************************************** -{ - if (!_drawable) return; - - Unit X = x; - Unit Y = y; - - GdkFont * police = gdk_font_load ( "-*-lucidatypewriter-bold-*-*-*-*-120-*-*-*-*-iso8859-1" ); - - gint textWidth = gdk_string_width ( police, text.c_str() ); - gint textHeight = gdk_string_height ( police, text.c_str() ); - - gdk_draw_string ( _drawable, - police, - _drawGC, - GetScreenX( X ) + 2, - GetScreenY( Y ) + 2, - text.c_str() - ); - gdk_draw_rectangle ( _drawable, - _drawGC, - false, - GetScreenX( X ), - GetScreenY( Y ) - textHeight, - textWidth + 4, - textHeight + 4 - ); -} - -void View::FillPolygon(const vector& points, unsigned size, bool solid) -// *************************************************************************** -{ - // PROVISOIREMENT : doit faire le clipping - - if (!_drawable || !size) return; - - if (SIZE < size) { - if (POINTS) delete[] POINTS; - SIZE = size; - POINTS = new GdkPoint[SIZE]; - } - - for (unsigned i = 0; i < size; i++) { - POINTS[i].x = GetScreenX(points[i].GetX()); - POINTS[i].y = GetScreenY(points[i].GetY()); - } - - gdk_draw_polygon(_drawable, ((solid) ? _drawGC : _fillGC), true, POINTS, size); -} - -void View::FillRectangle(const Unit& xo, const Unit& yo, const Unit& xe, const Unit& ye, bool solid) -// ************************************************************************************************* -{ - FillRectangle(Box(xo, yo, xe, ye), solid); -} - -void View::FillRectangle(const Point& origin, const Point& extremity, bool solid) -// ***************************************************************************** -{ - FillRectangle(Box(origin, extremity), solid); -} - -void View::FillRectangle(const Box& box, bool solid) -// ************************************************* -{ - if (!_drawable) return; - - Box cBox = box; - - if (_ClipBox(cBox)) { - Box screenBox = GetScreenBox(cBox); - gdk_draw_rectangle(_drawable, - (solid) ? _drawGC : _fillGC, - true, - screenBox.GetXMin(), - screenBox.GetYMin(), - screenBox.GetWidth() + 1, - screenBox.GetHeight() + 1); - } -} - -void View::FillCircle(const Unit& x, const Unit& y, const Unit& radius, bool solid) -// ******************************************************************************** -{ - if (!_drawable) return; - - ScreenUnit screenX = GetScreenX(x); - ScreenUnit screenY = GetScreenY(y); - ScreenUnit screenRadius = GetScreenSize(radius); - - static gint ANGLE = 360 * 64; - gdk_draw_arc(_drawable, - (solid) ? _drawGC : _fillGC, - true, - screenX - screenRadius, - screenY - screenRadius, - (screenRadius * 2), - (screenRadius * 2), - 0, - ANGLE); -} - -void View::FillCircle(const Point& center, const Unit& radius, bool solid) -// *********************************************************************** -{ - FillCircle(center.GetX(), center.GetY(), radius, solid); -} - -void View::_PostCreate() -// ********************* -{ - _frame = gtk_table_new(1, 1, false); - gtk_container_set_border_width(GTK_CONTAINER(_frame), 2); - - gtk_signal_connect(GTK_OBJECT(_frame), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &_frame); - - _drawingArea = gtk_drawing_area_new(); - gtk_table_attach - (GTK_TABLE(_frame), _drawingArea, 0, 1, 0, 1, GTK_FILL_EXPAND, GTK_FILL_EXPAND, 0, 0); - - gtk_signal_connect - (GTK_OBJECT(_drawingArea), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &_drawingArea); - - gtk_signal_connect - (GTK_OBJECT(_drawingArea), "expose_event", GTK_SIGNAL_FUNC(OnExpose), this); - - gtk_signal_connect - (GTK_OBJECT(_drawingArea), "configure_event", GTK_SIGNAL_FUNC(OnConfigure), this); - - gtk_signal_connect - (GTK_OBJECT(_drawingArea), "enter_notify_event", GTK_SIGNAL_FUNC(OnEnterNotify), this); - gtk_widget_add_events(GTK_WIDGET(_drawingArea), GDK_ENTER_NOTIFY_MASK); - - gtk_signal_connect - (GTK_OBJECT(_drawingArea), "motion_notify_event", GTK_SIGNAL_FUNC(OnMotionNotify), this); - gtk_widget_add_events - (GTK_WIDGET(_drawingArea), GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); - - gtk_signal_connect - (GTK_OBJECT(_drawingArea), "leave_notify_event", GTK_SIGNAL_FUNC(OnLeaveNotify), this); - gtk_widget_add_events(GTK_WIDGET(_drawingArea), GDK_LEAVE_NOTIFY_MASK); - - gtk_signal_connect - (GTK_OBJECT(_drawingArea), "button_press_event", GTK_SIGNAL_FUNC(OnButtonPress), this); - gtk_widget_add_events(GTK_WIDGET(_drawingArea), GDK_BUTTON_PRESS_MASK); - - gtk_signal_connect - (GTK_OBJECT(_drawingArea), "button_release_event", GTK_SIGNAL_FUNC(OnButtonRelease), this); - gtk_widget_add_events(GTK_WIDGET(_drawingArea), GDK_BUTTON_RELEASE_MASK); - - _backgroundGC = gtk_gc_new(&_backgroundColor); - _foregroundGC = gtk_gc_new(&_foregroundColor); - _phantomGC = gtk_gc_new(&_phantomColor); - _boundaryGC = gtk_gc_new(&_boundaryColor); - _rubberGC = gtk_gc_new(&_rubberColor); - _markerGC = gtk_gc_new(&_markerColor); - gdk_gc_set_line_attributes (_markerGC, 1, GDK_LINE_SOLID, GDK_CAP_PROJECTING, GDK_JOIN_MITER); - _selectionDrawGC = gtk_gc_new(&_selectionDrawColor); - _selectionFillGC = gtk_gc_new(&_selectionFillColor, "AA55AA55AA55AA55"); - _gridGC = gtk_gc_new(&_gridColor); - _spotGC = gtk_gc_new(&_spotColor); - gdk_gc_set_function(_spotGC, GDK_XOR); - _ghostGC = gtk_gc_new(&_ghostColor); - gdk_gc_set_function(_ghostGC, GDK_XOR); - - _drawGC = _foregroundGC; - _fillGC = _foregroundGC; - - Inherit::_PostCreate(); -} - -void View::_PreDelete() -// ******************** -{ - Inherit::_PreDelete(); - - for_each_selector(selector, GetSelectors()) selector->_DetachFrom(this); end_for; - - for_each_command(command, GetCommands()) command->UninstallFrom(this); end_for; - - gdk_gc_destroy(_backgroundGC); - gdk_gc_destroy(_foregroundGC); - gdk_gc_destroy(_phantomGC); - gdk_gc_destroy(_boundaryGC); - gdk_gc_destroy(_rubberGC); - gdk_gc_destroy(_markerGC); - gdk_gc_destroy(_selectionDrawGC); - gdk_gc_destroy(_selectionFillGC); - gdk_gc_destroy(_gridGC); - gdk_gc_destroy(_spotGC); - gdk_gc_destroy(_ghostGC); - - if (_frame) gtk_widget_destroy(_frame); - - Cell* cell = GetCell(); - if (cell) cell->_GetViewSet()._Remove(this); -} - -string View::_GetString() const -// **************************** -{ - string s = Inherit::_GetString(); - Cell* cell = GetCell(); - if (cell) s.insert(s.length() - 1, " " + GetString(cell->GetName())); - return s; -} - -Record* View::_GetRecord() const -// *********************** -{ - Record* record = Inherit::_GetRecord(); - if (record) { - record->Add(GetSlot("Cell", GetCell())); - record->Add(GetSlot("Transformation",GetTransformation())); - record->Add(GetSlot("Center", &_center)); - record->Add(GetSlot("Scale", &_scale)); - record->Add(GetSlot("ScreenWidth", &_screenWidth)); - record->Add(GetSlot("ScreenHeight", &_screenHeight)); - record->Add(GetSlot("Commands", &_commandMap)); - record->Add(GetSlot("GridIsVisible", &_gridIsVisible)); - record->Add(GetSlot("GridDisplayThreshold", &_gridDisplayThreshold)); - record->Add(GetSlot("AutoScrollIsEnabled", &_autoScrollIsEnabled)); - record->Add(GetSlot("DoubleBufferingIsEnabled", &_doubleBufferingIsEnabled)); - record->Add(GetSlot("PhantomsAreVisible", &_phantomsAreVisible)); - record->Add(GetSlot("BoundariesAreVisible", &_boundariesAreVisible)); - record->Add(GetSlot("CutPointsAreVisible", &_cutPointsAreVisible)); - record->Add(GetSlot("RubbersAreVisible", &_rubbersAreVisible)); - record->Add(GetSlot("MarkersAreVisible", &_markersAreVisible)); - record->Add(GetSlot("SelectionIsVisible", &_selectionIsVisible)); - record->Add(GetSlot("DisplaySlotsAreVisible", &_displaySlotsAreVisible)); - record->Add(GetSlot("VisualMapsAreVisible", &_visualMapsAreVisible)); - record->Add(GetSlot("VisibleBasicLayersMask", &_visibleBasicLayersMask)); - record->Add(GetSlot("Selection", &_selectorSet)); - record->Add(GetSlot("RubberDisplayType", &_rubberDisplayType)); - } - return record; -} - -bool View::_DisplayHasBeenAborted() -// ******************************** -{ - bool aborted = false; - if (gdk_events_pending()) { - GdkEvent* event = gdk_event_get(); - if (event) { - if (event->any.window == _drawingArea->window) { - if ((event->type == GDK_CONFIGURE) || - (event->type == GDK_BUTTON_PRESS) || - (event->type == GDK_2BUTTON_PRESS) || - (event->type == GDK_3BUTTON_PRESS) || - (event->type == GDK_KEY_PRESS)) - aborted = true; - } - if (!aborted) aborted = _DisplayHasBeenAborted(); - gdk_event_put(event); - gdk_event_free(event); - } - } - return aborted; -} - -void View::_PreRepaint() -// ********************* -{ -} - -void View::_PostRepaint() -// ********************** -{ -} - -void View::_DrawDisplaySlot(DisplaySlot* displaySlot, const Box& area, const Box& updateArea, const Transformation& transformation) -// ******************************************************************************************************************************** -{ - GdkRectangle clipRectangle; - clipRectangle.x = GetScreenX(area.GetXMin()); - clipRectangle.y = GetScreenY(area.GetYMax()); - clipRectangle.width = GetScreenX(area.GetXMax()) - clipRectangle.x; - clipRectangle.height = GetScreenY(area.GetYMin()) - clipRectangle.y; - - if (displaySlot->IsVisible()) { - _drawGC = displaySlot->_GetDrawGC(); - _fillGC = displaySlot->_GetFillGC(); - gdk_gc_set_clip_rectangle(_drawGC, &clipRectangle); - gdk_gc_set_clip_rectangle(_fillGC, &clipRectangle); - displaySlot->_Draw(this, updateArea, transformation); - gdk_flush(); - } -} - -void View::_Repaint(const Box& area) -// ********************************* -{ - GdkRectangle clipRectangle; - clipRectangle.x = GetScreenX(area.GetXMin()); - clipRectangle.y = GetScreenY(area.GetYMax()); - clipRectangle.width = GetScreenX(area.GetXMax()) - clipRectangle.x; - clipRectangle.height = GetScreenY(area.GetYMin()) - clipRectangle.y; - - Box updateArea = GetTransformation().GetInvert().GetBox(area); - - _drawGC = _backgroundGC; - _fillGC = _backgroundGC; - gdk_gc_set_clip_rectangle(_drawGC, &clipRectangle); - gdk_gc_set_clip_rectangle(_fillGC, &clipRectangle); - FillRectangle(area, true); - - _PreRepaint(); - - Cell* cell = GetCell(); - if (cell) { - - if (_phantomsAreVisible) { - _drawGC = _phantomGC; - _fillGC = _phantomGC; - gdk_gc_set_clip_rectangle(_drawGC, &clipRectangle); - gdk_gc_set_clip_rectangle(_fillGC, &clipRectangle); - cell->_DrawPhantoms(this, updateArea, GetTransformation()); - gdk_flush(); - } - - if (_boundariesAreVisible) { - _drawGC = _boundaryGC; - _fillGC = _boundaryGC; - gdk_gc_set_clip_rectangle(_drawGC, &clipRectangle); - gdk_gc_set_clip_rectangle(_fillGC, &clipRectangle); - cell->_DrawBoundaries(this, updateArea, GetTransformation()); - gdk_flush(); - } - - _drawGC = _foregroundGC; - _fillGC = _foregroundGC; - gdk_gc_set_clip_rectangle(_drawGC, &clipRectangle); - gdk_gc_set_clip_rectangle(_fillGC, &clipRectangle); - - DataBase* dataBase = GetDataBase(); - Technology* technology = dataBase->GetTechnology(); - for_each_composite_layer(compositeLayer, technology->GetCompositeLayers()) { - compositeLayer->_UpdateSymbolicBasicLayer(_visibleBasicLayersMask); - end_for; - } - - try { - for_each_basic_layer(basicLayer, GetVisibleBasicLayers()) { - CheckForDisplayInterruption(); - if (basicLayer->GetDisplayThreshold() < _scale) { - _drawGC = basicLayer->_GetDrawGC(); - _fillGC = basicLayer->_GetFillGC(); - gdk_gc_set_clip_rectangle(_drawGC, &clipRectangle); - gdk_gc_set_clip_rectangle(_fillGC, &clipRectangle); - cell->_DrawContent(this, basicLayer, updateArea, GetTransformation()); - gdk_flush(); - _drawGC = _foregroundGC; - _fillGC = _foregroundGC; - } - end_for; - } - } - catch (Interruption& interruption) { - } - - for_each_composite_layer(compositeLayer, technology->GetCompositeLayers()) { - compositeLayer->_UpdateSymbolicBasicLayer(~0); - end_for; - } - - if (_rubbersAreVisible) { - _drawGC = _rubberGC; - _fillGC = _rubberGC; - gdk_gc_set_clip_rectangle(_drawGC, &clipRectangle); - gdk_gc_set_clip_rectangle(_fillGC, &clipRectangle); - cell->_DrawRubbers(this, updateArea, GetTransformation()); - gdk_flush(); - } - - if (_markersAreVisible) { - _drawGC = _markerGC; - _fillGC = _markerGC; - gdk_gc_set_clip_rectangle(_drawGC, &clipRectangle); - gdk_gc_set_clip_rectangle(_fillGC, &clipRectangle); - cell->_DrawMarkers(this, updateArea, GetTransformation()); - gdk_flush(); - } - - if (_displaySlotsAreVisible) { - cell->_DrawDisplaySlots(this, area, updateArea, GetTransformation()); - } - - if (_visualMapsAreVisible) { - for_each_visual_map(visualMap, GetVisualMaps(cell)) { - if (visualMap->IsVisible()) { -#if 0 - _drawGC = visualMap->_GetGC(); - _fillGC = visualMap->_GetGC(); - gdk_gc_set_clip_rectangle(_drawGC, &clipRectangle); - gdk_gc_set_clip_rectangle(_fillGC, &clipRectangle); -#endif - visualMap->_Draw(this, updateArea, GetTransformation()); - gdk_flush(); - } - end_for; - } - } - - bool cutPointsAreVisible = _cutPointsAreVisible; - _cutPointsAreVisible = true; - if (_selectionIsVisible) { - _drawGC = _selectionDrawGC; - _fillGC = _selectionFillGC; - gdk_gc_set_clip_rectangle(_drawGC, &clipRectangle); - gdk_gc_set_clip_rectangle(_fillGC, &clipRectangle); - for_each_selector(selector, GetSelectors()) { - Occurrence occurrence = selector->GetOccurrence(); - Entity* entity = occurrence.GetEntity(); - Transformation transformation = occurrence.GetPath().GetTransformation(); - GetTransformation().ApplyOn(transformation); - if (is_a(entity)) - ((Go*)entity)->_Highlight(this, updateArea, transformation); - end_for; - } - gdk_flush(); - } - _cutPointsAreVisible = cutPointsAreVisible; - } - - if (GridIsVisible() && GridIsDrawable()) { - Unit xmin = GetOnGridUnit(GetX(0)); - Unit ymin = GetOnGridUnit(GetY(_screenHeight)); - Unit xmax = GetOnGridUnit(GetX(_screenWidth)); - Unit ymax = GetOnGridUnit(GetY(0)); - for (Unit xi = xmin; xi <= xmax; xi += GetGridStep()) { - bool bx = IsOnGrid(xi, 10); - for (Unit yi = ymin; yi <= ymax; yi += GetGridStep()) { - bool by = IsOnGrid(yi, 10); - ScreenUnit screenX = GetScreenX(xi); - ScreenUnit screenY = GetScreenY(yi); - if (!bx || !by) - gdk_draw_point(_drawable, _gridGC, screenX, screenY); - else { - gdk_draw_line(_drawable, _gridGC, screenX - 2, screenY, screenX + 2, screenY); - gdk_draw_line(_drawable, _gridGC, screenX, screenY - 2, screenX, screenY + 2); - } - } - } - } - - _PostRepaint(); - - clipRectangle.x = 0; - clipRectangle.y = 0; - clipRectangle.width = _screenWidth; - clipRectangle.height = _screenHeight; - gdk_gc_set_clip_rectangle(_drawGC, &clipRectangle); - gdk_gc_set_clip_rectangle(_fillGC, &clipRectangle); -} - -void View::_DrawSpot() -// ******************* -{ - if (!_drawingArea || !_drawingArea->window) return; - - if (_spotIsDrawable) { - ScreenUnit screenX = GetScreenX(_spotPosition.GetX()); - ScreenUnit screenY = GetScreenY(_spotPosition.GetY()); - if (((-3 <= screenX) && (screenX <= (_screenWidth + 3))) && - ((-3 <= screenY) && (screenY <= (_screenHeight + 3)))) - gdk_draw_rectangle(_drawable, _spotGC, false, screenX - 3, screenY - 3, 6, 6); - _spotIsVisible = !_spotIsVisible; - } -} - -void View::_ShowSpot() -// ******************* -{ - if (!_spotIsVisible) _DrawSpot(); -} - -void View::_HideSpot() -// ******************* -{ - if (_spotIsVisible) _DrawSpot(); -} - -int View::_GetClipCode(const Unit& x, const Unit& y) const -// ******************************************************* -{ - int code = 0; - if (x < _clipBox.GetXMin()) code = 1; - else if (_clipBox.GetXMax() < x) code = 2; - if (y < _clipBox.GetYMin()) code |= 4; - else if (_clipBox.GetYMax() < y) code |= 8; - return code; -} - -bool View::_ClipLine(Unit& xo, Unit& yo, Unit& xe, Unit& ye) const -// *************************************************************** -{ - int cco = _GetClipCode(xo, yo); - int cce = _GetClipCode(xe, ye); - - if (!(cco | cce)) return true; - - int c = cco & cce; - if ((c & 1) || (c & 2) || (c & 4) || (c & 8)) return false; - - if (cco & 1) { - yo += GetUnit((GetValue(ye - yo) * GetValue(_clipBox.GetXMin() - xo)) / GetValue(xe - xo)); - xo = _clipBox.GetXMin(); - return _ClipLine(xo, yo, xe, ye); - } - if (cco & 2) { - yo += GetUnit((GetValue(ye - yo) * GetValue(_clipBox.GetXMax() - xo)) / GetValue(xe - xo)); - xo = _clipBox.GetXMax(); - return _ClipLine(xo, yo, xe, ye); - } - if (cce & 1) { - ye += GetUnit((GetValue(yo - ye) * GetValue(_clipBox.GetXMin() - xe)) / GetValue(xo - xe)); - xe = _clipBox.GetXMin(); - return _ClipLine(xo, yo, xe, ye); - } - if (cce & 2) { - ye += GetUnit((GetValue(yo - ye) * GetValue(_clipBox.GetXMax() - xe)) / GetValue(xo - xe)); - xe = _clipBox.GetXMax(); - return _ClipLine(xo, yo, xe, ye); - } - if (cco & 4) { - xo += GetUnit((GetValue(xe - xo) * GetValue(_clipBox.GetYMin() - yo)) / GetValue(ye - yo)); - yo = _clipBox.GetYMin(); - return _ClipLine(xo, yo, xe, ye); - } - if (cco & 8) { - xo += GetUnit((GetValue(xe - xo) * GetValue(_clipBox.GetYMax() - yo)) / GetValue(ye - yo)); - yo = _clipBox.GetYMax(); - return _ClipLine(xo, yo, xe, ye); - } - if (cce & 4) { - xe += GetUnit((GetValue(xo - xe) * GetValue(_clipBox.GetYMin() - ye)) / GetValue(yo - ye)); - ye = _clipBox.GetYMin(); - return _ClipLine(xo, yo, xe, ye); - } - if (cce & 8) { - xe += GetUnit((GetValue(xo - xe) * GetValue(_clipBox.GetYMax() - ye)) / GetValue(yo - ye)); - ye = _clipBox.GetYMax(); - return _ClipLine(xo, yo, xe, ye); - } - return true; -} - -bool View::_ClipBox(Box& box) const -// ******************************** -{ - box = box.GetIntersection(_clipBox); - return !box.IsEmpty(); -} - -void View::_OnExpose(const ScreenUnit& screenX, const ScreenUnit& screenY, const ScreenUnit& screenWidth, const ScreenUnit& screenHeight, bool update) -// **************************************************************************************************** -{ - if (!_drawingArea) return; - - if (!_hasBeenExposed) { - GdkWindow* window = _drawingArea->window; - GdkColormap* colormap = gdk_window_get_colormap(window); - GdkColor color; - color.red = 50 * 255; - color.green = 50 * 255; - color.blue = 50 * 255; - gdk_color_alloc(colormap, &color); - gdk_window_set_background(window, &color); - FitToContent(); - _backCenter = _center; - _backScale = _scale; - } - - Invalidate(screenX, screenY, screenX + screenWidth, screenY + screenHeight); - - if (update) Update(); -} - -void View::_OnResize(const ScreenUnit& screenWidth, const ScreenUnit& screenHeight) -// ******************************************************************************** -{ - _screenWidth = screenWidth; - _screenHeight = screenHeight; - - if (_drawingArea && _drawingArea->window) { - Point backCenter = _backCenter; - double backScale = _backScale; - double scale = _scale; - _scale = 0; // to force reframe - Reframe(_center, scale); - // to restore good values altered by the hack - _backCenter = backCenter; - _backScale = backScale; - } -} - -void View::_OnMouseEnter(const Point& position) -// ******************************************** -{ - for_each_command(command, GetCommands()) { - command->_OnMouseEnter(this, position); - end_for; - } - _spotIsDrawable = true; - _spotPosition = position; - _ShowSpot(); -} - -void View::_OnMouseMove(const Point& position, unsigned state) -// *********************************************************** -{ - _HideSpot(); - for_each_command(command, GetCommands()) { - command->_OnMouseMove(this, position, state); - end_for; - } - _spotPosition = position; - _ShowSpot(); -} - -void View::_OnMouseLeave(const Point& position) -// ******************************************** -{ - _HideSpot(); - _spotIsDrawable = false; - for_each_command(command, GetCommands()) { - command->_OnMouseLeave(this, position); - end_for; - } -} - -void View::_OnButtonPress(unsigned button, const Point& position, unsigned state) -// ****************************************************************************** -{ - Command* command = GetCommand(button); - if (command) { - _HideSpot(); - command->_OnButtonPress(this, position, state); - _ShowSpot(); - } -} - -void View::_OnButtonRelease(unsigned button, const Point& position, unsigned state) -// ******************************************************************************** -{ - Command* command = GetCommand(button); - if (command) { - _HideSpot(); - command->_OnButtonRelease(this, position, state); - _ShowSpot(); - } -} - -void View::SetDefaultColor (const string& name, unsigned short red, unsigned short green, unsigned short blue) -// *********************************************************************************************************** -{ - GdkColor* color = NULL; - if (name == "background" ) { color = &_backgroundColor; } - else if (name == "foreground" ) { color = &_foregroundColor; } - else if (name == "rubber" ) { color = &_rubberColor; } - else if (name == "phantom" ) { color = &_phantomColor; } - else if (name == "boundary" ) { color = &_boundaryColor; } - else if (name == "marker" ) { color = &_markerColor; } - else if (name == "selectionDraw") { color = &_selectionDrawColor; } - else if (name == "selectionFill") { color = &_selectionFillColor; } - else if (name == "grid" ) { color = &_gridColor; } - else if (name == "spot" ) { color = &_spotColor; } - else if (name == "ghost" ) { color = &_ghostColor; } - else { - throw Error ("Invalid View color name : " + name); - } - - color->red = red * 255; - color->green = green * 255; - color->blue = blue * 255; -} - -void View::SetColor (const string& name, unsigned short red, unsigned short green, unsigned short blue) -// **************************************************************************************************** -{ - GdkColor* color = gdk_color_new(red, green, blue); - GdkGC* gc; - - if (name == "background" ) { gc = _backgroundGC; } - else if (name == "foreground" ) { gc = _foregroundGC; } - else if (name == "rubber" ) { gc = _rubberGC; } - else if (name == "phantom" ) { gc = _phantomGC; } - else if (name == "boundary" ) { gc = _boundaryGC; } - else if (name == "marker" ) { gc = _markerGC; } - else if (name == "selectionDraw") { gc = _selectionDrawGC; } - else if (name == "selectionFill") { gc = _selectionFillGC; } - else if (name == "grid" ) { gc = _gridGC; } - else if (name == "spot" ) { gc = _spotGC; } - else if (name == "ghost" ) { gc = _ghostGC; } - else { - throw Error ("Invalid View color name : " + name); - } - - gdk_gc_set_foreground(gc, color); -} - -void View::SetRubberDisplayType(const RubberDisplayType& rubberdisplaytype) -// ************************************************************************ -{ - _rubberDisplayType = rubberdisplaytype; -} - -void View::SetTextDisplayState(const bool& isTextVisible) -// ************************************************************************ -{ - _isTextVisible = isTextVisible; -} - -// **************************************************************************************************** -// View::RubberDisplayType implementation -// **************************************************************************************************** - -View::RubberDisplayType::RubberDisplayType(const Type& type) -// ********************************************************* -: _type(type) -{ -} - -View::RubberDisplayType::RubberDisplayType(const RubberDisplayType& rubberdisplaytype) -// *********************************************************************************** -: _type(rubberdisplaytype._type) -{ -} - -View::RubberDisplayType& View::RubberDisplayType::operator=(const RubberDisplayType& rubberdisplaytype) -// **************************************************************************************************** -{ - _type = rubberdisplaytype._type; - return *this; -} - -string View::RubberDisplayType::_GetString() const -// *********************************************** -{ - switch (_type) { - case GEOMETRIC : return "GEOMETRIC"; - case BARYCENTRIC : return "BARYCENTRIC"; - case STEINER: return "STEINER"; - } - return "ABNORMAL"; -} - -Record* View::RubberDisplayType::_GetRecord() const -// ****************************************** -{ - Record* record = new Record(GetString(this)); - record->Add(GetSlot("Type", ((unsigned int*)((void*)&_type)))); - return record; -} - -} // End of Hurricane namespace. - - -// **************************************************************************************************** -// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved -// **************************************************************************************************** diff --git a/hurricane/src/viewer/images/gtk-go-down.png b/hurricane/src/viewer/images/gtk-go-down.png new file mode 100644 index 0000000000000000000000000000000000000000..c8f54fb919a106efbda7efc3896fb5be03bfd8a0 GIT binary patch literal 536 zcmV+z0_XjSP)P*DMoq#*3HX#RY^SdIdxGYjiHtvw--f=I`N z+8_md*!s@Z`Ed^^nWU?;WA-+d0LFm}pqnU3ON*U?iTBgb`Lw&wO*cYHi3(({$q$A{ z)8G@XK2EnOty=>v;1^I|ntj2_c7sl+(Q*DZI6wH7fY)7JE8U(ffdxX~x9e+tdHyA< zI}IWo_r~=e@TRK^vnFSqyF>E%?Q6DwoN(QVN`n`Dg#s7?Mu5k_-qhS8#u$#ita*d` ztnw-_2229B{_IsU=acS!)nny*lhhn|tqi#EBpCvRfrr42n-;IOh!RSaJGyB9|LtGw azmHp`TEWigP)-(u5Kah1Y#(wqittcB1&SRcHOpJnggNao`k4 ztb_T0cWXP8q7aqoKVcbzF$NJK3I&yEQkAi}d%*j}3V;*htU;V8wAN^?QQ5B@Ktzy$ z-{67166MJWDz83x(-pY@U$*y1+A$JFh1yGN&9j*~Y8%xCFlr-7y@1P$7ICXtxPK47 zf1|ch1$Yh&05PBdBY%52I>e`eAJ)`W9h?!UG@*Td;uP#38up2w0!P5P1^Bxt&*K-f zOY{#7yTqHWE^pc|lpOZ&q~SA+s^*4QsBp7*u~p7f>mT(-H+ z755go<5_mCNxL84B;MG=V1|7@|mtz&QLB$Oa?Zx4T2Z9$@R_I}sy_tTfW?+|GRa?e2U7|LchIE>y2b zEI=P%dJPZ(K70=ckf>Jx5#Tp>ekSuFpwKIT2=F^U$~0Ow@fAaCnzezNyvhHZRS}WI zzt<(^BhUomtk>|A{P?1V(FzekDTUDr>pWULhSwW0yQK=Ni(dgIfh*u1@FpwyVfmW= zqM;c(L?t9^#Q1MyMt(AX4dcSpYW@4gVBmsY>BPIdBJ(X=tmX> zqX8%wjnXEyM$#Dgg{2iXz8|7g_8U+UI4@Msk8%M-z`*kSm;0%?Z;XAK$z3Fk+EuP+ zDu4w>OIvGP{@(j%O-VZ<3)}(YrLDD#DV~|suTQDpT&5=~6mtUz&;n{{AP3v)S)2BG z3N006V0bk7{~2fmww=lANs(nqMJGtxorYri3!J>LO7J&3nPkaDA21d`1(*g#!U=TM zqC8^P#w7S!VTWlZuj));Z4np@QhgirMtaivUaU8O4i{|Sy(hotz4{ literal 0 HcmV?d00001 diff --git a/hurricane/src/viewer/images/gtk-go-up.png b/hurricane/src/viewer/images/gtk-go-up.png new file mode 100644 index 0000000000000000000000000000000000000000..da3eab90988542f48fadcb32d030cede59b619f5 GIT binary patch literal 605 zcmV-j0;2tiP)a(NT8p+&hT=jHK|yN~v7k#AiZ9?>b^d<>Va+zA%cm5Lxt zDTtfFL8_gh+ID6-G08bD?wzC)lS#63;Rkn--Qd2f)oLg@U2f@Q?mij^DxG+cIgJ|cORBQ@&E>q z!*LpJjD1gZ*4VzdQ3}Zd3?SRxK5sic8oqt(d+9qOf{1X`?=jr}&f-d&%?D2kA&m?` z0IpqVCpX@7dJGQ6$+b!hDvb7ju=DC!w)#GH2_FGr7GQuyU>P`r-B8<03rz+GpsI)p zDzSy6x(x&_FmM(4Km_PXfV!JQVB$=SCShWTMN!R6gbf`4V<2`Jk<0t5MUgWZ-2AAj z`}#saO&?6vyA1h9D3X6(xF@Zo-R8&+T5GNXPf-FtbEX{JFp+9lCwJY@3!hXNslHW_3S1!HxKJR<4*8|{x zH9-&rK?uW2rBbO>!jS*|X|7D*kB|3v*9}A0eS6z%!q9bHce4q@PN&mR)$bR;^CW%N zytA}GzVCUC0}up3KEYS_1d!L^Jtt9LTnr0=BC^2 z_tWDF{H9*7*X#8>z(EiM9Q|~K3BlMj0gA;^38Bc>YKqcq0xTBu`FI>Xp9+pK#u!Jy z7_Zlh1%M>Ua=9FN+s1ggjGl8G$Fc471ZkF4HbSzDP?i9()}WM9-v?+kTCLmLXsNj8 z_Eu^eBbj3VJo5Q*~(KI1iqi0r&MC^4nhb? z(g7i&+o-2c>t1Hb0=Vbn$C@NbQmF*cY&II_=Lf*~F2TANz%+GzIz7I3lLbV;-;o2r zFidl`Itb2yxtC>x6a~PtOmn#eC=?2XLLm%QRaI4$DadvOQ7n}XClkeZ-0z|%V#mQ* ztB7K;$dZa8fGo46;-I1!tx$ZWL=m7^WcTrw<8k)EzvesEJ{9K)c&qGRY@AZ=DfK*- zp3->X@shr(&n~_~`G7so^L!sbQEIhv`2e_WZ?_o7^@v_pQQQy60rI!NY06USd6WXI z*BBEL1LxaYyWMWz-tH@ujgwR`%^zouv)!&%0He`lqG|h|ejzy_sr*lwuIsvG0W6oy zC+!oQS2P?B29J-dw`}|01J7nJFPa80ojyO$=jn&6)YBZ_zb(r!G>x5A6y@&$FBY$_ zvl#$Fk|aq0-EOaUcXtAKS^?btR3Y0fA(jQ;ID~j!HgIlmZr9gWR~HvyIGK#cgF!SN z|6s*G$!UPxIOuRV8cikumStHO=Reoy22ZX)tJQ2?UIGjT{eG_pfKat6%fAD+ZN~w4 xco>hTQvh8zjMeJ+KOiTArxlX-`BOoY_6sUuZ>tv?-5vk{002ovPDHLkV1g2Br9S`w literal 0 HcmV?d00001 diff --git a/hurricane/src/viewer/images/palette_show_all.png b/hurricane/src/viewer/images/palette_show_all.png new file mode 100644 index 0000000000000000000000000000000000000000..712566bfed59230064c4a106e07b40493a5637ec GIT binary patch literal 1398 zcmV-+1&R8JP)O4EabgM)*EG?mZ)HLjh2fBg9VeZ5Z8_4?blr>8Vsuh;9Rr!+k| zIXUTc{@nq2PI27z-rly27^5_f0nRy3lFb)67niQNfJu)Gm4@p*^_kO z_XOmmkt9jN7|?1R9bH^xp^~GVCnOAQ`(KzAKxeZcP!youUM$LGAc`2vM|wKFzrVfR zB<2_6j4>9+y8#p(V2n~iL?kS0H}grtIb*UoR-l}e-0Y5{}6>1nG4oS)mat^>oN z>v9elhGA&hD@43hnY?>DlSL~!AV)bbZ8Y+IMFA+~Tv32HP7(oB*EJ1zeDwV!0W?k1 zR24AIR;$r?1-PsdLcM_FSk`3n=h`hgkO6*4hiNKG6ak~ra_M=%o}_wu)n{*zrUZRold9I=?DfL2Pl^nMO9x1uPFI_ zUqT-YnoYqlA;Ll1wyX^B&5ddPj+i~kXb|}RY9&&pTo#Asvs@;VoXdmAmq*Tlmt{1Y z&%Y!0ilQhA0)R0g8ATB}psMAvI7^&cEEc8WMp7!9m*coDz}R>^oo3}s*59n|OL#A( zA@`S;Ow#*%#>!>D_r>}mU`i=v45-&@wMyj`sf3~MJTILj0TjjeMSUNSXEVTYCKK_c z>-UGlO(u7l1l;R+9;JY$8Ai1VJU()+s=#s?$C3yUJxY@V@ckelBu9j#zTIxOFD}wF z41M3SGG;96^78f;I6J$$ySV|R*PeHGcYhB=(R^-MK)KxQ*6YA*CL|X{oKp(4+p1cx z1C55NR;z$vh$_)+8irv2$H#_|XL34St$ZKob`3*Sf#Fa@xcKQ;ii}9+t5w6O)$&ZO zR+a^DPDm61K@f(72u&slFrN#+7Z;}4>j8vt9)`ed=DLdoz&WLy1Bw#InkMF>2;ltq zxZ4Fhj}StDBoPs|EY70{SgkC}bvGmTODfW%>+7qlyE~z+Fa$L1?Cj_Wu&l+xvVi4M zl%+5fj3|n(t193)zVCT}>oVrLnS>Z)j4^;xLgE-OP4Ql(BJ1^Hv0MT{uw1TIK)+wB zsVXp;JUq$>@zE85OBRF+HWK+&>p zQP}0>WHKIauKW10R%^9@Zr3!M&CTEAm=H>V)6-sWFxcHDzqx<@@ZtUYckj}4JRXg% zuC@cGR7fKTq9}?0QAdDgvtG~Vj0AdpJsgh58N+Yw>)#B#7=fcB!Q9nVzu)TthEc5w z$-Hh-GM_$;Mw1C(S+?zYfBpyLuYqrK|Y%jXFDfG=t4(p`m)62M5P7>I??YT`S@4UagsS7R(c3f9>;?rb! zaD#~=cX2m%tv4U#pK&Ly7=bDDum7bcu7UV&G2G#_q6WpOz#}2z+Wen!_+^N z#Taji$^5tT&yA+YbD}>A-*rc>&@J$O`1HN~g=HtCw8Y${CTbluS^x9doozvTU7fB! z+IjKLB91AqPxdZu)ogUlaV?!?t+!9b*osfeS7U5qaw$oIWxDE!~|t56N=tVO=-^N+z96f&eKJ0q`7yi=*}O! z7w7Pv|MNWO|2zkl`HzU7pDc>M6|U6kIB@cGa2=MoKNQAd>&NBwvMWEA+d%W92mf4w z0EETXkFLEFfRf^!C=(I@qN*a2u+X)43X82@EN0O4Ra9zqvR=f65vKZyfgJUkP{vD< zo|=LxC7I$wN9btM3m_(9*7b%K@%&AOHYgH9^+ya zvR*6>5Ockv993!(lhZS@!r!K*85(m_r#AsmuPda^V{NY-Amw{EAVtaO2H*g1G@HuJc>3zyf&(3qR*r%f~%+pt<%(Imz5 z@Mbl4Zrvc!=U#Abu@`b}CF%_=43AF$AX$4UKUIQea}M+K^Z5OKW@l%4YwJVXXrQoo z4^~Sno>3<~FO4B>*-3Ud?5s>w0&wowVT!ioai-!b4yTJiAV44xpm0+*d$$z;Fg-CI z6c5`)zY@jS^Zewf_w%)s2-9K#MfjXm%1`TZyq3M5J5VP$xP1I%P&d?0DNi>`FQpe z!T?(ZeetFa%BJjc-k{gOEyh2H%Ll0F|;r