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 "Spreadsheet.h"
00024 #include "Worksheet.h"
00025 #include "Project.h"
00026 #include "History.h"
00027
00028 #ifdef HAVE_QSA
00029 #include <qsproject.h>
00030 #include <qsinterpreter.h>
00031 #ifdef HAVE_QSA_IDE
00032 #include <qsworkbench.h>
00033 #endif
00034 #endif
00035
00036 #define PROJECT_VERSION 24
00037
00038 class Worksheet;
00039 class Spreadsheet;
00040 class Plot;
00041 class Plot2DSimple;
00042 class ExplorerDialog;
00043 class LegendDialog;
00044 class TitleDialog;
00045 class AxesDialog;
00046 class PlotSettingsDialog;
00047 class WorksheetDialog;
00048 class ObjectDialog;
00049
00050 class MainWin
00051 : public KParts::MainWindow
00052 {
00053 Q_OBJECT
00054 private:
00055 void setupActions();
00056 void readConfig();
00057 void enableAutosave(bool as);
00058 void newDialog(bool d, PType type);
00059 Plot *newPlot(PType type=P2D);
00060 QString filename;
00061 KParts::ReadOnlyPart* gvpart;
00062 QPopupMenu *spreadsheetpopup;
00063 QSignalMapper *sm, *smg;
00064 QWorkspace* ws;
00065 KConfig *config;
00066 Project *project;
00067 History *history;
00068 #ifdef HAVE_QSA
00069 QSProject *qsproject;
00070 #ifdef HAVE_QSA_IDE
00071 QSWorkbench *ide;
00072 #endif
00073 #endif
00074 KRecentFilesAction* recent;
00075 KAction *configureAction, *project_action, *explorer_action;
00076 KAction *import_action, *importopj_action, *export_image, *export_svg, *export_pic, *export_ps, *export_eps, *export_pdf;
00077 KAction *export_pstoedit, *export_ImageMagick, *print_action, *save_action, *save_as, *saveXML_action, *openXML_action;
00078 KAction *graph_list, *plot_list, *clear_action, *close_action, *worksheet_action, *plot_action, *arrange, *overlay;
00079 KAction *deleteplot, *qwt3d_plot, *qwt3d_func, *qwt3d_data;
00080 KAction *evaluate, *operations, *imagepro;
00081 KAction *smooth, *prune, *average, *compress, *periodic, *seasonal, *hist, *peak;
00082 KAction *interpolation, *differences, *integration, *capability, *regression, *fft, *convolution, *wavelet;
00083 KAction *hankel, *fit, *filter, *noise, *correl;
00084 KAction *axes, *title_action, *legend, *objects;
00085 KAction *asx, *asy, *asz, *asall, *maglens, *panzoom, *sl, *sr, *su, *sd, *sxu, *sxd, *syu, *syd, *szu, *szd;
00086 KAction *zoomin, *zoomout, *maskplot;
00087 KAction *baseline, *region, *label, *line, *rect, *ellipse, *image;
00088 KAction *ideAction, *scriptAction, *nextwindow_action, *prevwindow_action, *undo_action, *redo_action;
00089 KToggleAction *menubar, *toolbar, *sidetoolbar, *analysistoolbar, *drawingtoolbar, *statusbar;
00090 KToggleAction *printpreview, *togglespeedmode, *toggledatamode;
00091 bool printpreviewchecked;
00092 QTimer *autosaveTimer;
00093 bool autosave;
00094 long autosaveinterval;
00095 bool modified, is_fullscreen;
00096 bool speedmode, datamode;
00097 int speedmodevalue;
00098 QFont defaultfont;
00099 int nr_w, nr_s;
00100 private slots:
00101 void closeWin();
00102 void setWinFocus(int i) { (ws->windowList()).at(i)->setFocus(); }
00103 void SpreadsheetMenu();
00104 void windowActivated();
00105
00106 void configure();
00107 void configureKeys() { KKeyDialog::configure(actionCollection(), this, true); }
00108 void configureToolbars();
00109 void saveSettings();
00110 void autoSave();
00111 void setAutosaveInterval(long interval) { autosaveinterval=interval;}
00112
00113 void openIDE();
00114 void reportBug();
00115 void exampleAxesLabel() { openfile(locate("data", QString("LabPlot/axeslabel.lpl.gz"))); }
00116 void exampleAnalysis() { openfile(locate("data", QString("LabPlot/analysis.lpl.gz"))); }
00117 void exampleSurface() { openfile(locate("data", QString("LabPlot/surface.lpl.gz"))); }
00118 void example3d() { openfile(locate("data", QString("LabPlot/3d.lpl.gz"))); }
00119 void exampleRydberg() { openfile(locate("data", QString("LabPlot/rydberg.lpl.gz"))); }
00120 void exampleLog() { openfile(locate("data", QString("LabPlot/log.lpl.gz"))); }
00121 void exampleFFT() { openfile(locate("data", QString("LabPlot/fft.lpl.gz"))); }
00122 void exampleObjects() { openfile(locate("data", QString("LabPlot/objects.lpl.gz"))); }
00123 void exampleHist() { openfile(locate("data", QString("LabPlot/hist.lpl.gz"))); }
00124 void exampleFit() { openfile(locate("data", QString("LabPlot/fit.lpl.gz"))); }
00125 void exampleImage() { openfile(locate("data", QString("LabPlot/image.lpl.gz"))); }
00126 void examplePie() { openfile(locate("data", QString("LabPlot/pie.lpl.gz"))); }
00127 void exampleExponentialFit() { openfile(locate("data", QString("LabPlot/exponential_fit.lpl.gz"))); }
00128 void exampleMultiplot() { openfile(locate("data", QString("LabPlot/multiplot.lpl.gz"))); }
00129 void exampleSurface2() { openfile(locate("data", QString("LabPlot/surface2.lpl.gz"))); }
00130 void examplePolar() { openfile(locate("data", QString("LabPlot/polar.lpl.gz"))); }
00131 void exampleTernary() { openfile(locate("data", QString("LabPlot/ternary.lpl.gz"))); }
00132 void exampleAudio() { openfile(locate("data", QString("LabPlot/audio.lpl.gz"))); }
00133 void exampleQWT() { openfile(locate("data", QString("LabPlot/qwt.lpl.gz"))); }
00134 void exampleBar() { openfile(locate("data", QString("LabPlot/bar.lpl.gz"))); }
00135 void exampleLogfit() { openfile(locate("data", QString("LabPlot/logfit.lpl.gz"))); }
00136 void exampleMarker() { openfile(locate("data", QString("LabPlot/marker.lpl.gz"))); }
00137 void exampleSurfaceStyle() { openfile(locate("data", QString("LabPlot/surfacestyle.lpl.gz"))); }
00138 void exampleTeXLabel() { openfile(locate("data", QString("LabPlot/texlabel.lpl.gz"))); }
00139 public slots:
00140 void New();
00141 void open(QString fn=0);
00142 void save(QString fn=0);
00143 void openXML(QString fn=0);
00144 void saveXML(QString fn=0);
00145 void saveAs(QString fn=0);
00146 void projectInfo();
00147 void projectExplorer();
00148 void importData(QString fn,int filter=0);
00149 void importDialog();
00150 void importOPJ(QString fn=0);
00151 void exportPlot(QString fn=0, QString f=0);
00152 void exportPS(QString fn=0);
00153 void exportEPS(QString fn=0);
00154 void exportPDF(QString fn=0);
00155 void exportSVG(QString fn=0);
00156 void exportPIC(QString fn=0);
00157 void exportPstoEdit(QString fn=i18n("out.pdf"),int f=4, int s=5, double sc=1.0, double r=0.0);
00160 void exportPstoEditDialog();
00161 void exportImageMagick(QString fn=i18n("out.8bim"), int f=0, int sx=800, int sy=600, double r=0.0);
00164 void exportImageMagickDialog();
00165 void print();
00166 void printPreview();
00167 void graphDialog();
00168 void plotDialog();
00169
00170 void clear();
00171 void deletePlot();
00172 void loadScript(QString fn=0);
00173 void Environment();
00174 void aboutKDE();
00175 void exit() {modified=false; close(); }
00176 void toggleFullScreen();
00177 void toggleMenuBar();
00178 void toggleToolBar();
00179 void toggleSideToolBar();
00180 void toggleAnalysisToolBar();
00181 void toggleDrawingToolBar();
00182 void toggleStatusBar();
00183 bool speedMode() { return speedmode; }
00184 void setSpeedMode(bool s) { speedmode = s; }
00185 void toggleSpeedMode();
00186 int speedModeValue() { return speedmodevalue; }
00187 void setSpeedModeValue(int s) { speedmodevalue=s; }
00188 bool dataMode() { return datamode; }
00189 void setDataMode(bool d) { datamode = d; }
00190 QFont defaultFont() { return defaultfont; }
00191 void setDefaultFont(QFont f) { defaultfont=f; }
00192
00193 void newPlot(int type) { newPlot((PType) type); }
00194 Plot2DSimple* new2DPlot() { return (Plot2DSimple *) newPlot(P2D); }
00195 void newSurfacePlot() { newPlot(PSURFACE); }
00196 void new3DPlot() { newPlot(P3D); }
00197 void newPiePlot() { newPlot(PPIE); }
00198 void newPolarPlot() { newPlot(PPOLAR); }
00199 void newTernaryPlot() { newPlot(PTERNARY); }
00200 void newQWT3DPlot() { newPlot(PQWT3D); }
00201
00202 void new2DData() { newDialog(0,P2D); }
00203 void newSData() { newDialog(0,PSURFACE); }
00204 void new3DData() { newDialog(0,P3D); }
00205 void newPieData() { newDialog(0,PPIE); }
00206 void newPolarData() { newDialog(0,PPOLAR); }
00207 void newTernaryData() { newDialog(0,PTERNARY); }
00208 void newQWT3DData() { newDialog(0,PQWT3D); }
00209 void new2DFunction() { newDialog(1,P2D); }
00210 void new3DFunction() {newDialog(1,P3D); }
00211 void newQWT3DFunction() {newDialog(1,PQWT3D); }
00212 void newSFunction() { newDialog(1,PSURFACE); }
00213 void newPolarFunction() {newDialog(1,PPOLAR); }
00214
00215 Style* newStyle() { return new Style(); }
00216 Symbol* newSymbol() { return new Symbol(); }
00217 Style *defaultStyle();
00218 Symbol *defaultSymbol();
00219 void lDebug(QString s) { kdDebug()<<s<<endl; }
00220
00221 void evaluateDialog();
00222 void operationsDialog();
00223 void smoothDialog();
00224 void averageDialog();
00225 void compressDialog();
00226 void pruneDialog();
00227 void periodicDialog();
00228 void seasonalDialog();
00229 void histDialog();
00230 void peakDialog();
00231 void interpolationDialog();
00232 void differencesDialog();
00233 void integrationDialog();
00234 void capabilityDialog();
00235 void regressionDialog();
00236 void fftDialog();
00237 void convolutionDialog();
00238 void waveletDialog();
00239 void hankelDialog();
00240 void fitDialog();
00241 void filterDialog();
00242 void noiseDialog();
00243 void correlDialog();
00244 void imageDialog();
00245
00246 void arrangeDialog();
00247 void overlayDialog();
00248 void worksheetDialog();
00249 void plotSettingsDialog();
00250 void axesDialog();
00251 void titleDialog();
00252 void legendDialog();
00253 void objectDialog();
00254
00255 void autoScaleX();
00256 void autoScaleY();
00257 void autoScaleZ();
00258 void autoScaleAll();
00259 void shiftLeft();
00260 void shiftRight();
00261 void shiftUp();
00262 void shiftDown();
00263 void scaleXUp();
00264 void scaleXDown();
00265 void scaleYUp();
00266 void scaleYDown();
00267 void scaleZUp();
00268 void scaleZDown();
00269 void zoomIn();
00270 void zoomOut();
00271 void toggleDataMode();
00272
00273
00274 void open(const KURL& url);
00275
00276 void magLens();
00277 void panZoom();
00278 void maskPlot();
00279
00280 void defineRegion();
00281 void defineBaseline();
00282 void defineLine();
00283 void defineLabel();
00284 void defineRect();
00285 void defineEllipse();
00286 void defineImage();
00287
00288 void setActiveSheet(int i);
00289 void changeGraph(int i);
00290 void cloneActiveSheet();
00291 void cloneWorksheet(Worksheet *w);
00292 void cloneSpreadsheet(Spreadsheet *s);
00293 Spreadsheet* newSpreadsheet();
00294 Worksheet* newWorksheet();
00295 Worksheet* activeWorksheet();
00296 Spreadsheet* activeSpreadsheet();
00297 int activeSheetIndex();
00298 void updateGraphList();
00299 void updateSheetList();
00300
00301
00302 void updateExplorerDialog();
00303 void updateLegendDialog();
00304 void updateTitleDialog();
00305 void updateAxesDialog(int i=-1);
00306 void updatePlotSettingsDialog();
00307 void updateWorksheetDialog();
00308 void updateObjectDialog();
00309
00310 void activateNextWindow() {
00311 #if QT_VERSION > 0x030102
00312 ws->activateNextWindow();
00313 #endif
00314 }
00315 void activatePrevWindow() {
00316 #if QT_VERSION > 0x030102
00317 ws->activatePrevWindow();
00318 #endif
00319 }
00320 void undoAction();
00321 void redoAction();
00322 public:
00323 MainWin(const char *name,const char *filen,bool is_part=false);
00324 void replot();
00325 void openfile(QString file);
00326 void message(QString msg) {statusBar()->message(msg); }
00327 KConfig* Config() { return config; }
00328 History* getHistory() { return history; }
00329 int defining_region, defining_line, defining_rect, defining_ellipse;
00330 int defining_maglens,defining_panzoom, defining_mask;
00331 bool defining_baseline,defining_label,defining_image;
00332
00333 ExplorerDialog *explorer_dialog;
00334 LegendDialog *legend_dialog;
00335 TitleDialog *title_dialog;
00336 AxesDialog *axes_dialog;
00337 PlotSettingsDialog *plotsettings_dialog;
00338 WorksheetDialog *worksheet_dialog;
00339 ObjectDialog *object_dialog;
00340
00341 Project *getProject() { return project; }
00342 void setProject(Project *p) { project=p; }
00343 #ifdef HAVE_QSA
00344 QSProject *getQSProject() { return qsproject; }
00345 #endif
00346 void readScript(QString name);
00347 QWorkspace *getWorkspace() { return ws; }
00348 void deleteActiveSheet();
00349 void setModified() {modified = true;}
00350 int NrSpreadsheets() { return nr_s; }
00351 int NrWorksheets() { return nr_w; }
00352 QString Filename() { return filename; }
00353 Worksheet *addWorksheet(PType type, int sheet);
00354 int addGraph2D(Graph2D *g, int item, PType type=P2D);
00355 int addGraph3D(Graph3D *g, int item, PType type=P3D);
00356 int addGraph4D(Graph4D *g, int item);
00357 int addGraphM(GraphM *g, int item, PType type=PSURFACE);
00358 int addGraphIMAGE(GraphIMAGE *g, int item);
00359 int addGraphL(GraphL *g, int item, PType type=PPIE);
00360 void calculateRanges2D(Point *a, int n, double *xmin, double *xmax,
00361 double *ymin, double *ymax);
00362 void calculateRanges3D(Point3D *a, int n, double *xmin, double *xmax,
00363 double *ymin, double *ymax, double *zmin, double *zmax);
00364 void calculateRanges4D(Point4D *a, int n, double *xmin, double *xmax,
00365 double *ymin, double *ymax, double *zmin, double *zmax, double *tmin, double *tmax);
00366 double formatLabel(QString value,int item);
00367 protected:
00368 void resizeEvent(QResizeEvent *e) { this->resize(e->size()); }
00369 void dragEnterEvent(QDragEnterEvent *e) { e->accept(QTextDrag::canDecode(e)); }
00370 void dropEvent(QDropEvent *e);
00371 void closeEvent(QCloseEvent *e);
00372 void mouseDoubleClickEvent(QMouseEvent *e);
00373
00374 };
00375
00376 #endif // MAINWIN_H