]> rtime.felk.cvut.cz Git - orte.git/blob - orte/contrib/shape/Subscriber.cpp
94437f47e919f6182989bfe0bb16072bdc290e2c
[orte.git] / orte / contrib / shape / Subscriber.cpp
1 #include "Subscriber.h"
2 #include <qtimer.h>
3 #include <qrect.h>
4 #include <orte.h>
5
6 Subscriber::Subscriber( QWidget *parent, const char *name )
7         : QWidget( parent, name )
8 {
9 }
10
11 void Subscriber::Create(QString name, char shape, char color)
12 {
13
14         //init main frame
15         m_mainFrm = new MainForm;
16         Text = new QLabel( m_mainFrm, "Text" );
17         Text->setGeometry( QRect(10 , 0, 110, 15 ) );
18     Text->setText( trUtf8( "Minimum Separation : " ) );
19         MinSep = new QSlider(m_mainFrm, "str" );
20     MinSep->setGeometry( QRect( 120, 0, 130, 15 ) );
21         MinSep->setMaxValue( 10 );
22     MinSep->setOrientation( QSlider::Horizontal );
23         connect( MinSep, SIGNAL( valueChanged(int) ), this, SLOT(changeMinSep() ) );
24         m_mainFrm->show();
25         m_mainFrm->SetProperties(shape,color);
26
27
28         //init caption
29
30
31         strTitle="Subscriber : "+name+" (Topic=";
32 typS=color;
33 topS=shape;
34         switch(shape)
35         {
36         case RECTANGLE:
37                 strTitle+="RECTANGLE, Type=";
38                 topic="Rectangle";
39                 break;
40         case ELLIPSE:
41                 strTitle+="ELLIPSE, Type=";
42                 topic="Ellipse";
43                 break;
44         case TRIANGLE:
45                 strTitle+="TRIANGLE, Type=";
46                 topic="Triangle";
47                 break;
48         }
49
50         switch(color)
51         {
52         case BLUE:
53                 strTitle+="BLUE";
54                 type="Blue";
55                 break;
56         case GREEN:
57                 strTitle+="GREEN";
58                 type="Green";
59                 break;
60         case RED:
61                 strTitle+="RED";
62                 type="Red";
63                 break;
64         case BLACK:
65                 strTitle+="BLACK";
66                 type="Black";
67                 break;
68         }
69         strTitle+=" Min.Sep.=0 )";
70         m_mainFrm->setCaption(strTitle);
71 }
72
73
74 void Subscriber::Destroy()
75 {
76                 m_mainFrm->WantClose();
77         m_mainFrm->close();
78
79 }
80
81 void Subscriber::changeMinSep()
82 {
83         ORTESubsProp  sub_prop;
84         ORTEAppSubsPropGet(app,1,&sub_prop);
85         NtpTimeAssembFromMs(sub_prop.minimumSeparation,MinSep->value(),0);
86         ORTEAppSubsPropSet(app,1,&sub_prop);
87         QString name=QString::number(MinSep->value());
88         if((MinSep->value())<10) name+=" ";
89         (this->strTitle).replace((this->strTitle).length()-3,2,name);
90         (this->m_mainFrm)->setCaption(this->strTitle);
91 }