diff --git a/hurricane/src/hurricane/Timer.cpp b/hurricane/src/hurricane/Timer.cpp index a9e310ee..4fdf66d9 100644 --- a/hurricane/src/hurricane/Timer.cpp +++ b/hurricane/src/hurricane/Timer.cpp @@ -1,85 +1,211 @@ -// **************************************************************************************************** -// File: Timer.cpp -// Authors: R. Escassut -// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved -// **************************************************************************************************** -#include "hurricane/Timer.h" +/************************************************************************** +*** +*** Copyright (c) 1995-2000 Regents of the University of California, +*** Andrew E. Caldwell, Andrew B. Kahng and Igor L. Markov +*** Copyright (c) 2000-2002 Regents of the University of Michigan, +*** Saurabh N. Adya and Igor L. Markov +*** +*** Contact author(s): abk@cs.ucsd.edu, imarkov@umich.edu +*** Original Affiliation: UCLA, Computer Science Department, +*** Los Angeles, CA 90095-1596 USA +*** +*** Permission is hereby granted, free of charge, to any person obtaining +*** a copy of this software and associated documentation files (the +*** "Software"), to deal in the Software without restriction, including +*** without limitation +*** the rights to use, copy, modify, merge, publish, distribute, sublicense, +*** and/or sell copies of the Software, and to permit persons to whom the +*** Software is furnished to do so, subject to the following conditions: +*** +*** The above copyright notice and this permission notice shall be included +*** in all copies or substantial portions of the Software. +*** +*** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +*** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +*** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +*** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +*** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT +*** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR +*** THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*** +*** +***************************************************************************/ + + +#include "hurricane/Timer.h" + namespace Hurricane { + size_t Timer::_baseMemorySize = (size_t)sbrk(0); -// **************************************************************************************************** -// Timer implementation -// **************************************************************************************************** -Timer::Timer() -// *********** -: _time(time(NULL)) -{ -} +// ------------------------------------------------------------------- +// Class : "Timer". -Timer::Timer(const Timer& timer) -// ***************************** -: _time(timer._time) -{ -} -Timer& Timer::operator=(const Timer& timer) -// **************************************** -{ - _time = timer._time; - return *this; -} + Timer::Timer ( double limitInSec ) + : timeLimit(limitInSec) + , _memorySize((size_t)sbrk(0)) + { + status = TimerOff; + } -string Timer::_getString() const -// ***************************** -{ - unsigned seconds = time(NULL) - _time; - string s = ""; + void Timer::start ( double limitInSec ) + { + if ( status != TimerOff ) + throw Error ( "Can't start timer twice" ); + status = TimerOn; - if (86400 <= seconds) { - unsigned days = seconds / 86400; - seconds -= 96400 * days; - s += getString(days) + "d"; + timeLimit = limitInSec; + + if ( time(&realTime1) == -1 ) + throw Error ( "Can't get time" ); + if ( getrusage(RUSAGE_SELF,&_ru) == -1 ) + throw Error(" Can't get time"); + UserTime1 = _ru.ru_utime.tv_sec+1e-6*_ru.ru_utime.tv_usec; + SysTime1 = _ru.ru_stime.tv_sec+1e-6*_ru.ru_stime.tv_usec; + } + + + void Timer::stop () + { + if ( status != TimerOn ) + throw Error ( "Can't stop timer twice!" ); + status = TimerOff; + if ( time(&realTime2) == -1 ) + throw Error ( "Can't get time" ); + if ( getrusage(RUSAGE_SELF,&_ru) == -1 ) + throw Error ( " Can't get time" ); + UserTime2 = _ru.ru_utime.tv_sec+1e-6*_ru.ru_utime.tv_usec; + SysTime2 = _ru.ru_stime.tv_sec+1e-6*_ru.ru_stime.tv_usec; + } + + + void Timer::suspend () + { + stop (); + status = TimerSuspended; + } + + + void Timer::resume () + { + if ( status != TimerSuspended ) + throw Error ( "Can't resume timer unless suspended" ); + status = TimerOn; + } + + + double Timer::getUserTime () const + { + if ( status != TimerOff && status != TimerSuspended ) + throw Error ( "Have to stop timer to get a reading" ); + return UserTime2 - UserTime1; + } + + + double Timer::getSysTime () const + { + if ( status != TimerOff && status != TimerSuspended ) + throw Error ( "Have to stop timer to get a reading" ); + return SysTime2 - SysTime1; + } + + + double Timer::getCombTime () const + { + if ( status != TimerOff && status != TimerSuspended ) + throw Error ( "Have to stop timer to get a reading" ); + return ( UserTime2 - UserTime1 ) + ( SysTime2 - SysTime1 ); + } + + + double Timer::getRealTime () const + { + if ( status != TimerOff && status != TimerSuspended ) + throw Error ( "Have to stop timer to get a reading" ); + return difftime ( realTime2, realTime1 ); + } + + + double Timer::getUnixTime () const + { + time_t utime; + time_t zero = 0; + + if ( time(&utime) == -1 ) + throw Error ( "Can't get time" ); + return difftime ( utime, zero ); + } + + + std::ostream& operator<<(std::ostream& os, const Timer& tm) + { + //CPUNormalizer cpunorm; + double userSec = tm.getUserTime (); + double normSec = tm.getUserTime (); // * cpunorm.getNormalizingFactor(); + char buffer[20]; + + if ( userSec > 0.01 ) { + double frac =userSec-floor(userSec); + double delta=frac-0.001*floor(frac*1000.0); + + userSec -= delta; + frac = normSec - floor(normSec); + delta = frac - 0.001*floor(frac*1000); + normSec -= delta; } + + sprintf ( buffer, "%.1e", tm.getSysTime() ); + + os << " " << userSec << " user," + << " " << buffer << " system," + << " " << tm.getRealTime() << " real," + << " " << normSec << " norm'd " + << "sec "; - if (3600 <= seconds) { - unsigned hours = seconds / 3600; - seconds -= 3600 * hours; - if (!s.empty()) s += " "; - s += getString(hours) + "h"; - } + return os; + } - if (60 <= seconds) { - unsigned minutes = seconds / 60; - seconds -= 60 * minutes; - if (!s.empty()) s += " "; - s += getString(minutes) + "m"; - } - if ((1 <= seconds) || s.empty()) { - if (!s.empty()) s += " "; - s += getString(seconds) + "s"; + string Timer::getStringTime ( double duration ) + { + string s; + + unsigned int hours = (unsigned int)duration / 3600; + if ( hours ) + s += getString(hours) + "h "; + + unsigned int minutes = ((unsigned int)duration % 3600) / 60; + if ( hours || minutes ) + s += getString(minutes) + "m "; + + double seconds = duration; + if ( hours || minutes ) { + minutes = ((unsigned int)duration) / 60; + seconds = duration - ((float)minutes * 60.0); } + + s += getString((float)seconds) + "s"; return s; -} + } -Record* Timer::_getRecord() const -// ************************ -{ - Record* record = new Record(getString(this)); - record->add(getSlot("Time", &_time)); - return record; -} + string Timer::getStringMemory ( size_t size ) { + string s; + + if ( size >> 30 ) s = getString(size>>30) + "Mo"; + else if ( size >> 20 ) s = getString(size>>20) + "Mo"; + else if ( size >> 10 ) s = getString(size>>10) + "Ko"; + else s = getString(size) + " octets"; + + return s; + } } // End of Hurricane namespace. - -// **************************************************************************************************** -// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved -// **************************************************************************************************** diff --git a/hurricane/src/hurricane/hurricane/Timer.h b/hurricane/src/hurricane/hurricane/Timer.h index 929759ec..25140008 100644 --- a/hurricane/src/hurricane/hurricane/Timer.h +++ b/hurricane/src/hurricane/hurricane/Timer.h @@ -1,61 +1,186 @@ -// **************************************************************************************************** -// File: Timer.h -// Authors: R. Escassut -// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved -// **************************************************************************************************** -#ifndef HURRICANE_TIMER -#define HURRICANE_TIMER +/************************************************************************** +*** +*** Copyright (c) 1995-2000 Regents of the University of California, +*** Andrew E. Caldwell, Andrew B. Kahng and Igor L. Markov +*** Copyright (c) 2000-2002 Regents of the University of Michigan, +*** Saurabh N. Adya and Igor L. Markov +*** +*** Contact author(s): abk@cs.ucsd.edu, imarkov@umich.edu +*** Original Affiliation: UCLA, Computer Science Department, +*** Los Angeles, CA 90095-1596 USA +*** +*** Permission is hereby granted, free of charge, to any person obtaining +*** a copy of this software and associated documentation files (the +*** "Software"), to deal in the Software without restriction, including +*** without limitation +*** the rights to use, copy, modify, merge, publish, distribute, sublicense, +*** and/or sell copies of the Software, and to permit persons to whom the +*** Software is furnished to do so, subject to the following conditions: +*** +*** The above copyright notice and this permission notice shall be included +*** in all copies or substantial portions of the Software. +*** +*** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +*** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +*** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +*** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +*** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT +*** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR +*** THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*** +*** +***************************************************************************/ + +//! author="Igor Markov 06/22/97 " +// freely inspired from abktimer from UCLApack .... just no windows. + +#ifndef __HURRICANE_TIMER__ +#define __HURRICANE_TIMER__ + +#include +#include +#include +#include + +#include +#if defined(sun) +extern "C" int getrusage ( int who, struct rusage *rusage ); +#elif defined(linux) +#endif + +#include "hurricane/Error.h" +#include "hurricane/Slot.h" -#include "hurricane/Commons.h" namespace Hurricane { - -// **************************************************************************************************** -// Timer declaration -// **************************************************************************************************** - -class Timer { -// ******** - -// Attributes -// ********** - - private: time_t _time; - -// Constructors -// ************ - - public: Timer(); - - public: Timer(const Timer& timer); - -// Operators -// ********* - - public: Timer& operator=(const Timer& timer); - -// Others -// ****** - - public: string _getTypeName() const { return _TName("Timer"); }; - public: string _getString() const; - public: Record* _getRecord() const; - -}; + using std::string; +// Used to record the CPU time of process + class Timer { -} // End of Hurricane namespace. + public: + // Static Methods. + static string getStringTime ( double duration ); + static string getStringMemory ( size_t size ); + // Constructors & Destructors. + Timer ( double limitInSec=0.0 ); + ~Timer () { }; + // Methods. + void start ( double limitInSec=0.0 ); + void stop (); + void suspend (); //call to allow taking a reading without interrupting timing + void resume (); //call after taking a reading after calling suspend() + inline bool isStopped () const; + double getUserTime () const; // processor time in seconds + double getSysTime () const; // processor time in seconds + double getCombTime () const; // processor time in seconds (sum of the prev. two) + double getRealTime () const; // real time in seconds + double getUnixTime () const; // Unix time (large number for in randseed) + inline double getRealTimeOnTheFly () const; + inline double getUserTimeOnTheFly () const; + inline double getSysTimeOnTheFly () const; + inline double getCombTimeOnTheFly () const; + inline bool expired () const; + inline bool realTimeExpired (); // Methods expired and realtimeexpired can be used + // to check if the time is over. The choice of CPU + // time over real time for expiration is explained + // by a much finer granularity of measurment. The + // author observed sensitivity of up to 0.001 CPU + // sec. on Sparc architecture (while real seconds + // were integers). + // DO NOT CALL THIS METHOD ON "OTHER" PLATFORMS + // (not __SUNPRO_CC) AFTER WRAP_AROUND HAPPENED: + // (INT_MAX+0.0)/CLOCKS_PER_SEC) sec (can be 36 mins), + // call realTimeExpired() instead + inline size_t getBaseMemorySize () const; + inline size_t getMemorySize () const; + inline size_t getIncrease () const; + inline void resetIncrease (); + // Friends Functions. + friend std::ostream& operator<< ( std::ostream& os, const Timer& tm ); + + protected: + // Internal: Enum. + enum Status { TimerOn + , TimerOff + , TimerSuspended + }; + + private: + // Internal: Attributes. + time_t realTime1; + mutable time_t realTime2; + double UserTime1; + mutable double UserTime2; + double SysTime1; + mutable double SysTime2; + double timeLimit; + Status status; + mutable struct rusage _ru; + size_t _memorySize; + static size_t _baseMemorySize; + // Internal: Methods. + + }; -INSPECTOR_PV_SUPPORT(Hurricane::Timer); +// Inline Functions. + inline bool Timer::isStopped () const { return status == TimerOff; } + inline size_t Timer::getBaseMemorySize () const { return _baseMemorySize; } + inline size_t Timer::getMemorySize () const { return _memorySize - _baseMemorySize; } + inline size_t Timer::getIncrease () const { return (size_t)(sbrk(0)) - _memorySize; } + inline void Timer::resetIncrease () { _memorySize = (size_t)sbrk(0); } -#endif // HURRICANE_TIMER + inline double Timer::getRealTimeOnTheFly () const + { + time(&realTime2); + return difftime(realTime2,realTime1); + } -// **************************************************************************************************** -// Copyright (c) BULL S.A. 2000-2004, All Rights Reserved -// **************************************************************************************************** + + inline double Timer::getUserTimeOnTheFly () const + { + if ( getrusage(RUSAGE_SELF,&_ru) == -1 ) + throw Error ( "Can't get time" ); + return _ru.ru_utime.tv_sec+1e-6*_ru.ru_utime.tv_usec - UserTime1; + } + + + inline double Timer::getSysTimeOnTheFly () const + { + if ( getrusage(RUSAGE_SELF,&_ru) == -1 ) + throw Error ( "Can't get time" ); + return _ru.ru_stime.tv_sec+1e-6*_ru.ru_stime.tv_usec - SysTime1; + } + + + inline double Timer::getCombTimeOnTheFly () const + { + if ( getrusage(RUSAGE_SELF,&_ru) == -1 ) + throw Error ( "Can't get time" ); + return _ru.ru_utime.tv_sec+1e-6*_ru.ru_utime.tv_usec - UserTime1 + + _ru.ru_stime.tv_sec+1e-6*_ru.ru_stime.tv_usec - SysTime1; + } + + + inline bool Timer::expired() const + { + return ( timeLimit < getCombTimeOnTheFly() ) && ( timeLimit != 0.0 ); + } + + + inline bool Timer::realTimeExpired() + { + return ( timeLimit < getRealTimeOnTheFly() ) && ( timeLimit != 0.0 ); + } + + +} // End of Hurricane namespace. + + +#endif // __HURRICANE_TIMER__ diff --git a/hurricane/src/hviewer/AreaCommand.cpp b/hurricane/src/hviewer/AreaCommand.cpp index 60eab0e2..723565bc 100644 --- a/hurricane/src/hviewer/AreaCommand.cpp +++ b/hurricane/src/hviewer/AreaCommand.cpp @@ -53,6 +53,7 @@ # include # include +# include # include # include @@ -92,7 +93,8 @@ namespace Hurricane { { if ( !_drawingEnabled ) return; - widget->drawScreenRect ( _startPoint, _stopPoint ); + widget->setPen ( Graphics::getPen("grid"), 2 ); + widget->drawScreenRect ( _startPoint, _stopPoint, 2 ); drawCorner ( widget, true ); drawCorner ( widget, false ); } @@ -113,7 +115,7 @@ namespace Hurricane { _cornerPoints[0].ry() += (bottomLeft) ? -10 : 10; _cornerPoints[2].rx() += (bottomLeft) ? 10 : -10; - widget->drawScreenPolyline ( _cornerPoints, 3, 4 ); + widget->drawScreenPolyline ( _cornerPoints, 3, 4, 2 ); } diff --git a/hurricane/src/hviewer/CellViewer.cpp b/hurricane/src/hviewer/CellViewer.cpp index 3b793bc2..65d38a97 100644 --- a/hurricane/src/hviewer/CellViewer.cpp +++ b/hurricane/src/hviewer/CellViewer.cpp @@ -68,6 +68,7 @@ namespace Hurricane { , _zoomCommand() , _selectCommand() , _cellHistory() + , _firstShow(false) { setObjectName("viewer"); @@ -224,8 +225,8 @@ namespace Hurricane { setCentralWidget ( _cellWidget ); - connect ( this , SIGNAL(redrawCellWidget()), _cellWidget, SLOT(redraw()) ); - connect ( _refreshAction , SIGNAL(triggered()) , _cellWidget, SLOT(redraw()) ); + connect ( this , SIGNAL(redrawCellWidget()), _cellWidget, SLOT(refresh()) ); + connect ( _refreshAction , SIGNAL(triggered()) , _cellWidget, SLOT(refresh()) ); connect ( _fitToContentsAction , SIGNAL(triggered()) , _cellWidget, SLOT(fitToContents()) ); connect ( _showSelectionAction , SIGNAL(toggled(bool)) , _cellWidget, SLOT(setShowSelection(bool)) ); connect ( _controllerAction , SIGNAL(triggered()) , this , SLOT(showController()) ); @@ -236,7 +237,7 @@ namespace Hurricane { connect ( &_selectCommand , SIGNAL(selectionToggled (Occurrence,bool)) , _cellWidget , SLOT (toggleSelect (Occurrence,bool)) ); - _cellWidget->redraw (); + _cellWidget->refresh (); } diff --git a/hurricane/src/hviewer/CellWidget.cpp b/hurricane/src/hviewer/CellWidget.cpp index 0c178741..bb86416c 100644 --- a/hurricane/src/hviewer/CellWidget.cpp +++ b/hurricane/src/hviewer/CellWidget.cpp @@ -23,6 +23,7 @@ // x-----------------------------------------------------------------x +#include #include #include #include @@ -38,6 +39,8 @@ #include "hurricane/Instance.h" #include "hurricane/Slice.h" #include "hurricane/Segment.h" +#include "hurricane/Horizontal.h" +#include "hurricane/Vertical.h" #include "hurricane/Contact.h" #include "hurricane/Pad.h" #include "hurricane/RoutingPad.h" @@ -150,6 +153,16 @@ namespace Hurricane { { _restore = state; } + QPoint CellWidget::Spot::computeSpotPoint ( const QPoint& screenPoint ) + { + Point mousePoint = _cellWidget->screenToDbuPoint ( screenPoint ); + Point spotPoint = Point ( DbU::getOnSnapGrid(mousePoint.getX()) + , DbU::getOnSnapGrid(mousePoint.getY()) + ); + return _cellWidget->dbuToScreenPoint(spotPoint); + } + + void CellWidget::Spot::moveTo ( const QPoint& screenPoint ) { restore (); @@ -158,20 +171,146 @@ namespace Hurricane { _restore = true; QPainter& screenPainter = _cellWidget->getDrawingPlanes().painter(2); - - Point mousePoint = _cellWidget->screenToDbuPoint ( screenPoint ); - Point spotPoint = Point ( DbU::getOnSnapGrid(mousePoint.getX()) - , DbU::getOnSnapGrid(mousePoint.getY()) - ); - QPoint center = _cellWidget->dbuToScreenPoint(spotPoint); + _spotPoint = computeSpotPoint ( screenPoint ); screenPainter.setPen ( Graphics::getPen("spot") ); - screenPainter.drawRect ( center.x()-3, center.y()-3, 6, 6 ); + screenPainter.drawRect ( _spotPoint.x()-3, _spotPoint.y()-3, 6, 6 ); } // ------------------------------------------------------------------- -// Class : "Hurricane::CellWidget::Drawingplanes". +// Class : "Hurricane::CellWidget::RedrawEvent". + + + CellWidget::RedrawEvent::RedrawEvent ( EventType type, int shift, CellWidget* widget ) + : _type(type) + , _shift(shift) + { } + + +// ------------------------------------------------------------------- +// Class : "Hurricane::CellWidget::RedrawManager". + + + CellWidget::RedrawManager::RedrawManager ( CellWidget* widget ) + : _widget (widget) + , _events () + , _overrun(false) + , _refreshInterrupt(false) + { } + + + CellWidget::RedrawManager::~RedrawManager () + { + while ( !_events.empty() ) { + delete _events.front (); + _events.pop_front (); + } + } + + + void CellWidget::RedrawManager::goLeft ( int shift ) + { + list::iterator ievent = _events.end(); + if ( !_events.empty() && (_events.back()->getType() == RedrawEvent::Refresh) ) + --ievent; + _events.insert ( ievent, new RedrawEvent(RedrawEvent::GoLeft,shift,_widget) ); + + if ( !_overrun ) { + if ( _events.size() == 1 ) process (); + else _overrun = true; + } + } + + + void CellWidget::RedrawManager::goRight ( int shift ) + { + list::iterator ievent = _events.end(); + if ( !_events.empty() && (_events.back()->getType() == RedrawEvent::Refresh) ) + --ievent; + _events.insert ( ievent, new RedrawEvent(RedrawEvent::GoRight,shift,_widget) ); + + if ( !_overrun ) { + if ( _events.size() == 1 ) process (); + else _overrun = true; + } + } + + + void CellWidget::RedrawManager::goUp ( int shift ) + { + list::iterator ievent = _events.end(); + if ( !_events.empty() && (_events.back()->getType() == RedrawEvent::Refresh) ) + --ievent; + _events.insert ( ievent, new RedrawEvent(RedrawEvent::GoUp,shift,_widget) ); + + if ( !_overrun ) { + if ( _events.size() == 1 ) process (); + else _overrun = true; + } + } + + + void CellWidget::RedrawManager::goDown ( int shift ) + { + list::iterator ievent = _events.end(); + if ( !_events.empty() && (_events.back()->getType() == RedrawEvent::Refresh) ) + --ievent; + _events.insert ( ievent, new RedrawEvent(RedrawEvent::GoDown,shift,_widget) ); + + if ( !_overrun ) { + if ( _events.size() == 1 ) process (); + else _overrun = true; + } + } + + + void CellWidget::RedrawManager::refresh () + { + if ( !_events.empty() && (_events.back()->getType() == RedrawEvent::Refresh) ) { + _refreshInterrupt = true; + } else if ( _events.empty() ) { + _events.push_back ( new RedrawEvent(RedrawEvent::Refresh,0,_widget) ); + + if ( !_overrun ) { + if ( _events.size() == 1 ) process (); + else _overrun = true; + } + } + } + + + inline void CellWidget::RedrawManager::process () + { + while ( !_events.empty() ) { + RedrawEvent* event = _events.front (); + + switch ( event->getType() ) { + case RedrawEvent::GoLeft: _widget->_goLeft ( event->getShift() ); break; + case RedrawEvent::GoRight: _widget->_goRight ( event->getShift() ); break; + case RedrawEvent::GoUp: _widget->_goUp ( event->getShift() ); break; + case RedrawEvent::GoDown: _widget->_goDown ( event->getShift() ); break; + case RedrawEvent::Refresh: _widget->_refresh (); break; + } + + if ( event->getType() == RedrawEvent::Refresh ) + _events.pop_back (); + else + _events.pop_front (); + + delete event; + + if ( _events.empty() && (_overrun || _refreshInterrupt) ) { + _events.push_back ( new RedrawEvent(RedrawEvent::Refresh,0,_widget) ); + _overrun = false; + _refreshInterrupt = false; + } + } + } + + +// ------------------------------------------------------------------- +// Class : "Hurricane::CellWidget::DrawingPlanes". CellWidget::DrawingPlanes::DrawingPlanes ( const QSize& size, CellWidget* cw ) @@ -330,6 +469,8 @@ namespace Hurricane { : Query() , _cellWidget(widget) , _drawExtensionGo(NULL) + , _goCount(0) + , _instanceCount(0) { } @@ -355,6 +496,8 @@ namespace Hurricane { void CellWidget::DrawingQuery::masterCellCallback () { + _instanceCount++; + Box bbox = getTransformation().getBox(getMasterCell()->getAbutmentBox()); _cellWidget->drawBox ( bbox ); } @@ -380,33 +523,20 @@ namespace Hurricane { { //cerr << "DrawingQuery::drawGo() - " << go << endl; - const Segment* segment = dynamic_cast(go); - if ( segment ) { - if ( 1 < _cellWidget->dbuToDisplayLength(segment->getWidth()) ) { - _cellWidget->drawBox ( transformation.getBox(segment->getBoundingBox(basicLayer)) ); - } else { - _cellWidget->drawLine ( transformation.getPoint(segment->getSourcePosition()) - , transformation.getPoint(segment->getTargetPosition()) ); - } - return; - } + static QRect rectangle; + static unsigned int state; - const Contact* contact = dynamic_cast(go); - if ( contact ) { - _cellWidget->drawBox ( transformation.getBox(contact->getBoundingBox(basicLayer)) ); - return; - } + const Component* component = dynamic_cast(go); + if ( !component ) return; - const Pad* pad = dynamic_cast(go); - if ( pad ) { - _cellWidget->drawBox ( transformation.getBox(pad->getBoundingBox(basicLayer)) ); - return; - } - - const RoutingPad* rp = dynamic_cast(go); - if ( rp ) { - _cellWidget->drawBox ( transformation.getBox(rp->getBoundingBox(basicLayer)) ); - return; + _goCount++; + rectangle = _cellWidget->dbuToDisplayRect ( transformation.getBox(component->getBoundingBox(basicLayer)) ); + state = ( (rectangle.width() > 2) ? 1:0) | ( (rectangle.height() > 2) ? 2:0); + switch ( state ) { + case 0: break; + case 1: _cellWidget->drawScreenLine ( rectangle.bottomLeft(), rectangle.bottomRight() ); break; + case 2: _cellWidget->drawScreenLine ( rectangle.bottomLeft(), rectangle.topLeft () ); break; + case 3: _cellWidget->drawScreenRect ( rectangle ); break; } } @@ -562,13 +692,15 @@ namespace Hurricane { , _visibleArea(_stripWidth,_stripWidth,4*_stripWidth,4*_stripWidth) , _scale(1.0) , _offsetVA(_stripWidth,_stripWidth) + , _redrawManager(this) , _drawingPlanes(QSize(6*_stripWidth,6*_stripWidth),this) , _drawingQuery(this) , _textDrawingQuery(this) - , _queryFilter(Query::DoAll) + , _queryFilter(~Query::DoTerminalCells) , _mousePosition(0,0) , _spot(this) , _cell(NULL) + , _cellChanged(true) , _showBoundaries(true) , _showSelection(false) , _cumulativeSelection(false) @@ -598,8 +730,6 @@ namespace Hurricane { QFont font = Graphics::getNormalFont(); _textFontHeight = QFontMetrics(font).ascent(); - - fitToContents (); } @@ -623,7 +753,7 @@ namespace Hurricane { detachFromPalette (); _palette = palette; - connect ( _palette, SIGNAL(paletteChanged()) , this , SLOT(redraw()) ); + connect ( _palette, SIGNAL(paletteChanged()) , this , SLOT(refresh()) ); connect ( this , SIGNAL(cellChanged(Cell*)) , _palette, SLOT(updateExtensions(Cell*)) ); connect ( this , SIGNAL(updatePalette(Cell*)), _palette, SLOT(updateExtensions(Cell*)) ); } @@ -632,7 +762,7 @@ namespace Hurricane { void CellWidget::detachFromPalette () { if ( _palette ) { - disconnect ( _palette, SIGNAL(paletteChanged()), this, SLOT(redraw()) ); + disconnect ( _palette, SIGNAL(paletteChanged()) , this , SLOT(refresh()) ); disconnect ( this , SIGNAL(cellChanged(Cell*)) , _palette, SLOT(updateExtensions(Cell*)) ); disconnect ( this , SIGNAL(updatePalette(Cell*)), _palette, SLOT(updateExtensions(Cell*)) ); _palette = NULL; @@ -690,7 +820,7 @@ namespace Hurricane { if ( state != _showSelection ) { _showSelection = state; _selectionHasChanged = false; - redraw (); + refresh (); emit showSelectionToggled ( state ); } @@ -703,18 +833,27 @@ namespace Hurricane { } - void CellWidget::redraw ( QRect redrawArea ) + void CellWidget::_redraw ( QRect redrawArea ) { - //cerr << "CellWidget::redraw() - " - // << _selectionHasChanged << " filter:" - // << _queryFilter << endl; +// cerr << "CellWidget::redraw() - start " +// << _selectionHasChanged << " filter:" +// << _queryFilter << endl; + static bool timedout; + static Timer timer; + + if ( !isVisible() ) return; + + timer.start (); + timedout = false; + _cellChanged = false; _redrawRectCount = 0; pushCursor ( Qt::BusyCursor ); if ( ! ( _selectionHasChanged && _showSelection ) || _cellModificated ) { _spot.setRestore ( false ); + _drawingPlanes.copyToSelect (); _drawingPlanes.select ( 0 ); _drawingPlanes.painterBegin (); @@ -722,6 +861,7 @@ namespace Hurricane { _drawingPlanes.painter().setBackground ( Graphics::getBrush("background") ); _drawingPlanes.painter().setClipRect ( redrawArea ); _drawingPlanes.painter().eraseRect ( redrawArea ); + repaint (); int darkening = (_showSelection) ? Graphics::getDarkening() : 100; @@ -729,6 +869,8 @@ namespace Hurricane { Box redrawBox = displayToDbuBox ( redrawArea ); + _drawingQuery.resetGoCount (); + _drawingQuery.resetInstanceCount(); _drawingQuery.setExtensionMask ( 0 ); _drawingQuery.setArea ( redrawBox ); _drawingQuery.setTransformation ( Transformation() ); @@ -737,38 +879,60 @@ namespace Hurricane { _drawingPlanes.setPen ( Graphics::getPen ((*iLayer)->getName(),darkening) ); _drawingPlanes.setBrush ( Graphics::getBrush((*iLayer)->getName(),darkening) ); - if ( isDrawableLayer((*iLayer)->getName()) ) { + if ( isDrawable((*iLayer)->getName()) ) { _drawingQuery.setBasicLayer ( *iLayer ); _drawingQuery.setFilter ( _queryFilter & ~Query::DoMasterCells ); _drawingQuery.doQuery (); + _drawingPlanes.copyToSelect (); + repaint (); + } + QApplication::processEvents(); + if ( _redrawManager.interrupted() ) { + //cerr << "CellWidget::redraw() - interrupt after " << (*iLayer)->getName() << endl; + break; + } + //if ( timeout("redraw [layer]",timer,10.0,timedout) ) break; + } + + if ( /*!timeout("redraw [boundaries]",timer,10.0,timedout) &&*/ (!_redrawManager.interrupted()) ) { + if ( isDrawable("boundaries") ) { + _drawingPlanes.setPen ( Graphics::getPen ("boundaries",darkening) ); + _drawingPlanes.setBrush ( Graphics::getBrush("boundaries",darkening) ); + + _drawingQuery.setBasicLayer ( NULL ); + _drawingQuery.setFilter ( _queryFilter & ~Query::DoComponents ); + _drawingQuery.doQuery (); + _drawingPlanes.copyToSelect (); + repaint (); } } - if ( isDrawableLayer("boundaries") ) { - _drawingPlanes.setPen ( Graphics::getPen ("boundaries",darkening) ); - _drawingPlanes.setBrush ( Graphics::getBrush("boundaries",darkening) ); - - _drawingQuery.setBasicLayer ( NULL ); - _drawingQuery.setFilter ( _queryFilter & ~Query::DoComponents ); - _drawingQuery.doQuery (); - } - - if ( isDrawableLayer("text.instance") ) { - _drawingPlanes.setPen ( Graphics::getPen ("text.instance",darkening) ); - _drawingPlanes.setBrush ( Graphics::getBrush("text.instance",darkening) ); - _drawingPlanes.setBackground ( Graphics::getBrush("boundaries" ,darkening) ); - _textDrawingQuery.setArea ( redrawBox ); - _textDrawingQuery.setTransformation ( Transformation() ); - _textDrawingQuery.doQuery (); + QApplication::processEvents(); + if ( /*!timeout("redraw [text.instances]",timer,10.0,timedout) &&*/ (!_redrawManager.interrupted()) ) { + if ( isDrawable("text.instance") ) { + _drawingPlanes.setPen ( Graphics::getPen ("text.instance",darkening) ); + _drawingPlanes.setBrush ( Graphics::getBrush("text.instance",darkening) ); + _drawingPlanes.setBackground ( Graphics::getBrush("boundaries" ,darkening) ); + _textDrawingQuery.setArea ( redrawBox ); + _textDrawingQuery.setTransformation ( Transformation() ); + _textDrawingQuery.doQuery (); + _drawingPlanes.copyToSelect (); + repaint (); + } } //_drawingQuery.setFilter ( _queryFilter & ~Query::DoMasterCells ); forEach ( ExtensionSlice*, islice, _cell->getExtensionSlices() ) { + QApplication::processEvents(); + if ( /*timeout("redraw [extension]",timer,10.0,timedout) ||*/ (_redrawManager.interrupted()) ) break; + if ( isDrawableExtension((*islice)->getName()) ) { _drawingQuery.setExtensionMask ( (*islice)->getMask() ); _drawingQuery.setDrawExtensionGo ( (*islice)->getName() ); _drawingQuery.setFilter ( Query::DoExtensionGos ); _drawingQuery.doQuery (); + _drawingPlanes.copyToSelect (); + repaint (); } } } @@ -780,12 +944,23 @@ namespace Hurricane { if ( _showSelection ) redrawSelection ( redrawArea ); - - update (); popCursor (); - //cerr << "Redrawed objects: " << _redrawRectCount << endl; - //cerr << "CellWidget::redraw() - finished." << endl; + timer.stop (); +// cerr << "CellWidget::redraw() - " << _redrawRectCount +// << " in " << timer.getCombTime() << "s (" +// << setprecision(3) << (timer.getCombTime()/_redrawRectCount) << " s/r)"; +// if ( _drawingQuery.getGoCount() ) +// cerr << " " << _drawingQuery.getGoCount() +// << " (" << setprecision(3) << (timer.getCombTime()/_drawingQuery.getGoCount()) << " s/go)"; +// else +// cerr << " 0 Gos"; +// if ( _drawingQuery.getInstanceCount() ) +// cerr << " " << _drawingQuery.getInstanceCount() +// << " (" << setprecision(3) << (timer.getCombTime()/_drawingQuery.getInstanceCount()) << " s/inst)"; +// else +// cerr << " 0 Instances"; +// cerr << endl; } @@ -837,6 +1012,7 @@ namespace Hurricane { } end_for; } + repaint (); } _drawingPlanes.painterEnd (); @@ -844,12 +1020,20 @@ namespace Hurricane { } + bool CellWidget::isDrawable ( const Name& name ) + { + PaletteItem* item = (_palette) ? _palette->find(name) : NULL; + + return (!item || item->isItemVisible()) + && ( Graphics::getThreshold(name)/DbU::lambda(1.0) < _scale ); + } + + bool CellWidget::isDrawableLayer ( const Name& layerName ) { PaletteItem* item = (_palette) ? _palette->find(layerName) : NULL; - return (!item || item->isItemVisible()) - && ( Graphics::getThreshold(layerName)/DbU::lambda(1.0) < _scale ); + return !item || item->isItemVisible(); } @@ -927,20 +1111,36 @@ namespace Hurricane { } - void CellWidget::drawScreenPolyline ( const QPoint* points, int count, int width ) + void CellWidget::drawScreenLine ( const QPoint& p1, const QPoint& p2, size_t plane ) { - QPen pen = Graphics::getPen("grid"); - pen.setWidth ( width ); - - _drawingPlanes.painter(2).setPen ( pen ); - _drawingPlanes.painter(2).drawPolyline ( points, count ); + _redrawRectCount++; + _drawingPlanes.setLineMode ( true ); + _drawingPlanes.painter(plane).drawLine ( p1, p2 ); } - void CellWidget::drawScreenRect ( const QPoint& p1, const QPoint& p2 ) + void CellWidget::drawScreenPolyline ( const QPoint* points, int count, int width, size_t plane ) { - _drawingPlanes.painter(2).setPen ( Graphics::getPen("grid") ); - _drawingPlanes.painter(2).drawRect ( QRect(p1,p2) ); + QPen pen = _drawingPlanes.painter(plane).pen (); + pen.setWidth ( width ); + + _drawingPlanes.painter(plane).setPen ( pen ); + _drawingPlanes.painter(plane).drawPolyline ( points, count ); + } + + + void CellWidget::drawScreenRect ( const QPoint& p1, const QPoint& p2, size_t plane ) + { + _drawingPlanes.setLineMode ( false ); + _drawingPlanes.painter(plane).drawRect ( QRect(p1,p2) ); + } + + + void CellWidget::drawScreenRect ( const QRect& r, size_t plane ) + { + _redrawRectCount++; + _drawingPlanes.setLineMode ( false ); + _drawingPlanes.painter(plane).drawRect ( r ); } @@ -987,14 +1187,7 @@ namespace Hurricane { { if ( !dx ) dx = geometry().size().width() / 4; - _visibleArea.translate ( - (DbU::Unit)( dx / _scale ) , 0 ); - - if ( _offsetVA.rx() - dx >= 0 ) { - _offsetVA.rx() -= dx; - update (); - } else { - shiftLeft ( dx ); - } + _redrawManager.goLeft ( dx ); } @@ -1002,15 +1195,7 @@ namespace Hurricane { { if ( !dx ) dx = geometry().size().width() / 4; - //cerr << "CellWidget::goRight() - dx: " << dx << " (offset: " << _offsetVA.rx() << ")" << endl; - _visibleArea.translate ( (DbU::Unit)( dx / _scale ) , 0 ); - - if ( _offsetVA.rx() + dx < 2*_stripWidth ) { - _offsetVA.rx() += dx; - update (); - } else { - shiftRight ( dx ); - } + _redrawManager.goRight ( dx ); } @@ -1018,14 +1203,7 @@ namespace Hurricane { { if ( !dy ) dy = geometry().size().height() / 4; - _visibleArea.translate ( 0, (DbU::Unit)( dy / _scale ) ); - - if ( _offsetVA.ry() - dy >= 0 ) { - _offsetVA.ry() -= dy; - update (); - } else { - shiftUp ( dy ); - } + _redrawManager.goUp ( dy ); } @@ -1033,18 +1211,11 @@ namespace Hurricane { { if ( !dy ) dy = geometry().size().height() / 4; - _visibleArea.translate ( 0, - (DbU::Unit)( dy / _scale ) ); - - if ( _offsetVA.ry() + dy < 2*_stripWidth ) { - _offsetVA.ry() += dy; - update (); - } else { - shiftDown ( dy ); - } + _redrawManager.goDown ( dy ); } - void CellWidget::displayReframe () + void CellWidget::displayReframe ( bool delayed ) { _offsetVA.rx() = _stripWidth; _offsetVA.ry() = _stripWidth; @@ -1056,7 +1227,7 @@ namespace Hurricane { _displayArea = Box ( xmin, ymin, xmax, ymax ); - redraw (); + if ( !delayed ) _redrawManager.refresh (); } @@ -1080,11 +1251,12 @@ namespace Hurricane { } - void CellWidget::reframe ( const Box& box ) + void CellWidget::reframe ( const Box& box, bool delayed ) { //cerr << "CellWidget::reframe() - " << box << endl; //cerr << " widget size := " << _drawingPlanes.width() << "x" << _drawingPlanes.height() << endl; + //cerr << " CellWidget::reframe() - widget size := " << width() << "x" << height() << endl; int width = this->width (); int height = this->height (); @@ -1102,125 +1274,167 @@ namespace Hurricane { , (DbU::Unit)( center.getX() + width / _scale ) , (DbU::Unit)( center.getY() + height / _scale ) ); - displayReframe (); + displayReframe ( delayed ); //cerr << " _displayArea: " << _displayArea << " (offset: " << _offsetVA.x() << ")" << endl; } - void CellWidget::fitToContents () + void CellWidget::fitToContents ( bool delayed ) { - if ( _cell ) reframe ( _cell->getBoundingBox() ); + Box boundingBox = Box ( DbU::lambda(0) + , DbU::lambda(0) + , DbU::lambda(10) + , DbU::lambda(50) + ); + + if ( _cell ) boundingBox = _cell->getBoundingBox(); + reframe ( boundingBox, delayed ); } - void CellWidget::shiftLeft ( int dx ) + void CellWidget::_goLeft ( int dx ) { - //cerr << "CellWidget::shiftLeft() - " << dx << " (offset: " << _offsetVA.rx() << ")" << endl; + _visibleArea.translate ( - (DbU::Unit)( dx / _scale ) , 0 ); - int leftShift = ( 1 + ( dx - _offsetVA.rx() ) / _stripWidth ) * _stripWidth; + if ( _offsetVA.rx() - dx >= 0 ) { + _offsetVA.rx() -= dx; + repaint (); + return; + } - _displayArea.translate ( - (DbU::Unit)( leftShift / _scale ) , 0 ); - _offsetVA.rx() -= dx - leftShift; + int shift = ( 1 + ( dx - _offsetVA.rx() ) / _stripWidth ) * _stripWidth; - if ( leftShift >= _drawingPlanes.width() ) { - redraw (); - } else { - _drawingPlanes.shiftLeft ( leftShift ); + _displayArea.translate ( - (DbU::Unit)( shift / _scale ) , 0 ); + _offsetVA.rx() -= dx - shift; - redraw ( QRect ( QPoint ( 0, 0 ) - , QSize ( leftShift, _drawingPlanes.height() )) ); + if ( shift >= _drawingPlanes.width() ) + _redrawManager.refresh (); + else { + _drawingPlanes.shiftLeft ( shift ); + _redraw ( QRect ( QPoint(0,0), QSize(shift,_drawingPlanes.height()) ) ); } assert ( _offsetVA.rx() >= 0 ); } - void CellWidget::shiftRight ( int dx ) + void CellWidget::_goRight ( int dx ) { - //cerr << "CellWidget::shiftRight() - " << dx << " (offset: " << _offsetVA.rx() << ")" << endl; + //cerr << "CellWidget::goRight() - dx: " << dx << " (offset: " << _offsetVA.rx() << ")" << endl; - int rightShift = ( ( _offsetVA.rx() + dx ) / _stripWidth ) * _stripWidth; + _visibleArea.translate ( (DbU::Unit)( dx / _scale ) , 0 ); - _displayArea.translate ( (DbU::Unit)( rightShift / _scale ) , 0 ); - _offsetVA.rx() += dx - rightShift; + if ( _offsetVA.rx() + dx < 2*_stripWidth ) { + _offsetVA.rx() += dx; + repaint (); + return; + } - //cerr << " _displayArea: " << _displayArea << endl; + int shift = ( ( _offsetVA.rx() + dx ) / _stripWidth ) * _stripWidth; - if ( rightShift >= _drawingPlanes.width() ) { - redraw (); - } else { - _drawingPlanes.shiftRight ( rightShift ); + _displayArea.translate ( (DbU::Unit)( shift / _scale ) , 0 ); + _offsetVA.rx() += dx - shift; - redraw ( QRect ( QPoint ( _drawingPlanes.width()-rightShift, 0 ) - , QSize ( rightShift, _drawingPlanes.height() )) ); + if ( shift >= _drawingPlanes.width() ) + _redrawManager.refresh (); + else { + _drawingPlanes.shiftRight ( shift ); + _redraw ( QRect ( QPoint(_drawingPlanes.width()-shift,0) + , QSize (shift,_drawingPlanes.height()) ) ); } assert ( _offsetVA.rx() >= 0 ); } - void CellWidget::shiftUp ( int dy ) + void CellWidget::_goUp ( int dy ) { //cerr << "CellWidget::shiftUp() - " << dy << " (offset: " << _offsetVA.ry() << ")" << endl; - int upShift = ( 1 + ( dy - _offsetVA.ry() ) / _stripWidth ) * _stripWidth; + _visibleArea.translate ( 0, (DbU::Unit)( dy / _scale ) ); - _displayArea.translate ( 0, (DbU::Unit)( upShift / _scale ) ); - _offsetVA.ry() -= dy - upShift; + if ( _offsetVA.ry() - dy >= 0 ) { + _offsetVA.ry() -= dy; + repaint (); + return; + } - if ( upShift >= _drawingPlanes.height() ) { - redraw (); - } else { - _drawingPlanes.shiftUp ( upShift ); + int shift = ( 1 + ( dy - _offsetVA.ry() ) / _stripWidth ) * _stripWidth; - redraw ( QRect ( QPoint ( 0, 0 ) - , QSize ( _drawingPlanes.width(), upShift )) ); + _displayArea.translate ( 0, (DbU::Unit)( shift / _scale ) ); + _offsetVA.ry() -= dy - shift; + + if ( shift >= _drawingPlanes.height() ) + _redrawManager.refresh (); + else { + _drawingPlanes.shiftUp ( shift ); + _redraw ( QRect ( QPoint(0,0), QSize(_drawingPlanes.width(),shift) ) ); } assert ( _offsetVA.ry() >= 0 ); } - void CellWidget::shiftDown ( int dy ) + void CellWidget::_goDown ( int dy ) { //cerr << "CellWidget::shiftDown() - " << dy << " (offset: " << _offsetVA.ry() << ")" << endl; - int downShift = ( ( _offsetVA.ry() + dy ) / _stripWidth ) * _stripWidth; + _visibleArea.translate ( 0, - (DbU::Unit)( dy / _scale ) ); - _displayArea.translate ( 0, - (DbU::Unit)( downShift / _scale ) ); - _offsetVA.ry() += dy - downShift; + if ( _offsetVA.ry() + dy < 2*_stripWidth ) { + _offsetVA.ry() += dy; + repaint (); + return; + } - if ( downShift >= _drawingPlanes.height() ) { - redraw (); - } else { - _drawingPlanes.shiftDown ( downShift ); + int shift = ( ( _offsetVA.ry() + dy ) / _stripWidth ) * _stripWidth; - redraw ( QRect ( QPoint ( 0, _drawingPlanes.height()-downShift ) - , QSize ( _drawingPlanes.width(), downShift )) ); + _displayArea.translate ( 0, - (DbU::Unit)( shift / _scale ) ); + _offsetVA.ry() += dy - shift; + + if ( shift >= _drawingPlanes.height() ) + _redrawManager.refresh (); + else { + _drawingPlanes.shiftDown ( shift ); + _redraw ( QRect ( QPoint (0,_drawingPlanes.height()-shift) + , QSize (_drawingPlanes.width(), shift) ) ); } assert ( _offsetVA.ry() >= 0 ); } + void CellWidget::_refresh () + { + _redraw ( QRect(QPoint(0,0),_drawingPlanes.size()) ); + } + + + void CellWidget::showEvent ( QShowEvent* ) + { + //cerr << "CellWidget::showEvent() - size: " << geometry().width() << "x" << geometry().height() << endl; + if ( _cellChanged ) fitToContents(); + } + + void CellWidget::paintEvent ( QPaintEvent* event ) { _drawingPlanes.painterBegin ( 2 ); _drawingPlanes.copyToScreen (); - for ( size_t i=0 ; i<_commands.size() ; i++ ) _commands[i]->draw ( this ); - if ( isDrawableLayer("grid") ) drawGrid (); - if ( isDrawableLayer("spot") ) _spot.moveTo ( _mousePosition ); - + if ( isDrawable("grid") ) drawGrid (); + if ( isDrawable("spot") ) _spot.moveTo ( _mousePosition ); _drawingPlanes.painterEnd ( 2 ); } void CellWidget::resizeEvent ( QResizeEvent* ) { + //cerr << "CellWidget::resizeEvent() - size: " << geometry().width() << "x" << geometry().height() << endl; + QSize uaDelta ( 0, 0 ); QSize uaSize = geometry().size(); @@ -1233,24 +1447,26 @@ namespace Hurricane { if ( uaSize.height() > _drawingPlanes.height() ) uaDelta.rheight() = uaSize.height() - _drawingPlanes.height(); - //cerr << "New UA widget size: " << uaSize.width() << "x" << uaSize.height() << endl; - if ( uaDelta.width() || uaDelta.height() ) { _displayArea.inflate ( 0, 0, (DbU::Unit)(uaDelta.width()/_scale), (DbU::Unit)(uaDelta.height()/_scale) ); _visibleArea.inflate ( 0, 0, (DbU::Unit)(uaDelta.width()/_scale), (DbU::Unit)(uaDelta.height()/_scale) ); - //cerr << "new " << _displayArea << endl; - - //cerr << "Previous buffer size: " << _drawingPlanes.width () << "x" - // << _drawingPlanes.height() << endl; QSize bufferSize ( ( ( uaSize.width () / _stripWidth ) + 1 ) * _stripWidth , ( ( uaSize.height() / _stripWidth ) + 1 ) * _stripWidth ); _drawingPlanes.resize ( bufferSize ); - - //cerr << "Effective buffer resize to: " << bufferSize.width() << "x" - // << bufferSize.height() << endl; } - redraw (); + + _redrawManager.refresh (); + } + + + void CellWidget::wheelEvent ( QWheelEvent* event ) + { + bool commandActive = false; + for ( size_t i=0 ; i<_commands.size() && !commandActive; i++ ) + commandActive = _commands[i]->wheelEvent ( this, event ); + + if ( !commandActive ) QWidget::wheelEvent ( event ); } @@ -1264,6 +1480,16 @@ namespace Hurricane { } + void CellWidget::keyReleaseEvent ( QKeyEvent* event ) + { + bool commandActive = false; + for ( size_t i=0 ; i<_commands.size() && !commandActive; i++ ) + commandActive = _commands[i]->keyReleaseEvent ( this, event ); + + if ( !commandActive ) QWidget::keyReleaseEvent ( event ); + } + + void CellWidget::mouseMoveEvent ( QMouseEvent* event ) { bool commandActive = false; @@ -1271,10 +1497,12 @@ namespace Hurricane { commandActive = _commands[i]->mouseMoveEvent ( this, event ); if ( !commandActive ) { - _mousePosition = event->pos(); - emit mousePositionChanged ( screenToDbuPoint(event->pos()) ); + Point mousePoint = screenToDbuPoint ( _mousePosition = event->pos() ); + emit mousePositionChanged ( Point ( DbU::getOnSnapGrid(mousePoint.getX()) + , DbU::getOnSnapGrid(mousePoint.getY()) + ) ); - update (); + repaint (); } } @@ -1341,22 +1569,25 @@ namespace Hurricane { { if ( _showBoundaries != state ) { _showBoundaries = state; - redraw (); + _redrawManager.refresh (); } } void CellWidget::setCell ( Cell* cell ) { + //cerr << "CellWidget::setCell() - " << cell << endl; + cellPreModificate (); - _cell = cell; - _drawingQuery.setCell ( cell ); + _cellChanged = true; + _cell = cell; + _drawingQuery .setCell ( cell ); _textDrawingQuery.setCell ( cell ); emit cellChanged ( cell ); - fitToContents (); + fitToContents ( true ); cellPostModificate (); } @@ -1500,7 +1731,7 @@ namespace Hurricane { } _selectionHasChanged = true; - if ( _showSelection ) redraw (); + if ( _showSelection ) _redrawManager.refresh (); if ( fromPopup ) emit occurrenceToggled ( occurrence ); } @@ -1513,7 +1744,7 @@ namespace Hurricane { Occurrence occurrence ( *component ); select ( occurrence ); } - if ( !delayRedraw && _showSelection ) redraw (); + if ( !delayRedraw && _showSelection ) _redrawManager.refresh (); } @@ -1524,7 +1755,7 @@ namespace Hurricane { Occurrence occurrence ( *component ); unselect ( occurrence ); } - if ( !delayRedraw && _showSelection ) redraw (); + if ( !delayRedraw && _showSelection ) _redrawManager.refresh (); } @@ -1542,7 +1773,7 @@ namespace Hurricane { (*_selectors.begin())->detachFrom ( this ); if ( !_selectionHasChanged ) _selectionHasChanged = true; - if ( !delayRedraw && _showSelection ) redraw (); + if ( !delayRedraw && _showSelection ) _redrawManager.refresh (); } @@ -1563,7 +1794,7 @@ namespace Hurricane { _selection.revalidate (); updatePalette (); - redraw (); + _redrawManager.refresh (); --_delaySelectionChanged; emit selectionChanged(_selectors,_cell); diff --git a/hurricane/src/hviewer/Command.cpp b/hurricane/src/hviewer/Command.cpp index 16fa0ced..70009bcb 100644 --- a/hurricane/src/hviewer/Command.cpp +++ b/hurricane/src/hviewer/Command.cpp @@ -1,36 +1,9 @@ // -*- C++ -*- // -// This file is part of the Coriolis Project. -// Copyright (C) Laboratoire LIP6 - Departement ASIM -// Universite Pierre et Marie Curie +// This file is part of the Coriolis Software. +// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved // -// Main contributors : -// Christophe Alexandre -// Sophie Belloeil -// Hugo Clément -// Jean-Paul Chaput -// Damien Dupuis -// Christian Masson -// Marek Sroka -// -// The Coriolis Project is free software; you can redistribute it -// and/or modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// The Coriolis Project is distributed in the hope that it will be -// useful, but WITHOUT ANY WARRANTY; without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with the Coriolis Project; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// -// License-Tag -// Authors-Tag // =================================================================== // // $Id$ @@ -50,8 +23,9 @@ // x-----------------------------------------------------------------x -# include # include +# include +# include # include # include @@ -78,10 +52,18 @@ namespace Hurricane { } + bool Command::wheelEvent ( CellWidget*, QWheelEvent* ) + { return false; } + + bool Command::keyPressEvent ( CellWidget*, QKeyEvent* ) { return false; } + bool Command::keyReleaseEvent ( CellWidget*, QKeyEvent* ) + { return false; } + + bool Command::mouseMoveEvent ( CellWidget*, QMouseEvent* ) { return false; } diff --git a/hurricane/src/hviewer/ControllerWidget.cpp b/hurricane/src/hviewer/ControllerWidget.cpp index 0f2f17aa..0a6f41c2 100644 --- a/hurricane/src/hviewer/ControllerWidget.cpp +++ b/hurricane/src/hviewer/ControllerWidget.cpp @@ -98,7 +98,7 @@ namespace Hurricane { if ( getCellWidget() != cellWidget ) { ControllerTab::setCellWidget ( cellWidget ); if ( getCellWidget() ) { - connect ( _graphics, SIGNAL(styleChanged()), getCellWidget(), SLOT(redraw()) ); + connect ( _graphics, SIGNAL(styleChanged()), getCellWidget(), SLOT(refresh()) ); } } } @@ -112,7 +112,7 @@ namespace Hurricane { : ControllerTab (parent) , _displayFilter(new DisplayFilterWidget()) { - _displayFilter->setObjectName ( "controller.tabDisplayFilter.graphics" ); + _displayFilter->setObjectName ( "controller.tabDisplayFilter.displayFilter" ); QVBoxLayout* wLayout = new QVBoxLayout (); wLayout->setContentsMargins ( 0, 0, 0, 0 ); @@ -247,7 +247,7 @@ namespace Hurricane { if ( getCellWidget() != cellWidget ) { ControllerTab::setCellWidget ( cellWidget ); if ( getCellWidget() ) { - connect ( getCellWidget(), SIGNAL(cellChanged(Cell*)) , this , SLOT(setCell(Cell*)) ); + connect ( getCellWidget(), SIGNAL(cellChanged(Cell*)), this, SLOT(setCell(Cell*)) ); } setSyncNetlist ( _syncNetlist->isChecked() ); } diff --git a/hurricane/src/hviewer/DisplayFilterWidget.cpp b/hurricane/src/hviewer/DisplayFilterWidget.cpp index df0b3d08..cd326e8f 100644 --- a/hurricane/src/hviewer/DisplayFilterWidget.cpp +++ b/hurricane/src/hviewer/DisplayFilterWidget.cpp @@ -43,11 +43,14 @@ namespace Hurricane { DisplayFilterWidget::DisplayFilterWidget ( QWidget* parent ) - : QWidget(parent) - , _cellWidget(NULL) - , _startSpinBox(new QSpinBox()) - , _stopSpinBox(new QSpinBox()) - , _queryFilter(Query::DoAll) + : QWidget (parent) + , _cellWidget (NULL) + , _startSpinBox (new QSpinBox()) + , _stopSpinBox (new QSpinBox()) + , _doMasterCells (new QCheckBox()) + , _doTerminalCells(new QCheckBox()) + , _doComponents (new QCheckBox()) + , _queryFilter (Query::DoAll) { setAttribute ( Qt::WA_QuitOnClose, false ); setWindowTitle ( tr("Display Filter") ); @@ -81,29 +84,26 @@ namespace Hurricane { separator->setFrameShadow ( QFrame::Sunken ); gLayout->addWidget ( separator, 2, 0, 1, 2 ); - QCheckBox* filterBox = new QCheckBox (); - filterBox->setFont ( Graphics::getNormalFont() ); - filterBox->setText ( tr("Process Master Cells") ); - filterBox->setChecked ( true ); + _doMasterCells->setFont ( Graphics::getNormalFont() ); + _doMasterCells->setText ( tr("Process Master Cells") ); + _doMasterCells->setChecked ( true ); - gLayout->addWidget ( filterBox, 3, 0, 1, 2 ); - connect ( filterBox, SIGNAL(stateChanged(int)), this, SLOT(setDoMasterCells(int)) ); + gLayout->addWidget ( _doMasterCells, 3, 0, 1, 2 ); + connect ( _doMasterCells, SIGNAL(stateChanged(int)), this, SLOT(setDoMasterCells(int)) ); - filterBox = new QCheckBox (); - filterBox->setFont ( Graphics::getNormalFont() ); - filterBox->setText ( tr("Process Terminal Cells") ); - filterBox->setChecked ( true ); + _doTerminalCells->setFont ( Graphics::getNormalFont() ); + _doTerminalCells->setText ( tr("Process Terminal Cells") ); + _doTerminalCells->setChecked ( true ); - gLayout->addWidget ( filterBox, 4, 0, 1, 2 ); - connect ( filterBox, SIGNAL(stateChanged(int)), this, SLOT(setDoTerminalCells(int)) ); + gLayout->addWidget ( _doTerminalCells, 4, 0, 1, 2 ); + connect ( _doTerminalCells, SIGNAL(stateChanged(int)), this, SLOT(setDoTerminalCells(int)) ); - filterBox = new QCheckBox (); - filterBox->setFont ( Graphics::getNormalFont() ); - filterBox->setText ( tr("Process Components") ); - filterBox->setChecked ( true ); + _doComponents->setFont ( Graphics::getNormalFont() ); + _doComponents->setText ( tr("Process Components") ); + _doComponents->setChecked ( true ); - gLayout->addWidget ( filterBox, 5, 0, 1, 2 ); - connect ( filterBox, SIGNAL(stateChanged(int)), this, SLOT(setDoComponents(int)) ); + gLayout->addWidget ( _doComponents, 5, 0, 1, 2 ); + connect ( _doComponents, SIGNAL(stateChanged(int)), this, SLOT(setDoComponents(int)) ); groupBox->setLayout ( gLayout ); wLayout->addWidget ( groupBox ); @@ -119,12 +119,17 @@ namespace Hurricane { { if ( !cw ) { if ( _cellWidget ) - disconnect ( _cellWidget, SLOT(redraw()) ); + disconnect ( _cellWidget, SLOT(refresh()) ); _cellWidget = NULL; return; } + _cellWidget = cw; - connect ( this, SIGNAL(filterChanged()), _cellWidget, SLOT(redraw()) ); + connect ( this, SIGNAL(filterChanged()), _cellWidget, SLOT(refresh()) ); + + _doMasterCells ->setChecked ( _cellWidget->getQueryFilter() & Query::DoMasterCells ); + _doTerminalCells->setChecked ( _cellWidget->getQueryFilter() & Query::DoTerminalCells ); + _doComponents ->setChecked ( _cellWidget->getQueryFilter() & Query::DoComponents ); } diff --git a/hurricane/src/hviewer/MoveCommand.cpp b/hurricane/src/hviewer/MoveCommand.cpp index 8c1f8379..141f5440 100644 --- a/hurricane/src/hviewer/MoveCommand.cpp +++ b/hurricane/src/hviewer/MoveCommand.cpp @@ -1,36 +1,9 @@ // -*- C++ -*- // -// This file is part of the Coriolis Project. -// Copyright (C) Laboratoire LIP6 - Departement ASIM -// Universite Pierre et Marie Curie +// This file is part of the Coriolis Software. +// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved // -// Main contributors : -// Christophe Alexandre -// Sophie Belloeil -// Hugo Clément -// Jean-Paul Chaput -// Damien Dupuis -// Christian Masson -// Marek Sroka -// -// The Coriolis Project is free software; you can redistribute it -// and/or modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// The Coriolis Project is distributed in the hope that it will be -// useful, but WITHOUT ANY WARRANTY; without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with the Coriolis Project; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// -// License-Tag -// Authors-Tag // =================================================================== // // $Id$ @@ -65,9 +38,10 @@ namespace Hurricane { MoveCommand::MoveCommand () - : Command() - , _active(false) + : Command () + , _active (false) , _lastPosition() + , _firstEvent (true) { } @@ -82,26 +56,47 @@ namespace Hurricane { case Qt::Key_Down: widget->goDown (); return true; case Qt::Key_Left: widget->goLeft (); return true; case Qt::Key_Right: widget->goRight (); return true; + case Qt::Key_Space: + if ( !_active ) { + _active = true; + _firstEvent = true; + //_lastPosition = widget->getMousePosition(); + widget->pushCursor ( Qt::ClosedHandCursor ); + return true; + } } return false; } + bool MoveCommand::keyReleaseEvent ( CellWidget* widget, QKeyEvent* event ) + { + switch ( event->key() ) { + case Qt::Key_Space: + if ( _active && !event->isAutoRepeat() ) { + _active = false; + widget->popCursor (); + } + break; + } + } + + bool MoveCommand::mouseMoveEvent ( CellWidget* widget, QMouseEvent* event ) { if ( !_active ) return false; - int dx = event->x() - _lastPosition.x(); - dx <<= 1; + QPoint eventPosition = event->pos(); + if ( _firstEvent ) { _firstEvent = false; _lastPosition = eventPosition; } + + int dx = ( eventPosition.x() - _lastPosition.x() ) << 1; + int dy = ( eventPosition.y() - _lastPosition.y() ) << 1; + _lastPosition = eventPosition; + if ( dx > 0 ) widget->goLeft ( dx ); if ( dx < 0 ) widget->goRight ( -dx ); - - int dy = event->y() - _lastPosition.y(); - dy <<= 1; - if ( dy > 0 ) widget->goUp ( dy ); - if ( dy < 0 ) widget->goDown ( -dy ); - - _lastPosition = event->pos(); + if ( dy > 0 ) widget->goUp ( dy ); + if ( dy < 0 ) widget->goDown ( -dy ); return true; } @@ -109,26 +104,13 @@ namespace Hurricane { bool MoveCommand::mousePressEvent ( CellWidget* widget, QMouseEvent* event ) { - if ( _active ) return true; - - if ( ( event->button() == Qt::LeftButton ) && !event->modifiers() ) { - _active = true; - _lastPosition = event->pos(); - widget->pushCursor ( Qt::ClosedHandCursor ); - } - return _active; } bool MoveCommand::mouseReleaseEvent ( CellWidget* widget, QMouseEvent* event ) { - if ( !_active ) return false; - - _active = false; - widget->popCursor (); - - return false; + return _active; } diff --git a/hurricane/src/hviewer/PaletteWidget.cpp b/hurricane/src/hviewer/PaletteWidget.cpp index 561d685d..59bbcda9 100644 --- a/hurricane/src/hviewer/PaletteWidget.cpp +++ b/hurricane/src/hviewer/PaletteWidget.cpp @@ -299,16 +299,17 @@ namespace Hurricane { } _extensionGoItems.clear (); - if ( !cell ) return; GridBuffer gridBuffer ( _grid, 22, _extensionRow, _extensionColumn ); _extensionGroup = _createGroupItem ( "Extensions" ); gridBuffer.addSection ( _extensionGroup, Qt::AlignHCenter ); - forEach ( ExtensionSlice*, extension, cell->getExtensionSlices() ) { - PaletteExtensionGoItem* item = _createExtensionGoItem ( (*extension)->getName(), false ); - gridBuffer.addWidget ( item ); - _extensionGoItems [ item->getName() ] = item; + if ( cell ) { + forEach ( ExtensionSlice*, extension, cell->getExtensionSlices() ) { + PaletteExtensionGoItem* item = _createExtensionGoItem ( (*extension)->getName(), false ); + gridBuffer.addWidget ( item ); + _extensionGoItems [ item->getName() ] = item; + } } gridBuffer.flushWidgets (); } diff --git a/hurricane/src/hviewer/SelectCommand.cpp b/hurricane/src/hviewer/SelectCommand.cpp index f0d6cbd9..8c8855aa 100644 --- a/hurricane/src/hviewer/SelectCommand.cpp +++ b/hurricane/src/hviewer/SelectCommand.cpp @@ -109,10 +109,10 @@ namespace Hurricane { if ( !_selectAction->isChecked() ) _selectAction->setChecked ( true ); else - widget->redraw (); + widget->refresh (); } else { widget->setShowSelection ( true ); - widget->redraw (); + widget->refresh (); } return false; diff --git a/hurricane/src/hviewer/SelectionModel.cpp b/hurricane/src/hviewer/SelectionModel.cpp index 1443516f..67acaab8 100644 --- a/hurricane/src/hviewer/SelectionModel.cpp +++ b/hurricane/src/hviewer/SelectionModel.cpp @@ -154,7 +154,7 @@ namespace Hurricane { if ( role == Qt::DisplayRole ) { switch ( index.column() ) { - case 0: return getString(_selection[row]._occurrence.getPath()).c_str(); + case 0: return getString(_selection[row]._occurrence.getPath().getName()).c_str(); case 1: return getString(_selection[row]._occurrence.getEntity()).c_str(); } } diff --git a/hurricane/src/hviewer/SelectionPopupModel.cpp b/hurricane/src/hviewer/SelectionPopupModel.cpp index bbc33146..5a270c4d 100644 --- a/hurricane/src/hviewer/SelectionPopupModel.cpp +++ b/hurricane/src/hviewer/SelectionPopupModel.cpp @@ -98,7 +98,7 @@ namespace Hurricane { if ( _occurrences ) { if ( row < (int)_occurrences->size() ) { if ( index.column() == 0 ) { - name = getString ( (*_occurrences)[row].getPath() ) + name = getString ( (*_occurrences)[row].getPath().getName() ) + "::" + getString ( (*_occurrences)[row].getEntity() ); return name.c_str(); } diff --git a/hurricane/src/hviewer/ZoomCommand.cpp b/hurricane/src/hviewer/ZoomCommand.cpp index dd589be3..0f232159 100644 --- a/hurricane/src/hviewer/ZoomCommand.cpp +++ b/hurricane/src/hviewer/ZoomCommand.cpp @@ -1,36 +1,9 @@ // -*- C++ -*- // -// This file is part of the Coriolis Project. -// Copyright (C) Laboratoire LIP6 - Departement ASIM -// Universite Pierre et Marie Curie +// This file is part of the Coriolis Software. +// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved // -// Main contributors : -// Christophe Alexandre -// Sophie Belloeil -// Hugo Clément -// Jean-Paul Chaput -// Damien Dupuis -// Christian Masson -// Marek Sroka -// -// The Coriolis Project is free software; you can redistribute it -// and/or modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// The Coriolis Project is distributed in the hope that it will be -// useful, but WITHOUT ANY WARRANTY; without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with the Coriolis Project; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// -// License-Tag -// Authors-Tag // =================================================================== // // $Id$ @@ -53,6 +26,7 @@ # include # include +# include # include # include @@ -73,6 +47,16 @@ namespace Hurricane { { } + bool ZoomCommand::wheelEvent ( CellWidget* widget, QWheelEvent* event ) + { + if ( event->delta() > 0 ) widget->setScale ( widget->getScale()/1.2 ); + else if ( event->delta() < 0 ) widget->setScale ( widget->getScale()*1.2 ); + event->accept (); + + return true; + } + + bool ZoomCommand::keyPressEvent ( CellWidget* widget, QKeyEvent* event ) { switch ( event->key() ) { @@ -87,7 +71,7 @@ namespace Hurricane { { if ( isActive() ) return true; - if ( (event->button() == Qt::LeftButton) && (event->modifiers() & Qt::ControlModifier) ) { + if ( ( event->button() == Qt::LeftButton ) && !event->modifiers() ) { setActive ( true ); setStartPoint ( event->pos() ); setDrawingEnabled ( true ); @@ -104,7 +88,11 @@ namespace Hurricane { setActive ( false ); setDrawingEnabled ( false ); - widget->reframe ( widget->screenToDbuBox(QRect(_startPoint,_stopPoint)) ); + QRect zoomArea = QRect ( _startPoint, _stopPoint ); + if ( ( zoomArea.width() > 10 ) && ( zoomArea.height() > 10 ) ) + widget->reframe ( widget->screenToDbuBox(zoomArea) ); + else + cerr << Warning("Rejecting too small zoom request.") << endl; return false; } diff --git a/hurricane/src/hviewer/hurricane/viewer/CellViewer.h b/hurricane/src/hviewer/hurricane/viewer/CellViewer.h index 35415281..c3c63c5b 100644 --- a/hurricane/src/hviewer/hurricane/viewer/CellViewer.h +++ b/hurricane/src/hviewer/hurricane/viewer/CellViewer.h @@ -109,6 +109,7 @@ namespace Hurricane { ZoomCommand _zoomCommand; SelectCommand _selectCommand; list _cellHistory; + bool _firstShow; protected: void createActions (); diff --git a/hurricane/src/hviewer/hurricane/viewer/CellWidget.h b/hurricane/src/hviewer/hurricane/viewer/CellWidget.h index 9a2e7e49..b0474f51 100644 --- a/hurricane/src/hviewer/hurricane/viewer/CellWidget.h +++ b/hurricane/src/hviewer/hurricane/viewer/CellWidget.h @@ -37,13 +37,16 @@ #include class QCursor; +class QShowEvent; class QResizeEvent; class QMouseEvent; class QKeyEvent; class QAction; +#include "hurricane/Timer.h" #include "hurricane/Commons.h" +#include "hurricane/Warning.h" #include "hurricane/Point.h" #include "hurricane/Box.h" #include "hurricane/Transformation.h" @@ -111,14 +114,19 @@ namespace Hurricane { inline void setStartLevel ( int ); inline void setStopLevel ( int ); inline void setQueryFilter ( int ); + inline int getQueryFilter () const ; + inline bool timeout ( const char*, const Timer&, double timeout, bool& timedout ) const; // Painter control & Hurricane objects drawing primitives. inline void addDrawExtensionGo ( const Name&, InitExtensionGo_t*, DrawExtensionGo_t* ); - inline QPainter& getPainter (); + inline QPainter& getPainter ( size_t plane=3 ); inline float getScale () const; + inline const QPoint& getMousePosition () const; + bool isDrawable ( const Name& ); bool isDrawableLayer ( const Name& ); bool isDrawableExtension ( const Name& ); bool isSelectable ( const Name& ) const; bool isSelectable ( const Layer* ) const; + inline void setPen ( const QPen& , size_t plane=3 ); void drawBox ( DbU::Unit, DbU::Unit, DbU::Unit, DbU::Unit ); void drawBox ( const Box& ); void drawLine ( DbU::Unit, DbU::Unit, DbU::Unit, DbU::Unit ); @@ -126,8 +134,10 @@ namespace Hurricane { void drawText ( const Point&, const Name&, int angle=0, bool reverse=false ); void drawGrid (); void drawSpot (); - void drawScreenRect ( const QPoint&, const QPoint& ); - void drawScreenPolyline ( const QPoint*, int, int ); + void drawScreenLine ( const QPoint&, const QPoint&, size_t plane=3 ); + void drawScreenRect ( const QPoint&, const QPoint&, size_t plane=3 ); + void drawScreenRect ( const QRect&, size_t plane=3 ); + void drawScreenPolyline ( const QPoint*, int, int, size_t plane=3 ); // Geometric conversions. QRect dbuToDisplayRect ( DbU::Unit x1, DbU::Unit y1, DbU::Unit x2, DbU::Unit y2 ) const; QRect dbuToDisplayRect ( const Box& box ) const; @@ -151,13 +161,16 @@ namespace Hurricane { // Qt QWidget Functions Overloads. 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* ); + virtual QSize minimumSizeHint () const; + virtual void showEvent ( QShowEvent* ); + virtual void paintEvent ( QPaintEvent* ); + virtual void resizeEvent ( QResizeEvent* ); + virtual void wheelEvent ( QWheelEvent* ); + virtual void keyPressEvent ( QKeyEvent* ); + virtual void keyReleaseEvent ( QKeyEvent* ); + virtual void mouseMoveEvent ( QMouseEvent* ); + virtual void mousePressEvent ( QMouseEvent* ); + virtual void mouseReleaseEvent ( QMouseEvent* ); signals: void cellChanged ( Cell* ); void cellPreModificated (); @@ -188,32 +201,35 @@ namespace Hurricane { void updatePalette (); void cellPreModificate (); void cellPostModificate (); - inline void redraw (); - void redraw ( QRect redrawArea ); + inline void refresh (); + void _redraw ( QRect redrawArea ); inline void redrawSelection (); void redrawSelection ( QRect redrawArea ); void goLeft ( int dx = 0 ); void goRight ( int dx = 0 ); void goUp ( int dy = 0 ); void goDown ( int dy = 0 ); - void fitToContents (); + void fitToContents ( bool delayed=false ); void setScale ( float scale ); void setShowBoundaries ( bool state ); - void reframe ( const Box& box ); - void displayReframe (); - void shiftLeft ( int dx ); - void shiftRight ( int dx ); - void shiftUp ( int dy ); - void shiftDown ( int dy ); + void reframe ( const Box& box, bool delayed=false ); + void displayReframe ( bool delayed=false ); + void _goLeft ( int dx ); + void _goRight ( int dx ); + void _goUp ( int dy ); + void _goDown ( int dy ); + void _refresh (); private: class Spot { public: - Spot ( CellWidget* cw ); - void setRestore ( bool restore ); - inline void setShowSpot ( bool show ); - void restore (); - void moveTo ( const QPoint& point ); + Spot ( CellWidget* ); + void setRestore ( bool ); + inline void setShowSpot ( bool ); + inline const QPoint& getSpotPoint () const; + void restore (); + QPoint computeSpotPoint ( const QPoint& ); + void moveTo ( const QPoint& ); private: CellWidget* _cellWidget; QPoint _spotPoint; @@ -221,6 +237,46 @@ namespace Hurricane { bool _showSpot; }; + private: + class RedrawEvent { + public: + enum EventType { GoLeft = 1 + , GoRight = 2 + , GoUp = 3 + , GoDown = 4 + , Refresh = 5 + }; + public: + RedrawEvent ( EventType, int shift, CellWidget* ); + inline EventType getType () const; + inline int getShift () const; + private: + EventType _type; + int _shift; + }; + + private: + class RedrawManager { + public: + inline RedrawManager ( CellWidget* ); + ~RedrawManager (); + void goLeft ( int ); + void goRight ( int ); + void goUp ( int ); + void goDown ( int ); + void refresh (); + void process (); + inline void clearOverrun (); + inline bool isOverrun () const; + inline bool interrupted () const; + inline size_t getPendings () const; + private: + CellWidget* _widget; + list _events; + bool _overrun; + bool _refreshInterrupt; + }; + private: class DrawingPlanes { public: @@ -231,15 +287,10 @@ namespace Hurricane { inline int height () const; inline QSize size () const; inline void select ( size_t i ); - inline QPixmap* plane (); - inline QPixmap* plane ( size_t i ); - inline QPainter& painter (); - inline QPainter& painter ( size_t i ); - inline void painterBegin (); - inline void painterBegin ( size_t i ); + inline QPainter& painter ( size_t i=3 ); + inline void painterBegin ( size_t i=3 ); inline void paintersBegin (); - inline void painterEnd (); - inline void painterEnd ( size_t i ); + inline void painterEnd ( size_t i=3 ); inline void paintersEnd (); void setLineMode ( bool mode ); void setPen ( const QPen& pen ); @@ -271,35 +322,41 @@ namespace Hurricane { private: class DrawingQuery : public Query { public: - DrawingQuery ( CellWidget* widget ); - inline void setQuery ( const Box& area - , const Transformation& transformation - , const BasicLayer* basicLayer - , ExtensionSlice::Mask extensionMask - , unsigned int filter - ); - inline void addDrawExtensionGo ( const Name& - , InitExtensionGo_t* - , DrawExtensionGo_t* - ); - void setDrawExtensionGo ( const Name& ); - virtual bool hasMasterCellCallback () const; - virtual bool hasGoCallback () const; - virtual bool hasExtensionGoCallback () const; - virtual void masterCellCallback (); - virtual void goCallback ( Go* go ); - virtual void extensionGoCallback ( Go* go ); - void drawGo ( const Go* go - , const BasicLayer* basicLayer - , const Box& area - , const Transformation& transformation - ); + DrawingQuery ( CellWidget* widget ); + inline void setQuery ( const Box& area + , const Transformation& transformation + , const BasicLayer* basicLayer + , ExtensionSlice::Mask extensionMask + , unsigned int filter + ); + inline void addDrawExtensionGo ( const Name& + , InitExtensionGo_t* + , DrawExtensionGo_t* + ); + void setDrawExtensionGo ( const Name& ); + virtual bool hasMasterCellCallback () const; + virtual bool hasGoCallback () const; + virtual bool hasExtensionGoCallback () const; + virtual void masterCellCallback (); + virtual void goCallback ( Go* go ); + virtual void extensionGoCallback ( Go* go ); + void drawGo ( const Go* go + , const BasicLayer* basicLayer + , const Box& area + , const Transformation& transformation + ); + inline unsigned int getGoCount () const; + inline unsigned int getInstanceCount () const; + inline void resetGoCount (); + inline void resetInstanceCount (); protected: CellWidget* _cellWidget; DrawExtensionGo_t* _drawExtensionGo; map > _drawExtensionGos; + unsigned int _goCount; + unsigned int _instanceCount; }; private: @@ -346,6 +403,7 @@ namespace Hurricane { Box _visibleArea; float _scale; QPoint _offsetVA; + RedrawManager _redrawManager; DrawingPlanes _drawingPlanes; DrawingQuery _drawingQuery; TextDrawingQuery _textDrawingQuery; @@ -353,6 +411,7 @@ namespace Hurricane { QPoint _mousePosition; Spot _spot; Cell* _cell; + bool _cellChanged; bool _showBoundaries; bool _showSelection; bool _cumulativeSelection; @@ -364,6 +423,8 @@ namespace Hurricane { vector _commands; size_t _redrawRectCount; int _textFontHeight; + + friend class RedrawManager; }; @@ -371,6 +432,10 @@ namespace Hurricane { { _showSpot = show; } + inline const QPoint& CellWidget::Spot::getSpotPoint () const + { return _spotPoint; } + + inline void CellWidget::DrawingQuery::setQuery ( const Box& area , const Transformation& transformation , const BasicLayer* basicLayer @@ -395,6 +460,46 @@ namespace Hurricane { { _drawExtensionGos[name] = make_pair(initExtensionGo,drawExtensionGo); } + inline void CellWidget::DrawingQuery::resetGoCount () + { _goCount = 0; } + + + inline void CellWidget::DrawingQuery::resetInstanceCount () + { _instanceCount = 0; } + + + inline unsigned int CellWidget::DrawingQuery::getGoCount () const + { return _goCount; } + + + inline unsigned int CellWidget::DrawingQuery::getInstanceCount () const + { return _instanceCount; } + + + inline CellWidget::RedrawEvent::EventType CellWidget::RedrawEvent::getType () const + { return _type; } + + + inline int CellWidget::RedrawEvent::getShift () const + { return _shift; } + + + inline bool CellWidget::RedrawManager::isOverrun () const + { return _overrun; } + + + inline void CellWidget::RedrawManager::clearOverrun () + { _overrun = false; } + + + inline size_t CellWidget::RedrawManager::getPendings () const + { return _events.size(); } + + + inline bool CellWidget::RedrawManager::interrupted () const + { return ( _events.size() > 5 ) || _refreshInterrupt; } + + inline bool CellWidget::DrawingPlanes::getLineMode () const { return _lineMode; } @@ -415,28 +520,13 @@ namespace Hurricane { { _workingPlane = i; } - inline QPixmap* CellWidget::DrawingPlanes::plane () - { return plane(_workingPlane); } - - - inline QPixmap* CellWidget::DrawingPlanes::plane ( size_t i ) - { return _planes[i]; } - - - inline QPainter& CellWidget::DrawingPlanes::painter () - { return painter(_workingPlane); } - - inline QPainter& CellWidget::DrawingPlanes::painter ( size_t i ) - { return _painters[i]; } - - - inline void CellWidget::DrawingPlanes::painterBegin () - { painterBegin ( _workingPlane ); } + { return _painters[(i>2)?_workingPlane:i]; } inline void CellWidget::DrawingPlanes::painterBegin ( size_t i ) { + if ( i>2 ) i = _workingPlane; if ( i<2 ) _painters[i].begin ( _planes[i] ); else _painters[i].begin ( _cellWidget ); } @@ -449,12 +539,8 @@ namespace Hurricane { } - inline void CellWidget::DrawingPlanes::painterEnd () - { painterEnd ( _workingPlane ); } - - inline void CellWidget::DrawingPlanes::painterEnd ( size_t i ) - { _painters[i].end (); } + { _painters[(i>2)?_workingPlane:i].end (); } inline void CellWidget::DrawingPlanes::paintersEnd () @@ -503,8 +589,8 @@ namespace Hurricane { { return _offsetVA; } - inline void CellWidget::redraw () - { redraw ( QRect(QPoint(0,0),_drawingPlanes.size()) ); } + inline void CellWidget::refresh () + { _redrawManager.refresh(); } inline void CellWidget::redrawSelection () @@ -599,18 +685,42 @@ namespace Hurricane { { return _cumulativeSelection; } - inline QPainter& CellWidget::getPainter () - { return _drawingPlanes.painter(); } + inline QPainter& CellWidget::getPainter ( size_t plane ) + { return _drawingPlanes.painter(plane); } inline float CellWidget::getScale () const { return _scale; } + inline const QPoint& CellWidget::getMousePosition () const + { return _mousePosition; } + + inline void CellWidget::setQueryFilter ( int filter ) { _queryFilter = filter; } + inline int CellWidget::getQueryFilter () const + { return _queryFilter; } + + + inline void CellWidget::setPen ( const QPen& pen, size_t plane ) + { _drawingPlanes.painter(plane).setPen(pen); } + + + inline bool CellWidget::timeout ( const char* fname, const Timer& timer, double timeout, bool& timedout ) const + { + if ( timedout ) return true; + if ( timer.getCombTimeOnTheFly() < timeout ) return false; + + timedout = true; + cerr << Warning("CellWidget::%s(): timeout %.3f (limit:%.1f)." + ,fname,timer.getCombTimeOnTheFly(),timeout) << endl; + return true; + } + + } // End of Hurricane namespace. diff --git a/hurricane/src/hviewer/hurricane/viewer/Command.h b/hurricane/src/hviewer/hurricane/viewer/Command.h index 604aabe7..9a1339a0 100644 --- a/hurricane/src/hviewer/hurricane/viewer/Command.h +++ b/hurricane/src/hviewer/hurricane/viewer/Command.h @@ -1,36 +1,9 @@ // -*- C++ -*- // -// This file is part of the Coriolis Project. -// Copyright (C) Laboratoire LIP6 - Departement ASIM -// Universite Pierre et Marie Curie +// This file is part of the Coriolis Software. +// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved // -// Main contributors : -// Christophe Alexandre -// Sophie Belloeil -// Hugo Clément -// Jean-Paul Chaput -// Damien Dupuis -// Christian Masson -// Marek Sroka -// -// The Coriolis Project is free software; you can redistribute it -// and/or modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// The Coriolis Project is distributed in the hope that it will be -// useful, but WITHOUT ANY WARRANTY; without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with the Coriolis Project; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// -// License-Tag -// Authors-Tag // =================================================================== // // $Id$ @@ -61,6 +34,7 @@ using namespace std; class QKeyEvent; class QMouseEvent; +class QWheelEvent; namespace Hurricane { @@ -75,7 +49,9 @@ namespace Hurricane { virtual ~Command (); inline bool isActive (); inline void setActive ( bool state ); + virtual bool wheelEvent ( CellWidget*, QWheelEvent* ); virtual bool keyPressEvent ( CellWidget*, QKeyEvent* ); + virtual bool keyReleaseEvent ( CellWidget*, QKeyEvent* ); virtual bool mouseMoveEvent ( CellWidget*, QMouseEvent* ); virtual bool mousePressEvent ( CellWidget*, QMouseEvent* ); virtual bool mouseReleaseEvent ( CellWidget*, QMouseEvent* ); diff --git a/hurricane/src/hviewer/hurricane/viewer/DisplayFilterWidget.h b/hurricane/src/hviewer/hurricane/viewer/DisplayFilterWidget.h index 9012032d..991d87c8 100644 --- a/hurricane/src/hviewer/hurricane/viewer/DisplayFilterWidget.h +++ b/hurricane/src/hviewer/hurricane/viewer/DisplayFilterWidget.h @@ -30,6 +30,7 @@ #include class QSpinBox; +class QCheckBox; namespace Hurricane { @@ -59,6 +60,9 @@ namespace Hurricane { CellWidget* _cellWidget; QSpinBox* _startSpinBox; QSpinBox* _stopSpinBox; + QCheckBox* _doMasterCells; + QCheckBox* _doTerminalCells; + QCheckBox* _doComponents; int _queryFilter; }; diff --git a/hurricane/src/hviewer/hurricane/viewer/MoveCommand.h b/hurricane/src/hviewer/hurricane/viewer/MoveCommand.h index 386df873..e8298ae3 100644 --- a/hurricane/src/hviewer/hurricane/viewer/MoveCommand.h +++ b/hurricane/src/hviewer/hurricane/viewer/MoveCommand.h @@ -1,36 +1,9 @@ // -*- C++ -*- // -// This file is part of the Coriolis Project. -// Copyright (C) Laboratoire LIP6 - Departement ASIM -// Universite Pierre et Marie Curie +// This file is part of the Coriolis Software. +// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved // -// Main contributors : -// Christophe Alexandre -// Sophie Belloeil -// Hugo Clément -// Jean-Paul Chaput -// Damien Dupuis -// Christian Masson -// Marek Sroka -// -// The Coriolis Project is free software; you can redistribute it -// and/or modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// The Coriolis Project is distributed in the hope that it will be -// useful, but WITHOUT ANY WARRANTY; without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with the Coriolis Project; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// -// License-Tag -// Authors-Tag // =================================================================== // // $Id$ @@ -66,11 +39,13 @@ namespace Hurricane { MoveCommand (); virtual ~MoveCommand (); virtual bool keyPressEvent ( CellWidget*, QKeyEvent* ); + virtual bool keyReleaseEvent ( CellWidget*, QKeyEvent* ); virtual bool mouseMoveEvent ( CellWidget*, QMouseEvent* ); virtual bool mousePressEvent ( CellWidget*, QMouseEvent* ); virtual bool mouseReleaseEvent ( CellWidget*, QMouseEvent* ); protected: bool _active; + bool _firstEvent; QPoint _lastPosition; private: MoveCommand ( const MoveCommand& ); diff --git a/hurricane/src/hviewer/hurricane/viewer/ZoomCommand.h b/hurricane/src/hviewer/hurricane/viewer/ZoomCommand.h index c90f3351..3a976123 100644 --- a/hurricane/src/hviewer/hurricane/viewer/ZoomCommand.h +++ b/hurricane/src/hviewer/hurricane/viewer/ZoomCommand.h @@ -1,36 +1,9 @@ // -*- C++ -*- // -// This file is part of the Coriolis Project. -// Copyright (C) Laboratoire LIP6 - Departement ASIM -// Universite Pierre et Marie Curie +// This file is part of the Coriolis Software. +// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved // -// Main contributors : -// Christophe Alexandre -// Sophie Belloeil -// Hugo Clément -// Jean-Paul Chaput -// Damien Dupuis -// Christian Masson -// Marek Sroka -// -// The Coriolis Project is free software; you can redistribute it -// and/or modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// The Coriolis Project is distributed in the hope that it will be -// useful, but WITHOUT ANY WARRANTY; without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with the Coriolis Project; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// -// License-Tag -// Authors-Tag // =================================================================== // // $Id$ @@ -65,6 +38,7 @@ namespace Hurricane { public: ZoomCommand (); virtual ~ZoomCommand (); + virtual bool wheelEvent ( CellWidget*, QWheelEvent* ); virtual bool keyPressEvent ( CellWidget*, QKeyEvent* ); virtual bool mousePressEvent ( CellWidget*, QMouseEvent* ); virtual bool mouseReleaseEvent ( CellWidget*, QMouseEvent* );