-// 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.
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// 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
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// 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
//
// File : SPlot2d_Viewer.cxx
// Author : Sergey RUIN
// Module : SUIT
-
+//
#include "SPlot2d_ViewModel.h"
#include "SPlot2d_ViewWindow.h"
#include "SPlot2d_Prs.h"
#include "SUIT_Session.h"
#include "SUIT_Application.h"
+#include "SUIT_ViewManager.h"
+
+#include "SALOME_ListIO.hxx"
-//#include "utilities.h"
-#include "qapplication.h"
-#include <qtoolbar.h>
-#include <qtoolbutton.h>
-#include <qcursor.h>
-#include <qcolordialog.h>
-#include <qwt_math.h>
+#include <QApplication>
+#include <QToolBar>
+#include <QToolButton>
+#include <QCursor>
+#include <QColorDialog>
+
+//#include <qwt_math>
#include <qwt_plot_canvas.h>
+#include <qwt_plot_curve.h>
#include <stdlib.h>
using namespace std;
if( !aViewFrame )
return;
- QIntDictIterator<Plot2d_Curve> it( aViewFrame->getCurves() );
- for( ; it.current(); ++it )
+ CurveDict aCurves = aViewFrame->getCurves();
+ CurveDict::Iterator it = aCurves.begin();
+ for( ; it != aCurves.end(); ++it )
{
- SPlot2d_Curve* aCurve = dynamic_cast<SPlot2d_Curve*>( it.current() );
+ SPlot2d_Curve* aCurve = dynamic_cast<SPlot2d_Curve*>( it.value() );
if( aCurve && aCurve->hasIO() && aCurve->getIO()->isSame( IObject ) )
{
aCurve->setVerTitle( newName );
- int key = aViewFrame->hasCurve( aCurve );
- if( key )
- aViewFrame->setCurveTitle( key, newName );
+ it.key()->setTitle( newName );
}
if( aCurve && aCurve->hasTableIO() && aCurve->getTableIO()->isSame( IObject ) )
- aCurve->getTableIO()->setName( newName.latin1() );
+ aCurve->getTableIO()->setName( newName.toLatin1() );
}
aViewFrame->updateTitles();
}
SUIT_ViewManager* vm = getViewManager();
if ( vm )
{
- const QPtrVector<SUIT_ViewWindow>& wnds = vm->getViews();
+ const QVector<SUIT_ViewWindow*>& wnds = vm->getViews();
+
for ( uint i = 0; i < wnds.size(); i++ )
{
Plot2d_ViewWindow* pwnd = dynamic_cast<Plot2d_ViewWindow*>( wnds.at( i ) );
return 1;
else{
if(!IObject.IsNull()){
- QIntDictIterator<Plot2d_Curve> it(aViewFrame->getCurves());
- for(; it.current();++it) {
- SPlot2d_Curve* aCurve = dynamic_cast<SPlot2d_Curve*>(it.current());
- if(aCurve->hasIO() && aCurve->getTableIO()->isSame(IObject))
+ CurveDict aCurves = aViewFrame->getCurves();
+ CurveDict::Iterator it = aCurves.begin();
+ for( ; it != aCurves.end(); ++it ) {
+ SPlot2d_Curve* aCurve = dynamic_cast<SPlot2d_Curve*>( it.value() );
+ if(aCurve && aCurve->hasIO() && aCurve->getTableIO()->isSame(IObject))
return 1;
}
}
if(aViewFrame == NULL) return;
Plot2d_Curve* curve = getCurveByIO( IObject );
- QIntDictIterator<Plot2d_Curve> it( aViewFrame->getCurves() );
- for ( ; it.current(); ++it ) {
- if(it.current() != curve)
+ CurveDict aCurves = aViewFrame->getCurves();
+ CurveDict::Iterator it = aCurves.begin();
+ for( ; it != aCurves.end(); ++it ) {
+ if(it.value() != curve)
aViewFrame->eraseCurve( curve );
else
aViewFrame->updateCurve( curve, false );
Plot2d_ViewFrame* aViewFrame = getActiveViewFrame();
if(aViewFrame == NULL) return anIO;
- QIntDictIterator<Plot2d_Curve> it( aViewFrame->getCurves() );
- for ( ; it.current(); ++it ) {
- SPlot2d_Curve* aCurve = dynamic_cast<SPlot2d_Curve*>(it.current());
- if ( aCurve->hasIO() && !strcmp( aCurve->getIO()->getEntry(), Entry ) ) {
+ CurveDict aCurves = aViewFrame->getCurves();
+ CurveDict::Iterator it = aCurves.begin();
+ for( ; it != aCurves.end(); ++it ) {
+ SPlot2d_Curve* aCurve = dynamic_cast<SPlot2d_Curve*>(it.value());
+ if ( aCurve && aCurve->hasIO() && !strcmp( aCurve->getIO()->getEntry(), Entry ) ) {
anIO = aCurve->getIO();
break;
}
if ( !theIObject.IsNull() ) {
Plot2d_ViewFrame* aViewFrame = fr ? fr : getActiveViewFrame();
if(aViewFrame) {
- QIntDictIterator<Plot2d_Curve> it( aViewFrame->getCurves() );
- for ( ; it.current(); ++it ) {
- SPlot2d_Curve* aCurve = dynamic_cast<SPlot2d_Curve*>(it.current());
+ CurveDict aCurves = aViewFrame->getCurves();
+ CurveDict::Iterator it = aCurves.begin();
+ for( ; it != aCurves.end(); ++it ) {
+ SPlot2d_Curve* aCurve = dynamic_cast<SPlot2d_Curve*>( it.value() );
if(aCurve) {
if ( aCurve->hasIO() && aCurve->getIO()->isSame( theIObject ) )
return aCurve;
return NULL;
}
-/*!
- SLOT: called when action "Clone view" is activated
-*/
-void SPlot2d_Viewer::onCloneView( Plot2d_ViewFrame* clonedVF, Plot2d_ViewFrame* newVF )
-{
- if( !clonedVF || !newVF )
- return;
-
- // 1) Copy all properties of view
-
- newVF->copyPreferences( clonedVF );
-
- // 2) Display all curves displayed in cloned view
-
- QList<Plot2d_Curve> aCurves;
- clonedVF->getCurves( aCurves );
- QList<Plot2d_Curve>::const_iterator anIt = aCurves.begin(), aLast = aCurves.end();
-
- for( ; anIt!=aLast; anIt++ )
- if( clonedVF->isVisible( *anIt ) )
- newVF->displayCurve( *anIt, false );
- newVF->Repaint();
-}
-
/*!
create SPlot2d_ViewWindow
*/
aPlot2dView->getViewFrame()->Display(getPrs());
return aPlot2dView;
}
+
+/*!
+ SLOT: called when action "Legend Clicked" is activated.
+ override "onLegendClicked" method from Plot2d_ViewModel.
+*/
+void SPlot2d_Viewer::onLegendClicked( QwtPlotItem* plotItem )
+{
+ Plot2d_ViewFrame* aViewFrame = getActiveViewFrame();
+ if(aViewFrame == NULL) return;
+
+ CurveDict aCurves = aViewFrame->getCurves();
+ SPlot2d_Curve* aSCurve;
+ CurveDict::Iterator it = aCurves.begin();
+ for( ; it != aCurves.end(); ++it )
+ {
+ if ( it.key() == plotItem ) {
+ aSCurve = dynamic_cast<SPlot2d_Curve*>( it.value() );
+ break;
+ }
+ }
+ // Highlight curve in Object Browser
+ if(aSCurve && aSCurve->hasIO()) {
+ QString anEntry = aSCurve->getIO()->getEntry();
+ emit legendSelected( anEntry );
+ }
+}