]> rtime.felk.cvut.cz Git - orte.git/blob - orte/contrib/shape/MainForm.cpp
a3e661e73a7624916e41c49c5701234f15d677e6
[orte.git] / orte / contrib / shape / MainForm.cpp
1 #include <QMessageBox>
2 #include "MainForm.h"
3 #include "richtext.h"
4
5 #include "FPublisher.h"
6 #include "FSubscriber.h"
7
8 MainForm::MainForm(QWidget *parent)
9     : QDialog(parent)
10 {
11     setupUi(this);
12 }
13
14 void MainForm::about()
15 {
16     QMessageBox::about( this, "ORTE application demo",
17                         "This application demonstrates usege of ORTE library\n\n"
18                         "Petr Smolik (c) 2004-2008\n"
19                         "OCERA team");
20 }
21
22 void MainForm::viewPublSource()
23 {
24     MyRichText *richtext;
25     richtext=new MyRichText;
26     richtext->resize( 450, 350 );
27     richtext->setWindowTitle( "Publisher example");
28     richtext->setTextPublisher();
29     richtext->show();
30     connect( this, SIGNAL( rejected() ), richtext, SLOT( close() ) );
31 }
32
33 void MainForm::viewSubsSource()
34 {
35     MyRichText *richtext;
36     richtext=new MyRichText;
37     richtext->resize( 450, 350 );
38     richtext->setWindowTitle( "Subscriber example");
39     richtext->setTextSubscriber();
40     connect( this, SIGNAL( rejected() ), richtext, SLOT( close() ) );
41     richtext->show();
42 }
43
44 void MainForm::addPublisher()
45 {
46     FPublisher *fp;
47     int color=0;
48
49     if (radioButton2_3->isChecked())
50       color=1;
51     if (radioButton2_4->isChecked())
52       color=2;
53     if (radioButton1->isChecked())
54       color=3;
55     if (radioButton2->isChecked())
56       color=4;
57     fp = new FPublisher();
58     if (!fp->initPublisher(color,rand()%3)) {
59         QMessageBox::critical(this, "ORTE error", "Publisher initialization failed");
60         delete fp;
61         return;
62     }
63     connect( this, SIGNAL( rejected() ), fp, SLOT( destroy() ) );
64     fp->setWindowIcon(QPixmap(":/FPublisherIcon.png"));
65     fp->show();
66 }
67
68 void MainForm::addSubscriber()
69 {
70     FSubscriber *fs;
71     fs = new FSubscriber;
72     connect( this, SIGNAL( rejected() ), fs, SLOT( destroy() ) );
73     if (!fs->initSubscribers(
74         clBlue->isChecked(),
75         clGreen->isChecked(),
76         clRed->isChecked(),
77         clBlack->isChecked(),
78         clYellow->isChecked()))
79     {
80         QMessageBox::critical(this, "ORTE error", "Subscriber initialization failed");
81         delete fs;
82         return;
83     }
84     fs->setWindowIcon(QPixmap(":/FSubscriberIcon.png"));
85     fs->show();
86 }