00001
00002
00003 #ifndef MAINWIN_H
00004 #define MAINWIN_H
00005
00006 #include <qstring.h>
00007 #include <qfont.h>
00008 #include <qlistbox.h>
00009 #include <qworkspace.h>
00010 #include <qtoolbutton.h>
00011 #include <qsignalmapper.h>
00012 #include <qdragobject.h>
00013 #include <qtimer.h>
00014 #include <kapp.h>
00015 #include <kmainwindow.h>
00016 #include <kparts/mainwindow.h>
00017 #include <kaction.h>
00018 #include <kkeydialog.h>
00019 #include <kstatusbar.h>
00020 #include <kstandarddirs.h>
00021 #include <kmenubar.h>
00022 #include "GraphList.h"
00023 #include "Worksheet.h"
00024 #include "Project.h"
00025
00026 extern "C" double parse(char[]);
00027
00028 class MainWin
00029 : public KParts::MainWindow
00030 {
00031 Q_OBJECT
00032 private:
00033 void New();
00034 void readConfig();
00035 void enableAutosave(bool as);
00036 void newDialog(bool d, PType type);
00037 void newPlot(PType type);
00038 class Worksheet *activeWorksheet() { return (Worksheet *)ws->activeWindow(); }
00039 QWorkspace* ws;
00040 QString filename;
00041 KParts::ReadOnlyPart* gvpart;
00042 QPtrList<KAction> worksheetsActions;
00043 QSignalMapper *sm;
00044 KConfig *config;
00045 KRecentFilesAction* recent;
00046 KAction *configureAction, *project_action, *explorer_action;
00047 KAction *export_image, *export_svg, *export_pic, *export_pstoedit, *export_ImageMagick;
00048 KAction *print_action, *save_action, *save_as;
00049 KAction *graph_list, *clear_action, *close_action, *worksheet, *plot, *arrange, *overlay;
00050 KAction *deleteplot, *newgrassplot, *grassdata, *newvtkplot, *vtkdata;
00051 KAction *smooth, *prune, *average, *hist, *interpolation, *differences, *integration, *regression, *fft, *convolution, *fit;
00052 KAction *axes, *title, *legend, *objects;
00053 KAction *asx, *asy, *asz, *asall, *maglens, *panzoom, *sl, *sr, *su, *sd, *sxu, *sxd, *syu, *syd, *szu, *szd;
00054 KAction *baseline, *region, *label, *line, *rect, *ellipse, *image;
00055 KToggleAction *menubar, *toolbar, *sidetoolbar, *analysistoolbar, *drawingtoolbar, *statusbar;
00056 KToggleAction *printpreview;
00057 Project *project;
00058 QTimer *autosaveTimer;
00059 bool autosave;
00060 long autosaveinterval;
00061 bool modified;
00062 private slots:
00063 void open();
00064 void open(const KURL& url);
00065 void save();
00066 void saveAs();
00067 void projectInfo();
00068 void projectExplorer();
00069 void clear();
00070 void closeWin();
00071 void setWinFocus(int i) { (ws->windowList()).at(i)->setFocus(); }
00072
00073 void toggleFullScreen();
00074 void toggleMenuBar();
00075 void toggleToolBar();
00076 void toggleSideToolBar();
00077 void toggleAnalysisToolBar();
00078 void toggleDrawingToolBar();
00079 void toggleStatusBar();
00080 void configure();
00081 void configureKeys() { KKeyDialog::configure(actionCollection(), this, true); }
00082 void configureToolbars();
00083 void saveSettings();
00084 void setAutosaveInterval(long interval) { autosaveinterval=interval;}
00085
00086 void new2DPlot() { newPlot(P2D); }
00087 void newSurfacePlot() { newPlot(PSURFACE); }
00088 void new3DPlot() { newPlot(P3D); }
00089 void newPiePlot() { newPlot(PPIE); }
00090 void newPolarPlot() { newPlot(PPOLAR); }
00091 void newTernaryPlot() { newPlot(PTERNARY); }
00092 void newGRASSPlot() { newPlot(PGRASS); }
00093 void newVTKPlot() { newPlot(PVTK); }
00094 void deletePlot();
00095 class Worksheet* newWorksheet();
00096 void setActiveWorksheet(int i) { ws->windowList().at(i)->showMaximized(); }
00097 void aboutKDE();
00098 void reportBug();
00099 void exampleAxesLabel() { openfile(locate("data", QString("LabPlot/axeslabel.lpl.gz"))); }
00100 void exampleAnalysis() { openfile(locate("data", QString("LabPlot/analysis.lpl.gz"))); }
00101 void exampleSurface() { openfile(locate("data", QString("LabPlot/surface.lpl.gz"))); }
00102 void example3d() { openfile(locate("data", QString("LabPlot/3d.lpl.gz"))); }
00103 void exampleRydberg() { openfile(locate("data", QString("LabPlot/rydberg.lpl.gz"))); }
00104 void exampleLog() { openfile(locate("data", QString("LabPlot/log.lpl.gz"))); }
00105 void exampleFFT() { openfile(locate("data", QString("LabPlot/fft.lpl.gz"))); }
00106 void exampleObjects() { openfile(locate("data", QString("LabPlot/objects.lpl.gz"))); }
00107 void exampleHist() { openfile(locate("data", QString("LabPlot/hist.lpl.gz"))); }
00108 void exampleFit() { openfile(locate("data", QString("LabPlot/fit.lpl.gz"))); }
00109 void exampleImage() { openfile(locate("data", QString("LabPlot/image.lpl.gz"))); }
00110 void examplePie() { openfile(locate("data", QString("LabPlot/pie.lpl.gz"))); }
00111 void exampleExponentialFit() { openfile(locate("data", QString("LabPlot/exponential_fit.lpl.gz"))); }
00112 void exampleMultiplot() { openfile(locate("data", QString("LabPlot/multiplot.lpl.gz"))); }
00113 void exampleGrass() { openfile(locate("data", QString("LabPlot/grass.lpl.gz"))); }
00114 void exampleSurface2() { openfile(locate("data", QString("LabPlot/surface2.lpl.gz"))); }
00115 void examplePolar() { openfile(locate("data", QString("LabPlot/polar.lpl.gz"))); }
00116 void exampleTernary() { openfile(locate("data", QString("LabPlot/ternary.lpl.gz"))); }
00117 void exampleAudio() { openfile(locate("data", QString("LabPlot/audio.lpl.gz"))); }
00118 public slots:
00119 void updateWorksheetList();
00120 void exportPlot();
00121 void exportSVG();
00122 void exportPIC();
00123 void exportPstoedit();
00124 void exportImageMagick();
00125 void print();
00126 void printPreview();
00127 void graphs();
00128
00129 void new2DData() { newDialog(0,P2D); }
00130 void newSData() { newDialog(0,PSURFACE); }
00131 void new3DData() { newDialog(0,P3D); }
00132 void newPieData() { newDialog(0,PPIE); }
00133 void newPolarData() { newDialog(0,PPOLAR); }
00134 void newTernaryData() { newDialog(0,PTERNARY); }
00135 void newGRASSData() { newDialog(0,PGRASS); }
00136 void newVTKData() { newDialog(0,PVTK); }
00137 void new2DFunction() { newDialog(1,P2D); }
00138 void new3DFunction() {newDialog(1,P3D); }
00139 void newSFunction() { newDialog(1,PSURFACE); }
00140 void newPolarFunction() {newDialog(1,PPOLAR); }
00141
00142 void smoothDialog();
00143 void averageDialog();
00144 void pruneDialog();
00145 void histDialog();
00146 void interpolationDialog();
00147 void differencesDialog();
00148 void integrationDialog();
00149 void regressionDialog();
00150 void fftDialog();
00151 void convolutionDialog();
00152 void fitDialog();
00153
00154 void arrangeDialog();
00155 void overlayDialog();
00156 void worksheetDialog();
00157 void graphDialog();
00158 void axesDialog();
00159 void titleDialog();
00160 void legendDialog();
00161 void objectDialog();
00162
00163 void autoScaleX();
00164 void autoScaleY();
00165 void autoScaleZ();
00166 void autoScaleAll();
00167 void magLens();
00168 void panZoom();
00169 void shiftLeft();
00170 void shiftRight();
00171 void shiftUp();
00172 void shiftDown();
00173 void scaleXUp();
00174 void scaleXDown();
00175 void scaleYUp();
00176 void scaleYDown();
00177 void scaleZUp();
00178 void scaleZDown();
00179
00180 void defineRegion();
00181 void defineBaseline();
00182 void defineLine();
00183 void defineLabel();
00184 void defineRect();
00185 void defineEllipse();
00186 void defineImage();
00187 public:
00188 MainWin(const char *name,const char *filen);
00189 void replot();
00190 void openfile(QString file);
00191 void message(QString msg) {statusBar()->message(msg); }
00192 KConfig* getConfig() { return config; }
00193 int defining_region, defining_line, defining_rect, defining_ellipse;
00194 int defining_maglens,defining_panzoom;
00195 bool defining_baseline,defining_label,defining_image;
00196 Project *getProject() { return project; }
00197 void setProject(Project *p) { project=p; }
00198 QWorkspace *getWorkspace() { return ws; }
00199 void deleteActiveWorksheet();
00200 void setModified() {modified = true;}
00201 protected:
00202 void resizeEvent(QResizeEvent *e) { this->resize(e->size()); }
00203 void dragEnterEvent(QDragEnterEvent *e) { e->accept(QTextDrag::canDecode(e)); }
00204 void dropEvent(QDropEvent *e);
00205 void closeEvent(QCloseEvent *e);
00206 void mouseDoubleClickEvent(QMouseEvent *e) { if(!menuBar()->isVisible()) menuBar()->show(); }
00207
00208 };
00209
00210 #endif //MAINWIN_H