本文整理汇总了C++中SimpleGUI类的典型用法代码示例。如果您正苦于以下问题:C++ SimpleGUI类的具体用法?C++ SimpleGUI怎么用?C++ SimpleGUI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SimpleGUI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SimpleGUI
void ScheinrieseApp::setup()
{
// GUI
mGui = new SimpleGUI(this);
mGui->addColumn();
mGui->addLabel("CONTROLS");
mGui->addParam("Threshold", &mThreshold, 0, 255, 127);
mGui->addParam("Blur", &mBlur, 1, 20, 1);
mGui->addParam("Tilt", &mKinectTilt, -30, 30, 0);
mGui->addColumn();
mGui->addLabel("DEBUG VIEW");
mGui->addParam("Show Debug", &mShowDebug, true);
// mGui->addButton("Show Debug")->registerClick(this, &ScheinrieseApp::showDebug);
mGui->load(getResourcePath(RES_SETTINGS));
mGui->setEnabled(false);
mBlur = 1;
mThreshold = 127;
mShowDebug = true;
// KINECT
hasKinect = false;
console() << "### INFO: There are " << Kinect::getNumDevices() << " Kinects connected." << endl;
if (Kinect::getNumDevices() >= 1) {
mKinect = Kinect( Kinect::Device() );
mKinect.setTilt(mKinectTilt);
hasKinect = true;
}
}
示例2: getWindowHeight
void ButtonsAndTexturesApp::setup() {
rotation = 0;
screenshot = gl::Texture(getWindowWidth(), getWindowHeight()); //uninitialized texture with random pixels from GPU memory
gui = new SimpleGUI(this);
gui->lightColor = ColorA(1, 1, 0, 1);
gui->addLabel("CONTROLS");
//let's add a button
gui->addButton("Restart")->registerClick(this, &ButtonsAndTexturesApp::restartButtonClick);
gui->addSeparator();
gui->addLabel("SCREENSHOT");
screenshotTextureControl = gui->addParam("Screenshot", &screenshot);
//you can also store reference to it and add callback as a second step
takeScreenshotButton = gui->addButton("Take screenshot");
cbTakeScreenshotButtonClick = takeScreenshotButton->registerClick(this, &ButtonsAndTexturesApp::takeScreenshotButtonClick);
//to stop listening to click do this:
//takeScreenshotButton->unregisterClick(cbTakeScreenshotButtonClick);
gui->load(CONFIG_FILE); //we load settings after specifying all the
//params because we need to know their name and type
timer.start();
prevTime = timer.getSeconds();
}
示例3: console
void GesichtertauschApp::setup() {
console() << "+++ Gesichtertausch (PID " << getpid() << ")." << endl;
mTime = 0.0;
mSerialID = 0;
FACE_COLOR_UNO = ColorA(0, 1, 1, 1);
FACE_COLOR_DUO = ColorA(1, 0, 0, 1);
BACKGROUND_IMAGE_COLOR = ColorA(1, 1, 1, 1);
/* watchdog */
mWatchdogHost = "localhost";
mWatchdogPort = 8080;
mWatchdogSender.setup(mWatchdogHost, mWatchdogPort);
mWatchdogCounter = 0.0;
mWatchdogInterval = 2.5;
/* shader */
try {
mShader = gl::GlslProg( loadResource( RES_PASSTHRU_VERT ), loadResource( RES_BLUR_FRAG ) );
}
catch( gl::GlslProgCompileExc &exc ) {
console() << "Shader compile error: " << std::endl;
console() << exc.what();
}
catch( ... ) {
console() << "Unable to load shader" << std::endl;
}
/* settings */
mGui = new SimpleGUI(this);
mGui->addParam("WINDOW_WIDTH", &WINDOW_WIDTH, 0, 2048, 640);
mGui->addParam("WINDOW_HEIGHT", &WINDOW_HEIGHT, 0, 2048, 480);
mGui->addParam("CAMERA_WIDTH", &CAMERA_WIDTH, 0, 2048, 640);
mGui->addParam("CAMERA_HEIGHT", &CAMERA_HEIGHT, 0, 2048, 480);
mGui->addParam("DETECTION_WIDTH", &DETECTION_WIDTH, 0, 2048, 320);
mGui->addParam("DETECTION_HEIGHT", &DETECTION_HEIGHT, 0, 2048, 240);
mGui->addParam("FULLSCREEN", &FULLSCREEN, false, 0);
mGui->addParam("TRACKING", &TRACKING, 0, 1, 0);
//
mGui->addParam("FRAME_RATE", &FRAME_RATE, 1, 120, 30);
mGui->addParam("MIN_TRACKING_DISTANCE", &MIN_TRACKING_DISTANCE, 1, 100, 50);
mGui->addParam("TIME_BEFOR_IDLE_DEATH", &TIME_BEFOR_IDLE_DEATH, 0, 10, 0.5);
mGui->addParam("MIN_LIFETIME_TO_VIEW", &MIN_LIFETIME_TO_VIEW, 0, 10, 1.0);
mGui->addParam("ENABLE_SHADER", &ENABLE_SHADER, 0, 1, 0);
mGui->addParam("FACE_COLOR_UNO", &FACE_COLOR_UNO, ColorA(0, 1, 1, 1), SimpleGUI::RGB);
mGui->addParam("FACE_COLOR_DUO", &FACE_COLOR_DUO, ColorA(1, 1, 1, 1), SimpleGUI::RGB);
mGui->addParam("BACKGROUND_IMAGE_COLOR", &BACKGROUND_IMAGE_COLOR, ColorA(1, 1, 1, 1), SimpleGUI::RGB);
mGui->addParam("FACE_BORDER_SCALE", &FACE_BORDER_SCALE, 0, 3, 0.7);
mGui->addParam("FACE_FADE_BORDER_SCALE", &FACE_FADE_BORDER_SCALE, 1, 2, 1.4);
/* clean up controller window */
mGui->getControlByName("WINDOW_WIDTH")->active=false;
mGui->getControlByName("WINDOW_HEIGHT")->active=false;
mGui->getControlByName("CAMERA_WIDTH")->active=false;
mGui->getControlByName("CAMERA_HEIGHT")->active=false;
mGui->getControlByName("DETECTION_WIDTH")->active=false;
mGui->getControlByName("DETECTION_HEIGHT")->active=false;
mGui->getControlByName("FULLSCREEN")->active=false;
mGui->getControlByName("TRACKING")->active=false;
mGui->getControlByName("BACKGROUND_IMAGE_COLOR")->active=false;
mGui->getControlByName("BACKGROUND_IMAGE_COLOR")->active=false;
mGui->load(getResourcePath(RES_SETTINGS));
mGui->setEnabled(false);
setWindowSize( WINDOW_WIDTH, WINDOW_HEIGHT );
setFullScreen( FULLSCREEN );
if (FULLSCREEN) {
hideCursor();
// switch_resolution (WINDOW_WIDTH, WINDOW_HEIGHT, 60.0);
}
mFont = Font(loadResource("pf_tempesta_seven.ttf"), 8);
/* setting up capture device */
mCameraTexture = gl::Texture(CAMERA_WIDTH, CAMERA_HEIGHT);
switch (TRACKING) {
case 0:
mFaceDetection = new FeatureDetectionCinder();
break;
#ifdef COMPILE_CAPTURE_FIREFLY
case 1:
mFaceDetection = new FeatureDetectionFireFly();
break;
#endif
#ifdef COMPILE_CAPTURE_OPENCV
case 2:
mFaceDetection = new FeatureDetectionOpenCV();
break;
#endif
default:
console() << "### choosing default tracking method." << endl;
mFaceDetection = new FeatureDetectionCinder();
break;
}
mGui->addParam("DETECT_FLAGS",&(mFaceDetection->DETECT_FLAGS), CV_HAAR_DO_CANNY_PRUNING, CV_HAAR_DO_ROUGH_SEARCH, CV_HAAR_DO_CANNY_PRUNING);
mGui->addParam("DETECT_SCALE_FACTOR",&(mFaceDetection->DETECT_SCALE_FACTOR), 1.1, 5, 1.2);
mGui->addParam("DETECT_MIN_NEIGHBORS",&(mFaceDetection->DETECT_MIN_NEIGHBORS), 1, 20, 2);
//.........这里部分代码省略.........
示例4: getWindowHeight
void RogersGuiApp::setup() {
rotation = 0;
screenshot = gl::Texture(getWindowWidth(), getWindowHeight()); //uninitialized texture with random pixels from GPU memory
IntVarControl *ic;
BoolVarControl *bc;
PanelControl *pc;
ByteVarControl *btc;
FlagVarControl *fc;
aString = "whatever";
gui = new SimpleGUI(this);
gui->lightColor = ColorA(1, 1, 0, 1);
gui->addColumn();
gui->addLabel("> READ ONLY");
gui->addSeparator();
gui->addLabel("READONLY");
gui->addParam("String", &aString); // !NEW! Update aString will update label
gui->addParam("Window Width", &windowWidth, 0, 1920, getWindowWidth())->setReadOnly(); // !NEW! No slider, just value
gui->addParam("Window Height", &windowHeight, 0, 1080, getWindowHeight())->setReadOnly(); // !NEW! No slider, just value
gui->addParam("FPS", &FPS, 0, 60, 0)->setReadOnly(); // !NEW! No slider, just value
gui->addSeparator();
// Textures
gui->addLabel("> TEXTURES");
gui->addSeparator();
takeScreenshotButton = gui->addButton("Take screenshot");
takeScreenshotButton->registerClick(this, &RogersGuiApp::takeScreenshotButtonClick);
screenshotTextureControl = gui->addParam("Screenshot", &screenshot);
screenshotTextureControl->refreshRate = 0.0; // !NEW! let's refresh manually
//screenshotTextureControl->refreshRate = 0.1; // !NEW! use this for movies or syphon
//takeScreenshotButton->unregisterClick(cbTakeScreenshotButtonClick);
gui->addSeparator();
gui->addParam("Null Texture example", &nullTex); // !NEW! Null textures will be marked so
//
// ROGER:: From Grouping example
gui->addColumn();
gui->addLabel("> CONTROLS");
gui->addSeparator();
gui->addButton("Restart Animation")->registerClick(this, &RogersGuiApp::restartButtonClick);
bc = gui->addParam("Auto Rotation ON", &autoRotation, true);
bc->nameOff = "Auto Rotation OFF"; // !NEW! Alternative label when OFF
gui->addParam("Rotation", &rotation, 0, 360, 0)->setDisplayValue();
gui->addParam("Size", &size, 100, 600, 200)->setDisplayValue();
gui->addParam("Background", &colorBack, Color(0.1, 0.1, 0.5), SimpleGUI::RGB); //use R,G,B,A sliders
gui->addParam("Color", &color, ColorA(1, 0.2, 0.2, 0.1), SimpleGUI::RGB); //use R,G,B,A sliders
gui->addParam("HSV", &colorBackHSV, Color(0.1, 0.1, 0.5), SimpleGUI::HSV);
gui->addParam("HSV+A", &colorHSV, ColorA(1, 0.2, 0.2, 0.1), SimpleGUI::HSV);
gui->addSeparator();
gui->addLabel("RENDER TYPE");
gui->addParam("Fill", &fill, true, RENDER_TYPE_GROUP); //if we specify group id, we create radio button set
bc = gui->addParam("Stroke", &stroke, false, RENDER_TYPE_GROUP); //i.e. only one of the buttons can be active at any time
pc = gui->addPanel();
bc->switchPanel( pc ); // !NEW! Automatically open/close a panel
gui->addParam("Thickness", &thickness, 1, 10);
//
// LIST CONTROL
gui->addColumn();
gui->addLabel("> LISTS");
gui->addSeparator();
gui->addButton("Increase List")->registerClick(this, &RogersGuiApp::addToList);
gui->addButton("Decrease List")->registerClick(this, &RogersGuiApp::removeFromList);
valueLabels[0] = "val 0";
valueLabels[1] = "val 1";
valueLabels[2] = "val 2";
gui->addSeparator();
theDropDownControl = gui->addParamDropDown("Drop-Down List", &listVal, valueLabels); // !NEW! Drop-Down control
gui->addSeparator();
theListControl = gui->addParamList("Explicit List", &listVal, valueLabels); // !NEW! List control
gui->addSeparator();
gui->addLabel("just a label");
//
// INTS CONTROL
gui->addColumn();
gui->addLabel("> INTS");
gui->addSeparator();
gui->addParam("Int Radio (<=10)", &intValue1, 1, 3, 0)->setDisplayValue(); // !NEW! small int range will be displayed as radios
gui->addParam("Int Radio (<=10)", &intValue2, 1, 10, 0)->setDisplayValue(); // !NEW! small int range will be displayed as radios
gui->addParam("Int slider (>10)", &intValue3, 1, 11, 0)->setDisplayValue(); // !NEW! Display the value beside labels
// stepped
gui->addSeparator();
ic = gui->addParam("Int Step 2", &intValue4, 0, 10, 0);
ic->setDisplayValue();
ic->setStep(2); // !NEW! int step
ic = gui->addParam("Int Step 2", &intValue5, 0, 18, 0);
ic->setDisplayValue();
ic->setStep(2); // !NEW! int step
ic = gui->addParam("Int Step 2", &intValue6, 0, 20, 0);
ic->setDisplayValue();
ic->setStep(2); // !NEW! int step
//
// BYTE CONTROL
gui->addColumn();
gui->addLabel("> BYTES");
gui->addSeparator();
gui->addParam("Byte", &byteValue1, 0)->setDisplayValue(); // !NEW! ranges from 0-255
btc = gui->addParam("Byte as char", &byteValue2, 0); // !NEW! display as char
//.........这里部分代码省略.........
示例5: getWindowHeight
void GroupingApp::setup() {
fbo = gl::Fbo(getWindowWidth(), getWindowHeight());
gui = new SimpleGUI(this, Font(loadResource(RES_SGUI_FONT), 8));
gui->lightColor = ColorA(1, 1, 0, 1);
gui->addColumn();
gui->addLabel("CONTROLS");
gui->addParam("Rotation", &rotation, 0, 360, 0);
gui->addParam("Size", &size, 100, 600, 200);
gui->addParam("Color", &color, ColorA(0,0.5,1,0.5), SimpleGUI::RGB); //use R,G,B,A sliders
gui->addColumn();
gui->addLabel("RENDER TYPE");
gui->addParam("Fill", &fill, true, RENDER_TYPE_GROUP); //if we specify group id, we create radio button set
gui->addParam("Stroke", &stroke, false, RENDER_TYPE_GROUP); //i.e. only one of the buttons can be active at any time
strokePanel = gui->addPanel();
gui->addParam("Thickness", &thickness, 1, 10);
gui->addColumn();
gui->addLabel("OPTIONS");
gui->addParam("Auto Rotation", &autoRotation, false);
gui->addColumn();
gui->addLabel("PREVIEW");
gui->addParam("PreviewTex", &fbo.getTexture());
gui->load(CONFIG_FILE); //we load settings after specifying all the
//params because we need to know their name and type
timer.start();
prevTime = timer.getSeconds();
}
示例6: handleKinect
void ScheinrieseApp::handleKinect()
{
if (!hasKinect) {
return;
}
if( mKinectTilt != mKinect.getTilt() ) {
mKinect.setTilt( mKinectTilt );
}
if( mKinect.checkNewDepthFrame() ) {
mDepthTexture = mKinect.getDepthImage();
}
if( mKinect.checkNewVideoFrame() ) {
mColorTexture = mKinect.getVideoImage();
}
/* debug view */
if (mColorTexture && !mDebugViewColor) {
mGui->addLabel("COLOR");
mDebugViewColor = mGui->addParam("COLOR", &mColorTexture);
mDebugViewColor->var = &mColorTexture;
console() << "color" << endl;
}
if (mDepthTexture && !mDebugViewDepth) {
mGui->addLabel("DEPTH");
mDebugViewDepth = mGui->addParam("DEPTH", &mDepthTexture);
mDebugViewDepth->var = &mDepthTexture;
console() << "depth" << endl;
}
}
示例7: keyDown
void RogersGuiApp::keyDown( KeyEvent event ) {
switch(event.getChar()) {
case 'd': gui->dump(); break; //prints values of all the controls to the console
case 'l': gui->load(CONFIG_FILE); break;
case 's': gui->save(CONFIG_FILE); break;
}
switch(event.getCode()) {
case KeyEvent::KEY_ESCAPE: quit(); break;
}
}
示例8: draw
void ButtonsAndTexturesApp::draw(){
float currTime = timer.getSeconds();
float deltaTime = currTime - prevTime;
prevTime = currTime;
rotation += deltaTime/2;
gl::clear(ColorA(0.1, 0.1, 0.5, 0.92));
gl::enableAdditiveBlending();
gl::disableDepthRead();
gl::pushMatrices();
gl::translate(Vec3f(getWindowWidth()/2, getWindowHeight()/2, 0));
gl::color(ColorA(1, 0.2, 0.2, 0.1));
for(int i=0;i<50; i++) {
gl::rotate(Vec3f(0, 0, rotation));
gl::drawSolidRect(Rectf(20, 20, 140, 140));
}
gl::color(ColorA(0.5, 0.25, 0.0, 0.05));
for(int i=0;i<50; i++) {
gl::rotate(Vec3f(0, 0, rotation/4));
gl::drawSolidRect(Rectf(50, 50, 340, 340));
}
gl::enableDepthRead();
gl::disableAlphaBlending();
gl::popMatrices();
gui->draw();
}
示例9: draw
void RogersGuiApp::draw(){
float currTime = timer.getSeconds();
float deltaTime = currTime - prevTime;
prevTime = currTime;
if (autoRotation)
rotation += deltaTime/2;
gl::clear( colorBack );
gl::enableAdditiveBlending();
gl::disableDepthRead();
gl::pushMatrices();
gl::translate(Vec3f(getWindowWidth()/2, getWindowHeight()/2, 0));
gl::color( color );
for(int i=0;i<50; i++) {
gl::rotate(Vec3f(0, 0, rotation));
gl::drawSolidRect(Rectf(20, 20, 140, 140));
}
gl::color(ColorA(0.5, 0.25, 0.0, 0.05));
for(int i=0;i<50; i++) {
gl::rotate(Vec3f(0, 0, rotation/4));
gl::drawSolidRect(Rectf(50, 50, 340, 340));
}
gl::enableDepthRead();
gl::disableAlphaBlending();
gl::popMatrices();
FPS = getAverageFps();
gui->draw();
//std::cout << "LIST = " << listVal << std::endl;
}
示例10:
void CALLBACK
OnGUIEvent(int ID)
{
switch(ID)
{
case PLACE_TOWER:
gui.GetButton(PLACE_TOWER)->SetPressed(true);
return;
}
}
示例11: draw
void ScheinrieseApp::draw()
{
gl::clear( Color( 0, 0, 0 ) );
gl::setMatricesWindow( getWindowWidth(), getWindowHeight() );
glColor3f( 1.0f, 1.0f, 1.0f );
/* debug view */
drawDebug();
// glPushMatrix();
// for (int i = 0; i < mContours.size(); i++) {
// glColor3f(0.0f,1.0f,1.0f);
// glBegin( GL_LINE_STRIP );
// for (int j = 0; j < mContours[i].size(); j+=10) {
// glVertex2f( mContours[i][j].x, mContours[i][j].y);
// }
// glEnd();
// }
// glPopMatrix();
/*
//for (int i = 0; i < mContours.size(); i++) {
// vector<p2t::Point*> polyline;
// for (int j = 0; j < mContours[i].size(); j+=1) {
// polyline.push_back(new p2t::Point(mContours[i][j].x, mContours[i][j].y));
// }
// if (polyline.size() > 9) {
// cout << "Number of line points = " << polyline.size() << endl;
// CDT* cdt = new CDT(polyline);
// cdt->Triangulate();
// //vector<p2t::Triangle*> triangles = cdt->GetTriangles();
// //cout << "Number of triangles = " << triangles.size() << endl;
// }
// }
gl::setMatricesWindow( getWindowWidth(), getWindowHeight() );
glPushMatrix();
glTranslatef(200,200,0);
GLdouble quad1[4*3] = { -100,300,0, 0,0,0, 100,300,0, 0,200,0 };
tessellate(quad1, 12);
glPopMatrix();
for (int i = 0; i < mContours.size(); i++) {
gl::setMatricesWindow( getWindowWidth(), getWindowHeight() );
glPushMatrix();
for (int j = 0; j < mContours[i].size(); j+=1) {
}
glPopMatrix();
}
*/
// GUI
mGui->draw();
}
示例12: keyDown
void GesichtertauschApp::keyDown( KeyEvent pEvent ) {
switch(pEvent.getChar()) {
case 'd': mGui->dump(); break;
case 'l': mGui->load(getResourcePath(RES_SETTINGS)); break;
case 's': mGui->save(getResourcePath(RES_SETTINGS)); break;
// case 'm':
// CGDirectDisplayID mDisplayID = getSettings().getDisplay()->getCGDirectDisplayID();
// CGDisplayConfigRef pConfigRef;
// CGBeginDisplayConfiguration (&pConfigRef);
// CGConfigureDisplayOrigin (pConfigRef,
// mDisplayID,
// -100, 0);
// CGCompleteDisplayConfiguration (pConfigRef, kCGConfigureForAppOnly);
// break;
}
switch(pEvent.getCode()) {
case KeyEvent::KEY_ESCAPE: setFullScreen( false ); quit(); break;
case KeyEvent::KEY_SPACE: mGui->setEnabled(!mGui->isEnabled());break;
}
}
示例13: keyDown
void RogalarmApp::keyDown( KeyEvent event )
{
if( event.getChar() == 'f' ){
mFullscreen = !mFullscreen;
setFullScreen(mFullscreen);
} else if( event.getChar() == 'p' ){
cout << "User Position = " << mUserPos << endl;
} else if( event.getChar() == 'd' ){
mGui->dump();
}
}
示例14: keyDown
void ScheinrieseApp::keyDown( KeyEvent event )
{
switch(event.getChar()) {
case 'd':
mGui->dump();
break;
case 'l':
mGui->load(getResourcePath(RES_SETTINGS));
break;
case 's':
mGui->save(getResourcePath(RES_SETTINGS));
break;
}
switch(event.getCode()) {
case KeyEvent::KEY_ESCAPE:
quit();
break;
case KeyEvent::KEY_SPACE:
mGui->setEnabled(!mGui->isEnabled());
}
}
示例15: draw
void GroupingApp::draw() {
float currTime = timer.getSeconds();
float deltaTime = currTime - prevTime;
prevTime = currTime;
if (autoRotation) {
rotation += deltaTime * 60;
rotation = fmod(rotation, 360);
}
fbo.bindFramebuffer();
gl::pushMatrices();
gl::clear(ColorA(0.2, 0.2, 0.2, 1.0));
gl::translate(Vec2f(getWindowWidth()/2, getWindowHeight()/2));
gl::rotate(rotation);
gl::color(color);
gl::enableAlphaBlending();
gl::disableDepthRead();
if (fill) {
gl::translate(Vec2f(-50, -50));
gl::drawSolidRect(Rectf(-size/2, -size/2, size/2, size/2));
gl::translate(Vec2f(+100, +100));
gl::drawSolidRect(Rectf(-size/2, -size/2, size/2, size/2));
}
else if (stroke) {
glLineWidth(thickness);
gl::translate(Vec2f(-50, -50));
gl::drawLine(Vec2f(-size/2, -size/2), Vec2f( size/2, -size/2));
gl::drawLine(Vec2f( size/2, -size/2), Vec2f( size/2, size/2));
gl::drawLine(Vec2f( size/2, size/2), Vec2f(-size/2, size/2));
gl::drawLine(Vec2f(-size/2, size/2), Vec2f(-size/2, -size/2));
gl::translate(Vec2f(+100, +100));
gl::drawLine(Vec2f(-size/2, -size/2), Vec2f( size/2, -size/2));
gl::drawLine(Vec2f( size/2, -size/2), Vec2f( size/2, size/2));
gl::drawLine(Vec2f( size/2, size/2), Vec2f(-size/2, size/2));
gl::drawLine(Vec2f(-size/2, size/2), Vec2f(-size/2, -size/2));
glLineWidth(1);
}
gl::popMatrices();
fbo.unbindFramebuffer();
gl::color(ColorA(1,1,1,1));
gl::draw(fbo.getTexture());
strokePanel->enabled = stroke ? true : false;
gui->draw();
}