* ./hurricane/src/hviewer :

- Bug: redraw the palette layer samples whenever the style changes. Uses a
        new, more clear model to transmit signals. A star model where the
        CellWidget is the center, signals propagate a void pointer which tells
        the emitter to avoid looping. First a slave emit the signal to the
        CellWidget. When the CellWidget receive the signal it's transmitted to
        all slave widgets.
    - New feature: ExceptionWidget (derived from QDialog) to display properly
        catched exceptions. The Abort button of the Dialog forces the program
        to core-dump with a SIGSEGV. The "Try to Continue" resumes the program,
        which is higtly to crash anyway...
    - New feature: a HApplication in replacement of the QApplication to catch
        exceptions in the notify() function, that is exceptions that could be
        throwed inside event handlers.
This commit is contained in:
Jean-Paul Chaput 2009-01-18 21:17:43 +00:00
parent a042ed5f86
commit 8a2d46e21e
18 changed files with 226 additions and 24 deletions

View File

@ -94,7 +94,6 @@ namespace Hurricane {
void Breakpoint::setStopCb ( Breakpoint::StopCb_t* cb ) void Breakpoint::setStopCb ( Breakpoint::StopCb_t* cb )
{ {
cerr << "Breakpoint::setStopCb() - " << (void*)cb << endl;
_stopCb = cb; _stopCb = cb;
} }

View File

@ -61,11 +61,11 @@ namespace Hurricane {
vLine->setFrameShadow ( QFrame::Sunken ); vLine->setFrameShadow ( QFrame::Sunken );
QGridLayout* layout = new QGridLayout (); QGridLayout* layout = new QGridLayout ();
layout->addWidget ( ok , 0, 0, 2, 1, Qt::AlignVCenter ); layout->addWidget ( _message , 0, 0 );
layout->addWidget ( vLine , 0, 1, 2, 1 ); layout->addWidget ( stopLabel , 1, 0 );
layout->addWidget ( _message , 0, 2 ); layout->addWidget ( _stopLevel, 1, 1 );
layout->addWidget ( stopLabel , 1, 2 ); layout->addWidget ( vLine , 0, 2, 2, 1 );
layout->addWidget ( _stopLevel, 1, 3 ); layout->addWidget ( ok , 0, 3, 2, 1, Qt::AlignVCenter );
setLayout ( layout ); setLayout ( layout );
connect ( ok , SIGNAL(clicked()) , this, SLOT(accept()) ); connect ( ok , SIGNAL(clicked()) , this, SLOT(accept()) );

View File

@ -4,12 +4,14 @@
include_directories ( ${HURRICANE_SOURCE_DIR}/src/hurricane include_directories ( ${HURRICANE_SOURCE_DIR}/src/hurricane
${HURRICANE_SOURCE_DIR}/src/hviewer ) ${HURRICANE_SOURCE_DIR}/src/hviewer )
set ( mocincludes hurricane/viewer/PaletteItem.h set ( mocincludes hurricane/viewer/HApplication.h
hurricane/viewer/PaletteItem.h
hurricane/viewer/PaletteNamedItem.h hurricane/viewer/PaletteNamedItem.h
hurricane/viewer/PaletteLayerItem.h hurricane/viewer/PaletteLayerItem.h
hurricane/viewer/PaletteExtensionGoItem.h hurricane/viewer/PaletteExtensionGoItem.h
hurricane/viewer/PaletteWidget.h hurricane/viewer/PaletteWidget.h
hurricane/viewer/GraphicsWidget.h hurricane/viewer/GraphicsWidget.h
hurricane/viewer/ExceptionWidget.h
hurricane/viewer/BreakpointWidget.h hurricane/viewer/BreakpointWidget.h
hurricane/viewer/DynamicLabel.h hurricane/viewer/DynamicLabel.h
hurricane/viewer/MousePositionWidget.h hurricane/viewer/MousePositionWidget.h
@ -27,11 +29,13 @@
hurricane/viewer/DisplayFilterWidget.h hurricane/viewer/DisplayFilterWidget.h
hurricane/viewer/ControllerWidget.h hurricane/viewer/ControllerWidget.h
) )
set ( exports hurricane/viewer/ScreenUtilities.h set ( exports hurricane/viewer/HApplication.h
hurricane/viewer/ScreenUtilities.h
hurricane/viewer/DisplayStyle.h hurricane/viewer/DisplayStyle.h
hurricane/viewer/ColorScale.h hurricane/viewer/ColorScale.h
hurricane/viewer/Graphics.h hurricane/viewer/Graphics.h
hurricane/viewer/GraphicsWidget.h hurricane/viewer/GraphicsWidget.h
hurricane/viewer/ExceptionWidget.h
hurricane/viewer/BreakpointWidget.h hurricane/viewer/BreakpointWidget.h
hurricane/viewer/Selector.h hurricane/viewer/Selector.h
hurricane/viewer/Command.h hurricane/viewer/Command.h
@ -53,11 +57,13 @@
hurricane/viewer/DisplayFilterWidget.h hurricane/viewer/DisplayFilterWidget.h
hurricane/viewer/ControllerWidget.h hurricane/viewer/ControllerWidget.h
) )
set ( cpps ScreenUtilities.cpp set ( cpps HApplication.cpp
ScreenUtilities.cpp
DisplayStyle.cpp DisplayStyle.cpp
ColorScale.cpp ColorScale.cpp
Graphics.cpp Graphics.cpp
GraphicsWidget.cpp GraphicsWidget.cpp
ExceptionWidget.cpp
BreakpointWidget.cpp BreakpointWidget.cpp
PaletteItem.cpp PaletteItem.cpp
PaletteNamedItem.cpp PaletteNamedItem.cpp

View File

@ -10,5 +10,7 @@
<file>images/gtk-go-forward-ltr.png</file> <file>images/gtk-go-forward-ltr.png</file>
<file>images/swiss-knife.png</file> <file>images/swiss-knife.png</file>
<file>images/gnome-gmush.png</file> <file>images/gnome-gmush.png</file>
<file>images/gnome-core.png</file>
<file>images/i-core.png</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -890,6 +890,13 @@ namespace Hurricane {
} }
void CellWidget::styleChange ( void* emitter )
{
refresh ();
emit styleChanged(emitter);
}
void CellWidget::updatePalette () void CellWidget::updatePalette ()
{ {
emit updatePalette(getCell()); emit updatePalette(getCell());
@ -904,6 +911,7 @@ namespace Hurricane {
connect ( _palette, SIGNAL(paletteChanged()) , this , SLOT(refresh()) ); connect ( _palette, SIGNAL(paletteChanged()) , this , SLOT(refresh()) );
connect ( this , SIGNAL(cellChanged(Cell*)) , _palette, SLOT(updateExtensions(Cell*)) ); connect ( this , SIGNAL(cellChanged(Cell*)) , _palette, SLOT(updateExtensions(Cell*)) );
connect ( this , SIGNAL(updatePalette(Cell*)), _palette, SLOT(updateExtensions(Cell*)) ); connect ( this , SIGNAL(updatePalette(Cell*)), _palette, SLOT(updateExtensions(Cell*)) );
connect ( this , SIGNAL(styleChanged(void*)) , _palette, SLOT(styleChange(void*)) );
} }
@ -913,6 +921,7 @@ namespace Hurricane {
disconnect ( _palette, SIGNAL(paletteChanged()) , this , SLOT(refresh()) ); disconnect ( _palette, SIGNAL(paletteChanged()) , this , SLOT(refresh()) );
disconnect ( this , SIGNAL(cellChanged(Cell*)) , _palette, SLOT(updateExtensions(Cell*)) ); disconnect ( this , SIGNAL(cellChanged(Cell*)) , _palette, SLOT(updateExtensions(Cell*)) );
disconnect ( this , SIGNAL(updatePalette(Cell*)), _palette, SLOT(updateExtensions(Cell*)) ); disconnect ( this , SIGNAL(updatePalette(Cell*)), _palette, SLOT(updateExtensions(Cell*)) );
disconnect ( this , SIGNAL(styleChanged(void*)) , _palette, SLOT(styleChange(void*)) );
_palette = NULL; _palette = NULL;
} }
} }
@ -1094,7 +1103,7 @@ namespace Hurricane {
} }
} }
//_drawingQuery.setFilter ( _queryFilter & ~Query::DoMasterCells ); //_drawingQuery.setFilter ( _queryFilter & ~Query::DoMasterCells );
forEach ( ExtensionSlice*, islice, _cell->getExtensionSlices() ) { forEach ( ExtensionSlice*, islice, _cell->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;

View File

@ -98,7 +98,7 @@ namespace Hurricane {
if ( getCellWidget() != cellWidget ) { if ( getCellWidget() != cellWidget ) {
ControllerTab::setCellWidget ( cellWidget ); ControllerTab::setCellWidget ( cellWidget );
if ( getCellWidget() ) { if ( getCellWidget() ) {
connect ( _graphics, SIGNAL(styleChanged()), getCellWidget(), SLOT(refresh()) ); connect ( _graphics, SIGNAL(styleChanged(void*)), getCellWidget(), SLOT(styleChange(void*)) );
} }
} }
} }

View File

@ -79,15 +79,15 @@ namespace Hurricane {
wLayout->addStretch (); wLayout->addStretch ();
setLayout ( wLayout ); setLayout ( wLayout );
connect ( group, SIGNAL(buttonClicked(int)), this, SLOT(styleChanged(int)) ); connect ( group, SIGNAL(buttonClicked(int)), this, SLOT(styleChange(int)) );
} }
void GraphicsWidget::styleChanged ( int id ) void GraphicsWidget::styleChange ( int id )
{ {
Graphics::setStyle ( (size_t)id ); Graphics::setStyle ( (size_t)id );
//cerr << "GraphicsWidget::setStyle() - " << getString(Graphics::getStyle()->getName()) << endl; //cerr << "GraphicsWidget::setStyle() - " << getString(Graphics::getStyle()->getName()) << endl;
emit styleChanged (); emit styleChanged ( (void*)this );
} }

