From: ouv Date: Thu, 28 Aug 2008 15:10:04 +0000 (+0000) Subject: Merging with changes from For_CTH_V12 branch X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=80459c24c9671ca986be4c583b35a3db30ff20f4;p=modules%2Fgui.git Merging with changes from For_CTH_V12 branch --- diff --git a/src/GLViewer/GLViewer_Drawer.cxx b/src/GLViewer/GLViewer_Drawer.cxx index 6fbf36182..c60128488 100644 --- a/src/GLViewer/GLViewer_Drawer.cxx +++ b/src/GLViewer/GLViewer_Drawer.cxx @@ -894,6 +894,32 @@ void GLViewer_Drawer::drawRectangle( GLViewer_Rect* rect, QColor color ) glEnd(); } +/*! + Draws filled rectangle + \param rect - instance of primitive + \param fillingColor - color of filling +*/ +void GLViewer_Drawer::drawFilledRectangle( GLViewer_Rect* rect, QColor color ) +{ + if( !rect ) + return; + + float x1 = rect->left(); + float x2 = rect->right(); + float y1 = rect->bottom(); + float y2 = rect->top(); + + glColor3f( ( GLfloat )color.red() / 255, + ( GLfloat )color.green() / 255, + ( GLfloat )color.blue() / 255 ); + glBegin( GL_POLYGON ); + glVertex2f( x1, y1 ); + glVertex2f( x1, y2 ); + glVertex2f( x2, y2 ); + glVertex2f( x2, y1 ); + glEnd(); +} + /*! Saves object to file with format of HPGL \param hFile - file diff --git a/src/GLViewer/GLViewer_Drawer.h b/src/GLViewer/GLViewer_Drawer.h index 859eecbc3..d81c19dc7 100644 --- a/src/GLViewer/GLViewer_Drawer.h +++ b/src/GLViewer/GLViewer_Drawer.h @@ -399,6 +399,9 @@ public: //! Draw rectangle with predefined color static void drawRectangle( GLViewer_Rect* theRect, QColor = Qt::black ); + //! Draw filled rectangle with predefined color + static void drawFilledRectangle( GLViewer_Rect*, QColor = Qt::black ); + protected: //! Draw basic primitives: rectangle, contour, polygon, vertex, cross, arrow //* with predefined color diff --git a/src/GLViewer/GLViewer_Group.cxx b/src/GLViewer/GLViewer_Group.cxx index 646750490..3be5d4baa 100644 --- a/src/GLViewer/GLViewer_Group.cxx +++ b/src/GLViewer/GLViewer_Group.cxx @@ -141,6 +141,23 @@ void GLViewer_Group::dragingObjects( float x, float y, bool once ) (*it)->moveObject( x, y, true ); } +/*! + Updates horizontal zoom of object + \param sender - object to be updated + \param zoom - zoom coefficient +*/ +void GLViewer_Group::updateXZoom( GLViewer_Object* sender, float zoom ) +{ + OGIterator it = myList.begin(); + OGIterator end_it = myList.end(); + for( int i = 0; it != end_it; ++it, i++ ) + { + GLViewer_Object* anObject = *it; + if( anObject != sender ) + anObject->setXZoom( zoom, true, true ); + } +} + /*! Updates zoom of object \param sender - object to be updated diff --git a/src/GLViewer/GLViewer_Group.h b/src/GLViewer/GLViewer_Group.h index 620cd2f35..d44627c56 100644 --- a/src/GLViewer/GLViewer_Group.h +++ b/src/GLViewer/GLViewer_Group.h @@ -64,6 +64,8 @@ public: /*! Once = true, if this operation calls only one time for all object*/ void dragingObjects( float x, float y, bool once = false ); //!\warning it is for ouv + void updateXZoom( GLViewer_Object* sender, float zoom ); + //!\warning it is for ouv void updateZoom( GLViewer_Object* sender, float zoom ); private: diff --git a/src/GLViewer/GLViewer_Object.cxx b/src/GLViewer/GLViewer_Object.cxx index c6a920c81..cfd6a51a5 100644 --- a/src/GLViewer/GLViewer_Object.cxx +++ b/src/GLViewer/GLViewer_Object.cxx @@ -40,6 +40,7 @@ GLViewer_Object::GLViewer_Object() myYScale = 1.0; myXGap = 0; myYGap = 0; + myXZoom = 1.0; myZoom = 1.0; myIsHigh = GL_FALSE; @@ -97,6 +98,42 @@ GLboolean GLViewer_Object::isInside( GLViewer_Rect theRect ) return theRect.toQRect().contains( myRect->toQRect() ); } +/*! + Sets horizontal zoom factor + \param zoom - zoom factor +*/ +GLboolean GLViewer_Object::setXZoom( GLfloat zoom, bool, bool ) +{ + if( myXZoom == zoom ) + return GL_FALSE; + + myXZoom = zoom; + return GL_TRUE; +} + +/*! + Performs horizontal zoom change by step + \param zoomIn - to increase to decrease zoom +*/ +GLboolean GLViewer_Object::updateXZoom( bool zoomIn ) +{ + float newZoom; + float step = zoomIn ? 1 : -1; + double epsilon = 0.001; + + if( myXZoom - 1 > epsilon ) + newZoom = ( myXZoom * 2 + step ) / 2; + else if( 1 - myXZoom > epsilon ) + newZoom = 2 / ( 2 / myXZoom - step ); + else + newZoom = zoomIn ? 3./2. : 2./3.; + + if( newZoom < 0.01 || newZoom > 100.0 ) + return GL_FALSE; + + return setXZoom( newZoom, true ); +} + /*! Sets zoom factor \param zoom - zoom factor diff --git a/src/GLViewer/GLViewer_Object.h b/src/GLViewer/GLViewer_Object.h index 503a5a038..8175d0040 100644 --- a/src/GLViewer/GLViewer_Object.h +++ b/src/GLViewer/GLViewer_Object.h @@ -137,6 +137,13 @@ public: //! Returns scale factors virtual void getScale( GLfloat& xScale, GLfloat& yScale ) const { xScale = myXScale; yScale = myYScale;} + //!\warning It is for ouv + virtual GLboolean setXZoom( GLfloat zoom, bool recompute, bool fromGroup = false ); + //!\warning It is for ouv + virtual GLfloat getXZoom() const { return myXZoom; } + //!\warning It is for ouv + virtual GLboolean updateXZoom( bool zoomIn ); + //!\warning It is for ouv virtual GLboolean setZoom( GLfloat zoom, bool recompute, bool fromGroup = false ); //!\warning It is for ouv @@ -271,6 +278,8 @@ protected: //! Gap for Y direction of rect GLfloat myYGap; + //!\warning It is for ouv + GLfloat myXZoom; //!\warning It is for ouv GLfloat myZoom; diff --git a/src/GLViewer/GLViewer_Viewer.cxx b/src/GLViewer/GLViewer_Viewer.cxx index f850eeb41..bd2d28f11 100644 --- a/src/GLViewer/GLViewer_Viewer.cxx +++ b/src/GLViewer/GLViewer_Viewer.cxx @@ -652,7 +652,7 @@ bool GLViewer_ViewTransformer::eventFilter( QObject* o, QEvent* e ) TransformState state = EnTrain; QMouseEvent* me = ( QMouseEvent* )e; - myButtonState = me->modifiers(); + myButtonState = me->buttons(); if ( e->type() == QEvent::MouseButtonPress ) myButtonState |= me->button(); /* add pressed button */ @@ -664,7 +664,7 @@ bool GLViewer_ViewTransformer::eventFilter( QObject* o, QEvent* e ) myMajorBtn = mouseOnlyState; } - if ( e->type() == QEvent::MouseButtonRelease && mouseOnlyState == myMajorBtn ) + if ( e->type() == QEvent::MouseButtonRelease ) { state = Fin; } @@ -830,7 +830,7 @@ bool GLViewer_ViewSketcher::eventFilter( QObject* o, QEvent* e ) SketchState state = EnTrain; QMouseEvent* me = (QMouseEvent*)e; - myButtonState = me->modifiers(); + myButtonState = me->buttons(); if ( e->type() == QEvent::MouseButtonPress ) myButtonState |= me->button(); /* add pressed button */ diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index d05f9fc2c..fd22e1e9b 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -2391,8 +2391,9 @@ void LightApp_Application::loadDockWindowsState() if ( activeModule() ) modName = activeModule()->name(); - if ( myWinGeom.contains( modName ) ) - desktop()->restoreState( myWinGeom[modName] ); + // temporarily commented (for CATHARE) + //if ( myWinGeom.contains( modName ) ) + // desktop()->restoreState( myWinGeom[modName] ); if ( !myWinVis.contains( modName ) ) return; @@ -2422,8 +2423,9 @@ void LightApp_Application::loadDockWindowsState() if ( po != desktop() ) continue; - if ( dwMap.contains( dw->objectName() ) ) - dw->setVisible( dwMap[dw->objectName()] ); + // temporarily commented (for CATHARE) + //if ( dwMap.contains( dw->objectName() ) ) + // dw->setVisible( dwMap[dw->objectName()] ); } } diff --git a/src/LightApp/LightApp_SelectionMgr.cxx b/src/LightApp/LightApp_SelectionMgr.cxx index c466bbe31..7e47b6507 100644 --- a/src/LightApp/LightApp_SelectionMgr.cxx +++ b/src/LightApp/LightApp_SelectionMgr.cxx @@ -265,7 +265,7 @@ void LightApp_SelectionMgr::AddOrRemoveIndex( const Handle(SALOME_InteractiveObj select 'subobjects' with given indexes */ void LightApp_SelectionMgr::selectObjects( const Handle(SALOME_InteractiveObject)& IObject, - TColStd_IndexedMapOfInteger theIndex, bool append ) + const TColStd_IndexedMapOfInteger& theIndex, bool append ) { SUIT_DataOwnerPtrList aList; diff --git a/src/LightApp/LightApp_SelectionMgr.h b/src/LightApp/LightApp_SelectionMgr.h index b1db5bfe4..8b117dc2d 100644 --- a/src/LightApp/LightApp_SelectionMgr.h +++ b/src/LightApp/LightApp_SelectionMgr.h @@ -70,7 +70,7 @@ public: bool modeShift ); void selectObjects( const Handle(SALOME_InteractiveObject)& IObject, - TColStd_IndexedMapOfInteger theIndex, bool append ); + const TColStd_IndexedMapOfInteger& theIndex, bool append ); void selectObjects( MapIOOfMapOfInteger theMapIO, bool append ); void selectedSubOwners( MapEntryOfMapOfInteger& theMap ); diff --git a/src/Plot2d/Plot2d_Curve.cxx b/src/Plot2d/Plot2d_Curve.cxx index d26164e73..f027bedc4 100755 --- a/src/Plot2d/Plot2d_Curve.cxx +++ b/src/Plot2d/Plot2d_Curve.cxx @@ -377,6 +377,21 @@ double Plot2d_Curve::getMinX() const return aMinX; } +/*! + Gets curve's maxiaml abscissa +*/ +double Plot2d_Curve::getMaxX() const +{ + QList::const_iterator aIt; + double aMaxX = -1e150; + //int aCurrent = 0; + for(aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt) { + if ( (*aIt).x > aMaxX ) + aMaxX = (*aIt).x; + } + return aMaxX; +} + /*! Gets curve's minimal ordinate */ @@ -392,6 +407,21 @@ double Plot2d_Curve::getMinY() const return aMinY; } +/*! + Gets curve's maximal ordinate +*/ +double Plot2d_Curve::getMaxY() const +{ + QList::const_iterator aIt; + double aMaxY = -1e150; + //int aCurrent = 0; + for(aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt) { + if ( (*aIt).y > aMaxY ) + aMaxY = (*aIt).y; + } + return aMaxY; +} + /*! Changes text assigned to point of curve \param ind -- index of point diff --git a/src/Plot2d/Plot2d_Curve.h b/src/Plot2d/Plot2d_Curve.h index 3474a56b7..330095415 100755 --- a/src/Plot2d/Plot2d_Curve.h +++ b/src/Plot2d/Plot2d_Curve.h @@ -97,6 +97,11 @@ public: // non-positive X/Y coordinate double getMinX() const; double getMinY() const; + // Protection against QwtCurve::drawLines() bug in Qwt 0.4.x: + // sometimes it crashes (FPE) if draws curve with big abciss or ordinate cooridates + // after curve with small values + double getMaxX() const; + double getMaxY() const; protected: bool myAutoAssign; diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index c963ca5d1..fe488ca3b 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -144,6 +144,14 @@ const char* imageCrossCursor[] = { "................................"}; +QString Plot2d_ViewFrame::myPrefTitle = ""; +QString Plot2d_ViewFrame::myPrefXTitle = ""; +QString Plot2d_ViewFrame::myPrefYTitle = ""; + +bool Plot2d_ViewFrame::myPrefTitleChangedByUser = false; +bool Plot2d_ViewFrame::myXPrefTitleChangedByUser = false; +bool Plot2d_ViewFrame::myYPrefTitleChangedByUser = false; + /*! Constructor */ @@ -421,6 +429,22 @@ void Plot2d_ViewFrame::writePreferences() } resMgr->setValue( "Plot2d", "VerScaleMode", myYMode ); + + if ( myTitleChangedByUser ) + { + myPrefTitle = myTitle; + myPrefTitleChangedByUser = true; + } + if ( myXTitleChangedByUser ) + { + myPrefXTitle = myXTitle; + myXPrefTitleChangedByUser = true; + } + if ( myYTitleChangedByUser ) + { + myPrefYTitle = myYTitle; + myYPrefTitleChangedByUser = true; + } } /*! @@ -907,14 +931,26 @@ void Plot2d_ViewFrame::onSettings() myY2GridMinorEnabled, myPlot->axisMaxMinor( QwtPlot::yRight ) ); if ( dlg->exec() == QDialog::Accepted ) { // horizontal axis title + bool isTileChanged = dlg->getXTitle() != myXTitle; setTitle( dlg->isXTitleEnabled(), dlg->getXTitle(), XTitle, false ); + if ( isTileChanged ) + myXTitleChangedByUser = true; + // vertical left axis title + isTileChanged = dlg->getYTitle() != myYTitle; setTitle( dlg->isYTitleEnabled(), dlg->getYTitle(), YTitle, false ); + if ( isTileChanged ) + myYTitleChangedByUser = true; + if (mySecondY) // vertical right axis title setTitle( dlg->isY2TitleEnabled(), dlg->getY2Title(), Y2Title, false ); // main title + isTileChanged = dlg->getMainTitle() != myTitle; setTitle( dlg->isMainTitleEnabled(), dlg->getMainTitle(), MainTitle, true ); + if ( isTileChanged ) + myTitleChangedByUser = true; + // curve type if ( myCurveType != dlg->getCurveType() ) { setCurveType( dlg->getCurveType(), false ); @@ -2118,3 +2154,86 @@ void Plot2d_ViewFrame::customEvent( QEvent* ce ) if ( ce->type() == FITALL_EVENT ) fitAll(); } + +/*! + Verifies whether plot title must be generated automatically using curves titles +*/ +bool Plot2d_ViewFrame::isTitleChangedByUser( const ObjectType type ) +{ + switch ( type ) + { + case MainTitle: + return myPrefTitleChangedByUser || myTitleChangedByUser; + case XTitle: + return myXPrefTitleChangedByUser || myXTitleChangedByUser; + case YTitle: + return myYPrefTitleChangedByUser || myYTitleChangedByUser; + default: + return false; + } +} + +/*! + Verifies whether plot title must be generated automatically using curves titles +*/ +void Plot2d_ViewFrame::forgetLocalUserChanges( const ObjectType type ) +{ + switch ( type ) + { + case MainTitle: + myTitleChangedByUser = false; + break; + case XTitle: + myXTitleChangedByUser = false; + break; + case YTitle: + myYTitleChangedByUser = false; + break; + default: + break; + } +} + +/*! + Sets flag for automatic updates of titles in accordance with current set of curves + ( updateTitles method). You should call setAutoUpdateTitle( ObjType, false ) + if your application set titles itself and they can not be updated automatically. + By default titles are updated automatically. +*/ + +void Plot2d_ViewFrame::setAutoUpdateTitle( const ObjectType type, const bool upd ) +{ + switch ( type ) + { + case MainTitle: + myTitleAutoUpdate = upd; + break; + case XTitle: + myXTitleAutoUpdate = upd; + break; + case YTitle: + myYTitleAutoUpdate = upd; + break; + default: + break; + } +} + +/*! + Gets flag for automatic updates of titles in accordance with current set of curves + ( updateTitles method) +*/ +bool Plot2d_ViewFrame::getAutoUpdateTitle( const ObjectType type ) const +{ + switch ( type ) + { + case MainTitle: + return myTitleAutoUpdate; + case XTitle: + return myXTitleAutoUpdate; + case YTitle: + return myYTitleAutoUpdate; + default: + return true; + } +} diff --git a/src/Plot2d/Plot2d_ViewFrame.h b/src/Plot2d/Plot2d_ViewFrame.h index ba9f2e5f8..dc03493a7 100755 --- a/src/Plot2d/Plot2d_ViewFrame.h +++ b/src/Plot2d/Plot2d_ViewFrame.h @@ -107,6 +107,9 @@ public: void setTitle( bool enabled, const QString& title, ObjectType type, bool update = true ); QString getTitle( ObjectType type ) const; + bool isTitleChangedByUser( const ObjectType type ); + void forgetLocalUserChanges( const ObjectType type ); + void setFont( const QFont& font, ObjectType type, bool update = true ); void setHorScaleMode( const int mode, bool update = true ); int getHorScaleMode() const { return myXMode; } @@ -131,6 +134,9 @@ public: void incrementalPan ( const int incrX, const int incrY ); void incrementalZoom( const int incrX, const int incrY ); + void setAutoUpdateTitle( const ObjectType type, const bool upd ); + bool getAutoUpdateTitle( const ObjectType type ) const; + protected: int testOperation( const QMouseEvent& ); void readPreferences(); @@ -189,6 +195,17 @@ protected: int myXMode, myYMode; double myXDistance, myYDistance, myYDistance2; bool mySecondY; + + bool myTitleAutoUpdate, myXTitleAutoUpdate, myYTitleAutoUpdate; + bool myTitleChangedByUser, myXTitleChangedByUser, myYTitleChangedByUser; + + static QString myPrefTitle; + static QString myPrefXTitle; + static QString myPrefYTitle; + + static bool myPrefTitleChangedByUser; + static bool myXPrefTitleChangedByUser; + static bool myYPrefTitleChangedByUser; }; class Plot2d_Plot2d : public QwtPlot diff --git a/src/Qtx/QtxListBox.cxx b/src/Qtx/QtxListBox.cxx index b4bdef35f..928467250 100755 --- a/src/Qtx/QtxListBox.cxx +++ b/src/Qtx/QtxListBox.cxx @@ -24,11 +24,13 @@ #include #include +#include + /*! Constructor */ -QtxListBox::QtxListBox( QWidget* parent, const char* name, WFlags f ) -: QListBox( parent, name, f ), +QtxListBox::QtxListBox( QWidget* parent ) +: QListWidget( parent ), myEditor( 0 ), myEditIndex( -1 ), myEditState( false ), @@ -112,7 +114,7 @@ void QtxListBox::setModificationEnabled( bool on ) /*! \return current edited item */ -QListBoxItem* QtxListBox::editedItem() const +QListWidgetItem* QtxListBox::editedItem() const { return item( editedIndex() ); } @@ -144,7 +146,7 @@ void QtxListBox::startEdition( const int idx ) ensureItemVisible( myEditIndex ); - ed->setText( text( myEditIndex ) ); + ed->setText( item( myEditIndex )->text() ); updateEditor(); ed->show(); @@ -155,9 +157,9 @@ void QtxListBox::startEdition( const int idx ) Starts edition of item \param item - item to be edited */ -void QtxListBox::startEdition( const QListBoxItem* item ) +void QtxListBox::startEdition( const QListWidgetItem* item ) { - startEdition( index( item ) ); + startEdition( row( item ) ); } /*! @@ -178,14 +180,17 @@ void QtxListBox::endEdition( const bool action ) if ( action ) { - int cur = currentItem(); + int cur = currentRow(); + /*qt4 if ( pixmap( idx ) ) changeItem( *pixmap( idx ), ed->text(), idx ); else changeItem( ed->text(), idx ); + */ + item( idx )->setText( ed->text() ); - setCurrentItem( cur ); + setCurrentRow( cur ); emit itemEdited( idx ); emit itemEdited( item( idx ) ); @@ -201,19 +206,19 @@ void QtxListBox::ensureItemVisible( const int idx ) if ( idx < 0 ) return; - if ( itemVisible( idx ) ) - return; + //qt4 if ( itemVisible( idx ) ) + //qt4 return; - setTopItem( idx ); + //qt4 setTopItem( idx ); } /*! Ensures that the item is visible. \param item - item to be made visible */ -void QtxListBox::ensureItemVisible( const QListBoxItem* item ) +void QtxListBox::ensureItemVisible( const QListWidgetItem* item ) { - ensureItemVisible( index( item ) ); + ensureItemVisible( row( item ) ); } /*! @@ -233,7 +238,7 @@ const QValidator* QtxListBox::validator() const void QtxListBox::clearValidator() { if ( editor() ) - editor()->clearValidator(); + editor()->setValidator( 0 ); } /*! @@ -271,18 +276,18 @@ void QtxListBox::moveItemToBottom( const int idx ) */ void QtxListBox::moveItem( const int idx, const int step ) { - QListBoxItem* i = item( idx ); + QListWidgetItem* i = item( idx ); if ( !i || step == 0 ) return; - QListBoxItem* cur = item( currentItem() ); + QListWidgetItem* cur = currentItem(); - takeItem( i ); - insertItem( i, QMAX( 0, idx + step ) ); + takeItem( idx ); + insertItem( qMax( 0, idx + step ), i ); - setCurrentItem( index( cur ) ); + setCurrentItem( cur ); - int pos = index( i ); + int pos = row( i ); if ( myEditIndex == idx ) myEditIndex = pos; @@ -301,12 +306,12 @@ void QtxListBox::createItem( const int i ) if ( !isEditEnabled() ) return; - int idx = i < 0 ? currentItem() : i; + int idx = i < 0 ? currentRow() : i; idx = idx < 0 ? count() : idx; - idx = QMIN( (int)count(), idx ); + idx = qMin( (int)count(), idx ); - insertItem( "", idx ); - setCurrentItem( idx ); + insertItem( idx, "" ); + setCurrentRow( idx ); startEdition( idx ); } @@ -319,14 +324,14 @@ void QtxListBox::deleteItem( const int i ) if ( !isEditEnabled() ) return; - int idx = i < 0 ? currentItem() : i; + int idx = i < 0 ? currentRow() : i; if ( idx < 0 ) return; if ( editedIndex() == idx ) endEdition( defaultEditAction() ); - removeItem( idx ); + takeItem( idx ); updateEditor(); } @@ -336,7 +341,7 @@ void QtxListBox::deleteItem( const int i ) */ void QtxListBox::setContentsPos( int x, int y ) { - QListBox::setContentsPos( x, y ); + //qt4 QListWidget::setContentsPos( x, y ); updateEditor(); } @@ -354,14 +359,14 @@ bool QtxListBox::eventFilter( QObject* o, QEvent* e ) if ( e->type() == QEvent::KeyPress ) { QKeyEvent* ke = (QKeyEvent*)e; - if ( ke->key() == Key_Escape ) + if ( ke->key() == Qt::Key_Escape ) endEdition( false ); - else if ( ke->key() == Key_Enter || ke->key() == Key_Return ) + else if ( ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Return ) endEdition( true ); } } - return QListBox::eventFilter( o, e ); + return QListWidget::eventFilter( o, e ); } /*! @@ -370,28 +375,28 @@ bool QtxListBox::eventFilter( QObject* o, QEvent* e ) */ void QtxListBox::keyPressEvent( QKeyEvent* e ) { - if ( e->key() == Key_Up && e->state() & ControlButton && isModificationEnabled() ) - moveItem( currentItem(), -1 ); - else if ( e->key() == Key_Down && e->state() & ControlButton && isModificationEnabled() ) - moveItem( currentItem(), 1 ); - else if ( e->key() == Key_Home && e->state() & ControlButton && isModificationEnabled() ) - moveItemToTop( currentItem() ); - else if ( e->key() == Key_End && e->state() & ControlButton && isModificationEnabled() ) - moveItemToBottom( currentItem() ); - else if ( e->key() == Key_Insert && e->state() & ControlButton ) - createItem( currentItem() ); - else if ( e->key() == Key_Delete && e->state() & ControlButton ) - deleteItem( currentItem() ); + if ( e->key() == Qt::Key_Up && e->modifiers() & Qt::ControlModifier && isModificationEnabled() ) + moveItem( currentRow(), -1 ); + else if ( e->key() == Qt::Key_Down && e->modifiers() & Qt::ControlModifier && isModificationEnabled() ) + moveItem( currentRow(), 1 ); + else if ( e->key() == Qt::Key_Home && e->modifiers() & Qt::ControlModifier && isModificationEnabled() ) + moveItemToTop( currentRow() ); + else if ( e->key() == Qt::Key_End && e->modifiers() & Qt::ControlModifier && isModificationEnabled() ) + moveItemToBottom( currentRow() ); + else if ( e->key() == Qt::Key_Insert && e->modifiers() & Qt::ControlModifier ) + createItem( currentRow() ); + else if ( e->key() == Qt::Key_Delete && e->modifiers() & Qt::ControlModifier ) + deleteItem( currentRow() ); else - QListBox::keyPressEvent( e ); + QListWidget::keyPressEvent( e ); } /*! Custom resize event handler */ -void QtxListBox::viewportResizeEvent( QResizeEvent* e ) +void QtxListBox::resizeEvent( QResizeEvent* e ) { - QListBox::viewportResizeEvent( e ); + QListWidget::resizeEvent( e ); updateEditor(); } @@ -404,7 +409,7 @@ void QtxListBox::mouseDoubleClickEvent( QMouseEvent* e ) if ( isEditEnabled() ) startEdition( itemAt( e->pos() ) ); else - QListBox::mouseDoubleClickEvent( e ); + QListWidget::mouseDoubleClickEvent( e ); } /*! @@ -438,14 +443,14 @@ void QtxListBox::createEditor() myEditor = new QLineEdit( viewport() ); - myEditor->setLineWidth( 1 ); - myEditor->setMidLineWidth( 0 ); - myEditor->setFrameStyle( QFrame::Box | QFrame::Plain ); + //qt4 myEditor->setLineWidth( 1 ); + //qt4 myEditor->setMidLineWidth( 0 ); + //qt4 myEditor->setFrameStyle( QFrame::Box | QFrame::Plain ); myEditor->installEventFilter( this ); myEditor->hide(); - addChild( myEditor ); + //qt4 addChild( myEditor ); } /*! @@ -453,6 +458,7 @@ void QtxListBox::createEditor() */ void QtxListBox::updateEditor() { + /*qt4 if ( !editedItem() || !editor() ) return; @@ -468,4 +474,5 @@ void QtxListBox::updateEditor() r.addCoords( pix->width() + 2, 0, 0, 0 ); editor()->setGeometry( r ); + */ } diff --git a/src/Qtx/QtxListBox.h b/src/Qtx/QtxListBox.h index e2e9076b4..e9ba91d21 100755 --- a/src/Qtx/QtxListBox.h +++ b/src/Qtx/QtxListBox.h @@ -42,7 +42,7 @@ class QTX_EXPORT QtxListBox : public QListWidget//QListBox // This file isn't ye Q_OBJECT public: - QtxListBox( QWidget* = 0, const char* = 0, Qt::WindowFlags = 0 ); + QtxListBox( QWidget* = 0 ); virtual ~QtxListBox(); bool isEditEnabled() const; @@ -89,7 +89,7 @@ private slots: protected: virtual void keyPressEvent( QKeyEvent* ); - virtual void viewportResizeEvent( QResizeEvent* ); + virtual void resizeEvent( QResizeEvent* ); //qt4 viewportResizeEvent virtual void mouseDoubleClickEvent( QMouseEvent* ); private: diff --git a/src/Qtx/QtxWorkstack.cxx b/src/Qtx/QtxWorkstack.cxx index 9a5794f29..e8ee43a26 100644 --- a/src/Qtx/QtxWorkstack.cxx +++ b/src/Qtx/QtxWorkstack.cxx @@ -1279,6 +1279,7 @@ void QtxWorkstackChild::childEvent( QChildEvent* e ) */ QtxWorkstackTabBar::QtxWorkstackTabBar( QWidget* parent ) : QTabBar( parent ), + myActive( false ), myId( -1 ) { setDrawBase( true ); diff --git a/src/SUIT/SUIT_SelectionMgr.cxx b/src/SUIT/SUIT_SelectionMgr.cxx index a3f8a8e81..d3729f026 100755 --- a/src/SUIT/SUIT_SelectionMgr.cxx +++ b/src/SUIT/SUIT_SelectionMgr.cxx @@ -25,12 +25,13 @@ * Provide selection manager. Manipulate by selection filters, modes, data owners. */ -/*!constructor. initialize myIterations and myIsSelChangeEnabled.*/ +/*!constructor. initialize myIterations, myIsSelChangeEnabled and myIsSynchronizationEnabled.*/ SUIT_SelectionMgr::SUIT_SelectionMgr( const bool Feedback, QObject* p ) : QObject( p ), myIterations( Feedback ? 1 : 0 ), myAutoDelFilter( false ), -myIsSelChangeEnabled( true ) +myIsSelChangeEnabled( true ), +myIsSynchronizationEnabled( true ) { } @@ -144,17 +145,25 @@ void SUIT_SelectionMgr::selectionChanged( SUIT_Selector* sel ) SUIT_DataOwnerPtrList newOwners; filterOwners( owners, newOwners ); - for ( int i = 0; i < myIterations; i++ ) + if ( myIsSynchronizationEnabled ) { - for ( SelectorList::iterator it = mySelectors.begin(); it != mySelectors.end(); ++it ) + for ( int i = 0; i < myIterations; i++ ) { - // Temporary action(to avoid selection of the objects which don't pass the filters): - //if ( *it != sel ) - (*it)->setSelected( newOwners ); + for ( SelectorList::iterator it = mySelectors.begin(); it != mySelectors.end(); ++it ) + { + // Temporary action(to avoid selection of the objects which don't pass the filters): + //if ( *it != sel ) + (*it)->setSelected( newOwners ); + } } } + else + sel->setSelected( newOwners ); + myIsSelChangeEnabled = true; + myLastSelectionSource = sel->type(); + emit selectionChanged(); } @@ -345,3 +354,24 @@ void SUIT_SelectionMgr::filterOwners( const SUIT_DataOwnerPtrList& in, SUIT_Data out.append( *it ); } } + +/*! Gets type of last selector where selection has been changed. +*/ +QString SUIT_SelectionMgr::lastSelectionSource() const +{ + return myLastSelectionSource; +} + +/*! Verifies whether synchronization between selectors is enabled. +*/ +bool SUIT_SelectionMgr::isSynchronizationEnabled() const +{ + return myIsSynchronizationEnabled; +} + +/*! Enable or disable synchronization between selectors. +*/ +void SUIT_SelectionMgr::setSynchronizationEnabled( const bool on ) +{ + myIsSynchronizationEnabled = on; +} diff --git a/src/SUIT/SUIT_SelectionMgr.h b/src/SUIT/SUIT_SelectionMgr.h index ec2ecb9fa..8bef8ff5e 100755 --- a/src/SUIT/SUIT_SelectionMgr.h +++ b/src/SUIT/SUIT_SelectionMgr.h @@ -77,6 +77,10 @@ public: bool isSynchronizing() const; + QString lastSelectionSource() const; + bool isSynchronizationEnabled() const; + void setSynchronizationEnabled( const bool ); + signals: void selectionChanged(); @@ -99,6 +103,8 @@ private: int myIterations; bool myAutoDelFilter; bool myIsSelChangeEnabled; + bool myIsSynchronizationEnabled; + QString myLastSelectionSource; friend class SUIT_Selector; }; diff --git a/src/VTKViewer/VTKViewer_MergeFilter.cxx b/src/VTKViewer/VTKViewer_MergeFilter.cxx new file mode 100755 index 000000000..2ddcb8621 --- /dev/null +++ b/src/VTKViewer/VTKViewer_MergeFilter.cxx @@ -0,0 +1,442 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "VTKViewer_MergeFilter.h" + +#include "vtkCellData.h" +#include "vtkObjectFactory.h" +#include "vtkPointData.h" +#include "vtkPolyData.h" +#include "vtkRectilinearGrid.h" +#include "vtkStructuredGrid.h" +#include "vtkStructuredPoints.h" +#include "vtkUnstructuredGrid.h" + +vtkCxxRevisionMacro(VTKViewer_MergeFilter, "$Revision$"); +vtkStandardNewMacro(VTKViewer_MergeFilter); + +class vtkFieldNode +{ +public: + vtkFieldNode(const char* name, vtkDataSet* ptr=0) + { + int length = static_cast(strlen(name)); + if (length > 0) + { + this->Name = new char[length+1]; + strcpy(this->Name, name); + } + else + { + this->Name = 0; + } + this->Ptr = ptr; + this->Next = 0; + } + ~vtkFieldNode() + { + delete[] this->Name; + } + + const char* GetName() + { + return Name; + } + vtkDataSet* Ptr; + vtkFieldNode* Next; +private: + vtkFieldNode(const vtkFieldNode&) {} + void operator=(const vtkFieldNode&) {} + char* Name; +}; + +class vtkFieldList +{ +public: + vtkFieldList() + { + this->First = 0; + this->Last = 0; + } + ~vtkFieldList() + { + vtkFieldNode* node = this->First; + vtkFieldNode* next; + while(node) + { + next = node->Next; + delete node; + node = next; + } + } + + + void Add(const char* name, vtkDataSet* ptr) + { + vtkFieldNode* newNode = new vtkFieldNode(name, ptr); + if (!this->First) + { + this->First = newNode; + this->Last = newNode; + } + else + { + this->Last->Next = newNode; + this->Last = newNode; + } + } + + friend class vtkFieldListIterator; + +private: + vtkFieldNode* First; + vtkFieldNode* Last; +}; + +class vtkFieldListIterator +{ +public: + vtkFieldListIterator(vtkFieldList* list) + { + this->List = list; + this->Position = 0; + } + void Begin() + { + this->Position = this->List->First; + } + void Next() + { + if (this->Position) + { + this->Position = this->Position->Next; + } + } + int End() + { + return this->Position ? 0 : 1; + } + vtkFieldNode* Get() + { + return this->Position; + } + +private: + vtkFieldNode* Position; + vtkFieldList* List; +}; + +//------------------------------------------------------------------------------ + +// Create object with no input or output. +VTKViewer_MergeFilter::VTKViewer_MergeFilter() +{ + this->FieldList = new vtkFieldList; +} + +VTKViewer_MergeFilter::~VTKViewer_MergeFilter() +{ + delete this->FieldList; +} + +void VTKViewer_MergeFilter::SetScalars(vtkDataSet *input) +{ + this->vtkProcessObject::SetNthInput(1, input); +} +vtkDataSet *VTKViewer_MergeFilter::GetScalars() +{ + if (this->NumberOfInputs < 2) + { + return NULL; + } + return (vtkDataSet *)(this->Inputs[1]); +} + +void VTKViewer_MergeFilter::SetVectors(vtkDataSet *input) +{ + this->vtkProcessObject::SetNthInput(2, input); +} +vtkDataSet *VTKViewer_MergeFilter::GetVectors() +{ + if (this->NumberOfInputs < 3) + { + return NULL; + } + return (vtkDataSet *)(this->Inputs[2]); +} + +void VTKViewer_MergeFilter::SetNormals(vtkDataSet *input) +{ + this->vtkProcessObject::SetNthInput(3, input); +} +vtkDataSet *VTKViewer_MergeFilter::GetNormals() +{ + if (this->NumberOfInputs < 4) + { + return NULL; + } + return (vtkDataSet *)(this->Inputs[3]); +} + +void VTKViewer_MergeFilter::SetTCoords(vtkDataSet *input) +{ + this->vtkProcessObject::SetNthInput(4, input); +} +vtkDataSet *VTKViewer_MergeFilter::GetTCoords() +{ + if (this->NumberOfInputs < 5) + { + return NULL; + } + return (vtkDataSet *)(this->Inputs[4]); +} + +void VTKViewer_MergeFilter::SetTensors(vtkDataSet *input) +{ + this->vtkProcessObject::SetNthInput(5, input); +} +vtkDataSet *VTKViewer_MergeFilter::GetTensors() +{ + if (this->NumberOfInputs < 6) + { + return NULL; + } + return (vtkDataSet *)(this->Inputs[5]); +} + +void VTKViewer_MergeFilter::AddField(const char* name, vtkDataSet* input) +{ + this->FieldList->Add(name, input); +} + +void VTKViewer_MergeFilter::Execute() +{ + vtkIdType numPts, numScalars=0, numVectors=0, numNormals=0, numTCoords=0; + vtkIdType numTensors=0; + vtkIdType numCells, numCellScalars=0, numCellVectors=0, numCellNormals=0; + vtkIdType numCellTCoords=0, numCellTensors=0; + vtkPointData *pd; + vtkDataArray *scalars = NULL; + vtkDataArray *vectors = NULL; + vtkDataArray *normals = NULL; + vtkDataArray *tcoords = NULL; + vtkDataArray *tensors = NULL; + vtkCellData *cd; + vtkDataArray *cellScalars = NULL; + vtkDataArray *cellVectors = NULL; + vtkDataArray *cellNormals = NULL; + vtkDataArray *cellTCoords = NULL; + vtkDataArray *cellTensors = NULL; + vtkDataSet *output = this->GetOutput(); + vtkPointData *outputPD = output->GetPointData(); + vtkCellData *outputCD = output->GetCellData(); + + vtkDebugMacro(<<"Merging data!"); + + // geometry needs to be copied + output->CopyStructure(this->GetInput()); + if ( (numPts = this->GetInput()->GetNumberOfPoints()) < 1 ) + { + vtkWarningMacro(<<"Nothing to merge!"); + } + numCells = this->GetInput()->GetNumberOfCells(); + + if ( this->GetScalars() ) + { + pd = this->GetScalars()->GetPointData(); + scalars = pd->GetScalars(); + if ( scalars != NULL ) + { + numScalars = scalars->GetNumberOfTuples(); + } + cd = this->GetScalars()->GetCellData(); + cellScalars = cd->GetScalars(); + if ( cellScalars != NULL ) + { + numCellScalars = cellScalars->GetNumberOfTuples(); + } + } + + if ( this->GetVectors() ) + { + pd = this->GetVectors()->GetPointData(); + vectors = pd->GetVectors(); + if ( vectors != NULL ) + { + numVectors= vectors->GetNumberOfTuples(); + } + cd = this->GetVectors()->GetCellData(); + cellVectors = cd->GetVectors(); + if ( cellVectors != NULL ) + { + numCellVectors = cellVectors->GetNumberOfTuples(); + } + } + + if ( this->GetNormals() ) + { + pd = this->GetNormals()->GetPointData(); + normals = pd->GetNormals(); + if ( normals != NULL ) + { + numNormals= normals->GetNumberOfTuples(); + } + cd = this->GetNormals()->GetCellData(); + cellNormals = cd->GetNormals(); + if ( cellNormals != NULL ) + { + numCellNormals = cellNormals->GetNumberOfTuples(); + } + } + + if ( this->GetTCoords() ) + { + pd = this->GetTCoords()->GetPointData(); + tcoords = pd->GetTCoords(); + if ( tcoords != NULL ) + { + numTCoords= tcoords->GetNumberOfTuples(); + } + cd = this->GetTCoords()->GetCellData(); + cellTCoords = cd->GetTCoords(); + if ( cellTCoords != NULL ) + { + numCellTCoords = cellTCoords->GetNumberOfTuples(); + } + } + + if ( this->GetTensors() ) + { + pd = this->GetTensors()->GetPointData(); + tensors = pd->GetTensors(); + if ( tensors != NULL ) + { + numTensors = tensors->GetNumberOfTuples(); + } + cd = this->GetTensors()->GetCellData(); + cellTensors = cd->GetTensors(); + if ( cellTensors != NULL ) + { + numCellTensors = cellTensors->GetNumberOfTuples(); + } + } + + // merge data only if it is consistent + if ( numPts == numScalars ) + { + outputPD->SetScalars(scalars); + } + if ( numCells == numCellScalars ) + { + outputCD->SetScalars(cellScalars); + } + + if ( numPts == numVectors ) + { + outputPD->SetVectors(vectors); + } + if ( numCells == numCellVectors ) + { + outputCD->SetVectors(cellVectors); + } + + if ( numPts == numNormals ) + { + outputPD->SetNormals(normals); + } + if ( numCells == numCellNormals ) + { + outputCD->SetNormals(cellNormals); + } + + if ( numPts == numTCoords ) + { + outputPD->SetTCoords(tcoords); + } + if ( numCells == numCellTCoords ) + { + outputCD->SetTCoords(cellTCoords); + } + + if ( numPts == numTensors ) + { + outputPD->SetTensors(tensors); + } + if ( numCells == numCellTensors ) + { + outputCD->SetTensors(cellTensors); + } + + vtkFieldListIterator it(this->FieldList); + vtkDataArray* da; + const char* name; + vtkIdType num; + for(it.Begin(); !it.End() ; it.Next()) + { + pd = it.Get()->Ptr->GetPointData(); + cd = it.Get()->Ptr->GetCellData(); + name = it.Get()->GetName(); + if ( (da=pd->GetArray(name)) ) + { + num = da->GetNumberOfTuples(); + if (num == numPts) + { + outputPD->AddArray(da); + } + } + if ( (da=cd->GetArray(name)) ) + { + num = da->GetNumberOfTuples(); +// RKV: Fixed to be able to pass through celldata arrays given by AddField() +// RKV if (num == numPts) + if (num == numCells) // RKV + { + outputCD->AddArray(da); + } + } + } +} + +//---------------------------------------------------------------------------- +// Trick: Abstract data types that may or may not be the same type +// (structured/unstructured), but the points/cells match up. +// Output/Geometry may be structured while ScalarInput may be +// unstructured (but really have same triagulation/topology as geometry). +// Just request all the input. Always generate all of the output (todo). +void VTKViewer_MergeFilter::ComputeInputUpdateExtents(vtkDataObject *vtkNotUsed(data)) +{ + vtkDataSet *input; + int idx; + + for (idx = 0; idx < this->NumberOfInputs; ++idx) + { + input = (vtkDataSet *)(this->Inputs[idx]); + if (input) + { + input->SetUpdateExtent(0, 1, 0); + input->RequestExactExtentOn(); + } + } +} + +void VTKViewer_MergeFilter::PrintSelf(ostream& os, vtkIndent indent) +{ + this->Superclass::PrintSelf(os,indent); + +} + diff --git a/src/VTKViewer/VTKViewer_MergeFilter.h b/src/VTKViewer/VTKViewer_MergeFilter.h new file mode 100755 index 000000000..6e6b5b33f --- /dev/null +++ b/src/VTKViewer/VTKViewer_MergeFilter.h @@ -0,0 +1,97 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef __VTKViewer_MergeFilter_h +#define __VTKViewer_MergeFilter_h + +#include "VTKViewer.h" // RKV +#include "vtkDataSetToDataSetFilter.h" + +class vtkFieldList; + +// .NAME VTKViewer_MergeFilter - extract separate components of data from different datasets +// .SECTION Description +// VTKViewer_MergeFilter is a filter that extracts separate components of data from +// different datasets and merges them into a single dataset. The output from +// this filter is of the same type as the input (i.e., vtkDataSet.) It treats +// both cell and point data set attributes. + +// RKV: The source is vtkMergeFilter. +// RKV: Fixed to be able to pass through celldata arrays given by AddField() + +//RKV class VTK_GRAPHICS_EXPORT VTKViewer_MergeFilter : public vtkDataSetToDataSetFilter +class VTKVIEWER_EXPORT VTKViewer_MergeFilter : public vtkDataSetToDataSetFilter // RKV +{ +public: + static VTKViewer_MergeFilter *New(); + vtkTypeRevisionMacro(VTKViewer_MergeFilter,vtkDataSetToDataSetFilter); + void PrintSelf(ostream& os, vtkIndent indent); + + // Description: + // Specify object from which to extract geometry information. + void SetGeometry(vtkDataSet *input) {this->SetInput(input);}; + vtkDataSet *GetGeometry() {return this->GetInput();}; + + // Description: + // Specify object from which to extract scalar information. + void SetScalars(vtkDataSet *); + vtkDataSet *GetScalars(); + + // Description: + // Set / get the object from which to extract vector information. + void SetVectors(vtkDataSet *); + vtkDataSet *GetVectors(); + + // Description: + // Set / get the object from which to extract normal information. + void SetNormals(vtkDataSet *); + vtkDataSet *GetNormals(); + + // Description: + // Set / get the object from which to extract texture coordinates + // information. + void SetTCoords(vtkDataSet *); + vtkDataSet *GetTCoords(); + + // Description: + // Set / get the object from which to extract tensor data. + void SetTensors(vtkDataSet *); + vtkDataSet *GetTensors(); + + // Description: + // Set the object from which to extract a field and the name + // of the field + void AddField(const char* name, vtkDataSet* input); + +protected: + VTKViewer_MergeFilter(); + ~VTKViewer_MergeFilter(); + + // Usual data generation method + void Execute(); + void ComputeInputUpdateExtents(vtkDataObject *data); + + vtkFieldList* FieldList; +private: + VTKViewer_MergeFilter(const VTKViewer_MergeFilter&); // Not implemented. + void operator=(const VTKViewer_MergeFilter&); // Not implemented. + }; + +#endif + +