reza UI framerate issue when used in class

Hello,

I’m very new to OF and c++ programming. I started with it because I want to make a UI for my f-box, a synthesizer of which the sound is influenced by the growth of mold (the mold is captured by a usb-microscope, color- and edge detection provide me of parameters). http://www.daviddebuyser.be/f-box

Very quickly I found reza ali’s excellent UI and I decided to use it for my f-box. It works fine when I implement it in my testApp.cpp and testApp.h, but when I put the code in a class (like osc.cpp and osc.h), the framerate of the reza UI drops to 0.

After almost 2 days of googleling, I still do not have a solution. Can anyone help?

Thx, David

This is my code:

testApp.h

  
#pragma once  
  
#include "ofMain.h"  
#include "flt.h"  
#include "osc.h"  
#include "ofxUI.h"  
#include "cam.h"  
  
class testApp : public ofBaseApp{  
	public:  
		void setup();  
		void update();  
		void draw();  
		  
        void keyPressed(int key);  
		void keyReleased(int key);  
		void mouseMoved(int x, int y);  
		void mouseDragged(int x, int y, int button);  
		void mousePressed(int x, int y, int button);  
		void mouseReleased(int x, int y, int button);  
		void windowResized(int w, int h);  
		void dragEvent(ofDragInfo dragInfo);  
		void gotMessage(ofMessage msg);  
      
        void regEff();  
        void regFlt();  
        void regOsc();  
      
        bool m_oscPressed;  
        bool m_fltPressed;  
        bool m_effPressed;  
      
      
        int btn;  
      
        osc                 myOsc;  
        flt                 myFlt;  
        cam                 myCam;  
};  
  

testApp.cpp

  
#include "testApp.h"  
//#include "ofxUIFPS.h"  
#include "cam.h"  
  
//--------------------------------------------------------------  
void testApp::setup(){  
      
    //myCam.setup();  
      
    btn = 0;  
  
}  
  
//--------------------------------------------------------------  
void testApp::update(){  
      
    ofBackground(100,100,100);  
      
    int x = mouseX;  
    int y = mouseY;  
      
    if (x < 256 && y < 256) {  
          
        btn = 1;  
        cout << "1" << endl;  
          
    }  
      
    else if (x < 256 && y > 256 && y < 512) {  
          
        btn = 2;  
        cout << "2" << endl;  
          
    }  
      
    else if (x < 256 && y > 512 && y < 768) {  
          
        btn = 3;  
        cout << "3" << endl;  
          
    }  
      
    if (m_oscPressed == TRUE) {  
          
        myOsc.setup();  
        myOsc.draw();  
          
    }  
      
    else if (m_fltPressed == TRUE) {  
          
          
    }  
      
    else if (m_effPressed == TRUE) {  
          
          
    }  
      
    else  
          
              
    myCam.update();  
	  
}  
  
//--------------------------------------------------------------  
void testApp::draw(){  
      
    myCam.draw();  
      
    string str = "framerate is ";  
    str += ofToString(ofGetFrameRate(), 2)+"fps";  
    ofSetWindowTitle(str);  
  
}  
  

osc.h

  
#ifndef f_GUI_osc_h  
#define f_GUI_osc_h  
  
#include "ofMain.h"  
#include "ofxUI.h"  
  
class osc {  
      
public:  
      
    //methods  
      
    void setup();  
    void update();  
    void draw();  
      
    void keyPressed(int key);  
      
    void guiEvent(ofxUIEventArgs &e);  
    void exit();  
      
    //constructor  
      
    osc();  
      
    //variables  
      
    ofxUICanvas *gui;  
    bool drawPadding;  
      
};  
#endif  
  

osc.cpp

  
#include "osc.h"  
  
osc::osc() {  
      
    //ofSetColor(ofColor::white);  
    //ofFill();  
    //ofRect(0, 0, 1024, 768);  
      
}  
  
