Exemplo n.º 1
0
void FunctionGraphView::drawRect(KDContext * ctx, KDRect rect) const {
  ctx->fillRect(rect, KDColorWhite);
  drawGrid(ctx, rect);
  drawAxes(ctx, rect, Axis::Horizontal);
  drawAxes(ctx, rect, Axis::Vertical);
  drawLabels(ctx, rect, Axis::Horizontal, true);
  drawLabels(ctx, rect, Axis::Vertical, true);
}
Exemplo n.º 2
0
void GLCanvas::display(void)
{
	// Clear the display buffer
	Vec3f bgColor = scene->getBackgroundColor();
	glClearColor(bgColor.x(), bgColor.y(), bgColor.z(), 1.0);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// Set the camera parameters
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	scene->getCamera()->glPlaceCamera();

	glEnable(GL_DEPTH_TEST);
	drawAxes();  // Remove this line to disable axis display
	glEnable(GL_LIGHTING);

	// Place each of the lights in the scene
	for (int i = 0; i<scene->getNumLights(); i++) {
		scene->getLight(i)->glInit(i);
	}

	// Draw the scene tree
	scene->getGroup()->paint();

	// Swap the back buffer with the front buffer to display
	// the scene
	glutSwapBuffers();
}
Exemplo n.º 3
0
void SmokeSim::draw(const Camera& c) {
  drawAxes(); 
  mGrid.draw(c);
  if (mRecordEnabled) {
    grabScreen();
  }
}
Exemplo n.º 4
0
void myDisplay() {
	glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	gluLookAt(0.0, 0.5, 1.5, 0, 0, 0, 0, 1, 0);
	LightPosition();

	glDisable(GL_LIGHTING);
	glLineWidth(5);
	drawAxes();

	glEnable(GL_LIGHTING);


	//glDisable(GL_DEPTH_TEST); 
	static float angle = 0.0;
	glRotatef(angle, 0.0, 1.0, 0.0);
	angle += 0.5;
	glPushMatrix();
	glTranslatef(0, 0, -0.5);
	glColor4f(1, 1, 1, 0.5);
	glutSolidTeapot(0.5);
	glPopMatrix();

	
	glPushMatrix();	
	glColor4f(0, 0, 1, 0.5);
	glutSolidTeapot(0.5);
	glPopMatrix();
	//glEnable(GL_DEPTH_TEST);

	glutSwapBuffers();
}
Exemplo n.º 5
0
void OkcViewDisplay::paint() {
    OkcVisualMapResult* vmr = getOkcVisualMapResult();

	// If the VisualMapResult is NULL, do nothing
	if (!vmr) {
		return;
	}

    // Set parameters about data size, dimension size and dimension attributes
	setParameters();

	// If the dataset does not have enough dimensions, do nothing
	if (!testDimensionality()) return;

	Data* data = vmr->getData();
	assert ( typeid(*data)==typeid(OkcData));
	// if the brush is not null, draw it
	Brush* curBrush = vmr->getBrush();
	if (curBrush) {
		drawSingleBrush(curBrush);
	}

	drawData();

	drawAxes();

}
Exemplo n.º 6
0
//
// Process the Expose event: draw in the window
//
void MyWindow::onExpose(XEvent& event) {
    // Erase a window
    setForeground(getBackground());
    fillRectangle(m_RWinRect);

    // Draw the coordinate axes
    drawAxes("black", true, "gray");

    // Draw a graph of function
    setForeground("red");
    drawGraphic();

    // Draw a cross on mouse click
    if (clicked) {
        if (mouseButton == Button1)
            setForeground("blue");      // Left button
        else if (mouseButton == Button2)
            setForeground("SeaGreen");  // Middle button
        else if (mouseButton == Button3)
            setForeground("brown");     // Right mouse button
        R2Vector dx(0.2, 0.);
        R2Vector dy(0., 0.2);
        drawLine(lastClick-dx, lastClick+dx);
        drawLine(lastClick-dy, lastClick+dy);
    }
}
Exemplo n.º 7
0
void CMeshViewer::draw() const
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	gluLookAt(m_camera.x, m_camera.y, m_camera.z
		, m_camera.lookAt.x, m_camera.lookAt.y, m_camera.lookAt.z
		, 0, 1, 0);
	m_sceneObject.draw();
	// remember lighting state and disable lighting
	bool isLightingEnabled = glIsEnabled(GL_LIGHTING);
	bool isTextureEnabled = glIsEnabled(GL_TEXTURE_2D);
	if (isLightingEnabled)
		glDisable(GL_LIGHTING);
	if (isTextureEnabled)
		glDisable(GL_TEXTURE_2D);
	// unlit elements
	glTranslatef(m_worldTranslationX, m_worldTranslationY, 0);
	drawAxes();
	//	restore previous lighting state
	if (isLightingEnabled)
		glEnable(GL_LIGHTING);
	if (isTextureEnabled)
		glEnable(GL_TEXTURE_2D);
}
Exemplo n.º 8
0
//--------------------------------------------------------------
void testApp::draw(){
    centroid = center;
    cam.setPosition(ofVec3f(0, 0, -centroid.z));
    
    cam.lookAt(centroid, ofVec3f(0,1,0));
    cam.setFarClip(50000);
    
    cam.begin();
    
    ofPushMatrix();
    ofTranslate(camPosX, camPosY, camZoom);
    
    if(bTop){
        pivot(centroid, 100, 0, 0);
    }
    else{
        pivot(centroid, camRotX, camRotY, 0);
    }
    
    ofScale(-1.0, 1.0, 1.0);
    drawAxes(centroid, refPoint);
    
    ofPushStyle();
    
    //-------------------------
    for(int i = 0; i < K; i++)
        kinects[i].draw();
    
    
    if(bCalibrated && bTracking){
        for(int i = 0; i < N; i++)
            trackers[i].draw();
        
        for(int i = 0; i < N - 1; i++)
            for(int j = 1; j < N; j++){
                setLineColor(i + j);
                ofLine(trackers[i].lerpedPos, trackers[j].lerpedPos);
            }
        
        //-------------------------
        ofEnableAlphaBlending();
        ofSetColor(255, 0, 0, 50);
        ofFill();
        ofBeginShape();
        for(int i = 0; i < N; i++)
            ofVertex(trackers[i].lerpedPos);
        ofEndShape();
        ofDisableAlphaBlending();
        //-------------------------
    }
    
    ofPopStyle();
   

    ofPopMatrix();

    cam.end();
    
    gui.draw();    
}
Exemplo n.º 9
0
void VCanvas::paintGL()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	glTranslatef(0.0, 0.0, -10.0);

	qglColor(Qt::darkBlue);

	glBegin(GL_POINTS);
	glVertex3f(0.0, 0.0, 0.0);
	glEnd();

	glScalef(scaling, scaling, scaling);

	glRotatef(rotationX, 1.0, 0.0, 0.0);
	glRotatef(rotationY, 0.0, 1.0, 0.0);
	glRotatef(rotationZ, 0.0, 0.0, 1.0);

	glTranslatef(translX, translY, translZ); //

	//drawAxes(axesLength);
	if (drawingData != 0)
		drawData();
	if (areAxesVisible)
		drawAxes(axesLength);
}
Exemplo n.º 10
0
void display() {
	
	// 카메라 위치
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	gluLookAt(
			  0, 0, 5, 
			  0, 0, 0, 
			  0, 1, 0);
	
	
	glClear(GL_COLOR_BUFFER_BIT);
	
	drawAxes();
	glColor3f(1, 1, 0);
	draw();
	glTranslatef(1.0, 0.0, 0.0);
	glColor3f(0, 1, 1);	
	draw();
	glTranslatef(-0.5, 1.0, 0.0);
	glColor3f(1, 0, 0);
	draw();
	
	
	// 화면 송출
	glutSwapBuffers();
}
Exemplo n.º 11
0
Arquivo: draw.c Projeto: te-bachi/cgr
void draw3D() {
    glLoadIdentity();                               // Load a new matrix

    camera();                                       // Calculate and set cameraview and cameraposition
    
    incAnimationVars();                                         

    // Draw Ship
    glPushMatrix();
        glTranslatef(0.0f, 0.0f,  -2.0f);
        drawShip();
    glPopMatrix();
    glPushMatrix();
        glRotatef(angle, 0, 1, 0);
        glTranslatef(0.0f, 0.0f,  -10.0f);
        drawShip();
    glPopMatrix();
    glPushMatrix();
        glTranslatef(0.0f, 0.0f, dist);
        glRotatef(90, 0, 1, 0);
        drawShip();
    glPopMatrix();
    
    drawAxes();
    
    // Draw grid
    ////////////////////
    glPushMatrix();                                 // Save matrix
    glTranslatef( 0.0f, -0.2f, 0.0f);               // Translate grid in the y-axis
    drawGrid();                                     // Draw a grid on the ground
    glPopMatrix();                                  // Restore matrix
}
Exemplo n.º 12
0
void WeatherChart::paintEvent(QPaintEvent *)
{
    resetPaintRect();

    QPainter p;
    p.begin(this);

    if (scaleRect.width() == 0 && scaleRect.height() == 0)
    {
        setMinMax();
        resetZoom();
    }

    p.setBrush(QColor(20,20,20));
    p.setPen(QColor(20,20,20));
    p.drawRect(0, 0, width(), height());

    drawAxes(&p);
    drawChart(&p);

    if (scaling)
        drawScaleRect(&p);

    p.end();
}
Exemplo n.º 13
0
void GLWidget::paintGL()
{
    //delete color and depth buffer
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glTranslatef(position.x(), position.y(), position.z());
    glRotatef(xRot / 16.0, 1.0, 0.0, 0.0);
    glRotatef(yRot / 16.0, 0.0, 1.0, 0.0);
    glRotatef(zRot / 16.0, 0.0, 0.0, 1.0);
    //applyCamera();

    drawAxes();
    drawGrid();

    timerQuery.begin();
    // draw meshes
    for(int i=0; i<meshes.size(); i++) {
        meshes.at(i).draw();
    }
    timerQuery.end();

    qDebug() << timerQuery.waitForResult() / 1000000.0;
}
Exemplo n.º 14
0
void AnalysisView::runAnalysis() {

	drawMagnitudes();
	drawSubbands();
	drawAxes();
	drawClipping();
}
Exemplo n.º 15
0
void myDisplay() {
	glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	gluLookAt(0, 30, 40, 0, 30, 0, 0, 1, 0);

	LightPosition();

	glDisable(GL_LIGHTING);
	glLineWidth(5);
	drawAxes();

	static float angle = 0.0;
	glRotatef(angle, 0, 1, 0);
	angle += 0.5;
	glLineWidth(1);
	myMesh.drawMesh();
	clothMesh.drawMesh();

	glEnable(GL_LIGHTING);


	glutSwapBuffers();
}
Exemplo n.º 16
0
void display(void) {
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	drawText();
	glCallList(textList);

	if (displayFFT) {
		glPushMatrix();
		glCallList(fftList);
		glPopMatrix();
		glPointSize(pSize);
		glEnableClientState(GL_VERTEX_ARRAY);
		glEnableClientState(GL_COLOR_ARRAY);
		glVertexPointer(3, GL_DOUBLE, sizeof(point), fftPointList);
		glColorPointer(4, GL_FLOAT, sizeof(point), &fftPointList[0].r);
		glDrawArrays(GL_LINES, 0, fftN);
		glDisableClientState(GL_COLOR_ARRAY);
		glDisableClientState(GL_VERTEX_ARRAY);
	}

	if (displayHilbert) {
		drawHilbert();
	}

	glPushMatrix();
	glTranslatef(xx, yy, -zoom);
	glRotatef(rotx, 1.0, 0.0, 0.0);
	glRotatef(roty, 0.0, 1.0, 0.0);
	glRotatef(rotz, 0.0, 0.0, 1.0);

	GLfloat ambient1[] = {0.15f, 0.15f, 0.15f, 1.0f};
	GLfloat diffuse1[] = {0.8f, 0.8f, 0.8f, 1.0f};
	GLfloat specular1[] = {1.0f, 1.0f, 1.0f, 1.0f};
	GLfloat position1[] = {0.0f, 0.0f, 24.0f, 1.0f};
	glLightfv(GL_LIGHT1, GL_AMBIENT, ambient1);
	glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse1);
	glLightfv(GL_LIGHT1, GL_DIFFUSE, specular1);
	glLightfv(GL_LIGHT1, GL_POSITION, position1);
	glEnable(GL_LIGHT1);

	drawAxes();

	glPointSize(pSize);
	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_COLOR_ARRAY);
	glVertexPointer(3, GL_DOUBLE, sizeof(point), pointsList);
	glColorPointer(4, GL_FLOAT, sizeof(point), &pointsList[0].r);
	glDrawArrays(GL_POINTS, 0, sampleSize);
	glDisableClientState(GL_COLOR_ARRAY);
	glDisableClientState(GL_VERTEX_ARRAY);

	glPopMatrix();

	glutPostRedisplay();
	glutSwapBuffers();
}
Exemplo n.º 17
0
/*
 * Main display of the ColorSpaceKeyerOverlay class
 * @param args current arg (time/renderScale/pixelScale....
 * @return if there is something drawed by the function (y or n)
 */
