Esempio n. 1
0
void BasicGLPane::render( wxPaintEvent& evt )
{
    if(!IsShown()) return;
    
    wxGLCanvas::SetCurrent(*m_context);
    wxPaintDC(this); // only to be used in paint events. use wxClientDC to paint outside the paint event
	
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	
    // ------------- draw some 2D ----------------
    prepare2DViewport(0,0,getWidth()/2, getHeight());
    glLoadIdentity();
	
    // white background
    glColor4f(1, 1, 1, 1);
    glBegin(GL_QUADS);
    glVertex3f(0,0,0);
    glVertex3f(getWidth(),0,0);
    glVertex3f(getWidth(),getHeight(),0);
    glVertex3f(0,getHeight(),0);
    glEnd();
	
    // red square
    glColor4f(1, 0, 0, 1);
    glBegin(GL_QUADS);
    glVertex3f(getWidth()/8, getHeight()/3, 0);
    glVertex3f(getWidth()*3/8, getHeight()/3, 0);
    glVertex3f(getWidth()*3/8, getHeight()*2/3, 0);
    glVertex3f(getWidth()/8, getHeight()*2/3, 0);
    glEnd();
    
    // ------------- draw some 3D ----------------
    prepare3DViewport(getWidth()/2,0,getWidth(), getHeight());
    glLoadIdentity();
	
    glColor4f(0,0,1,1);
    glTranslatef(0,0,-5);
    glRotatef(50.0f, 0.0f, 1.0f, 0.0f);
    
    glColor4f(1, 0, 0, 1);
    for (int i = 0; i < 6; i++)
    {
        glBegin(GL_LINE_STRIP);
        glVertex3fv(&v[faces[i][0]][0]);
        glVertex3fv(&v[faces[i][1]][0]);
        glVertex3fv(&v[faces[i][2]][0]);
        glVertex3fv(&v[faces[i][3]][0]);
        glVertex3fv(&v[faces[i][0]][0]);
        glEnd();
    }
    
    glFlush();
    SwapBuffers();
}
Esempio n. 2
0
void ModelPreview::InitializePreview(wxString img,int brightness)
{
    image = NULL;
    mBackgroundImage = img;
    mBackgroundImageExists = wxFileExists(mBackgroundImage)?true:false;
    mBackgroundBrightness = brightness;
    wxGLCanvas::SetCurrent(*m_context);
    wxClientDC dc(this);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    prepare2DViewport(0,0,getWidth(), getHeight());
    glLoadIdentity();
}
Esempio n. 3
0
void Waveform::InitializeGLCanvas()
{
    if(!IsShownOnScreen()) return;
    SetCurrentGLContext();
    LOG_GL_ERRORV(glClearColor(0.0f, 0.0f, 0.0f, 0.0f)); // Black Background
    LOG_GL_ERRORV(glDisable(GL_BLEND));
    LOG_GL_ERRORV(glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA));
    LOG_GL_ERRORV(glClear(GL_COLOR_BUFFER_BIT));
    prepare2DViewport(0,0,mWindowWidth, mWindowHeight);
    mIsInitialized = true;
    SetZoomLevel(mZoomLevel);
}
Esempio n. 4
0
void Waveform::InitializeGLCanvas()
{
    if(!IsShownOnScreen()) return;
    SetCurrentGLContext();
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background
    glDisable(GL_TEXTURE_2D);   // textures
    glDisable(GL_COLOR_MATERIAL);
    glDisable(GL_BLEND);
    glDisable(GL_DEPTH_TEST);
    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    prepare2DViewport(0,0,mWindowWidth, mWindowHeight);
    glLoadIdentity();
    mIsInitialized = true;
    SetZoomLevel(mZoomLevel);
}
Esempio n. 5
0
void Waveform::renderGL( )
{
    if(!mIsInitialized) { InitializeGLCanvas(); }

    if(!IsShownOnScreen()) return;

    SetCurrentGLContext();

    LOG_GL_ERRORV(glClear(GL_COLOR_BUFFER_BIT));
    prepare2DViewport(0,0,mWindowWidth, mWindowHeight);

	if (mCurrentWaveView >= 0)
	{
		DrawWaveView(views[mCurrentWaveView]);
	}
    LOG_GL_ERRORV(SwapBuffers());
}
Esempio n. 6
0
void BasicGLPane::render( wxPaintEvent& evt )
{
    if(!IsShown()) return;
    
    wxGLCanvas::SetCurrent(*m_context);
    wxPaintDC(this); // only to be used in paint events. use wxClientDC to paint outside the paint event
    
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
    prepare2DViewport(0,0,getWidth(), getHeight());
    glLoadIdentity();
    
    if (!buf.empty()) paint_buffer();


    glFlush();
    SwapBuffers();
}
Esempio n. 7
0
void xlGridCanvasPictures::render( wxPaintEvent& event )
{
    if(!mIsInitialized) { InitializeGLCanvas(); }
    if(!IsShownOnScreen()) return;

    SetCurrentGLContext();

    LOG_GL_ERRORV(glClear(GL_COLOR_BUFFER_BIT));
    prepare2DViewport(0,0,mWindowWidth, mWindowHeight);

    if( mEffect != nullptr )
    {
        DrawPicturesEffect();
        DrawBaseGrid();
        DrawSelection();
    }
    SwapBuffers();
}
Esempio n. 8
0
void Waveform::renderGL( wxPaintEvent& event )
{
    if(!mIsInitialized) { InitializeGLCanvas(); }

    if(!IsShownOnScreen()) return;

    SetCurrentGLContext();

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    if( mWindowResized )
    {
        prepare2DViewport(0,0,mWindowWidth, mWindowHeight);
    }
    DrawWaveView(views[mCurrentWaveView]);

    glFlush();
    SwapBuffers();
}
Esempio n. 9
0
void ModelPreview::StartDrawing(wxDouble pointSize)
{
    mIsInitialized = true;
    mPointSize = pointSize;
    mIsDrawing = true;
    wxGLCanvas::SetCurrent(*m_context);
    wxClientDC dc(this);
    glPointSize( mPointSize );
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    prepare2DViewport(0,0,getWidth(), getHeight());
    if(mBackgroundImageExists)
    {
        if (image == NULL)
        {
           image = new Image(mBackgroundImage);
           sprite = new xLightsDrawable(image);
        }
        float intensity = mBackgroundBrightness*.01;
        glColor3f(intensity, intensity, intensity);
        glEnable(GL_TEXTURE_2D);   // textures
        sprite->render();
    }
    glDisable(GL_TEXTURE_2D);   // textures
}
Esempio n. 10
0
bool ModelPreview::StartDrawing(wxDouble pointSize)
{
    if(!IsShownOnScreen()) return false;
    if(!mIsInitialized) { InitializeGLCanvas(); }
    mIsInitialized = true;
    mPointSize = pointSize;
    mIsDrawing = true;
    SetCurrentGLContext();
    wxClientDC dc(this);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    if( mWindowResized )
    {
        prepare2DViewport(0,0,mWindowWidth, mWindowHeight);
    }
    glPointSize(translateToBacking(mPointSize));
    glPushMatrix();
    // Rotate Axis and tranlate
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glRotatef(180,0,0,1);
    glRotatef(180,0,1,0);

    currentPixelScaleFactor = 1.0;
    if (!allowSelected && virtualWidth > 0 && virtualHeight > 0
        && (virtualWidth != mWindowWidth || virtualHeight != mWindowHeight)) {
        glTranslatef(0,-mWindowHeight,0);
        double scaleh= double(mWindowHeight) / double(virtualHeight);
        double scalew = double(mWindowWidth) / double(virtualWidth);
        glScalef(scalew, scaleh, 1.0);

        if (scalew < scaleh) {
            scaleh = scalew;
        }
        currentPixelScaleFactor = scaleh;
        glPointSize(calcPixelSize(mPointSize));
        glColor3f(0.0, 0.0, 0.0);
        glBegin(GL_QUADS);
        glVertex2f(0, 0);
        glVertex2f(virtualWidth, 0);
        glVertex2f(virtualWidth, virtualHeight);
        glVertex2f(0, virtualHeight);
        glEnd();
    } else if (virtualWidth == 0 && virtualHeight == 0) {
        glTranslatef(0, -mWindowHeight, 0);
    } else {
        glTranslatef(0, -virtualHeight, 0);
        glColor3f(0.0, 0.0, 0.0);
        glBegin(GL_QUADS);
        glVertex2f(0, 0);
        glVertex2f(virtualWidth, 0);
        glVertex2f(virtualWidth, virtualHeight);
        glVertex2f(0, virtualHeight);
        glEnd();
    }
    if(mBackgroundImageExists)
    {
        if (image == NULL)
        {
           image = new Image(mBackgroundImage);
           sprite = new xLightsDrawable(image);
        }
        float intensity = mBackgroundBrightness*.01;
        glPushMatrix();
        double scaleh= double(virtualHeight) / double(image->height);
        double scalew = double(virtualWidth) / double(image->width);
        if (scaleImage) {
            glScalef(scalew, scaleh, 1.0);
        } else {
            if (scalew < scaleh) {
                scaleh = scalew;
            }
            glScalef(scaleh, scaleh, 1.0);
        }
        
        glColor3f(intensity, intensity, intensity);
        glEnable(GL_TEXTURE_2D);   // textures
        sprite->render();
        glDisable(GL_TEXTURE_2D);   // textures
        glPopMatrix();
    }
    return true;
}
void GLImagePane::draw() {
	MyApp::bBusyDrawingVideo[m_camId] = true;
	wxGLCanvas::SetCurrent(*m_context);
	wxPaintDC(this); // only to be used in paint events. use wxClientDC to paint outside the paint event

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	// ------------- draw some 2D ----------------
	prepare2DViewport(0, 0, getWidth(), getHeight());
	glLoadIdentity();

	//draw video frame
	if (imgData) {
		glEnable(GL_TEXTURE_2D);
		if (b_firstRun) {
			glGenTextures(1, &m_imgTexture); // generate OpenGL texture object
			glBindTexture(GL_TEXTURE_2D, m_imgTexture); // use previously created texture object and set options
			glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
			b_firstRun = false;
		}
		if (s_clicked_camid >= 0) {
			ImgRGB img(imgWidth, imgHeight);
			gray2rgb(imgWidth, imgHeight, imgData, img.data);
			drawClickedPoint(img);
			if (s_clicked_camid != m_camId)
				drawEpipolarLine(img);
			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, imgWidth, imgHeight, 0,
					GL_RGB, GL_UNSIGNED_BYTE, img.data);
		} else
			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, imgWidth, imgHeight, 0,
					GL_LUMINANCE, GL_UNSIGNED_BYTE, imgData);

		glBegin(GL_QUADS);
		glTexCoord2f(0, 0);
		glVertex3f(0, 0, 0);
		glTexCoord2f(1, 0);
		glVertex3f(getWidth(), 0, 0);
		glTexCoord2f(1, 1);
		glVertex3f(getWidth(), getHeight(), 0);
		glTexCoord2f(0, 1);
		glVertex3f(0, getHeight(), 0);
		glEnd();
		glDisable(GL_TEXTURE_2D);
	} else {
		// white background
		glColor4f(1, 1, 1, 1);
		glBegin(GL_QUADS);
		glVertex3f(0, 0, 0);
		glVertex3f(getWidth(), 0, 0);
		glVertex3f(getWidth(), getHeight(), 0);
		glVertex3f(0, getHeight(), 0);
		glEnd();
	}

	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glEnable(GL_POINT_SMOOTH);
	glEnable(GL_LINE_SMOOTH);
	glEnable(GL_POLYGON_SMOOTH);
	glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
	glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);

	drawFeaturePoints();

	if (imgData) {
		drawConvexHulls();
		drawInfo(0, 0, getWidth(), getHeight());
	}

	SwapBuffers();
	MyApp::bBusyDrawingVideo[m_camId] = false;
}
Esempio n. 12
0
 //本当は再描画のことも考えた関数設計にする
