29 #if defined(WIN32) || defined(BOINC)
34 #include <basic/options/keys/edensity.OptionKeys.gen.hh>
51 #include <ObjexxFCL/string.functions.hh>
56 #include <basic/options/keys/edensity.OptionKeys.gen.hh>
60 #include <utility/vector1.hh>
62 #include <numeric/NumericTraits.hh>
65 #if defined GL_GRAPHICS || defined BOINC_GRAPHICS
68 #include <GLUT/glut.h>
70 #include <glut/glut.h>
84 void check_for_new_conformation_viewers();
87 typedef std::map< int, ConformationViewerOP > ConformationViewers;
88 ConformationViewers conformation_viewers;
91 pthread_mutex_t new_conformation_viewers_mut = PTHREAD_MUTEX_INITIALIZER;
93 pthread_mutex_t start_mut = PTHREAD_MUTEX_INITIALIZER;
95 pthread_cond_t start_cond = PTHREAD_COND_INITIALIZER;
99 #if defined GL_GRAPHICS || defined BOINC_GRAPHICS
102 int window_size = 30;
110 std::map< int , GraphicsState* > gs_map_;
113 Vector bg_color( 0.0f, 0.0f, 0.0f );
116 const int NUM_SEGMENTS = 5;
117 const int NUM_SEGMENTS_COIL = 10;
125 const core::Real CHAINBREAK_CUTOFF2 = 4.5*4.5;
126 const core::Real CHAINBREAK_CUTOFF2_NA = 7.5*7.5;
127 const core::Real SHOWBONDCUTOFF2 = (5.0*5.0)/(NUM_SEGMENTS*NUM_SEGMENTS);
128 const core::Real SHOWBONDCUTOFF2_COIL = (5.0*5.0)/(NUM_SEGMENTS_COIL*NUM_SEGMENTS_COIL);
129 const core::Real SHOWBONDCUTOFF2_NA = (8.0*8.0)/(NUM_SEGMENTS*NUM_SEGMENTS);
132 core::Real const ligand_sphere_opacity( 1.0 );
133 core::Real const protein_sphere_opacity( 1.0 );
134 core::Real const ligand_sphere_shininess( 1.0);
135 core::Real const protein_sphere_shininess( 1.0 );
137 core::Real const protein_wireframeScale( 0.2 );
140 int sphereDisplayList = 0;
141 core::Real const BOND_LENGTH_CUTOFF2 = 6.0*6.0;
146 #if defined GL_GRAPHICS
149 void processMouse(
int button,
int state,
int x,
int y) {
150 using namespace graphics;
155 specialKey = glutGetModifiers();
159 if (state == GLUT_DOWN) {
160 clicked_button = button;
166 if (state == GLUT_UP) {
176 void processMouseActiveMotion(
int x,
int y) {
177 using namespace graphics;
190 float delta_x = old_x - x;
191 float delta_y = old_y - y;
194 if (specialKey == GLUT_ACTIVE_SHIFT & clicked_button == 0) {
195 double s = exp( -1.0* (
double) delta_y*0.01);
198 else if (specialKey == GLUT_ACTIVE_CTRL & clicked_button == 0) {
199 GraphicsState* current_gs = gs_map_[ glutGetWindow() ];
201 std::cerr <<
"ignoring processKeyPress for window id " << glutGetWindow() << std::endl;
204 current_gs->density_sigma += delta_y*0.02;
205 current_gs->density_redraw =
true;
207 else if (specialKey == GLUT_ACTIVE_SHIFT & clicked_button > 0){
209 GLfloat currentrotation[16];
210 glGetFloatv(GL_MODELVIEW_MATRIX, currentrotation);
212 glRotatef(delta_x,0,0,1);
213 glMultMatrixf(currentrotation);
215 else if (clicked_button > 0){
217 glGetIntegerv(GL_VIEWPORT,viewport);
221 glMatrixMode(GL_MODELVIEW);
222 double xscale = (graphics::window_size * 2.0)/(viewport[2]);
223 double yscale = (graphics::window_size * 2.0)/(viewport[3]);
225 GLfloat currentrotation[16];
226 glGetFloatv(GL_MODELVIEW_MATRIX, currentrotation);
228 glTranslatef( -delta_x * xscale, delta_y * yscale, 0);
229 glMultMatrixf(currentrotation);
233 double axis_x = -delta_y;
234 double axis_y = -delta_x;
235 double userangle = sqrt(delta_x*delta_x + delta_y*delta_y);
237 glMatrixMode(GL_MODELVIEW);
246 GLfloat currentrotation[16];
247 glGetFloatv(GL_MODELVIEW_MATRIX, currentrotation);
249 glRotatef(userangle,axis_x,axis_y,0.0);
250 glMultMatrixf(currentrotation);
261 void processKeyPress(
unsigned char key,
int ,
int ) {
262 using namespace graphics;
263 using namespace protocols::viewer;
265 GraphicsState* current_gs = gs_map_[ glutGetWindow() ];
267 std::cerr <<
"ignoring processKeyPress for window id " << glutGetWindow() << std::endl;
271 if (key == 67 || key == 99) {
272 current_gs->Color_mode =
ColorMode ( current_gs->Color_mode + 1 );
275 if (key == 66 || key == 98) {
276 current_gs->BBdisplay_state =
BBdisplayState ( current_gs->BBdisplay_state + 1 );
279 if (key == 72 || key == 104) {
280 current_gs->show_H_state =
ShowHState ( current_gs->show_H_state + 1 );
281 if ( current_gs->show_H_state >
SHOW_H ) current_gs->show_H_state =
SHOW_NO_H;
283 if (key == 83 || key == 115) {
284 current_gs->SCdisplay_state =
SCdisplayState ( current_gs->SCdisplay_state + 1 );
298 conformation_viewer_display(
void )
301 int const window( glutGetWindow() );
305 if ( conformation_viewers.count( window ) ) {
306 conformation_viewers.find( window )->second->display_func();
320 check_for_new_conformation_viewers();
324 for ( ConformationViewers::const_iterator iter = conformation_viewers.begin(), iter_end = conformation_viewers.end();
325 iter != iter_end; ++iter ) {
326 iter->second->display_if_necessary();
340 conformation_viewer_window_init( GraphicsState& gs,
std::string const & window_name,
int length,
int width )
342 using namespace graphics;
344 glutInitWindowSize (length, width);
345 glutInitWindowPosition (370, 10);
347 int const window = glutCreateWindow ( window_name.c_str() );
356 graphics::gs_map_[window] = &gs;
358 glutDisplayFunc( conformation_viewer_display );
360 glClearColor( bg_color.x(), bg_color.y(), bg_color.z(), 1.0 );
361 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
363 glMatrixMode(GL_PROJECTION);
365 using graphics::window_size;
366 glOrtho( -window_size, window_size, -window_size, window_size, -10*window_size, 10*window_size );
367 glEnable( GL_DEPTH_TEST );
368 glMatrixMode(GL_MODELVIEW);
370 glEnable(GL_LINE_SMOOTH);
371 glEnable(GL_POINT_SMOOTH);
372 glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
375 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
376 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
378 glutMouseFunc( processMouse );
380 glutMotionFunc( processMouseActiveMotion );
381 glutKeyboardFunc( processKeyPress );
384 runtime_assert( glutGetWindow() == window );
391 conformation_viewer_window_init( GraphicsState& gs,
std::string const & window_name )
394 using namespace graphics;
395 glutInitWindowSize (900, 900);
396 int window = conformation_viewer_window_init( gs, window_name, 900, 900 );
404 check_for_new_conformation_viewers()
406 pthread_mutex_lock( &new_conformation_viewers_mut );
407 if ( !new_conformation_viewers.empty() ) {
408 for (
Size i=1; i<= new_conformation_viewers.size(); ++i ) {
412 int width = viewer->get_width();
413 int length = viewer->get_length();
415 int const new_window( conformation_viewer_window_init( viewer->get_gs(), viewer->name(), length, width ) );
416 viewer->window( new_window );
417 conformation_viewers[ new_window ] = viewer;
419 new_conformation_viewers.clear();
421 pthread_mutex_unlock( &new_conformation_viewers_mut );
439 pthread_mutex_lock( &new_conformation_viewers_mut );
443 ( name_in.empty() ?
"conformation"+ObjexxFCL::string_of( conformation_viewers.size() + new_conformation_viewers.size() ) :
448 viewer->attach_to( conformation );
450 new_conformation_viewers.push_back( viewer );
452 pthread_mutex_unlock( &new_conformation_viewers_mut );
455 pthread_cond_broadcast( &start_cond );
466 moves::MonteCarlo & mc,
474 pthread_mutex_lock( &new_conformation_viewers_mut );
479 "MC"+ObjexxFCL::string_of( conformation_viewers.size() + new_conformation_viewers.size() ) :
486 std::cerr <<
"attaching viewers!!!!" << std::endl;
487 mc.attach_observer_to_last_accepted_conformation( *viewer1 );
488 mc.attach_observer_to_lowest_score_conformation ( *viewer2 );
490 new_conformation_viewers.push_back( viewer1 );
491 new_conformation_viewers.push_back( viewer2 );
493 pthread_mutex_unlock( &new_conformation_viewers_mut );
496 pthread_cond_broadcast( &start_cond );
502 silly_window_display()
505 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
517 silly_window_init() {
520 glutInitWindowSize (500, 500);
521 glutInitWindowPosition (100, 100);
523 glutCreateWindow (
"silly_window" );
525 glutDisplayFunc( silly_window_display );
531 glClearColor (0.0, 0.0, 0.0, 0.0);
540 pthread_create ( &p, NULL, worker_main, NULL );
544 char * argv[] = {
"test"};
545 glutInit( &argc, argv );
547 glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );
552 pthread_mutex_lock( &start_mut );
553 if ( new_conformation_viewers.empty() ) {
554 pthread_cond_wait( &start_cond, &start_mut );
556 pthread_mutex_unlock( &start_mut );
558 check_for_new_conformation_viewers();
560 glutIdleFunc( idle_func );
569 #if defined GL_GRAPHICS || defined BOINC_GRAPHICS
575 glVertex3fxyz(
Vector const & coord )
577 glVertex3f((
float)coord.x(), (float)coord.y(), (float)coord.z() );
582 runtime_assert( new_bg_color.x() >= 0 );
583 runtime_assert( new_bg_color.y() >= 0 );
584 runtime_assert( new_bg_color.z() >= 0 );
585 graphics::bg_color = new_bg_color;
591 glColor3fxyz(
Vector const & coord )
593 glColor3f((
float)coord.x(), (float)coord.y(), (float)coord.z() );
603 if ( element ==
"N" ) {
604 return Vector(0.0, 0.0, 1.0 );
605 }
else if ( element ==
"O" ) {
606 return Vector(1.0, 0.0, 0.0 );
607 }
else if ( element ==
"S") {
608 return Vector(1.0, 1.0, 0.0 );
609 }
else if ( element ==
"P") {
610 return Vector(1.0, 0.5, 0.0 );
611 }
else if ( element ==
"H") {
612 return Vector(1.0, 1.0, 1.0 );
615 return Vector(0.5, 0.5, 0.5 );
619 inline float dgaussian(
float x,
float mean,
float sd )
621 float sqrt_2pi = 2.50662721600161f;
622 float sd_sq = sd * sd;
623 float mean_diff_sq = (x - mean) * (x - mean);
624 return 1 / (sd * sqrt_2pi) * std::exp( -1 * mean_diff_sq / ( 2 * sd_sq ) );
633 float factor = (float) res.
seqpos() / (float) total_residue;
635 factor = (max - min) * factor + min;
637 float red =
dgaussian( factor, 0.75, sd );
638 float green =
dgaussian( factor, 0.50, sd );
639 float blue =
dgaussian( factor, 0.25, sd );
641 Vector color( red, green, blue );
646 void rainbow_color(
float frac ,
float & red,
float & green,
float & blue ,
bool mute_color ) {
648 float my_color = frac;
650 blue = 1.0 - my_color ;
651 green = (my_color < .5) ? 2.0*my_color : 2.0-2.0*my_color;
653 float saturation = sqrt(red*red + green*green + blue*blue);
654 red = muting*red/saturation;
655 green = muting*green/saturation;
656 blue = muting*blue/saturation;
660 void chain_color(
int const chain,
float & red,
float & green,
float & blue ) {
661 static int const num_color = 5;
662 int chain_local = chain%num_color;
663 switch ( chain_local ) {
698 void get_residue_color(
float i,
float & red,
float & green,
float & blue,
bool mute_color,
int total_residue ) {
700 if (i > total_residue) i_local = total_residue;
701 rainbow_color (
float(i_local) /
float(total_residue), red, green, blue, mute_color);
705 std::map<std::string, Vector> get_sidechain_color_rhiju() {
707 std::map<std::string, Vector> sidechain_color_rhiju;
709 sidechain_color_rhiju[
"ALA" ] =
Vector( 0.3, 0.3, 0.3);
710 sidechain_color_rhiju[
"CYS" ] =
Vector( 0.7, 0.7, 0.0);
711 sidechain_color_rhiju[
"ASP" ] =
Vector( 0.7, 0.0, 0.0);
712 sidechain_color_rhiju[
"GLU" ] =
Vector( 0.7, 0.0, 0.0);
713 sidechain_color_rhiju[
"PHE" ] =
Vector( 0.3, 0.3, 0.3);
714 sidechain_color_rhiju[
"GLY" ] =
Vector( 0.7, 0.5, 0.0);
715 sidechain_color_rhiju[
"HIS" ] =
Vector( 0.0, 0.0, 0.7);
716 sidechain_color_rhiju[
"ILE" ] =
Vector( 0.3, 0.3, 0.3);
717 sidechain_color_rhiju[
"LYS" ] =
Vector( 0.0, 0.0, 0.7);
718 sidechain_color_rhiju[
"LEU" ] =
Vector( 0.3, 0.3, 0.3);
719 sidechain_color_rhiju[
"MET" ] =
Vector( 0.3, 0.3, 0.3);
720 sidechain_color_rhiju[
"ASN" ] =
Vector( 0.0, 0.5, 0.0);
721 sidechain_color_rhiju[
"PRO" ] =
Vector( 0.3, 0.3, 0.3);
722 sidechain_color_rhiju[
"GLN" ] =
Vector( 0.0, 0.5, 0.0);
723 sidechain_color_rhiju[
"ARG" ] =
Vector( 0.0, 0.0, 0.7);
724 sidechain_color_rhiju[
"SER" ] =
Vector( 0.0, 0.5, 0.0);
725 sidechain_color_rhiju[
"THR" ] =
Vector( 0.0, 0.5, 0.0);
726 sidechain_color_rhiju[
"VAL" ] =
Vector( 0.3, 0.3, 0.3);
727 sidechain_color_rhiju[
"TRP" ] =
Vector( 0.3, 0.3, 0.3);
728 sidechain_color_rhiju[
"TYR" ] =
Vector( 0.0, 0.5, 0.0);
729 sidechain_color_rhiju[
"SEP" ] =
Vector( 0.5, 0.5, 0.0);
730 sidechain_color_rhiju[
"GUA" ] =
Vector( 0.0, 0.0, 0.5);
731 sidechain_color_rhiju[
"ADE" ] =
Vector( 0.5, 0.5, 0.0);
732 sidechain_color_rhiju[
"CYT" ] =
Vector( 0.0, 0.5, 0.0);
733 sidechain_color_rhiju[
"THY" ] =
Vector( 0.5, 0.0, 0.0);
734 sidechain_color_rhiju[
"RGU" ] =
Vector( 0.0, 0.0, 0.5);
735 sidechain_color_rhiju[
"RAD" ] =
Vector( 0.5, 0.5, 0.0);
736 sidechain_color_rhiju[
"RCY" ] =
Vector( 0.0, 0.5, 0.0);
737 sidechain_color_rhiju[
"URA" ] =
Vector( 0.5, 0.0, 0.0);
738 sidechain_color_rhiju[
" rG" ] =
Vector( 0.0, 0.0, 0.5);
739 sidechain_color_rhiju[
" rA" ] =
Vector( 0.5, 0.5, 0.0);
740 sidechain_color_rhiju[
" rC" ] =
Vector( 0.0, 0.5, 0.0);
741 sidechain_color_rhiju[
" rU" ] =
Vector( 0.5, 0.0, 0.0);
743 return sidechain_color_rhiju;
753 float red,green,blue;
754 static std::map<std::string, Vector> sidechain_color_rhiju = get_sidechain_color_rhiju();
756 switch ( gs.Color_mode ) {
759 return atom_color_by_element( residues[r]->atom_type(i).element());
762 rainbow_color(
float(r)/
float(residues.size()), red, green, blue,
true );
763 return Vector(red, green, blue);
766 if (sidechain_color_rhiju.find(residues[r]->name3()) != sidechain_color_rhiju.end() )
767 return sidechain_color_rhiju[residues[r]->name3()];
768 return Vector( 1.0, 0.5, 0.0);
771 chain_color( residues[r]->chain(), red, green, blue );
772 return Vector(red, green, blue);
775 if ( !residues[r]->atom_is_backbone(i) ) {
776 return atom_color_by_element( residues[r]->atom_type(i).element());
778 rainbow_color(
float(r)/
float(residues.size()), red, green, blue,
true );
779 return Vector(red, green, blue);
782 if ( !residues[r]->atom_is_backbone(i) ) {
783 return atom_color_by_element( residues[r]->atom_type(i).element());
785 if (sidechain_color_rhiju.find(residues[r]->name3()) != sidechain_color_rhiju.end() )
786 return sidechain_color_rhiju[residues[r]->name3()];
787 return Vector( 1.0, 1.0, 1.0);
790 if ( residues[r]->is_virtual(i) ){
791 return Vector( 1.0, 1.0, 1.0 );
792 }
else if ( residues[r]->atom_is_backbone(i) ) {
793 rainbow_color(
float(r)/
float(residues.size()), red, green, blue,
false );
794 return Vector(red, green, blue);
795 }
else if ( sidechain_color_rhiju.find(residues[r]->name3()) != sidechain_color_rhiju.end() ) {
796 return sidechain_color_rhiju[ residues[r]->name3() ];
799 return Vector( 1.0, 1.0, 1.0);
805 display_residues_wireframe(
810 using namespace conformation;
811 using namespace chemical;
817 glMatrixMode(GL_MODELVIEW);
818 GLfloat currentrotation[16];
819 glGetFloatv(GL_MODELVIEW_MATRIX, currentrotation);
820 Vector const z( currentrotation[2], currentrotation[6], currentrotation[10] );
822 Size const nres( residues.size() );
824 for (
Size i=1; i<= nres; ++i ) {
826 Size const natoms( rsd.natoms() );
829 if ( i>1 && !rsd.is_lower_terminus() && rsd.is_polymer() ) {
831 Residue const & prev_rsd( *(residues[i-1]));
832 int const atom1( prev_rsd.mainchain_atoms()[ prev_rsd.n_mainchain_atoms() ] );
833 int const atom2( rsd.mainchain_atoms()[ 1 ] );
835 Vector const color1( get_atom_color( gs, residues, i-1, atom1 ) );
836 Vector const color2( get_atom_color( gs, residues, i , atom2 ) );
838 Vector const xyz1( prev_rsd.xyz( atom1 ) - center );
839 Vector const xyz2( rsd.xyz( atom2 ) - center );
841 Vector const bond( xyz2 - xyz1 );
842 if (bond.length_squared() <= graphics::BOND_LENGTH_CUTOFF2 ) {
844 Vector width( cross( bond, z ) );
845 if ( width.length_squared() ) width.normalize();
846 width *= graphics::protein_wireframeScale;
850 glColor3fxyz( color1 );
852 glVertex3fxyz ( xyz1 + width );
853 glVertex3fxyz ( xyz1 - width );
854 glColor3fxyz( color2 );
855 glVertex3fxyz ( xyz2 - width );
856 glVertex3fxyz ( xyz2 + width );
865 for (
Size m=1; m<= natoms; ++m ) {
867 AtomIndices const & nbrs( rsd.bonded_neighbor(m) );
869 for (
Size jj=1; jj<= nbrs.size(); ++jj ) {
870 Size const n( nbrs[jj] );
871 if ( n < m )
continue;
874 Vector const color1( get_atom_color( gs, residues, i, m ) );
875 Vector const color2( get_atom_color( gs, residues, i, n ) );
877 Vector const xyz1( rsd.xyz(m) - center );
878 Vector const xyz2( rsd.xyz(n) - center );
880 Vector const bond( xyz2 - xyz1 );
885 Vector width( cross( bond, z ) );
886 if ( width.length_squared() ) width.normalize();
887 width *= graphics::protein_wireframeScale;
889 if ( rsd.atom_type(m).is_hydrogen() || rsd.atom_type(n).is_hydrogen() || rsd.is_virtual(m) || rsd.is_virtual(n) ) width *= 0.5;
891 glColor3fxyz( color1 );
893 if ( prev_set[ m ] ) {
896 glVertex3fxyz ( prev1[m] );
897 glVertex3fxyz ( xyz1 + width );
898 glVertex3fxyz ( xyz1 - width );
899 glVertex3fxyz ( prev2[m] );
903 prev1[m] = xyz1 - width;
904 prev2[m] = xyz1 + width;
908 glVertex3fxyz ( xyz1 + width );
909 glVertex3fxyz ( xyz1 - width );
910 glColor3fxyz( color2 );
911 glVertex3fxyz ( xyz2 - width );
912 glVertex3fxyz ( xyz2 + width );
915 if ( !prev_set[n] ) {
918 prev1[n] = xyz2 + width;
919 prev2[n] = xyz2 - width;
923 glVertex3fxyz ( prev1[n] );
924 glVertex3fxyz ( xyz2 - width );
925 glVertex3fxyz ( xyz2 + width );
926 glVertex3fxyz ( prev2[n] );
944 void get_direction(
Vector & direction,
const int & next_res,
const int & prior_res,
946 direction = residues[ next_res ]->xyz(
"CA" ) - residues[ prior_res ]->xyz(
"CA" );
947 if (direction.length_squared() > 0.00001) direction.normalize();
952 normal = cross( (residues[ n ]->
xyz(
"CA" )-residues[ n-1 ]->
xyz(
"CA" )),
953 (residues[ n+1 ]->
xyz(
"CA" )-residues[ n ]->
xyz(
"CA" )) );
954 if (normal.length_squared() > 0.00001) normal.normalize();
958 void get_axis_and_tangent(
Vector & axis,
Vector & tangent,
962 axis = std::cos(HELIX_ALPHA) * normal + std::sin(HELIX_ALPHA) * direction;
964 tangent = std::cos(HELIX_BETA) * direction + std::sin(HELIX_BETA) * normal;
970 const float & p,
const float & hermite_factor) {
978 return (h1*prev_CA + h2*current_CA + h3*hermite_factor*prev_tangent + h4*hermite_factor*tangent);
982 float get_half_width(
const std::string & taper,
const float & secstruct_half_width,
const float & p ) {
983 const Real PI = numeric::NumericTraits<Real>::pi();
986 if (taper ==
"start"){
987 half_width = graphics::COILRADIUS + (secstruct_half_width - graphics::COILRADIUS)*
988 0.5 * ( - cos( PI * p ) + 1.0 );
991 half_width = graphics::COILRADIUS + (secstruct_half_width - graphics::COILRADIUS)*
992 0.5 * ( cos( PI * p ) + 1.0 );
994 if (taper ==
"strand_ultimate"){
995 half_width = graphics::COILRADIUS + (2*secstruct_half_width - graphics::COILRADIUS) * (1 - p);
1001 void set_initial_polygon_vertices(
const Vector & vec1,
const Vector & vec2, GraphicsState & gs) {
1002 gs.previous_vertex1 = vec1;
1003 gs.previous_vertex2 = vec2;
1004 gs.previous_width_vector = 0.0;
1008 void draw_next_polygon(
const Vector & vec1,
const Vector & vec2,
1009 const float & red,
const float & green,
const float & blue,
const int & aa,
1011 bool is_coil =
false,
1012 bool darken_inside =
false) {
1016 const bool show_thickness =
true;
1019 core::Real showbondcutoff2 = (is_coil) ? graphics::SHOWBONDCUTOFF2_COIL : graphics::SHOWBONDCUTOFF2;
1021 const core::Real bond_length2 = ((vec1 + vec2)/2.0 - (gs.previous_vertex1 + gs.previous_vertex2)/2.0).length_squared();
1022 if (!show_thickness) {
1023 glColor3f(red,green,blue);
1024 glBegin(GL_POLYGON);
1025 glVertex3fxyz ( gs.previous_vertex1 );
1026 glVertex3fxyz ( gs.previous_vertex2 );
1027 glVertex3fxyz ( vec2 );
1028 glVertex3fxyz ( vec1 );
1029 glVertex3fxyz ( gs.previous_vertex1 );
1032 width_vector = cross( (vec1 + vec2) - (gs.previous_vertex1 + gs.previous_vertex2),
1033 (vec1 + gs.previous_vertex1) - (vec2 + gs.previous_vertex2) );
1034 if (width_vector.length_squared() > 0.000001) width_vector.normalize();
1035 const float cartoon_width = 0.3;
1036 width_vector *= -1.0f * cartoon_width;
1038 if (gs.previous_width_vector == 0.0) gs.previous_width_vector = width_vector;
1040 if (bond_length2 < showbondcutoff2 ) {
1042 glColor3f(red,green,blue);
1043 glBegin(GL_POLYGON);
1044 glVertex3fxyz ( gs.previous_vertex1 + gs.previous_width_vector );
1045 glVertex3fxyz ( gs.previous_vertex2 + gs.previous_width_vector );
1046 glVertex3fxyz ( vec2 + width_vector );
1047 glVertex3fxyz ( vec1 + width_vector );
1051 if (darken_inside) glColor3f(0.5*red,0.5*green,0.5*blue);
1052 glBegin(GL_POLYGON);
1053 glVertex3fxyz ( gs.previous_vertex1 - gs.previous_width_vector );
1054 glVertex3fxyz ( gs.previous_vertex2 - gs.previous_width_vector );
1055 glVertex3fxyz ( vec2 - width_vector );
1056 glVertex3fxyz ( vec1 - width_vector );
1060 glColor3f(0.7*red,0.7*green,0.7*blue);
1061 glBegin(GL_POLYGON);
1062 glVertex3fxyz ( gs.previous_vertex1 + gs.previous_width_vector );
1063 glVertex3fxyz ( vec1 + width_vector );
1064 glVertex3fxyz ( vec1 - width_vector );
1065 glVertex3fxyz ( gs.previous_vertex1 - gs.previous_width_vector );
1067 glBegin(GL_POLYGON);
1068 glVertex3fxyz ( gs.previous_vertex2 + gs.previous_width_vector );
1069 glVertex3fxyz ( vec2 + width_vector );
1070 glVertex3fxyz ( vec2 - width_vector );
1071 glVertex3fxyz ( gs.previous_vertex2 - gs.previous_width_vector );
1077 gs.previous_vertex1 = vec1;
1078 gs.previous_vertex2 = vec2;
1079 gs.previous_width_vector = width_vector;
1083 void draw_secstruct_chunk(
1085 const Vector & current_CA,
1086 const Vector & prev_tangent,
1088 const Vector & prev_axis,
1091 const char & secstruct_res,
1096 float hermite_factor;
1097 float red( 0.0 ), green( 0.0 ), blue( 0.0 );
1098 float secstruct_half_width;
1100 if (secstruct_res ==
'H'){
1101 secstruct_half_width = graphics::HELIX_HALF_WIDTH;
1102 darken_inside =
true;
1103 hermite_factor = graphics::HELIX_HERMITE_FACTOR;
1104 }
else if ( secstruct_res ==
'E' ){
1105 secstruct_half_width = graphics::STRAND_HALF_WIDTH;
1106 darken_inside =
false;
1107 hermite_factor = graphics::STRAND_HERMITE_FACTOR;
1109 runtime_assert( secstruct_res ==
'N' );
1110 secstruct_half_width = graphics::STRAND_HALF_WIDTH;
1111 darken_inside =
true;
1112 hermite_factor = graphics::NA_HERMITE_FACTOR;
1114 Vector axis_segment, CA_segment;
1115 for (
int s = 1; s <= graphics::NUM_SEGMENTS; s++ ){
1117 axis_segment = p*axis + (1-p)*prev_axis;
1118 CA_segment = get_CA_segment( prev_CA, current_CA, prev_tangent, tangent, p, hermite_factor);
1120 chain_color( residues[n]->chain(), red, green, blue );
1122 get_residue_color( static_cast<float>(n - 1) + p, red, green, blue,
false, residues.size());
1124 const core::Real half_width = get_half_width( taper, secstruct_half_width, p );
1125 draw_next_polygon(CA_segment - half_width*axis_segment, CA_segment + half_width*axis_segment,
1126 red,green,blue, n, gs,
false, darken_inside);
1138 const int total_residue = residues.size();
1141 int prior_res( start-1 );
1142 if (prior_res < 1) prior_res = 1;
1143 Vector direction, normal, tangent, axis, current_CA;
1144 Vector prev_CA, prev_tangent, prev_axis;
1147 int next_res = start + 1;
1148 if (next_res > total_residue-1) next_res = total_residue-1;
1149 get_direction( direction, next_res+1, next_res-1, residues);
1150 get_normal( normal, next_res, residues );
1151 get_axis_and_tangent( axis, tangent, direction, normal );
1153 get_direction(direction, start+1, prior_res, residues);
1154 tangent = direction;
1155 current_CA = residues[
start ]->xyz(
"CA" );
1157 set_initial_polygon_vertices( current_CA - graphics::HELIX_HALF_WIDTH*axis,
1158 current_CA + graphics::HELIX_HALF_WIDTH*axis, gs);
1161 prev_CA = current_CA;
1162 prev_tangent = tangent;
1167 for (
int n = start+1; n<=end-1; n++){
1169 get_direction( direction, n+1, n-1, residues );
1170 get_normal( normal, n, residues );
1171 get_axis_and_tangent( axis, tangent, direction, normal);
1172 current_CA = residues[ n ]->xyz(
"CA" );
1173 draw_secstruct_chunk( prev_CA, current_CA, prev_tangent, tangent, prev_axis, axis, n,
1174 'H', taper, gs, residues);
1177 prev_CA = current_CA;
1178 prev_tangent = tangent;
1187 get_direction( direction, end, end - 1, residues);
1188 tangent = direction;
1189 current_CA = residues[
end ]->xyz(
"CA" );
1191 draw_secstruct_chunk( prev_CA, current_CA, prev_tangent, tangent, prev_axis, axis, end,
1192 'H', taper, gs, residues);
1202 const int total_residue = residues.size();
1208 int prior_res( start-1 );
1209 if (prior_res < 1) prior_res = 1;
1210 Vector direction, normal, tangent, axis, current_CA, prev_CA, prev_direction, prev_normal;
1213 int next_res = start + 1;
1214 if (next_res > total_residue-1) next_res = total_residue-1;
1215 get_direction( direction, next_res+1, next_res-1, residues);
1216 get_normal( normal, next_res, residues );
1218 current_CA = residues[
start ]->xyz(
"CA" );
1220 set_initial_polygon_vertices( current_CA - graphics::STRAND_HALF_WIDTH*normal,
1221 current_CA + graphics::STRAND_HALF_WIDTH*normal, gs);
1224 prev_CA = current_CA;
1225 prev_normal = normal;
1226 prev_direction = direction;
1230 for (
int n = start+1; n<=end-1; n++){
1232 get_direction( direction, n+1, n-1, residues);
1233 get_normal( normal, n, residues );
1234 if ( dot(normal, prev_normal) < 0.0 ) normal *= -1.0;
1235 current_CA = residues[ n ]->xyz(
"CA" );
1236 draw_secstruct_chunk( prev_CA, current_CA, prev_direction, direction, prev_normal, normal, n,
1237 'E', taper, gs, residues);
1240 prev_CA = current_CA;
1241 prev_normal = normal;
1242 prev_direction = direction;
1248 if (next_res > total_residue) next_res = total_residue;
1249 get_direction( direction, next_res, end - 1, residues);
1250 tangent = direction;
1251 current_CA = residues[
end ]->xyz(
"CA" );
1252 taper =
"strand_ultimate";
1253 draw_secstruct_chunk( prev_CA, current_CA, prev_direction, direction, prev_normal, normal, end,
1254 'E', taper, gs, residues);
1258 void draw_coil_chunk(
1260 const Vector & current_CA,
1261 const Vector & prev_tangent,
1266 float red( 0.0 ), green( 0.0 ), blue( 0.0 );
1268 Vector axis_segment, CA_segment, prev_CA_segment, bond, prev_bond;
1270 GLfloat currentrotation[16];
1271 glGetFloatv(GL_MODELVIEW_MATRIX, currentrotation);
1272 Vector z(currentrotation[2],currentrotation[6],currentrotation[10]);
1274 prev_CA_segment = prev_CA;
1275 prev_bond = current_CA - prev_CA;
1276 for (
int s = 1; s <= graphics::NUM_SEGMENTS_COIL; s++ ){
1277 const float p = s /
static_cast<float>(graphics::NUM_SEGMENTS_COIL);
1278 CA_segment = get_CA_segment( prev_CA, current_CA, prev_tangent, tangent, p, graphics::COIL_HERMITE_FACTOR);
1280 chain_color( residues[n]->chain(), red, green, blue );
1282 get_residue_color ( static_cast<float>(n) + p, red, green, blue,
false, residues.size());
1285 bond = CA_segment - prev_CA_segment;
1286 Vector width = cross( bond, z );
1287 if (width.length_squared() > 0.0001 ) width.normalize();
1288 width = (width - 0.5*z).normalized();
1289 width *= graphics::COILRADIUS;
1291 draw_next_polygon( CA_segment + width, CA_segment - width, red, green, blue, n, gs,
false );
1293 prev_CA_segment = CA_segment;
1304 const int total_residue = residues.size();
1307 Vector prev_CA, prev_direction, direction, current_CA;
1308 prev_CA = residues[
start ]->xyz(
"CA" );
1309 get_direction( prev_direction, start+1, start, residues );
1311 set_initial_polygon_vertices( prev_CA, prev_CA, gs );
1312 for (
int n = start; n <= end-1; n++){
1313 if (n < end-1 && end < total_residue)
1314 get_direction( direction, n+2, n, residues);
1316 get_direction( direction, n+1, n, residues);
1317 current_CA = residues[ n+1 ]->xyz(
"CA" );
1318 draw_coil_chunk( prev_CA, current_CA, prev_direction, direction, n, gs, residues);
1320 prev_CA = current_CA;
1321 prev_direction = direction;
1327 const int & start_segment,
1328 const int & end_segment,
1329 const char & prev_secstruct,
1332 const int size_segment = end_segment - start_segment + 1;
1333 if (start_segment >= end_segment)
return;
1334 if (prev_secstruct==
'H' && size_segment >= 4)
1335 draw_helix( start_segment, end_segment, gs, residues );
1336 else if (prev_secstruct==
'E' && size_segment >= 2)
1337 draw_strand( start_segment, end_segment, gs, residues );
1339 draw_coil( start_segment, end_segment, gs, residues );
1344 if (i==1)
return false;
1346 float chainbreak_cutoff2 = graphics::CHAINBREAK_CUTOFF2;
1347 Vector vec = residues[i]->xyz(
"CA");
1348 Vector vec_prev = residues[i-1]->xyz(
"CA");
1349 const float dist2 = (vec-vec_prev).length_squared();
1350 if ( dist2 > chainbreak_cutoff2) {
1358 void draw_secstruct(
1362 int const begin,
int const end)
1365 char prev_secstruct = ss[ begin ];
1367 int start_segment( begin );
1368 bool is_chainbreak =
false;
1370 int protein_end = 0;
1371 for (
int i = begin+1; i<=
end; i++) {
1372 if ( ! (residues[i-1]->is_protein() && residues[i]->is_protein()) )
continue;
1373 char current_secstruct = ss[ i ];
1376 if (current_secstruct != prev_secstruct || check_chainbreak(i, residues)) {
1377 int const end_segment = i - 1;
1378 draw_segment( start_segment, end_segment, prev_secstruct, gs, residues );
1384 if ( !check_chainbreak(i, residues)) {
1385 draw_segment( end_segment, end_segment+1,
'L', gs, residues );
1388 prev_secstruct = current_secstruct;
1391 draw_segment( start_segment, protein_end, prev_secstruct, gs, residues );
1396 void draw_Calpha_trace(
1399 const int & start,
const int & end,
float xwidth = 0.5)
1402 GLfloat currentrotation[16];
1403 glGetFloatv(GL_MODELVIEW_MATRIX, currentrotation);
1404 Vector z(currentrotation[2],currentrotation[6],currentrotation[10]);
1406 const Vector z_halo = z * z_offset;
1408 Vector prev1( 0.0 ), prev2( 0.0 );
1409 bool last_bonded =
false;
1410 for (
int i = start; i<
end ; i++ ) {
1411 if ( ! (residues[i]->is_protein() && residues[i+1]->is_protein()) )
continue;
1413 Vector ca_pos1tmp = residues[i]->xyz(
"CA");
1414 Vector ca_pos2tmp = residues[i+1]->xyz(
"CA");
1415 ca_pos1 = ca_pos1tmp;
1416 ca_pos2 = ca_pos2tmp;
1419 bond = ca_pos2 - ca_pos1;
1420 Vector width( cross( bond, z ));
1421 if ( width.length_squared() > 0.0001 ) width.normalize();
1424 float red, green, blue;
1426 chain_color( residues[i]->chain(), red, green, blue );
1428 get_residue_color( i, red, green, blue,
false, residues.size() );
1430 if ( i > 1 && last_bonded) {
1431 glColor3f(red, green, blue);
1432 glBegin(GL_POLYGON);
1433 glVertex3fxyz ( prev1 );
1434 glVertex3fxyz ( ca_pos1 + width );
1435 glVertex3fxyz ( ca_pos1 - width );
1436 glVertex3fxyz ( prev2 );
1441 glVertex3fxyz ( prev1 );
1442 glVertex3fxyz ( ca_pos1 + width );
1443 glVertex3fxyz ( ca_pos1 - width );
1444 glVertex3fxyz ( prev2 );
1447 last_bonded =
false;
1448 if (bond.length_squared() < 16) {
1450 glColor3f(red, green, blue);
1451 glBegin(GL_POLYGON);
1452 glVertex3fxyz ( ca_pos1 + width );
1453 glVertex3fxyz ( ca_pos2 + width );
1454 glVertex3fxyz ( ca_pos2 - width );
1455 glVertex3fxyz ( ca_pos1 - width );
1460 glVertex3fxyz ( z_halo + ca_pos1 + width );
1461 glVertex3fxyz ( z_halo + ca_pos2 + width );
1462 glVertex3fxyz ( z_halo + ca_pos2 - width );
1463 glVertex3fxyz ( z_halo + ca_pos1 - width );
1466 prev1 = ca_pos2 + width;
1467 prev2 = ca_pos2 - width;
1477 if (gs.SCdisplay_state ==
SHOW_NOSC)
return;
1479 GLfloat currentrotation[16];
1480 glGetFloatv(GL_MODELVIEW_MATRIX, currentrotation);
1481 Vector z(currentrotation[2],currentrotation[6],currentrotation[10]);
1483 float xwidth = graphics::protein_stickScale;
1484 for (
int r = start; r<=
end ; ++r ) {
1486 if (residues[r]->is_ligand() && gs.SCdisplay_state !=
SHOW_STICK
1489 if (!residues[r]->is_ligand() && gs.SCdisplay_state ==
SHOW_WIREFRAME)
1490 xwidth = graphics::protein_wireframeScale;
1495 Size const natoms( residues[r]->natoms() );
1501 for (
Size i=1; i<= natoms; ++i ) {
1504 for (
Size jj=1; jj<= nbrs.size(); ++jj ) {
1505 Size const j( nbrs[jj] );
1506 if ( j < i )
continue;
1507 if ( residues[r]->is_virtual(j) )
continue;
1508 if ( residues[r]->atom_type(j).is_hydrogen() && gs.show_H_state ==
SHOW_NO_H )
continue;
1511 Vector const color1 = get_atom_color( gs, residues, r, i );
1512 Vector const color2 = get_atom_color( gs, residues, r, j );
1514 Vector const xyz1( residues[r]->
xyz(i));
1515 Vector const xyz2( residues[r]->
xyz(j));
1517 Vector const bond( xyz2 - xyz1 );
1520 if (bond.length_squared() > graphics::BOND_LENGTH_CUTOFF2 )
break;
1522 Vector width( cross( bond, z ) );
1523 if ( width.length_squared() ) width.normalize();
1526 if ( residues[r]->atom_type(j).is_hydrogen() ) width *= 0.5;
1528 glColor3fxyz( color1 );
1530 if ( prev_set[ i ] ) {
1532 glBegin(GL_POLYGON);
1533 glVertex3fxyz ( prev1[i] );
1534 glVertex3fxyz ( xyz1 + width );
1535 glVertex3fxyz ( xyz1 - width );
1536 glVertex3fxyz ( prev2[i] );
1540 prev1[i] = xyz1 - width;
1541 prev2[i] = xyz1 + width;
1544 glBegin(GL_POLYGON);
1545 glVertex3fxyz ( xyz1 + width );
1546 glVertex3fxyz ( xyz1 - width );
1547 glColor3fxyz( color2 );
1548 glVertex3fxyz ( xyz2 - width );
1549 glVertex3fxyz ( xyz2 + width );
1552 if ( !prev_set[j] ) {
1555 prev1[j] = xyz2 + width;
1556 prev2[j] = xyz2 - width;
1559 glBegin(GL_POLYGON);
1560 glVertex3fxyz ( prev1[j] );
1561 glVertex3fxyz ( xyz2 - width );
1562 glVertex3fxyz ( xyz2 + width );
1563 glVertex3fxyz ( prev2[j] );
1577 switch( gs.BBdisplay_state ) {
1579 draw_Calpha_trace( gs, residues, 1, residues.size() );
1582 draw_secstruct( gs, residues, ss, 1, residues.size() );
1594 using namespace graphics;
1597 const int nres = residues.size();
1598 glPushAttrib(GL_ENABLE_BIT);
1599 glEnable(GL_LIGHTING);
1601 GLUquadricObj *sphereObj = gluNewQuadric();
1603 gluQuadricDrawStyle(sphereObj, GLU_FILL);
1604 gluQuadricNormals(sphereObj, GLU_SMOOTH);
1607 for (
int i = 1; i <= nres; i++ ) {
1612 float const sphere_opacity ( rsd.
is_protein() ? protein_sphere_opacity : ligand_sphere_opacity );
1613 float const sphere_shininess ( rsd.
is_protein() ? protein_sphere_shininess : ligand_sphere_shininess );
1616 int atom_begin = 1 ;
1617 int atom_end = rsd.
natoms();
1619 for (
int j = atom_begin; j <= atom_end; ++j ) {
1627 Vector const atom_color ( get_atom_color( gs, residues, i, j ) );
1630 GLfloat atom_material[4] = {
1636 GLfloat specular_material[4] = {
1637 atom_material[0] * sphere_opacity,
1638 atom_material[1] * sphere_opacity,
1639 atom_material[2] * sphere_opacity,
1645 for (
int color = 0 ; color < 3 ; color++) {
1646 atom_material[color] *= 1.5;
1647 if (atom_material[color] > 1.0)
1648 atom_material[color] = 1.0;
1650 if (atom_material[3] < 0.1)
1651 atom_material[3] = 0.1;
1653 if (atom_material[3] < 0.1)
continue;
1654 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, atom_material);
1655 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, atom_material);
1656 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular_material);
1657 glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, &sphere_shininess);
1663 if ( graphics::sphereDisplayList == 0 ) {
1664 const int SPHERE_SLICES(16), SPHERE_STACKS(16);
1665 float sphereRadius(1.0);
1666 graphics::sphereDisplayList = glGenLists(1);
1667 runtime_assert(graphics::sphereDisplayList != 0);
1669 glNewList(graphics::sphereDisplayList, GL_COMPILE);
1670 gluSphere(sphereObj, sphereRadius, SPHERE_SLICES, SPHERE_STACKS);
1673 if( graphics::sphereDisplayList != 0) {
1674 float sphereRadius, sphereScale(1.0);
1675 const float scale_for_display_list(1.0);
1676 sphereScale = 1.0 * scale_for_display_list ;
1677 sphereRadius = sphereScale * rsd.
atom_type_set()[ atom.type() ].lj_radius();
1678 glScalef(sphereRadius, sphereRadius, sphereRadius);
1680 glCallList(graphics::sphereDisplayList);
1687 gluDeleteQuadric(sphereObj);
1688 glDisable(GL_LIGHTING);
1696 void render_density(
1700 if (!gs.density_redraw)
return;
1708 numeric::xyzVector_float vertex[3], normal[3];
1710 while (tri_it.hasNext()) {
1711 tri_it.next( vertex, normal );
1712 for (
int j=0; j<3; ++j) {
1713 edm.
idx2cart( vertex[j] , cart_vi[j] );
1715 cart_ni[j].normalize();
1720 triangles.push_back(
triangle( cart_vi, cart_ni ) );
1734 using namespace conformation;
1735 using namespace chemical;
1737 if (triangles.size() == 0)
return;
1740 glMatrixMode(GL_MODELVIEW);
1741 GLfloat currentrotation[16];
1742 glGetFloatv(GL_MODELVIEW_MATRIX, currentrotation);
1743 numeric::xyzVector_float
const z( currentrotation[2], currentrotation[6], currentrotation[10] );
1745 glPushAttrib(GL_ENABLE_BIT);
1747 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1748 glEnable(GL_LIGHTING);
1749 glColorMaterial ( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ) ;
1750 glEnable ( GL_COLOR_MATERIAL ) ;
1751 glDisable( GL_DEPTH_TEST );
1756 triangles[i].update( z );
1759 std::sort( triangles.begin(), triangles.end() );
1761 glBegin(GL_TRIANGLES);
1762 Vector const color( 0.8,0.8,0.8 );
1763 glColor4f( color[0], color[1], color[2], 0.3 );
1765 for (
Size i=1; i<=ntris; ++i ) {
1766 for (
Size j=0; j<3; ++j) {
1767 glNormal3f ( triangles[i].normals_[j][0] , triangles[i].normals_[j][1] , triangles[i].normals_[j][2] );
1768 glVertex3f ( triangles[i].vertices_[j][0], triangles[i].vertices_[j][1], triangles[i].vertices_[j][2] );
1774 glDisable(GL_LIGHTING);
1778 draw_conformation_and_density(
1786 using namespace graphics;
1787 const int total_residue = residues.size();
1790 glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
1793 glClearColor( bg_color.x(), bg_color.y(), bg_color.z(), 1.0 );
1796 glMatrixMode(GL_MODELVIEW);
1797 GLfloat currentrotation[16];
1798 glGetFloatv(GL_MODELVIEW_MATRIX, currentrotation);
1800 Vector const x( currentrotation[0], currentrotation[4], currentrotation[ 8] );
1801 Vector const y( currentrotation[1], currentrotation[5], currentrotation[ 9] );
1802 Vector const z( currentrotation[2], currentrotation[6], currentrotation[10] );
1804 Vector light2 = z - y - x;
1806 GLfloat light_position[] = { light[0], light[1], light[2], 0.0 };
1807 GLfloat light2_position[] = { light2[0], light2[1], light2[2], 0.0 };
1814 glEnable(GL_LIGHT0);
1815 glEnable(GL_LIGHT1);
1816 glEnable(GL_DEPTH_TEST);
1817 glShadeModel(GL_SMOOTH);
1819 glLightfv(GL_LIGHT0, GL_POSITION, light_position);
1820 glLightfv(GL_LIGHT1, GL_POSITION, light2_position);
1828 if ( total_residue > 0 ) {
1830 glTranslatef(-center.x(), -center.y(), -center.z());
1832 draw_backbone( gs, residues, ss );
1833 draw_sidechains( gs, residues, 1, total_residue );
1834 draw_sphere( gs, residues );
1836 render_density( gs, triangles );
1837 display_density( gs, triangles );
1852 using namespace graphics;
1853 const int total_residue = residues.size();
1855 #ifndef BOINC_GRAPHICS
1858 glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
1861 glClearColor( bg_color.x(), bg_color.y(), bg_color.z(), 1.0 );
1865 GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 };
1866 glEnable(GL_LIGHT0);
1867 glEnable(GL_DEPTH_TEST);
1868 glShadeModel(GL_SMOOTH);
1869 glLightfv(GL_LIGHT0, GL_POSITION, light_position);
1872 glTranslatef(-center.x(), -center.y(), -center.z());
1875 for (
Size n = 1; n <= residues.size(); n++ ){
1877 if ( rsd->is_protein() ) {
1878 residues_protein.push_back( rsd );
1880 other_residues.push_back( rsd );
1885 if ( residues_protein.size() > 0 ){
1886 draw_backbone( gs, residues_protein, ss );
1887 draw_sidechains( gs, residues_protein, 1, residues_protein.size() );
1888 draw_sphere( gs, residues_protein );
1891 if ( other_residues.size() > 0 ){
1892 ColorMode colormode_save = gs.Color_mode;
1894 display_residues_wireframe( gs, other_residues,
Vector( 0.0, 0.0, 0.0) );
1895 gs.Color_mode = colormode_save;
1899 glDisable(GL_LIGHT0);
1908 const bool centered) {
1915 residues[i] = pose.
residue(i);
1938 bool fullatom =
false
1942 viewer1(
new SilentObserver( name_in +
"_last_accepted", fullatom ) ),
1943 viewer2(
new SilentObserver( name_in +
"_best_accepted", fullatom ) );
1945 std::cout <<
"attaching viewers!" << std::endl;
1949 silent_observers.push_back( viewer1 );
1950 silent_observers.push_back( viewer2 );
1959 conformation_viewers.clear();