View File

@ -0,0 +1,102 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved
//
// ===================================================================
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | C O R I O L I S |
// | U n i c o r n - M a i n G U I |
// | |
// | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
// | =============================================================== |
// | C++ Module : "./HApplication.cpp" |
// | *************************************************************** |
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#include <csignal>
#include <iostream>
#include "hurricane/Error.h"
#include "hurricane/viewer/ExceptionWidget.h"
#include "hurricane/viewer/HApplication.h"
namespace Hurricane {
using std::cerr;
using std::endl;
using std::exception;
// -------------------------------------------------------------------
// Class : "HApplication".
HApplication::HApplication ( int& argc, char** argv )
: QApplication ( argc, argv )
{ }
HApplication::HApplication ( int& argc, char** argv, bool GUIenabled )
: QApplication ( argc, argv, GUIenabled )
{ }
HApplication::HApplication ( int& argc, char** argv, Type type )
: QApplication ( argc, argv, type )
{ }
HApplication::HApplication ( Display* display, Qt::HANDLE visual, Qt::HANDLE colormap )
: QApplication ( display, visual, colormap )
{ }
HApplication::HApplication ( Display* display, int& argc, char** argv, Qt::HANDLE visual, Qt::HANDLE colormap )
: QApplication ( display, argc, argv, visual, colormap )
{ }
bool HApplication::notify ( QObject* object, QEvent* event )
{
try {
return QApplication::notify ( object, event );
}
catch ( Error& e ) {
ExceptionWidget* ew = new ExceptionWidget ();
ew->setMessage ( e.getReason().c_str() );
if ( ew->exec() == QDialog::Rejected )
kill ( getpid(), SIGSEGV );
}
catch ( exception& e ) {
ExceptionWidget* ew = new ExceptionWidget ();
ew->setMessage ( e.what() );
if ( ew->exec() == QDialog::Rejected )
kill ( getpid(), SIGSEGV );
}
catch ( ... ) {
static const char* message =
"&nbsp;&nbsp;Unmanaged exception, neither a <b>Hurricane::Error</b><br>"
"nor a <b>std::exception</b>.";
ExceptionWidget* ew = new ExceptionWidget ();
ew->setMessage ( message );
if ( ew->exec() == QDialog::Rejected )
kill ( getpid(), SIGSEGV );
}
return true;
}
} // End of Hurricane namespace.

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
// //
// =================================================================== // ===================================================================
// //
@ -59,6 +59,8 @@ namespace Hurricane {
painter.setPen ( Graphics::getPen (_entry->getName()) ); painter.setPen ( Graphics::getPen (_entry->getName()) );
painter.setBrush ( Graphics::getBrush(_entry->getName()) ); painter.setBrush ( Graphics::getBrush(_entry->getName()) );
painter.drawRect ( 2, 2, 16, 16 ); painter.drawRect ( 2, 2, 16, 16 );
update ();
} }
@ -88,4 +90,10 @@ namespace Hurricane {
{ } { }
void PaletteItem::styleChange ()
{
emit styleChanged ();
}
} // End of Hurricane namespace. } // End of Hurricane namespace.