void AGIPane::render(wxPaintEvent& evt)
{
	std::cerr << "AGIRender" << std::endl;
    if(!IsShown()) return;
 
    wxGLCanvas::SetCurrent(*m_context);
    wxPaintDC(this); // only to be used in paint events. use wxClientDC to paint outside the paint event
 
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    const int atr = data->atr;
    std::list<int> notselected = data->getNSIndex();
    const int num = data->num;
    const int width = getWidth();
    // ------------- draw some 2D ----------------
    prepare2DViewport(0, 0, width, width);
    glLoadIdentity();
 
    //white background
    glColor4f(1, 1, 1, 1);
    glBegin(GL_QUADS);
    glVertex3f(0, 0, 0);
    glVertex3f(width, 0, 0);
    glVertex3f(width, width, 0);
    glVertex3f(0, width, 0);
    glEnd();
   
    //辺を描く
    glColor4f(0.2f, 0.4f, 0.7f, 0.3f);
    glLineWidth(1);
	glBegin(GL_LINES);
	std::vector<std::pair<int,int> > edge = data->filteredge;
	for(int i = 0;i< edge.size();i++){
		int n1 = edge.at(i).first;
		int n2 = edge.at(i).second;
		glVertex3f(enlarge(ag->getB(n1,0)), enlarge(ag->getB(n1,1)),0);
		glVertex3f(enlarge(ag->getB(n2,0)), enlarge(ag->getB(n2,1)),0);
	}
    glEnd();
     glColor4f(0.2f, 0.4f, 0.7f, 1.0f);
    glPointSize(5.0);
    glBegin(GL_POINTS);
    //選択されていない点を書く
  	for(int i: notselected){
       	glVertex3f(enlarge(ag->getB(i,0)), enlarge(ag->getB(i,1)),0);
    }
    glEnd();
    glPointSize(8.0); 
    glBegin(GL_POINTS);
    //選択されている点を描く
    for(auto c:data->getCluster()){
    	RGB rgb = c.rgb; 
    	glColor4f(rgb.r, rgb.g, rgb.b, 1.0f);
    	for(int i :c.index ){ 
       		glVertex3f(enlarge(ag->getB(i,0)), enlarge(ag->getB(i,1)), 0);
    	}
	}
	glEnd();
	if(data->isPCA){
		//元の軸を描く
		glLineWidth(2.0);
		glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
		glBegin(GL_LINES);
		for(int i = 0;i< atr;i++){ 
			drawaxispca(i);
		}
		glEnd();
		//PCPが軸選択モードのとき
		if(data->isCoord){
			int o = data->selectedorder;
			glColor4f(0.8f, 0.1f, 0.1f, 1.0f);
			glLineWidth(2.0);
			glBegin(GL_LINES);	
			drawaxispca(data->order[o]);
			glEnd();
			glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
			int from = std::max(o-1,0);
			int to = std::min(o+2,atr);
			for(int i = from;i< to;i++){
				int k = data->order[i];
				drawcoodname(k);
			}		
		}
		else{
			for(int i = 0;i< atr;i++)
				drawcoodname(i);
    	}
    	//agiで軸選択がされているとき
    	int nowcoord = data->selectedcoord;
    	if(nowcoord != -1){
    		glColor4f(0.8f, 0.1f, 0.1f, 1.0f);
			glBegin(GL_LINES);	
			drawaxispca(nowcoord);
			glEnd();
			drawcoodname(nowcoord);
    	}
    	glLineWidth(1);
	}
	//pcaを使っていないとき
	else{
		glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
		glPointSize(5.0);
		glLineWidth(1);
		for(int i = 0; i<data->atr ;i++){
			glBegin(GL_POINTS);
			int x = enlarge(ag->getB(i+num,0));
			int y = enlarge(ag->getB(i+num,1));
			glVertex3f(x, y, 0);
			glEnd();
			
			glRasterPos2d(x+5, y+5);
    		std::string str = data->atrname.at(i);
   			int size = (int)str.size();
    		for(int j = 0;j< size;j++){
       			char ic = str[j];
        		glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,ic);
    		} 
    		glBegin(GL_LINES);
    		glVertex3f(width/2,width/2,0);
    		glVertex3f(x,y,0);
    		glEnd();  		
		}
		glLineWidth(1);
	}
	//範囲選択がされているとき
    if(rangeselect){
    	glColor4f(0.0f,0.0f,0.0f,1.0f);
    	glBegin(GL_LINE_STRIP);
    	glVertex3f(xfrom,yfrom,0);
    	glVertex3f(xfrom,yto,0);
    	glVertex3f(xto,yto,0);
    	glVertex3f(xto,yfrom,0);
    	glVertex3f(xfrom,yfrom,0);
    	glEnd();
    }
    if(polystart){
    	glColor4f(0.0f,0.0f,0.0f,1.0f);
    	glBegin(GL_LINE_LOOP);
    	for(auto p:polyvector)
    		glVertex3f(p.first,p.second,0);
    	glVertex3f(polynow.first,polynow.second,0);
    	glEnd();
    }
    glFlush();
    SwapBuffers();
}