Exemplo n.º 1
0
// Documented in superclass.
void
SoXtPlaneViewer::setCamera(SoCamera * camera)
{
  Pixmap pixmap, pixmap_ins;
  if (camera == NULL) {
    // find better pixmaps for this...
    pixmap = PRIVATE(this)->pixmaps.ortho;
    pixmap_ins = PRIVATE(this)->pixmaps.ortho_ins;
  } else if (camera->isOfType(SoPerspectiveCamera::getClassTypeId())) {
    pixmap = PRIVATE(this)->pixmaps.perspective;
    pixmap_ins = PRIVATE(this)->pixmaps.perspective_ins;
    SoXtResource rsc(this->getRightWheelLabelWidget());
    char * dollyString = NULL;
    char * zoomString = NULL;
    if (
        (rsc.getResource("dollyString", XmRString, dollyString) && dollyString != NULL)
        &&
        (rsc.getResource("zoomString", XmRString, zoomString) && zoomString != NULL)
        && strcmp(zoomString,this->getRightWheelString())== 0
        )
      this->setRightWheelString(dollyString);
  } else if (camera->isOfType(SoOrthographicCamera::getClassTypeId())) {
    pixmap = PRIVATE(this)->pixmaps.ortho;
    pixmap_ins = PRIVATE(this)->pixmaps.ortho_ins;
    SoXtResource rsc(this->getRightWheelLabelWidget());
    char * dollyString = NULL;
    char * zoomString = NULL;
    if (
        (rsc.getResource("dollyString", XmRString, dollyString) && dollyString != NULL)
        &&
        (rsc.getResource("zoomString", XmRString, zoomString) && zoomString != NULL)
        && strcmp(dollyString,this->getRightWheelString())== 0
        )
      this->setRightWheelString(zoomString);
  } else {
    SoDebugError::postWarning("SoXtExaminerViewer::setCamera",
      "unknown camera type - got no pixmap");
    // find better pixmaps for this...
    pixmap = PRIVATE(this)->pixmaps.ortho;
    pixmap_ins = PRIVATE(this)->pixmaps.ortho_ins;
  }

#if HAVE_LIBXPM
  XtUnmanageChild(PRIVATE(this)->buttons[3].bwidget);
  XtVaSetValues(PRIVATE(this)->buttons[3].bwidget,
    XmNlabelType, XmPIXMAP,
    XmNlabelPixmap, pixmap,
    XmNselectPixmap, pixmap,
    XmNlabelInsensitivePixmap, pixmap_ins,
    XmNselectInsensitivePixmap, pixmap_ins,
    NULL);
  XtVaSetValues(PRIVATE(this)->buttons[3].bwidget,
    XmNwidth, 30, XmNheight, 30, NULL);
  XtManageChild(PRIVATE(this)->buttons[3].bwidget);
#endif // HAVE_LIBXPM

  inherited::setCamera(camera);
}
void ReadEV3LineTracerSetting::process(InputContext &input)
{
	//Intervalの読み取り
	ReadInterval ri(ev3LineTracer);
	ri.process(input);

	//CostMaxの読み取り
	ReadCostMax rcm(ev3LineTracer);
	rcm.process(input);

	//State数の読み取り
	ReadStateCount rsc(ev3LineTracer);
	rsc.process(input);

	//Stateの読み取り
	ReadState rs(ev3LineTracer);
	rs.process(input);

	//Controlの読み取り
	ReadControl rc(ev3LineTracer);
	rc.process(input);

	//RegularPolicyの読み取り
	ReadRegularPolicy<EV3LineTracer> rrp(ev3LineTracer);
	rrp.process(input);

	//CurrentPolicyをRegularPolicyとして設定する
	ev3LineTracer.setCurrentPolicyLocal(ev3LineTracer.getRegularPolicy());
}
Exemplo n.º 3
0
oc::result<void> selinux_lset_context_recursive(const std::string &path,
                                                const std::string &context)
{
    RecursiveSetContext rsc(path, context, false);
    if (!rsc.run()) {
        auto ret = rsc.result();
        if (ret) {
            return ec_from_errno();
        } else {
            return ret.as_failure();
        }
    }

    return rsc.result();
}
Exemplo n.º 4
0
void
SoXtExaminerViewerP::constructor(const SbBool build)
{
  this->genericConstructor();

  PUBLIC(this)->setClassName(PUBLIC(this)->getWidgetName());
  this->camerabutton = (Widget) NULL;

  if (build) {
    Widget viewer = PUBLIC(this)->buildWidget(PUBLIC(this)->getParentWidget());
    PUBLIC(this)->setBaseWidget(viewer);
    PUBLIC(this)->fitSize(SbVec2s(500, 300));

    char * dollyString = NULL;
    SoXtResource rsc(PUBLIC(this)->getRightWheelLabelWidget());
    if (rsc.getResource("dollyString", XmRString, dollyString) &&
         dollyString != NULL)
      PUBLIC(this)->setRightWheelString(dollyString);
  }
}
Exemplo n.º 5
0
// Documented in common/SoGuiGLWidgetCommon.cpp.in.
Widget
SoXtGLWidget::buildWidget(Widget parent)
{
  // This method builds the GL widget inside \a parent.  The returned
  // widget is the widget managing the GL widget and providing it with
  // a border.

#if SOXT_DEBUG && 0
  SoDebugError::postInfo("SoXtGLWidget::buildWidget", "[enter]");
#endif // SOXT_DEBUG

  PRIVATE(this)->glxmanager =
    XtVaCreateManagedWidget("SoXtRenderArea",
                            xmFormWidgetClass, parent,
                            XmNleftAttachment, XmATTACH_FORM,
                            XmNtopAttachment, XmATTACH_FORM,
                            XmNrightAttachment, XmATTACH_FORM,
                            XmNbottomAttachment, XmATTACH_FORM,
                            NULL);
  this->registerWidget(PRIVATE(this)->glxmanager);

  SoXtResource rsc(PRIVATE(this)->glxmanager);

  short width = 0;
  if (rsc.getResource("borderThickness", XmRShort, width))
    PRIVATE(this)->borderwidth = width;

  SbBool haveborder = FALSE;
  if (rsc.getResource("border", XmRBoolean, haveborder))
    PRIVATE(this)->border = haveborder;

  PRIVATE(this)->createVisual();
  PRIVATE(this)->buildGLWidget();

#if SOXT_DEBUG && 0
  SoDebugError::postInfo("SoXtGLWidget::buildWidget", "[exit]");
#endif // SOXT_DEBUG
  return PRIVATE(this)->glxmanager;
}
Exemplo n.º 6
0
void
SoXtPlaneViewerP::constructor(SbBool build)
{
  this->commonConstructor(); // generic code

  const int numbuttons = sizeof(SoXtPlaneViewerButtons) / sizeof(SoXtViewerButton);
  this->buttons = new SoXtViewerButton[numbuttons];
  memcpy(this->buttons, SoXtPlaneViewerButtons, sizeof(SoXtPlaneViewerButtons));

  PUBLIC(this)->setClassName(PUBLIC(this)->getDefaultWidgetName());

  if (build) {
    Widget viewer = PUBLIC(this)->buildWidget(PUBLIC(this)->getParentWidget());
    PUBLIC(this)->setBaseWidget(viewer);
    PUBLIC(this)->fitSize(SbVec2s(500, 300));

    SoXtResource rsc(PUBLIC(this)->getRightWheelLabelWidget());
    char * dollystring = NULL;
    rsc.getResource("dollyString", XmRString, dollystring);
    if (dollystring != NULL)
      PUBLIC(this)->setRightWheelString(dollystring);
  }
}
Exemplo n.º 7
0
int main(int argc, char ** argv)
{
  Radiant::enableVerboseOutput(true);

  Luminous::Shader red, green, blue, rings;

  /* First three ultra-simple shaders: */
  red.setFragmentShader
      ("void main(void) { gl_FragColor = vec4(1, 0, 0, 1); }");
  green.setFragmentShader
      ("void main(void) { gl_FragColor = vec4(0, 1, 0, 1); }");
  blue.setFragmentShader
      ("void main(void) { gl_FragColor = vec4(0, 0, 1, 1); }");

  /* Then something a bit more interesting. This creates rings. When the
     scale goes up, we get really cool moire-effects.
  */
  rings.setFragmentShader
      ("uniform float scale;\n"
       "void main(void) { \n"
       " vec2 offset = gl_TexCoord[0].st - vec2(0.5, 0.5);\n"
       " float val = 0.5 + 2.5 *  sin(length(offset) * scale);\n"
       " gl_FragColor = vec4(val, val, val, 1); \n"
       "}\n");

  Valuable::ValueFloat scale(0, "scale", 10.0f);
  rings.addShaderUniform( & scale);

  SDL_Init(SDL_INIT_VIDEO);

  SDL_GL_SetAttribute(SDL_GL_RED_SIZE,   8);
  SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
  SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,  8);
  SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16 );
  SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1 );

  SDL_SetVideoMode(600 , 600, 0, SDL_OPENGL);

  Luminous::initLuminous();

  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glOrtho(0, 600, 0, 600, 0, 1);
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();

  Luminous::GLResources rsc(Radiant::ResourceLocator::instance());
  Luminous::GLResources::setThreadResources( & rsc, 0, 0);
  Luminous::Utils::glUsualBlend();

  glColor3f(1.0f, 0.5f, 0.5f);

  int index = 0;

  for(bool running = true; running; ) {
    index++;

    SDL_Event event;

    if(SDL_PollEvent( & event)) {
      if(event.type == SDL_QUIT)
        running = false;
      else if((event.type == SDL_KEYDOWN) &&
         (event.key.keysym.sym == SDLK_ESCAPE))
        running = false;
    }

    glClearColor(0.f, 0.f, 0.f, 1.f);
    glClear(GL_COLOR_BUFFER_BIT);

    red.bind();
    Luminous::Utils::glTriangle(30, 30, 30, 270, 270, 70);

    green.bind();
    Luminous::Utils::glTriangle(30, 570, 30, 330, 270, 370);

    blue.bind();
    Luminous::Utils::glTriangle(330, 570, 330, 330, 570, 540);

    scale = (index % 10000);
    rings.bind();
    Luminous::Utils::glTexRect(330, 30, 570, 270);


    Luminous::Utils::glCheck("After rendering");

    SDL_GL_SwapBuffers();
#ifndef WIN32
    Radiant::Sleep::sleepMs(20);
#endif
  }

  return 0;
}
Exemplo n.º 8
0
//
// main task
//
int main(void) {

#ifdef DEBUG
	#if __USE_USB
		usbCDC ser;
		ser.connect();
	#else
		CSerial ser;
		ser.settings(115200);
	#endif
	CDebug dbg(ser);
	dbg.start();
#endif

	/*************************************************************************
	 *
	 *                         your setup code here
	 *
	 **************************************************************************/
	bleSerial ble("uCX-RSC");
	ble.enable();

	//
	// Running Speed Cadence Service
	//
	bleRSC rsc(ble);
	rsc.features(RSC_SUPPORT_STATUS);

	//
	// Battery Level Service
	//
	bleBatteryLevel bl(ble);	// declare Battery Level Service object

	float 	value;
	uint8_t level;
	CPin led(LED1);
	while(1) {
		/**********************************************************************
		 *
		 *                         your loop code here
		 *
		 **********************************************************************/
		if ( rsc.isAvailable() ) {
			// speed = 3m/s, cadence=2rpm, distance=2m
			rsc.send( RSC_SPEED_KMH(6.5), 50, RSC_RUNNING);
		}

		if ( bl.isAvailable() ) {
			if ( bl.readSystemVoltage(value) ) {
				if ( value>=2.4 && value<=3.6 ) {
					level =  map(value, 2.0, 3.3, 0, 100);
					bl.sendBatteryLevel(level);
				}
			}
		}

		led = !led;
		sleep(500);
	}
    return 0 ;
}
Exemplo n.º 9
0
// Documented in superclass.
void
SoXtExaminerViewer::setCamera(SoCamera * camera)
{
#if SOXT_DEBUG && 0
  SoDebugError::postInfo("SoXtExaminerViewer::setCamera", "[enter]");
#endif // SOXT_DEBUG
  Pixmap pixmap, pixmap_ins;
  if (camera == NULL) {
    // find better pixmaps for this...
    pixmap = PRIVATE(this)->camerapixmaps.ortho;
    pixmap_ins = PRIVATE(this)->camerapixmaps.ortho_ins;
  } else if (camera->isOfType(SoPerspectiveCamera::getClassTypeId())) {
    pixmap = PRIVATE(this)->camerapixmaps.perspective;
    pixmap_ins = PRIVATE(this)->camerapixmaps.perspective_ins;
    SoXtResource rsc(this->getRightWheelLabelWidget());
    char * dollyString = NULL;
    char * zoomString = NULL;
    if (
        (rsc.getResource("dollyString", XmRString, dollyString) && dollyString != NULL)
        &&
        (rsc.getResource("zoomString", XmRString, zoomString) && zoomString != NULL)
        && strcmp(zoomString,this->getRightWheelString())== 0
        )
      this->setRightWheelString(dollyString);
  } else if (camera->isOfType(SoOrthographicCamera::getClassTypeId())) {
    pixmap = PRIVATE(this)->camerapixmaps.ortho;
    pixmap_ins = PRIVATE(this)->camerapixmaps.ortho_ins;
    SoXtResource rsc(this->getRightWheelLabelWidget());
    char * dollyString = NULL;
    char * zoomString = NULL;
    if (
        (rsc.getResource("dollyString", XmRString, dollyString) && dollyString != NULL)
        &&
        (rsc.getResource("zoomString", XmRString, zoomString) && zoomString != NULL)
        && strcmp(dollyString,this->getRightWheelString())== 0
        )
      this->setRightWheelString(zoomString);
  } else {
    SoDebugError::postWarning("SoXtExaminerViewer::setCamera",
      "unknown camera type - got no pixmap");
    // find better pixmaps for this...
    pixmap = PRIVATE(this)->camerapixmaps.ortho;
    pixmap_ins = PRIVATE(this)->camerapixmaps.ortho_ins;
  }

#if HAVE_LIBXPM
  SbBool extra = XtIsRealized(PRIVATE(this)->camerabutton) ? TRUE : FALSE;

  if (extra) {
    XtUnmapWidget(PRIVATE(this)->camerabutton);
    XtUnrealizeWidget(PRIVATE(this)->camerabutton);
  }
  if (pixmap) {
    XtVaSetValues(PRIVATE(this)->camerabutton,
                  XmNlabelType, XmPIXMAP,
                  XmNlabelPixmap, pixmap,
                  XmNselectPixmap, pixmap,
                  XmNlabelInsensitivePixmap, pixmap_ins,
                  XmNselectInsensitivePixmap, pixmap_ins,
                  NULL);
    XtVaSetValues(PRIVATE(this)->camerabutton,
                  XmNwidth, 30,
                  XmNheight, 30,
                  NULL);
  }
  if (extra) {
    XtRealizeWidget(PRIVATE(this)->camerabutton);
    XtMapWidget(PRIVATE(this)->camerabutton);
  }
#endif // HAVE_LIBXPM

  inherited::setCamera(camera);
#if SOXT_DEBUG && 0
  SoDebugError::postInfo("SoXtExaminerViewer::setCamera", "[exit]");
#endif // SOXT_DEBUG
}
// TEMP METHOD: This should be removed when JVMCI is in place.
void CompilationScope::resolve_string_constants(TRAPS) {  
  ResolveStringsClosure rsc(this, THREAD);
  iterate(&rsc);
  // Could have a pending exception at this point
}