-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D\r
-//\r
-// This library is free software; you can redistribute it and/or\r
-// modify it under the terms of the GNU Lesser General Public\r
-// License as published by the Free Software Foundation; either\r
-// version 2.1 of the License.\r
-//\r
-// This library is distributed in the hope that it will be useful\r
-// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
-// Lesser General Public License for more details.\r
-//\r
-// You should have received a copy of the GNU Lesser General Public\r
-// License along with this library; if not, write to the Free Software\r
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
-//\r
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
-//\r
-// File: Plot2d_ToolTip.cxx\r
-// Author: Alexandre SOLOVYOV\r
-\r
-#include "Plot2d_ToolTip.h"\r
-#include "Plot2d_ViewFrame.h"\r
-#include "Plot2d_Curve.h"\r
-\r
-#include <QFontMetrics>\r
-#include <QEvent>\r
-#include <QMouseEvent>\r
-\r
-#include <qwt_plot.h>\r
-#include <qwt_plot_canvas.h>\r
-\r
-const int maxDist = 3, tip_margin = 10;\r
-\r
-\r
-Plot2d_ToolTip::Plot2d_ToolTip( Plot2d_ViewFrame* frame, Plot2d_Plot2d* plot )\r
-: QtxToolTip( plot->canvas() ),\r
- myFrame( frame ),\r
- myPlot( plot )\r
-{\r
- connect( this, SIGNAL( maybeTip( QPoint, QString&, QFont&, QRect&, QRect& ) ),\r
- this, SLOT( onToolTip( QPoint, QString&, QFont&, QRect&, QRect& ) ) );\r
-}\r
-\r
-Plot2d_ToolTip::~Plot2d_ToolTip()\r
-{\r
-}\r
-\r
-void Plot2d_ToolTip::onToolTip( QPoint p, QString& str, QFont& f, QRect& txtRect, QRect& rect )\r
-{\r
- QList< QList< int > > pInd;\r
-\r
- // Get all curves points in the vicinity.\r
- QList<Plot2d_Curve*> aCurves = myPlot->getClosestPoints( p, maxDist, pInd );\r
- if( aCurves.isEmpty() )\r
- return;\r
-\r
- QString aTxt;\r
-\r
- // Produce a tooltip containing text from all found points.\r
- for(int i = 0; i < aCurves.length(); i++)\r
- {\r
- const QList< int >& aPnts = pInd[i];\r
- foreach(int j, aPnts)\r
- {\r
- aTxt = aCurves[i]->text( j );\r
- if( !aTxt.isEmpty() )\r
- str += QString( "<p>%1</p>" ).arg( aTxt );\r
- }\r
- }\r
-\r
- // Produce a tooltip containing titles of all found curves.\r
- if( str.isEmpty() )\r
- {\r
- for(int i = 0; i < aCurves.length(); i++)\r
- {\r
- aTxt = aCurves[i]->getVerTitle();\r
- if( !aTxt.isEmpty() )\r
- {\r
- aTxt.replace( "\n", " " );\r
- str += QString( "<p>%1</p>" ).arg( aTxt );\r
- }\r
- }\r
- }\r
-\r
- if( str.isEmpty() )\r
- return;\r
-\r
- // Compute a size according to the produced tooltip text.\r
- QFontMetrics m( f );\r
- QStringList lst = str.split( QRegExp("\n|(<p>)|(</p>)"), QString::SkipEmptyParts );\r
- QStringList::const_iterator anIt = lst.begin(), aLast = lst.end();\r
- int w = 0, h = 0;\r
- for( ; anIt!=aLast; anIt++ )\r
- {\r
- //RKV: if( h>0 )\r
- h+= m.lineSpacing();\r
-\r
- QRect r = m.boundingRect( *anIt );\r
- if( r.width()>w )\r
- w = r.width();\r
- h+=r.height();\r
- }\r
-\r
- txtRect = QRect( p.x(), p.y(), w, h );\r
- rect = txtRect;\r
-}\r
-\r
-bool Plot2d_ToolTip::eventFilter( QObject* o, QEvent* e )\r
-{\r
- bool res = QtxToolTip::eventFilter( o, e );\r
- if( e && e->type() == QEvent::MouseMove )\r
- {\r
- QMouseEvent* me = ( QMouseEvent* )e;\r
- if( me->modifiers()==0 )\r
- return true;\r
- }\r
- return res;\r
-}\r
+// 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
+//
+// File: Plot2d_ToolTip.cxx
+// Author: Alexandre SOLOVYOV
+
+#include "Plot2d_ToolTip.h"
+#include "Plot2d_ViewFrame.h"
+#include "Plot2d_Curve.h"
+
+#include <QFontMetrics>
+#include <QEvent>
+#include <QMouseEvent>
+
+#include <qwt_plot.h>
+#include <qwt_plot_canvas.h>
+
+const int maxDist = 3, tip_margin = 10;
+
+
+Plot2d_ToolTip::Plot2d_ToolTip( Plot2d_ViewFrame* frame, Plot2d_Plot2d* plot )
+: QtxToolTip( plot->canvas() ),
+ myFrame( frame ),
+ myPlot( plot )
+{
+ connect( this, SIGNAL( maybeTip( QPoint, QString&, QFont&, QRect&, QRect& ) ),
+ this, SLOT( onToolTip( QPoint, QString&, QFont&, QRect&, QRect& ) ) );
+}
+
+Plot2d_ToolTip::~Plot2d_ToolTip()
+{
+}
+
+void Plot2d_ToolTip::onToolTip( QPoint p, QString& str, QFont& f, QRect& txtRect, QRect& rect )
+{
+ QList< QList< int > > pInd;
+
+ // Get all curves points in the vicinity.
+ QList<Plot2d_Curve*> aCurves = myPlot->getClosestPoints( p, maxDist, pInd );
+ if( aCurves.isEmpty() )
+ return;
+
+ QString aTxt;
+
+ // Produce a tooltip containing text from all found points.
+ for(int i = 0; i < aCurves.length(); i++)
+ {
+ const QList< int >& aPnts = pInd[i];
+ foreach(int j, aPnts)
+ {
+ aTxt = aCurves[i]->text( j );
+ if( !aTxt.isEmpty() )
+ str += QString( "<p>%1</p>" ).arg( aTxt );
+ }
+ }
+
+ // Produce a tooltip containing titles of all found curves.
+ if( str.isEmpty() )
+ {
+ for(int i = 0; i < aCurves.length(); i++)
+ {
+ aTxt = aCurves[i]->getVerTitle();
+ if( !aTxt.isEmpty() )
+ {
+ aTxt.replace( "\n", " " );
+ str += QString( "<p>%1</p>" ).arg( aTxt );
+ }
+ }
+ }
+
+ if( str.isEmpty() )
+ return;
+
+ // Compute a size according to the produced tooltip text.
+ QFontMetrics m( f );
+ QStringList lst = str.split( QRegExp("\n|(<p>)|(</p>)"), QString::SkipEmptyParts );
+ QStringList::const_iterator anIt = lst.begin(), aLast = lst.end();
+ int w = 0, h = 0;
+ for( ; anIt!=aLast; anIt++ )
+ {
+ //RKV: if( h>0 )
+ h+= m.lineSpacing();
+
+ QRect r = m.boundingRect( *anIt );
+ if( r.width()>w )
+ w = r.width();
+ h+=r.height();
+ }
+
+ txtRect = QRect( p.x(), p.y(), w, h );
+ rect = txtRect;
+}
+
+bool Plot2d_ToolTip::eventFilter( QObject* o, QEvent* e )
+{
+ bool res = QtxToolTip::eventFilter( o, e );
+ if( e && e->type() == QEvent::MouseMove )
+ {
+ QMouseEvent* me = ( QMouseEvent* )e;
+ if( me->modifiers()==0 )
+ return true;
+ }
+ return res;
+}