Salome HOME
Fix for bug 10438: Crash during Explode on Blocks operation (Global selection on...
[modules/gui.git] / src / Plot2d / Plot2d_ViewFrame.cxx
1 #include "Plot2d_ViewFrame.h"
2
3 #include "Plot2d_Prs.h"
4 #include "Plot2d_Curve.h"
5 #include "Plot2d_FitDataDlg.h"
6 #include "Plot2d_ViewWindow.h"
7 #include "Plot2d_SetupViewDlg.h"
8
9 #include "SUIT_Tools.h"
10 #include "SUIT_Session.h"
11 #include "SUIT_MessageBox.h"
12 #include "SUIT_ResourceMgr.h"
13 #include "SUIT_Application.h"
14
15 //#include "utilities.h"
16
17 #include "qapplication.h"
18 #include <qtoolbar.h>
19 #include <qtoolbutton.h>
20 #include <qcursor.h>
21 #include <qcolordialog.h>
22 #include <qptrlist.h>
23 #include <qlayout.h>
24 #include <qmap.h>
25
26 #include <qwt_math.h>
27 #include <qwt_plot_canvas.h>
28 #include <iostream>
29 #include <stdlib.h>
30
31 #include <qwt_legend.h>
32
33 //#include "utilities.h"
34
35 #define DEFAULT_LINE_WIDTH     0     // (default) line width
36 #define DEFAULT_MARKER_SIZE    9     // default marker size
37 #define MIN_RECT_SIZE          11    // min sensibility area size
38
39 const char* imageZoomCursor[] = { 
40 "32 32 3 1",
41 ". c None",
42 "a c #000000",
43 "# c #ffffff",
44 "................................",
45 "................................",
46 ".#######........................",
47 "..aaaaaaa.......................",
48 "................................",
49 ".............#####..............",
50 "...........##.aaaa##............",
51 "..........#.aa.....a#...........",
52 ".........#.a.........#..........",
53 ".........#a..........#a.........",
54 "........#.a...........#.........",
55 "........#a............#a........",
56 "........#a............#a........",
57 "........#a............#a........",
58 "........#a............#a........",
59 ".........#...........#.a........",
60 ".........#a..........#a.........",
61 ".........##.........#.a.........",
62 "........#####.....##.a..........",
63 ".......###aaa#####.aa...........",
64 "......###aa...aaaaa.......#.....",
65 ".....###aa................#a....",
66 "....###aa.................#a....",
67 "...###aa...............#######..",
68 "....#aa.................aa#aaaa.",
69 ".....a....................#a....",
70 "..........................#a....",
71 "...........................a....",
72 "................................",
73 "................................",
74 "................................",
75 "................................"};
76
77 const char* imageCrossCursor[] = { 
78   "32 32 3 1",
79   ". c None",
80   "a c #000000",
81   "# c #ffffff",
82   "................................",
83   "................................",
84   "................................",
85   "................................",
86   "................................",
87   "................................",
88   "................................",
89   "...............#................",
90   "...............#a...............",
91   "...............#a...............",
92   "...............#a...............",
93   "...............#a...............",
94   "...............#a...............",
95   "...............#a...............",
96   "...............#a...............",
97   ".......#################........",
98   "........aaaaaaa#aaaaaaaaa.......",
99   "...............#a...............",
100   "...............#a...............",
101   "...............#a...............",
102   "...............#a...............",
103   "...............#a...............",
104   "...............#a...............",
105   "...............#a...............",
106   "................a...............",
107   "................................",
108   "................................",
109   "................................",
110   "................................",
111   "................................",
112   "................................",
113   "................................"};
114   
115
116 QPixmap zoomPixmap(imageZoomCursor);
117 QPixmap globalPanPixmap(imageCrossCursor);
118
119 QCursor panCursor(Qt::SizeAllCursor);
120 QCursor zoomCursor(zoomPixmap);
121 QCursor glPanCursor(globalPanPixmap);
122
123 //=================================================================================
124 // Plot2d_ViewFrame implementation
125 //=================================================================================
126
127 /*!
128   Constructor
129 */
130 Plot2d_ViewFrame::Plot2d_ViewFrame( QWidget* parent, const QString& title )
131      : QWidget (parent, title, 0),
132        myOperation( NoOpId ), 
133        myCurveType( 1 ), 
134        myShowLegend( true ), myLegendPos( 1 ),
135        myMarkerSize( DEFAULT_MARKER_SIZE ),
136        myTitle( "" ), myXTitle( "" ), myYTitle( "" ), myY2Title( "" ),
137        myBackground( white ),
138        myTitleEnabled( true ), myXTitleEnabled( true ),
139        myYTitleEnabled( true ), myY2TitleEnabled (true),
140        myXGridMajorEnabled( true ), myYGridMajorEnabled( true ), myY2GridMajorEnabled( true ), 
141        myXGridMinorEnabled( false ), myYGridMinorEnabled( false ), myY2GridMinorEnabled( false ),
142        myXGridMaxMajor( 8 ), myYGridMaxMajor( 8 ), myY2GridMaxMajor( 8 ),
143        myXGridMaxMinor( 5 ), myYGridMaxMinor( 5 ), myY2GridMaxMinor( 5 ),
144        myXMode( 0 ), myYMode( 0 ), mySecondY( false )
145 {
146   /* Plot 2d View */
147   QVBoxLayout* aLayout = new QVBoxLayout( this ); 
148   myPlot = new Plot2d_Plot2d( this );
149   aLayout->addWidget( myPlot );
150
151 //  createActions();
152
153   connect( myPlot, SIGNAL( plotMouseMoved( const QMouseEvent& ) ),
154      this,   SLOT( plotMouseMoved( const QMouseEvent& ) ) );
155   connect( myPlot, SIGNAL( plotMousePressed( const QMouseEvent& ) ),
156      this,   SLOT( plotMousePressed( const QMouseEvent& ) ) );
157   connect( myPlot, SIGNAL( plotMouseReleased( const QMouseEvent& ) ),
158      this,   SLOT( plotMouseReleased( const QMouseEvent& ) ) );
159   //connect( myPlot, SIGNAL( legendClicked( long ) ),
160   //   this,   SLOT( onLegendClicked( long ) ) );
161
162   /* Initial Setup - get from the preferences */
163   readPreferences();
164
165   myPlot->setMargin( 5 );
166   setCurveType( myCurveType, false );
167   setXGrid( myXGridMajorEnabled, myXGridMaxMajor, myXGridMinorEnabled, myXGridMaxMinor, false );
168   setYGrid( myYGridMajorEnabled, myYGridMaxMajor, myYGridMinorEnabled, myYGridMaxMinor,
169             myY2GridMajorEnabled, myY2GridMaxMajor, myY2GridMinorEnabled, myY2GridMaxMinor, false );
170
171   setTitle( myTitleEnabled,  myTitle,  MainTitle, false );
172   setTitle( myXTitleEnabled, myXTitle, XTitle, false );
173   setTitle( myYTitleEnabled, myYTitle, YTitle, false );
174
175   if (mySecondY)
176     setTitle( myY2TitleEnabled, myY2Title, Y2Title, false );
177   setHorScaleMode( myXMode, false );
178   setVerScaleMode( myYMode, false );
179   setBackgroundColor( myBackground );
180   setLegendPos( myLegendPos );
181   showLegend( myShowLegend, false );
182   myPlot->replot();
183
184   if ( parent ) {
185     resize( (int)(0.8 * parent->width()), (int)(0.8 * parent->height()) );
186   }
187   QwtDiMap xMap = myPlot->canvasMap( QwtPlot::xBottom );
188   QwtDiMap yMap = myPlot->canvasMap( QwtPlot::yLeft );
189   myXDistance = xMap.d2() - xMap.d1();
190   myYDistance = yMap.d2() - yMap.d1();
191   myYDistance2 = 0;
192   if (mySecondY) {
193     QwtDiMap yMap2 = myPlot->canvasMap( QwtPlot::yRight );
194     myYDistance2 = yMap2.d2() - yMap2.d1();
195   }
196 }
197 /*!
198   Destructor
199 */
200 Plot2d_ViewFrame::~Plot2d_ViewFrame()
201 {
202 }
203 /*!
204   Gets window's central widget
205 */
206 QWidget* Plot2d_ViewFrame::getViewWidget()
207 {
208   return (QWidget*)myPlot;
209 }
210 /*!
211   Actually this method just re-displays all curves which are presented in the viewer
212 */
213 void Plot2d_ViewFrame::DisplayAll()
214 {
215   QList<Plot2d_Curve> clist;
216   getCurves( clist );
217   for ( int i = 0; i < (int)clist.count(); i++ ) {
218     updateCurve( clist.at( i ), false );
219   }
220   myPlot->replot();
221 }
222 /*!
223    Removes all curves from the view
224 */
225 void Plot2d_ViewFrame::EraseAll() 
226 {
227   myPlot->clear();
228   myCurves.clear();
229   myPlot->replot();
230 }
231 /*!
232   Redraws viewframe contents
233 */
234 void Plot2d_ViewFrame::Repaint()
235 {
236   myPlot->replot();
237 }
238 /*!
239   Display presentation
240 */
241 void Plot2d_ViewFrame::Display( const Plot2d_Prs* prs )
242 {
243   if ( !prs || prs->IsNull() )
244     return;
245
246   if (prs->isSecondY()) {
247     myPlot->enableAxis(QwtPlot::yRight, true);
248     mySecondY = true;
249   }
250   else {
251     myPlot->enableAxis(QwtPlot::yRight, false);
252     mySecondY = false;
253   }
254
255   // display all curves from presentation
256   curveList aCurves = prs->getCurves();
257   displayCurves( aCurves );
258   setXGrid( myXGridMajorEnabled, myXGridMaxMajor, myXGridMinorEnabled, myXGridMaxMinor, true );
259   setYGrid( myYGridMajorEnabled, myYGridMaxMajor, myYGridMinorEnabled, myYGridMaxMinor,
260             myY2GridMajorEnabled, myY2GridMaxMajor, myY2GridMinorEnabled, myY2GridMaxMinor, true );
261 }
262
263 /*!
264   Erase presentation
265 */
266 void Plot2d_ViewFrame::Erase( const Plot2d_Prs* prs, const bool )
267 {
268   if ( !prs || prs->IsNull() )
269     return;
270
271   // erase all curves from presentation
272   curveList aCurves = prs->getCurves();
273   eraseCurves( aCurves );
274 }
275
276 /*!
277   Sets title
278 */
279 void Plot2d_ViewFrame::setTitle( const QString& title )
280 {
281   setTitle( myTitleEnabled, title, MainTitle, true );
282 }
283
284 /*!
285   Reads Plot2d view settings from the preferences
286 */
287 void Plot2d_ViewFrame::readPreferences()
288 {
289   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
290
291   myCurveType = resMgr->integerValue( "Plot2d", "CurveType", myCurveType );
292   if ( myCurveType < 1 || myCurveType > 2 )
293     myCurveType = 1;
294   myShowLegend = resMgr->booleanValue( "Plot2d", "ShowLegend", myShowLegend );
295   myLegendPos = resMgr->integerValue( "Plot2d", "LegendPos", myLegendPos );
296   myMarkerSize = resMgr->integerValue( "Plot2d", "MarkerSize", myMarkerSize );
297   myBackground = resMgr->colorValue( "Plot2d", "Background", myBackground );
298
299   myTitleEnabled = resMgr->booleanValue( "Plot2d", "ShowTitle", myTitleEnabled );
300   myXTitleEnabled = resMgr->booleanValue( "Plot2d", "ShowHorTitle", myXTitleEnabled );
301   myYTitleEnabled = resMgr->booleanValue( "Plot2d", "ShowVerLeftTitle", myYTitleEnabled );
302   myY2TitleEnabled = resMgr->booleanValue( "Plot2d", "ShowVerRightTitle", myY2TitleEnabled );
303
304   myXGridMajorEnabled = resMgr->booleanValue( "Plot2d", "EnableHorMajorGrid", myXGridMajorEnabled );
305   myYGridMajorEnabled = resMgr->booleanValue( "Plot2d", "EnableVerMajorGrid", myYGridMajorEnabled );
306   myY2GridMajorEnabled = resMgr->booleanValue( "Plot2d", "EnableRightVerMajorGrid", myY2GridMajorEnabled );
307
308   myXGridMinorEnabled = resMgr->booleanValue( "Plot2d", "EnableHorMinorGrid", myXGridMinorEnabled );
309   myYGridMinorEnabled = resMgr->booleanValue( "Plot2d", "EnableVerMinorGrid", myYGridMinorEnabled );
310   myY2GridMinorEnabled = resMgr->booleanValue( "Plot2d", "EnableRightVerMinorGrid", myY2GridMinorEnabled );
311
312   myXGridMaxMajor = resMgr->integerValue( "Plot2d", "HorMajorGridMax", myXGridMaxMajor );
313   myYGridMaxMajor = resMgr->integerValue( "Plot2d", "VerMajorGridMax", myYGridMaxMajor );
314   if ( mySecondY )
315     myY2GridMaxMajor = resMgr->integerValue( "Plot2d", "VerMajorRightGridMax", myY2GridMaxMajor );
316
317   myXGridMaxMinor = resMgr->integerValue( "Plot2d", "HorMinorGridMax", myXGridMaxMinor );
318   myYGridMaxMinor = resMgr->integerValue( "Plot2d", "VerMinorGridMax", myYGridMaxMinor );
319   if ( mySecondY )
320     myY2GridMaxMinor = resMgr->integerValue( "Plot2d", "VerMinorGridMax", myY2GridMaxMinor );
321
322   myXMode = resMgr->integerValue( "Plot2d", "HorScaleMode", myXMode );
323   myXMode = QMAX( 0, QMIN( 1, myXMode ) );
324
325   myYMode = resMgr->integerValue( "Plot2d", "VerScaleMode", myYMode );
326   myYMode = QMAX( 0, QMIN( 1, myYMode ) );
327 }
328
329 /*!
330   Writes Plot2d view settings to the preferences
331 */
332 void Plot2d_ViewFrame::writePreferences()
333 {
334   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
335
336   resMgr->setValue( "Plot2d", "CurveType", myCurveType );
337   resMgr->setValue( "Plot2d", "ShowLegend", myShowLegend );
338   resMgr->setValue( "Plot2d", "LegendPos", myLegendPos );
339   resMgr->setValue( "Plot2d", "MarkerSize", myMarkerSize );
340   resMgr->setValue( "Plot2d", "Background", myBackground );
341   resMgr->setValue( "Plot2d", "ShowTitle", myTitleEnabled );
342   resMgr->setValue( "Plot2d", "ShowHorTitle", myXTitleEnabled );
343   resMgr->setValue( "Plot2d", "ShowVerLeftTitle", myYTitleEnabled );
344   if ( mySecondY )
345     resMgr->setValue( "Plot2d", "ShowVerRightTitle", myY2TitleEnabled );
346
347   resMgr->setValue( "Plot2d", "EnableHorMajorGrid", myXGridMajorEnabled );
348   resMgr->setValue( "Plot2d", "EnableVerMajorGrid", myYGridMajorEnabled );
349   resMgr->setValue( "Plot2d", "EnableHorMinorGrid", myXGridMinorEnabled );
350   resMgr->setValue( "Plot2d", "EnableVerMinorGrid", myYGridMinorEnabled );
351
352   resMgr->setValue( "Plot2d", "HorMajorGridMax", myXGridMaxMajor );
353   resMgr->setValue( "Plot2d", "VerMajorGridMax", myYGridMaxMajor );
354
355   resMgr->setValue( "Plot2d", "HorMinorGridMax", myXGridMaxMinor );
356   resMgr->setValue( "Plot2d", "VerMinorGridMax", myYGridMaxMinor );
357
358   resMgr->setValue( "Plot2d", "HorScaleMode", myXMode );
359
360   if ( mySecondY )
361   {
362     resMgr->setValue( "Plot2d", "EnableRightVerMajorGrid", myY2GridMajorEnabled );
363     resMgr->setValue( "Plot2d", "EnableRightVerMinorGrid", myY2GridMinorEnabled );
364     resMgr->setValue( "Plot2d", "VerRightMajorGridMax", myY2GridMaxMajor );
365     resMgr->setValue( "Plot2d", "VerRightMinorGridMax", myY2GridMaxMinor );
366   }
367
368   resMgr->setValue( "Plot2d", "VerScaleMode", myYMode );
369 }
370
371 /*!
372   Prints mouse cursor coordinates into string
373 */
374 QString Plot2d_ViewFrame::getInfo( const QPoint& pnt ) 
375 {
376   int i;
377   bool xFound = false, yFound = false;
378   double xCoord, yCoord;
379   const QwtScaleDiv* aXscale = myPlot->axisScale( QwtPlot::xBottom );
380   for ( i = 0; i < aXscale->majCnt(); i++ ) {
381     double majXmark = aXscale->majMark( i );
382     int xmark = myPlot->transform( QwtPlot::xBottom, majXmark );
383     if ( xmark-2 == pnt.x() ) {
384       xCoord = majXmark; 
385       xFound = true;
386 //      MESSAGE("Plot2d_ViewFrame::getInfo : close maj X mark("<<i<<") = "<<majXmark<<" "<<xmark<<" "<<pnt.x());
387       break;
388     }
389   }
390   if ( !xFound ) {
391     for ( i = 0; i < aXscale->minCnt(); i++ ) {
392       double minXmark = aXscale->minMark( i );
393       int xmark = myPlot->transform( QwtPlot::xBottom, minXmark );
394       if ( xmark-2 == pnt.x() ) {
395         xCoord = minXmark; 
396         xFound = true;
397 //        MESSAGE("Plot2d_ViewFrame::getInfo : close min X mark("<<i<<") = "<<minXmark<<" "<<xmark<<" "<<pnt.x());
398         break;
399       }
400     }
401   }  
402   const QwtScaleDiv* aYscale = myPlot->axisScale( QwtPlot::yLeft );
403   for ( i = 0; i < aYscale->majCnt(); i++ ) {
404     double majYmark = aYscale->majMark( i );
405     int ymark = myPlot->transform( QwtPlot::yLeft, majYmark );
406     if ( ymark-2 == pnt.y() ) {
407       yCoord = majYmark; 
408       yFound = true;
409       break;
410     }
411   }
412   if ( !yFound ) {
413     for ( i = 0; i < aYscale->minCnt(); i++ ) {
414       double minYmark = aYscale->minMark( i );
415       int ymark = myPlot->transform( QwtPlot::yLeft, minYmark );
416       if ( ymark-2 == pnt.y() ) {
417         yCoord = minYmark; 
418         yFound = true;
419         break;
420       }
421     }
422   }  
423
424   QString strX = QString::number( xFound ? xCoord : myPlot->invTransform( QwtPlot::xBottom, pnt.x() ) ).stripWhiteSpace();
425   if ( strX == "-0" )
426     strX = "0";
427   QString strY = QString::number( yFound ? yCoord : myPlot->invTransform( QwtPlot::yLeft, pnt.y() ) ).stripWhiteSpace();
428   if ( strY == "-0" )
429     strY = "0";
430   QString info = "";
431
432   if (mySecondY) {
433     bool yFound2 = false;
434     double yCoord2;
435
436     const QwtScaleDiv* aYscale2 = myPlot->axisScale( QwtPlot::yRight );
437     for ( i = 0; i < aYscale2->majCnt(); i++ ) {
438       double majYmark = aYscale2->majMark( i );
439       int ymark = myPlot->transform( QwtPlot::yRight, majYmark );
440       if ( ymark-2 == pnt.y() ) {
441         yCoord2 = majYmark; 
442         yFound2 = true;
443         break;
444       }
445     }
446     if ( !yFound2 ) {
447       for ( i = 0; i < aYscale2->minCnt(); i++ ) {
448         double minYmark = aYscale2->minMark( i );
449         int ymark = myPlot->transform( QwtPlot::yRight, minYmark );
450         if ( ymark-2 == pnt.y() ) {
451           yCoord2 = minYmark; 
452           yFound2 = true;
453           break;
454         }
455       }
456     }
457     QString strY2 = QString::number( yFound2 ? yCoord2 : 
458                       myPlot->invTransform( QwtPlot::yRight, pnt.y() ) ).stripWhiteSpace();
459     if ( strY2 == "-0" )
460     strY2 = "0";
461     info = tr("INF_COORDINATES_SOME_Y").arg( strX ).arg( strY ).arg( strY2 );
462   }
463   else
464     info = tr("INF_COORDINATES").arg( strX ).arg( strY );
465
466   return info;
467 }
468
469 /*!
470   Converts Plot2d_Curve's marker style to Qwt marker style [ static ]
471 */
472 static QwtSymbol::Style plot2qwtMarker( Plot2d_Curve::MarkerType m )
473 {
474   QwtSymbol::Style ms = QwtSymbol::None;  
475   switch ( m ) {
476   case Plot2d_Curve::Circle:
477     ms = QwtSymbol::Ellipse;   break;
478   case Plot2d_Curve::Rectangle:
479     ms = QwtSymbol::Rect;      break;
480   case Plot2d_Curve::Diamond:
481     ms = QwtSymbol::Diamond;   break;
482   case Plot2d_Curve::DTriangle:
483     ms = QwtSymbol::DTriangle; break;
484   case Plot2d_Curve::UTriangle:
485     ms = QwtSymbol::UTriangle; break;
486   case Plot2d_Curve::LTriangle: // Qwt confuses LTriangle and RTriangle :(((
487     ms = QwtSymbol::RTriangle; break;
488   case Plot2d_Curve::RTriangle: // Qwt confuses LTriangle and RTriangle :(((
489     ms = QwtSymbol::LTriangle; break;
490   case Plot2d_Curve::Cross:
491     ms = QwtSymbol::Cross;     break;
492   case Plot2d_Curve::XCross:
493     ms = QwtSymbol::XCross;    break;
494   case Plot2d_Curve::None:
495   default:
496     ms = QwtSymbol::None;      break;
497   }
498   return ms;
499 }
500
501 /*!
502   Converts Qwt marker style to Plot2d_Curve's marker style [ static ]
503 */
504 static Plot2d_Curve::MarkerType qwt2plotMarker( QwtSymbol::Style m )
505 {
506   Plot2d_Curve::MarkerType ms = Plot2d_Curve::None;  
507   switch ( m ) {
508   case QwtSymbol::Ellipse:
509     ms = Plot2d_Curve::Circle;    break;
510   case QwtSymbol::Rect:
511     ms = Plot2d_Curve::Rectangle; break;
512   case QwtSymbol::Diamond:
513     ms = Plot2d_Curve::Diamond;   break;
514   case QwtSymbol::DTriangle:
515     ms = Plot2d_Curve::DTriangle; break;
516   case QwtSymbol::UTriangle:
517     ms = Plot2d_Curve::UTriangle; break;
518   case QwtSymbol::RTriangle: // Qwt confuses LTriangle and RTriangle :(((
519     ms = Plot2d_Curve::LTriangle; break;
520   case QwtSymbol::LTriangle: // Qwt confuses LTriangle and RTriangle :(((
521     ms = Plot2d_Curve::RTriangle; break;
522   case QwtSymbol::Cross:
523     ms = Plot2d_Curve::Cross;     break;
524   case QwtSymbol::XCross:
525     ms = Plot2d_Curve::XCross;    break;
526   case QwtSymbol::None:
527   default:
528     ms = Plot2d_Curve::None;      break;
529   }
530   return ms;
531 }
532
533 /*!
534   Converts Plot2d_Curve's line style to Qwt line style [ static ]
535 */
536 static Qt::PenStyle plot2qwtLine( Plot2d_Curve::LineType p )
537 {
538   Qt::PenStyle ps = Qt::NoPen;
539   switch ( p ) {
540   case Plot2d_Curve::Solid:
541     ps = Qt::SolidLine;      break;
542   case Plot2d_Curve::Dash:
543     ps = Qt::DashLine;       break;
544   case Plot2d_Curve::Dot:
545     ps = Qt::DotLine;        break;
546   case Plot2d_Curve::DashDot:
547     ps = Qt::DashDotLine;    break;
548   case Plot2d_Curve::DashDotDot:
549     ps = Qt::DashDotDotLine; break;
550   case Plot2d_Curve::NoPen:
551   default:
552     ps = Qt::NoPen;          break;
553   }
554   return ps;
555 }
556
557 /*!
558   Converts Qwt line style to Plot2d_Curve's line style [ static ]
559 */
560 static Plot2d_Curve::LineType qwt2plotLine( Qt::PenStyle p )
561 {
562   Plot2d_Curve::LineType ps = Plot2d_Curve::NoPen;
563   switch ( p ) {
564   case Qt::SolidLine:
565     ps = Plot2d_Curve::Solid;      break;
566   case Qt::DashLine:
567     ps = Plot2d_Curve::Dash;       break;
568   case Qt::DotLine:
569     ps = Plot2d_Curve::Dot;        break;
570   case Qt::DashDotLine:
571     ps = Plot2d_Curve::DashDot;    break;
572   case Qt::DashDotDotLine:
573     ps = Plot2d_Curve::DashDotDot; break;
574   case Qt::NoPen:
575   default:
576     ps = Plot2d_Curve::NoPen;      break;
577   }
578   return ps;
579 }
580
581 /*!
582   Adds curve into view
583 */
584 void Plot2d_ViewFrame::displayCurve( Plot2d_Curve* curve, bool update )
585 {
586   if ( !curve )
587     return;
588   if ( hasCurve( curve ) ) {
589     updateCurve( curve, update );
590   }
591   else {
592     long curveKey = myPlot->insertCurve( curve->getVerTitle() );
593     myPlot->setCurveYAxis(curveKey, curve->getYAxis());
594
595     myCurves.insert( curveKey, curve );
596     if ( curve->isAutoAssign() ) {
597       QwtSymbol::Style typeMarker;
598       QColor           color;
599       Qt::PenStyle     typeLine;
600       myPlot->getNextMarker( typeMarker, color, typeLine );
601       myPlot->setCurvePen( curveKey, QPen( color, DEFAULT_LINE_WIDTH, typeLine ) );
602       myPlot->setCurveSymbol( curveKey, QwtSymbol( typeMarker, 
603                QBrush( color ), 
604                QPen( color ), 
605                QSize( myMarkerSize, myMarkerSize ) ) );
606       curve->setColor( color );
607       curve->setLine( qwt2plotLine( typeLine ) );
608       curve->setMarker( qwt2plotMarker( typeMarker ) );
609     }
610     else {
611       Qt::PenStyle     ps = plot2qwtLine( curve->getLine() );
612       QwtSymbol::Style ms = plot2qwtMarker( curve->getMarker() );
613       myPlot->setCurvePen( curveKey, QPen( curve->getColor(), curve->getLineWidth(), ps ) );
614       myPlot->setCurveSymbol( curveKey, QwtSymbol( ms, 
615                QBrush( curve->getColor() ), 
616                QPen( curve->getColor() ), 
617                QSize( myMarkerSize, myMarkerSize ) ) );
618     }
619     if ( myCurveType == 0 )
620       myPlot->setCurveStyle( curveKey, QwtCurve::NoCurve );
621     else if ( myCurveType == 1 )
622       myPlot->setCurveStyle( curveKey, QwtCurve::Lines );
623     else if ( myCurveType == 2 )
624       myPlot->setCurveStyle( curveKey, QwtCurve::Spline );
625     myPlot->setCurveData( curveKey, curve->horData(), curve->verData(), curve->nbPoints() );
626   }
627   if ( update )
628     myPlot->replot();
629 }
630
631 /*!
632   Adds curves into view
633 */
634 void Plot2d_ViewFrame::displayCurves( const curveList& curves, bool update )
635 {
636   myPlot->setUpdatesEnabled( false );
637   QPtrListIterator<Plot2d_Curve> it(curves);
638   Plot2d_Curve* aCurve;
639   while( (aCurve = it.current()) ) {
640     displayCurve( aCurve, false );
641     ++it;
642   }
643
644   fitAll();
645   myPlot->setUpdatesEnabled( true );
646   if ( update )
647     myPlot->replot();
648 }
649
650 /*!
651   Erases curve
652 */
653 void Plot2d_ViewFrame::eraseCurve( Plot2d_Curve* curve, bool update )
654 {
655   if ( !curve )
656     return;
657   int curveKey = hasCurve( curve );
658   if ( curveKey ) {
659     myPlot->removeCurve( curveKey );
660     myCurves.remove( curveKey );
661     if ( update )
662       myPlot->replot();
663   }
664 }
665
666 /*!
667   Erases curves
668 */
669 void Plot2d_ViewFrame::eraseCurves( const curveList& curves, bool update )
670 {
671   QPtrListIterator<Plot2d_Curve> it(curves);
672   Plot2d_Curve* aCurve;
673   while( (aCurve = it.current()) ) {
674     eraseCurve( aCurve, false );
675     ++it;
676   }
677 //  fitAll();
678   if ( update )
679     myPlot->replot();
680 }
681
682 /*!
683   Updates curves attributes
684 */
685 void Plot2d_ViewFrame::updateCurve( Plot2d_Curve* curve, bool update )
686 {
687   if ( !curve )
688     return;
689   int curveKey = hasCurve( curve );
690   if ( curveKey ) {
691     if ( !curve->isAutoAssign() ) {
692       Qt::PenStyle     ps = plot2qwtLine( curve->getLine() );
693       QwtSymbol::Style ms = plot2qwtMarker( curve->getMarker() );
694       myPlot->setCurvePen( curveKey, QPen( curve->getColor(), curve->getLineWidth(), ps ) );
695       myPlot->setCurveSymbol( curveKey, QwtSymbol( ms, 
696                QBrush( curve->getColor() ), 
697                QPen( curve->getColor() ), 
698                QSize( myMarkerSize, myMarkerSize ) ) );
699       myPlot->setCurveData( curveKey, curve->horData(), curve->verData(), curve->nbPoints() );
700     }
701     myPlot->setCurveTitle( curveKey, curve->getVerTitle() );
702     myPlot->curve( curveKey )->setEnabled( true );
703     if ( update )
704       myPlot->replot();
705   }
706 }
707
708 /*!
709   Returns curve key if is is displayed in the viewer and 0 otherwise
710 */
711 int Plot2d_ViewFrame::hasCurve( Plot2d_Curve* curve )
712 {
713   QIntDictIterator<Plot2d_Curve> it( myCurves );
714   for ( ; it.current(); ++it ) {
715     if ( it.current() == curve )
716       return it.currentKey();
717   }
718   return 0;
719 }
720
721 /*!
722   Gets lsit of displayed curves
723 */
724 int Plot2d_ViewFrame::getCurves( QList<Plot2d_Curve>& clist )
725 {
726   clist.clear();
727   clist.setAutoDelete( false );
728   QIntDictIterator<Plot2d_Curve> it( myCurves );
729   for ( ; it.current(); ++it ) {
730     clist.append( it.current() );
731   }
732   return clist.count();
733 }
734
735 /*!
736   Returns true if the curve is visible
737 */
738 bool Plot2d_ViewFrame::isVisible( Plot2d_Curve* curve )
739 {
740   if(curve) {
741     int key = hasCurve( curve );
742     if ( key )
743       return myPlot->curve( key )->enabled();
744   }
745   return false;
746
747
748 /*!
749   update legend
750 */
751 void Plot2d_ViewFrame::updateLegend( const Plot2d_Prs* prs )
752 {
753   if ( !prs || prs->IsNull() )
754     return;
755   curveList aCurves = prs->getCurves();
756
757   QPtrListIterator<Plot2d_Curve> it(aCurves);
758   Plot2d_Curve* aCurve;
759   while( (aCurve = it.current()) ) {
760     int curveKey = hasCurve( aCurve );
761     if ( curveKey )
762       myPlot->setCurveTitle( curveKey, aCurve->getVerTitle() );
763     ++it;
764   }
765 }
766
767 /*!
768   Fits the view to see all data
769 */
770 void Plot2d_ViewFrame::fitAll()
771 {
772   QwtDiMap xMap1 = myPlot->canvasMap( QwtPlot::xBottom );
773
774   myPlot->setAxisAutoScale( QwtPlot::yLeft );
775   myPlot->setAxisAutoScale( QwtPlot::xBottom );
776   myPlot->replot();
777
778   // for existing grid
779   QwtDiMap xMap = myPlot->canvasMap( QwtPlot::xBottom );
780   QwtDiMap yMap = myPlot->canvasMap( QwtPlot::yLeft );
781
782   myPlot->setAxisScale( QwtPlot::xBottom, 
783       myPlot->invTransform( QwtPlot::xBottom, xMap.i1() ), 
784       myPlot->invTransform( QwtPlot::xBottom, xMap.i2() ) );
785   myPlot->setAxisScale( QwtPlot::yLeft, 
786       myPlot->invTransform( QwtPlot::yLeft, yMap.i1() ), 
787       myPlot->invTransform( QwtPlot::yLeft, yMap.i2() ) );
788
789   if (mySecondY) {
790     myPlot->setAxisAutoScale( QwtPlot::yRight );
791     myPlot->replot();
792     QwtDiMap yMap2 = myPlot->canvasMap( QwtPlot::yRight );
793     myPlot->setAxisScale( QwtPlot::yRight, 
794         myPlot->invTransform( QwtPlot::yRight, yMap2.i1() ), 
795         myPlot->invTransform( QwtPlot::yRight, yMap2.i2() ) );
796   }
797   myPlot->replot();
798 }
799
800 /*!
801   Fits the view to rectangle area (pixels)
802 */
803 void Plot2d_ViewFrame::fitArea( const QRect& area )
804 {
805   QRect rect = area.normalize();
806   if ( rect.width() < MIN_RECT_SIZE ) {
807     rect.setWidth( MIN_RECT_SIZE );
808     rect.setLeft( rect.left() - MIN_RECT_SIZE/2 );
809   }
810   if ( rect.height() < MIN_RECT_SIZE ) {
811     rect.setHeight( MIN_RECT_SIZE );
812     rect.setTop( rect.top() - MIN_RECT_SIZE/2 );
813   }
814   myPlot->setAxisScale( QwtPlot::yLeft, 
815             myPlot->invTransform( QwtPlot::yLeft, rect.top() ), 
816             myPlot->invTransform( QwtPlot::yLeft, rect.bottom() ) );
817   if (mySecondY)
818     myPlot->setAxisScale( QwtPlot::yRight, 
819             myPlot->invTransform( QwtPlot::yRight, rect.top() ), 
820             myPlot->invTransform( QwtPlot::yRight, rect.bottom() ) );
821   myPlot->setAxisScale( QwtPlot::xBottom, 
822             myPlot->invTransform( QwtPlot::xBottom, rect.left() ), 
823             myPlot->invTransform( QwtPlot::xBottom, rect.right() ) );
824   myPlot->replot();
825 }
826
827 /*!
828   "Fit Data" command for TUI interface
829 */
830 void Plot2d_ViewFrame::fitData(const int mode,
831                                const double xMin, const double xMax,
832                                const double yMin, const double yMax,
833                                double y2Min, double y2Max)
834 {
835   if ( mode == 0 || mode == 2 ) {
836     myPlot->setAxisScale( QwtPlot::yLeft, yMax, yMin );
837     if (mySecondY)
838       myPlot->setAxisScale( QwtPlot::yRight, y2Max, y2Min );
839   }
840   if ( mode == 0 || mode == 1 ) 
841     myPlot->setAxisScale( QwtPlot::xBottom, xMin, xMax ); 
842   myPlot->replot();
843 }
844
845 /*!
846   Gets current fit ranges for view frame
847 */
848 void Plot2d_ViewFrame::getFitRanges(double& xMin,double& xMax,
849                                     double& yMin, double& yMax,
850                                     double& y2Min, double& y2Max)
851 {
852   int ixMin = myPlot->canvasMap( QwtPlot::xBottom ).i1();
853   int ixMax = myPlot->canvasMap( QwtPlot::xBottom ).i2();
854   int iyMin = myPlot->canvasMap( QwtPlot::yLeft ).i1();
855   int iyMax = myPlot->canvasMap( QwtPlot::yLeft ).i2();
856   xMin = myPlot->invTransform(QwtPlot::xBottom, ixMin);
857   xMax = myPlot->invTransform(QwtPlot::xBottom, ixMax);
858   yMin = myPlot->invTransform(QwtPlot::yLeft, iyMin);
859   yMax = myPlot->invTransform(QwtPlot::yLeft, iyMax);
860   y2Min = 0;
861   y2Max = 0;
862   if (mySecondY) {
863     int iyMin = myPlot->canvasMap( QwtPlot::yRight ).i1();
864     int iyMax = myPlot->canvasMap( QwtPlot::yRight ).i2();
865     y2Min = myPlot->invTransform(QwtPlot::yRight, iyMin);
866     y2Max = myPlot->invTransform(QwtPlot::yRight, iyMax);
867   }
868 }
869
870 /*!
871   Tests if it is necessary to start operation on mouse action
872 */
873 int Plot2d_ViewFrame::testOperation( const QMouseEvent& me )
874 {
875   int btn = me.button() | me.state();
876   const int zoomBtn = ControlButton | LeftButton;
877   const int panBtn  = ControlButton | MidButton;
878   const int fitBtn  = ControlButton | RightButton;
879
880   switch (btn)
881   {
882   case zoomBtn:
883     myPlot->canvas()->setCursor( zoomCursor );
884     return ZoomId;
885   case panBtn:
886     myPlot->canvas()->setCursor( QCursor( Qt::SizeAllCursor ) );
887     return PanId;
888   case fitBtn:
889     myPlot->canvas()->setCursor( QCursor( Qt::PointingHandCursor ) );
890     return FitAreaId;
891   default :
892     return NoOpId;
893   }
894 }
895
896 /*!
897   "Settings" toolbar action slot
898 */
899 void Plot2d_ViewFrame::onSettings()
900 {
901 #ifdef TEST_AUTOASSIGN
902   typedef QMap<int,int> IList;
903   typedef QMap<QString,int> SList;
904   IList mars, lins;
905   SList cols;
906   cols[ "red-min" ]   = 1000;
907   cols[ "red-max" ]   = -1;
908   cols[ "green-min" ] = 1000;
909   cols[ "green-max" ] = -1;
910   cols[ "blue-min" ]  = 1000;
911   cols[ "blue-max" ]  = -1;
912   for ( unsigned i = 0; i < 10000; i++ ) {
913     QwtSymbol::Style typeMarker;
914     QColor           color;
915     Qt::PenStyle     typeLine;
916     myPlot->getNextMarker( typeMarker, color, typeLine );
917     if ( mars.contains(typeMarker) )
918       mars[ typeMarker ] = mars[ typeMarker ]+1;
919     else
920       mars[ typeMarker ] = 0;
921     if ( lins.contains(typeLine) )
922       lins[ typeLine ] = lins[ typeLine ]+1;
923     else
924       lins[ typeLine ] = 0;
925     if ( cols[ "red-max" ] < color.red() )
926       cols[ "red-max" ] = color.red();
927     if ( cols[ "red-min" ] > color.red() )
928       cols[ "red-min" ] = color.red();
929     if ( cols[ "green-max" ] < color.green() )
930       cols[ "green-max" ] = color.green();
931     if ( cols[ "green-min" ] > color.green() )
932       cols[ "green-min" ] = color.green();
933     if ( cols[ "blue-max" ] < color.blue() )
934       cols[ "blue-max" ] = color.blue();
935     if ( cols[ "blue-min" ] > color.blue() )
936       cols[ "blue-min" ] = color.blue();
937   }
938   for (IList::Iterator it = mars.begin();  it != mars.end(); ++it)
939     MESSAGE("markers( " << it.key() << ") = " << it.data() );
940   for (IList::Iterator it = lins.begin();  it != lins.end(); ++it)
941     MESSAGE("lines( " << it.key() << ") = " << it.data() );
942   for (SList::Iterator it = cols.begin();  it != cols.end(); ++it)
943     MESSAGE("colors( " << it.key() << ") = " << it.data() );
944 #endif
945   
946   Plot2d_SetupViewDlg* dlg = new Plot2d_SetupViewDlg( this, true, mySecondY );
947   dlg->setMainTitle( myTitleEnabled, myTitle );
948   dlg->setXTitle( myXTitleEnabled, myXTitle );
949   dlg->setYTitle( myYTitleEnabled, myYTitle );
950   if (mySecondY)
951     dlg->setY2Title( myY2TitleEnabled, myY2Title );
952   dlg->setCurveType( myCurveType );
953   dlg->setLegend( myShowLegend, myLegendPos );
954   dlg->setMarkerSize( myMarkerSize );
955   dlg->setBackgroundColor( myBackground );
956   dlg->setScaleMode(myXMode, myYMode);
957   //
958   dlg->setMajorGrid( myXGridMajorEnabled, myPlot->axisMaxMajor( QwtPlot::xBottom ),
959          myYGridMajorEnabled, myPlot->axisMaxMajor( QwtPlot::yLeft ),
960          myY2GridMajorEnabled, myPlot->axisMaxMajor( QwtPlot::yRight ) );
961   dlg->setMinorGrid( myXGridMinorEnabled, myPlot->axisMaxMinor( QwtPlot::xBottom ),
962          myYGridMinorEnabled, myPlot->axisMaxMinor( QwtPlot::yLeft ),
963          myY2GridMinorEnabled, myPlot->axisMaxMinor( QwtPlot::yRight ) );
964   if ( dlg->exec() == QDialog::Accepted ) {
965     // horizontal axis title
966     setTitle( dlg->isXTitleEnabled(), dlg->getXTitle(), XTitle, false );
967     // vertical left axis title
968     setTitle( dlg->isYTitleEnabled(), dlg->getYTitle(), YTitle, false );
969     if (mySecondY) // vertical right axis title
970       setTitle( dlg->isY2TitleEnabled(), dlg->getY2Title(), Y2Title, false );
971
972     // main title
973     setTitle( dlg->isMainTitleEnabled(), dlg->getMainTitle(), MainTitle, true );
974     // curve type
975     if ( myCurveType != dlg->getCurveType() ) {
976       setCurveType( dlg->getCurveType(), false );
977     }
978     // legend
979     if ( myShowLegend != dlg->isLegendEnabled() ) {
980       showLegend( dlg->isLegendEnabled(), false );
981     }
982     if ( myLegendPos != dlg->getLegendPos() ) {
983       setLegendPos( dlg->getLegendPos() );
984     }
985     // marker size
986     if ( myMarkerSize != dlg->getMarkerSize() ) {
987       setMarkerSize( dlg->getMarkerSize(), false );
988     }
989     // background color
990     if ( myBackground != dlg->getBackgroundColor() ) {
991       setBackgroundColor( dlg->getBackgroundColor() );
992     }
993     // grid
994     bool aXGridMajorEnabled, aXGridMinorEnabled, aYGridMajorEnabled, aYGridMinorEnabled,
995          aY2GridMajorEnabled, aY2GridMinorEnabled;
996     int  aXGridMaxMajor, aXGridMaxMinor, aYGridMaxMajor, aYGridMaxMinor,
997          aY2GridMaxMajor, aY2GridMaxMinor;
998     dlg->getMajorGrid( aXGridMajorEnabled, aXGridMaxMajor, aYGridMajorEnabled, aYGridMaxMajor,
999                        aY2GridMajorEnabled, aY2GridMaxMajor);
1000     dlg->getMinorGrid( aXGridMinorEnabled, aXGridMaxMinor, aYGridMinorEnabled, aYGridMaxMinor,
1001                        aY2GridMinorEnabled, aY2GridMaxMinor);
1002     setXGrid( aXGridMajorEnabled, aXGridMaxMajor, aXGridMinorEnabled, aXGridMaxMinor, false );
1003     setYGrid( aYGridMajorEnabled, aYGridMaxMajor, aYGridMinorEnabled, aYGridMaxMinor,
1004               aY2GridMajorEnabled, aY2GridMaxMajor, aY2GridMinorEnabled, aY2GridMaxMinor, false );
1005     if ( myXMode != dlg->getXScaleMode() ) {
1006       setHorScaleMode( dlg->getXScaleMode() );
1007     }
1008     if ( myYMode != dlg->getYScaleMode() ) {
1009       setVerScaleMode( dlg->getYScaleMode() );
1010     }
1011     // update view
1012     myPlot->replot();
1013     // update preferences
1014     if ( dlg->isSetAsDefault() ) 
1015       writePreferences();
1016   }
1017   delete dlg;
1018 }
1019
1020 /*!
1021   "Fit Data" command slot
1022 */
1023 void Plot2d_ViewFrame::onFitData()
1024 {
1025   Plot2d_FitDataDlg* dlg = new Plot2d_FitDataDlg( this, mySecondY );
1026   double xMin,xMax,yMin,yMax,y2Min,y2Max;
1027   getFitRanges(xMin,xMax,yMin,yMax,y2Min,y2Max);
1028   
1029   dlg->setRange( xMin, xMax, yMin, yMax, y2Min, y2Max );
1030   if ( dlg->exec() == QDialog::Accepted ) {
1031     int mode = dlg->getRange( xMin, xMax, yMin, yMax, y2Min, y2Max );
1032     fitData(mode,xMin,xMax,yMin,yMax,y2Min,y2Max);
1033   }
1034   delete dlg;
1035 }
1036
1037 /*!
1038   Change background color
1039 */
1040 void Plot2d_ViewFrame::onChangeBackground()
1041 {
1042   QColor selColor = QColorDialog::getColor ( backgroundColor(), this ); 
1043   if ( selColor.isValid() ) {
1044     setBackgroundColor( selColor );
1045   }
1046 }
1047
1048 /*!
1049   Sets curve type
1050 */
1051 void Plot2d_ViewFrame::setCurveType( int curveType, bool update )
1052 {
1053   myCurveType = curveType;
1054   QArray<long> keys = myPlot->curveKeys();
1055   for ( int i = 0; i < (int)keys.count(); i++ ) {
1056     if ( myCurveType == 0 )
1057       myPlot->setCurveStyle( keys[i], QwtCurve::Dots );//QwtCurve::NoCurve
1058     else if ( myCurveType == 1 )
1059       myPlot->setCurveStyle( keys[i], QwtCurve::Lines );
1060     else if ( myCurveType == 2 )
1061       myPlot->setCurveStyle( keys[i], QwtCurve::Spline );
1062   }
1063   if ( update )
1064     myPlot->replot();
1065   emit vpCurveChanged();
1066 }
1067
1068 void Plot2d_ViewFrame::setCurveTitle( int curveKey, const QString& title ) 
1069
1070   if(myPlot) myPlot->setCurveTitle(curveKey, title); 
1071 }   
1072
1073 /*!
1074   Shows/hides legend
1075 */
1076 void Plot2d_ViewFrame::showLegend( bool show, bool update )
1077 {
1078   myShowLegend = show;
1079   myPlot->setAutoLegend( myShowLegend );
1080   myPlot->enableLegend( myShowLegend );
1081   if ( update )
1082     myPlot->replot();
1083 }
1084
1085 /*!
1086   Sets legend position : 0 - left, 1 - right, 2 - top, 3 - bottom
1087 */
1088 void Plot2d_ViewFrame::setLegendPos( int pos )
1089 {
1090   myLegendPos = pos;
1091   switch( pos ) {
1092   case 0:
1093     myPlot->setLegendPos( Qwt::Left );
1094     break;
1095   case 1:
1096     myPlot->setLegendPos( Qwt::Right );
1097     break;
1098   case 2:
1099     myPlot->setLegendPos( Qwt::Top );
1100     break;
1101   case 3:
1102     myPlot->setLegendPos( Qwt::Bottom );
1103     break;
1104   }
1105 }
1106
1107 /*!
1108   Sets new marker size
1109 */
1110 void Plot2d_ViewFrame::setMarkerSize( const int size, bool update )
1111 {
1112   if ( myMarkerSize != size )
1113   {
1114     myMarkerSize = size;
1115     QArray<long> keys = myPlot->curveKeys();
1116     for ( int i = 0; i < (int)keys.count(); i++ )
1117     {
1118       QwtPlotCurve* crv = myPlot->curve( keys[i] );
1119       if ( crv )
1120       {
1121         QwtSymbol aSymbol = crv->symbol();
1122         aSymbol.setSize( myMarkerSize, myMarkerSize );
1123         myPlot->setCurveSymbol( keys[i], aSymbol );
1124       }
1125     }
1126     if ( update )
1127       myPlot->replot();
1128   }
1129 }
1130
1131 /*!
1132   Sets background color
1133 */
1134 void Plot2d_ViewFrame::setBackgroundColor( const QColor& color )
1135 {
1136   myBackground = color;
1137   //myPlot->setCanvasBackground( myBackground );
1138   myPlot->canvas()->setPalette( myBackground );
1139   myPlot->setPalette( myBackground );
1140   QPalette aPal = myPlot->getLegend()->palette();
1141   for ( int i = 0; i < QPalette::NColorGroups; i++ ) {
1142     QPalette::ColorGroup cg = (QPalette::ColorGroup)i;
1143     aPal.setColor( cg, QColorGroup::Base, myBackground );
1144     aPal.setColor( cg, QColorGroup::Background, myBackground );
1145   }
1146   myPlot->getLegend()->setPalette( aPal );
1147   Repaint();
1148 }
1149 /*!
1150   Gets background color
1151 */
1152 QColor Plot2d_ViewFrame::backgroundColor() const
1153 {
1154   return myBackground;
1155 }
1156 /*!
1157   Sets hor.axis grid parameters
1158 */
1159 void Plot2d_ViewFrame::setXGrid( bool xMajorEnabled, const int xMajorMax, 
1160          bool xMinorEnabled, const int xMinorMax, 
1161          bool update )
1162 {
1163   if( xMinorMax>=xMajorMax )
1164     return;
1165
1166   myXGridMajorEnabled = xMajorEnabled;
1167   myXGridMinorEnabled = xMinorEnabled;
1168   myXGridMaxMajor = xMajorMax;
1169   myXGridMaxMinor = xMinorMax;
1170   myPlot->setAxisMaxMajor( QwtPlot::xBottom, myXGridMaxMajor );
1171   myPlot->setAxisMaxMinor( QwtPlot::xBottom, myXGridMaxMinor );
1172   myPlot->setGridXAxis(QwtPlot::xBottom);
1173   myPlot->enableGridX( myXGridMajorEnabled );
1174   myPlot->enableGridXMin( myXGridMinorEnabled );
1175   if ( update )
1176     myPlot->replot();
1177 }
1178 /*!
1179   Sets ver.axis grid parameters
1180 */
1181 void Plot2d_ViewFrame::setYGrid( bool yMajorEnabled, const int yMajorMax, 
1182                                  bool yMinorEnabled, const int yMinorMax,
1183                                  bool y2MajorEnabled, const int y2MajorMax, 
1184                                  bool y2MinorEnabled, const int y2MinorMax, 
1185                                  bool update )
1186 {
1187   myYGridMajorEnabled = yMajorEnabled;
1188   myYGridMinorEnabled = yMinorEnabled;
1189   myYGridMaxMajor = yMajorMax;
1190   myYGridMaxMinor = yMinorMax;
1191
1192   if (mySecondY) {
1193     myY2GridMajorEnabled = y2MajorEnabled;
1194     myY2GridMinorEnabled = y2MinorEnabled;
1195     myY2GridMaxMajor = y2MajorMax;
1196     myY2GridMaxMinor = y2MinorMax;
1197   }
1198   myPlot->setAxisMaxMajor( QwtPlot::yLeft, myYGridMaxMajor );
1199   myPlot->setAxisMaxMinor( QwtPlot::yLeft, myYGridMaxMinor );
1200
1201   if (mySecondY) {
1202     myPlot->setAxisMaxMajor( QwtPlot::yRight, myY2GridMaxMajor );
1203     myPlot->setAxisMaxMinor( QwtPlot::yRight, myY2GridMaxMinor );
1204   }
1205
1206   myPlot->setGridYAxis(QwtPlot::yLeft);
1207
1208   if (mySecondY) {
1209     if (myYGridMajorEnabled) {
1210       myPlot->enableGridYMin(myYGridMinorEnabled);
1211       myPlot->enableGridY( myYGridMajorEnabled);
1212     }
1213     else if (myY2GridMajorEnabled) {
1214       myPlot->setGridYAxis(QwtPlot::yRight);
1215       myPlot->enableGridYMin(myY2GridMinorEnabled);
1216       myPlot->enableGridY(myY2GridMajorEnabled);
1217     }
1218     else {
1219       myPlot->enableGridYMin(false);
1220       myPlot->enableGridY(false);
1221     }
1222   }
1223   else {
1224     myPlot->enableGridY( myYGridMajorEnabled );
1225     myPlot->enableGridYMin( myYGridMinorEnabled );
1226   }
1227   if ( update )
1228     myPlot->replot();
1229 }
1230
1231 /*!
1232   Sets title for some axis
1233 */
1234 void Plot2d_ViewFrame::setTitle( bool enabled, const QString& title,
1235                                  ObjectType type, bool update )
1236 {
1237   switch (type) {
1238     case MainTitle:
1239       myTitleEnabled = enabled;
1240       myTitle = title;
1241       myPlot->setTitle( myTitleEnabled ? myTitle : QString::null );
1242       break;
1243     case XTitle:
1244       myXTitleEnabled = enabled;
1245       myXTitle = title;
1246       myPlot->setAxisTitle( QwtPlot::xBottom, myXTitleEnabled ? myXTitle : QString::null );
1247       break;
1248     case YTitle:
1249       myYTitleEnabled = enabled;
1250       myYTitle = title;
1251       myPlot->setAxisTitle( QwtPlot::yLeft, myYTitleEnabled ? myYTitle : QString::null );
1252       break;
1253     case Y2Title:
1254       myY2TitleEnabled = enabled;
1255       myY2Title = title;
1256       myPlot->setAxisTitle( QwtPlot::yRight, myY2TitleEnabled ? myY2Title : QString::null );
1257       break;
1258   }
1259   if ( update )
1260     myPlot->replot();
1261 }
1262 /*!
1263   Sets title for some axis
1264 */
1265 QString Plot2d_ViewFrame::getTitle( ObjectType type ) const
1266 {
1267   QString title = "";
1268   switch (type) {
1269     case MainTitle:
1270       title = myTitle;   break;
1271     case XTitle:
1272       title = myXTitle;  break;
1273     case YTitle:
1274       title = myYTitle;  break;
1275     case Y2Title:
1276       title = myY2Title; break;
1277   }
1278   return title;
1279 }
1280 /*!
1281   Sets font for Plot2d object : title or axis
1282 */
1283 void Plot2d_ViewFrame::setFont( const QFont& font, ObjectType type, bool update)
1284 {
1285   switch (type) {
1286     case MainTitle:
1287       myPlot->setTitleFont(font);
1288       break;
1289     case XTitle:
1290       myPlot->setAxisTitleFont(QwtPlot::xBottom, font); break;
1291     case YTitle:
1292       myPlot->setAxisTitleFont(QwtPlot::yLeft, font);   break;
1293     case Y2Title:
1294       myPlot->setAxisTitleFont(QwtPlot::yRight, font);  break;
1295     case XAxis:
1296       myPlot->setAxisFont(QwtPlot::xBottom, font);      break;
1297     case YAxis:
1298       myPlot->setAxisFont(QwtPlot::yLeft, font);        break;
1299     case Y2Axis:
1300       myPlot->setAxisFont(QwtPlot::yRight, font);       break;
1301   }
1302   if ( update )
1303     myPlot->replot();
1304 }
1305 /*!
1306   Sets scale mode for horizontal axis: 0 - linear, 1 - logarithmic
1307 */
1308 void Plot2d_ViewFrame::setHorScaleMode( const int mode, bool update )
1309 {
1310   myXMode = mode;
1311   if ( myXMode == 0 ) // linear
1312     myPlot->changeAxisOptions( QwtPlot::xBottom, QwtAutoScale::Logarithmic, false );
1313   else                // logarithmic
1314     myPlot->changeAxisOptions( QwtPlot::xBottom, QwtAutoScale::Logarithmic, true );
1315
1316   if ( update )
1317     fitAll();
1318   emit vpModeHorChanged();
1319 }
1320 /*!
1321   Sets scale mode for vertical axis: 0 - linear, 1 - logarithmic
1322 */
1323 void Plot2d_ViewFrame::setVerScaleMode( const int mode, bool update )
1324 {
1325   myYMode = mode;
1326   if ( myYMode == 0 ) { // linear
1327     myPlot->changeAxisOptions( QwtPlot::yLeft, QwtAutoScale::Logarithmic, false );
1328     if (mySecondY)
1329       myPlot->changeAxisOptions( QwtPlot::yRight, QwtAutoScale::Logarithmic, false );
1330   }
1331   else {               // logarithmic
1332     myPlot->changeAxisOptions( QwtPlot::yLeft, QwtAutoScale::Logarithmic, true );
1333     if (mySecondY)
1334       myPlot->changeAxisOptions( QwtPlot::yRight, QwtAutoScale::Logarithmic, true );
1335   }
1336   if ( update )
1337     fitAll();
1338   emit vpModeVerChanged();
1339 }
1340
1341 /*!
1342   Return, scale mode for horizontal axis
1343 */
1344 bool Plot2d_ViewFrame::isModeHorLinear()
1345 {
1346   return (myXMode == 0 ? true : false);
1347 }
1348
1349 /*!
1350   Return, scale mode for vertical axis
1351 */
1352 bool Plot2d_ViewFrame::isModeVerLinear()
1353 {
1354   return (myYMode == 0 ? true : false);
1355 }
1356 /*!
1357   Slot, called when user presses mouse button
1358 */
1359 void Plot2d_ViewFrame::plotMousePressed(const QMouseEvent& me )
1360 {
1361   ((Plot2d_ViewWindow*)parent())->putInfo(getInfo(me.pos()));
1362   if ( myOperation == NoOpId )
1363     myOperation = testOperation( me );
1364   if ( myOperation != NoOpId ) {
1365     myPnt = me.pos();
1366     if ( myOperation == FitAreaId ) {
1367       myPlot->setOutlineStyle( Qwt::Rect );
1368     }
1369     else if ( myOperation == GlPanId ) {
1370       myPlot->setAxisScale( QwtPlot::yLeft,
1371           myPlot->invTransform( QwtPlot::yLeft, myPnt.y() ) + myYDistance/2, 
1372           myPlot->invTransform( QwtPlot::yLeft, myPnt.y() ) - myYDistance/2 );
1373       myPlot->setAxisScale( QwtPlot::xBottom, 
1374           myPlot->invTransform( QwtPlot::xBottom, myPnt.x() ) - myXDistance/2, 
1375           myPlot->invTransform( QwtPlot::xBottom, myPnt.x() ) + myXDistance/2 );
1376       if (mySecondY)
1377         myPlot->setAxisScale( QwtPlot::yRight,
1378           myPlot->invTransform( QwtPlot::yRight, myPnt.y() ) + myYDistance2/2, 
1379           myPlot->invTransform( QwtPlot::yRight, myPnt.y() ) - myYDistance2/2 );
1380       myPlot->replot();
1381     }
1382   }
1383   else {
1384     int btn = me.button() | me.state();
1385     if (btn == RightButton) {
1386       QMouseEvent* aEvent = new QMouseEvent(QEvent::MouseButtonPress,
1387                                             me.pos(), btn, me.state());
1388       // QMouseEvent 'me' has the 'MouseButtonDblClick' type. In this case we create new event 'aEvent'.
1389       parent()->eventFilter(this, aEvent);
1390     }
1391   }
1392 }
1393 /*!
1394   Slot, called when user moves mouse
1395 */
1396 void Plot2d_ViewFrame::plotMouseMoved( const QMouseEvent& me )
1397 {
1398   int    dx = me.pos().x() - myPnt.x();
1399   int    dy = me.pos().y() - myPnt.y();
1400
1401   if ( myOperation != NoOpId) {
1402     if ( myOperation == ZoomId ) {
1403       QwtDiMap xMap = myPlot->canvasMap( QwtPlot::xBottom );
1404       QwtDiMap yMap = myPlot->canvasMap( QwtPlot::yLeft );
1405
1406       myPlot->setAxisScale( QwtPlot::yLeft, 
1407           myPlot->invTransform( QwtPlot::yLeft, yMap.i1() ), 
1408           myPlot->invTransform( QwtPlot::yLeft, yMap.i2() + dy ) );
1409       myPlot->setAxisScale( QwtPlot::xBottom, 
1410           myPlot->invTransform( QwtPlot::xBottom, xMap.i1() ), 
1411           myPlot->invTransform( QwtPlot::xBottom, xMap.i2() - dx ) );
1412       if (mySecondY) {
1413         QwtDiMap y2Map = myPlot->canvasMap( QwtPlot::yRight );
1414         myPlot->setAxisScale( QwtPlot::yRight, 
1415           myPlot->invTransform( QwtPlot::yRight, y2Map.i1() ), 
1416           myPlot->invTransform( QwtPlot::yRight, y2Map.i2() + dy ) );
1417       }
1418       myPlot->replot();
1419       myPnt = me.pos();
1420     }
1421     else if ( myOperation == PanId ) {
1422       QwtDiMap xMap = myPlot->canvasMap( QwtPlot::xBottom );
1423       QwtDiMap yMap = myPlot->canvasMap( QwtPlot::yLeft );
1424
1425       myPlot->setAxisScale( QwtPlot::yLeft, 
1426           myPlot->invTransform( QwtPlot::yLeft, yMap.i1()-dy ), 
1427           myPlot->invTransform( QwtPlot::yLeft, yMap.i2()-dy ) );
1428       myPlot->setAxisScale( QwtPlot::xBottom, 
1429           myPlot->invTransform( QwtPlot::xBottom, xMap.i1()-dx ),
1430           myPlot->invTransform( QwtPlot::xBottom, xMap.i2()-dx ) ); 
1431       if (mySecondY) {
1432         QwtDiMap y2Map = myPlot->canvasMap( QwtPlot::yRight );
1433         myPlot->setAxisScale( QwtPlot::yRight,
1434           myPlot->invTransform( QwtPlot::yRight, y2Map.i1()-dy ), 
1435           myPlot->invTransform( QwtPlot::yRight, y2Map.i2()-dy ) );
1436       }
1437       myPlot->replot();
1438       myPnt = me.pos();
1439     }
1440   }
1441   else {
1442     ((Plot2d_ViewWindow*)parent())->putInfo(getInfo(me.pos()));
1443   }
1444 }
1445 /*!
1446   Slot, called when user releases mouse
1447 */
1448 void Plot2d_ViewFrame::plotMouseReleased( const QMouseEvent& me )
1449 {
1450   if ( myOperation == NoOpId && me.button() == RightButton )
1451   {
1452     QContextMenuEvent aEvent( QContextMenuEvent::Mouse,
1453                               me.pos(), me.globalPos(),
1454                               me.state() );
1455     emit contextMenuRequested( &aEvent );
1456   }
1457   if ( myOperation == FitAreaId ) {
1458     QRect rect( myPnt, me.pos() );
1459     fitArea( rect );
1460   }
1461   myPlot->canvas()->setCursor( QCursor( Qt::CrossCursor ) );
1462   myPlot->setOutlineStyle( Qwt::Triangle );
1463
1464   ((Plot2d_ViewWindow*)parent())->putInfo(tr("INF_READY"));
1465   myOperation = NoOpId;
1466 }
1467 /*!
1468   Slot, called when user wheeling mouse
1469 */
1470 void Plot2d_ViewFrame::wheelEvent(QWheelEvent* event)
1471
1472   double aDelta = event->delta();
1473   double aScale = (aDelta < 0) ? 100./(-aDelta) : aDelta/100.; 
1474
1475   QwtDiMap xMap = myPlot->canvasMap( QwtPlot::xBottom );
1476   QwtDiMap yMap = myPlot->canvasMap( QwtPlot::yLeft );
1477
1478   myPlot->setAxisScale( QwtPlot::yLeft,
1479     myPlot->invTransform( QwtPlot::yLeft, yMap.i1() ), 
1480     myPlot->invTransform( QwtPlot::yLeft, yMap.i2() )*aScale );
1481   myPlot->setAxisScale( QwtPlot::xBottom, 
1482     myPlot->invTransform( QwtPlot::xBottom, xMap.i1() ),
1483     myPlot->invTransform( QwtPlot::xBottom, xMap.i2() )*aScale );
1484   if (mySecondY) {
1485     QwtDiMap y2Map = myPlot->canvasMap( QwtPlot::yRight );
1486     myPlot->setAxisScale( QwtPlot::yRight,
1487       myPlot->invTransform( QwtPlot::yRight, y2Map.i1() ), 
1488       myPlot->invTransform( QwtPlot::yRight, y2Map.i2() )*aScale );
1489   }
1490   myPlot->replot();
1491   myPnt = event->pos();
1492 }
1493 /*!
1494   View operations : Pan view
1495 */
1496 void Plot2d_ViewFrame::onViewPan()
1497
1498   myPlot->canvas()->setCursor( panCursor );
1499   myOperation = PanId;
1500   qApp->installEventFilter( this );
1501 }
1502 /*!
1503   View operations : Zoom view
1504 */
1505 void Plot2d_ViewFrame::onViewZoom() 
1506 {
1507   myPlot->canvas()->setCursor( zoomCursor );
1508   myOperation = ZoomId;
1509   qApp->installEventFilter( this );
1510 }
1511 /*!
1512   View operations : Fot All
1513 */
1514 void Plot2d_ViewFrame::onViewFitAll() 
1515
1516   fitAll();
1517 }
1518 /*!
1519   View operations : Fit Area
1520 */
1521 void Plot2d_ViewFrame::onViewFitArea() 
1522 {
1523   myPlot->canvas()->setCursor( QCursor( Qt::PointingHandCursor ) );
1524   myOperation = FitAreaId;
1525   qApp->installEventFilter( this );
1526 }
1527 /*!
1528   View operations : Global panning
1529 */
1530 void Plot2d_ViewFrame::onViewGlobalPan() 
1531 {
1532   myPlot->canvas()->setCursor( glPanCursor );
1533   myPlot->changeAxisOptions( QwtPlot::xBottom, QwtAutoScale::Logarithmic, false );
1534   myPlot->changeAxisOptions( QwtPlot::yLeft, QwtAutoScale::Logarithmic, false );
1535   if (mySecondY)
1536     myPlot->changeAxisOptions( QwtPlot::yRight, QwtAutoScale::Logarithmic, false );
1537   myPlot->replot();
1538   QwtDiMap xMap = myPlot->canvasMap( QwtPlot::xBottom );
1539   QwtDiMap yMap = myPlot->canvasMap( QwtPlot::yLeft );
1540
1541   myXDistance = xMap.d2() - xMap.d1();
1542   myYDistance = yMap.d2() - yMap.d1();
1543
1544   if (mySecondY) {
1545     QwtDiMap yMap2 = myPlot->canvasMap( QwtPlot::yRight );
1546     myYDistance2 = yMap2.d2() - yMap2.d1();
1547   }
1548   fitAll();
1549   myOperation = GlPanId;
1550   qApp->installEventFilter( this );
1551 }
1552
1553 //=================================================================================
1554 // Plot2d_Plot2d implementation
1555 //=================================================================================
1556 /*!
1557   Constructor
1558 */
1559 Plot2d_Plot2d::Plot2d_Plot2d( QWidget* parent )
1560      : QwtPlot( parent )
1561 {
1562   // outline
1563   enableOutline( true );
1564   setOutlineStyle( Qwt::Triangle );
1565   setOutlinePen( green );
1566   // legend
1567   setAutoLegend( false );
1568   setLegendFrameStyle( QFrame::Box | QFrame::Sunken );
1569   enableLegend( false );
1570   // grid
1571   enableGridX( false );
1572   enableGridXMin( false );
1573   enableGridY( false );
1574   enableGridYMin( false );
1575   // auto scaling by default
1576   setAxisAutoScale( QwtPlot::yLeft );
1577   setAxisAutoScale( QwtPlot::yRight );
1578   setAxisAutoScale( QwtPlot::xBottom );
1579 }
1580 /*!
1581   Recalculates and redraws Plot 2d view 
1582 */
1583 void Plot2d_Plot2d::replot()
1584 {
1585   updateLayout();  // to fix bug(?) of Qwt - view is not updated when title is changed
1586   QwtPlot::replot(); 
1587 }
1588
1589 /*!
1590   Checks if two colors are close to each other [ static ]
1591   uses COLOR_DISTANCE variable as max tolerance for comparing of colors
1592 */
1593 const long COLOR_DISTANCE = 100;
1594 const int  MAX_ATTEMPTS   = 10;
1595 static bool closeColors( const QColor& color1, const QColor& color2 )
1596 {
1597   long tol = abs( color2.red()   - color1.red() ) + 
1598              abs( color2.green() - color1.green() ) +
1599        abs( color2.blue()  - color1.blue() );
1600
1601   return ( tol <= COLOR_DISTANCE );
1602 }
1603 /*!
1604   Gets new unique marker for item if possible
1605 */
1606 void Plot2d_Plot2d::getNextMarker( QwtSymbol::Style& typeMarker, QColor& color, Qt::PenStyle& typeLine ) 
1607 {
1608   bool bOk = false;
1609   int cnt = 1;
1610   while ( !bOk ) {
1611     int aRed    = (int)( 256.0 * rand() / RAND_MAX);    // generate random color
1612     int aGreen  = (int)( 256.0 * rand() / RAND_MAX);    // ...
1613     int aBlue   = (int)( 256.0 * rand() / RAND_MAX);    // ...
1614     int aMarker = (int)( 9.0 * rand() / RAND_MAX) + 1;  // 9 markers types ( not including empty )
1615     int aLine   = (int)( 5.0 * rand() / RAND_MAX) + 1;  // 5 line types ( not including empty )
1616
1617     typeMarker = ( QwtSymbol::Style )aMarker;
1618     color      = QColor( aRed, aGreen, aBlue );
1619     typeLine   = ( Qt::PenStyle )aLine;
1620
1621     cnt++;
1622     if ( cnt == MAX_ATTEMPTS )
1623       bOk = true;
1624     else
1625       bOk = !existMarker( typeMarker, color, typeLine );
1626   }
1627 /*
1628   static int aMarker = -1;
1629   static int aColor  = -1;
1630   static int aLine   = -1;
1631
1632   if ( myColors.isEmpty() ) {
1633     // creating colors list
1634     myColors.append( Qt::white );
1635     myColors.append( Qt::blue );
1636     myColors.append( Qt::gray );
1637     myColors.append( Qt::darkGreen );
1638     myColors.append( Qt::magenta );
1639     myColors.append( Qt::darkGray );
1640     myColors.append( Qt::red );
1641     myColors.append( Qt::darkBlue );
1642     myColors.append( Qt::darkYellow );
1643     myColors.append( Qt::cyan );
1644     myColors.append( Qt::darkRed );
1645     myColors.append( Qt::darkCyan );
1646     myColors.append( Qt::yellow );
1647     myColors.append( Qt::darkMagenta );
1648     myColors.append( Qt::green );
1649     myColors.append( Qt::black );
1650   }
1651
1652   int nbMarkers = 11;                   // QwtSymbol supports 11 marker types
1653   int nbLines   = 6;                    // Qt supports 6 line types
1654   int nbColors  = myColors.count();     // number of default colors supported
1655
1656   aMarker = ( aMarker + 1 ) % nbMarkers;  
1657   if ( aMarker == QwtSymbol::None || aMarker == QwtSymbol::Triangle ) aMarker++;
1658   aColor  = ( aColor  + 1 ) % nbColors;
1659   aLine   = ( aLine   + 1 ) % nbLines;    
1660   if ( aLine == Qt::NoPen ) aLine++;             
1661
1662   typeMarker = ( QwtSymbol::Style )aMarker;
1663   color      = myColors[ aColor ];
1664   typeLine   = ( Qt::PenStyle )aLine;
1665   if ( !existMarker( typeMarker, color, typeLine ) )
1666     return;
1667
1668   int i, j, k;
1669   for ( i = 0; i < nbMarkers; i++ ) {
1670     aMarker = ( aMarker + 1 ) % nbMarkers;
1671     if ( aMarker == QwtSymbol::None || aMarker == QwtSymbol::Triangle ) aMarker++;
1672     for ( j = 0; j < nbColors; j++ ) {
1673       aColor  = ( aColor  + 1 ) % nbColors;
1674       for ( k = 0; k < nbLines; k++ ) {
1675         aLine = ( aLine + 1 ) % nbLines;
1676   if ( aLine == Qt::NoPen ) aLine++;             
1677         if ( !existMarker( ( QwtSymbol::Style )aMarker, aColor, ( Qt::PenStyle )aLine ) ) {
1678           typeMarker = ( QwtSymbol::Style )aMarker;
1679           color      = myColors[ aColor ];
1680           typeLine   = ( Qt::PenStyle )aLine;
1681           return;
1682         }
1683       }
1684     }
1685   }
1686 */
1687 }
1688
1689 QSizePolicy Plot2d_Plot2d::sizePolicy() const
1690 {
1691   return QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
1692 }
1693
1694 QSize Plot2d_Plot2d::sizeHint() const
1695 {
1696   return QwtPlot::minimumSizeHint();
1697 }
1698
1699 /*!
1700   return minimum size for qwt plot
1701 */
1702 QSize Plot2d_Plot2d::minimumSizeHint() const
1703 {
1704   return QSize( 0, 0 );
1705 //  QSize aSize = QwtPlot::minimumSizeHint();
1706 //  return QSize(aSize.width()*3/4, aSize.height());
1707 }
1708 /*!
1709   Checks if marker belongs to any enitity
1710 */
1711 bool Plot2d_Plot2d::existMarker( const QwtSymbol::Style typeMarker, const QColor& color, const Qt::PenStyle typeLine ) 
1712 {
1713   // getting all curves
1714   QArray<long> keys = curveKeys();
1715   //QColor aRgbColor;
1716
1717   if ( closeColors( color, backgroundColor() ) )
1718       return true;
1719   for ( int i = 0; i < (int)keys.count(); i++ )
1720   {
1721     QwtPlotCurve* crv = curve( keys[i] );
1722     if ( crv ) {
1723       QwtSymbol::Style aStyle = crv->symbol().style();
1724       QColor           aColor = crv->pen().color();
1725       Qt::PenStyle     aLine  = crv->pen().style();
1726 //      if ( aStyle == typeMarker && aColor == color && aLine == typeLine )
1727       if ( aStyle == typeMarker && closeColors( aColor,color ) && aLine == typeLine )
1728   return true;
1729     }
1730   }
1731   return false;
1732 }
1733
1734 // TEMPORARY SOLUTION!!!  TO BE IMPLEMENTED!!!
1735 Plot2d_Prs* Plot2d_ViewFrame::CreatePrs( const char* /*entry*/ )
1736 {
1737   return 0;
1738 }
1739
1740 void Plot2d_ViewFrame::copyPreferences( Plot2d_ViewFrame* vf )
1741 {
1742   if( !vf )
1743     return;
1744
1745   myCurveType = vf->myCurveType;
1746   myShowLegend = vf->myShowLegend;
1747   myLegendPos = vf->myLegendPos;
1748   myMarkerSize = vf->myMarkerSize;
1749   myBackground = vf->myBackground;
1750   myTitle = vf->myTitle; 
1751   myXTitle = vf->myXTitle;
1752   myYTitle = vf->myYTitle;
1753   myY2Title = vf->myY2Title;
1754   myTitleEnabled = vf->myTitleEnabled;
1755   myXTitleEnabled = vf->myXTitleEnabled;
1756   myYTitleEnabled = vf->myYTitleEnabled;
1757   myY2TitleEnabled = vf->myY2TitleEnabled;
1758   myXGridMajorEnabled = vf->myXGridMajorEnabled;
1759   myYGridMajorEnabled = vf->myYGridMajorEnabled;
1760   myY2GridMajorEnabled = vf->myY2GridMajorEnabled;
1761   myXGridMinorEnabled = vf->myXGridMinorEnabled;
1762   myYGridMinorEnabled = vf->myYGridMinorEnabled;
1763   myY2GridMinorEnabled = vf->myY2GridMinorEnabled;
1764   myXGridMaxMajor = vf->myXGridMaxMajor;
1765   myYGridMaxMajor = vf->myYGridMaxMajor;
1766   myY2GridMaxMajor = vf->myY2GridMaxMajor;
1767   myXGridMaxMinor = vf->myXGridMaxMinor;
1768   myYGridMaxMinor = vf->myYGridMaxMinor;
1769   myY2GridMaxMinor = vf->myY2GridMaxMinor;
1770   myXMode = vf->myXMode;
1771   myYMode = vf->myYMode;
1772   mySecondY = vf->mySecondY;
1773 }