gint redrawGL2PS() { GLdouble m[4][4]; GtkWidget *widget = GLArea; if(!GTK_IS_WIDGET(widget)) return TRUE; if(!GTK_WIDGET_REALIZED(widget)) return TRUE; glMatrixMode(GL_PROJECTION); glLoadIdentity(); addFog(); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); set_background_color(); mYPerspective(45,(GLdouble)widget->allocation.width/(GLdouble)widget->allocation.height,1,100); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); if(optcol==-1) drawChecker(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if(perspective) mYPerspective(Zoom,(GLdouble)widget->allocation.width/(GLdouble)widget->allocation.height,zNear,zFar); else { gdouble fw = (GLdouble)widget->allocation.width/(GLdouble)widget->allocation.height; gdouble fh = 1.0; glOrtho(-fw,fw,-fh,fh,-1,1); } glMatrixMode(GL_MODELVIEW); glLoadIdentity(); if(perspective) glTranslatef(Trans[0],Trans[1],Trans[2]); else { glTranslatef(Trans[0]/10,Trans[1]/10,0); glScalef(1/Zoom*2,1/Zoom*2,1/Zoom*2); } SetLight(); build_rotmatrix(m,Quat); glMultMatrixd(&m[0][0]); redrawGeometry(); redrawSurfaces(); redrawCell(); redrawContours(); redrawPlanesMapped(); if(get_show_symbols() || get_show_numbers() || get_show_charges()) showLabelSymbolsNumbersCharges(); if(get_show_dipole()) showLabelDipole(); if(get_show_distances()) showLabelDistances(); if(get_show_axes()) showLabelAxes(); if(get_show_axes()) showLabelPrincipalAxes(); showLabelTitle(GLArea->allocation.width,GLArea->allocation.height); /* Swap backbuffer to front */ glFlush(); return TRUE; }
/*------------------------------------------------------------------------ * do_draw() * Input: none * Output: * geometry drawings. See draw() for details */ static void do_draw(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClearColor(0.,0.,0.,0); glScalef(scale, scale, scale); // three axes: rotate with the model glPushMatrix(); glRotatef(rot_x, 1,0,0); glRotatef(rot_y, 0,1,0); glRotatef(rot_z, 0,0,1); glBegin(GL_LINES); glColor3f(1,0,0); glVertex3f(0,0,0); glVertex3f(40,0,0); glColor3f(0,1,0); glVertex3f(0,0,0); glVertex3f(0,40,0); glColor3f(0,0,1); glVertex3f(0,0,0); glVertex3f(0,0,40); glEnd(); glPopMatrix(); // draw a box glColor3f(1.0, 1.0, 1.0); glPushMatrix(); // box behind the screen when loaded glTranslatef( - (Xminmax[0] + Xminmax[1])/2.0, - (Yminmax[0] + Yminmax[1])/2.0, - Zminmax[1] ); if(next_image==0) { glColor3f(1,1,1); glRecti(0, 0, camera.screenwidth, camera.screenheight); } else if(next_image ==1) { glColor3f(0,0,0); glRecti(0, 0, camera.screenwidth, camera.screenheight); } else { drawChecker(camera.screenwidth/4, camera.screenheight/4); }; glPopMatrix(); glutSwapBuffers(); }
void Cell::paintEvent(QPaintEvent *) { if(isSelect) { QPainter painter(this); painter.setBrush(QColor(120,65,15)); painter.drawRect(0, 0, width(), height()); drawChecker(); } else { drawCell(); } update(); }
void Cell::drawCell() { QPainter painter(this); if(CellColor == BLACK) { painter.setBrush(QColor(0xbc,0x5c,0xc)); } else if(CellColor == WHITE) { painter.setBrush(Qt::white); } else { return; } painter.drawRect(0, 0, width(), height()); drawChecker(); update(); }
QPixmap StylePainterMobile::findCheckBox(const QSize& size, bool checked, bool enabled) const { ASSERT(size.width() == size.height()); QPixmap result; KeyIdentifier id; id.type = KeyIdentifier::CheckBox; id.height = size.height(); id.trait1 = enabled; id.trait2 = checked; if (!findCachedControl(id, &result)) { result = QPixmap(size); result.fill(Qt::transparent); QPainter cachePainter(&result); QRect rect(QPoint(0, 0), size); drawCheckableBackground(&cachePainter, rect, checked, enabled); if (checked || !enabled) drawChecker(&cachePainter, rect, enabled ? Qt::white : Qt::gray); insertIntoCache(id, result); } return result; }
/*------------------------------------------------------------------------ * Display call back * * Input: none * Output: */ static void draw(void) { glClear (GL_COLOR_BUFFER_BIT); glColor3f(1,1,1); glDisable(GL_TEXTURE_2D); if(next_image==0) // all white { glColor3f(1,1,1); glRecti(0, 0, width, height); // draw the rectangle } else if(next_image==1) // all black { glColor3f(0,0,0); glRecti(0, 0, width, height); // draw the rectangle } else if(next_image==2) // ansi 4x4 { drawChecker(width/4, height/4); } glFlush(); }
static gint redraw(GtkWidget *widget, gpointer data) { GdkGLContext *glcontext = gtk_widget_get_gl_context (widget); GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (widget); GLdouble m[4][4]; if(!GTK_IS_WIDGET(widget)) return TRUE; if(!GTK_WIDGET_REALIZED(widget)) return TRUE; if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext)) return FALSE; glMatrixMode(GL_PROJECTION); glLoadIdentity(); addFog(); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); set_background_color(); mYPerspective(45,(GLdouble)widget->allocation.width/(GLdouble)widget->allocation.height,1,100); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); if(optcol==-1) drawChecker(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if(perspective) mYPerspective(Zoom,(GLdouble)widget->allocation.width/(GLdouble)widget->allocation.height,zNear,zFar); else { gdouble fw = (GLdouble)widget->allocation.width/(GLdouble)widget->allocation.height; gdouble fh = 1.0; glOrtho(-fw,fw,-fh,fh,-1,1); } glMatrixMode(GL_MODELVIEW); glLoadIdentity(); if(perspective) glTranslatef(Trans[0],Trans[1],Trans[2]); else { glTranslatef(Trans[0]/10,Trans[1]/10,0); glScalef(1/Zoom*2,1/Zoom*2,1/Zoom*2); } SetLight(); build_rotmatrix(m,Quat); glMultMatrixd(&m[0][0]); redrawGeometry(); redrawSurfaces(); redrawCell(); redrawContours(); redrawPlanesMapped(); if(get_show_symbols() || get_show_numbers() || get_show_charges()) showLabelSymbolsNumbersCharges(); if(get_show_dipole()) showLabelDipole(); if(get_show_distances()) showLabelDistances(); if(get_show_axes()) showLabelAxes(); if(get_show_axes()) showLabelPrincipalAxes(); showLabelTitle(GLArea->allocation.width,GLArea->allocation.height); /* glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); glDepthRange(0.0f,1.0f); */ if (gdk_gl_drawable_is_double_buffered (gldrawable)) gdk_gl_drawable_swap_buffers (gldrawable); else glFlush (); gdk_gl_drawable_gl_end (gldrawable); while( gtk_events_pending() ) gtk_main_iteration(); createImagesFiles(); /* gtk_widget_queue_draw(PrincipalWindow);*/ return TRUE; }