ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/qtrvu/qt_rvu_main.cxx
Revision: 1.1
Committed: Sat Oct 22 22:38:10 2011 UTC (12 years, 5 months ago) by greg
Branch: MAIN
CVS Tags: rad4R2P2, rad4R2, rad4R1, rad4R2P1
Log Message:
Added qt interface for rvu and cmake files from Bill Hoffman

File Contents

# User Rev Content
1 greg 1.1 #include <QtGui/QApplication>
2     #include <QtGui/QInputDialog>
3     #include <QtGui/QColor>
4     #include <QtCore/QDir>
5     #include <string>
6     #include <iostream>
7     #include "rvuwidget.h"
8     #include "mainwindow.h"
9    
10     // file level globals
11     static RvuWidget* WidgetInstance = 0;
12     static MainWindow* MainWindowInstance = 0;
13     static QApplication* ApplicationInstance = 0;
14    
15     // default size of window
16     static int XSize = 1024;
17     static int YSize = 768;
18    
19     extern "C"
20     int qt_rvu_paint(int r,int g,int b,
21     int xmin, int ymin, int xmax, int ymax
22     )
23     {
24     WidgetInstance->drawRect(xmin, YSize - ymax -1,
25     abs(xmax-xmin),
26     abs(ymax-ymin),
27     QColor(r, g, b));
28     return 0;
29     }
30    
31     extern "C" void qt_set_progress(int p)
32     {
33     MainWindowInstance->setProgress(p);
34     }
35     extern "C" void qt_flush_display()
36     {
37     WidgetInstance->update();
38     ApplicationInstance->processEvents();
39     }
40    
41     extern "C" int qt_rvu_run()
42     {
43     MainWindowInstance->show();
44     int ret = ApplicationInstance->exec();
45     return ret;
46     }
47    
48     extern "C" void qt_rvu_get_position(int *x, int *y)
49     {
50     MainWindowInstance->pick(x, y);
51     *y = YSize - *y -1;
52     }
53    
54     extern "C"
55     int qt_rvu_init(char* name, char* id,
56     int* xsize, int* ysize)
57     {
58     static int argc = 1;
59     static char * argv[] = {"rvu"};
60     ApplicationInstance = new QApplication(argc, argv);
61     *xsize = XSize;
62     *ysize = YSize;
63     MainWindowInstance = new MainWindow(*xsize, *ysize, name, id);
64     WidgetInstance = MainWindowInstance->getRvuWidget();
65     return 0;
66     }
67    
68     extern "C"
69     void qt_window_comout(const char* m)
70     {
71     MainWindowInstance->setStatus(m);
72     }
73    
74     extern "C"
75     void qt_resize(int X, int Y)
76     {
77     XSize = X;
78     YSize = Y;
79     MainWindowInstance->resizeImage(X, Y);
80     MainWindowInstance->show();
81     }
82    
83     // Return 1 if inp was changed
84     // Return 0 if no change was made to inp
85     extern "C"
86     int qt_open_text_dialog(char* inp, const char* prompt)
87     {
88     bool ok;
89     QString text = QInputDialog::getText(MainWindowInstance,
90     "QInputDialog::getText()",
91     prompt, QLineEdit::Normal,
92     "", &ok);
93     if (ok && !text.isEmpty())
94     {
95     if(text != inp)
96     {
97     strcpy(inp, text.toAscii());
98     return 1;
99     }
100     }
101     return 0;
102     }