From 9ef696f23ed074e6bb62fc3adeec8c104a2ff889 Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 4 Sep 2019 00:49:54 +0300 Subject: [PATCH] 0030791: Visualization - possibility to display materials by different hatching style for clipping # move capping style from presentation into drawer # crash in capping by setting projection as # several hatch templates (cherry picked from commit 3a8ba84200bb4402ef38e1889ed7072b24dce42f) (cherry picked from commit 280e1f1b27270fe3aeea29c6c858937f0fa371e0) # Conflicts: # src/AIS/AIS_InteractiveObject.cxx # src/ViewerTest/ViewerTest_ViewerCommands.cxx --- data/images/hatch_1_.png | Bin 0 -> 670 bytes data/images/hatch_2.png | Bin 0 -> 679 bytes data/images/hatch_3.png | Bin 0 -> 761 bytes data/images/hatch_4.png | Bin 0 -> 674 bytes data/images/hatch_5.png | Bin 0 -> 887 bytes data/images/hatch_6.png | Bin 0 -> 933 bytes data/images/hatch_7.png | Bin 0 -> 633 bytes data/images/hatch_8.png | Bin 0 -> 1511 bytes src/AIS/AIS_ColoredShape.cxx | 8 +- src/AIS/AIS_InteractiveObject.cxx | 31 - src/AIS/AIS_InteractiveObject.hxx | 7 - src/AIS/AIS_Shape.cxx | 2 +- src/OpenGl/OpenGl_CappingAlgo.cxx | 7 +- src/Prs3d/Prs3d_Drawer.cxx | 26 +- src/Prs3d/Prs3d_Drawer.hxx | 15 + src/ViewerTest/ViewerTest_ViewerCommands.cxx | 798 +++++++++++-------- 16 files changed, 507 insertions(+), 387 deletions(-) create mode 100644 data/images/hatch_1_.png create mode 100644 data/images/hatch_2.png create mode 100644 data/images/hatch_3.png create mode 100644 data/images/hatch_4.png create mode 100644 data/images/hatch_5.png create mode 100644 data/images/hatch_6.png create mode 100644 data/images/hatch_7.png create mode 100644 data/images/hatch_8.png diff --git a/data/images/hatch_1_.png b/data/images/hatch_1_.png new file mode 100644 index 0000000000000000000000000000000000000000..4f7fc204be84764c401b9b1462f8a699d86b92a3 GIT binary patch literal 670 zcmV;P0%84$P)N2bZe?^J zG%heMF)*zP3cvsW0vkz0K~#8N-HrhcgD?yO_y13`0Ro!FEma#!@g^NhlauAowr!5z z@Av2TE&kc}3!(CeXx~1>%GWUbXAmr3!t&3LX!#4KPYvIZ_tCNiy-Y$M9uPC(^{z)& z-yIOM;iF{s%>l6zK08ond%qh$+vnS?$(AZEhrU5~83J0NDmN6GA)17an7gzWx3AXdZQ zQ1H#8BqF?ritiT3Qlxx~NZ&7n$|ItE`w%N%!|qi1zJ6tb7f_e+I$wB`p8^h?c)# z`qc0pc^@rX(90zB;Q=udUhjHj_1yt68$L>A-y9Gt;Ui@C?*XwI{)U2Y9wiasJyd+R zIF=&iTSWSPAygg_?c0Y~`5K1*41(oLSpNADEq}rEso^{FK3cY*mr3Zu17aq;-u1}p zy8~i2e3Z<-IUrWTN67Bq17bD&4F%skN+QC0X!zUb3umDz_>jihRsaA107*qoM6N<$ Eg1dPzFaQ7m literal 0 HcmV?d00001 diff --git a/data/images/hatch_2.png b/data/images/hatch_2.png new file mode 100644 index 0000000000000000000000000000000000000000..0bf87b2f73f73005974c4948d9eda0dc289ef526 GIT binary patch literal 679 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY1|&n@ZgvM!jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucLCF%=h?3y^w370~qEv>0#LT=By}Z;C1rt33 zJwt=FTwDhj7?{L8T^vIy;@)1k*w<{p<8txefB(%JLKz=>dOX@VnSFi9E`yb;R@ZFH z4gR+O@BDj_RrU30{c@j*Sbk2LzBq=z((=N0W&PzDD`y-ovdu_&*%$e?=-d0l%xx2A zJU?b~YcZdMTk@WWsw0fes>hnQKCemGaBPEN)sb#i<+jeNi`xX(NQkBJ%TyaAOWd$6 z$T`}#@zaaOWbS?m?)7pO`#yF_KE26&TOm(e^FAD z>$d|R^^BIemhj8eFG{|5=0)Sm)Az_ctvYeKai4sprK|T* znQ5;blRK-=WKG}v-_FKCDQRA`Z%DtD1K6w%W)+ZG=YKZ19N#nZqH^53v?Eu}yb3)0 zf5!CUOU`k93h|$cro2|vXa80AF=!G!eCSPMGJhHm^KSOOwKojIn%BtQo+^baepu^?JmyTDBkAp*eR-cfwxaWFoOUJv$ z$NnW}W=q-@*qrHDIrD1s@jY`U qUd%8zt~zr1ZqJNambSN_^LJeGc;00#LT=By}Z;C1rt33 zJwt=FTwDhj7??6WT^vIy;_gmp>^rQ$hqcy{=fU3#rhx#`T`y>a@7 zf4~2m{M>*Stw)e{|gK^Jni3pH$b}KU~W3FXGz!)c-8?Yc4GZno?74C$-Kg?jM`Ho`CYh zr)yfn@9PLGeyDY&Hpo6&A?=Xpir-WIRXUt$t56^vkYBxLdw0%GHOUJl&6Kj&%9`g;M7mo1x11c@B5>(=QFiyzB0P^N65k^ zV0tIe@gin(TF=&>GH*UVfhRrj^ZYMw6#^=c06k!#eSXo4V%a18skLIE^ZzQ><)i>j ze|R>%@vzjZPg(O*Pq%ZkL_Z6!*&J~&V`kjDFPo2YrJedxu)Q8RV6+3jAN=?Fy}WE< W=M3)fjn2T7$>8bg=d#Wzp$Pyq@Mxz1 literal 0 HcmV?d00001 diff --git a/data/images/hatch_4.png b/data/images/hatch_4.png new file mode 100644 index 0000000000000000000000000000000000000000..5e5839ac92d7419aa3fe8f1e6bffd2eed575ecb6 GIT binary patch literal 674 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY1|&n@ZgvM!Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C|TkfQ4*Y=R#Ki=l*&+$n3-3imzP?iV4`QBXK1jNi|YUb1CzX` zi(^Pd+}jC^ea!|uEWiKz7cUiMoXmT)bNNe8yUZOan>Q`1(>ZN)=JWfX{`)oS*4DT3 z*k1Tl@?Y3!54W!W_xB2itwCHpqdzP_uI-5rTv7AhRZmRh22$S@oLPZ_)e|2|0(t!k zhn2V3+?982lLk`#4sF^X%Bg+l94FZ)MLgdoonCo^f2YjJ-;+;gHl4m)Deycy(8Kee)$Q+TM?Of`hn=PBCgU2rwwm->n%^Re^R9K z-d}Gyr_~?n3;&FA9?JSX{zgTCf zvFC8+9y`I>V#`NB zZ%$8835pZEJ6+Lr%OA-_`p!&F|2VErPc)hGhwbL{M3p6fxbB4~itMnt6F)JL1sMMK zCp^>uQua!R1v4sl)w{Lr1;%E);$b-;Z+)a(ea9t_=Myc1egM-GgQu&X%Q~loCIE>K BIYR&d literal 0 HcmV?d00001 diff --git a/data/images/hatch_5.png b/data/images/hatch_5.png new file mode 100644 index 0000000000000000000000000000000000000000..bf468b6ab05289ae195c834c9762819cb162848b GIT binary patch literal 887 zcmV--1Bm>IP)N2bZe?^J zG%heMF)*zP3cvsW0`y5lK~#8N<(KQusxS~m{i(+2`#-G*F<>vd&;^}d&S$cqooRM< zN|}+%`~8l%-|y2cj;EM@(@p0}K=mJw$8^&<#g={)xZQ5k&5vzC%~Pm;Y5(5jdc96J zf58^5&4*a{m%$u*Fz;fu`7*c%HE&(hEcMNwY{`PDu-2Es6up_R(QRc=LB*{La;-0s6IvMdlQ%Lx(U=Tb@HRY zhaS607%Rz^eiZ1nn^>`@?@fB{COKGa{yG@#$%a^M{(Kp!CMYcZ57SLjSo@d36jYo- z^=ounnNU!13e~UGZDlf~H}f^SZIle@&3x@{D}xJE+`1dK=(aNWfr?uf%vRkt3e3UI z%(wiX76+hst!|PF)!)OPK=GR0BnPUWv-!V)fw&9Rr%?Ue&HrAYc*~lgu=J0`TXmBZ z=KfVM#poyJ$itNh#ppHXsQ)OT=%JgqQ2jIhy+jFWn$O|v=C6YiQ1jL`t%SZeap|s` zG}4a(M`&d}Mah#Xg9K{cx*(U<_a@e_)rk7*!1~x*pBzfA{(O18Ueir4P*C$D{{z1~ zpU>&8lL~6y`ea(awlbK4ivJJaZZe^u;-l7_g~h*2hEQ?qV{g6ruKy?*Ld7X(%;!M$ z!_D`SAyk|~^;>+qc@q~ZZvAAfyJ1Q{3d}($PAO$R1=Zg=nQ@@A&9N@Xd;0zaid(-{ zJ?Q@iP~7_1Tc4aN2bZe?^J zG%heMF)*zP3cvsW10qR8K~#8N<(pk^gD?z5``A`h`~QD!2i2(ZaRWJ!3t^jdfY_FG z=Qxh`u*>`X&bZ(2!z;I!xL&WrOZ!@IyWNJD_9-5Z$MDiV#hm`kK*hMB#i#n0;-f`x zo#5`|n*7pO0~JH#=`nE~LuqUc?F3pJnxDkmk5w<7FhTQ6V+pr-#|#Ns(+tw6pvh@5 z-SKOY#uWEX?a>K@;b(aLeor4IdYd5>TFkIGpLMuMq2isl$sQ;@(IUj%2{ga^Se5i= zhLN++kd~X98EA4E?}iqCNq@9BdnY*be?NM=O=!Gp27VrAxJ~Au#Uc4|8@rE{s}m+@ zerarlTRh#YH8V;&T0q6qV!Goeq%nmicibi+?))Lr7($cxHbW@s?;AN&db&+UXnYH# zaiq6Sp!v5Ps}O0V;(MMUHOv)1GtixK$Gcf7ezf?@ouH`E|NWrJ_r6V*pz*c(KaVrq zCUa0dWOGk*o0M?tm&Ovk%@A4~s(TFlz`&x49T;x=gs(PQrfn%{k_sD5cIamE=ELW?u%mktFLYw7J zGo`mqaCdT;KXYz{ilOoD8JOmeoO?q%ffk46SMkvz#C@#x?t~>u`7^^B+~T*)kQ(Ol zOCy1br^R%~FA*({+$n`Se+}Oc+V;K85K3(^KabbzHN13yf{Jf(n;gaE`Fsv^@fR+pv^BGmP{$LuhfR{<+SSMkiD}EoSR@X{@E?PAPiG|NWq1Xxkq( zL$)G~OZ=z5-K24j|Ms_=G?qyJ>3)gcW)x-2FC7Y6oYuF=-b|Y%ohh_9y>-HtW1cxv zXmMP($pkGXjZgJQ&J=g&xS@Jfr$vhpS{(OnLZO|k^}H`X$rTPs5wxEi00000NkvXX Hu0mjf*6F)G literal 0 HcmV?d00001 diff --git a/data/images/hatch_7.png b/data/images/hatch_7.png new file mode 100644 index 0000000000000000000000000000000000000000..5f395a201b4052af157bf1beb34c3a163084fc4f GIT binary patch literal 633 zcmV-<0*3vGP)N2bZe?^J zG%heMF)*zP3cvsW0rp8mK~#8N<&4pe12G5#`~N@Pt5D!#ui4}oSDGz0Lq6Z{_rdS? z`}_YtG1-R@1xe~?XS!cQgyu2lUX}{pyZ8`J)RB>YEhlzAqtYz(av- zoTwus|5{G${PryJ!j6*PnCd@@D3{zF zF_V1=QIMpLcBcC^L}(s!?q#Xqy^9awL>(FV*K%U#$LI1WJtrSR&I;bU__Ac2dssw4 zN1U1IehpAAiRF&TK7<`5zcJN+6j3g@J7OmL5TYPS9qml_YlzT1=G@Ct!Fv}U!ihRE z@~`E@&X3RKQF=~3gq#(;ckyM(IQOuKf{r*d)BPHtToTJ2lYIy~N`7Oe|NZ;{Mh0A) TvhV?L00000NkvXXu0mjf@`@ke literal 0 HcmV?d00001 diff --git a/data/images/hatch_8.png b/data/images/hatch_8.png new file mode 100644 index 0000000000000000000000000000000000000000..f580b76a6ca0088cc4d55b418866b7b49d843479 GIT binary patch literal 1511 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7OGoEa{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C|TkfQ4*Y=R#Ki=l*&+$n3-3imzP?iV4`QBXK1jNi|YUb18a(> zi(^Pd+}m@3la^ZWxLmyXe_6JaRG`JgIhiN(ek3Tplh%>n`Fj8S`SYXe|NZ{F|F@0S z>#KX$grBY|UH^RcVLJi&t*hp}4YytW>ZaZ2=f~?5`V%+*c~yBuCw}H`XZ=0ta>;V< z=YNymFld{_5(cxVxvTw)W)neS6#b zeet}|uQ~f)MMl2o+Zg$IMP%Jqn^liych@rXKa`AqYxwNrzs&x--`2MmS123_T)h`) zTK>mrK-X-Q?En7jk70TH$>UHr>c8Imj`?FCx9#oqRbf{*|6O(b7W2V~C*kK8r~SP8 zIeWi6)4pRi_v}Gt)=kal%UWgrT@2(zFa6}#pZ~V~{im$QYd`PHtGH{cQ}^!LzVlha z{kS)BtE;xfe_gXG{dXC}ffviu&Mr=?OuZNLhB@MpvDqt#6Ak;nZ~y$YfRDe$BI`;t z)aW@tcbf8l|5da9#C^8k9}Zj;n)Wp-a{as1y;0}yvo}{uef5451^pj zUnRHn$9?`Lkhg(m`d7bx-`~X#acK0PYXbLxh9$n|UA(EjXV-LyVSB0{F15>AnEo4V z*!-{Cx%IzEhylF}49uf@cHUs$(2_3px#Itp<1>!`US)4T>tUn7=8*h%y7z+i?v&hT z8S}Yd{rT_Re{whQ^ULTauG$QVpEcjV%{pwy@I*H@`FjK?IMYM_zP%&Ublm-UASBxB z=YpbrJ~WaH^S_^MEY;KfH0{;dy+@;0-JjF5_WXD0Z}$vN$%X%)2u?=&udkZDkE?k2 zxZ>Cjq4+&xNLcn%?g_6gPMGVxXgkdR zf{4hUDGiI9W9IC?za9D=2#K6EYs%YitbxQ$=*P21?HZ1M=vfO&=fEJ%`+fberH#O& z6<0x_xxM1_=d%xQ^&GFR{WoLx;U|xwZk+x#?t9~p6|K zE^m)8>7Vr!l+;I4CNQR`oie4Loox;O($NackH9qa|N6f_ADm=TAvs9Brg+D*hjH`Y fKmR@d|37xmgn5VmWG1Nr3uOjRS3j3^P6NewGroup(); aShadedGroup->SetClosed (isClosed); - if (isClosed - && !myCappingStyle.IsNull()) - aShadedGroup->SetGroupPrimitivesAspect (myCappingStyle); + if (isClosed) + { + if (aDrawer->HasOwnFillCappingAspect()) + aShadedGroup->SetGroupPrimitivesAspect (aDrawer->FillCappingAspect()); + } } aShadedGroup->SetPrimitivesAspect (aDrawer->ShadingAspect()->Aspect()); aShadedGroup->AddPrimitiveArray (aTriangles); diff --git a/src/AIS/AIS_InteractiveObject.cxx b/src/AIS/AIS_InteractiveObject.cxx index d307a5b77b..8ec7f1d38c 100644 --- a/src/AIS/AIS_InteractiveObject.cxx +++ b/src/AIS/AIS_InteractiveObject.cxx @@ -84,37 +84,6 @@ void AIS_InteractiveObject::SetContext (const Handle(AIS_InteractiveContext)& th } } -//======================================================================= -//function : SetCappingStyle -//purpose : -//======================================================================= -void AIS_InteractiveObject::SetCappingStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle) -{ - myCappingStyle = theStyle; - - // Modify existing presentations - for (Standard_Integer aPrsIter = 1, n = myPresentations.Length(); aPrsIter <= n; ++aPrsIter) - { - const Handle(PrsMgr_Presentation)& aPrs3d = myPresentations (aPrsIter); - if (!aPrs3d.IsNull()) - { - const Handle(Graphic3d_Structure)& aStruct = aPrs3d->Presentation(); - if (!aStruct.IsNull()) - { - const Graphic3d_SequenceOfGroup& aGroups = aStruct->Groups(); - for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aGroups); aGroupIter.More(); aGroupIter.Next()) - { - Handle(Graphic3d_Group)& aGrp = aGroupIter.ChangeValue(); - if (aGrp.IsNull()) - continue; - - aGrp->SetGroupPrimitivesAspect (theStyle); - } - } - } - } -} - //======================================================================= //function : HasPresentation //purpose : diff --git a/src/AIS/AIS_InteractiveObject.hxx b/src/AIS/AIS_InteractiveObject.hxx index bd6877e196..ec9b48de08 100644 --- a/src/AIS/AIS_InteractiveObject.hxx +++ b/src/AIS/AIS_InteractiveObject.hxx @@ -104,12 +104,6 @@ public: void ClearOwner() { myOwner.Nullify(); } public: - //! Set style of filling capping section created by clipping planes. - Standard_EXPORT virtual void SetCappingStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle); - - //! Returns style for filling capping section created by clipping planes. - const Handle(Graphic3d_AspectFillCapping)& CappingStyle() const { return myCappingStyle; } - //! Returns the context pointer to the interactive context. Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const; @@ -136,7 +130,6 @@ protected: AIS_InteractiveContext* myCTXPtr; //!< pointer to Interactive Context, where object is currently displayed; @sa SetContext() Handle(Standard_Transient) myOwner; //!< application-specific owner object - Handle(Graphic3d_AspectFillCapping) myCappingStyle; }; diff --git a/src/AIS/AIS_Shape.cxx b/src/AIS/AIS_Shape.cxx index 57509b973d..82d8a9907d 100644 --- a/src/AIS/AIS_Shape.cxx +++ b/src/AIS/AIS_Shape.cxx @@ -180,7 +180,7 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat try { OCC_CATCH_SIGNALS - StdPrs_ShadedShape::Add (aPrs, myshape, myDrawer, myCappingStyle); + StdPrs_ShadedShape::Add (aPrs, myshape, myDrawer, myDrawer->FillCappingAspect()); } catch (Standard_Failure const& anException) { diff --git a/src/OpenGl/OpenGl_CappingAlgo.cxx b/src/OpenGl/OpenGl_CappingAlgo.cxx index 3154878cb3..1d77c45ca5 100755 --- a/src/OpenGl/OpenGl_CappingAlgo.cxx +++ b/src/OpenGl/OpenGl_CappingAlgo.cxx @@ -293,8 +293,11 @@ namespace const gp_Dir aPlaneUp (aPlaneMat.GetValue (0, 2), aPlaneMat.GetValue (1, 2), aPlaneMat.GetValue (2, 2)); const gp_Dir& aCameraUp = aCamera->Up(); const gp_Vec aCameraPln = aPlaneSide.Dot (aCameraUp) * aPlaneSide + aPlaneUp.Dot (aCameraUp) * aPlaneUp; - const gp_Dir& aCameraDir = aCamera->Direction(); - aRotateAngle = static_cast (aCameraPln.AngleWithRef (aPlaneUp, aCameraDir) / M_PI * 180.0); + if (aCameraPln.Magnitude() > Precision::Confusion()) + { + const gp_Dir& aCameraDir = aCamera->Direction(); + aRotateAngle = static_cast (aCameraPln.AngleWithRef (aPlaneUp, aCameraDir) / M_PI * 180.0); + } } aHatchAngle = aRotateAngle; diff --git a/src/Prs3d/Prs3d_Drawer.cxx b/src/Prs3d/Prs3d_Drawer.cxx index 92858a2198..a03fa3d36f 100644 --- a/src/Prs3d/Prs3d_Drawer.cxx +++ b/src/Prs3d/Prs3d_Drawer.cxx @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -109,7 +110,9 @@ Prs3d_Drawer::Prs3d_Drawer() myHasOwnDimLengthModelUnits (Standard_False), myHasOwnDimAngleModelUnits (Standard_False), myHasOwnDimLengthDisplayUnits (Standard_False), - myHasOwnDimAngleDisplayUnits (Standard_False) + myHasOwnDimAngleDisplayUnits (Standard_False), + + myHasOwnFillCappingAspect (Standard_False) { myDimensionModelUnits.SetLengthUnits ("m"); myDimensionModelUnits.SetAngleUnits ("rad"); @@ -431,6 +434,27 @@ void Prs3d_Drawer::SetDimensionAspect (const Handle(Prs3d_DimensionAspect)& theA myHasOwnDimensionAspect = !myDimensionAspect.IsNull(); } +// ======================================================================= +// function : FillCappingAspect +// purpose : +// ======================================================================= + +const Handle(Graphic3d_AspectFillCapping)& Prs3d_Drawer::FillCappingAspect() +{ + return myFillCappingAspect; +} + +// ======================================================================= +// function : SetFillCappingAspect +// purpose : +// ======================================================================= + +void Prs3d_Drawer::SetFillCappingAspect (const Handle(Graphic3d_AspectFillCapping)& theAspect) +{ + myFillCappingAspect = theAspect; + myHasOwnFillCappingAspect = !myFillCappingAspect.IsNull(); +} + // ======================================================================= // function : SetDimLengthModelUnits // purpose : diff --git a/src/Prs3d/Prs3d_Drawer.hxx b/src/Prs3d/Prs3d_Drawer.hxx index 967b11834b..50a74ffe37 100644 --- a/src/Prs3d/Prs3d_Drawer.hxx +++ b/src/Prs3d/Prs3d_Drawer.hxx @@ -31,6 +31,7 @@ #include #include +class Graphic3d_AspectFillCapping; class Prs3d_IsoAspect; class Prs3d_LineAspect; class Prs3d_TextAspect; @@ -792,6 +793,16 @@ public: //! the appearance of dimensions that overrides the one in the link. Standard_Boolean HasOwnDimensionAspect() const { return myHasOwnDimensionAspect; } + //! Returns style for filling capping section created by clipping planes. + Standard_EXPORT const Handle(Graphic3d_AspectFillCapping)& FillCappingAspect(); + + //! Set style of filling capping section created by clipping planes. + Standard_EXPORT void SetFillCappingAspect (const Handle(Graphic3d_AspectFillCapping)& theStyle); + + //! Returns true if the drawer has its own attribute for + //! the appearance of dimensions that overrides the one in the link. + Standard_Boolean HasOwnFillCappingAspect() const { return myHasOwnFillCappingAspect; } + //! Sets dimension length model units for computing of dimension presentation. //! The method sets value owned by the drawer that will be used during //! visualization instead of the one set in link. @@ -984,6 +995,10 @@ protected: Prs3d_DimensionUnits myDimensionDisplayUnits; Standard_Boolean myHasOwnDimLengthDisplayUnits; Standard_Boolean myHasOwnDimAngleDisplayUnits; + + Handle(Graphic3d_AspectFillCapping) myFillCappingAspect; + Standard_Boolean myHasOwnFillCappingAspect; + }; Standard_DEPRECATED("Class name is deprecated - use Prs3d_Drawer instead") diff --git a/src/ViewerTest/ViewerTest_ViewerCommands.cxx b/src/ViewerTest/ViewerTest_ViewerCommands.cxx index edae95fac9..d2a7b1de5a 100644 --- a/src/ViewerTest/ViewerTest_ViewerCommands.cxx +++ b/src/ViewerTest/ViewerTest_ViewerCommands.cxx @@ -9224,6 +9224,371 @@ namespace } } +//=============================================================================================== +//function : setCappingParams +//purpose : +//=============================================================================================== +static Standard_Boolean setCappingParams (const TCollection_AsciiString& theChangeArg, + const Handle(Graphic3d_AspectFillCapping)& theCappingStyle, + const char** theChangeArgs, + Standard_Integer aNbChangeArgs, + Standard_Integer& anArgIter) +{ + if (theCappingStyle.IsNull()) + return Standard_False; + + Standard_Boolean toEnable = Standard_True; + if (theChangeArg == "-useobjectmaterial" + || theChangeArg == "-useobjectmat" + || theChangeArg == "-useobjmat" + || theChangeArg == "-useobjmaterial") + { + if (aNbChangeArgs < 2) + { + std::cout << "Syntax error: need more arguments.\n"; + return Standard_False; + } + + if (ViewerTest::ParseOnOff (theChangeArgs[1], toEnable)) + { + theCappingStyle->SetUseObjectMaterial (toEnable == Standard_True); + anArgIter += 1; + } + } + else if (theChangeArg == "-useobjecttexture" + || theChangeArg == "-useobjecttex" + || theChangeArg == "-useobjtexture" + || theChangeArg == "-useobjtex") + { + if (aNbChangeArgs < 2) + { + std::cout << "Syntax error: need more arguments.\n"; + return Standard_False; + } + + if (ViewerTest::ParseOnOff (theChangeArgs[1], toEnable)) + { + theCappingStyle->SetUseObjectTexture (toEnable == Standard_True); + anArgIter += 1; + } + } + else if (theChangeArg == "-useobjectshader" + || theChangeArg == "-useobjshader") + { + if (aNbChangeArgs < 2) + { + std::cout << "Syntax error: need more arguments.\n"; + return Standard_False; + } + + if (ViewerTest::ParseOnOff (theChangeArgs[1], toEnable)) + { + theCappingStyle->SetUseObjectShader (toEnable == Standard_True); + anArgIter += 1; + } + } + else if (theChangeArg == "-color" + || theChangeArg == "color") + { + Quantity_Color aColor; + Standard_Integer aNbParsed = ViewerTest::ParseColor (aNbChangeArgs - 1, + theChangeArgs + 1, + aColor); + if (aNbParsed == 0) + { + std::cout << "Syntax error: need more arguments.\n"; + return Standard_False; + } + + Graphic3d_MaterialAspect aMat = theCappingStyle->Material(); + aMat.SetAmbientColor (aColor); + aMat.SetDiffuseColor (aColor); + theCappingStyle->SetMaterial (aMat); + anArgIter += aNbParsed; + } + else if ((theChangeArg == "-transparency" + || theChangeArg == "-transp") + && aNbChangeArgs >= 2) + { + TCollection_AsciiString aValStr (theChangeArgs[1]); + if (aValStr.IsRealValue()) + { + Graphic3d_MaterialAspect aMat = theCappingStyle->Material(); + aMat.SetTransparency ((float )aValStr.RealValue()); + theCappingStyle->SetMaterial (aMat); + } + else + { + std::cout << "Syntax error at '" << aValStr << "'\n"; + return Standard_False; + } + anArgIter += 1; + } + else if (theChangeArg == "-texname" + || theChangeArg == "texname") + { + if (aNbChangeArgs < 2) + { + std::cout << "Syntax error: need more arguments.\n"; + return Standard_False; + } + + TCollection_AsciiString aTextureName (theChangeArgs[1]); + Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(aTextureName); + if (!aTexture->IsDone()) + { + theCappingStyle->SetTexture (Handle(Graphic3d_TextureMap)()); + } + else + { + aTexture->EnableModulate(); + aTexture->EnableRepeat(); + theCappingStyle->SetTexture (aTexture.get()); + } + anArgIter += 1; + } + else if (theChangeArg == "-texscale" + || theChangeArg == "texscale") + { + const Handle(Graphic3d_TextureMap)& aHatchTexture = theCappingStyle->Texture(); + + if (aHatchTexture.IsNull()) + { + std::cout << "Error: no texture is set.\n"; + return Standard_False; + } + + if (aNbChangeArgs < 3) + { + std::cout << "Syntax error: need more arguments.\n"; + return Standard_False; + } + + Standard_ShortReal aSx = (Standard_ShortReal)Draw::Atof (theChangeArgs[1]); + Standard_ShortReal aSy = (Standard_ShortReal)Draw::Atof (theChangeArgs[2]); + aHatchTexture->GetParams()->SetScale (Graphic3d_Vec2 (aSx, aSy)); + anArgIter += 2; + } + else if (theChangeArg == "-texorigin" + || theChangeArg == "texorigin") // texture origin + { + const Handle(Graphic3d_TextureMap)& aHatchTexture = theCappingStyle->Texture(); + + if (aHatchTexture.IsNull()) + { + std::cout << "Error: no texture is set.\n"; + return Standard_False; + } + + if (aNbChangeArgs < 3) + { + std::cout << "Syntax error: need more arguments.\n"; + return Standard_False; + } + + Standard_ShortReal aTx = (Standard_ShortReal)Draw::Atof (theChangeArgs[1]); + Standard_ShortReal aTy = (Standard_ShortReal)Draw::Atof (theChangeArgs[2]); + + aHatchTexture->GetParams()->SetTranslation (Graphic3d_Vec2 (aTx, aTy)); + anArgIter += 2; + } + else if (theChangeArg == "-texrotate" + || theChangeArg == "texrotate") // texture rotation + { + const Handle(Graphic3d_TextureMap)& aHatchTexture = theCappingStyle->Texture(); + + if (aHatchTexture.IsNull()) + { + std::cout << "Error: no texture is set.\n"; + return Standard_False; + } + + if (aNbChangeArgs < 2) + { + std::cout << "Syntax error: need more arguments.\n"; + return Standard_False; + } + + Standard_ShortReal aRot = (Standard_ShortReal)Draw::Atof (theChangeArgs[1]); + aHatchTexture->GetParams()->SetRotation (aRot); + anArgIter += 1; + } + else if (theChangeArg == "-hatch" + || theChangeArg == "hatch") + { + if (aNbChangeArgs < 2) + { + std::cout << "Syntax error: need more arguments.\n"; + return Standard_False; + } + + if (ViewerTest::ParseOnOff (theChangeArgs[1], toEnable)) + { + theCappingStyle->SetToDrawHatch (toEnable == Standard_True); + anArgIter += 1; + } + } + else if (theChangeArg == "-hatchtexture" + || theChangeArg == "hatchtexture") + { + if (aNbChangeArgs < 2) + { + std::cout << "Syntax error: need more arguments.\n"; + return Standard_False; + } + + TCollection_AsciiString aTextureName (theChangeArgs[1]); + Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(aTextureName); + if (!aTexture->IsDone()) + { + theCappingStyle->SetHatchStyle (Handle(Graphic3d_TextureMap)()); + } + else + { + aTexture->EnableModulate(); + aTexture->EnableRepeat(); + theCappingStyle->SetHatchStyle (aTexture.get()); + theCappingStyle->SetToDrawHatch (true); + } + anArgIter += 1; + } + else if (theChangeArg == "-hatchstipple" + || theChangeArg == "hatchstipple") + { + if (aNbChangeArgs < 2) + { + std::cout << "Syntax error: need more arguments.\n"; + return Standard_False; + } + + theCappingStyle->SetHatchStyle ((Aspect_HatchStyle)Draw::Atoi (theChangeArgs[1])); + theCappingStyle->SetToDrawHatch (true); + anArgIter += 1; + } + else if (theChangeArg == "-hatchcolor" + || theChangeArg == "hatchcolor") + { + Quantity_Color aColor; + Standard_Integer aNbParsed = ViewerTest::ParseColor (aNbChangeArgs - 1, + theChangeArgs + 1, + aColor); + if (aNbParsed == 0) + { + std::cout << "Syntax error: need more arguments.\n"; + return Standard_False; + } + + Graphic3d_MaterialAspect aMat = theCappingStyle->HatchMaterial(); + aMat.SetAmbientColor (aColor); + aMat.SetDiffuseColor (aColor); + theCappingStyle->SetHatchMaterial (aMat); + anArgIter += aNbParsed; + } + + else if (theChangeArg == "-hatchscale" + || theChangeArg == "hatchscale") + { + const Handle(Graphic3d_TextureMap)& aHatchTexture = theCappingStyle->TextureHatch(); + + if (aHatchTexture.IsNull()) + { + std::cout << "Error: no texture is set.\n"; + return Standard_False; + } + + if (aNbChangeArgs < 3) + { + std::cout << "Syntax error: need more arguments.\n"; + return Standard_False; + } + + Standard_ShortReal aSx = (Standard_ShortReal)Draw::Atof (theChangeArgs[1]); + Standard_ShortReal aSy = (Standard_ShortReal)Draw::Atof (theChangeArgs[2]); + aHatchTexture->GetParams()->SetScale (Graphic3d_Vec2 (aSx, aSy)); + anArgIter += 2; + } + else if (theChangeArg == "-hatchorigin" + || theChangeArg == "hatchorigin") // texture origin + { + const Handle(Graphic3d_TextureMap)& aHatchTexture = theCappingStyle->TextureHatch(); + + if (aHatchTexture.IsNull()) + { + std::cout << "Error: no texture is set.\n"; + return Standard_False; + } + + if (aNbChangeArgs < 3) + { + std::cout << "Syntax error: need more arguments.\n"; + return Standard_False; + } + + Standard_ShortReal aTx = (Standard_ShortReal)Draw::Atof (theChangeArgs[1]); + Standard_ShortReal aTy = (Standard_ShortReal)Draw::Atof (theChangeArgs[2]); + + aHatchTexture->GetParams()->SetTranslation (Graphic3d_Vec2 (aTx, aTy)); + anArgIter += 2; + } + else if (theChangeArg == "-hatchrotate" + || theChangeArg == "hatchrotate") // texture rotation + { + const Handle(Graphic3d_TextureMap)& aHatchTexture = theCappingStyle->TextureHatch(); + + if (aHatchTexture.IsNull()) + { + std::cout << "Error: no texture is set.\n"; + return Standard_False; + } + + if (aNbChangeArgs < 2) + { + std::cout << "Syntax error: need more arguments.\n"; + return Standard_False; + } + + Standard_ShortReal aRot = (Standard_ShortReal)Draw::Atof (theChangeArgs[1]); + aHatchTexture->GetParams()->SetRotation (aRot); + anArgIter += 1; + } + else if (theChangeArg == "-hatchzoompers" + || theChangeArg == "hatchzoompers") + { + if (aNbChangeArgs < 2) + { + std::cout << "Syntax error: need more arguments.\n"; + return Standard_False; + } + + if (ViewerTest::ParseOnOff (theChangeArgs[1], toEnable)) + { + theCappingStyle->SetHatchZoomPeristent (toEnable == Standard_True); + anArgIter += 1; + } + } + else if (theChangeArg == "-hatchrotatepers" + || theChangeArg == "hatchrotatepers") + { + if (aNbChangeArgs < 2) + { + std::cout << "Syntax error: need more arguments.\n"; + return Standard_False; + } + + if (ViewerTest::ParseOnOff (theChangeArgs[1], toEnable)) + { + theCappingStyle->SetHatchRotationPeristent (toEnable == Standard_True); + anArgIter += 1; + } + } + else + { + return Standard_False; + } + + return Standard_True; +} + //=============================================================================================== //function : VClipPlane //purpose : @@ -9520,72 +9885,6 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons // just skip otherwise (old syntax) } } - else if (aChangeArg == "-useobjectmaterial" - || aChangeArg == "-useobjectmat" - || aChangeArg == "-useobjmat" - || aChangeArg == "-useobjmaterial") - { - if (aNbChangeArgs < 2) - { - std::cout << "Syntax error: need more arguments.\n"; - return 1; - } - - if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable)) - { - aClipPlane->CappingSectionStyle()->SetUseObjectMaterial (toEnable == Standard_True); - anArgIter += 1; - } - } - else if (aChangeArg == "-useobjecttexture" - || aChangeArg == "-useobjecttex" - || aChangeArg == "-useobjtexture" - || aChangeArg == "-useobjtex") - { - if (aNbChangeArgs < 2) - { - std::cout << "Syntax error: need more arguments.\n"; - return 1; - } - - if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable)) - { - aClipPlane->CappingSectionStyle()->SetUseObjectTexture (toEnable == Standard_True); - anArgIter += 1; - } - } - else if (aChangeArg == "-useobjectshader" - || aChangeArg == "-useobjshader") - { - if (aNbChangeArgs < 2) - { - std::cout << "Syntax error: need more arguments.\n"; - return 1; - } - - if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable)) - { - aClipPlane->CappingSectionStyle()->SetUseObjectShader (toEnable == Standard_True); - anArgIter += 1; - } - } - else if (aChangeArg == "-color" - || aChangeArg == "color") - { - Quantity_Color aColor; - Standard_Integer aNbParsed = ViewerTest::ParseColor (aNbChangeArgs - 1, - aChangeArgs + 1, - aColor); - if (aNbParsed == 0) - { - std::cout << "Syntax error: need more arguments.\n"; - return 1; - } - aClipPlane->SetCappingColor (aColor); - Graphic3d_MaterialAspect aMat = aClipPlane->CappingSectionStyle()->Material(); - aClipPlane->CappingSectionStyle()->SetMaterial (aMat); - anArgIter += aNbParsed; - } else if (aNbChangeArgs >= 1 && (aChangeArg == "-material" || aChangeArg == "material")) @@ -9599,24 +9898,6 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons } aClipPlane->SetCappingMaterial (aMatName); } - else if ((aChangeArg == "-transparency" - || aChangeArg == "-transp") - && aNbChangeArgs >= 2) - { - TCollection_AsciiString aValStr (aChangeArgs[1]); - if (aValStr.IsRealValue()) - { - Graphic3d_MaterialAspect aMat = aClipPlane->CappingSectionStyle()->Material(); - aMat.SetTransparency ((float )aValStr.RealValue()); - aClipPlane->CappingSectionStyle()->SetMaterial (aMat); - } - else - { - std::cout << "Syntax error at '" << aValStr << "'\n"; - return 1; - } - anArgIter += 1; - } else if (aChangeArg == "-overrideaspect" || aChangeArg == "overrideaspect") { @@ -9632,263 +9913,6 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons anArgIter += 1; } } - else if (aChangeArg == "-texname" - || aChangeArg == "texname") - { - if (aNbChangeArgs < 2) - { - std::cout << "Syntax error: need more arguments.\n"; - return 1; - } - - TCollection_AsciiString aTextureName (aChangeArgs[1]); - Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(aTextureName); - if (!aTexture->IsDone()) - { - aClipPlane->CappingSectionStyle()->SetTexture (Handle(Graphic3d_TextureMap)()); - } - else - { - aTexture->EnableModulate(); - aTexture->EnableRepeat(); - aClipPlane->CappingSectionStyle()->SetTexture (aTexture.get()); - } - anArgIter += 1; - } - else if (aChangeArg == "-texscale" - || aChangeArg == "texscale") - { - const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->Texture(); - - if (aHatchTexture.IsNull()) - { - std::cout << "Error: no texture is set.\n"; - return 1; - } - - if (aNbChangeArgs < 3) - { - std::cout << "Syntax error: need more arguments.\n"; - return 1; - } - - Standard_ShortReal aSx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]); - Standard_ShortReal aSy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]); - aHatchTexture->GetParams()->SetScale (Graphic3d_Vec2 (aSx, aSy)); - anArgIter += 2; - } - else if (aChangeArg == "-texorigin" - || aChangeArg == "texorigin") // texture origin - { - const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->Texture(); - - if (aHatchTexture.IsNull()) - { - std::cout << "Error: no texture is set.\n"; - return 1; - } - - if (aNbChangeArgs < 3) - { - std::cout << "Syntax error: need more arguments.\n"; - return 1; - } - - Standard_ShortReal aTx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]); - Standard_ShortReal aTy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]); - - aHatchTexture->GetParams()->SetTranslation (Graphic3d_Vec2 (aTx, aTy)); - anArgIter += 2; - } - else if (aChangeArg == "-texrotate" - || aChangeArg == "texrotate") // texture rotation - { - const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->Texture(); - - if (aHatchTexture.IsNull()) - { - std::cout << "Error: no texture is set.\n"; - return 1; - } - - if (aNbChangeArgs < 2) - { - std::cout << "Syntax error: need more arguments.\n"; - return 1; - } - - Standard_ShortReal aRot = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]); - aHatchTexture->GetParams()->SetRotation (aRot); - anArgIter += 1; - } - else if (aChangeArg == "-hatch" - || aChangeArg == "hatch") - { - if (aNbChangeArgs < 2) - { - std::cout << "Syntax error: need more arguments.\n"; - return 1; - } - - if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable)) - { - aClipPlane->CappingSectionStyle()->SetToDrawHatch (toEnable == Standard_True); - anArgIter += 1; - } - } - else if (aChangeArg == "-hatchtexture" - || aChangeArg == "hatchtexture") - { - if (aNbChangeArgs < 2) - { - std::cout << "Syntax error: need more arguments.\n"; - return 1; - } - - TCollection_AsciiString aTextureName (aChangeArgs[1]); - Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(aTextureName); - if (!aTexture->IsDone()) - { - aClipPlane->CappingSectionStyle()->SetHatchStyle (Handle(Graphic3d_TextureMap)()); - } - else - { - aTexture->EnableModulate(); - aTexture->EnableRepeat(); - aClipPlane->CappingSectionStyle()->SetHatchStyle (aTexture.get()); - aClipPlane->CappingSectionStyle()->SetToDrawHatch (true); - } - anArgIter += 1; - } - else if (aChangeArg == "-hatchstipple" - || aChangeArg == "hatchstipple") - { - if (aNbChangeArgs < 2) - { - std::cout << "Syntax error: need more arguments.\n"; - return 1; - } - - aClipPlane->CappingSectionStyle()->SetHatchStyle ((Aspect_HatchStyle)Draw::Atoi (aChangeArgs[1])); - aClipPlane->CappingSectionStyle()->SetToDrawHatch (true); - anArgIter += 1; - } - else if (aChangeArg == "-hatchcolor" - || aChangeArg == "hatchcolor") - { - Quantity_Color aColor; - Standard_Integer aNbParsed = ViewerTest::ParseColor (aNbChangeArgs - 1, - aChangeArgs + 1, - aColor); - if (aNbParsed == 0) - { - std::cout << "Syntax error: need more arguments.\n"; - return 1; - } - - Graphic3d_MaterialAspect aMat = aClipPlane->CappingSectionStyle()->HatchMaterial(); - aMat.SetAmbientColor (aColor); - aMat.SetDiffuseColor (aColor); - aClipPlane->CappingSectionStyle()->SetHatchMaterial (aMat); - anArgIter += aNbParsed; - } - - else if (aChangeArg == "-hatchscale" - || aChangeArg == "hatchscale") - { - const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->TextureHatch(); - - if (aHatchTexture.IsNull()) - { - std::cout << "Error: no texture is set.\n"; - return 1; - } - - if (aNbChangeArgs < 3) - { - std::cout << "Syntax error: need more arguments.\n"; - return 1; - } - - Standard_ShortReal aSx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]); - Standard_ShortReal aSy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]); - aHatchTexture->GetParams()->SetScale (Graphic3d_Vec2 (aSx, aSy)); - anArgIter += 2; - } - else if (aChangeArg == "-hatchorigin" - || aChangeArg == "hatchorigin") // texture origin - { - const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->TextureHatch(); - - if (aHatchTexture.IsNull()) - { - std::cout << "Error: no texture is set.\n"; - return 1; - } - - if (aNbChangeArgs < 3) - { - std::cout << "Syntax error: need more arguments.\n"; - return 1; - } - - Standard_ShortReal aTx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]); - Standard_ShortReal aTy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]); - - aHatchTexture->GetParams()->SetTranslation (Graphic3d_Vec2 (aTx, aTy)); - anArgIter += 2; - } - else if (aChangeArg == "-hatchrotate" - || aChangeArg == "hatchrotate") // texture rotation - { - const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->TextureHatch(); - - if (aHatchTexture.IsNull()) - { - std::cout << "Error: no texture is set.\n"; - return 1; - } - - if (aNbChangeArgs < 2) - { - std::cout << "Syntax error: need more arguments.\n"; - return 1; - } - - Standard_ShortReal aRot = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]); - aHatchTexture->GetParams()->SetRotation (aRot); - anArgIter += 1; - } - else if (aChangeArg == "-hatchzoompers" - || aChangeArg == "hatchzoompers") - { - if (aNbChangeArgs < 2) - { - std::cout << "Syntax error: need more arguments.\n"; - return 1; - } - - if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable)) - { - aClipPlane->CappingSectionStyle()->SetHatchZoomPeristent (toEnable == Standard_True); - anArgIter += 1; - } - } - else if (aChangeArg == "-hatchrotatepers" - || aChangeArg == "hatchrotatepers") - { - if (aNbChangeArgs < 2) - { - std::cout << "Syntax error: need more arguments.\n"; - return 1; - } - - if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable)) - { - aClipPlane->CappingSectionStyle()->SetHatchRotationPeristent (toEnable == Standard_True); - anArgIter += 1; - } - } else if (aChangeArg == "-delete" || aChangeArg == "delete") { @@ -9965,7 +9989,7 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons anArgIter = anArgIter + anIt - 1; } } - else + else if (!setCappingParams (aChangeArg, aClipPlane->CappingSectionStyle(), aChangeArgs, aNbChangeArgs, anArgIter)) { std::cout << "Syntax error: unknown argument '" << aChangeArg << "'.\n"; return 1; @@ -9976,6 +10000,69 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons return 0; } +//=============================================================================================== +//function : VSetCapping +//purpose : +//=============================================================================================== +static int VSetCapping (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec) +{ + if (theArgsNb < 2) + { + std::cout << "Syntax error: the wrong number of input parameters.\n"; + return 1; + } + + TCollection_AsciiString aName (theArgVec[1]); + gp_Pln aWorkingPlane; + Standard_Boolean toUpdate = Standard_True; + + NCollection_DataMap aRealParams; + NCollection_DataMap aStringParams; + + Handle(AIS_InteractiveObject) anObject; + if (GetMapOfAIS().Find2 (aName, anObject)) + { + if (anObject.IsNull()) + { + std::cout << "Syntax error: no presentation with this name.\n"; + return 1; + } + } + + Handle(Graphic3d_AspectFillCapping) aFillCapping = anObject->Attributes()->FillCappingAspect(); + for (Standard_Integer anArgIter = 2; anArgIter < theArgsNb; ++anArgIter) + { + const char** aChangeArgs = theArgVec + anArgIter; + Standard_Integer aNbChangeArgs = theArgsNb - anArgIter; + TCollection_AsciiString aChangeArg (aChangeArgs[0]); + aChangeArg.LowerCase(); + + Standard_Boolean toEnable = Standard_True; + if (ViewerTest::ParseOnOff (aChangeArgs[0], toEnable)) + { + if (!toEnable) + anObject->Attributes()->SetFillCappingAspect (NULL); + else + { + if (aFillCapping.IsNull()) + { + aFillCapping = new Graphic3d_AspectFillCapping(); + anObject->Attributes()->SetFillCappingAspect (aFillCapping); + } + } + } + else if (!setCappingParams (aChangeArg, aFillCapping, aChangeArgs, aNbChangeArgs, anArgIter)) + { + std::cout << "Syntax error: unknown argument '" << aChangeArg << "'.\n"; + return 1; + } + } + ViewerTest::GetAISContext()->Redisplay (anObject, Standard_False); + + return 0; +} + + //=============================================================================================== //function : VZRange //purpose : @@ -14311,6 +14398,33 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands) "\n\t\t: -useObjTexture {off|on|0|1} use texture of clipped object" "\n\t\t: -useObjShader {off|on|0|1} use shader program of object", __FILE__, VClipPlane, group); + + theCommands.Add("vsetcapping", + "vsetcapping name [{0|1}]" + "\n\t\t: Sets capping parameters for all, selected or named objects." + "\n\t\t: Capping options:" + "\n\t\t: -capping {off|on|0|1} turn capping on/off" + "\n\t\t: -overrideAspect override presentation aspect (if defined)" + "\n\t\t: -color R G B set capping color" + "\n\t\t: -transparency Value set capping transparency 0..1" + "\n\t\t: -texName Texture set capping texture" + "\n\t\t: -texScale SX SY set capping tex scale" + "\n\t\t: -texOrigin TX TY set capping tex origin" + "\n\t\t: -texRotate Angle set capping tex rotation" + "\n\t\t: -hatch {on|off} turn on/off hatch style on capping" + "\n\t\t: -hatchStipple ID set stipple mask for drawing hatch" + "\n\t\t: -hatchColor R G B set color for hatch material" + "\n\t\t: -hatchTexture Texture set texture (semi-opaque) for drawing hatch" + "\n\t\t: -hatchScale SX SY set hatch texture scale" + "\n\t\t: -hatchOrigin TX TY set hatch texture origin" + "\n\t\t: -hatchRotate Angle set hatch texture rotation" + "\n\t\t: -hatchZoomPers allow hatch tetxure mapping to be constant when zooming" + "\n\t\t: -hatchRotatePers allow hatch tetxure mapping to be constant when rotating" + "\n\t\t: -useObjMaterial {off|on|0|1} use material of clipped object" + "\n\t\t: -useObjTexture {off|on|0|1} use texture of clipped object" + "\n\t\t: -useObjShader {off|on|0|1} use shader program of object", + __FILE__, VSetCapping, group); + theCommands.Add("vdefaults", "vdefaults [-absDefl value]" "\n\t\t: [-devCoeff value]" -- 2.39.5