summaryrefslogtreecommitdiff
path: root/src/pmview/pmview.h
blob: bd402ad552ea6aada386f1e488ec57a482151f92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
 * Copyright (c) 2007-2009, Aconex.  All Rights Reserved.
 * 
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 */
#ifndef PMVIEW_H
#define PMVIEW_H

#include <Inventor/Qt/SoQt.h>
#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
#include <Inventor/nodes/SoDrawStyle.h>

#include "ui_pmview.h"

#include "qmc_time.h"
#include "qed_statusbar.h"
#include "qed_viewcontrol.h"

class ModList;
class SceneGroup;

class View : public QedViewControl
{
public:
    View() : QedViewControl() { };
    virtual ~View() { };

    void init(SceneGroup *, QMenu *, QString);
    SceneGroup *group() const { return my.group; }

    bool saveConfig(QString, bool, bool, bool, bool);
    QStringList hostList(bool);
    QString pmloggerSyntax(bool);

    bool stopRecording();
    bool queryRecording();
    bool detachLoggers();

private:
    struct {
	SceneGroup	*group;
    } my;
};

class PmView : public QMainWindow, public Ui::PmView
{
    Q_OBJECT

public:
    PmView();

    typedef enum {
	nothing = 0,
	// fetch = 0x1,		-- TODO
	metrics = 0x2,
	inventor = 0x4,
	metricLabel = 0x8,
        timeLabel = 0x10,
	all = 0xffffffff,
    } RenderOptions;

    static int defaultFontSize();
    static double defaultViewDelta() { return 1.0; }	// seconds
    static double defaultLoggerDelta() { return 1.0; }
    static int defaultTimeout() { return 3000; }		// milliseconds
    static int minimumPoints() { return 2; }
    static int maximumPoints() { return 360; }
    static int maximumLegendLength() { return 120; }	// chars
    static int minimumViewHeight() { return 80; }	// pixels

    bool view(bool, float, float, float, float, float);
    void render(RenderOptions options, time_t);
    View *activeView() { return my.viewList.at(my.activeView); }
    bool isViewRecording();
    bool isArchiveView();

    virtual void step(bool livemode, QmcTime::Packet *pmtime);
    virtual void VCRMode(bool livemode, QmcTime::Packet *pmtime, bool drag);
    virtual void timeZone(bool livemode, QmcTime::Packet *pmtime, char *tzdata);
    virtual void setDateLabel(QString label);
    virtual void setDateLabel(time_t seconds, QString tz);
    virtual void setButtonState(QedTimeButton::State state);
    virtual void setRecordState(bool recording);

    virtual QMenu *createPopupMenu();
    virtual void updateToolbarContents();
    virtual void updateToolbarLocation();
    virtual QList<QAction*> toolbarActionsList();
    virtual QList<QAction*> enabledActionsList();
    virtual void setupEnabledActionsList();
    virtual void addSeparatorAction();
    virtual void setEnabledActionsList(QStringList tools, bool redisplay);

    // Adjusted height for exporting images (without UI elements)
    int exportHeight()
	{ return height() - menuBar()->height() - toolBar->height(); }

    SoQtExaminerViewer *viewer() { return my.viewer; }
    static void selectionCB(ModList *, bool);

public slots:
    virtual void init();
    virtual void quit();
    virtual void enableUi();
    virtual void filePrint();
    virtual void fileQuit();
    virtual void helpManual();
    virtual void helpTutorial();
    virtual void helpAbout();
    virtual void helpSeeAlso();
    virtual void whatsThis();
    virtual void optionsNewPmchart();
    virtual void optionsTimeControl();
    virtual void optionsMenubar();
    virtual void optionsToolbar();
    virtual void optionsConsole();
    virtual void recordStart();
    virtual void recordQuery();
    virtual void recordStop();
    virtual void recordDetach();
    virtual void updateToolbarOrientation(Qt::Orientation);

protected slots:
    virtual void languageChange();
    virtual void closeEvent(QCloseEvent *);

private:
    struct {
	bool dialogsSetup;
	bool liveHidden;
	bool archiveHidden;
	bool menubarHidden;
	bool toolbarHidden;
	bool consoleHidden;

	QMenu *viewMenu;
	QList<QAction*> separatorsList;		// separator follow these
	QList<QAction*> toolbarActionsList;	// all toolbar actions
	QList<QAction*> enabledActionsList;	// currently visible actions

	QList<View *>viewList;
	int activeView;

	SoSeparator *root;
	SoDrawStyle *drawStyle;
	SoQtExaminerViewer *viewer;		// The examiner window

	QString text;
	QString prevText;
	QedStatusBar *statusBar;
    } my;
};

#endif	// PMVIEW_H