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) 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" #include "hurricane/Tabulation.h"

View File

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

View File

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

View File

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

View File

@ -1,14 +1,14 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // 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 | // | 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 | // | V L S I B a c k e n d D a t a - B a s e |
// | | // | |
// | Author : Jean-Paul CHAPUT | // | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Module : "./InspectorWidget.cpp" | // | C++ Module : "./InspectorWidget.cpp" |
// +-----------------------------------------------------------------+ // +-----------------------------------------------------------------+
@ -24,7 +24,6 @@
#include <QKeyEvent> #include <QKeyEvent>
#include <QGroupBox> #include <QGroupBox>
#include <QVBoxLayout> #include <QVBoxLayout>
#include "hurricane/viewer/Graphics.h" #include "hurricane/viewer/Graphics.h"
#include "hurricane/viewer/RecordModel.h" #include "hurricane/viewer/RecordModel.h"
#include "hurricane/viewer/InspectorWidget.h" #include "hurricane/viewer/InspectorWidget.h"

View File

@ -1,7 +1,7 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // 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 | // | H U R R I C A N E |
@ -220,7 +220,7 @@ namespace Hurricane {
if (isActive()) return; if (isActive()) return;
if (event->button() == Qt::RightButton) { if (event->button() == Qt::RightButton) {
if ( !event->modifiers() ) { if (not event->modifiers() ) {
event->accept(); event->accept();
setActive ( true ); setActive ( true );
setStartPoint ( event->pos() ); setStartPoint ( event->pos() );
@ -268,14 +268,26 @@ namespace Hurricane {
//_cellWidget->unselectAll (); //_cellWidget->unselectAll ();
_cellWidget->selectOccurrencesUnder( _cellWidget->screenToDbuBox(selectArea) ); _cellWidget->selectOccurrencesUnder( _cellWidget->screenToDbuBox(selectArea) );
bool somethingSelected = not _cellWidget->getSelectorSet().empty(); setShowSelection( not _cellWidget->getSelectorSet().empty() );
}
if ( _cellWidget->showSelection() != somethingSelected )
_cellWidget->setShowSelection ( somethingSelected ); 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 else
_cellWidget->refresh(); _cellWidget->refresh();
} }
} // End of Hurricane namespace. } // End of Hurricane namespace.

View File

@ -1,13 +1,14 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // 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 | // | 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 | // | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Module : "./SelectionPopup.cpp" | // | C++ Module : "./SelectionPopup.cpp" |
// +-----------------------------------------------------------------+ // +-----------------------------------------------------------------+
@ -21,6 +22,7 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include "hurricane/Commons.h" #include "hurricane/Commons.h"
#include "hurricane/viewer/Graphics.h" #include "hurricane/viewer/Graphics.h"
#include "hurricane/viewer/CellWidget.h"
#include "hurricane/viewer/SelectionPopupModel.h" #include "hurricane/viewer/SelectionPopupModel.h"
#include "hurricane/viewer/SelectionPopup.h" #include "hurricane/viewer/SelectionPopup.h"
@ -34,6 +36,7 @@ namespace Hurricane {
SelectionPopup::SelectionPopup ( QWidget* parent ) SelectionPopup::SelectionPopup ( QWidget* parent )
: QWidget(parent) : QWidget(parent)
, _cellWidget(NULL)
, _model(NULL) , _model(NULL)
, _view(NULL) , _view(NULL)
, _rowHeight(20) , _rowHeight(20)
@ -75,7 +78,7 @@ namespace Hurricane {
} }
void SelectionPopup::popup () bool SelectionPopup::popup ()
{ {
show(); show();
grabMouse(); grabMouse();
@ -96,7 +99,6 @@ namespace Hurricane {
} }
void SelectionPopup::mouseMoveEvent ( QMouseEvent* event ) void SelectionPopup::mouseMoveEvent ( QMouseEvent* event )
{ {
QModelIndex index = _view->indexAt ( event->pos() ); QModelIndex index = _view->indexAt ( event->pos() );
@ -107,7 +109,6 @@ namespace Hurricane {
} }
void SelectionPopup::mouseReleaseEvent ( QMouseEvent* event ) void SelectionPopup::mouseReleaseEvent ( QMouseEvent* event )
{ {
releaseMouse(); releaseMouse();
@ -116,9 +117,11 @@ namespace Hurricane {
QModelIndex index = _view->indexAt( event->pos() ); QModelIndex index = _view->indexAt( event->pos() );
if (index.isValid()) { if (index.isValid()) {
Occurrence occurrence = _model->getOccurrence(index.row()); Occurrence occurrence = _model->getOccurrence(index.row());
if ( occurrence.getEntity() ) if (occurrence.getEntity()) {
if (_cellWidget) _cellWidget->setShowSelection( true );
emit selectionToggled( occurrence ); emit selectionToggled( occurrence );
} }
}
clear(); clear();
} }

View File

@ -169,7 +169,7 @@ namespace Hurricane {
void SelectionWidget::changeSelectionMode () void SelectionWidget::changeSelectionMode ()
{ {
if ( !_cellWidget ) return; if (not _cellWidget) return;
if (_updateState == InternalEmit) { if (_updateState == InternalEmit) {
_updateState = InternalReceive; _updateState = InternalReceive;
@ -177,14 +177,12 @@ namespace Hurricane {
} else { } else {
if (_updateState == ExternalEmit) { if (_updateState == ExternalEmit) {
blockAllSignals( true ); blockAllSignals( true );
_showSelection->setChecked( _cellWidget->getState()->showSelection () ); _showSelection->setChecked( _cellWidget->getState()->showSelection () );
_cumulative ->setChecked( _cellWidget->getState()->cumulativeSelection() ); _cumulative ->setChecked( _cellWidget->getState()->cumulativeSelection() );
blockAllSignals( false ); blockAllSignals( false );
} }
_updateState = ExternalEmit;
} }
_updateState = ExternalEmit;
} }

View File

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

View File

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

View File

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

View File

@ -1,22 +1,20 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // 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 | // | 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 | // | V L S I B a c k e n d D a t a - B a s e |
// | | // | |
// | Author : Jean-Paul CHAPUT | // | 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" | // | C++ Header : "./hurricane/viewer/SelectionPopup.h" |
// +-----------------------------------------------------------------+ // +-----------------------------------------------------------------+
#ifndef HURRICANE_SELECTION_POPUP_WIDGET_H #pragma once
#define HURRICANE_SELECTION_POPUP_WIDGET_H
#include <QWidget> #include <QWidget>
#include <QTableView> #include <QTableView>
#include "hurricane/Commons.h" #include "hurricane/Commons.h"
@ -38,15 +36,16 @@ namespace Hurricane {
class SelectionPopupModel; class SelectionPopupModel;
class CellWidget;
class SelectionPopup : public QWidget { class SelectionPopup : public QWidget {
Q_OBJECT; Q_OBJECT;
public: public:
SelectionPopup ( QWidget* parent=NULL ); SelectionPopup ( QWidget* parent=NULL );
inline void setCellWidget ( CellWidget* );
void updateLayout (); void updateLayout ();
void popup (); bool popup ();
void clearFilter (); void clearFilter ();
void setFilter ( OccurrenceFilter ); void setFilter ( OccurrenceFilter );
signals: signals:
@ -59,8 +58,8 @@ namespace Hurricane {
virtual void keyPressEvent ( QKeyEvent * ); virtual void keyPressEvent ( QKeyEvent * );
virtual void mouseMoveEvent ( QMouseEvent* ); virtual void mouseMoveEvent ( QMouseEvent* );
virtual void mouseReleaseEvent ( QMouseEvent* ); virtual void mouseReleaseEvent ( QMouseEvent* );
private: private:
CellWidget* _cellWidget;
SelectionPopupModel* _model; SelectionPopupModel* _model;
QTableView* _view; QTableView* _view;
int _rowHeight; 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,7 +1,7 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // 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 | // | H U R R I C A N E |
@ -14,9 +14,7 @@
// +-----------------------------------------------------------------+ // +-----------------------------------------------------------------+
#ifndef HURRICANE_SELECTION_WIDGET_H #pragma once
#define HURRICANE_SELECTION_WIDGET_H
#include <QWidget> #include <QWidget>
#include <QTableView> #include <QTableView>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
@ -42,7 +40,6 @@ namespace Hurricane {
class SelectionWidget : public QWidget { class SelectionWidget : public QWidget {
Q_OBJECT; Q_OBJECT;
public: public:
SelectionWidget ( QWidget* parent=NULL ); SelectionWidget ( QWidget* parent=NULL );
void inspect ( const QModelIndex& index ); void inspect ( const QModelIndex& index );
@ -84,5 +81,3 @@ namespace Hurricane {
} // Hurricane namespace. } // Hurricane namespace.
#endif // HURRICANE_SELECTION_WIDGET_H