void osc::setup(){  
      
    //ofSetColor(ofColor::white);  
    //ofFill();  
    //ofRect(0, 0, 1024, 768);  
      
      
    // UI code  
      
    ofSetVerticalSync(true);  
	ofEnableSmoothing();  
    ofBackground(0);  
	  
	float dim = 32;  
	float xInit = OFX_UI_GLOBAL_WIDGET_SPACING;  
    float length = 320-xInit;  
	  
    drawPadding = false;  
      
    gui = new ofxUICanvas(0,0,800,600);  
    gui->setDrawBack(false);  
  
    ofColor paddingColor = ofColor(255,0,0,200);  
      
	ofxUIWidget *w = (ofxUILabel *) gui->addWidgetDown(new ofxUILabel(length-xInit,"SLIDER WIDGETS", OFX_UI_FONT_LARGE));  
    w->setColorPadded(paddingColor);  
    paddingColor.setHue(paddingColor.getHue()+5);  
      
    w = gui->addSpacer(length-xInit, 2);  
    w->setColorPadded(paddingColor);  
    paddingColor.setHue(paddingColor.getHue()+5);  
      
	w = gui->addWidgetDown(new ofxUILabel(length-xInit,"HORIZONTAL SLIDERS", OFX_UI_FONT_MEDIUM));  
    w->setColorPadded(paddingColor);  
    paddingColor.setHue(paddingColor.getHue()+5);  
      
    w = gui->addWidgetDown(new ofxUILabel(length-xInit,"FPS SLIDER", OFX_UI_FONT_MEDIUM));  
    w->setColorPadded(paddingColor);  
    paddingColor.setHue(paddingColor.getHue()+5);  
      
    w = gui->addFPSSlider("FPS SLIDER", length-xInit, dim/2.0, 60.0);  
    w->setColorPadded(paddingColor);  
    paddingColor.setHue(paddingColor.getHue()+5);  
      
    w = gui->addSpacer(length-xInit, 2);  
    w->setColorPadded(paddingColor);  
    paddingColor.setHue(paddingColor.getHue()+5);  
      
    w = gui->addSlider("NORMAL SLIDER", 0.0, 100, 50, length-xInit,dim);  
    w->setColorPadded(paddingColor);  
    paddingColor.setHue(paddingColor.getHue()+5);  
      
    w = gui->addWidgetDown(new ofxUIMinimalSlider(length-xInit, 0, 100, 50.0, "MINIMAL", OFX_UI_FONT_MEDIUM));  
    w->setColorPadded(paddingColor);  
    paddingColor.setHue(paddingColor.getHue()+5);  
      
    w = gui->addSpacer(length-xInit, 2);  
    w->setColorPadded(paddingColor);  
    paddingColor.setHue(paddingColor.getHue()+5);  
      
	w = gui->addWidgetDown(new ofxUILabel(length-xInit,"BILABEL SLIDER", OFX_UI_FONT_MEDIUM));  
    w->setColorPadded(paddingColor);  
    paddingColor.setHue(paddingColor.getHue()+5);  
      
    w = gui->addWidgetDown(new ofxUIBiLabelSlider(length-xInit, 0, 100, 50, "BILABEL SLIDER", "HOT", "COLD", OFX_UI_FONT_MEDIUM));  
    w->setColorPadded(paddingColor);  
    paddingColor.setHue(paddingColor.getHue()+5);  
      
    w = gui->addSpacer(length-xInit, 2);  
	w->setColorPadded(paddingColor);  
    paddingColor.setHue(paddingColor.getHue()+5);  
      
    w = gui->addWidgetDown(new ofxUILabel(length-xInit, "RANGE SLIDER", OFX_UI_FONT_MEDIUM));  
	w->setColorPadded(paddingColor);  
    paddingColor.setHue(paddingColor.getHue()+5);  
      
    w = gui->addWidgetDown(new ofxUIRangeSlider(length-xInit,dim, 0.0, 255.0, 50.0, 100.0, "RSLIDER"));  
    w->setColorPadded(paddingColor);  
    paddingColor.setHue(paddingColor.getHue()+5);  
      
    w = gui->addSpacer(length-xInit, 2);  
	w->setColorPadded(paddingColor);  
    paddingColor.setHue(paddingColor.getHue()+5);  
      
    w = gui->addWidgetDown(new ofxUILabel(length-xInit, "CIRCLE SLIDER", OFX_UI_FONT_MEDIUM));  
	w->setColorPadded(paddingColor);  
    paddingColor.setHue(paddingColor.getHue()+5);  
      
    w = gui->addWidgetDown(new ofxUICircleSlider((length-xInit*2.5)/2.0, 0, 100, 50, "SOUTH NORTH", OFX_UI_FONT_MEDIUM));  
    w->setColorPadded(paddingColor);  
    paddingColor.setHue(paddingColor.getHue()+5);  
      
    w = gui->addWidgetRight(new ofxUICircleSlider((length-xInit*2.5)/2.0, 0, 100, 50, "WEST EAST", OFX_UI_FONT_MEDIUM));  
    w->setColorPadded(paddingColor);  
    paddingColor.setHue(paddingColor.getHue()+5);  
      
    ofxUICircleSlider *cslider2 = (ofxUICircleSlider *) gui->getWidget("WEST EAST");  
    cslider2->setInputDirection(OFX_UI_DIRECTION_WESTEAST);  
      
    w = gui->addSpacer(length-xInit, 2);  
	w->setColorPadded(paddingColor);  
    paddingColor.setHue(paddingColor.getHue()+5);  
      
    w = gui->addWidgetDown(new ofxUILabel(length-xInit, "2D PAD", OFX_UI_FONT_MEDIUM));  
	w->setColorPadded(paddingColor);  
    paddingColor.setHue(paddingColor.getHue()+5);  
      
    w = gui->addWidgetDown(new ofxUI2DPad(length-xInit, 160, ofPoint((length-xInit)*.5,190*.5), "PAD"));  
    w->setColorPadded(paddingColor);  
    paddingColor.setHue(paddingColor.getHue()+5);  
      
    gui->setWidgetColor(OFX_UI_WIDGET_COLOR_BACK, ofColor(0,25));  
    gui->setWidgetColor(OFX_UI_WIDGET_COLOR_OUTLINE, ofColor(255,100));  
    gui->setWidgetColor(OFX_UI_WIDGET_COLOR_OUTLINE_HIGHLIGHT, ofColor(255,200));  
    gui->setWidgetColor(OFX_UI_WIDGET_COLOR_FILL, ofColor(255,200));  
    gui->setWidgetColor(OFX_UI_WIDGET_COLOR_FILL_HIGHLIGHT, ofColor(255, 255));  
      
    drawPadding = !drawPadding;  
    gui->setDrawWidgetPadding(drawPadding);  
      
    ofAddListener(gui->newGUIEvent,this,&osc::guiEvent);  
  
      
}  
  