bool ColorSpaceKeyerOverlay::draw( const OFX::DrawArgs& args )
{
	bool displaySomethings = false;
	if( _plugin->_paramBoolPointCloudDisplay->getValue() ) //Is CloudPointData displayed ? (GUI)
	{
		glPushMatrix();								//new transformation
		prepareOpenGLScene(args);					//prepare frustum and projection settings
		if(_plugin->_updateVBO )					//VBO need to be updated
		{
			//update VBO
			getData().updateVBO();					//update VBO from VBO data (already computed)
			_plugin->_updateVBO = false;			//VBO has been recomputed
		}
		if(_plugin->_resetViewParameters)			//View parameters need to be reseted
		{
			_rotateX = _rotateY = 0;				//reset parameters
			_rotateXForm = _rotateYForm = 0;		//reset geodesic form center rotation parameters
			_plugin->_resetViewParameters = false;	//view parameters has been changed
			setToIdentity(_modelViewMatrix);		//reset model-view matrix to identity
		}
		//OpenGL parameters
		glEnable(GL_DEPTH_TEST);					//active depth (better for understand results)
		
		//drawing Axes
		drawAxes();									//draw the X, Y and Z axes
		//drawing VBO
		if(getData()._isVBOBuilt)					//if VBO has already been built
			getData()._imgVBO.draw();				//draw VBO
		
		//drawing color selection VBO
		if(getData()._isSelectionVBOBuilt && _plugin->_paramBoolSeeSelection->getValue())	//color selection VBO data is built
		{
			glColor3f(1.0f,1.0f,1.0f);														//color is white
			getData()._selectionColorVBO.draw();											//draw selection VBO
		}
		//drawing spill selection VBO
		if(getData()._isSpillSelectionVBOBuilt && _plugin->_paramBoolSeeSpillSelection->getValue()) //spill selection VBO data is built
		{
			glColor3f(.3f,.3f,.3f);														//color is white
			getData()._selectionSpillVBO.draw();										//draw selection VBO
		}
		
		//drawing average
		getData()._averageColor.draw();								//draw average (cross)
		//drawing geodesic form
		if(_plugin->_paramBoolDisplayGeodesicForm->getValue())		//does user want to display color geodesic form
			getData()._geodesicFormColor.draw(false);				//draw geodesic form on screen without alpha
		if(_plugin->_paramBoolDisplaySpillGF->getValue())			//does user want to display spill geodesic form
			getData()._geodesicFormSpill.draw(true);				//draw spill geodesic form on screen with alpha
		
		//OpenGL end of parameters
		glDisable(GL_DEPTH_TEST);	//disable deep
		glPopMatrix();				//pop matrix
		displaySomethings = true;	//something has been drown on screen
	}
	return displaySomethings;		//return if overlay has displayed something (y or n)
}
Exemplo n.º 18
0
void drawScene(void)
{
  drawAxes();
  drawParameters();
  drawLight();
  currentTexture = textures[TEX_CRATE];
  cube(0,0,0, 2,2,2, cubeRotation);
  currentTexture = textures[TEX_DEFAULT];
}
Exemplo n.º 19
0
void draw() {
		
	
	glPushMatrix();
	glRotated(angle, 1.0, 1.0, 1.0);
	drawScene();
	glPopMatrix();
	
	drawAxes();
}
Exemplo n.º 20
0
/* display axes in a matrix */
void displayAxes(void)
{
	glPushMatrix();
	glTranslatef(translateAxes.posX, translateAxes.posY, translateAxes.posZ); 
	glRotatef(rotateAxes.rotX, THIS, NOT_THIS, NOT_THIS);
	glRotatef(rotateAxes.rotY, NOT_THIS, THIS, NOT_THIS);
	glRotatef(rotateAxes.rotZ, NOT_THIS, NOT_THIS, THIS);
	drawAxes();
	glPopMatrix();
}
Exemplo n.º 21
0
void Scene::display() {
    // Set lighting
    light.setLighting();
    // Set background color
    glClearColor(backgroundColor[0],
                 backgroundColor[1],
                 backgroundColor[2],
                 backgroundColor[3]);
 	glColor3f(1,1,1);
    if (drawAxesOn) drawAxes(-(worldX/2)-5, -(worldY/2)-5, -(worldZ/2)-5);

    // Draw real time scene
    /*
    Thing thing;
    unsigned long nObjects = model.get_num_objects();
    Vec3 * p = 0;
    Vec3 * r = 0;
    double * a = 0;

    for (unsigned long i=0; i<nObjects; i++) {
        model.get_next_object_state(&p,&r,&a);
        if (p != 0) {
            thing.Cube(p->x, p->y, p->z,
                       0.4,0.4,0.4,
                       *a,p->x,p->y,p->z);
        }
        else { std::cout << "its zero" << std::endl;}
    }
    */
    // Draw box bounding the world
    WireframeCube(0,0,0,
                  worldX,worldY, worldZ,
                  0,0,0,0);

    // Draw recorded scene
    double radius = 1.0;
    FrameState * frame = reader.get_next_frame();
    if (frame != 0) {
        unsigned long nObjects = frame->get_num_objects();
        for (unsigned long i=0; i<nObjects; i++) {
            Object * o = frame->get_object(i);
            if (o != 0) {
                // Set color based on id
                int origin = o->getID() >> 28;
 	            glColor3f(colors[origin].x, colors[origin].y, colors[origin].z);


                // Draw an object from the animation record file
                //Cube(o->x(), o->y(), o->z(),
                //           0.4,0.4,0.4,
                //           o->a_r(),o->x_r(),o->y_r(),o->z_r());
                Sphere(o->x(), o->y(), o->z(), radius);
            }
        }
Exemplo n.º 22
0
void GLWidget::paintGL()
{
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    // Adjust clipping box
    if(width <= height)
    {
        glOrtho(-zoomFactor, zoomFactor, -zoomFactor*height/width,
            zoomFactor*height/width, -zoomFactor*5000.0f, zoomFactor*5000.0f);
    }
    else
    {
        glOrtho(-zoomFactor*width/height, zoomFactor*width/height,
            -zoomFactor, zoomFactor, -zoomFactor*5000.0f, zoomFactor*5000.0f);
    }
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glTranslated(-xTrans, -yTrans, -zTrans);
    glRotated(xRot / 16.0, 1.0, 0.0, 0.0);
    glRotated(yRot / 16.0, 0.0, 1.0, 0.0);
    glRotated(zRot / 16.0, 0.0, 0.0, 1.0);
    //glMultMatrixf(panMatrix);
    //glLoadMatrixd(panMatrix);
    //glTranslated(-xPos-xTrans, -yPos-yTrans, -zPos-zTrans);
    glTranslated(-xPos, -yPos, -zPos);

    if(!wireframeMode)
    {
        //glPolygonMode(GL_BACK, GL_FILL);
        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    }
    else
    {
        glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
    }
    glCullFace(GL_BACK);
    qglColor(grey);
    glCallList(object);

    if(!wireframeMode)
    {
        glCullFace(GL_FRONT);
        qglColor(black);
        glPolygonMode(GL_BACK, GL_LINE);
        glCallList(object);
        glPolygonMode(GL_BACK, GL_FILL);
        glCullFace(GL_BACK);
    }

    drawAxes();
}
void
QvisParallelCoordinatesWidget::redrawScene(QPainter *painter)
{
    double sceneWidth = (double)width();
    double sceneHeight = (double)height();
    double leftAxisX = sceneWidth * AXIS_LEFT_MARGIN;
    double axisSpacing = (sceneWidth*(1.0-AXIS_LEFT_MARGIN-AXIS_RIGHT_MARGIN)) /
        (double)(axisCount-1);
    double tickSpacing = (sceneHeight*(1.0-AXIS_BOTTOM_MARGIN-AXIS_TOP_MARGIN)) /
        (double)(TICKS_PER_AXIS+1);
    
    QBrush backgroundBrush(QColor(255,255,255));
    qDrawShadePanel(painter,
        0, 0, width(), height(), palette(), true, 2, &backgroundBrush);
        
    axisBottomY = (int)(sceneHeight*(1.0-AXIS_BOTTOM_MARGIN) + 0.5);
    axisTopY    = (int)(sceneHeight*AXIS_TOP_MARGIN + 0.5);
    
    axesXPos.clear();
    
    for (int axisNum = 0; axisNum < axisCount; axisNum++)
    {
        axesXPos.push_back((int)(leftAxisX + (double)axisNum*axisSpacing + 0.5));
    }
    
    ticksYPos.clear();
    
    for (int tickNum = 1; tickNum <= TICKS_PER_AXIS; tickNum++)
    {
        ticksYPos.push_back((int)(axisTopY + (double)tickNum*tickSpacing + 0.5));
    }
    
    double axisLen = (double)(axisBottomY - axisTopY);
    double dashAndGapLen = axisLen / ((double)DASHES_PER_AXIS - DASH_GAP_FRACTION);
    double dashTopYPos = (double)axisTopY;
    int dashLen = (int)(dashAndGapLen * (1.0-DASH_GAP_FRACTION));
        
    dashesTopYPos.clear(); dashesBotYPos.clear();
    
    for (int dashNum = 0; dashNum < DASHES_PER_AXIS; dashNum++)
    {
        dashesTopYPos.push_back((int)dashTopYPos);
        dashesBotYPos.push_back((int)dashTopYPos + dashLen);
        
        dashTopYPos += dashAndGapLen;
    }
    
    dashesBotYPos[DASHES_PER_AXIS-1] = axisBottomY;

    drawDataCurves(painter);
    drawAxes(painter);
    drawAxisTitles(painter);
}
Exemplo n.º 24
0
void GLWidget::paintGL()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glViewport(viewport.x(), viewport.y(), viewport.width(), viewport.height());

    updateMatrices();

    drawAxes();
    drawCube();
    drawPoints();

}
Exemplo n.º 25
0
void ViewScene::setNewOriginOffset(int unsigned xOffset,int unsigned yOffset){
    QPoint oldOffset = originOffset;
    originOffset.setX(xOffset);
    originOffset.setY(yOffset);
    QPoint relativeOffset = originOffset - oldOffset;
    setSceneRect(0,0,width() + relativeOffset.x(), height() +
                 relativeOffset.y());
    //loop to relocate all items on the scene
    for( auto item : items() ) {
        item->setPos(item->pos()+relativeOffset);
    }
    drawAxes();
}
Exemplo n.º 26
0
void Plot2D::render(){
    //void drawGrid( bounds.x0, bounds.y0, bounds.x0, bounds.x0, dx, dy );

    if( glObj ) glDeleteLists(glObj,1);
    glObj = glGenLists(1);
    glNewList(glObj, GL_COMPILE);
    drawAxes();
    glEndList( );

    for( DataLine2D* line : lines ){ line->render(); }
    // TO DO :
    //if( tickCaption ){ }
};
Exemplo n.º 27
0
void display(void)
{
	static double t0 /*= currentSeconds()*/;
	       double t1, elapsedTime;
	static unsigned N;
	float fps;
	char cfps[256];

	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(ortho_left,   -ortho_left,
		ortho_bottom, -ortho_bottom,
		ortho_znear,   ortho_zfar);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	gluLookAt(eye_x, eye_y, eye_z, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

	glPushMatrix();
	glRotatef(angle, rotate_x, rotate_y, rotate_z);

	drawAxes();

	glPopMatrix();

	glTranslatef(translate_x, translate_y, translate_z);
	glPushMatrix();
	glRotatef(angle, rotate_x, rotate_y, rotate_z);

	drawJulia();

	glPopMatrix();

	/* compute FPS */
	N++;
	t1 = currentSeconds();
	elapsedTime = t1 - t0;
	if (elapsedTime > FPS_TIME_WINDOW) {
		fps = (float) N / elapsedTime;
		N = 0;
		t0 = t1;
		sprintf(cfps, "Julia Fractal GL (%d x %d): %3.1f fps", WIDTH, HEIGHT, fps);
		printf("%s\n", cfps);
		glutSetWindowTitle(cfps);
	}
	glutPostRedisplay();
	glutSwapBuffers();
}
Exemplo n.º 28
0
// The window display callback function.
// This function is responsible for drawing the contents of a window.
// One can safely assume that the reshape callback for a window has
// been called at least once before the display callback is invoked.
void display()
{
	// Clear the window.
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// Set the current matrix to the modelview matrix.
	glMatrixMode(GL_MODELVIEW);

	// Save the current modelview matrix.
	glPushMatrix();

	// Set the eye position.
	// The eye is always oriented to look towards the origin.
	GLfloat eyeX = 5 * cos(degToRad(theta));
	GLfloat eyeY = 5 * sin(degToRad(theta));
	GLfloat eyeZ = ro;
	gluLookAt(eyeX, eyeY, eyeZ, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0);

	// Draw the coordinate axes.
	drawAxes();

	// Draw a cube at 1.5,-1.5, 0
	glPushMatrix();
	glColor3f(0.0, 0.0, 0.9);
	glTranslatef(-1.5, 1.5, 0.0);
	glScalef(0.5, 0.5, 0.5);
	glutSolidCube(1);
	glPopMatrix();

	//draw a sphere at the origin
	glPushMatrix();
	glColor3f(0.9, 0.0, 0.9);
	glTranslatef(0.0, 0.0, 0.0);
	glScalef(0.5, 0.5, 0.5);
	glutSolidSphere(0.7071, 10, 10);
	glPopMatrix();

	//draw a tetrahedron
	glPushMatrix();
	glTranslatef(1.5, -1.5, 0.0);
	glScalef(0.5, 0.5, 0.5);
	drawTetrahedron();
	glPopMatrix();

	// Restore the old modelview matrix.
	glPopMatrix();

	// Flush the graphics output to the framebuffer.
	glutSwapBuffers();
}
Exemplo n.º 29
0
void display(SDL_Surface *surface)
{
	/* Clear the colour and depth buffer */
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	/* Load indentity*/
	glLoadIdentity();


	/* Set the light position (gets multiplied by the modelview matrix) */
	//glLightfv(GL_LIGHT0, GL_POSITION, light0_position);
	if (renderstate.lightType)
		glLightfv(GL_LIGHT0, GL_POSITION, light0_directional);
	else
		glLightfv(GL_LIGHT0, GL_POSITION, light0_point);

	/* Camera transformation - called later so it is static */
	glTranslatef(0, 0, -camera_zoom);
	glRotatef(-camera_pitch, 1, 0, 0);
	glRotatef(-camera_heading, 0, 1, 0);


	/*Turn on Shaders if applicable*/
	if (renderstate.shaders) {
		glUseProgram(shader); /* Use our shader for future rendering */

		glUniform1i(uniform.object, renderstate.object);
		glUniform1i(uniform.lightingModel, renderstate.specularMode);
		glUniform1i(uniform.isLocalViewer, renderstate.lightModel);
		glUniform1i(uniform.isPerPixelLighting, renderstate.perPixel);
		glUniform1f(uniform.time, time_s);
	}

	/* Draw the scene */
	drawObject(object);
	//drawNormals(object);

	/* turn shaders off */
	glUseProgram(0);

	/*drawAxes once shader is turned off*/
	drawAxes(0,0,0,2);

	/* Draw framerate */
	draw_framerate(surface);
	if (renderstate.osd) draw_osd(surface);

	CHECKERROR;
}
Exemplo n.º 30
0
	void updateGraph(HWND hwnd) {

		HDC hdc = (HDC)GetDC(hwnd);
		
		clearGraph(hwnd, hdc);

		drawAxes(hwnd, hdc);

		drawGrid(hwnd, hdc);

		drawGraph(hwnd, hdc);
		
		ReleaseDC(hwnd, hdc);
		
	}