* ./hurricane/src/hviewer :

- New feature: CellWidget now store it's internal state in a separate
        nested object CellWidgetState. The State is work in progress, currently
        is store the Cell*, showSelection, cumulativeSelection, selection
        criterions and showBoundaries. showBoundaries may evolve to be stored
        as part of the Palette's state.
    - Change: implement the "start" propagation model signal/slot for
        showSelection, cumulativeSelection & showBoundaries. The main concern
        is to avoid signals loop. See SelectionWidget::setShowSelection(bool)
        for an example.
    - Change: supress the minimumSize of the SelectionWidget (200 pixels is a
        waste of space when the Path is empty).
This commit is contained in:
Jean-Paul Chaput 2009-01-27 10:14:46 +00:00
parent e58c397360
commit 8961968b8b
11 changed files with 408 additions and 234 deletions

View File

@ -249,13 +249,15 @@ namespace Hurricane {
connect ( this , SIGNAL(redrawCellWidget()) , _cellWidget, SLOT(refresh()) ); connect ( this , SIGNAL(redrawCellWidget()) , _cellWidget, SLOT(refresh()) );
connect ( _refreshAction , SIGNAL(triggered()) , _cellWidget, SLOT(refresh()) ); connect ( _refreshAction , SIGNAL(triggered()) , _cellWidget, SLOT(refresh()) );
connect ( _fitToContentsAction , SIGNAL(triggered()) , _cellWidget, SLOT(fitToContents()) ); connect ( _fitToContentsAction , SIGNAL(triggered()) , _cellWidget, SLOT(fitToContents()) );
connect ( _showSelectionAction , SIGNAL(toggled(bool)) , _cellWidget, SLOT(setShowSelection(bool)) ); connect ( _showSelectionAction , SIGNAL(toggled(bool)) , this , SLOT(setShowSelection(bool)) );
connect ( _rubberChangeAction , SIGNAL(triggered()) , _cellWidget, SLOT(rubberChange()) ); connect ( _rubberChangeAction , SIGNAL(triggered()) , _cellWidget, SLOT(rubberChange()) );
connect ( _controllerAction , SIGNAL(triggered()) , this , SLOT(showController()) ); connect ( _controllerAction , SIGNAL(triggered()) , this , SLOT(showController()) );
connect ( _cellWidget , SIGNAL(mousePositionChanged(const Point&)) connect ( _cellWidget , SIGNAL(mousePositionChanged(const Point&))
, _mousePosition , SLOT(setPosition(const Point&)) ); , _mousePosition , SLOT(setPosition(const Point&)) );
connect ( this , SIGNAL(showSelectionToggled(bool))
, _cellWidget , SLOT (setShowSelection (bool)) );
connect ( _cellWidget , SIGNAL(showSelectionToggled(bool)) connect ( _cellWidget , SIGNAL(showSelectionToggled(bool))
, _showSelectionAction , SLOT(setChecked(bool)) ); , this , SLOT (setShowSelection (bool)) );
connect ( &_selectCommand , SIGNAL(selectionToggled (Occurrence,bool)) connect ( &_selectCommand , SIGNAL(selectionToggled (Occurrence,bool))
, _cellWidget , SLOT (toggleSelect (Occurrence,bool)) ); , _cellWidget , SLOT (toggleSelect (Occurrence,bool)) );
@ -323,6 +325,24 @@ namespace Hurricane {
} }
void CellViewer::setShowSelection ( bool state )
{
static bool isEmitter = false;
if ( sender() == _showSelectionAction ) {
isEmitter = true;
emit showSelectionToggled ( state );
} else {
if ( !isEmitter ) {
_showSelectionAction->blockSignals ( true );
_showSelectionAction->setChecked ( state );
_showSelectionAction->blockSignals ( false );
} else
isEmitter = false;
}
}
void CellViewer::openHistoryCell () void CellViewer::openHistoryCell ()
{ {
QAction* historyAction = qobject_cast<QAction*> ( sender() ); QAction* historyAction = qobject_cast<QAction*> ( sender() );

View File

@ -2,7 +2,7 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved // Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved
// //
// =================================================================== // ===================================================================
// //
@ -768,8 +768,8 @@ namespace Hurricane {
// Class : "Hurricane::CellWidget::SelectorCriterions". // Class : "Hurricane::CellWidget::SelectorCriterions".
CellWidget::SelectorCriterions::SelectorCriterions ( CellWidget* cw ) CellWidget::SelectorCriterions::SelectorCriterions ()
: _cellWidget(cw) : _cellWidget(NULL)
, _criterions() , _criterions()
{ } { }
@ -782,6 +782,7 @@ namespace Hurricane {
bool CellWidget::SelectorCriterions::add ( const Net* net, bool delayRedraw ) bool CellWidget::SelectorCriterions::add ( const Net* net, bool delayRedraw )
{ {
if ( !_cellWidget ) return false;
if ( !_cellWidget->isSelected(Occurrence(net)) ) { if ( !_cellWidget->isSelected(Occurrence(net)) ) {
_criterions.push_back ( new NetSelectorCriterion(net) ); _criterions.push_back ( new NetSelectorCriterion(net) );
_criterions.back()->doSelection ( _cellWidget, delayRedraw ); _criterions.back()->doSelection ( _cellWidget, delayRedraw );
@ -793,6 +794,7 @@ namespace Hurricane {
bool CellWidget::SelectorCriterions::add ( Box area ) bool CellWidget::SelectorCriterions::add ( Box area )
{ {
if ( !_cellWidget ) return false;
_criterions.push_back ( new AreaSelectorCriterion(area) ); _criterions.push_back ( new AreaSelectorCriterion(area) );
_criterions.back()->doSelection ( _cellWidget, true ); _criterions.back()->doSelection ( _cellWidget, true );
return true; return true;
@ -801,6 +803,7 @@ namespace Hurricane {
bool CellWidget::SelectorCriterions::remove ( const Net* net, bool delayRedraw ) bool CellWidget::SelectorCriterions::remove ( const Net* net, bool delayRedraw )
{ {
if ( !_cellWidget ) return false;
if ( !_cellWidget->isSelected(Occurrence(net)) ) return false; if ( !_cellWidget->isSelected(Occurrence(net)) ) return false;
size_t i=0; size_t i=0;
@ -820,14 +823,17 @@ namespace Hurricane {
void CellWidget::SelectorCriterions::clear () void CellWidget::SelectorCriterions::clear ()
{ {
for ( size_t i=0 ; i<_criterions.size() ; i++ ) for ( size_t i=0 ; i<_criterions.size() ; i++ ) {
delete _criterions[i]; delete _criterions[i];
}
_criterions.clear (); _criterions.clear ();
} }
void CellWidget::SelectorCriterions::revalidate () void CellWidget::SelectorCriterions::revalidate ()
{ {
if ( !_cellWidget ) return;
size_t i = 0; size_t i = 0;
size_t last = _criterions.size (); size_t last = _criterions.size ();
while ( i < last ) { while ( i < last ) {
@ -865,16 +871,12 @@ namespace Hurricane {
, _darkening (100) , _darkening (100)
, _mousePosition (0,0) , _mousePosition (0,0)
, _spot (this) , _spot (this)
, _cell (NULL) , _state (new State(NULL))
, _cellChanged (true) , _cellChanged (true)
, _showBoundaries (true)
, _showSelection (false)
, _cumulativeSelection (false)
, _selectionHasChanged (false) , _selectionHasChanged (false)
, _delaySelectionChanged(0) , _delaySelectionChanged(0)
, _cellModificated (true) , _cellModificated (true)
, _selectors () , _selectors ()
, _selection (this)
, _commands () , _commands ()
, _redrawRectCount (0) , _redrawRectCount (0)
, _textFontHeight (20) , _textFontHeight (20)
@ -1004,8 +1006,8 @@ namespace Hurricane {
void CellWidget::setShowSelection ( bool state ) void CellWidget::setShowSelection ( bool state )
{ {
if ( state != _showSelection ) { if ( state != _state->showSelection() ) {
_showSelection = state; _state->setShowSelection ( state );
_selectionHasChanged = false; _selectionHasChanged = false;
refresh (); refresh ();
@ -1016,7 +1018,21 @@ namespace Hurricane {
void CellWidget::setCumulativeSelection ( bool state ) void CellWidget::setCumulativeSelection ( bool state )
{ {
_cumulativeSelection = state; if ( state != _state->cumulativeSelection() ) {
_state->setCumulativeSelection ( state );
emit cumulativeSelectionToggled ( state );
}
}
void CellWidget::setShowBoundaries ( bool state )
{
if ( _state->showBoundaries() != state ) {
_state->setShowBoundaries ( state );
refresh ();
emit showBoundariesToggled ( state );
}
} }
@ -1038,7 +1054,7 @@ namespace Hurricane {
pushCursor ( Qt::BusyCursor ); pushCursor ( Qt::BusyCursor );
if ( ! ( _selectionHasChanged && _showSelection ) || _cellModificated ) { if ( ! ( _selectionHasChanged && _state->showSelection() ) || _cellModificated ) {
_spot.setRestore ( false ); _spot.setRestore ( false );
//_drawingPlanes.copyToSelect ( redrawArea ); //_drawingPlanes.copyToSelect ( redrawArea );
_drawingPlanes.select ( PlaneId::Normal ); _drawingPlanes.select ( PlaneId::Normal );
@ -1050,9 +1066,9 @@ namespace Hurricane {
_drawingPlanes.painter().eraseRect ( redrawArea ); _drawingPlanes.painter().eraseRect ( redrawArea );
//repaint (); //repaint ();
setDarkening ( (_showSelection) ? Graphics::getDarkening() : 100 ); setDarkening ( (_state->showSelection()) ? Graphics::getDarkening() : 100 );
if ( _cell ) { if ( getCell() ) {
Box redrawBox = displayToDbuBox ( redrawArea ); Box redrawBox = displayToDbuBox ( redrawArea );
@ -1123,7 +1139,7 @@ namespace Hurricane {
} }
//_drawingQuery.setFilter ( _queryFilter & ~Query::DoMasterCells ); //_drawingQuery.setFilter ( _queryFilter & ~Query::DoMasterCells );
forEach ( ExtensionSlice*, islice, _cell->getExtensionSlices() ) { forEach ( ExtensionSlice*, islice, getCell()->getExtensionSlices() ) {
QApplication::processEvents(); QApplication::processEvents();
if ( /*timeout("redraw [extension]",timer,10.0,timedout) ||*/ (_redrawManager.interrupted()) ) break; if ( /*timeout("redraw [extension]",timer,10.0,timedout) ||*/ (_redrawManager.interrupted()) ) break;
@ -1146,7 +1162,7 @@ namespace Hurricane {
if ( isDrawable("grid") ) drawGrid ( redrawArea ); if ( isDrawable("grid") ) drawGrid ( redrawArea );
setDarkening ( 100 ); setDarkening ( 100 );
if ( _showSelection ) if ( _state->showSelection() )
redrawSelection ( redrawArea ); redrawSelection ( redrawArea );
popCursor (); popCursor ();
@ -1188,7 +1204,7 @@ namespace Hurricane {
_drawingPlanes.painter().setBackground ( Graphics::getBrush("background") ); _drawingPlanes.painter().setBackground ( Graphics::getBrush("background") );
_drawingPlanes.painter().setClipRect ( redrawArea ); _drawingPlanes.painter().setClipRect ( redrawArea );
if ( _cell ) { if ( getCell() ) {
Box redrawBox = displayToDbuBox ( redrawArea ); Box redrawBox = displayToDbuBox ( redrawArea );
SelectorSet::iterator iselector; SelectorSet::iterator iselector;
@ -1539,7 +1555,7 @@ namespace Hurricane {
, DbU::lambda(50) , DbU::lambda(50)
); );
if ( _cell ) boundingBox = _cell->getBoundingBox(); if ( getCell() ) boundingBox = getCell()->getBoundingBox();
reframe ( boundingBox, delayed ); reframe ( boundingBox, delayed );
} }
@ -1840,27 +1856,35 @@ namespace Hurricane {
} }
void CellWidget::setShowBoundaries ( bool state )
{
if ( _showBoundaries != state ) {
_showBoundaries = state;
_redrawManager.refresh ();
}
}
void CellWidget::setCell ( Cell* cell ) void CellWidget::setCell ( Cell* cell )
{ {
//cerr << "CellWidget::setCell() - " << cell << endl; //cerr << "CellWidget::setCell() - " << cell << endl;
if ( cell == getCell() ) return;
shared_ptr<State> state ( new State(cell) );
setState ( state );
}
void CellWidget::setState ( shared_ptr<State>& state )
{
//cerr << "CellWidget::setCell() - " << cell << endl;
if ( state.get() == _state.get() ) return;
cellPreModificate (); cellPreModificate ();
_state->getSelection().clear ();
_state->setCellWidget ( NULL );
_cellChanged = true; _cellChanged = true;
_cell = cell; _state = state;
_drawingQuery .setCell ( cell );
_textDrawingQuery.setCell ( cell );
emit cellChanged ( cell ); _state->setCellWidget ( this );
_drawingQuery .setCell ( getCell() );
_textDrawingQuery.setCell ( getCell() );
emit cellChanged ( getCell() );
fitToContents ( true ); fitToContents ( true );
@ -1878,10 +1902,10 @@ namespace Hurricane {
{ {
++_delaySelectionChanged; ++_delaySelectionChanged;
if ( !_cumulativeSelection ) unselectAll ( true ); if ( !_state->cumulativeSelection() ) unselectAll ( true );
bool added = _selection.add ( net, delayRedraw ); bool added = _state->getSelection().add ( net, delayRedraw );
if ( !--_delaySelectionChanged && added ) emit selectionChanged(_selectors,_cell); if ( !--_delaySelectionChanged && added ) emit selectionChanged(_selectors,getCell());
} }
@ -1890,8 +1914,12 @@ namespace Hurricane {
if ( !occurrence.isValid() ) if ( !occurrence.isValid() )
throw Error ( "Can't select occurrence : invalid occurrence" ); throw Error ( "Can't select occurrence : invalid occurrence" );
if ( occurrence.getOwnerCell() != getCell() ) if ( occurrence.getOwnerCell() != getCell() ) {
throw Error ( "Can't select occurrence : incompatible occurrence" ); string s1 = Graphics::toHtml ( getString(occurrence.getOwnerCell()) );
string s2 = Graphics::toHtml ( getString(getCell()) );
throw Error ( "Can't select occurrence : incompatible occurrence %s vs. %s"
, s1.c_str(), s2.c_str() );
}
Property* property = occurrence.getProperty ( Selector::getPropertyName() ); Property* property = occurrence.getProperty ( Selector::getPropertyName() );
if ( !property ) if ( !property )
@ -1910,10 +1938,14 @@ namespace Hurricane {
if ( !occurrence.isValid() ) if ( !occurrence.isValid() )
throw Error ( "Can't select occurrence : invalid occurrence" ); throw Error ( "Can't select occurrence : invalid occurrence" );
if ( occurrence.getOwnerCell() != getCell() ) if ( occurrence.getOwnerCell() != getCell() ) {
throw Error ( "Can't select occurrence : incompatible occurrence" ); string s1 = Graphics::toHtml ( getString(occurrence.getOwnerCell()) );
string s2 = Graphics::toHtml ( getString(getCell()) );
throw Error ( "Can't select occurrence : incompatible occurrence %s vs. %s"
, s1.c_str(), s2.c_str() );
}
//if ( !_cumulativeSelection ) unselectAll ( true ); //if ( !_state->cumulativeSelection() ) unselectAll ( true );
Property* property = occurrence.getProperty ( Selector::getPropertyName() ); Property* property = occurrence.getProperty ( Selector::getPropertyName() );
Selector* selector = NULL; Selector* selector = NULL;
@ -1928,7 +1960,7 @@ namespace Hurricane {
selector->attachTo(this); selector->attachTo(this);
_selectionHasChanged = true; _selectionHasChanged = true;
if ( !_delaySelectionChanged ) emit selectionChanged(_selectors,_cell); if ( !_delaySelectionChanged ) emit selectionChanged(_selectors,getCell());
} }
@ -1936,10 +1968,10 @@ namespace Hurricane {
{ {
++_delaySelectionChanged; ++_delaySelectionChanged;
if ( !_cumulativeSelection ) unselectAll ( true ); if ( !_state->cumulativeSelection() ) unselectAll ( true );
bool added = _selection.add ( selectArea ); bool added = _state->getSelection().add ( selectArea );
if ( !--_delaySelectionChanged && added ) emit selectionChanged(_selectors,_cell); if ( !--_delaySelectionChanged && added ) emit selectionChanged(_selectors,getCell());
} }
@ -1947,8 +1979,8 @@ namespace Hurricane {
{ {
++_delaySelectionChanged; ++_delaySelectionChanged;
bool removed = _selection.remove ( net, delayRedraw ); bool removed = _state->getSelection().remove ( net, delayRedraw );
if ( !--_delaySelectionChanged && removed ) emit selectionChanged(_selectors,_cell); if ( !--_delaySelectionChanged && removed ) emit selectionChanged(_selectors,getCell());
} }
@ -1970,7 +2002,7 @@ namespace Hurricane {
} }
_selectionHasChanged = true; _selectionHasChanged = true;
if ( !_delaySelectionChanged ) emit selectionChanged(_selectors,_cell); if ( !_delaySelectionChanged ) emit selectionChanged(_selectors,getCell());
} }
@ -1978,10 +2010,10 @@ namespace Hurricane {
{ {
++_delaySelectionChanged; ++_delaySelectionChanged;
_selection.clear (); _state->getSelection().clear ();
_unselectAll ( delayRedraw ); _unselectAll ( delayRedraw );
if ( !--_delaySelectionChanged ) emit selectionChanged(_selectors,_cell); if ( !--_delaySelectionChanged ) emit selectionChanged(_selectors,getCell());
} }
@ -2006,7 +2038,7 @@ namespace Hurricane {
} }
_selectionHasChanged = true; _selectionHasChanged = true;
if ( _showSelection ) _redrawManager.refresh (); if ( _state->showSelection() ) _redrawManager.refresh ();
if ( fromPopup ) emit occurrenceToggled ( occurrence ); if ( fromPopup ) emit occurrenceToggled ( occurrence );
} }
@ -2023,7 +2055,7 @@ namespace Hurricane {
Occurrence occurrence ( *rubber ); Occurrence occurrence ( *rubber );
select ( occurrence ); select ( occurrence );
} }
if ( !delayRedraw && _showSelection ) _redrawManager.refresh (); if ( !delayRedraw && _state->showSelection() ) _redrawManager.refresh ();
} }
@ -2038,7 +2070,7 @@ namespace Hurricane {
Occurrence occurrence ( *rubber ); Occurrence occurrence ( *rubber );
unselect ( occurrence ); unselect ( occurrence );
} }
if ( !delayRedraw && _showSelection ) _redrawManager.refresh (); if ( !delayRedraw && _state->showSelection() ) _redrawManager.refresh ();
} }
@ -2056,7 +2088,7 @@ namespace Hurricane {
(*_selectors.begin())->detachFrom ( this ); (*_selectors.begin())->detachFrom ( this );
if ( !_selectionHasChanged ) _selectionHasChanged = true; if ( !_selectionHasChanged ) _selectionHasChanged = true;
if ( !delayRedraw && _showSelection ) _redrawManager.refresh (); if ( !delayRedraw && _state->showSelection() ) _redrawManager.refresh ();
} }
@ -2064,7 +2096,7 @@ namespace Hurricane {
{ {
_unselectAll ( true ); _unselectAll ( true );
emit selectionChanged(_selectors,_cell); emit selectionChanged(_selectors,getCell());
emit cellPreModificated (); emit cellPreModificated ();
} }
@ -2074,13 +2106,13 @@ namespace Hurricane {
_cellModificated = true; _cellModificated = true;
++_delaySelectionChanged; ++_delaySelectionChanged;
_selection.revalidate (); _state->getSelection().revalidate ();
updatePalette (); updatePalette ();
_redrawManager.refresh (); _redrawManager.refresh ();
--_delaySelectionChanged; --_delaySelectionChanged;
emit selectionChanged(_selectors,_cell); emit selectionChanged(_selectors,getCell());
emit cellPostModificated (); emit cellPostModificated ();
} }

View File

@ -296,12 +296,12 @@ namespace Hurricane {
, _selection , SLOT (toggleSelection (Occurrence)) ); , _selection , SLOT (toggleSelection (Occurrence)) );
connect ( _selection , SIGNAL(cumulativeToggled (bool)) connect ( _selection , SIGNAL(cumulativeToggled (bool))
, getCellWidget(), SLOT (setCumulativeSelection(bool)) ); , getCellWidget(), SLOT (setCumulativeSelection(bool)) );
connect ( _selection , SIGNAL(selectionCleared())
, getCellWidget(), SLOT (unselectAll ()) );
connect ( _selection , SIGNAL(showSelectionToggled(bool)) connect ( _selection , SIGNAL(showSelectionToggled(bool))
, getCellWidget(), SLOT (setShowSelection (bool)) ); , getCellWidget(), SLOT (setShowSelection (bool)) );
connect ( getCellWidget(), SIGNAL(showSelectionToggled(bool)) connect ( getCellWidget(), SIGNAL(showSelectionToggled(bool))
, _selection , SLOT (setShowSelection (bool)) ); , _selection , SLOT (setShowSelection (bool)) );
connect ( _selection , SIGNAL(selectionCleared())
, getCellWidget(), SLOT (unselectAll ()) );
} }
} }
} }

View File

@ -273,6 +273,26 @@ namespace Hurricane {
} }
string Graphics::toHtml ( const string& s )
{
string protect = s;
if ( !isEnabled() ) return protect;
unsigned int pos = protect.find ( '<' );
while ( pos < protect.size() ) {
protect.replace ( pos, 1, "&lt;" );
pos = protect.find ( '<', pos );
}
pos = protect.find ( '>' );
while ( pos < protect.size() ) {
protect.replace ( pos, 1, "&gt;" );
pos = protect.find ( '>', pos );
}
return protect;
}
bool Graphics::breakpointStopCb ( const string& message ) bool Graphics::breakpointStopCb ( const string& message )
{ {
static BreakpointWidget* bpw = NULL; static BreakpointWidget* bpw = NULL;

View File

@ -2,7 +2,7 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved // Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved
// //
// =================================================================== // ===================================================================
// //

View File

@ -101,7 +101,7 @@ namespace Hurricane {
QHeaderView* horizontalHeader = _view->horizontalHeader (); QHeaderView* horizontalHeader = _view->horizontalHeader ();
horizontalHeader->setStretchLastSection ( true ); horizontalHeader->setStretchLastSection ( true );
horizontalHeader->setMinimumSectionSize ( 200 ); //horizontalHeader->setMinimumSectionSize ( 200 );
QHeaderView* verticalHeader = _view->verticalHeader (); QHeaderView* verticalHeader = _view->verticalHeader ();
verticalHeader->setVisible ( false ); verticalHeader->setVisible ( false );
@ -119,7 +119,7 @@ namespace Hurricane {
, this , SLOT(textFilterChanged()) ); , this , SLOT(textFilterChanged()) );
connect ( _baseModel , SIGNAL(layoutChanged()), this, SLOT (forceRowHeight()) ); connect ( _baseModel , SIGNAL(layoutChanged()), this, SLOT (forceRowHeight()) );
connect ( _cumulative , SIGNAL(toggled(bool)) , this, SIGNAL(cumulativeToggled(bool)) ); connect ( _cumulative , SIGNAL(toggled(bool)) , this, SIGNAL(cumulativeToggled(bool)) );
connect ( _showSelection, SIGNAL(toggled(bool)) , this, SIGNAL(showSelectionToggled(bool)) ); connect ( _showSelection, SIGNAL(toggled(bool)) , this, SLOT (setShowSelection(bool)) );
connect ( clear , SIGNAL(clicked()) , this, SIGNAL(selectionCleared()) ); connect ( clear , SIGNAL(clicked()) , this, SIGNAL(selectionCleared()) );
connect ( clear , SIGNAL(clicked()) , _baseModel, SLOT(clear()) ); connect ( clear , SIGNAL(clicked()) , _baseModel, SLOT(clear()) );
connect ( _view->selectionModel(), SIGNAL(currentChanged(const QModelIndex&,const QModelIndex&)) connect ( _view->selectionModel(), SIGNAL(currentChanged(const QModelIndex&,const QModelIndex&))
@ -180,10 +180,19 @@ namespace Hurricane {
void SelectionWidget::setShowSelection ( bool state ) void SelectionWidget::setShowSelection ( bool state )
{ {
if ( state == _showSelection->isChecked() ) return; static bool isEmitter = false;
if ( sender() == _showSelection ) {
isEmitter = true;
emit showSelectionToggled ( state );
} else {
if ( !isEmitter ) {
_showSelection->blockSignals ( true );
_showSelection->setChecked ( state ); _showSelection->setChecked ( state );
emit showSelection ( state ); _showSelection->blockSignals ( false );
} else
isEmitter = false;
}
} }
@ -206,6 +215,7 @@ namespace Hurricane {
void SelectionWidget::clear () void SelectionWidget::clear ()
{ {
_baseModel->clear (); _baseModel->clear ();
_view->selectionModel()->clearSelection ();
} }

View File

@ -77,10 +77,12 @@ namespace Hurricane {
void unselect ( Occurrence& occurence ); void unselect ( Occurrence& occurence );
void unselectAll (); void unselectAll ();
public slots: public slots:
void setShowSelection ( bool );
void showController (); void showController ();
void openHistoryCell (); void openHistoryCell ();
void printDisplay (); void printDisplay ();
signals: signals:
void showSelectionToggled ( bool );
void redrawCellWidget (); void redrawCellWidget ();
public: public:

View File

@ -29,6 +29,7 @@
#include <math.h> #include <math.h>
#include <vector> #include <vector>
#include <tr1/memory>
#include <QWidget> #include <QWidget>
#include <QPixmap> #include <QPixmap>
@ -63,6 +64,9 @@ class QAction;
namespace Hurricane { namespace Hurricane {
using std::vector;
using std::tr1::shared_ptr;
class Technology; class Technology;
class BasicLayer; class BasicLayer;
class Go; class Go;
@ -86,6 +90,7 @@ namespace Hurricane {
private: private:
class DrawingPlanes; class DrawingPlanes;
public: public:
class State;
typedef void ( DrawExtensionGo_t )( CellWidget* typedef void ( DrawExtensionGo_t )( CellWidget*
, const Go* , const Go*
, const BasicLayer* , const BasicLayer*
@ -93,7 +98,6 @@ namespace Hurricane {
, const Transformation& , const Transformation&
); );
typedef void ( InitExtensionGo_t )( CellWidget* ); typedef void ( InitExtensionGo_t )( CellWidget* );
public:
enum RubberShape { Centric = 1 enum RubberShape { Centric = 1
, Barycentric , Barycentric
, Steiner , Steiner
@ -105,7 +109,9 @@ namespace Hurricane {
// Accessors. // Accessors.
// MapView* getMapView () { return _mapView; }; // MapView* getMapView () { return _mapView; };
void setCell ( Cell* ); void setCell ( Cell* );
void setState ( shared_ptr<State>& );
inline Cell* getCell () const; inline Cell* getCell () const;
inline shared_ptr<State>& getState ();
inline PaletteWidget* getPalette (); inline PaletteWidget* getPalette ();
void bindToPalette ( PaletteWidget* ); void bindToPalette ( PaletteWidget* );
void detachFromPalette (); void detachFromPalette ();
@ -193,6 +199,8 @@ namespace Hurricane {
void selectionChanged ( const SelectorSet&, Cell* ); void selectionChanged ( const SelectorSet&, Cell* );
void occurrenceToggled ( Occurrence ); void occurrenceToggled ( Occurrence );
void showSelectionToggled ( bool ); void showSelectionToggled ( bool );
void cumulativeSelectionToggled ( bool );
void showBoundariesToggled ( bool );
public slots: public slots:
// Qt QWidget Slots Overload & CellWidget Specifics. // Qt QWidget Slots Overload & CellWidget Specifics.
inline DrawingPlanes& getDrawingPlanes (); inline DrawingPlanes& getDrawingPlanes ();
@ -427,18 +435,42 @@ namespace Hurricane {
private: private:
class SelectorCriterions { class SelectorCriterions {
public: public:
SelectorCriterions ( CellWidget* ); SelectorCriterions ();
~SelectorCriterions (); ~SelectorCriterions ();
inline void setCellWidget ( CellWidget* );
bool add ( const Net* net, bool delayRedraw ); bool add ( const Net* net, bool delayRedraw );
bool add ( Box area ); bool add ( Box area );
bool remove ( const Net* net, bool delayRedraw ); bool remove ( const Net* net, bool delayRedraw );
void clear (); void clear ();
void revalidate (); void revalidate ();
inline size_t size () const;
private: private:
CellWidget* _cellWidget; CellWidget* _cellWidget;
vector<SelectorCriterion*> _criterions; vector<SelectorCriterion*> _criterions;
}; };
public:
class State {
public:
inline State ( Cell* cell=NULL );
inline void setCell ( Cell* );
inline void setCellWidget ( CellWidget* );
inline void setShowBoundaries ( bool );
inline void setShowSelection ( bool );
inline void setCumulativeSelection ( bool );
inline Cell* getCell () const;
inline SelectorCriterions& getSelection ();
inline bool showBoundaries () const;
inline bool showSelection () const;
inline bool cumulativeSelection () const;
private:
Cell* _cell;
SelectorCriterions _selection;
bool _showBoundaries;
bool _showSelection;
bool _cumulativeSelection;
};
protected: protected:
// Internal: Attributes. // Internal: Attributes.
static const int _stripWidth; static const int _stripWidth;
@ -459,16 +491,12 @@ namespace Hurricane {
int _darkening; int _darkening;
QPoint _mousePosition; QPoint _mousePosition;
Spot _spot; Spot _spot;
Cell* _cell; shared_ptr<State> _state;
bool _cellChanged; bool _cellChanged;
bool _showBoundaries;
bool _showSelection;
bool _cumulativeSelection;
bool _selectionHasChanged; bool _selectionHasChanged;
int _delaySelectionChanged; int _delaySelectionChanged;
bool _cellModificated; bool _cellModificated;
SelectorSet _selectors; SelectorSet _selectors;
SelectorCriterions _selection;
vector<Command*> _commands; vector<Command*> _commands;
size_t _redrawRectCount; size_t _redrawRectCount;
int _textFontHeight; int _textFontHeight;
@ -641,6 +669,67 @@ namespace Hurricane {
} }
inline void CellWidget::SelectorCriterions::setCellWidget ( CellWidget* cw )
{ _cellWidget = cw; }
inline size_t CellWidget::SelectorCriterions::size () const
{ return _criterions.size(); }
inline CellWidget::State::State ( Cell* cell )
: _cell (cell)
, _selection ()
, _showBoundaries (true)
, _showSelection (false)
, _cumulativeSelection(false)
{ }
inline void CellWidget::State::setCell ( Cell* cell )
{ _cell = cell; }
inline void CellWidget::State::setCellWidget ( CellWidget* cw )
{ _selection.setCellWidget ( cw ); }
inline void CellWidget::State::setShowBoundaries ( bool state )
{ _showBoundaries = state; }
inline void CellWidget::State::setShowSelection ( bool state )
{ _showSelection = state; }
inline void CellWidget::State::setCumulativeSelection ( bool state )
{ _cumulativeSelection = state; }
inline Cell* CellWidget::State::getCell () const
{ return _cell; }
inline CellWidget::SelectorCriterions& CellWidget::State::getSelection ()
{ return _selection; }
inline bool CellWidget::State::showBoundaries () const
{ return _showBoundaries; }
inline bool CellWidget::State::showSelection () const
{ return _showSelection; }
inline bool CellWidget::State::cumulativeSelection () const
{ return _cumulativeSelection; }
inline shared_ptr<CellWidget::State>& CellWidget::getState ()
{ return _state; }
inline void CellWidget::addDrawExtensionGo ( const Name& name inline void CellWidget::addDrawExtensionGo ( const Name& name
, InitExtensionGo_t* initExtensionGo , InitExtensionGo_t* initExtensionGo
, DrawExtensionGo_t* drawExtensionGo , DrawExtensionGo_t* drawExtensionGo
@ -753,7 +842,7 @@ namespace Hurricane {
inline Cell* CellWidget::getCell () const inline Cell* CellWidget::getCell () const
{ return _cell; } { return _state->getCell(); }
inline PaletteWidget* CellWidget::getPalette () inline PaletteWidget* CellWidget::getPalette ()
@ -761,15 +850,15 @@ namespace Hurricane {
inline bool CellWidget::showBoundaries () const inline bool CellWidget::showBoundaries () const
{ return _showBoundaries; } { return _state->showBoundaries(); }
inline bool CellWidget::showSelection () const inline bool CellWidget::showSelection () const
{ return _showSelection; } { return _state->showSelection(); }
inline bool CellWidget::cumulativeSelection () const inline bool CellWidget::cumulativeSelection () const
{ return _cumulativeSelection; } { return _state->cumulativeSelection(); }
inline QPainter& CellWidget::getPainter ( size_t plane ) inline QPainter& CellWidget::getPainter ( size_t plane )

View File

@ -2,7 +2,7 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved // Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved
// //
// =================================================================== // ===================================================================
// //
@ -66,6 +66,7 @@ namespace Hurricane {
static float getThreshold ( const Name& key ); static float getThreshold ( const Name& key );
static int getDarkening (); static int getDarkening ();
static const ColorScale& getColorScale ( ColorScale::ScaleType ); static const ColorScale& getColorScale ( ColorScale::ScaleType );
static string toHtml ( const string& );
static bool breakpointStopCb ( const string& message ); static bool breakpointStopCb ( const string& message );
// Modifiers. // Modifiers.

View File

@ -149,6 +149,7 @@ namespace Hurricane {
void NetlistWidget::setCell ( Cell* cell ) void NetlistWidget::setCell ( Cell* cell )
{ {
_cell = cell; _cell = cell;
_view->selectionModel()->clear ();
_baseModel->setCell<InformationType> ( cell ); _baseModel->setCell<InformationType> ( cell );
string windowTitle = "Netlist" + getString(cell); string windowTitle = "Netlist" + getString(cell);

View File

@ -59,16 +59,15 @@ namespace Hurricane {
SelectionWidget ( QWidget* parent=NULL ); SelectionWidget ( QWidget* parent=NULL );
void inspect ( const QModelIndex& index ); void inspect ( const QModelIndex& index );
bool isCumulative () const; bool isCumulative () const;
void clear ();
signals: signals:
void showSelection ( bool ); void showSelectionToggled ( bool );
void occurrenceToggled ( Occurrence, bool ); void occurrenceToggled ( Occurrence, bool );
void cumulativeToggled ( bool ); void cumulativeToggled ( bool );
void showSelectionToggled ( bool );
void selectionCleared (); void selectionCleared ();
void inspect ( Record* ); void inspect ( Record* );
void inspect ( Occurrence& ); void inspect ( Occurrence& );
public slots: public slots:
void clear ();
void setShowSelection ( bool ); void setShowSelection ( bool );
void selectCurrent ( const QModelIndex& current, const QModelIndex& ); void selectCurrent ( const QModelIndex& current, const QModelIndex& );
void setSelection ( const SelectorSet& selection, Cell* cell=NULL ); void setSelection ( const SelectorSet& selection, Cell* cell=NULL );