//--------------------------------------------------------------  
  
void osc::guiEvent(ofxUIEventArgs &e)  
{  
	string name = e.widget->getName();  
	int kind = e.widget->getKind();  
	  
	if(!name.compare("NORMAL SLIDER"))  
	{  
		ofxUISlider *slider = (ofxUISlider *) e.widget;  
        cout << slider->getScaledValue() << endl;  
	}  
    else if(!name.compare("RSLIDER"))  
    {  
        ofxUIRangeSlider *rslider = (ofxUIRangeSlider *) e.widget;  
        cout << "valuelow: " << rslider->getScaledValueLow() << endl;  
        cout << "valuehigh: " << rslider->getScaledValueHigh() << endl;  
    }  
    else if(!name.compare("PAD"))  
    {  
        ofxUI2DPad *pad = (ofxUI2DPad *) e.widget;  
        cout << "value x: " << pad->getScaledValue().x << endl;  
        cout << "value y: " << pad->getScaledValue().y << endl;  
    }  
    else if(!name.compare("CSLIDER") || !name.compare("CSLIDER 2"))  
    {  
        ofxUIRotarySlider *rotslider = (ofxUIRotarySlider *) e.widget;  
        cout << "value: " << rotslider->getScaledValue() << endl;  
    }  
}  
  
//--------------------------------------------------------------  
void osc::exit()  
{  
    delete gui;  
    gui->saveSettings("GUI/guiSettings.xml");  
}  
  
void osc::update(){  
      
    //ofSetColor(ofColor::white);  
    //ofFill();  
    //ofRect(0, 0, 1024, 768);  
      
}  
  
void osc::draw(){  
     
    //ofSetColor(ofColor::white);  
    //ofFill();  
    //ofRect(0, 0, 1024, 768);  
      
    // draw UI background  
    ofPushStyle();  
	ofEnableBlendMode(OF_BLENDMODE_ALPHA);  
	ofPopStyle();  
      
}  
  
//--------------------------------------------------------------  
void osc::keyPressed(int key){  
      
    switch (key)  
    {  
        case 'p':  
        {  
            drawPadding = !drawPadding;  
            gui->setDrawWidgetPadding(drawPadding);  
        }  
            break;  
              
        case 'g':  
        {  
            gui->toggleVisible();  
        }  
            break;  
        default:  
            break;  
    }  
      
}