More fixes for the selection & inspector mechanisms.

* Bug: In Common.h, makes the INSPECTOR_PV_SUPPORT to generate a getRecord()
    by *value* instead of *by reference*. Seems the overload resolution
    system has changed and discriminate between them using now the exact
    match.
      This was causing InspectorWidget::setRootoccurrence() to fail, the
    getRecord(Occurrence) not corectly resolved always returning NULL.
* Change: In Occurrence, now use INSPECTOR_PV_SUPPORT (instead of PR).
* Change: In SelectionPopup, added a _cellWidget attribute to be able
    to call setShowSelection() in ::mouseReleaseEvent(), same as for
    SelectCommand.
* Bug: In SelectionWidget::changeSelectionMode(), reset the _updateState
    to ExternalEmit in *all cases* at the end of the function call.
    Failing to do that was another cause for the selection check box
    to desinchronize.
This commit is contained in:
Jean-Paul Chaput 2021-11-09 10:53:56 +01:00
parent f5bfeb3eae
commit fcf6ec97c3
14 changed files with 153 additions and 152 deletions

View File

@ -993,6 +993,15 @@ inline Hurricane::Record* getRecord ( const std::multiset<Element,Compare>* s )
GETRECORD_REFERENCE_SUPPORT(Data)
# define INSPECTOR_PV_SUPPORT(Data) \
GETSTRING_POINTER_SUPPORT(Data) \
GETSTRING_VALUE_SUPPORT(Data) \
IOSTREAM_POINTER_SUPPORT(Data) \
IOSTREAM_VALUE_SUPPORT(Data) \
GETRECORD_POINTER_SUPPORT(Data) \
GETRECORD_VALUE_SUPPORT(Data)
#include "hurricane/Tabulation.h"

View File

@ -124,7 +124,7 @@ class JsonOccurrence : public JsonObject {
} // End of Hurricane namespace.
INSPECTOR_PR_SUPPORT(Hurricane::Occurrence);
INSPECTOR_PV_SUPPORT(Hurricane::Occurrence);
#endif // HURRICANE_OCCURENCE

View File

