void OrthoViews::set_primary(gp_Dir facing, gp_Dir right) // set the orientation of the primary view { primary.SetDirection(facing); primary.SetXDirection(right); gp_Dir up = primary.YDirection(); // compute dimensions of part when orientated according to primary view width = abs(right.X() * bbox.LengthX() + right.Y() * bbox.LengthY() + right.Z() * bbox.LengthZ()); height = abs(up.X() * bbox.LengthX() + up.Y() * bbox.LengthY() + up.Z() * bbox.LengthZ()); depth = abs(facing.X() * bbox.LengthX() + facing.Y() * bbox.LengthY() + facing.Z() * bbox.LengthZ()); if (views.size() == 0) add_view(0, 0); else { views[0]->set_projection(primary); set_all_orientations(); // reorient all other views appropriately process_views(); } }
void HDimension::RenderText(const wxString &text, const gp_Pnt& p, const gp_Dir& xdir, const gp_Dir& ydir, double scale) { float width, height; if(!wxGetApp().get_text_size(text, &width, &height))return; // make a matrix at top left of text gp_Pnt text_top_left( p.XYZ() + ydir.XYZ() * (scale * height) ); gp_Trsf text_matrix = make_matrix(text_top_left, xdir, ydir); glPushMatrix(); double m[16]; extract_transposed(text_matrix, m); glMultMatrixd(m); if(DrawFlat) { //Try and draw this ortho. must find the origin point in screen coordinates double x, y, z; // arrays to hold matrix information double model_view[16]; glGetDoublev(GL_MODELVIEW_MATRIX, model_view); double projection[16]; glGetDoublev(GL_PROJECTION_MATRIX, projection); int viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); // get 3D coordinates based on window coordinates gluProject(0,0,0, model_view, projection, viewport, &x, &y, &z); wxGetApp().render_screen_text_at(text, scale*8,x,y,atan2(xdir.Y(),xdir.X()) * 180 / M_PI); } else { wxGetApp().render_text(text); } glPopMatrix(); }