From 092f7d1747a94e45428654aecdd2edaff95ca362 Mon Sep 17 00:00:00 2001 From: ansgar <ansgar@5a81b35b-ba03-0410-adc8-b2c5c5119f08> Date: Sun, 11 Apr 2010 01:27:16 +0000 Subject: [PATCH] added hsc profile types; fixed hsc render glitches; reverted trace rendering to old style git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@1965 5a81b35b-ba03-0410-adc8-b2c5c5119f08 --- modules/gfx/pymod/export_gfx_obj.cc | 5 + modules/gfx/pymod/export_render_options.cc | 6 + modules/gfx/src/entity.cc | 4 + modules/gfx/src/gfx_object.cc | 7 +- modules/gfx/src/gfx_object.hh | 5 + modules/gfx/src/impl/cartoon_renderer.cc | 169 ++++++++++++++---- modules/gfx/src/impl/cartoon_renderer.hh | 5 +- modules/gfx/src/impl/entity_renderer.cc | 6 +- modules/gfx/src/impl/entity_renderer.hh | 6 +- modules/gfx/src/impl/tabulated_trig.cc | 6 +- modules/gfx/src/impl/trace_renderer.cc | 44 +++++ .../render_options/cartoon_render_options.cc | 39 +++- .../render_options/cartoon_render_options.hh | 10 +- modules/gfx/src/vertex_array.cc | 2 +- modules/gui/pymod/scene/hsc_widget.py | 130 ++++++++++---- 15 files changed, 356 insertions(+), 88 deletions(-) diff --git a/modules/gfx/pymod/export_gfx_obj.cc b/modules/gfx/pymod/export_gfx_obj.cc index bd45ff17d..de30f31ec 100644 --- a/modules/gfx/pymod/export_gfx_obj.cc +++ b/modules/gfx/pymod/export_gfx_obj.cc @@ -25,6 +25,10 @@ using namespace ost::gfx; #include "color_by_def.hh" +namespace { + void set_debug(GfxObj* o, unsigned int d) {o->Debug()=d;} + unsigned int get_debug(GfxObj* o) {return o->Debug();} +} void export_GfxObj() { @@ -76,6 +80,7 @@ void export_GfxObj() .def("SetOutlineExpandFactor",&GfxObj::SetOutlineExpandFactor) .def("SetOutlineExpandColor",&GfxObj::SetOutlineExpandColor) .def("SmoothVertices",&GfxObj::SmoothVertices) + .add_property("debug",get_debug,set_debug) .add_property("center", &GfxObj::GetCenter) COLOR_BY_DEF() ; diff --git a/modules/gfx/pymod/export_render_options.cc b/modules/gfx/pymod/export_render_options.cc index 5d2a95172..b27e55c46 100644 --- a/modules/gfx/pymod/export_render_options.cc +++ b/modules/gfx/pymod/export_render_options.cc @@ -92,18 +92,24 @@ void export_RenderOptions() .def("GetTubeRadius", &CartoonRenderOptions::GetTubeRadius) .def("SetTubeRatio", &CartoonRenderOptions::SetTubeRatio) .def("GetTubeRatio", &CartoonRenderOptions::GetTubeRatio) + .def("SetTubeProfileType", &CartoonRenderOptions::SetTubeProfileType) + .def("GetTubeProfileType", &CartoonRenderOptions::GetTubeProfileType) .def("SetHelixWidth", &CartoonRenderOptions::SetHelixWidth) .def("GetHelixWidth", &CartoonRenderOptions::GetHelixWidth) .def("SetHelixThickness", &CartoonRenderOptions::SetHelixThickness) .def("GetHelixThickness", &CartoonRenderOptions::GetHelixThickness) .def("SetHelixEcc", &CartoonRenderOptions::SetHelixEcc) .def("GetHelixEcc", &CartoonRenderOptions::GetHelixEcc) + .def("SetHelixProfileType", &CartoonRenderOptions::SetHelixProfileType) + .def("GetHelixProfileType", &CartoonRenderOptions::GetHelixProfileType) .def("SetStrandWidth", &CartoonRenderOptions::SetStrandWidth) .def("GetStrandWidth", &CartoonRenderOptions::GetStrandWidth) .def("SetStrandThickness", &CartoonRenderOptions::SetStrandThickness) .def("GetStrandThickness", &CartoonRenderOptions::GetStrandThickness) .def("SetStrandEcc", &CartoonRenderOptions::SetStrandEcc) .def("GetStrandEcc", &CartoonRenderOptions::GetStrandEcc) + .def("SetStrandProfileType", &CartoonRenderOptions::SetStrandProfileType) + .def("GetStrandProfileType", &CartoonRenderOptions::GetStrandProfileType) ; class_<TraceRenderOptions, boost::shared_ptr<TraceRenderOptions>, bases<RenderOptions>, boost::noncopyable>("TraceRenderOptions") diff --git a/modules/gfx/src/entity.cc b/modules/gfx/src/entity.cc index 54ddc5fad..faaff3f43 100644 --- a/modules/gfx/src/entity.cc +++ b/modules/gfx/src/entity.cc @@ -303,6 +303,10 @@ void Entity::CustomPreRenderGL(bool update) { if (update) { this->UpdateIfNeeded(); + for (RendererMap::iterator i=renderer_.begin(), + e=renderer_.end(); i!=e; ++i) { + i->second->Debug()=Debug(); + } } } diff --git a/modules/gfx/src/gfx_object.cc b/modules/gfx/src/gfx_object.cc index 392b177b0..7aaf85e38 100644 --- a/modules/gfx/src/gfx_object.cc +++ b/modules/gfx/src/gfx_object.cc @@ -44,6 +44,7 @@ GfxObj::GfxObj(const String& name): GfxNode(name), va_(), render_mode_(RenderMode::SIMPLE), + debug_flags_(0), transform_(), rebuild_(true), refresh_(false), @@ -59,7 +60,9 @@ GfxObj::GfxObj(const String& name): mat_update_(true), opacity_(1.0), smoothf_(0.0), - omode_(0) + omode_(0), + c_ops_(), + labels_() { } @@ -150,6 +153,8 @@ void GfxObj::RefreshVA(IndexedVertexArray& va) va.SetPolyMode(GetPolyMode()); va.SetAALines(GetAALines()); va.SetLineHalo(GetLineHalo()); + va.DrawNormals(debug_flags_&0x1); + va.SetPolyMode(debug_flags_&0x2 ? 1 : 2); va.FlagRefresh(); } diff --git a/modules/gfx/src/gfx_object.hh b/modules/gfx/src/gfx_object.hh index c3d9bd369..15500849d 100644 --- a/modules/gfx/src/gfx_object.hh +++ b/modules/gfx/src/gfx_object.hh @@ -252,6 +252,9 @@ public: const String& prop, const Color& c1, const Color& c2, float minv, float maxv); #endif + + unsigned int& Debug() {return debug_flags_;} + protected: void PreRenderGL(bool flag); @@ -270,6 +273,7 @@ public: IndexedVertexArray va_; RenderMode::Type render_mode_; + unsigned int debug_flags_; private: mol::Transform transform_; @@ -295,6 +299,7 @@ public: TextPrimList labels_; void render_labels() const; + }; }} //ns diff --git a/modules/gfx/src/impl/cartoon_renderer.cc b/modules/gfx/src/impl/cartoon_renderer.cc index e9b750232..08f0a0c3e 100644 --- a/modules/gfx/src/impl/cartoon_renderer.cc +++ b/modules/gfx/src/impl/cartoon_renderer.cc @@ -143,25 +143,31 @@ void CartoonRenderer::RebuildSplineObj(const SplineEntryList& l, std::vector<TraceProfile> profiles; float factor=is_sel ? 0.2 : 0.0; profiles.push_back(GetCircProfile(detail, - options_->GetTubeRadius()*options_->GetTubeRatio()+factor, - options_->GetTubeRadius()+factor, 1.0)); // tube + options_->GetTubeRadius()*options_->GetTubeRatio()+factor, + options_->GetTubeRadius()+factor, + options_->GetTubeProfileType(), + 1.0)); // tube if (!force_tube_) { profiles.push_back(GetCircProfile(detail, - options_->GetHelixWidth()+factor, - options_->GetHelixThickness()+factor, - options_->GetHelixEcc()+factor)); // helix + options_->GetHelixWidth()+factor, + options_->GetHelixThickness()+factor, + options_->GetHelixProfileType(), + options_->GetHelixEcc())); // helix profiles.push_back(GetCircProfile(detail, - options_->GetStrandWidth()+factor, - options_->GetStrandThickness()+factor, - options_->GetStrandEcc()+factor)); // strand + options_->GetStrandWidth()+factor, + options_->GetStrandThickness()+factor, + options_->GetStrandProfileType(), + options_->GetStrandEcc())); // strand profiles.push_back(GetCircProfile(detail, - 0.1*options_->GetStrandWidth()+factor, - options_->GetStrandThickness()+factor, - options_->GetStrandEcc()+factor)); // arrow end + 0.1*options_->GetStrandWidth()+factor, + options_->GetStrandThickness()+factor, + options_->GetTubeProfileType(), + 1.0)); // arrow end, tube profile profiles.push_back(GetCircProfile(detail, - 1.7*options_->GetStrandWidth()+factor, - 1.1*options_->GetStrandThickness()+factor, - options_->GetStrandEcc()+factor)); // arrow start + 1.7*options_->GetStrandWidth()+factor, + 1.1*options_->GetStrandThickness()+factor, + options_->GetStrandProfileType(), + options_->GetStrandEcc())); // arrow start } // iterate over all spline segments @@ -266,6 +272,7 @@ void CartoonRenderer::AssembleProfile(const TraceProfile& prof1, { // determine rotational offset with a heuristic routine int best_off=0; +#if 0 uint i1=0; uint i2=prof1.size()/4; uint i3=prof1.size()/2; @@ -285,6 +292,7 @@ void CartoonRenderer::AssembleProfile(const TraceProfile& prof1, best_off=oo; } } +#endif // assume both profiles have the same size for(unsigned int i1=0;i1<prof1.size();++i1) { @@ -292,9 +300,12 @@ void CartoonRenderer::AssembleProfile(const TraceProfile& prof1, unsigned int i3=(i1+best_off)%prof1.size(); unsigned int i4=(i1+best_off+1)%prof1.size(); +#if 1 va.AddTri(prof1[i1].id,prof1[i2].id,prof2[i3].id); va.AddTri(prof1[i2].id,prof2[i4].id,prof2[i3].id); - // curvature induces bow-tie artefacts with quads, hence triangles +#else + va.AddQuad(prof1[i1].id,prof1[i2].id,prof2[i4].id,prof2[i3].id); +#endif } } @@ -302,47 +313,131 @@ void CartoonRenderer::CapProfile(const impl::TraceProfile& p, const impl::SplineEntry& se, bool flipn, IndexedVertexArray& va) { - VertexID pi0 = va.Add(se.position,flipn ? -se.direction : se.direction, se.color1); + geom::Vec3 norm=flipn ? -se.direction : se.direction; + VertexID pi0 = va.Add(se.position,norm, se.color1); + std::vector<VertexID> vertices(p.size()); + for(unsigned int i=0;i<p.size();++i) { + vertices[i]=va.Add(p[i].v,norm,se.color1); + } for(unsigned int i1=0;i1<p.size();++i1) { unsigned int i2=(i1+1)%p.size(); if(flipn) { - va.AddTri(pi0,p[i2].id,p[i1].id); + va.AddTri(pi0,vertices[i2],vertices[i1]); } else { - va.AddTri(pi0,p[i1].id,p[i2].id); + va.AddTri(pi0,vertices[i1],vertices[i2]); } } } -TraceProfile CartoonRenderer::GetCircProfile(unsigned int detail, float rx, - float ry, float ex) -{ - TraceProfile prof; +namespace { + + template<unsigned int TYPE> + void circle_profile(TraceProfile& prof, float ecc); + + // algorithm to get a square x-section + template<> + void circle_profile<1>(TraceProfile& prof, float ecc) + { + unsigned int detail=prof.size()/4; + for(unsigned int i=0;i<detail;++i) { + float ang=0.5*M_PI*static_cast<float>(i)/static_cast<float>(detail); + float ca=cos(ang); + float sa=sin(ang); + float px=std::pow(ca,ecc); + float py=std::pow(sa,ecc); + prof[i]=TraceProfileEntry(geom::Vec3(px,py,0),geom::Vec3()); + prof[detail+i]=TraceProfileEntry(geom::Vec3(-py,px,0),geom::Vec3()); + prof[2*detail+i]=TraceProfileEntry(geom::Vec3(-px,-py,0),geom::Vec3()); + prof[3*detail+i]=TraceProfileEntry(geom::Vec3(py,-px,0),geom::Vec3()); + } + } - if(prof.empty()) { - prof=TraceProfile(detail*4); + // different algorithm for square x-section + template<> + void circle_profile<2>(TraceProfile& prof, float ecc) + { + unsigned int detail=prof.size()/4; for(unsigned int i=0;i<detail;++i) { float ang=0.5*M_PI*static_cast<float>(i)/static_cast<float>(detail); - float ca=TabCos(ang); - float sa=TabSin(ang); - float px=pow(ca,ex); - float py=pow(sa,ex); + float ca=cos(ang); + float sa=sin(ang); + float rad=ecc+(1.0f-ecc)/std::max(ca,sa); + float px=rad*ca; + float py=rad*sa; prof[i]=TraceProfileEntry(geom::Vec3(px,py,0),geom::Vec3()); prof[detail+i]=TraceProfileEntry(geom::Vec3(-py,px,0),geom::Vec3()); prof[2*detail+i]=TraceProfileEntry(geom::Vec3(-px,-py,0),geom::Vec3()); prof[3*detail+i]=TraceProfileEntry(geom::Vec3(py,-px,0),geom::Vec3()); } - unsigned int d4=detail*4; - for(unsigned int i=0;i<d4;++i) { - prof[i].v=geom::CompMultiply(prof[i].v,geom::Vec3(rx,ry,1.0)); + } + + template<> + void circle_profile<3>(TraceProfile& prof, float ecc) + { + unsigned int detail=prof.size()/4; + for(unsigned int i=0;i<detail;++i) { + float ang=0.5*M_PI*static_cast<float>(i)/static_cast<float>(detail); + float ca=cos(ang); + float sa=sin(ang); + float sa2=sin(2.0*ang); + float rad=1.0+std::abs(1.0-ecc)*0.5*sa2*sa2*sa2; + float px=rad*ca; + float py=rad*sa; + prof[i]=TraceProfileEntry(geom::Vec3(px,py,0),geom::Vec3()); + prof[detail+i]=TraceProfileEntry(geom::Vec3(-py,px,0),geom::Vec3()); + prof[2*detail+i]=TraceProfileEntry(geom::Vec3(-px,-py,0),geom::Vec3()); + prof[3*detail+i]=TraceProfileEntry(geom::Vec3(py,-px,0),geom::Vec3()); } - for(unsigned int i=0;i<d4;++i) { - unsigned int p1=(d4+i-1)%d4; - unsigned int p2=(i+1)%d4; - float dx=prof[p2].v[0]-prof[p1].v[0]; - float dy=prof[p2].v[1]-prof[p1].v[1]; - prof[i].n=geom::Normalize(geom::Vec3(dy,-dx,0.0)); + } + + // default - plain circular + template<unsigned int TYPE> + void circle_profile(TraceProfile& prof, float ecc) + { + unsigned int detail=prof.size()/4; + for(unsigned int i=0;i<detail;++i) { + float ang=0.5*M_PI*static_cast<float>(i)/static_cast<float>(detail); + float px=cos(ang); + float py=sin(ang); + prof[i]=TraceProfileEntry(geom::Vec3(px,py,0),geom::Vec3()); + prof[detail+i]=TraceProfileEntry(geom::Vec3(-py,px,0),geom::Vec3()); + prof[2*detail+i]=TraceProfileEntry(geom::Vec3(-px,-py,0),geom::Vec3()); + prof[3*detail+i]=TraceProfileEntry(geom::Vec3(py,-px,0),geom::Vec3()); } } +} + + TraceProfile CartoonRenderer::GetCircProfile(unsigned int detail, float rx, float ry, unsigned int type, float ecc) +{ + unsigned int d4=detail*4; + TraceProfile prof(d4); + + if(type==1) { + circle_profile<1>(prof,ecc); + } else if(type==2) { + circle_profile<2>(prof,ecc); + } else if(type==3) { + circle_profile<3>(prof,ecc); + } else if(type==4) { + circle_profile<4>(prof,ecc); + } else { + circle_profile<0>(prof,ecc); + } + + // adjust axis rations + for(unsigned int i=0;i<d4;++i) { + prof[i].v[0]*=rx; + prof[i].v[1]*=ry; + } + + // calculate normals + for(unsigned int i=0;i<d4;++i) { + unsigned int p1=(d4+i-1)%d4; + unsigned int p2=(i+1)%d4; + float dx=prof[p2].v[0]-prof[p1].v[0]; + float dy=prof[p2].v[1]-prof[p1].v[1]; + prof[i].n=geom::Normalize(geom::Vec3(dy,-dx,0.0)); + } return prof; } diff --git a/modules/gfx/src/impl/cartoon_renderer.hh b/modules/gfx/src/impl/cartoon_renderer.hh index 76f450523..ff9097e5c 100644 --- a/modules/gfx/src/impl/cartoon_renderer.hh +++ b/modules/gfx/src/impl/cartoon_renderer.hh @@ -68,8 +68,9 @@ private: void PrepareRendering(TraceSubset& subset, IndexedVertexArray& va, SplineEntryListList& spline_list_list, bool is_sel); - static TraceProfile GetCircProfile(unsigned int detail, float rx, float ry, - float ex); + + TraceProfile GetCircProfile(unsigned int detail, float rx, float ry, unsigned int type, float ecc); + bool force_tube_; CartoonRenderOptionsPtr options_; SplineEntryListList spline_list_list_; diff --git a/modules/gfx/src/impl/entity_renderer.cc b/modules/gfx/src/impl/entity_renderer.cc index 1949ab11f..ff243cb7c 100644 --- a/modules/gfx/src/impl/entity_renderer.cc +++ b/modules/gfx/src/impl/entity_renderer.cc @@ -36,7 +36,10 @@ namespace ost { namespace gfx { namespace impl { -EntityRenderer::EntityRenderer():name_(""),enabled_(true){} +EntityRenderer::EntityRenderer(): + name_(""), + enabled_(true) +{} void EntityRenderer::FlagPositionsDirty() { @@ -135,6 +138,7 @@ void EntityRenderer::Render(RenderPass pass) { assert(sel_state_==0 && state_==0); if (pass==STANDARD_RENDER_PASS) { + va_.DrawNormals(debug_flags_&0x1); va_.RenderGL(); } else if (pass==GLOW_RENDER_PASS && this->HasSelection()) { sel_va_.RenderGL(); diff --git a/modules/gfx/src/impl/entity_renderer.hh b/modules/gfx/src/impl/entity_renderer.hh index 3a262d073..c6ee2a49e 100644 --- a/modules/gfx/src/impl/entity_renderer.hh +++ b/modules/gfx/src/impl/entity_renderer.hh @@ -66,6 +66,7 @@ typedef char DirtyFlags; class DLLEXPORT_OST_GFX EntityRenderer { public: EntityRenderer(); + virtual ~EntityRenderer(){} /// \brief add view void AddView(const mol::EntityView& view); @@ -145,8 +146,6 @@ public: virtual void RenderOptionsChanged(); - virtual ~EntityRenderer(){} - virtual void Apply(const gfx::ByElementColorOp& op)=0; virtual void Apply(const gfx::ByChainColorOp& op)=0; virtual void Apply(const gfx::UniformColorOp& op)=0; @@ -159,6 +158,8 @@ public: bool IsDirty() const; void FlagPositionsDirty(); + + unsigned int& Debug() {return debug_flags_;} protected: virtual void SetName(const String& name); @@ -176,6 +177,7 @@ protected: DirtyFlags sel_state_; DirtyFlags state_; + unsigned int debug_flags_; }; //Simplify color ops diff --git a/modules/gfx/src/impl/tabulated_trig.cc b/modules/gfx/src/impl/tabulated_trig.cc index f1df91232..6244ad356 100644 --- a/modules/gfx/src/impl/tabulated_trig.cc +++ b/modules/gfx/src/impl/tabulated_trig.cc @@ -30,9 +30,9 @@ public: const static int TAB_ENTRIES=360; CosTable() { - float delta=2*M_PI/TAB_ENTRIES; + float delta=2.0*M_PI/TAB_ENTRIES; for (int i=0; i<TAB_ENTRIES; ++i) { - tab_[i]=cos(delta*i); + tab_[i]=cos(delta*static_cast<float>(i)); } } float Get(float angle) const @@ -66,4 +66,4 @@ float TabSin(float angle) } -}}} \ No newline at end of file +}}} diff --git a/modules/gfx/src/impl/trace_renderer.cc b/modules/gfx/src/impl/trace_renderer.cc index 043dbb2d6..8f306915c 100644 --- a/modules/gfx/src/impl/trace_renderer.cc +++ b/modules/gfx/src/impl/trace_renderer.cc @@ -43,6 +43,49 @@ void TraceRenderer::PrepareRendering() } } +#if 1 +void TraceRenderer::PrepareRendering(TraceSubset& trace_subset, + IndexedVertexArray& va, bool is_sel) +{ + float plus=is_sel ? 0.05: 0.0; + const Color& sel_clr=this->GetSelectionColor(); + if(options_!=NULL){ + va.Clear(); + va.SetLighting(true); + va.SetCullFace(true); + va.SetColorMaterial(true); + va.SetTwoSided(false); + for (int node_list=0; node_list<trace_subset.GetSize(); ++node_list) { + NodeListSubset& nl=trace_subset[node_list]; + + mol::AtomHandle& a1=nl[0].atom; + va.AddSphere(SpherePrim(a1.GetPos(), + options_->GetTubeRadius()+plus, + is_sel ? sel_clr : nl[0].color1), + options_->GetArcDetail()); + for(int i=1;i<nl.GetSize();++i) { + mol::AtomHandle& a2=nl[i].atom; + va.AddSphere(SpherePrim(a2.GetPos(), + options_->GetTubeRadius()+plus, + is_sel ? sel_clr : nl[i].color1), + options_->GetArcDetail()); + const geom::Vec3& p0=a1.GetPos(); + const geom::Vec3& p2=a2.GetPos(); + geom::Vec3 p1=(p0+p2)*0.5; + va.AddCylinder(CylinderPrim(p0,p1,options_->GetTubeRadius()+plus,nl[i-1].color1), + options_->GetArcDetail()); + va.AddCylinder(CylinderPrim(p1,p2,options_->GetTubeRadius()+plus,nl[i].color1), + options_->GetArcDetail()); + a1=a2; + } + } + } + sel_state_=0; + state_=0; +} + +#else + void TraceRenderer::PrepareRendering(TraceSubset& trace_subset, IndexedVertexArray& va, bool is_sel) { @@ -130,6 +173,7 @@ void TraceRenderer::PrepareRendering(TraceSubset& trace_subset, sel_state_=0; state_=0; } +#endif VertexID TraceRenderer::AddCappedProfile(IndexedVertexArray& va, const Color& color, diff --git a/modules/gfx/src/render_options/cartoon_render_options.cc b/modules/gfx/src/render_options/cartoon_render_options.cc index 30996bfd1..da5d2e703 100644 --- a/modules/gfx/src/render_options/cartoon_render_options.cc +++ b/modules/gfx/src/render_options/cartoon_render_options.cc @@ -34,12 +34,16 @@ CartoonRenderOptions::CartoonRenderOptions(bool force_tube): smooth_factor_(0.0), tube_radius_(0.4), tube_ratio_(1.0), + tube_profile_(0), helix_width_(1.1), helix_thickness_(0.2), helix_ecc_(0.3), + helix_profile_(1), strand_width_(1.2), strand_thickness_(0.2), - strand_ecc_(0.3) {} + strand_ecc_(0.3), + strand_profile_(1) +{} RenderMode::Type CartoonRenderOptions::GetRenderMode(){ if(force_tube_) @@ -137,6 +141,17 @@ float CartoonRenderOptions::GetTubeRatio() const{ return tube_ratio_; } +unsigned int CartoonRenderOptions::GetTubeProfileType() const +{ + return tube_profile_; +} + +void CartoonRenderOptions::SetTubeProfileType(unsigned int t) +{ + tube_profile_=t; + this->NotifyStateChange(); +} + void CartoonRenderOptions::SetHelixWidth(float helix_width){ if(helix_width_ != helix_width){ helix_width_= helix_width>0.0 ? helix_width : helix_width_; @@ -170,6 +185,17 @@ float CartoonRenderOptions::GetHelixEcc() const{ return helix_ecc_; } +unsigned int CartoonRenderOptions::GetHelixProfileType() const +{ + return helix_profile_; +} + +void CartoonRenderOptions::SetHelixProfileType(unsigned int t) +{ + helix_profile_=t; + this->NotifyStateChange(); +} + void CartoonRenderOptions::SetStrandWidth(float strand_width){ if(strand_width_ != strand_width){ strand_width_= strand_width>0.0 ? strand_width : strand_width_; @@ -203,6 +229,17 @@ float CartoonRenderOptions::GetStrandEcc() const{ return strand_ecc_; } +unsigned int CartoonRenderOptions::GetStrandProfileType() const +{ + return strand_profile_; +} + +void CartoonRenderOptions::SetStrandProfileType(unsigned int t) +{ + strand_profile_=t; + this->NotifyStateChange(); +} + float CartoonRenderOptions::GetMaxRad() const{ float max_rad=std::max(float(3.0),tube_radius_*tube_ratio_); max_rad=std::max(max_rad,tube_radius_); diff --git a/modules/gfx/src/render_options/cartoon_render_options.hh b/modules/gfx/src/render_options/cartoon_render_options.hh index 55653bb53..092fafe69 100644 --- a/modules/gfx/src/render_options/cartoon_render_options.hh +++ b/modules/gfx/src/render_options/cartoon_render_options.hh @@ -56,6 +56,8 @@ public: virtual float GetTubeRadius() const; virtual void SetTubeRatio(float tube_ratio); virtual float GetTubeRatio() const; + virtual unsigned int GetTubeProfileType() const; + virtual void SetTubeProfileType(unsigned int); virtual void SetHelixWidth(float helix_width); virtual float GetHelixWidth() const; @@ -63,6 +65,8 @@ public: virtual float GetHelixThickness() const; virtual void SetHelixEcc(float helix_ecc); virtual float GetHelixEcc() const; + virtual unsigned int GetHelixProfileType() const; + virtual void SetHelixProfileType(unsigned int); virtual void SetStrandWidth(float strand_width); virtual float GetStrandWidth() const; @@ -70,6 +74,8 @@ public: virtual float GetStrandThickness() const; virtual void SetStrandEcc(float strand_ecc); virtual float GetStrandEcc() const; + virtual unsigned int GetStrandProfileType() const; + virtual void SetStrandProfileType(unsigned int); float GetMaxRad() const; @@ -85,13 +91,15 @@ private: float tube_radius_; float tube_ratio_; + unsigned int tube_profile_; float helix_width_; float helix_thickness_; float helix_ecc_; + unsigned int helix_profile_; float strand_width_; float strand_thickness_; float strand_ecc_; - + unsigned int strand_profile_; }; typedef boost::shared_ptr<CartoonRenderOptions> CartoonRenderOptionsPtr; diff --git a/modules/gfx/src/vertex_array.cc b/modules/gfx/src/vertex_array.cc index 0cbf8c96f..b93bd5941 100644 --- a/modules/gfx/src/vertex_array.cc +++ b/modules/gfx/src/vertex_array.cc @@ -482,7 +482,7 @@ void IndexedVertexArray::RenderGL() } if(draw_normals_) { - glColor3f(1,0,0); + //glColor3f(1,0,0); glBegin(GL_LINES); for(EntryList::const_iterator it=entry_list_.begin();it!=entry_list_.end();++it) { glNormal3fv(it->n); diff --git a/modules/gui/pymod/scene/hsc_widget.py b/modules/gui/pymod/scene/hsc_widget.py index 814cf9ef6..b5f716a0a 100644 --- a/modules/gui/pymod/scene/hsc_widget.py +++ b/modules/gui/pymod/scene/hsc_widget.py @@ -52,6 +52,9 @@ class HSCWidget(RenderModeWidget): min_ecc = 0.1 max_ecc = 5 + + min_profile=0 + max_profile=4 #########UI########## @@ -105,8 +108,13 @@ class HSCWidget(RenderModeWidget): self.thickness_tube_slider_.setRange(min_tube_ratio*10.0, max_tube_ratio*10) self.thickness_tube_slider_.setTickPosition(QtGui.QSlider.NoTicks) self.thickness_tube_slider_.setTickInterval(1) + + # Tube Profile Type + tube_profile_label = QtGui.QLabel("Tube Profile Type") + self.tube_profile_spinbox_ = QtGui.QSpinBox() + self.tube_profile_spinbox_.setRange(min_profile, max_profile) - #Helifx + # Helix helix_label = QtGui.QLabel("Helix") font = helix_label.font() font.setBold(True) @@ -152,6 +160,10 @@ class HSCWidget(RenderModeWidget): self.ecc_helix_slider_.setTickPosition(QtGui.QSlider.NoTicks) self.ecc_helix_slider_.setTickInterval(1) + # Helix Profile Type + helix_profile_label = QtGui.QLabel("Helix Profile Type") + self.helix_profile_spinbox_ = QtGui.QSpinBox() + self.helix_profile_spinbox_.setRange(min_profile, max_profile) #Strand strand_label = QtGui.QLabel("Strand") @@ -199,45 +211,70 @@ class HSCWidget(RenderModeWidget): self.ecc_strand_slider_.setTickPosition(QtGui.QSlider.NoTicks) self.ecc_strand_slider_.setTickInterval(1) + # Strand Profile Type + strand_profile_label = QtGui.QLabel("Strand Profile Type") + self.strand_profile_spinbox_ = QtGui.QSpinBox() + self.strand_profile_spinbox_.setRange(min_profile, max_profile) + + row=1 grid = QtGui.QGridLayout() - grid.addWidget(poly_mode_label,1,0,1,1) - grid.addWidget(self.poly_mode_cb_,1,3,1,2) - grid.addWidget(spline_label, 2, 0, 1, 3) - grid.addWidget(self.spline_spinbox_, 2, 4, 1, 1) - grid.addWidget(arc_label,3,0,1,3) - grid.addWidget(self.arc_spinbox_,3,4,1,1) - - grid.addWidget(tube_label, 4, 0, 1, 3) - grid.addWidget(radius_tube_label, 5, 0, 1, 1) - grid.addWidget(self.width_tube_slider_, 5, 1, 1, 3) - grid.addWidget(self.width_tube_spinbox_, 5, 4, 1, 1) - grid.addWidget(ratio_tube_label, 6, 0, 1, 1) - grid.addWidget(self.thickness_tube_slider_, 6, 1, 1, 3) - grid.addWidget(self.thickness_tube_spinbox_, 6, 4, 1, 1) - - grid.addWidget(helix_label, 7, 0, 1, 3) - grid.addWidget(radius_helix_label, 8, 0, 1, 1) - grid.addWidget(self.width_helix_slider_, 8, 1, 1, 3) - grid.addWidget(self.width_helix_spinbox_, 8, 4, 1, 1) - grid.addWidget(ratio_helix_label, 9, 0, 1, 1) - grid.addWidget(self.thickness_helix_slider_, 9, 1, 1, 3) - grid.addWidget(self.thickness_helix_spinbox_, 9, 4, 1, 1) - grid.addWidget(ecc_helix_label, 10, 0, 1, 1) - grid.addWidget(self.ecc_helix_slider_, 10, 1, 1, 3) - grid.addWidget(self.ecc_helix_spinbox_, 10, 4, 1, 1) - - grid.addWidget(strand_label, 11, 0, 1, 3) - grid.addWidget(radius_strand_label, 12, 0, 1, 1) - grid.addWidget(self.width_strand_slider_, 12, 1, 1, 3) - grid.addWidget(self.width_strand_spinbox_, 12, 4, 1, 1) - grid.addWidget(ratio_strand_label, 13, 0, 1, 1) - grid.addWidget(self.thickness_strand_slider_, 13, 1, 1, 3) - grid.addWidget(self.thickness_strand_spinbox_, 13, 4, 1, 1) - grid.addWidget(ecc_strand_label, 14, 0, 1, 1) - grid.addWidget(self.ecc_strand_slider_, 14, 1, 1, 3) - grid.addWidget(self.ecc_strand_spinbox_, 14, 4, 1, 1) - - grid.setRowStretch(15,1) + grid.addWidget(poly_mode_label,row,0,1,1) + grid.addWidget(self.poly_mode_cb_,row,3,1,2) + row+=1 + grid.addWidget(spline_label, row, 0, 1, 3) + grid.addWidget(self.spline_spinbox_, row, 4, 1, 1) + row+=1 + grid.addWidget(arc_label,row,0,1,3) + grid.addWidget(self.arc_spinbox_,row,4,1,1) + row+=1 + grid.addWidget(tube_label, row, 0, 1, 3) + row+=1 + grid.addWidget(radius_tube_label, row, 0, 1, 1) + grid.addWidget(self.width_tube_slider_, row, 1, 1, 3) + grid.addWidget(self.width_tube_spinbox_, row, 4, 1, 1) + row+=1 + grid.addWidget(ratio_tube_label, row, 0, 1, 1) + grid.addWidget(self.thickness_tube_slider_, row, 1, 1, 3) + grid.addWidget(self.thickness_tube_spinbox_, row, 4, 1, 1) + row+=1 + grid.addWidget(tube_profile_label, row, 0, 1, 3) + grid.addWidget(self.tube_profile_spinbox_, row, 4, 1, 1) + row+=1 + grid.addWidget(helix_label, row, 0, 1, 3) + row+=1 + grid.addWidget(radius_helix_label, row, 0, 1, 1) + grid.addWidget(self.width_helix_slider_, row, 1, 1, 3) + grid.addWidget(self.width_helix_spinbox_, row, 4, 1, 1) + row+=1 + grid.addWidget(ratio_helix_label, row, 0, 1, 1) + grid.addWidget(self.thickness_helix_slider_, row, 1, 1, 3) + grid.addWidget(self.thickness_helix_spinbox_, row, 4, 1, 1) + row+=1 + grid.addWidget(ecc_helix_label, row, 0, 1, 1) + grid.addWidget(self.ecc_helix_slider_, row, 1, 1, 3) + grid.addWidget(self.ecc_helix_spinbox_, row, 4, 1, 1) + row+=1 + grid.addWidget(helix_profile_label, row, 0, 1, 3) + grid.addWidget(self.helix_profile_spinbox_, row, 4, 1, 1) + row+=1 + grid.addWidget(strand_label, row, 0, 1, 3) + row+=1 + grid.addWidget(radius_strand_label, row, 0, 1, 1) + grid.addWidget(self.width_strand_slider_, row, 1, 1, 3) + grid.addWidget(self.width_strand_spinbox_, row, 4, 1, 1) + row+=1 + grid.addWidget(ratio_strand_label, row, 0, 1, 1) + grid.addWidget(self.thickness_strand_slider_, row, 1, 1, 3) + grid.addWidget(self.thickness_strand_spinbox_, row, 4, 1, 1) + row+=1 + grid.addWidget(ecc_strand_label, row, 0, 1, 1) + grid.addWidget(self.ecc_strand_slider_, row, 1, 1, 3) + grid.addWidget(self.ecc_strand_spinbox_, row, 4, 1, 1) + row+=1 + grid.addWidget(strand_profile_label, row, 0, 1, 3) + grid.addWidget(self.strand_profile_spinbox_, row, 4, 1, 1) + + grid.setRowStretch(row+1,1) self.setLayout(grid) QtCore.QObject.connect(self.spline_spinbox_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateSplineDetail) @@ -248,6 +285,7 @@ class HSCWidget(RenderModeWidget): QtCore.QObject.connect(self.width_tube_slider_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateSliderTubeRadius) QtCore.QObject.connect(self.thickness_tube_spinbox_, QtCore.SIGNAL("valueChanged(double)"), self.UpdateTubeRatio) QtCore.QObject.connect(self.thickness_tube_slider_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateSliderTubeRatio) + QtCore.QObject.connect(self.tube_profile_spinbox_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateTubeProfileType) QtCore.QObject.connect(self.width_helix_spinbox_, QtCore.SIGNAL("valueChanged(double)"), self.UpdateHelixWidth) QtCore.QObject.connect(self.width_helix_slider_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateSliderHelixWidth) @@ -255,6 +293,7 @@ class HSCWidget(RenderModeWidget): QtCore.QObject.connect(self.thickness_helix_slider_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateSliderHelixThickness) QtCore.QObject.connect(self.ecc_helix_spinbox_, QtCore.SIGNAL("valueChanged(double)"), self.UpdateHelixEcc) QtCore.QObject.connect(self.ecc_helix_slider_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateSliderHelixEcc) + QtCore.QObject.connect(self.helix_profile_spinbox_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateHelixProfileType) QtCore.QObject.connect(self.width_strand_spinbox_, QtCore.SIGNAL("valueChanged(double)"), self.UpdateStrandWidth) QtCore.QObject.connect(self.width_strand_slider_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateSliderStrandWidth) @@ -262,6 +301,7 @@ class HSCWidget(RenderModeWidget): QtCore.QObject.connect(self.thickness_strand_slider_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateSliderStrandThickness) QtCore.QObject.connect(self.ecc_strand_spinbox_, QtCore.SIGNAL("valueChanged(double)"), self.UpdateStrandEcc) QtCore.QObject.connect(self.ecc_strand_slider_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateSliderStrandEcc) + QtCore.QObject.connect(self.strand_profile_spinbox_, QtCore.SIGNAL("valueChanged(int)"), self.UpdateStrandProfileType) self.setMinimumSize(250,420) #14*30 ########/UI######## @@ -273,12 +313,15 @@ class HSCWidget(RenderModeWidget): self.UpdateTubeRadiusGui(options.GetTubeRadius()) self.UpdateTubeRatioGui(options.GetTubeRatio()) + self.tube_profile_spinbox_.setValue(options.GetTubeProfileType()) self.UpdateHelixWidthGui(options.GetHelixWidth()) self.UpdateHelixThicknessGui(options.GetHelixThickness()) self.UpdateHelixEccGui(options.GetHelixEcc()) + self.helix_profile_spinbox_.setValue(options.GetHelixProfileType()) self.UpdateStrandWidthGui(options.GetStrandWidth()) self.UpdateStrandThicknessGui(options.GetStrandThickness()) self.UpdateStrandEccGui(options.GetStrandEcc()) + self.strand_profile_spinbox_.setValue(options.GetStrandProfileType()) def UpdatePolyMode(self, value): self.GetOptions().SetPolyMode(value) @@ -300,6 +343,9 @@ class HSCWidget(RenderModeWidget): def UpdateSliderTubeRatio(self, value): self.GetOptions().SetTubeRatio(value/10.0) + + def UpdateTubeProfileType(self, value): + self.GetOptions().SetTubeProfileType(value) def UpdateHelixWidth(self, value): self.GetOptions().SetHelixWidth(value) @@ -316,6 +362,9 @@ class HSCWidget(RenderModeWidget): def UpdateHelixEcc(self, value): self.GetOptions().SetHelixEcc(value) + def UpdateHelixProfileType(self, value): + self.GetOptions().SetHelixProfileType(value) + def UpdateSliderHelixEcc(self, value): self.GetOptions().SetHelixEcc(value/10.0) @@ -337,6 +386,9 @@ class HSCWidget(RenderModeWidget): def UpdateSliderStrandEcc(self, value): self.GetOptions().SetStrandEcc(value/10.0) + def UpdateStrandProfileType(self, value): + self.GetOptions().SetStrandProfileType(value) + def UpdateTubeRadiusGui(self,value): if(abs(value*10.0 - self.width_tube_slider_.value())>=self.width_tube_spinbox_.singleStep()): self.width_tube_slider_.setValue(value*10.0) -- GitLab