View File

@ -43,7 +43,9 @@ namespace Hurricane {
{ {
QHBoxLayout* layout = new QHBoxLayout (); QHBoxLayout* layout = new QHBoxLayout ();
layout->setContentsMargins ( 0, 0, 0, 0 ); layout->setContentsMargins ( 0, 0, 0, 0 );
layout->addWidget ( new DrawingStyleSample(this) );
DrawingStyleSample* sample = new DrawingStyleSample(this);
layout->addWidget ( sample );
_visible->setChecked ( visible ); _visible->setChecked ( visible );
_visible->setText ( getString(getName()).c_str() ); _visible->setText ( getString(getName()).c_str() );
@ -61,8 +63,9 @@ namespace Hurricane {
setLayout ( layout ); setLayout ( layout );
connect ( _visible , SIGNAL(clicked()), this, SIGNAL(visibleToggled ()) ); connect ( this , SIGNAL(styleChanged()), sample, SLOT (redraw ()) );
connect ( _selectable, SIGNAL(clicked()), this, SIGNAL(selectableToggled()) ); connect ( _visible , SIGNAL(clicked ()), this , SIGNAL(visibleToggled ()) );
connect ( _selectable, SIGNAL(clicked ()), this , SIGNAL(selectableToggled()) );
} }

View File

@ -377,4 +377,18 @@ namespace Hurricane {
} }
void PaletteWidget::styleChange ( void* emitter )
{
if ( emitter == this ) return;
PaletteItems::iterator iitem = _layerItems.begin();
for ( ; iitem != _layerItems.end() ; iitem++ )
iitem->second->styleChange ();
iitem = _extensionGoItems.begin();
for ( ; iitem != _extensionGoItems.end() ; iitem++ )
iitem->second->styleChange ();
}
} // End of Hurricane namespace. } // End of Hurricane namespace.

