Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Examples  

qsplotview.h

00001 /***************************************************************************
00002                                 qsplotview.h                              
00003                              -------------------                                         
00004     begin                : 01-January-2000
00005     copyright            : (C) 2000 by Kamil Dobkowski                         
00006     email                : kamildobk@poczta.onet.pl                                     
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   * 
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 
00019 #ifndef QSPLOTVIEW_H
00020 #define QSPLOTVIEW_H
00021 
00022 #include "qscoord.h"
00023 #include "qsaxes.h"
00024 #include "qsaxis.h"
00025 #include "qsctool.h"
00026 #include "qsworkbook.h"
00027 #include <qdatetime.h>
00028 #include <qcstring.h>
00029 #include <qwidget.h>
00030 #include <qscrollbar.h>
00031 #include <qintdict.h>
00032 #include <qlist.h>
00033 
00034 class QTimer;
00035 class QPixmap;
00036 class QSRuler;
00037 class QSRangeScrollBar;
00038 class QPushButton;
00039 class QTabBar;
00040 class QPopupMenu;
00041 class QScrollBar;
00042 class QGridLayout;
00043 class QEvent;
00044 class QSlider;
00045 class QSPlotView;
00046 
00055 class QSSelection : public QSCObjectCollection
00056  {
00057     friend QSPlotView;
00058     Q_OBJECT
00059   public:
00063     QSSelection( QObject *parent=NULL );
00067     virtual ~QSSelection();
00071     QSCObjectCollection *collection() const { return m_curr_collection; }
00075     QSCObjectCollection *rootCollection() const { return m_root_collection; }
00079     void set( QSCObject *object );
00083     void turn( QSCObject *object );
00087     virtual void insert( int position, QSCObject *object );
00091     virtual void remove( int index );
00092 
00093 
00094   private:
00095     QSWorkbook *m_workbook;
00096     QSCObjectCollection *m_curr_collection;
00097     QSCObjectCollection *m_root_collection;
00098     void set_workbook( QSWorkbook *workbook );
00099         void set_collection( QSCObject *object );
00100 
00101   private slots:
00102     void slot_object_removed(QSCObjectCollection*,QSCObject*);
00103         void slot_page_removed( QSPage *page );
00104  };
00105 
00106 //-----------------------------------------------------------------//
00107 
00117 class QSPlotView : public QWidget  {
00118      Q_OBJECT
00119    public:
00123        enum ScrollBarType { HorizontalBar = 0, VerticalBar = 1 };
00127        enum SliderType { HorizontalSlider = 0, VerticalSlider = 1, AdditionalSlider = 2 };
00131        QSPlotView(QWidget *parent=0, const char *name=0);
00135        virtual ~QSPlotView();
00139        void setWorkbook( QSWorkbook *workbook );
00143        QSWorkbook *workbook() const { return m_workbook; }
00147     QSPage *currentPage() const { return m_curr_page; }
00151     QSSelection *selection() const { return m_selection; }
00155     void setPixmapBuffering( bool enabled );
00159     bool pixmapBuffering() const { return m_screen_buffering; }
00163         void setTool( QSTool *t );
00167         void setFullPage( bool enabled );
00171         void setZoom( double zoom );
00175         void setGridSpacing( int x_mm, int y_mm );
00179         void setGridVisible( bool visible );
00183         void setRulersVisible( bool visible );
00187         void setSlidersVisible( bool visible );
00191         void setPageMarginsVisible( bool visible );
00197        QSCObject *activeObject() const { return m_active_object; }
00201        QSAxes *activeAxes() const { return m_active_axes; }
00206     QSCObjectCollection *activeCollection() const;
00210        int gridSpacingX() const { return m_grid_x; }
00214        int gridSpacingY() const { return m_grid_y; }
00218        bool gridVisible() const { return m_grid_visible; }  
00222        bool rulersVisible() const { return m_rulers_visible; }
00226        bool slidersVisible() const { return m_sliders_visible; }
00230        bool pageMarginsVisible() const { return m_page_margins_visible; }           
00234        bool fullPage() const { return m_full_page; }
00238        double zoom() const { return m_zoom; }
00242        double dpi() const { return m_full_page ? m_zoom * 72.0 : 72.0; }
00250        void bindScrollBar( ScrollBarType t, QSAxis::AxisType axisType );
00255        void bindSlider( SliderType t, const char *property, int min, int max );
00259        QSAxis::AxisType scrollBarAxis( ScrollBarType t ) const { return m_scrollbars[t].type; }
00263        QCString sliderProperty( SliderType t ) const { return m_sliders[t].property; }
00267        int sliderMin( SliderType t ) const { return m_sliders[t].min; }
00271        int sliderMax( SliderType t ) const { return m_sliders[t].max; }
00275        QSTool *tool() const { return m_ctool; }
00279        QWidget *canvasWidget() const { return m_canvas; }
00284        QSCObject *objectAt( const QPoint& pos, bool recursive = true );
00288        void showUserMessage( const QString& msg );
00292        bool eventFilter( QObject *, QEvent* );
00293 
00294   public slots:
00298     void setCurrentPage( int index );
00303        void updateCanvas();
00304 
00305   signals:
00309         void message( const QString& msg );
00313         void sigActiveObjectChanged();
00318         void sigActiveAxesChanged();
00322         void sigActiveAxesDatasetsChanged();
00326     void sigCurrentPageChanged();
00330     void sigCurrentPageTitleChanged( const QString& newTitle );
00334     void sigCurrentPageObjectListChanged();
00338     void sigPageBarClicked();
00342     void sigSliderPressed();
00346     void sigSliderReleased();
00350     void sigScrollBarPressed();
00354     void sigScrollBarReleased();
00355 
00356    private:
00357     QSWorkbook  *m_workbook;
00358     QSPage      *m_curr_page;
00359     QSSelection *m_selection;   
00360     bool        m_full_page;
00361     QSAxes      *m_active_axes;
00362     QGridLayout *m_layout;
00363     QWidget     *m_canvas;
00364     QWidget     *m_shadow;
00365     QWidget     *m_interior;
00366     QSTool      *m_ctool;
00367     bool        m_tool_activated;
00368     bool        m_tool_activating;
00369     QSCObject   *m_active_object;
00370     double      m_zoom;
00371     int     m_grid_x;
00372     int     m_grid_y;
00373     bool        m_grid_visible;
00374     bool        m_page_margins_visible;
00375     bool        m_screen_buffering;
00376     bool        m_screen_buffer_valid;
00377     QPixmap     *m_screen_buffer;
00378     QTimer      *m_refresh_buffer;
00379         QTime       m_perf_monitor;
00380 
00381     bool m_rulers_visible;
00382     QSRuler *m_hruler;
00383     QSRuler *m_vruler;
00384 
00385     bool m_sliders_visible;
00386     QScrollBar *m_hscrollbar;
00387     QScrollBar *m_vscrollbar;
00388 
00389     QTabBar     *m_page_list;
00390     QIntDict<QSPage> m_pages;
00391 
00392        struct slider_data_t {
00393         QSlider *slider;
00394         int min;
00395         int max;
00396         QCString property;
00397         } m_sliders[3];
00398 
00399     struct scrollbar_data_t {
00400         QSRangeScrollBar *scrollbar;
00401         QSAxis::AxisType type;
00402         } m_scrollbars[2];
00403 
00404        void set_backstore_internal( bool enabled );
00405        bool backstore_internal();
00406        void recreate_gui();
00407        void recreate_rulers();
00408        void recreate_parameter_scrollbars();
00409        void recreate_parameter_sliders();
00410        void recreate_canvas_scrollbars();
00411        void recreate_page_bar();
00412 
00413        void update_rulers();
00414        void update_parameter_scrollbars();
00415        void update_parameter_sliders();
00416        void update_canvas_scrollbars();
00417        void update_page_bar();
00418 
00419         void init();
00420         void clean();
00421         void activate_tool();
00422         void deactivate_tool();
00423         void set_active_object( QSCObject *o, bool tool = false );
00424         void set_active_axes( QSAxes *axes );
00425         void draw_tool();
00426         void draw_page();
00427         void draw_grid( QPainter *p );
00428     void draw_full_page( QPaintDevice *paint_device );
00429     void draw_single_view( QPaintDevice *paint_device );
00430     void show_page_popup();
00431 
00432     bool confirm( const QString& message );
00433 
00434      private slots:
00435        void slot_selection_changed();
00436        void adjust_canvas_size();
00437        void slot_page_removed( QSPage *page );
00438        void slot_page_added( QSPage *page );
00439        void slot_page_order();
00440        void slot_curr_page_object_list_changed();
00441        void slot_page_tab_selected(int);
00442        void slot_active_axes_modified();    
00443        void slot_active_axes_ranges_changed();
00444        void slot_active_axes_changed(QSData*);
00445        void slot_active_axes_order();
00446        void slot_update_canvas_pos(int);
00447        void slot_object_removed( QSCObject *object );
00448        void slot_hslider_moved( int );
00449        void slot_vslider_moved( int );
00450        void slot_aslider_moved( int );
00451        void slot_slider_pressed();
00452        void slot_slider_released();
00453        void slot_scrollbar_pressed();
00454        void slot_scrollbar_released();
00455        void slot_hscrollbar_moved( int );
00456        void slot_vscrollbar_moved( int );
00457        void slot_page_list_changed();
00458        void slot_refresh_screen_buffer();
00459     void slot_page_draw_ends();
00460     void slot_axes_draw_ends();
00461     void slot_curr_page_title_changed( const QString& new_title );
00462   };
00463 
00464 //-------------------------------------------------------------//
00465 
00466 class QSRangeScrollBar : public QScrollBar
00467  {
00468   Q_OBJECT
00469   public:
00470     QSRangeScrollBar( QWidget *parent );
00471     virtual ~QSRangeScrollBar();
00472     void setAxes( QSAxes *axes, QSAxis::AxisType type );
00473     void updateScrollbar();
00474     void updateRange();
00475    private:
00476     QSAxes *m_axes;
00477     QSAxis::AxisType m_type;
00478     bool m_updating_range;
00479     bool m_updating_scrollbars;
00480     double m_min;
00481     double m_max;       
00482  };
00483 
00484 
00485 
00486 
00487 
00488 
00489 
00490 
00491 #endif
00492 

Generated on Mon Mar 18 19:16:33 2002 for KMatplot library by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002