1 /****************************************************************************
2 ** ui.h extension file, included from the uic-generated form implementation.
4 ** If you wish to add, delete or rename functions or slots use
5 ** Qt Designer which will update this file, preserving your code. Create an
6 ** init() function in place of a constructor, and a destroy() function in
7 ** place of a destructor.
8 *****************************************************************************/
12 #include <qapplication.h>
13 #if (QT_VERSION-0 >= 0x040000)
14 #include <QCloseEvent>
17 extern QApplication *a;
19 void FPublisher::init()
21 stepx=rand()%2+1;stepy=rand()%2+1;
23 while(incx==0) incx=(rand()%3-1)*stepx;
24 while(incy==0) incy=(rand()%3-1)*stepy;
25 rect.setRect(0,0,25,45);
27 domain=ORTEDomainAppCreate(ORTE_DEFAULT_DOMAIN,NULL,NULL,ORTE_FALSE);
28 BoxType_type_register(domain);
32 void FPublisher::initPublisher(int icolor,int istrength)
40 boxType.shape=strength;
41 timer = new QTimer(this);
42 connect( timer, SIGNAL(timeout()), SLOT(Timer()));
43 timer->start( 50, FALSE );
44 view->activateObject(0,color,strength);//color,shape
45 NtpTimeAssembFromMs(persistence, 5, 0);
47 case CL_BLUE:topic="Blue";break;
48 case CL_GREEN:topic="Green";break;
49 case CL_RED:topic="Red";break;
50 case CL_BLACK:topic="Black";break;
51 case CL_YELLOW:topic="Yellow";break;
53 publisher=ORTEPublicationCreate(
65 void FPublisher::closeEvent( QCloseEvent *e )
71 void FPublisher::destroy()
75 ORTEDomainAppDestroy(domain);
80 void FPublisher::Timer()
83 if(rect.left()<=0) incx=stepx;
84 if(rect.top()<=0) incy=stepy;
85 if((rect.right())>=view->width()) incx=-stepx;
86 if((rect.bottom())>=view->height()) incy=-stepy;
87 if(view->mousePressed==1) {
88 int tmpW=rect.width();
89 int tmpH=rect.height();
90 rect.setRect(view->mouseX-tmpW/2,view->mouseY-tmpH/2,tmpW,tmpH);
92 rect.moveBy(incx,incy);
94 view->setPosition(0,rect);
95 //prepare published data
96 boxType.rectangle.top_left_x=rect.left();
97 boxType.rectangle.top_left_y=rect.top();
98 boxType.rectangle.bottom_right_x=rect.right();
99 boxType.rectangle.bottom_right_y=rect.bottom();
100 ORTEPublicationSend(publisher);
105 void FPublisher::strengthChanged()
109 if (!publisher) return;
111 ORTEPublicationPropertiesGet(publisher,&pp);
112 pp.strength=slider->value();
113 ORTEPublicationPropertiesSet(publisher,&pp);