/////////////////////////////////////////////////////////////
//
//
Source file for BulletinBoard
//
// This file is generated by RapidApp 1.2
//
// This class is derived from BulletinBoardUI
which
// implements the user interface created in
// RapidApp. This class contains virtual
// functions that are called from the user
interface.
//
// When you modify this source, limit your
changes to
// modifying the emtpy virtual functions. You
can also add
// new functions below the "//--- End
generated code section" markers
//
// This will allow RapidApp to integrate
changes more easily
//
// This class is a ViewKit user interface
"component".
// For more information on how components are
used, see the
// "ViewKit Programmers' Manual",
and the RapidApp
// User's Guide.
/////////////////////////////////////////////////////////////
#include
"BulletinBoard.h"
#include
<Vk/VkEZ.h>
#include
<GL/GLwMDrawA.h>
#include
<Sgm/Dial.h>
#include
<Xm/BulletinB.h>
#include
<Xm/Label.h>
#include
<Xm/LabelG.h>
#include
<Xm/PushB.h>
#include
<Xm/Scale.h>
#include
<Xm/ToggleB.h>
#include
<Vk/VkResource.h>
#include
<Vk/VkSimpleWindow.h>
#include
<Vk/VkPeriodic.h>
extern
void VkUnimplemented ( Widget, const char * );
///////////////////////////////////////////////////////////////////////////////
// The
following non-container elements are created by BulletinBoardUI and are
//
available as protected data members inherited by this class
//
// XmLabel
_label2
// XmLabel
_label1
// XmPushButton _reset
// XmToggleButton (LED style) _rotation
// XmScale
_blue1
// XmScale
_green1
// XmScale
_red1
// XmScale
_scale
// XmLabelGadget _label4
// XmLabelGadget _label3
// SgDial
_dial
// XmToggleButton (LED style) _drawing
// XmPushButton _clear
// XmPushButton _exit1
// GLwMDrawingArea _window
//
///////////////////////////////////////////////////////////////////////////////
#include
<GL/gl.h>
#include
<GL/glu.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<math.h>
#include
"XwindowSupport.h"
#include
"Build_rrt.h"
#define
XWINDOWSIZE 470
#define
YWINDOWSIZE 570
int
timerControl,sec[2];
//
Animation class
void
Anim();
class
MyPeriodic:public VkPeriodic{
public:
MyPeriodic(int
interval):VkPeriodic(interval)
{;}
virtual void tick(void) {Anim();}
};
MyPeriodic*
mp=0;
int
mode[2],priority[2];
Build
build;
void
Anim(){ //Animation funtion
makeGLCurrent();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 470.0, 0.0, 570.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glViewport(0, 0, 470, 570);
glClearColor(1.0,1.0,1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT |
GL_DEPTH_BUFFER_BIT);
glColor3f(0.0,0.0,1.0);
for (int k=0;k<numObstacles;k++){
glBegin(GL_POLYGON);
for (int i =0;i<obs[k].npoints;i++)
glVertex2f(obs[k].x[i],obs[k].y[i]);
glEnd();
}
glColor3f(0.0,1.0,0.0);
for (int j=0;j<2;j++){
glLoadIdentity();
glLineWidth(2);
glTranslatef(goal[j][0],goal[j][1],0.0);
glRotatef(goal[j][2]*180/3.1416,0.0,0.0,1.0);
glCallList(2);
glLoadIdentity();
if(mode[j]!=1){
if(path[j][sec[j]+1].status!=sharepath
){
sec[j]++;
priority[0]=0;
}
else{
if(j==0 &&
path[0][sec[0]+1].shareRegion != path[1][sec[1]].shareRegion)
sec[0]++;
if(j==1 && path[1][sec[1]+1].shareRegion!=path[0][sec[0]].shareRegion)
sec[1]++;
}
}
if(sec[j]<finalLevel[j]){
glTranslatef(path[j][sec[j]].x,path[j][sec[j]].y,0.0);
glRotatef(path[j][sec[j]].theta,0,0,1);
glCallList(1);
}
else {
glTranslatef(path[j][sec[j]].x,path[j][sec[j]].y,0.0);
glRotatef(path[j][sec[j]].theta,0,0,1);
glCallList(1);
mode[j]=1;
}
}
GLSwapBuffers();
}
//----
End generated headers
//----
BulletinBoard Constructor
BulletinBoard::BulletinBoard(const
char *name, Widget parent) :
BulletinBoardUI(name,
parent)
{
//--- Add application code here:
} // End Constructor
BulletinBoard::BulletinBoard(const
char *name) :
BulletinBoardUI(name)
{ //--- Add application code here:
} // End Constructor
BulletinBoard::~BulletinBoard()
{
//--- Add application code here:
} // End Destructor
const
char * BulletinBoard::className() // classname
{
return ("BulletinBoard");
} //
End className()
void
BulletinBoard::MyExpose ( Widget w, XtPointer callData )
{
//--- Add application code for
BulletinBoard::MyExpose here:
makeGLCurrent();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 470.0, 0.0, 570.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glViewport(0, 0, 470, 570);
glClearColor(1.0,1.0,1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT |
GL_DEPTH_BUFFER_BIT);
printf("numNodes[0]=%d
finallevel[0]=%d numNodes[1]=%d finallevel[1]=%d\n",
numNodes[0],finalLevel[0],numNodes[1],finalLevel[1]);
glColor3f(0.0,0.0,1.0);
for (int k=0;k<numObstacles;k++){
glBegin(GL_POLYGON);
for (int i =0;i<obs[k].npoints;i++)
glVertex2f(obs[k].x[i],obs[k].y[i]);
glEnd();
}
for (int j=0;j<2;j++){
glLoadIdentity();
glTranslatef(goal[j][0],goal[j][1],0.0);
glRotatef(goal[j][2]*180/pi,0.0,0.0,1.0);
glCallList(2);
glLoadIdentity();
if(j==0) glColor3f(0.0,0.5,0.5);
if(j==1) glColor3f(0.0,1.0,0.0);
glLineWidth(1);
for (int i=0;i<numNodes[j]-1;i++){
glBegin(GL_LINES);
glVertex2f(node[j][i].x,node[j][i].y);
glVertex2f(node[j][node[j][i].parent].x,node[j][node[j][i].parent].y);
glEnd();
}
for (i =0;i<(finalLevel[j]);i++){
if(path[j][i].status!=sharepath)
glColor3f(1.0,0.0,0.0);
else glColor3f(0.0,0.0,0.0);
glLineWidth(4);
glBegin(GL_LINES);
glVertex2f(path[j][i].x,path[j][i].y);
glVertex2f(path[j][i+1].x,path[j][i+1].y);
glEnd();
}
if(mode[j]!=1){
glTranslatef(path[j][0].x,path[j][0].y,0.0);
glRotatef(path[j][0].theta,0,0,1);
}
else{
glTranslatef(path[j][finalLevel[j]-1].x,path[j][finalLevel[j]-1].y,0.0);
glRotatef(path[j][finalLevel[j]-1].theta,0,0,1);
}
glCallList(1);
}
//
GLSwapBuffers();
} // End BulletinBoard::MyExpose()
void
BulletinBoard::MyInit ( Widget w, XtPointer callData )
{
//--- Add application code for BulletinBoard::MyInit
here:
initGLWindow(w, callData);
startpt=0,endpt=2;
makeGLCurrent();
mp=new MyPeriodic(200);
glNewList(1,GL_COMPILE);
glBegin(GL_POLYGON);
glColor3f(1.0,0.0,1.0);
glVertex2d(-10,-6);
glVertex2d(12,-6);
glVertex2d(12,6);
glVertex2d(-10,6);
glEnd();
glEndList();
glNewList(2,GL_COMPILE);
glLineWidth(2);
glBegin(GL_LINE_LOOP);
glColor3f(.20,1.0,.8);
glVertex2d(-10,-6);
glVertex2d(12,-6);
glVertex2d(12,6);
glVertex2d(-10,6);
glEnd();
glEndList();
build.init();
build.rrt();
build.sharezone();
} // End BulletinBoard::MyInit()
void
BulletinBoard::MyInput ( Widget w, XtPointer callData )
{
//--- Add application code for
BulletinBoard::MyInput here:
} // End BulletinBoard::MyInput()
void
BulletinBoard::blue_value ( Widget w, XtPointer callData )
{
//--- Add application code for
BulletinBoard::blue_value here:
MyExpose(w,callData);
} // End BulletinBoard::blue_value()
void
BulletinBoard::doClear ( Widget w, XtPointer callData )
{
//--- Add application code for
BulletinBoard::doClear here:
} // End BulletinBoard::doClear()
void
BulletinBoard::doExirt ( Widget w, XtPointer callData )
{
//--- Add application code for
BulletinBoard::doExirt here:
exit(1);
} // End BulletinBoard::doExirt()
void
BulletinBoard::doReset ( Widget w, XtPointer callData )
{
//--- Add application code for
BulletinBoard::doReset here:
sec[0]=0;
sec[1]=0;
timerControl=0;
mode[0]=0;
mode[1]=0;
//MyExpose(w,callData);
} // End BulletinBoard::doReset()
void
BulletinBoard::green_value ( Widget w, XtPointer callData )
{
//--- Add application code for
BulletinBoard::green_value here:
} // End BulletinBoard::green_value()
void
BulletinBoard::red_value ( Widget w, XtPointer callData )
{
//--- Add application code for BulletinBoard::red_value
here:
} // End BulletinBoard::red_value()
void
BulletinBoard::rotation_value ( Widget w, XtPointer callData )
{
//--- Add application code for
BulletinBoard::rotation_value here:
} // End BulletinBoard::rotation_value()
void
BulletinBoard::scale_value ( Widget w, XtPointer callData )
{
//--- Add application code for
BulletinBoard::scale_value here:
} // End BulletinBoard::scale_value()
void
BulletinBoard::setDrawing ( Widget w, XtPointer callData )
{
//--- Add application code for
BulletinBoard::setDrawing here:
timerControl=1;
mp->start();
} // End BulletinBoard::setDrawing()
void
BulletinBoard::setRotation ( Widget w, XtPointer callData )
{
//--- Add application code for
BulletinBoard::setRotation here:
if (timerControl==1) {
mp->stop();
timerControl=0;
}
else{
mp->start();
timerControl=1;
}
} // End BulletinBoard::setRotation()
void
BulletinBoard::setParent( class VkSimpleWindow * parent )
{
// Store a pointer to the parent VkWindow.
This can
// be useful for accessing the menubar
from this class.
_parent = parent;
} // End BulletinBoard::setParent()
///////////////////////////////////////////////////////////////////
//
C-callable creation function, for importing class into rapidapp
///////////////////////////////////////////////////////////////////
extern
"C" VkComponent *CreateBulletinBoard( const char *name, Widget parent
)
{
VkComponent *obj = new BulletinBoard ( name, parent );
obj->show();
return ( obj );
} //
End CreateBulletinBoard
///////////////////////////////////////////////////////////////////
//
Function for importing this class into rapidapp
// This
function is only used by RapidApp.
//
//
WARNING: The structure below is out of date for RapidApp 1.2.
// See
the RapidApp release notes for details
///////////////////////////////////////////////////////////////////
typedef
void (BulletinBoard::*Method)(void);
struct
FunctionMap {
char
*resource; Method method; char
*code;
char
*type;
};
extern
"C" void* RegisterBulletinBoardInterface()
{
// This structure registers information
about this class
// that allows RapidApp to create and
manipulate an instance.
// Each entry provides a resource name
that will appear in the
// resource manager palette when an
instance of this class is
// selected, the relative address of the
member function that
// should be invoked when the resource is
set, the name of the
// member function as a string, and the
type of the single
// argument to this function. All
functions must have the form
//
//
void memberFunction ( Type );
//
// where "Type" is one of:
//
const char * (Use XmRString)
//
Boolean (Use XmRBoolean)
//
int (Use XmRInt)
//
float (Use XmRFloat)
//
No argument (Use VkRNoArg or
"NoArg"
//
A filename (Use VkRFilename
or "Filename")
//
An enumeration (Use
"Enumeration:ClassName:Type: VALUE1, VALUE2, VALUE3")
//
A callback (Use XmRCallback)
static FunctionMap map[] = {
// { "resourceName",
"setAttribute", XmRString},
{ NULL }, // MUST be NULL terminated
};
return map;
} //
End RegisterBulletinBoardInterface()
//----
End of generated code