View File

@ -187,6 +187,7 @@ namespace Hurricane {
void cellPreModificated (); void cellPreModificated ();
void cellPostModificated (); void cellPostModificated ();
void settingsChanged (); void settingsChanged ();
void styleChanged ( void* emitter );
void updatePalette ( Cell* ); void updatePalette ( Cell* );
void mousePositionChanged ( const Point& position ); void mousePositionChanged ( const Point& position );
void selectionChanged ( const SelectorSet&, Cell* ); void selectionChanged ( const SelectorSet&, Cell* );
@ -211,6 +212,7 @@ namespace Hurricane {
void _selectOccurrencesUnder ( Box selectArea ); void _selectOccurrencesUnder ( Box selectArea );
void _unselectAll ( bool delayRedraw ); void _unselectAll ( bool delayRedraw );
void rubberChange (); void rubberChange ();
void styleChange ( void* emitter );
void updatePalette (); void updatePalette ();
void cellPreModificate (); void cellPreModificate ();
void cellPostModificate (); void cellPostModificate ();

View File

@ -39,9 +39,9 @@ namespace Hurricane {
public: public:
GraphicsWidget ( QWidget* parent=NULL ); GraphicsWidget ( QWidget* parent=NULL );
signals: signals:
void styleChanged (); void styleChanged ( void* emitter );
public slots: public slots:
void styleChanged ( int id ); void styleChange ( int id );
}; };

View File

@ -0,0 +1,54 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved
//
// ===================================================================
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | C O R I O L I S |
// | U n i c o r n - M a i n G U I |
// | |
// | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
// | =============================================================== |
// | C++ Header : "./HApplication.h" |
// | *************************************************************** |
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#ifndef __HURRICANE_HAPPLICATION__
#define __HURRICANE_HAPPLICATION__
#include <QApplication>
namespace Hurricane {
class HApplication : public QApplication {
Q_OBJECT;
public:
HApplication ( int& argc, char** argv );
HApplication ( int& argc, char** argv, bool GUIenabled );
HApplication ( int& argc, char** argv, Type type );
HApplication ( Display*, Qt::HANDLE visual=0, Qt::HANDLE colormap=0 );
HApplication ( Display*, int& argc, char** argv, Qt::HANDLE visual=0, Qt::HANDLE colormap=0 );
virtual bool notify ( QObject*, QEvent* );
};
} // End of Hurricane namespace.
#endif // __HURRICANE_HAPPLICATION__

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
// //
// =================================================================== // ===================================================================
// //
@ -55,7 +55,7 @@ namespace Hurricane {
protected: protected:
QPixmap _sample; QPixmap _sample;
PaletteItem* _entry; PaletteItem* _entry;
protected: protected slots:
void redraw (); void redraw ();
void paintEvent ( QPaintEvent* ); void paintEvent ( QPaintEvent* );
}; };
@ -74,10 +74,12 @@ namespace Hurricane {
virtual bool isItemSelectable () const; virtual bool isItemSelectable () const;
virtual void setItemVisible ( bool ) = 0; virtual void setItemVisible ( bool ) = 0;
virtual void setItemSelectable ( bool ); virtual void setItemSelectable ( bool );
public slots:
virtual void styleChange ();
signals: signals:
void styleChanged ();
void visibleToggled (); void visibleToggled ();
void selectableToggled (); void selectableToggled ();
protected: protected:
PaletteItem (); PaletteItem ();
PaletteItem ( const PaletteItem& ); PaletteItem ( const PaletteItem& );

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
// //
// =================================================================== // ===================================================================
// //
@ -68,6 +68,7 @@ namespace Hurricane {
void updateExtensions ( Cell* cell ); void updateExtensions ( Cell* cell );
void showAll (); void showAll ();
void hideAll (); void hideAll ();
void styleChange ( void* emitter );
protected: protected:
PaletteItems _layerItems; PaletteItems _layerItems;

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB