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

@ -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 |
@ -220,7 +220,7 @@ namespace Hurricane {
if (isActive()) return;
if (event->button() == Qt::RightButton) {
if ( !event->modifiers() ) {
if (not event->modifiers() ) {
event->accept();
setActive ( true );
setStartPoint ( event->pos() );
@ -268,14 +268,26 @@ namespace Hurricane {
//_cellWidget->unselectAll ();
_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
_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,7 +78,7 @@ namespace Hurricane {
}
void SelectionPopup::popup ()
bool SelectionPopup::popup ()
{
show();
grabMouse();
@ -96,7 +99,6 @@ namespace Hurricane {
}
void SelectionPopup::mouseMoveEvent ( QMouseEvent* event )
{
QModelIndex index = _view->indexAt ( event->pos() );
@ -107,7 +109,6 @@ namespace Hurricane {
}
void SelectionPopup::mouseReleaseEvent ( QMouseEvent* event )
{
releaseMouse();
@ -116,9 +117,11 @@ namespace Hurricane {
QModelIndex index = _view->indexAt( event->pos() );
if (index.isValid()) {
Occurrence occurrence = _model->getOccurrence(index.row());
if ( occurrence.getEntity() )
if (occurrence.getEntity()) {
if (_cellWidget) _cellWidget->setShowSelection( true );
emit selectionToggled( occurrence );
}
}
clear();
}

View File

@ -169,7 +169,7 @@ namespace Hurricane {
void SelectionWidget::changeSelectionMode ()
{
if ( !_cellWidget ) return;
if (not _cellWidget) return;
if (_updateState == InternalEmit) {
_updateState = InternalReceive;
@ -177,14 +177,12 @@ namespace Hurricane {
} else {
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,37 +2,24 @@
// -*- 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__
#pragma once
#include <set>
#include <QObject>
#include <QPoint>
class QAction;
#include "hurricane/Occurrence.h"
#include "hurricane/viewer/AreaCommand.h"
@ -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;
};
} // Hurricane namespace.
inline CellWidget* SelectionModel::getCellWidget () const { return _cellWidget; }
#endif // HURRICANE_SELECTION_MODEL_H
} // Hurricane namespace.

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,7 +1,7 @@
// -*- 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 |
@ -14,9 +14,7 @@
// +-----------------------------------------------------------------+
#ifndef HURRICANE_SELECTION_WIDGET_H
#define HURRICANE_SELECTION_WIDGET_H
#pragma once
#include <QWidget>
#include <QTableView>
#include <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