@ -1281,6 +1281,7 @@ namespace Hurricane {
void CellWidget::setShowSelection ( bool state )
{
//cerr << "CellWidget::setShowSelection(): " << state << " vs. " << _state->showSelection() << endl;
if ( state != _state->showSelection() ) {
_state->setShowSelection ( state );
_selectionHasChanged = false;
@ -2796,7 +2797,6 @@ namespace Hurricane {
if ( occurrence.getOwnerCell() != getCell() )
throw Error( "CellWidget::toggleSelection(): Occurrence do not belong to the loaded cell." );
cerr << "CellWidget::toggleSelection() " << occurrence << endl;
Property* property = occurrence.getProperty( Selector::getPropertyName() );
Selector* selector = NULL;
if (not property) {

View File

@ -51,6 +51,7 @@ namespace Hurricane {
}
void Command::setCellWidget ( CellWidget* widget ) { _cellWidget=widget; }
void Command::wheelEvent ( QWheelEvent* ) { }
void Command::keyPressEvent ( QKeyEvent* ) { }
void Command::keyReleaseEvent ( QKeyEvent* ) { }

View File

@ -14,26 +14,26 @@
// +-----------------------------------------------------------------+
#include <QAction>
#include <QFrame>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QCheckBox>
#include <QComboBox>
#include <hurricane/configuration/Configuration.h>
#include <hurricane/configuration/ConfigurationWidget.h>
#include <hurricane/DataBase.h>
#include <hurricane/Cell.h>
#include <hurricane/viewer/Graphics.h>
#include <hurricane/viewer/CellWidget.h>
#include <hurricane/viewer/GraphicsWidget.h>
#include <hurricane/viewer/PaletteWidget.h>
#include <hurricane/viewer/DisplayFilterWidget.h>
#include <hurricane/viewer/NetlistWidget.h>
#include <hurricane/viewer/HierarchyWidget.h>
#include <hurricane/viewer/SelectionWidget.h>
#include <hurricane/viewer/InspectorWidget.h>
#include <hurricane/viewer/ControllerWidget.h>
#include <QAction>
#include <QFrame>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QCheckBox>
#include <QComboBox>
#include <hurricane/configuration/Configuration.h>
#include <hurricane/configuration/ConfigurationWidget.h>
#include <hurricane/DataBase.h>
#include <hurricane/Cell.h>
#include <hurricane/viewer/Graphics.h>
#include <hurricane/viewer/CellWidget.h>
#include <hurricane/viewer/GraphicsWidget.h>
#include <hurricane/viewer/PaletteWidget.h>
#include <hurricane/viewer/DisplayFilterWidget.h>
#include <hurricane/viewer/NetlistWidget.h>
#include <hurricane/viewer/HierarchyWidget.h>
#include <hurricane/viewer/SelectionWidget.h>
#include <hurricane/viewer/InspectorWidget.h>
#include <hurricane/viewer/ControllerWidget.h>
namespace Hurricane {

View File

@ -1,14 +1,14 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2018, All Rights Reserved
// Copyright (c) Sorbonne Université 2008-2021, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | H U R R I C A N E |
// | V L S I B a c k e n d D a t a - B a s e |
// | |
// | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Module : "./InspectorWidget.cpp" |
// +-----------------------------------------------------------------+
@ -24,7 +24,6 @@
#include <QKeyEvent>
#include <QGroupBox>
#include <QVBoxLayout>
#include "hurricane/viewer/Graphics.h"
#include "hurricane/viewer/RecordModel.h"
#include "hurricane/viewer/InspectorWidget.h"

View File

@ -1,7 +1,7 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC 2008-2018, All Rights Reserved
// Copyright (c) Sorbonne Université 2008-2021, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | H U R R I C A N E |
@ -14,20 +14,20 @@
// +-----------------------------------------------------------------+
#include <QString>
#include <QMouseEvent>
#include <QKeyEvent>
#include <QAction>
#include "hurricane/Path.h"
#include "hurricane/Entity.h"
#include "hurricane/Net.h"
#include "hurricane/Component.h"
#include "hurricane/Occurrence.h"
#include "hurricane/HyperNet.h"
#include "hurricane/Cell.h"
#include "hurricane/viewer/CellWidget.h"
#include "hurricane/viewer/SelectCommand.h"
#include "hurricane/viewer/SelectionPopup.h"
#include <QString>
#include <QMouseEvent>
#include <QKeyEvent>
#include <QAction>
#include "hurricane/Path.h"
#include "hurricane/Entity.h"
#include "hurricane/Net.h"
#include "hurricane/Component.h"
#include "hurricane/Occurrence.h"
#include "hurricane/HyperNet.h"
#include "hurricane/Cell.h"
#include "hurricane/viewer/CellWidget.h"
#include "hurricane/viewer/SelectCommand.h"
#include "hurricane/viewer/SelectionPopup.h"
namespace Hurricane {
@ -217,34 +217,34 @@ namespace Hurricane {
void SelectCommand::mousePressEvent ( QMouseEvent* event )
{
if ( isActive() ) return;
if (isActive()) return;
if ( event->button() == Qt::RightButton ) {
if ( !event->modifiers() ) {
event->accept ();
setActive ( true );
setStartPoint ( event->pos() );
setDrawingEnabled ( true );
} else if ( event->modifiers() == Qt::ControlModifier ) {
event->accept ();
if (event->button() == Qt::RightButton) {
if (not event->modifiers() ) {
event->accept();
setActive ( true );
setStartPoint ( event->pos() );
setDrawingEnabled( true );
} else if (event->modifiers() == Qt::ControlModifier) {
event->accept();
QRect selectArea ( event->pos() - QPoint(2,2), QSize(4,4) );
Occurrences selection;
switch ( _selectMode ) {
case AllMode: // 0
selection = _cellWidget->getOccurrencesUnder(selectArea);
selection = _cellWidget->getOccurrencesUnder( selectArea );
break;
case NetMode: // 1
selection = Occurrences_GetNets(_cellWidget->getOccurrencesUnder(selectArea),false);
selection = Occurrences_GetNets( _cellWidget->getOccurrencesUnder(selectArea), false );
break;
case NoAnonNetMode: // 2
selection = Occurrences_GetNets(_cellWidget->getOccurrencesUnder(selectArea),true);
selection = Occurrences_GetNets( _cellWidget->getOccurrencesUnder(selectArea), true );
break;
}
_selectionPopup->loadOccurrences ( selection );
_selectionPopup->updateLayout ();
_selectionPopup->move ( event->globalPos() );
_selectionPopup->popup ();
_selectionPopup->loadOccurrences( selection );
_selectionPopup->updateLayout();
_selectionPopup->move( event->globalPos() );
_selectionPopup->popup();
}
}
}
@ -257,25 +257,37 @@ namespace Hurricane {
event->accept ();
setActive ( false );
setDrawingEnabled ( false );
setActive( false );
setDrawingEnabled( false );
QRect selectArea;
if ( _startPoint == _stopPoint )
selectArea = QRect ( _startPoint - QPoint(2,2), QSize(4,4) );
selectArea = QRect( _startPoint - QPoint(2,2), QSize(4,4) );
else
selectArea = QRect ( _startPoint, _stopPoint );
selectArea = QRect( _startPoint, _stopPoint );
//_cellWidget->unselectAll ();
_cellWidget->selectOccurrencesUnder ( _cellWidget->screenToDbuBox(selectArea) );
bool somethingSelected = not _cellWidget->getSelectorSet().empty();
if ( _cellWidget->showSelection() != somethingSelected )
_cellWidget->setShowSelection ( somethingSelected );
else
_cellWidget->refresh ();
_cellWidget->selectOccurrencesUnder( _cellWidget->screenToDbuBox(selectArea) );
setShowSelection( not _cellWidget->getSelectorSet().empty() );
}
void SelectCommand::setCellWidget ( CellWidget* cellWidget )
{
Super::setCellWidget( cellWidget );
_selectionPopup->setCellWidget( cellWidget );
}
void SelectCommand::setShowSelection ( bool state )
{
//cerr << "SelectCommand::setShowSelection(): "
// << state << " vs. " << _cellWidget->showSelection() << endl;
if (_cellWidget->showSelection() != state)
_cellWidget->setShowSelection( state );
else
_cellWidget->refresh();
}
} // End of Hurricane namespace.

View File

@ -1,13 +1,14 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC 2008-2018, All Rights Reserved
// Copyright (c) Sorbonne Université 2008-2021, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | H U R R I C A N E |
// | V L S I B a c k e n d D a t a - B a s e |
// | |
// | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Module : "./SelectionPopup.cpp" |
// +-----------------------------------------------------------------+
@ -21,6 +22,7 @@
#include <QVBoxLayout>
#include "hurricane/Commons.h"
#include "hurricane/viewer/Graphics.h"
#include "hurricane/viewer/CellWidget.h"
#include "hurricane/viewer/SelectionPopupModel.h"
#include "hurricane/viewer/SelectionPopup.h"
@ -34,6 +36,7 @@ namespace Hurricane {
SelectionPopup::SelectionPopup ( QWidget* parent )
: QWidget(parent)
, _cellWidget(NULL)
, _model(NULL)
, _view(NULL)
, _rowHeight(20)
@ -75,10 +78,10 @@ namespace Hurricane {
}
void SelectionPopup::popup ()
bool SelectionPopup::popup ()
{
show ();
grabMouse ();
show();
grabMouse();
}
@ -96,7 +99,6 @@ namespace Hurricane {
}
void SelectionPopup::mouseMoveEvent ( QMouseEvent* event )
{
QModelIndex index = _view->indexAt ( event->pos() );
@ -107,20 +109,21 @@ namespace Hurricane {
}
void SelectionPopup::mouseReleaseEvent ( QMouseEvent* event )
{
releaseMouse ();
hide ();
releaseMouse();
hide();
QModelIndex index = _view->indexAt ( event->pos() );
if ( index.isValid() ) {
QModelIndex index = _view->indexAt( event->pos() );
if (index.isValid()) {
Occurrence occurrence = _model->getOccurrence(index.row());
if ( occurrence.getEntity() )
emit selectionToggled ( occurrence );
if (occurrence.getEntity()) {
if (_cellWidget) _cellWidget->setShowSelection( true );
emit selectionToggled( occurrence );
}
}
clear ();
clear();
}

View File

@ -160,7 +160,7 @@ namespace Hurricane {
connect( _cellWidget, SIGNAL(selectionChanged(const SelectorSet&))
, this , SLOT (setSelection (const SelectorSet&)) );
connect( _cellWidget, SIGNAL(selectionToggled(Selector*)), this , SLOT(toggleSelection(Selector*)) );
connect( _cellWidget, SIGNAL(selectionToggled(Selector*)), this, SLOT(toggleSelection(Selector*)) );
_updateState = ExternalEmit;
changeSelectionMode ();
@ -169,22 +169,20 @@ namespace Hurricane {
void SelectionWidget::changeSelectionMode ()
{
if ( !_cellWidget ) return;
if (not _cellWidget) return;
if ( _updateState == InternalEmit ) {
if (_updateState == InternalEmit) {
_updateState = InternalReceive;
emit selectionModeChanged ();
} else {
if ( _updateState == ExternalEmit ) {
blockAllSignals ( true );
_showSelection->setChecked ( _cellWidget->getState()->showSelection () );
_cumulative ->setChecked ( _cellWidget->getState()->cumulativeSelection() );
blockAllSignals ( false );
if (_updateState == ExternalEmit) {
blockAllSignals( true );
_showSelection->setChecked( _cellWidget->getState()->showSelection () );
_cumulative ->setChecked( _cellWidget->getState()->cumulativeSelection() );
blockAllSignals( false );
}
_updateState = ExternalEmit;
}
_updateState = ExternalEmit;
}

View File

@ -43,7 +43,7 @@ namespace Hurricane {
virtual Type getType () const;
inline bool isActive () const;
void setActive ( bool state );
inline void setCellWidget ( CellWidget* );
virtual void setCellWidget ( CellWidget* );
virtual void wheelEvent ( QWheelEvent* );
virtual void keyPressEvent ( QKeyEvent* );
virtual void keyReleaseEvent ( QKeyEvent* );
@ -63,7 +63,6 @@ namespace Hurricane {
// Inline Functions.
bool Command::isActive () const { return _active; }
void Command::setCellWidget ( CellWidget* widget ) { _cellWidget=widget; }
}

View File

@ -2,39 +2,26 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2018, All Rights Reserved
//
// ===================================================================
//
// $Id$
// Copyright (c) Sorbonne Université 2008-2021, All Rights Reserved
//
// x-----------------------------------------------------------------x
// | |
// | H U R R I C A N E |
// | V L S I B a c k e n d D a t a - B a s e |
// | |
// | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Header : "./SelectCommand.h" |
// | *************************************************************** |
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#ifndef __HURRICANE_SELECT_COMMAND_H__
#define __HURRICANE_SELECT_COMMAND_H__
#include <set>
#include <QObject>
#include <QPoint>
#pragma once
#include <set>
#include <QObject>
#include <QPoint>
class QAction;
#include "hurricane/Occurrence.h"
#include "hurricane/viewer/AreaCommand.h"
#include "hurricane/Occurrence.h"
#include "hurricane/viewer/AreaCommand.h"
using namespace std;
@ -50,7 +37,8 @@ namespace Hurricane {
class SelectCommand : public QObject, public AreaCommand {
Q_OBJECT;
public:
typedef AreaCommand Super;
public:
enum SelectMode { AllMode=0, NetMode=1, NoAnonNetMode=2 };
public:
@ -64,6 +52,8 @@ namespace Hurricane {
virtual void mousePressEvent ( QMouseEvent* );
virtual void mouseReleaseEvent ( QMouseEvent* );
void bindToAction ( QAction* );
virtual void setCellWidget ( CellWidget* );
void setShowSelection ( bool state );
signals:
void selectionToggled ( Occurrence );
private:
@ -81,6 +71,3 @@ namespace Hurricane {
} // End of Hurricane namespace.
#endif

View File

@ -1,7 +1,7 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2018, All Rights Reserved
// Copyright (c) Sornonne Université 2008-2021, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | H U R R I C A N E |
@ -14,9 +14,7 @@
// +-----------------------------------------------------------------+
#ifndef HURRICANE_SELECTION_MODEL_H
#define HURRICANE_SELECTION_MODEL_H
#pragma once
#include <vector>
#include <QFont>
#include <QApplication>
@ -34,10 +32,10 @@ namespace Hurricane {
class SelectionModel : public QAbstractTableModel {
Q_OBJECT;
public:
SelectionModel ( QObject* parent=NULL );
~SelectionModel ();
inline CellWidget* getCellWidget () const;
void setCellWidget ( CellWidget* );
Selector* getSelector ( const QModelIndex& index );
void setSelection ( const SelectorSet& selection );
@ -53,13 +51,13 @@ namespace Hurricane {
public slots:
void unlink ( Selector* );
void clear ();
private:
CellWidget* _cellWidget;
vector<Selector*> _selection;
};
inline CellWidget* SelectionModel::getCellWidget () const { return _cellWidget; }
} // Hurricane namespace.
#endif // HURRICANE_SELECTION_MODEL_H

View File

@ -1,22 +1,20 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC 2008-2018, All Rights Reserved
// Copyright (c) Sorbonne Université 2008-2021, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | H U R R I C A N E |
// | V L S I B a c k e n d D a t a - B a s e |
// | |
// | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Header : "./hurricane/viewer/SelectionPopup.h" |
// +-----------------------------------------------------------------+
#ifndef HURRICANE_SELECTION_POPUP_WIDGET_H
#define HURRICANE_SELECTION_POPUP_WIDGET_H
#pragma once
#include <QWidget>
#include <QTableView>
#include "hurricane/Commons.h"
@ -38,15 +36,16 @@ namespace Hurricane {
class SelectionPopupModel;
class CellWidget;
class SelectionPopup : public QWidget {
Q_OBJECT;
public:
SelectionPopup ( QWidget* parent=NULL );
inline void setCellWidget ( CellWidget* );
void updateLayout ();
void popup ();
bool popup ();
void clearFilter ();
void setFilter ( OccurrenceFilter );
signals:
@ -59,8 +58,8 @@ namespace Hurricane {
virtual void keyPressEvent ( QKeyEvent * );
virtual void mouseMoveEvent ( QMouseEvent* );
virtual void mouseReleaseEvent ( QMouseEvent* );
private:
CellWidget* _cellWidget;
SelectionPopupModel* _model;
QTableView* _view;
int _rowHeight;
@ -68,6 +67,7 @@ namespace Hurricane {
};
} // Hurricane namespace.
inline void SelectionPopup::setCellWidget ( CellWidget* cellWidget ) { _cellWidget=cellWidget; }
#endif // HURRICANE_SELECTION_POPUP_WIDGET_H
} // Hurricane namespace.

View File

@ -1,29 +1,27 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2019, All Rights Reserved
// Copyright (c) Sorbonne Université 2008-2021, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | H U R R I C A N E |
// | V L S I B a c k e n d D a t a - B a s e |
// | |
// | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Header : "./hurricane/viewer/SelectionWidget.h" |
// +-----------------------------------------------------------------+
#ifndef HURRICANE_SELECTION_WIDGET_H
#define HURRICANE_SELECTION_WIDGET_H
#include <QWidget>
#include <QTableView>
#include <QSortFilterProxyModel>
#include "hurricane/Commons.h"
#include "hurricane/Occurrence.h"
#include "hurricane/viewer/SelectionModel.h"
#include "hurricane/viewer/CellWidget.h"
#pragma once
#include <QWidget>
#include <QTableView>
#include <QSortFilterProxyModel>
#include "hurricane/Commons.h"
#include "hurricane/Occurrence.h"
#include "hurricane/viewer/SelectionModel.h"
#include "hurricane/viewer/CellWidget.h"
class QCloseEvent;
class QSortFilterProxyModel;
@ -42,7 +40,6 @@ namespace Hurricane {
class SelectionWidget : public QWidget {
Q_OBJECT;
public:
SelectionWidget ( QWidget* parent=NULL );
void inspect ( const QModelIndex& index );
@ -84,5 +81,3 @@ namespace Hurricane {
} // Hurricane namespace.
#endif // HURRICANE_SELECTION_WIDGET_H