From 586cf75e22889d19a66bc5c73b4e5e90d626c6d1 Mon Sep 17 00:00:00 2001 From: ouv Date: Wed, 28 Jan 2009 16:32:46 +0000 Subject: [PATCH] Merge from BR_DumpPython_Extension branch (from tag mergeto_BR_V5_Dev_28Jan09) --- .../gui/SMESH/images/addnode_notebook.png | Bin 0 -> 11965 bytes .../SMESH/input/adding_nodes_and_elements.doc | 5 + doc/salome/gui/SMESH/input/index.doc | 1 + .../SMESH/input/using_notebook_smesh_page.doc | 33 + idl/SMESH_Hypothesis.idl | 32 + idl/SMESH_Mesh.idl | 16 + idl/SMESH_MeshEditor.idl | 78 ++ src/SMESH/SMESH_Hypothesis.cxx | 57 ++ src/SMESH/SMESH_Hypothesis.hxx | 9 + src/SMESHGUI/SMESHGUI.cxx | 10 + src/SMESHGUI/SMESHGUI.h | 2 + src/SMESHGUI/SMESHGUI_BuildCompoundDlg.cxx | 32 + src/SMESHGUI/SMESHGUI_BuildCompoundDlg.h | 2 + .../SMESHGUI_ExtrusionAlongPathDlg.cxx | 183 ++-- src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.h | 5 + src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx | 108 ++- src/SMESHGUI/SMESHGUI_ExtrusionDlg.h | 8 +- src/SMESHGUI/SMESHGUI_Hypotheses.cxx | 95 +- src/SMESHGUI/SMESHGUI_Hypotheses.h | 12 +- src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.cxx | 27 +- src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.h | 2 +- src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx | 34 +- src/SMESHGUI/SMESHGUI_MeshPatternDlg.h | 6 +- src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx | 22 + src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx | 31 +- src/SMESHGUI/SMESHGUI_MultiEditDlg.h | 3 +- src/SMESHGUI/SMESHGUI_NodesDlg.cxx | 36 +- src/SMESHGUI/SMESHGUI_NodesDlg.h | 2 + src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx | 199 ++-- src/SMESHGUI/SMESHGUI_RevolutionDlg.h | 11 +- src/SMESHGUI/SMESHGUI_RotationDlg.cxx | 138 ++- src/SMESHGUI/SMESHGUI_RotationDlg.h | 5 +- src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx | 121 +-- src/SMESHGUI/SMESHGUI_SmoothingDlg.h | 10 +- src/SMESHGUI/SMESHGUI_SpinBox.cxx | 5 +- src/SMESHGUI/SMESHGUI_SpinBox.h | 4 +- src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx | 121 ++- src/SMESHGUI/SMESHGUI_SymmetryDlg.h | 6 +- src/SMESHGUI/SMESHGUI_TranslationDlg.cxx | 110 ++- src/SMESHGUI/SMESHGUI_TranslationDlg.h | 6 +- src/SMESHGUI/SMESH_msg_en.ts | 4 + src/SMESH_I/Makefile.am | 4 +- src/SMESH_I/SMESH_2smeshpy.cxx | 47 +- src/SMESH_I/SMESH_Gen_i.hxx | 5 + src/SMESH_I/SMESH_Gen_i_1.cxx | 99 ++ src/SMESH_I/SMESH_Hypothesis_i.cxx | 115 +++ src/SMESH_I/SMESH_Hypothesis_i.hxx | 19 + src/SMESH_I/SMESH_MeshEditor_i.cxx | 497 +++++++--- src/SMESH_I/SMESH_MeshEditor_i.hxx | 62 +- src/SMESH_I/SMESH_Mesh_i.cxx | 47 + src/SMESH_I/SMESH_Mesh_i.hxx | 15 + src/SMESH_I/SMESH_NoteBook.cxx | 861 ++++++++++++++++++ src/SMESH_I/SMESH_NoteBook.hxx | 106 +++ src/SMESH_SWIG/smeshDC.py | 827 ++++++++++++++++- .../StdMeshersGUI_NbSegmentsCreator.cxx | 54 +- .../StdMeshersGUI_NbSegmentsCreator.h | 7 +- .../StdMeshersGUI_StdHypothesisCreator.cxx | 105 ++- .../StdMeshersGUI_StdHypothesisCreator.h | 5 +- 58 files changed, 3934 insertions(+), 532 deletions(-) create mode 100755 doc/salome/gui/SMESH/images/addnode_notebook.png create mode 100644 doc/salome/gui/SMESH/input/using_notebook_smesh_page.doc create mode 100644 src/SMESH_I/SMESH_NoteBook.cxx create mode 100644 src/SMESH_I/SMESH_NoteBook.hxx diff --git a/doc/salome/gui/SMESH/images/addnode_notebook.png b/doc/salome/gui/SMESH/images/addnode_notebook.png new file mode 100755 index 0000000000000000000000000000000000000000..4abab33589ea61a0b79c81146f571f4348eca47f GIT binary patch literal 11965 zcmbt)cUY6(mTo}7hA5(-R7HwN2Lb5{2vQ@x_uhL6UFp&Ugb{B9 z-}~Ztb%^r7K(iKV`>i3EOg!Ubb#%yG8@$Wgno`=O=6CK+y1Pk_&;d_~R;hV<8Xili z4nA1`!|N73wFqF$%7h+sM5?$MH;fY||L&!SPNQst=M3=Q`zK|4DJyuZUMqni-5M0N zIc#*sRLMP3)75uD;|(|q*2LS#XJ;sh;e@4+AIZ)ysGqCB1I!RwTMaB_c#Qeuw(5g@ zIC6wP=jBHuLv9m(aa#)-<_Q;eb@aMSdOiJ%pyPz#RRe6bX^ZKnCT@BzZ>rb*jJ-YXU>VP%?MOUoEyqP5ZJ+ysf& zu;UwY_3q~*PQAx->pmyp5fLWCV)hH|&ENyHstVj$&haK=e0amrdUsTcN!ZT^vdWzT z^~dbdF{AcQ$7CC_I`WL95;aJR#-kF|J9+Z^Rd@2I4zJ0L`et{{g&p6I?+9vD{-{^u z_m|s-CTOzEYJ;o6!7cWgC-Fsi@=+Rn`w5u>`N=Xrh-TJ5%veCPBqsOSen$Uk;X-NE04z z^o$Zj{LcMA5|HfeX4Ks;YCA#Fo)OGpQflsu8+Rf;$}kY#+4muUiTR7(A+K+e@VJa} zI?!k8+B`PnyqJgBH{>v-6Jks!)_Hx7XN0DlQ0OX`T|-;)IEcd*cKmby^4vwW%TB+j zPn8jmL)|4sGvPhM!`(SkxKQ)_k*FV|>68`3L5j#s{*^iAs`VJB|J^TPtUkkG{*@%V>@w{i#$#@+eSZ_Y5IU z+S~Bt^ZOH$NBY6h1>g2jd!(DwHPEh+qGe=!c6d}&ru$OscW#TATgb!S`k<~K{Q3*F z)d}6X8hgu7oweb#x;l0_$FQ!0NAv;$Fz6*BZVh`$i#)RIilg;&dV#zi%K1~838c=h zC$Ig6A#w9K_*dXu7JLkG7~y8BR=Dk~6LPpo)R-NCemBq{#S~(!p?Y*N} zPKb)6o@H^$ED=q*CAo&nF%xc>W}P*Iy8oRV7@w#X5*8{o)f7OZ=V>-#o^S4-8>~V2 zl#44?PHo*-L1F2*LxtEa^UodzpO~W*C;4*Pshb_lHsD&2#3F40?_GIC#bsqp5#@yi zyr0_TFa1_XD;H@uoptD%O8qwvmXjR>zpCY_-#wV{WIs`3EvuuO*K^ZVlk)&UYDNhzr~iX>mJx2}>&&F6`;_n|8+kqobc#?faNiQdpJ1xrnLG*H_tU>QV}C1M6UT8--kHMh9UxQ;_MwD|mqv*Y4UEPEIWW2}q} z+8$8N@B0LIz*cs1#5DIu2rp+EvLz}~x z4=1YWc$mmFv@~v0Yh5~PaC0NZu^Uc_MS9@Oh&|oH(c)uDElF90ZG#KH%M)4rYitxXB*O1%L-q(o} zw%4=Z&z^2kG1@SyBgCNBSmKpRURH4w&RXl>4=NXDq_lp8;W3hGUA{F{C3?>DX2mev zGugnycJZtzQBWSCU7%b2Rn~c**3{gbgo0w;F>Rm=%HeW(4(SC%Z)iZLl2hCzEOo#L z8@D{3j`$!M8T(`^QvOnSY_+p#_WoeA&71Ag+57A&?V=G+-WO>PIl+H)djucOKF&TE z|0MB#C0E$2LN?7*m&*Z8`t0-Y@+5J@>BY%?k{t_f*yWT>f^Y9q0u(@Bs1EYpR7UQ5TQ!rf9SeD^|C!Bu}D|#TVB`L z?8j@u)7OE%%+0b4hFfBeUz(+(`zw{w2Q~H5fJT{Lt|qWwzyus^446=fItP*UB-dnK zZcMr@wr}Y~l*vad_dF`Sn$B*Drr2+$20EVf_#5(b+DQ4>{;wLG`wNGemmzgE3$kU= zZz3{(ceS*&yfD35v`!_jA)7(fXGLnEaU3ym;csLz-$2dSUE%|^V$~M|UY~1xvZJXV z{u$fR9{0%TuU2Dp^Q(*Sc8Jqu*YVkjfP5ds9^bs%CyuX#+L9FY5r!}~=~T1lgCz;t z5sp<@$+fdjYaMQ%5qI4L zp%yC{t3P3m`dCGV9!gVGdq2GS@cT+%LuEiq3w?z@GTcsw&w1ZJ+jB0H0JBfN(jYJE zeA@}tuz+&28L#jSZ3cj4kIWmpWimaa5_;@xah@=(i4;$fWG6|*K~(|@aAc-roX*71yP+W zX%G@WY5SP!f!AMVW}{wo{Ppx`9dEa*NIKjO-BIt;#aF_rb&jX-P515_abr5YYRqE) zW$NcC{VU_pNC7Jl7&eELM?U7tGF>rL3;(IVX!hgBk4n2^w5QcC7Ww4UBnd5JV>*qI z0vlY-jGCK_tZXSR<;$1%(}HfB{swBu=;r-w#gr@;Bpftu%a^at!WiGNRB@N)b-)sf z2AA{j^gAzwD^+4L=u_A+r3|7Sb+1|c4L5yV*W9mpL{Y49ig0tsp<`%~J87p|*aZM% z#=FvgOAA_@Ay@?7llM*QQcY*V#PoF#; z2d^)Siu4(s7N-Tm1nn4QEPB5reQhy`5&Kn~Cb7AMoD%-ZtdcGCb%oD*kvcN<@TqhR z^>ZGc_`n>iCwn8&PYFph5a`8>=oAE zA3vqH*AwEfHdT^dqoKm8Q(=xamY$OZG!VHs8jx_1S9^Hq>QR`b=@-^jFA~#~a5Z+% zmUpqUxVjww^kxme}WK!BSVgsgwJE;!XY+j_B`Qmv`0(=~KZ3jeULh#Kgot zvH8*1#{#Q+-{EO{PksMnSa`0puP;XayyQgdvA`(}m{;LSUP)oUFiwxkeJmC!MhoCUD2D-GZq=1m*bm+}cKT{^HgNmn=2QH|j`rG*$MWu+xG$LZ!i6*j zvw&?2dkB;EdzU06d9l|{8x$IP?Mq^!`VU8f`?EV>RaIWl%j?%44_+O-*dM#^8*f*b z;w09$CRDO#-30-DBBVm+Y6Bn9)DR~k42Tm=`_zaL z6Y`FZ#dvI2*2+v1Ly#{d9SxcV7Iv^%h5xx6du1Ojl%A}HOV@ukOnXHPtzF4q-?@P7 zRQe0>HL;~_3mVQ>>S4C|-|y6a3vCWKtO&M*Ja~UlUx{KS6^^eiJ7`s5H({xIwLZzt z>(q2t%lR*$Ea8~@?z>W@Mrz%sZdo8_2V`C;n3Hhf{h;?cq5B<4nqFvK(I)zV#+~oVfctFQrQ1 z(j68DAB8)j=euIA8w1HU-;i|u#=mU2x!fj+3hjmxqxGs0tJ7HO$>HN~WW;@9CyOf8 z=zeGxn>LT>IQq5wCcihtSe$O54gAARUg(o{Yg9Q*1aP%0w z4^`B&nh;D3rG;U7l@Cy>fh^pi`E0cGvghaA*kw#A^UM2kvv{u_M8dl@tIs-d)8T?5$uiK>zU*@M(?F- zvXbe4$8j@vFt^y@q8-Kxj8GVAV!P`76D+C%;nm9RCr}BcJUdz%XiqJM##CDnnQT`@ zT!`%$z=Z#8s*^WKVj2)zyT5{#-gX@qfc|_+pC+#>`m^chv9K)Z7euub_~r zc+o}=7o01r%gM()1F9MT3|@fFU?6S1l!x ziILG+ZMquMu%V|0&B&mKcHxCO5&%K`KMqO3l%AKtD$1+SG{VSjf@x$M>*~`u*xO#$7n8|J< z9xK4;V$-+Xt^BT>&bO}_L#_H1ElgE4)%)&tsQsfcH0SvaQjjesGI9~S(7xrJ?00tY zIyRPs9V$fnNR6$JyOr1YaJn1L8wl7KDFsDS@E!7>Dh*C)8wO{s*4D#e?%Fe1ZY-Av zziL4FXXYX%?OICE%aDy?QJxTkd(POOE~4z0#87G1A(M6qQj z9K!8oPY^%Vka*WZiPH6IG(-2#+NUJ2l&AN}o}}1J)|J^%cKwxx{E+T0vQ6V6c5#ZS zfMVB1;!)C5GCkEtu)RepeaK0suwCVT8tD|k0BQ}w6`hM7DAhGer~giXIP>=JL?kU&Wwr~ieskR(ADGT#KB%zmsjvGRF~PdnGUeoo3u&k< zU)+cK-k}L*0W1PNixJTjc$Sw5o!XqxVAcf!fn#Fi4c228Q#{@2%2_$euyl#gdn|wc zNK(F~xvTM8(Dm5Ss-RT2`9+1>X)*4S(S(iVFa7a~Qbi^d>vdbpAl1Usw%&S8gEF zIM#0HO}k_(+#R`0p-sJ`X;|w2S|O?N>&0BRpMB@SuY`RT7M8q5XF0>CfrK+b{%=5Q zR#utAx#vF(B5Zu}3|2ni$i|M%aqhh<_=z2+*W#a$W^LZHEWA;bDkosUvKy$)^*U*$ z&c4yO#Ia8=z2rKf^V)o?vTf?~BO9kEhocRub@V(1dJ}!JR~2B^bs1*v|F~yamsXXB z@gNn4?Y~hj>v^5opB`d5J^wq=4VIrTpKbOmEn&^em;BQw{9Ct)=w7_|vIZ7bY@Idi zO%>AVWb4WD1J+aSm(rYkhV;B=u=TgGJ0Xjk#(Xf&v| zf%Ut)ok@u%D{)NYn>$5px^LcFnkmQOUL0Xg#T)9a8lP@AI1pW&VG&^5`2mOLg@Hq{ z_0qnwg9>EP=0Y$OaY;?0)~xTxenP~ESa2w`<)a)j?=~Iy;lTxykF0i~=dqAS-Y9A6 zY{ed1<9fk4H}ZpmuG>?+4qEC;R7RK=-WvyGtFhwTsXgML;J5#}v+uuU%!k5}e2zf1 zR_>8{ZjETHj+V19fm4iUY9Z$f7?j)sgTU^=LAF#BMeXhsV#))pDQZyHdHIo6%;-Uk z=>AQGWInbd_XK{}8}qD%8@zPfaW*;?^qidib2=Xk4WEAe_*N62&8PbCd2Uc}{MRJS z{3ButuRB*r=jVGip6$E0q*1#!+Mrc$D^uTfBHrNVJj%)_c6k39AyF~df4OP}vKCAZ zNKmz7E!v@SLGhH8TM%6efDQrsM!tVGJ%b_N83~2{BQY_YFy6)%64z5kf=(dib~y zWIKL&%JsS9IwKE9Z)zWq?^_+IA@?&Equ{gso$OF=Wx&YB79|tUgs`2+1`$!Z^Kb~` zgg<`#$ewV6P;GI-BGu^foZ!2l+vf=K-gr2?xAI0C(3Jb7T5d~AI4Owp>;$jB229Im zKiSsO>F>@ARJ(A1iy8D+n^kPGU$-FyjvmHY%w!7Y> zvCDI2#CJ9!p%@KAz!wkKJc&2aF+Jucizy!58yyqEJPvTVC6JR?+g@`twWOpeF6gjh zV(7KYGEoDSz^4&wvqL=(yw^VQsXP|MzNeT>^B!&1vqKg2BJE6v)65sx!ev~_xkGrO z$A}x3-B0~GL3BR)O&`s)7PiL=Ku*Rig$;b@L4u#iS;s`A_blG&(MCH@pJ-QJQSA>= zy-wkQqLdTUiEJv-{W}izm$GRGfHuq#PY?n%V4)544PvUNd=&+C{(2sItiVe#PEQk1 zgu@zIiW847xu*@dr~}=+b=w&-_mX5pMn+IC|B;2cIrs6hPL)fGm?y3oSA3X$4@jE5 zaIHFwbnQ0xKR@qIx;WoEIC!3K&D)!G{`Soqke}ZrMD%C5^@w?M$k8k7uXP@q{b>@1 zn~-a`i=A80&K`3yMff?#z<~c2U6Ec5F(qGqwo!8kh)UEa3E)n@tlfNEG>R_2zYQeZ zyFA-*LD@A&low>I_QGXm#jWSi`4Prbl}_w>;HAcofx^eXO?*nM1upCwXH$d=cl>x4aeJD^mGg)hoC{g|SVfDQC6q%Yz zYcA&h>7_c|fwL6+a%+bcFeSldF|4gtfjVpA8+L@0DeLzi6FNvlKl&{Wy+2pXx8EsBgq>a8ciHr$?0ID^~qa&uBBIx^ycYKW4+d zK9A&S@YqkiKE>{UH8qoLid1A-8w}DbQM_ZX(iBrBg$1xyh1I$CX>+%CbNobXM&pNz z3{umjW0tMrD^s&i-J(qzF4~5zc#bXi&H%|8t#FqI-T9k2il=|#SI@l%X=!O7U^X~# zDSYM=oDku#?~3D#YsVjLjUb0?x1RXa9{bYx9Xi>sPQ<@ddr6*GNW6tQ7}2n)G-;t$ z1X4ghfCwe&Lg!>4T^eB0&Q(*e)zwwuE?ukcB(6wWG5F=h8ISv>W?M9M*L-V4#1Td2 zs`JiE`~Kq9hRO3IXmhJR_Nz2)mYTefd%GQnJN3+D(Z)#L%C0}N9(;3*nc1RhrQWHw z!V!-INDtJ|XuPr+jimKIkEIdu0^KJkmqwWP=(3Ze7dtNPUIAgY%sr8&q#Eg=jS%=0 z@2MhI(e#vEJue?R#nZQ}#R8dx~Qc0$2 zXk5N-gOq^JE+{HlxB0ZFfsTP8_$$IfMn*tRR`#}q3p`cf8N(7QCBNPB?yqaaUF2#& zVvg$4fNEyEsP#a2q=>_yzI)Ys+iY?nX5goiM7q9W{dVO7G2Cj5R$=`KJmzbshP$@1zkTa$aIHbvZKoeQcD zWP3zFAY#v}T7W|3;CkP)!2%tA@00HWE@7WP{{Rl)E5O45$id}}v4wV}z<6!QVq;^6 z3v{4lY}(@u@9;KJ$QS{a<=xYbB2+d^o^i$(s|PH;H%DdWfF-n)m4#(!&dCtncepwN z1#(@3LxVDMatr{P3=h9j9#WQ3P%v4@>Y*CPy1>muN>G!i({j%n;G+$In47PD`K61_ zL_8~c{yKyEl-2-f&%SEpDP90P+MR1_ZO641`jnr779yPwI(b9afkMC4(!7$ia z%yaj?f6W$cz5(`;T66Q((89vP6V79Ebv6U_S))imjx(9KDsW=Az^(C#jz;B6AhWr= znB$pk)}vD~AG`wZIAF7E?Ht*>u=1#PQ}i{~j#W$~iil)CJbfcDT-5pqus((=;>1&A zWfNuF)|AgSJr;0M=6$`?kSytU?@AWV*fOW7n49;{sJPP!<;5NVokwm7mf<0Wg% z=4YNmruxDV79fkH+Mw>AI5@lJgnD0X81_|*V2ftvWWjw>cPyF&SDC^f2Q4{h-=aaM zu+HB;vSIG(RK}?{#&PEr$5Z={S0s#Ms85Vg>P3QF${A1B$CMKjGA|1P7|aq`YNC+7 z$O#({j)>Rker#r1TI=ZBn#$&ogF=(odF6)0(tOq<2Le`RgwGsh^n0Zo134{qU_pHZ z`QAJJjYA6eX^Vkmmgi;b3EV!U>uS;UqeU)1{Uca>%KcZ`P58aZ0Or4^&QM33xc!+K z2!{S=7Z(4TsJHNY+oP-UNVe`@1)Myx4~v!K6v@}5!hm_`mOc`bTqW!Niz^Y?LzX50 zvZAa*fwo~9SJ1U-Cg($)51dFK&}g9qV#;z!=#Rl?;=m;T&3l%ADfWN5qG8$Vfk!;2 zXB{NXOL$NTS-nqIcOezNG2p!;m|js8#y{|Qwz{beWG6QUF%~|0-&m?$0M{(=#H+*7 zEhV>s7A$qV`1`Ks=d*(I)oTN0ykqwjOah$B*y@rohB7&W-WSOdtArtAU9#Oi1G3_UiavXk3c zhDij`$WD{Q#?mt|dYMj3l{f3?OE^K+>o}MV(A#t~KWbxeQu_&eWvuqz8lFou`HCq* z@d;*TD6Ed0?{sG7U+(z^4R8UM)cM^siQz((P#IDt$BhDHby+^r#RJtPfhO5A+dijC zSSlHU4SI@<{K$>J??1V;cEW6fnt7y;WoZJgi{oH0nc&-G?wiLSHwq(|%iW+^=aVGl z@t$j$l+$9B9}9C}2sZR-tL6QZl{)=Nz<6?GR>(Jo?YIC^My zVP=P_X?l+AEHO7*Iy*jIh^aCgX9H3IJwE4q?Zjpy={CFjT^vKT@8s4;92$edNoC{| z+^VRap2Ub*PUZ{9gok6+fajIX%%_&1AmOc(t#OCQ#{zMLcPW*!x7CPf{U~qk?GbP2 zmRXXFwN_*TH^o!^dHiRX?Q&>#W)`+bhF35i1E9`x8k##Y{`nE6!4qB4(>~~-~eJSx_CzL{Oqr5KBcbA zHSRkV&>n+bZf~Httcyd`Vyrji`gK)9%v2RY;aJL!uMF+XxQFcNeddTMUP8}}@wHyA zMm-dF!&V~tu&F|38o}Fh+<$QJTmex$bosj7NSj` znA7Cc70B(~yqDJ$`DEyL6S4H}B~lylSY%xh$k$46a}SniBaZjGiXL;D77y|H)?rwH zgb$EPz*EhC+yVqvrB(}!p@J*DDGI>V0Z?N$<%_k%Y@uubJoh0O$_77Y&A&Z2X9RGe zf<`+>%%;}M(2zwPxc5W?iw3vvk7kK+W}Pr6=NA>+8SSlGdy>-9dwtod zrO=C&^q3@3UkW9qk)N7eU)pJWllsJPKN^p!59&D9nkml|WoYTlVr$w!e>Vsl9sP-r zNw@W7$fCZ#5sDsL`(ameqjyYcvUXiiQ%+2)tw$nsyepLWNfT2lYq|lt9s{u+{b|He zq=z624-Y3kdZcdOQwpTi6||97J)Mv89=~?{V=`q-S%P)|4%a}uW`uz?c4f-t0C`5n zPzXz?dIiod$M6{sPuHb~v9U3n?@`%ZaS8GFm(O9lySw5@17+n0<<_I;dE46Mf9@tP zCRy%i6+1q=qp$xS2&RGfKHH;6AM_m{!u1!Y*9;L8#o7fBeW*}no}a^}5M3O!MwG?O zcawGXs1j9T;NQVhpdT25IjSjD_{=?;_()F@;vNXN)@mDMpjE2#a?5tBi4a=Hj@Cb?gH&xGlt06Z#D&&D|}(_KULd`&Yj60y?F!1XM) zB}me|58m8}$3L;*m?^vhL1ZZa>7RL+1>CH^@uMQjw5K#KF)^eeRqPS|OUL=+TQsSs zK@uXp`rvJ=YxdQ#6E4efUz1E7RQynl-^`Y_YqsYnR^S#xSv?uqnFpv6wC7@M`}a}b zp(uWCkL@91H?-?Q6lVVxDU;K2KMBC^Iy$@QSjN0Ua2F23m&c@3LKsRY54+21zY)Nd zzdO`Som{!Af`7Ox@_)9@rY!Ob1?Rpy1Tp1iR>DW$HVl0+6BfdvOC`c)frP|{+bUq5 z`DhegB|BqCG9l68e5Tyt#u&5&i(V;~H(IJnjR7)3;9i)VeDdfCO}ekwHWmDGMYs+8 z{k^NJn^X)%E4hIW%ppZXk&++dXD%v`Y%k(+(~{EC_O;wv zh!}zIn|3a!XdPlG849y20q=KWjOMaVj_@P}N8#1~Eaqw?N17?MYo|Z75Vk{Cv7jn! zT_KkTITI^Z4&%j%B+uJC*VP4D!MVX~8`jh0?79F1i7giJqhBa_XIKhX6^wXD3WHOh zEF7;_9FDk?CyeQJh=`3<^wz)hh_KOtR&Lwqv>Wmz!vK7fR4vfX$GqRGG|^c(jEXDN z@s)155auP^oOon$>?P7Oy%3XUVxxq#gFNA{Tc*ly+Wd?%(wwf^cp1^|TL%-WK$7^H zXiO0wQO7FJ=5YPR>Zd<_@h$S)gWn^?Y_HC-O(OJWm$X+x?cq$sR|kq~k?D48(>{O~ z|9bbId5^vug9r23Kes8nAt#&g&-|(PSDf-clOUjePC56Vdk8-$*7vmf$fVAq|7NG| z{Ye&AuTye!cbA~##=n1{Mq`(Vv(f@=L{-?T~|Ik$#UyUwz1*SfqEP@2M zX@=SraXroeNUYZ34*%N324UzL!);Awnd}JH=aRtGv88lOx&rAEL07c+-B%%9plahO zxavg#Q#4u{ zyFBY}*FSM{IL1hY@KiXqh`SK^v=;I1vInaMf}ncV@((m^us6eSDA4L|)G D`sclZ literal 0 HcmV?d00001 diff --git a/doc/salome/gui/SMESH/input/adding_nodes_and_elements.doc b/doc/salome/gui/SMESH/input/adding_nodes_and_elements.doc index fc727701b..179e7885a 100644 --- a/doc/salome/gui/SMESH/input/adding_nodes_and_elements.doc +++ b/doc/salome/gui/SMESH/input/adding_nodes_and_elements.doc @@ -43,6 +43,11 @@ created: \image html add_node.png +\note You can also use variables defined in the SALOME \b NoteBook +to specify coordinates of the node: + +\image html addnode_notebook.png +
\anchor adding_edges_anchor

Adding edges

diff --git a/doc/salome/gui/SMESH/input/index.doc b/doc/salome/gui/SMESH/input/index.doc index cea4b5462..2de722d16 100644 --- a/doc/salome/gui/SMESH/input/index.doc +++ b/doc/salome/gui/SMESH/input/index.doc @@ -16,6 +16,7 @@ the VTK viewer; allowing to highlight important elements:
  • \subpage modifying_meshes_page "modifying meshes" with a vast array of dedicated operations.
  • +
  • \subpage using_notebook_mesh_page.
  • Almost all mesh module functionalities are accessible via diff --git a/doc/salome/gui/SMESH/input/using_notebook_smesh_page.doc b/doc/salome/gui/SMESH/input/using_notebook_smesh_page.doc new file mode 100644 index 000000000..2968a27be --- /dev/null +++ b/doc/salome/gui/SMESH/input/using_notebook_smesh_page.doc @@ -0,0 +1,33 @@ +/*! + +\page using_notebook_mesh_page Using SALOME NoteBook + +It is possible to use variables defined through SALOME NoteBook for +creation and modification of objects in the MESH module with the following +limitations: + +
      +
    • \ref radial_prism_algo_page "Distribution of Layers" hypothesis - + parametrical values are correctly applied, but they are not restored + after "Update study" operation. +
    • \ref a1d_meshing_hypo_page "Number of Segments" hypothesis, Distribution + with Table Density and Distribution with Analytic Density - parametrical + values are not applicable. +
    • \ref translation_page "Translation" dialog box, default mode + (translation by two points) - parametrical values are correctly applied, + but they are not restored after "Update study" operation. +
    • \ref merging_nodes_page "Merging nodes" dialog box - parametrical value + (tolerance of coincident nodes detection) is correctly applied, + but it is not restored after "Update study" operation. +
    • \ref revolution_page "Revolution" dialog box - it is impossible to + use the angle of revolution as "total angle" if it is defined as variable. +
    • \ref extrusion_along_path_page "Extrusion along a path" dialog box - it is + impossible to use "Linear variation of the angles" mode if at least one of + those angles is defined as variable. +
    • \ref pattern_mapping_page "Pattern mapping" dialog box - parametrical + values (indices of nodes) are correctly applied, but they are not restored + after "Update study" operation. +
    • \ref clipping_page "Clipping" dialog box. +
    • Colors / Size dialog box. +
    +*/ diff --git a/idl/SMESH_Hypothesis.idl b/idl/SMESH_Hypothesis.idl index 8694f49e7..56ae48b0c 100644 --- a/idl/SMESH_Hypothesis.idl +++ b/idl/SMESH_Hypothesis.idl @@ -39,8 +39,11 @@ module SMESH DIM_3D }; + typedef sequence ListOfParameters; + interface SMESH_Hypothesis : SALOME::GenericObj { + /*! * Get the Hypothesis typeName */ @@ -55,7 +58,36 @@ module SMESH * Get the internal Id */ long GetId(); + + /*! + * Set list of parameters + * \param theParameters is a string containing the notebook variables separated by ":" symbol, + * used for Hypothesis creation + */ + void SetParameters (in string theParameters); + + /*! + * Return list of notebook variables used for Hypothesis creation separated by ":" symbol + */ + string GetParameters(); + + /*! + * Return list of last notebook variables used for Hypothesis creation. + */ + ListOfParameters GetLastParameters(); + + /*! + * Set list of parameters + * \param theParameters is a string containing the last notebook variables separated by ":" symbol, + * used for Hypothesis creation + */ + void SetLastParameters(in string theParameters); + /*! + * Clear parameters list + */ + void ClearParameters(); + /*! * Verify whether hypothesis supports given entity type */ diff --git a/idl/SMESH_Mesh.idl b/idl/SMESH_Mesh.idl index 9b5b3477e..fa5180a24 100644 --- a/idl/SMESH_Mesh.idl +++ b/idl/SMESH_Mesh.idl @@ -718,6 +718,22 @@ module SMESH /*! Gets information about imported MED file */ SALOME_MED::MedFileInfo GetMEDFileInfo(); + + /*! + * Sets list of notebook variables used for Mesh operations separated by ":" symbol + * \param theParameters is a string containing the notebook variables + */ + void SetParameters (in string theParameters); + + /*! + * Returns list of notebook variables used for Mesh operations separated by ":" symbol + */ + string GetParameters(); + + /*! + * Returns list of notebook variables used for last Mesh operation + */ + string_array GetLastParameters(); }; interface SMESH_subMesh : SALOME::GenericObj, SMESH_IDSource diff --git a/idl/SMESH_MeshEditor.idl b/idl/SMESH_MeshEditor.idl index bba45665b..0a4b5b7cd 100644 --- a/idl/SMESH_MeshEditor.idl +++ b/idl/SMESH_MeshEditor.idl @@ -281,6 +281,48 @@ module SMESH in double AngleInRadians, in long NbOfSteps, in double Tolerance); + /*! + * \brief Genarate dim+1 elements by rotation of the object around axis + * \param theObject - object containing elements to ratate + * \param Axix - rotation axis + * \param AngleInRadians - rotation angle + * \param NbOfSteps - number of elements to generate from one element + */ + void RotationSweepObject1D(in SMESH_IDSource theObject, + in AxisStruct Axix, + in double AngleInRadians, + in long NbOfSteps, + in double Tolerance); + /*! + * \brief Same as previous but additionally create groups of elements + * generated from elements belonging to preexisting groups + */ + ListOfGroups RotationSweepObject1DMakeGroups(in SMESH_IDSource theObject, + in AxisStruct Axix, + in double AngleInRadians, + in long NbOfSteps, + in double Tolerance); + /*! + * \brief Genarate dim+1 elements by rotation of the object around axis + * \param theObject - object containing elements to ratate + * \param Axix - rotation axis + * \param AngleInRadians - rotation angle + * \param NbOfSteps - number of elements to generate from one element + */ + void RotationSweepObject2D(in SMESH_IDSource theObject, + in AxisStruct Axix, + in double AngleInRadians, + in long NbOfSteps, + in double Tolerance); + /*! + * \brief Same as previous but additionally create groups of elements + * generated from elements belonging to preexisting groups + */ + ListOfGroups RotationSweepObject2DMakeGroups(in SMESH_IDSource theObject, + in AxisStruct Axix, + in double AngleInRadians, + in long NbOfSteps, + in double Tolerance); /*! * \brief Genarate dim+1 elements by extrusion of elements along vector * \param IDsOfElements - elements to sweep @@ -386,6 +428,42 @@ module SMESH in PointStruct RefPoint, out Extrusion_Error Error); + Extrusion_Error ExtrusionAlongPathObject1D(in SMESH_IDSource theObject, + in SMESH_Mesh PathMesh, + in GEOM::GEOM_Object PathShape, + in long NodeStart, + in boolean HasAngles, + in double_array Angles, + in boolean HasRefPoint, + in PointStruct RefPoint); + ListOfGroups ExtrusionAlongPathObject1DMakeGroups(in SMESH_IDSource theObject, + in SMESH_Mesh PathMesh, + in GEOM::GEOM_Object PathShape, + in long NodeStart, + in boolean HasAngles, + in double_array Angles, + in boolean HasRefPoint, + in PointStruct RefPoint, + out Extrusion_Error Error); + + Extrusion_Error ExtrusionAlongPathObject2D(in SMESH_IDSource theObject, + in SMESH_Mesh PathMesh, + in GEOM::GEOM_Object PathShape, + in long NodeStart, + in boolean HasAngles, + in double_array Angles, + in boolean HasRefPoint, + in PointStruct RefPoint); + ListOfGroups ExtrusionAlongPathObject2DMakeGroups(in SMESH_IDSource theObject, + in SMESH_Mesh PathMesh, + in GEOM::GEOM_Object PathShape, + in long NodeStart, + in boolean HasAngles, + in double_array Angles, + in boolean HasRefPoint, + in PointStruct RefPoint, + out Extrusion_Error Error); + /*! * Compute rotation angles for ExtrusionAlongPath as linear variation * of given angles along path steps diff --git a/src/SMESH/SMESH_Hypothesis.cxx b/src/SMESH/SMESH_Hypothesis.cxx index 147b0c2bf..4b288a0d9 100644 --- a/src/SMESH/SMESH_Hypothesis.cxx +++ b/src/SMESH/SMESH_Hypothesis.cxx @@ -50,6 +50,7 @@ SMESH_Hypothesis::SMESH_Hypothesis(int hypId, _type = PARAM_ALGO; _shapeType = 0; // to be set by algo with TopAbs_Enum _param_algo_dim = -1; // to be set by algo parameter + _parameters = string(); } //============================================================================= @@ -149,3 +150,59 @@ void SMESH_Hypothesis::SetLibName(const char* theLibName) { _libName = string(theLibName); } + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESH_Hypothesis::SetParameters(const char *theParameters) +{ + string aNewParameters(theParameters); + if(aNewParameters.size()==0 && _parameters.size()==0) + aNewParameters = " "; + if(_parameters.size()>0) + _parameters +="|"; + _parameters +=aNewParameters; + SetLastParameters(theParameters); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESH_Hypothesis::ClearParameters() +{ + _parameters = string(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +char* SMESH_Hypothesis::GetParameters() const +{ + return (char*)_parameters.c_str(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +char* SMESH_Hypothesis::GetLastParameters() const +{ + return (char*)_lastParameters.c_str(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESH_Hypothesis::SetLastParameters(const char* theParameters) +{ + _lastParameters = string(theParameters); +} diff --git a/src/SMESH/SMESH_Hypothesis.hxx b/src/SMESH/SMESH_Hypothesis.hxx index d62f22352..55ed9dd5f 100644 --- a/src/SMESH/SMESH_Hypothesis.hxx +++ b/src/SMESH/SMESH_Hypothesis.hxx @@ -77,6 +77,13 @@ public: virtual const char* GetLibName() const; void SetLibName(const char* theLibName); + void SetParameters(const char *theParameters); + char* GetParameters() const; + + void SetLastParameters(const char* theParameters); + char* GetLastParameters() const; + void ClearParameters(); + /*! * \brief Initialize my parameter values by the mesh built on the geometry * \param theMesh - the built mesh @@ -115,6 +122,8 @@ protected: private: std::string _libName; + std::string _parameters; + std::string _lastParameters; }; #endif diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index f13ba84a5..50f44fb18 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -1270,6 +1270,16 @@ SalomeApp_Study* SMESHGUI::activeStudy() return NULL; } +//============================================================================= +/*! + * + */ +//============================================================================= +char* SMESHGUI::JoinObjectParameters(const QStringList& theParametersList) +{ + return theParametersList.join(":").toLatin1().data(); +} + //============================================================================= /*! * diff --git a/src/SMESHGUI/SMESHGUI.h b/src/SMESHGUI/SMESHGUI.h index d8cb5eb97..230bc3162 100644 --- a/src/SMESHGUI/SMESHGUI.h +++ b/src/SMESHGUI/SMESHGUI.h @@ -70,6 +70,8 @@ public : static SUIT_ResourceMgr* resourceMgr(); static SUIT_Desktop* desktop(); static SalomeApp_Study* activeStudy(); + static char* JoinObjectParameters(const QStringList& theParametersList); + bool isActiveStudyLocked(); static bool automaticUpdate(); diff --git a/src/SMESHGUI/SMESHGUI_BuildCompoundDlg.cxx b/src/SMESHGUI/SMESHGUI_BuildCompoundDlg.cxx index 0e1b3f250..2d6b7435b 100644 --- a/src/SMESHGUI/SMESHGUI_BuildCompoundDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_BuildCompoundDlg.cxx @@ -285,7 +285,13 @@ bool SMESHGUI_BuildCompoundDlg::ClickOnApply() { if (mySMESHGUI->isActiveStudyLocked()) return false; + + if (!isValid()) + return false; + if (!myMesh->_is_nil()) { + QStringList aParameters; + aParameters << (CheckBoxMerge->isChecked() ? SpinBoxTol->text() : QString(" ")); try { SUIT_OverrideCursor aWaitCursor; @@ -303,6 +309,8 @@ bool SMESHGUI_BuildCompoundDlg::ClickOnApply() CheckBoxMerge->isChecked(), SpinBoxTol->GetValue()); + aCompoundMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) ); + SMESH::SetName( SMESH::FindSObject( aCompoundMesh ), LineEditName->text() ); mySMESHGUI->updateObjBrowser(); } catch(...) { @@ -483,6 +491,30 @@ void SMESHGUI_BuildCompoundDlg::keyPressEvent( QKeyEvent* e ) //================================================================================= void SMESHGUI_BuildCompoundDlg::onSelectMerge(bool toMerge) { + TextLabelTol->setEnabled(toMerge); SpinBoxTol->setEnabled(toMerge); + if(!toMerge) + SpinBoxTol->SetValue(1e-05); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool SMESHGUI_BuildCompoundDlg::isValid() +{ + QString msg; + bool ok=true; + if(CheckBoxMerge->isChecked()) + ok = SpinBoxTol->isValid( msg, true ); + + if( !ok ) { + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); + return false; + } + return true; } diff --git a/src/SMESHGUI/SMESHGUI_BuildCompoundDlg.h b/src/SMESHGUI/SMESHGUI_BuildCompoundDlg.h index 2acfe5ea0..c1085739d 100644 --- a/src/SMESHGUI/SMESHGUI_BuildCompoundDlg.h +++ b/src/SMESHGUI/SMESHGUI_BuildCompoundDlg.h @@ -72,6 +72,8 @@ private: void hideEvent( QHideEvent* ); /* ESC key */ void keyPressEvent( QKeyEvent* ); + bool isValid(); + private: SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */ diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx b/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx index 8044fe73b..a8cffc9e3 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx @@ -487,47 +487,12 @@ bool SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply() !myMeshActor || myPathMesh->_is_nil() || myPathShape->_is_nil()) return false; - SMESH::long_array_var anElementsId = new SMESH::long_array; + if (!isValid()) + return false; - if (MeshCheck->isChecked()) { - // If "Select whole mesh, submesh or group" check box is on -> - // get all elements of the required type from the object selected + SMESH::long_array_var anElementsId = new SMESH::long_array; - // if MESH object is selected - if (!CORBA::is_nil(SMESH::SMESH_Mesh::_narrow(myIDSource))) { - // get mesh - SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(myIDSource); - // get IDs from mesh... - if (Elements1dRB->isChecked()) - // 1d elements - anElementsId = aMesh->GetElementsByType(SMESH::EDGE); - else if (Elements2dRB->isChecked()) { - anElementsId = aMesh->GetElementsByType(SMESH::FACE); - } - } - // SUBMESH is selected - if (!CORBA::is_nil(SMESH::SMESH_subMesh::_narrow(myIDSource))) { - // get submesh - SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(myIDSource); - // get IDs from submesh - if (Elements1dRB->isChecked()) - // 1d elements - anElementsId = aSubMesh->GetElementsByType(SMESH::EDGE); - else if (Elements2dRB->isChecked()) - // 2d elements - anElementsId = aSubMesh->GetElementsByType(SMESH::FACE); - } - // GROUP is selected - if (!CORBA::is_nil(SMESH::SMESH_GroupBase::_narrow(myIDSource))) { - // get smesh group - SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(myIDSource); - // get IDs from group - // 1d elements or 2d elements - if (Elements1dRB->isChecked() && aGroup->GetType() == SMESH::EDGE || - Elements2dRB->isChecked() && aGroup->GetType() == SMESH::FACE) - anElementsId = aGroup->GetListOfID(); - } - } else { + if (!MeshCheck->isChecked()) { // If "Select whole mesh, submesh or group" check box is off -> // use only elements of given type selected by user @@ -552,10 +517,10 @@ bool SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply() } anElementsId->length(j); } - } - if (anElementsId->length() <= 0) { - return false; + if (anElementsId->length() <= 0) { + return false; + } } if (StartPointLineEdit->text().trimmed().isEmpty()) { @@ -568,16 +533,17 @@ bool SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply() return false; } + QStringList aParameters; + // get angles SMESH::double_array_var anAngles = new SMESH::double_array; if (AnglesGrp->isChecked()) { - anAngles->length(AnglesList->count()); + anAngles->length(myAnglesList.count()); int j = 0; - bool bOk; - for (int i = 0; i < AnglesList->count(); i++) { - double angle = AnglesList->item(i)->text().toDouble(&bOk); - if (bOk) - anAngles[ j++ ] = angle*PI/180; + for (int i = 0; i < myAnglesList.count(); i++) { + double angle = myAnglesList[i]; + anAngles[ j++ ] = angle*PI/180; + aParameters << AnglesList->item(i)->text(); } anAngles->length(j); } @@ -590,6 +556,10 @@ bool SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply() aBasePoint.z = ZSpin->GetValue(); } + aParameters << XSpin->text(); + aParameters << YSpin->text(); + aParameters << ZSpin->text(); + try { SUIT_OverrideCursor wc; SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); @@ -597,17 +567,50 @@ bool SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply() anAngles = aMeshEditor->LinearAnglesVariation( myPathMesh, myPathShape, anAngles ); SMESH::SMESH_MeshEditor::Extrusion_Error retVal; - if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) - SMESH::ListOfGroups_var groups = - aMeshEditor->ExtrusionAlongPathMakeGroups(anElementsId, myPathMesh, - myPathShape, aNodeStart, - AnglesGrp->isChecked(), anAngles, - BasePointGrp->isChecked(), aBasePoint, retVal); - else - retVal = aMeshEditor->ExtrusionAlongPath(anElementsId, myPathMesh, - myPathShape, aNodeStart, - AnglesGrp->isChecked(), anAngles, - BasePointGrp->isChecked(), aBasePoint); + if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) { + if( MeshCheck->isChecked() ) { + if( GetConstructorId() == 0 ) + SMESH::ListOfGroups_var groups = + aMeshEditor->ExtrusionAlongPathObject1DMakeGroups(myIDSource, myPathMesh, + myPathShape, aNodeStart, + AnglesGrp->isChecked(), anAngles, + BasePointGrp->isChecked(), aBasePoint, retVal); + else + SMESH::ListOfGroups_var groups = + aMeshEditor->ExtrusionAlongPathObject2DMakeGroups(myIDSource, myPathMesh, + myPathShape, aNodeStart, + AnglesGrp->isChecked(), anAngles, + BasePointGrp->isChecked(), aBasePoint, retVal); + } + else + SMESH::ListOfGroups_var groups = + aMeshEditor->ExtrusionAlongPathMakeGroups(anElementsId, myPathMesh, + myPathShape, aNodeStart, + AnglesGrp->isChecked(), anAngles, + BasePointGrp->isChecked(), aBasePoint, retVal); + } + else { + if( MeshCheck->isChecked() ) { + if( GetConstructorId() == 0 ) + retVal = aMeshEditor->ExtrusionAlongPathObject1D(myIDSource, myPathMesh, + myPathShape, aNodeStart, + AnglesGrp->isChecked(), anAngles, + BasePointGrp->isChecked(), aBasePoint); + else + retVal = aMeshEditor->ExtrusionAlongPathObject2D(myIDSource, myPathMesh, + myPathShape, aNodeStart, + AnglesGrp->isChecked(), anAngles, + BasePointGrp->isChecked(), aBasePoint); + } + else + retVal = aMeshEditor->ExtrusionAlongPath(anElementsId, myPathMesh, + myPathShape, aNodeStart, + AnglesGrp->isChecked(), anAngles, + BasePointGrp->isChecked(), aBasePoint); + } + + if( retVal == SMESH::SMESH_MeshEditor::EXTR_OK ) + myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) ); //wc.stop(); wc.suspend(); @@ -1152,7 +1155,18 @@ int SMESHGUI_ExtrusionAlongPathDlg::GetConstructorId() //======================================================================= void SMESHGUI_ExtrusionAlongPathDlg::OnAngleAdded() { - AnglesList->addItem(QString::number(AngleSpin->GetValue())); + QString msg; + if( !AngleSpin->isValid( msg, true ) ) { + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); + return; + } + AnglesList->addItem(AngleSpin->text()); + myAnglesList.append(AngleSpin->GetValue()); + + updateLinearAngles(); } //======================================================================= @@ -1163,7 +1177,12 @@ void SMESHGUI_ExtrusionAlongPathDlg::OnAngleRemoved() { QList aList = AnglesList->selectedItems(); QListWidgetItem* anItem; - foreach(anItem, aList) delete anItem; + foreach(anItem, aList) { + myAnglesList.removeAt(AnglesList->row(anItem)); + delete anItem; + } + + updateLinearAngles(); } //================================================================================= @@ -1233,3 +1252,45 @@ void SMESHGUI_ExtrusionAlongPathDlg::setFilters() myFilterDlg->show(); } + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool SMESHGUI_ExtrusionAlongPathDlg::isValid() +{ + QString msg; + bool ok = true; + ok = XSpin->isValid( msg, true ) && ok; + ok = YSpin->isValid( msg, true ) && ok; + ok = ZSpin->isValid( msg, true ) && ok; + + if( !ok ) { + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); + return false; + } + return true; +} + +//================================================================================= +// function : updateLinearAngles +// purpose : +//================================================================================= +void SMESHGUI_ExtrusionAlongPathDlg::updateLinearAngles() +{ + bool enableLinear = true; + for( int row = 0, nbRows = AnglesList->count(); row < nbRows; row++ ) { + if( QListWidgetItem* anItem = AnglesList->item( row ) ) { + enableLinear = false; + anItem->text().toDouble(&enableLinear); + if( !enableLinear ) + break; + } + } + if( !enableLinear ) + LinearAnglesCheck->setChecked( false ); + LinearAnglesCheck->setEnabled( enableLinear ); +} diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.h b/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.h index 9ca43c0d1..4e1cbcb9c 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.h +++ b/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.h @@ -79,6 +79,10 @@ private: int GetConstructorId(); void SetEditCurrentArgument( QToolButton* ); + bool isValid(); + + void updateLinearAngles(); + SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ SMESHGUI_IdValidator* myIdValidator; LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */ @@ -95,6 +99,7 @@ private: SUIT_SelectionFilter* myElementsFilter; SUIT_SelectionFilter* myPathMeshFilter; int myType; + QList myAnglesList; // widgets QGroupBox* ConstructorsBox; diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx index a6f1a1cca..0626e4575 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx @@ -53,6 +53,8 @@ #include #include +#include + // OCCT includes #include #include @@ -67,7 +69,6 @@ #include #include #include -#include #include #include #include @@ -89,7 +90,8 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule) : QDialog( SMESH::GetDesktop( theModule ) ), mySMESHGUI( theModule ), mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), - myFilterDlg( 0 ) + myFilterDlg( 0 ), + mySelectedObject(SMESH::SMESH_IDSource::_nil()) { QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_EDGE"))); QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE"))); @@ -197,7 +199,7 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule) // Controls for nb. steps defining TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupArguments); - SpinBox_NbSteps = new QSpinBox(GroupArguments); + SpinBox_NbSteps = new SalomeApp_IntSpinBox(GroupArguments); // CheckBox for groups generation MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments); @@ -404,6 +406,9 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply() if (mySMESHGUI->isActiveStudyLocked()) return false; + if (!isValid()) + return false; + if (myNbOkElements) { gp_XYZ aNormale(SpinBox_Vx->GetValue(), @@ -419,15 +424,41 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply() long aNbSteps = (long)SpinBox_NbSteps->value(); + QStringList aParameters; + aParameters << SpinBox_Dx->text(); + aParameters << SpinBox_Dy->text(); + aParameters << SpinBox_Dz->text(); + aParameters << SpinBox_NbSteps->text(); + try { SUIT_OverrideCursor aWaitCursor; SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) - SMESH::ListOfGroups_var groups = - aMeshEditor->ExtrusionSweepMakeGroups(myElementsId.inout(), aVector, aNbSteps); - else - aMeshEditor->ExtrusionSweep(myElementsId.inout(), aVector, aNbSteps); + if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) { + if( CheckBoxMesh->isChecked() ) { + if( GetConstructorId() == 0 ) + SMESH::ListOfGroups_var groups = + aMeshEditor->ExtrusionSweepObject1DMakeGroups(mySelectedObject, aVector, aNbSteps); + else + SMESH::ListOfGroups_var groups = + aMeshEditor->ExtrusionSweepObject2DMakeGroups(mySelectedObject, aVector, aNbSteps); + } + else + SMESH::ListOfGroups_var groups = + aMeshEditor->ExtrusionSweepMakeGroups(myElementsId.inout(), aVector, aNbSteps); + } + else { + if( CheckBoxMesh->isChecked() ) { + if( GetConstructorId() == 0 ) + aMeshEditor->ExtrusionSweepObject1D(mySelectedObject, aVector, aNbSteps); + else + aMeshEditor->ExtrusionSweepObject2D(mySelectedObject, aVector, aNbSteps); + } + else + aMeshEditor->ExtrusionSweep(myElementsId.inout(), aVector, aNbSteps); + } + + myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) ); } catch (...) { } @@ -437,6 +468,7 @@ bool SMESHGUI_ExtrusionDlg::ClickOnApply() mySMESHGUI->updateObjBrowser(true); // new groups may appear Init(false); ConstructorsClicked(GetConstructorId()); + mySelectedObject = SMESH::SMESH_IDSource::_nil(); SelectionIntoArgument(); } return true; @@ -603,41 +635,21 @@ void SMESHGUI_ExtrusionDlg::SelectionIntoArgument() } if (CheckBoxMesh->isChecked()) { - SMESH::ElementType neededType = GetConstructorId() ? SMESH::FACE : SMESH::EDGE; - SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); - SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface(IO); - - if (!mesh->_is_nil()) { //MESH - // get elements from mesh - myElementsId = mesh->GetElementsByType(neededType); - aNbElements = myElementsId->length(); - } else { - SMESH::SMESH_subMesh_var aSubMesh = - SMESH::IObjectToInterface(IO); - - if (!aSubMesh->_is_nil()) { //SUBMESH - // get IDs from submesh - myElementsId = aSubMesh->GetElementsByType(neededType); - aNbElements = myElementsId->length(); - } else { - SMESH::SMESH_GroupBase_var aGroup = - SMESH::IObjectToInterface(IO); - - if (!aGroup->_is_nil() && aGroup->GetType() == neededType) { // GROUP - // get IDs from smesh group - myElementsId = aGroup->GetListOfID(); - aNbElements = myElementsId->length(); - } - } - } + if (!SMESH::IObjectToInterface(IO)->_is_nil()) + mySelectedObject = SMESH::IObjectToInterface(IO); + else + return; } else { // get indices of selcted elements TColStd_IndexedMapOfInteger aMapIndex; mySelector->GetIndex(IO,aMapIndex); aNbElements = aMapIndex.Extent(); + if (aNbElements < 1) + return; + myElementsId = new SMESH::long_array; myElementsId->length( aNbElements ); aString = ""; @@ -645,9 +657,6 @@ void SMESHGUI_ExtrusionDlg::SelectionIntoArgument() aString += QString(" %1").arg( myElementsId[ i ] = aMapIndex( i+1 ) ); } - if (aNbElements < 1) - return; - myNbOkElements = true; myBusy = true; @@ -856,3 +865,26 @@ void SMESHGUI_ExtrusionDlg::setFilters() myFilterDlg->show(); } + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool SMESHGUI_ExtrusionDlg::isValid() +{ + QString msg; + bool ok = true; + ok = SpinBox_Dx->isValid( msg, true ) && ok; + ok = SpinBox_Dy->isValid( msg, true ) && ok; + ok = SpinBox_Dz->isValid( msg, true ) && ok; + ok = SpinBox_NbSteps->isValid( msg, true ) && ok; + + if( !ok ) { + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); + return false; + } + return true; +} diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h index ee3ec9cb5..99468eaa7 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h +++ b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h @@ -45,7 +45,6 @@ class QGroupBox; class QLabel; class QLineEdit; class QCheckBox; -class QSpinBox; class QPushButton; class SMESHGUI; @@ -56,6 +55,7 @@ class SMESHGUI_FilterDlg; class SVTK_Selector; class LightApp_SelectionMgr; class SUIT_SelectionFilter; +class SalomeApp_IntSpinBox; //================================================================================= // class : SMESHGUI_ExtrusionDlg @@ -75,6 +75,8 @@ private: void keyPressEvent( QKeyEvent* ); int GetConstructorId(); + bool isValid(); + SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ SMESHGUI_IdValidator* myIdValidator; LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */ @@ -82,6 +84,8 @@ private: int myNbOkElements; /* to check when elements are defined */ SVTK_Selector* mySelector; + SMESH::SMESH_IDSource_var mySelectedObject; + bool myBusy; SMESH::SMESH_Mesh_var myMesh; SMESH::long_array_var myElementsId; @@ -116,7 +120,7 @@ private: QLabel* TextLabelVz; SMESHGUI_SpinBox* SpinBox_Vz; QLabel* TextLabelNbSteps; - QSpinBox* SpinBox_NbSteps; + SalomeApp_IntSpinBox* SpinBox_NbSteps; QCheckBox* MakeGroupsCheck; QGroupBox* GroupButtons; diff --git a/src/SMESHGUI/SMESHGUI_Hypotheses.cxx b/src/SMESHGUI/SMESHGUI_Hypotheses.cxx index 4ebd58629..8ca61f49f 100644 --- a/src/SMESHGUI/SMESHGUI_Hypotheses.cxx +++ b/src/SMESHGUI/SMESHGUI_Hypotheses.cxx @@ -36,11 +36,11 @@ #include // SALOME GUI includes -#include #include #include #include #include +#include // Qt includes #include @@ -211,7 +211,7 @@ QFrame* SMESHGUI_GenericHypothesisCreator::buildStdFrame() { case QVariant::Int: { - QtxIntSpinBox* sb = new QtxIntSpinBox( GroupC1 ); + SalomeApp_IntSpinBox* sb = new SalomeApp_IntSpinBox( GroupC1 ); sb->setObjectName( (*anIt).myName ); attuneStdWidget( sb, i ); sb->setValue( (*anIt).myValue.toInt() ); @@ -221,7 +221,7 @@ QFrame* SMESHGUI_GenericHypothesisCreator::buildStdFrame() break; case QVariant::Double: { - QtxDoubleSpinBox* sb = new SMESHGUI_SpinBox( GroupC1 ); + SalomeApp_DoubleSpinBox* sb = new SMESHGUI_SpinBox( GroupC1 ); sb->setObjectName( (*anIt).myName ); attuneStdWidget( sb, i ); sb->setValue( (*anIt).myValue.toDouble() ); @@ -231,12 +231,34 @@ QFrame* SMESHGUI_GenericHypothesisCreator::buildStdFrame() break; case QVariant::String: { - QLineEdit* le = new QLineEdit( GroupC1 ); - le->setObjectName( (*anIt).myName ); - attuneStdWidget( le, i ); - le->setText( (*anIt).myValue.toString() ); - connect( le, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) ); - w = le; + if((*anIt).isVariable) { + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + QString aVar = (*anIt).myValue.toString(); + if(aStudy->IsInteger(aVar.toLatin1().constData())){ + SalomeApp_IntSpinBox* sb = new SalomeApp_IntSpinBox( GroupC1 ); + sb->setObjectName( (*anIt).myName ); + attuneStdWidget( sb, i ); + sb->setText( aVar ); + connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) ); + w = sb; + } + else if(aStudy->IsReal(aVar.toLatin1().constData())){ + SalomeApp_DoubleSpinBox* sb = new SalomeApp_DoubleSpinBox( GroupC1 ); + sb->setObjectName( (*anIt).myName ); + attuneStdWidget( sb, i ); + sb->setText( aVar ); + connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) ); + w = sb; + } + } + else { + QLineEdit* le = new QLineEdit( GroupC1 ); + le->setObjectName( (*anIt).myName ); + attuneStdWidget( le, i ); + le->setText( (*anIt).myValue.toString() ); + connect( le, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) ); + w = le; + } } break; } @@ -279,16 +301,16 @@ bool SMESHGUI_GenericHypothesisCreator::getStdParamFromDlg( ListOfStdParams& par for( ; anIt!=aLast; anIt++ ) { item.myName = (*anIt)->objectName(); - if( (*anIt)->inherits( "QtxIntSpinBox" ) ) + if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) ) { - QtxIntSpinBox* sb = ( QtxIntSpinBox* )( *anIt ); + SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt ); item.myValue = sb->value(); params.append( item ); } - else if( (*anIt)->inherits( "QtxDoubleSpinBox" ) ) + else if( (*anIt)->inherits( "SalomeApp_DoubleSpinBox" ) ) { - QtxDoubleSpinBox* sb = ( QtxDoubleSpinBox* )( *anIt ); + SalomeApp_DoubleSpinBox* sb = ( SalomeApp_DoubleSpinBox* )( *anIt ); item.myValue = sb->value(); params.append( item ); } @@ -311,6 +333,24 @@ bool SMESHGUI_GenericHypothesisCreator::getStdParamFromDlg( ListOfStdParams& par return res; } + +QStringList SMESHGUI_GenericHypothesisCreator::getVariablesFromDlg() const +{ + QStringList aResult; + ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end(); + for( ; anIt!=aLast; anIt++ ) { + if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) ) { + SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt ); + aResult.append(sb->text()); + } + else if( (*anIt)->inherits( "QtxDoubleSpinBox" ) ) { + QtxDoubleSpinBox* sb = ( QtxDoubleSpinBox* )( *anIt ); + aResult.append(sb->text()); + } + } + return aResult; +} + QString SMESHGUI_GenericHypothesisCreator::stdParamValues( const ListOfStdParams& params) { QString valueStr = ""; @@ -428,6 +468,26 @@ bool SMESHGUI_GenericHypothesisCreator::getParamFromCustomWidget( StdParam&, QWi return false; } +bool SMESHGUI_GenericHypothesisCreator::checkParams( QString& msg ) const +{ + bool ok = true; + ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end(); + for( ; anIt!=aLast; anIt++ ) + { + if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) ) + { + SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt ); + ok = sb->isValid( msg, true ) && ok; + } + else if( (*anIt)->inherits( "SalomeApp_DoubleSpinBox" ) ) + { + SalomeApp_DoubleSpinBox* sb = ( SalomeApp_DoubleSpinBox* )( *anIt ); + ok = sb->isValid( msg, true ) && ok; + } + } + return ok; +} + void SMESHGUI_GenericHypothesisCreator::onReject() { } @@ -520,8 +580,15 @@ void SMESHGUI_HypothesisDlg::setCustomFrame( QFrame* f ) void SMESHGUI_HypothesisDlg::accept() { - if ( myCreator && !myCreator->checkParams() ) + QString msg; + if ( myCreator && !myCreator->checkParams( msg ) ) + { + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); return; + } QtxDialog::accept(); } diff --git a/src/SMESHGUI/SMESHGUI_Hypotheses.h b/src/SMESHGUI/SMESHGUI_Hypotheses.h index 1a1978a41..6cf6c524d 100644 --- a/src/SMESHGUI/SMESHGUI_Hypotheses.h +++ b/src/SMESHGUI/SMESHGUI_Hypotheses.h @@ -57,7 +57,7 @@ public: const QString&, QWidget* ); void setInitParamsHypothesis(SMESH::SMESH_Hypothesis_ptr); - virtual bool checkParams() const = 0; + virtual bool checkParams( QString& ) const; virtual void onReject(); virtual QString helpPage() const; @@ -66,12 +66,15 @@ public: bool isCreation() const; protected: - typedef struct + struct StdParam { QString myName; QVariant myValue; - - } StdParam; + bool isVariable; + StdParam(){ + isVariable = false; + } + }; typedef QList ListOfStdParams; typedef QList ListOfWidgets; @@ -89,6 +92,7 @@ protected: virtual QString storeParams() const = 0; virtual bool stdParams( ListOfStdParams& ) const; bool getStdParamFromDlg( ListOfStdParams& ) const; + virtual QStringList getVariablesFromDlg() const; static QString stdParamValues( const ListOfStdParams& ); virtual void attuneStdWidget( QWidget*, const int ) const; virtual QWidget* getCustomWidget( const StdParam&, diff --git a/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.cxx b/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.cxx index dbbfcef25..ac654fdd6 100644 --- a/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.cxx @@ -372,9 +372,11 @@ bool SMESHGUI_MakeNodeAtPointOp::onApply() return false; } - if ( !isValid() ) { // node id is invalid - SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ), - tr("INVALID_ID") ); + QString msg; + if ( !isValid( msg ) ) { // node id is invalid + if( !msg.isEmpty() ) + SUIT_MessageBox::warning( dlg(), tr( "SMESH_WRN_WARNING" ), + tr("INVALID_ID") ); dlg()->show(); return false; } @@ -408,6 +410,12 @@ bool SMESHGUI_MakeNodeAtPointOp::onApply() } if (aResult) { + QStringList aParameters; + aParameters << myDlg->myX->text(); + aParameters << myDlg->myY->text(); + aParameters << myDlg->myZ->text(); + aMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) ); + myDlg->myId->setText(""); SALOME_ListIO aList; @@ -432,10 +440,9 @@ bool SMESHGUI_MakeNodeAtPointOp::onApply() */ //================================================================================ -bool SMESHGUI_MakeNodeAtPointOp::isValid() +bool SMESHGUI_MakeNodeAtPointOp::isValid( QString& msg ) { bool ok = true; - if ( myMeshActor && myDlg->myMoveRBtn->isDown() && !myDlg->myAutoSearchChkBox->isChecked() ) @@ -445,7 +452,14 @@ bool SMESHGUI_MakeNodeAtPointOp::isValid() if ( id > 0 ) if (SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh()) ok = aMesh->FindNode( id ); + if( !ok ) + msg += tr("INVALID_ID") + "\n"; } + + ok = myDlg->myX->isValid( msg, !myNoPreview ) && ok; + ok = myDlg->myY->isValid( msg, !myNoPreview ) && ok; + ok = myDlg->myZ->isValid( msg, !myNoPreview ) && ok; + return ok; } @@ -538,7 +552,8 @@ void SMESHGUI_MakeNodeAtPointOp::redisplayPreview() const bool preview = myDlg->myPreviewChkBox->isChecked(); if ( autoSearch ) myDlg->myId->setText(""); - if ( preview && ( autoSearch || isValid() )) + QString msg; + if ( preview && ( autoSearch || isValid( msg ) )) { try { SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(myMeshActor->getIO()); diff --git a/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.h b/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.h index b2c977fc5..6df8ba722 100644 --- a/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.h +++ b/src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.h @@ -60,7 +60,7 @@ protected: virtual void activateSelection(); - bool isValid(); + bool isValid( QString& ); protected slots: virtual bool onApply(); diff --git a/src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx b/src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx index 91e7bc202..8456928f7 100755 --- a/src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx @@ -51,6 +51,7 @@ #include #include #include +#include #include @@ -76,7 +77,6 @@ #include #include #include -#include #include #include #include @@ -246,9 +246,9 @@ QWidget* SMESHGUI_MeshPatternDlg::createMainFrame (QWidget* theParent) mySelEdit[ Ids ] = new QLineEdit( myRefineGrp ); QLabel* aNodeLbl = new QLabel( tr( "NODE_1" ), myRefineGrp ); - myNode1 = new QSpinBox( myRefineGrp ); + myNode1 = new SalomeApp_IntSpinBox( myRefineGrp ); myNode2Lbl = new QLabel( tr( "NODE_2" ), myRefineGrp ); - myNode2 = new QSpinBox( myRefineGrp ); + myNode2 = new SalomeApp_IntSpinBox( myRefineGrp ); myRefineGrpLayout->addWidget( mySelLbl[ Ids ], 0, 0 ); myRefineGrpLayout->addWidget( mySelBtn[ Ids ], 0, 1 ); @@ -411,6 +411,24 @@ void SMESHGUI_MeshPatternDlg::Init() //======================================================================= bool SMESHGUI_MeshPatternDlg::isValid (const bool theMess) { + if (isRefine()) + { + QString msg; + bool ok = true; + ok = myNode1->isValid( msg, theMess ) && ok; + if (myType == Type_3d) + ok = myNode2->isValid( msg, theMess ) && ok; + if( !ok ) { + if( theMess ) { + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); + } + return false; + } + } + QList ids; if ((isRefine() && (myMesh->_is_nil() || !getIds(ids) || getNode(false) < 0 || @@ -460,6 +478,12 @@ bool SMESHGUI_MeshPatternDlg::onApply() ? myPattern->ApplyToMeshFaces (myMesh, varIds, getNode(false), myReverseChk->isChecked()) : myPattern->ApplyToHexahedrons(myMesh, varIds, getNode(false), getNode(true)); + QStringList aParameters; + aParameters << myNode1->text(); + if(myType == Type_3d ) + aParameters << myNode2->text(); + myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) ); + } else { // Applying a pattern to geometrical object if (myType == Type_2d) myPattern->ApplyToFace(myGeomObj[Object], myGeomObj[Vertex1], myReverseChk->isChecked()); @@ -1375,8 +1399,8 @@ void SMESHGUI_MeshPatternDlg::onTextChanged (const QString& theNewText) void SMESHGUI_MeshPatternDlg::onNodeChanged (int value) { if (myType == Type_3d) { - QSpinBox* first = (QSpinBox*)sender(); - QSpinBox* second = first == myNode1 ? myNode2 : myNode1; + SalomeApp_IntSpinBox* first = (SalomeApp_IntSpinBox*)sender(); + SalomeApp_IntSpinBox* second = first == myNode1 ? myNode2 : myNode1; int secondVal = second->value(); if (secondVal == value) { secondVal = value == second->maximum() ? second->minimum() : value + 1; diff --git a/src/SMESHGUI/SMESHGUI_MeshPatternDlg.h b/src/SMESHGUI/SMESHGUI_MeshPatternDlg.h index 6fba2b11f..e3e2d6870 100755 --- a/src/SMESHGUI/SMESHGUI_MeshPatternDlg.h +++ b/src/SMESHGUI/SMESHGUI_MeshPatternDlg.h @@ -44,7 +44,7 @@ class QRadioButton; class QCheckBox; class QButtonGroup; class QLabel; -class QSpinBox; +class SalomeApp_IntSpinBox; class vtkUnstructuredGrid; class SALOME_Actor; class SVTK_Selector; @@ -130,8 +130,8 @@ private: QCheckBox* myRefine; QFrame* myRefineGrp; - QSpinBox* myNode1; - QSpinBox* myNode2; + SalomeApp_IntSpinBox* myNode1; + SalomeApp_IntSpinBox* myNode2; QLabel* myNode2Lbl; QFrame* myGeomGrp; diff --git a/src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx b/src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx index d659ca464..199575293 100644 --- a/src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx @@ -281,6 +281,22 @@ bool SMESHGUI_MoveNodesDlg::isValid (const bool theMess) tr("NODE_ID_IS_NOT_DEFINED")); return false; } + + QString msg; + bool ok = true; + ok = myX->isValid( msg, theMess ) && ok; + ok = myY->isValid( msg, theMess ) && ok; + ok = myZ->isValid( msg, theMess ) && ok; + if( !ok ) { + if( theMess ) { + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); + } + return false; + } + return true; } @@ -325,6 +341,12 @@ bool SMESHGUI_MoveNodesDlg::onApply() bool aResult = false; try { aResult = aMeshEditor->MoveNode(anId, myX->GetValue(), myY->GetValue(), myZ->GetValue()); + + QStringList aParameters; + aParameters << myX->text(); + aParameters << myY->text(); + aParameters << myZ->text(); + aMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) ); } catch (...) { } diff --git a/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx b/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx index 3c57f8f70..526c3f3e3 100755 --- a/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx @@ -298,7 +298,7 @@ QWidget* SMESHGUI_MultiEditDlg::createButtonFrame (QWidget* theParent) // name : SMESHGUI_MultiEditDlg::isValid // Purpose : Verify validity of input data //======================================================================= -bool SMESHGUI_MultiEditDlg::isValid (const bool /*theMess*/) const +bool SMESHGUI_MultiEditDlg::isValid (const bool /*theMess*/) { return (!myMesh->_is_nil() && (myListBox->count() > 0 || (myToAllChk->isChecked() && myActor))); @@ -1168,12 +1168,39 @@ SMESHGUI_UnionOfTrianglesDlg::~SMESHGUI_UnionOfTrianglesDlg() { } +bool SMESHGUI_UnionOfTrianglesDlg::isValid (const bool theMess) +{ + bool ok = SMESHGUI_MultiEditDlg::isValid( theMess ); + if( !ok ) + return false; + + QString msg; + ok = myMaxAngleSpin->isValid( msg, theMess ); + if( !ok ) { + if( theMess ) { + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); + } + return false; + } + + return ok; +} + bool SMESHGUI_UnionOfTrianglesDlg::process (SMESH::SMESH_MeshEditor_ptr theEditor, const SMESH::long_array& theIds) { SMESH::NumericalFunctor_var aCriterion = getNumericalFunctor(); double aMaxAngle = myMaxAngleSpin->GetValue() * PI / 180.0; - return theEditor->TriToQuad(theIds, aCriterion, aMaxAngle); + bool ok = theEditor->TriToQuad(theIds, aCriterion, aMaxAngle); + if( ok ) { + QStringList aParameters; + aParameters << myMaxAngleSpin->text(); + myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) ); + } + return ok; } diff --git a/src/SMESHGUI/SMESHGUI_MultiEditDlg.h b/src/SMESHGUI/SMESHGUI_MultiEditDlg.h index ade9cdee8..0ada531f9 100755 --- a/src/SMESHGUI/SMESHGUI_MultiEditDlg.h +++ b/src/SMESHGUI/SMESHGUI_MultiEditDlg.h @@ -107,7 +107,7 @@ protected: void keyPressEvent( QKeyEvent* ); QWidget* createButtonFrame( QWidget* ); QWidget* createMainFrame( QWidget*, const bool ); - bool isValid( const bool ) const; + virtual bool isValid( const bool ); SMESH::long_array_var getIds(); void updateButtons(); void setSelectionMode(); @@ -190,6 +190,7 @@ public: virtual ~SMESHGUI_UnionOfTrianglesDlg(); protected: + virtual bool isValid( const bool ); virtual bool process( SMESH::SMESH_MeshEditor_ptr, const SMESH::long_array& ); private: diff --git a/src/SMESHGUI/SMESHGUI_NodesDlg.cxx b/src/SMESHGUI/SMESHGUI_NodesDlg.cxx index 4718dce50..38869cedd 100644 --- a/src/SMESHGUI/SMESHGUI_NodesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_NodesDlg.cxx @@ -87,13 +87,14 @@ namespace SMESH { - void AddNode( SMESH::SMESH_Mesh_ptr theMesh, float x, float y, float z ) + void AddNode( SMESH::SMESH_Mesh_ptr theMesh, float x, float y, float z, const QStringList& theParameters ) { SUIT_OverrideCursor wc; try { _PTR(SObject) aSobj = SMESH::FindSObject( theMesh ); SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor(); aMeshEditor->AddNode( x, y, z ); + theMesh->SetParameters( SMESHGUI::JoinObjectParameters(theParameters) ); _PTR(Study) aStudy = GetActiveStudyDocument(); CORBA::Long anId = aStudy->StudyId(); if (TVisualObjPtr aVisualObj = SMESH::GetVisualObj( anId, aSobj->GetID().c_str() ) ) { @@ -400,12 +401,21 @@ bool SMESHGUI_NodesDlg::ClickOnApply() return false; } + if( !isValid() ) + return false; + /* Recup args and call method */ double x = SpinBox_X->GetValue(); double y = SpinBox_Y->GetValue(); double z = SpinBox_Z->GetValue(); + + QStringList aParameters; + aParameters << SpinBox_X->text(); + aParameters << SpinBox_Y->text(); + aParameters << SpinBox_Z->text(); + mySimulation->SetVisibility( false ); - SMESH::AddNode( myMesh, x, y, z ); + SMESH::AddNode( myMesh, x, y, z, aParameters ); SMESH::SetPointRepresentation( true ); // select myMesh @@ -591,3 +601,25 @@ void SMESHGUI_NodesDlg::keyPressEvent( QKeyEvent* e ) ClickOnHelp(); } } + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool SMESHGUI_NodesDlg::isValid() +{ + QString msg; + bool ok = true; + ok = SpinBox_X->isValid( msg, true ) && ok; + ok = SpinBox_Y->isValid( msg, true ) && ok; + ok = SpinBox_Z->isValid( msg, true ) && ok; + + if( !ok ) { + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); + return false; + } + return true; +} diff --git a/src/SMESHGUI/SMESHGUI_NodesDlg.h b/src/SMESHGUI/SMESHGUI_NodesDlg.h index 747f5166a..8fc28eacc 100644 --- a/src/SMESHGUI/SMESHGUI_NodesDlg.h +++ b/src/SMESHGUI/SMESHGUI_NodesDlg.h @@ -77,6 +77,8 @@ private: void hideEvent ( QHideEvent* ); void keyPressEvent( QKeyEvent* ); + bool isValid(); + QGroupBox* GroupConstructors; QRadioButton* Constructor1; QGroupBox* GroupCoordinates; diff --git a/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx b/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx index 15119eca4..355e01ec3 100644 --- a/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx @@ -50,6 +50,7 @@ #include #include #include +#include #include #include @@ -71,7 +72,6 @@ #include #include #include -#include #include #include @@ -92,7 +92,8 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule ) mySMESHGUI( theModule ), mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), myVectorDefinition(NONE_SELECT), - myFilterDlg( 0 ) + myFilterDlg( 0 ), + mySelectedObject(SMESH::SMESH_IDSource::_nil()) { mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI )); @@ -214,7 +215,7 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule ) SpinBox_Angle = new SMESHGUI_SpinBox(GroupAngleBox); TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupAngleBox); - SpinBox_NbSteps = new QSpinBox(GroupAngleBox); + SpinBox_NbSteps = new SalomeApp_IntSpinBox(GroupAngleBox); GroupAngleLayout->addWidget(RadioButton3, 0, 0); GroupAngleLayout->addWidget(RadioButton4, 0, 1); @@ -350,6 +351,8 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule ) connect(SpinBox_Tolerance, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation())); connect(CheckBoxPreview, SIGNAL(toggled(bool)), this, SLOT(onDisplaySimulation(bool))); + connect(SpinBox_Angle, SIGNAL(textChanged(const QString&)), this, SLOT(onAngleTextChange(const QString&))); + ConstructorsClicked(0); SelectionIntoArgument(); } @@ -462,10 +465,13 @@ void SMESHGUI_RevolutionDlg::ConstructorsClicked (int constructorId) // function : ClickOnApply() // purpose : //================================================================================= -void SMESHGUI_RevolutionDlg::ClickOnApply() +bool SMESHGUI_RevolutionDlg::ClickOnApply() { if (mySMESHGUI->isActiveStudyLocked()) - return; + return false; + + if (!isValid()) + return false; if (myNbOkElements && IsAxisOk()) { QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts); @@ -492,16 +498,49 @@ void SMESHGUI_RevolutionDlg::ClickOnApply() if ( GroupAngle->checkedId() == 1 ) anAngle = anAngle/aNbSteps; + QStringList aParameters; + aParameters << SpinBox_X->text(); + aParameters << SpinBox_Y->text(); + aParameters << SpinBox_Z->text(); + aParameters << SpinBox_DX->text(); + aParameters << SpinBox_DY->text(); + aParameters << SpinBox_DZ->text(); + aParameters << SpinBox_Angle->text(); + aParameters << SpinBox_NbSteps->text(); + aParameters << SpinBox_Tolerance->text(); + try { SUIT_OverrideCursor aWaitCursor; SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) - SMESH::ListOfGroups_var groups = - aMeshEditor->RotationSweepMakeGroups(anElementsId.inout(), anAxis, - anAngle, aNbSteps, aTolerance); - else - aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance); + if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) { + if( CheckBoxMesh->isChecked() ) { + if( GetConstructorId() == 0 ) + SMESH::ListOfGroups_var groups = + aMeshEditor->RotationSweepObject1DMakeGroups(mySelectedObject, anAxis, + anAngle, aNbSteps, aTolerance); + else + SMESH::ListOfGroups_var groups = + aMeshEditor->RotationSweepObject2DMakeGroups(mySelectedObject, anAxis, + anAngle, aNbSteps, aTolerance); + } + else + SMESH::ListOfGroups_var groups = + aMeshEditor->RotationSweepMakeGroups(anElementsId.inout(), anAxis, + anAngle, aNbSteps, aTolerance); + } + else { + if( CheckBoxMesh->isChecked() ) { + if( GetConstructorId() == 0 ) + aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance); + else + aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis, anAngle, aNbSteps, aTolerance); + } + else + aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance); + } + + myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) ); } catch (...) { } @@ -510,8 +549,11 @@ void SMESHGUI_RevolutionDlg::ClickOnApply() mySMESHGUI->updateObjBrowser(true); // new groups may appear Init(false); ConstructorsClicked(GetConstructorId()); + mySelectedObject = SMESH::SMESH_IDSource::_nil(); SelectionIntoArgument(); } + + return true; } //================================================================================= @@ -520,8 +562,8 @@ void SMESHGUI_RevolutionDlg::ClickOnApply() //================================================================================= void SMESHGUI_RevolutionDlg::ClickOnOk() { - ClickOnApply(); - ClickOnCancel(); + if( ClickOnApply() ) + ClickOnCancel(); } //================================================================================= @@ -567,6 +609,19 @@ void SMESHGUI_RevolutionDlg::ClickOnHelp() } } +//======================================================================= +// function : onAngleTextChange() +// purpose : +//======================================================================= +void SMESHGUI_RevolutionDlg::onAngleTextChange (const QString& theNewText) +{ + bool isNumber; + SpinBox_Angle->text().toDouble( &isNumber ); + if( !isNumber ) + RadioButton3->setChecked( true ); + RadioButton4->setEnabled( isNumber ); +} + //======================================================================= // function : onTextChange() // purpose : @@ -677,77 +732,18 @@ void SMESHGUI_RevolutionDlg::SelectionIntoArgument() } if (CheckBoxMesh->isChecked()) { - int aConstructorId = GetConstructorId(); - SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); - if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //MESH - // get IDs from mesh - SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); - if (!aSMDSMesh) - return; - - if (aConstructorId == 0) { - SMDS_EdgeIteratorPtr anIter = aSMDSMesh->edgesIterator(); - - while (anIter->more()) { - const SMDS_MeshEdge * edge = anIter->next(); - if (edge) { - myElementsId += QString(" %1").arg(edge->GetID()); - aNbUnits++; - } - } - } else if (aConstructorId == 1) { - SMDS_FaceIteratorPtr anIter = aSMDSMesh->facesIterator(); - while (anIter->more()) { - const SMDS_MeshFace * face = anIter->next(); - if (face) { - myElementsId += QString(" %1").arg(face->GetID()); - aNbUnits++; - } - } - } - } else if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //SUBMESH - // get submesh - SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(IO); - - // get IDs from submesh - SMESH::long_array_var anElementsIds = new SMESH::long_array; - if (aConstructorId == 0) - anElementsIds = aSubMesh->GetElementsByType(SMESH::EDGE); - else if (aConstructorId == 1) - anElementsIds = aSubMesh->GetElementsByType(SMESH::FACE); - - for (int i = 0; i < anElementsIds->length(); i++) - myElementsId += QString(" %1").arg(anElementsIds[i]); - aNbUnits = anElementsIds->length(); - } else { // GROUP - // get smesh group - SMESH::SMESH_GroupBase_var aGroup = - SMESH::IObjectToInterface(IO); - if (aGroup->_is_nil()) - return; - - if ((aConstructorId == 0 && aGroup->GetType()!= SMESH::EDGE) || - (aConstructorId == 1 && aGroup->GetType()!= SMESH::FACE)) - return; - - // get IDs from smesh group - SMESH::long_array_var anElementsIds = new SMESH::long_array; - anElementsIds = aGroup->GetListOfID(); - for (int i = 0; i < anElementsIds->length(); i++) { - myElementsId += QString(" %1").arg(anElementsIds[i]); - } - aNbUnits = anElementsIds->length(); - } + if (!SMESH::IObjectToInterface(IO)->_is_nil()) + mySelectedObject = SMESH::IObjectToInterface(IO); + else + return; } else { aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString); myElementsId = aString; + if (aNbUnits < 1) + return; } - - if (aNbUnits < 1) - return; - myNbOkElements = true; } else { @@ -1073,11 +1069,20 @@ void SMESHGUI_RevolutionDlg::onDisplaySimulation(bool toDisplayPreview) try { SUIT_OverrideCursor aWaitCursor; SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer(); - aMeshEditor->RotationSweep(anElementsId.inout(), - anAxis, - anAngle, - aNbSteps, - aTolerance); + if( CheckBoxMesh->isChecked() ) { + if( GetConstructorId() == 0 ) + aMeshEditor->RotationSweepObject1D(mySelectedObject, anAxis, + anAngle, aNbSteps, aTolerance); + else + aMeshEditor->RotationSweepObject2D(mySelectedObject, anAxis, + anAngle, aNbSteps, aTolerance); + } + else + aMeshEditor->RotationSweep(anElementsId.inout(), + anAxis, + anAngle, + aNbSteps, + aTolerance); SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData(); mySimulation->SetData(aMeshPreviewStruct._retn()); } catch (...) {} @@ -1154,3 +1159,31 @@ void SMESHGUI_RevolutionDlg::setFilters() myFilterDlg->show(); } + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool SMESHGUI_RevolutionDlg::isValid() +{ + QString msg; + bool ok = true; + ok = SpinBox_X->isValid( msg, true ) && ok; + ok = SpinBox_Y->isValid( msg, true ) && ok; + ok = SpinBox_Z->isValid( msg, true ) && ok; + ok = SpinBox_DX->isValid( msg, true ) && ok; + ok = SpinBox_DY->isValid( msg, true ) && ok; + ok = SpinBox_DZ->isValid( msg, true ) && ok; + ok = SpinBox_Angle->isValid( msg, true ) && ok; + ok = SpinBox_NbSteps->isValid( msg, true ) && ok; + ok = SpinBox_Tolerance->isValid( msg, true ) && ok; + + if( !ok ) { + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); + return false; + } + return true; +} diff --git a/src/SMESHGUI/SMESHGUI_RevolutionDlg.h b/src/SMESHGUI/SMESHGUI_RevolutionDlg.h index 3502596f1..a4c3fc111 100644 --- a/src/SMESHGUI/SMESHGUI_RevolutionDlg.h +++ b/src/SMESHGUI/SMESHGUI_RevolutionDlg.h @@ -44,7 +44,7 @@ class QLineEdit; class QPushButton; class QRadioButton; class QCheckBox; -class QSpinBox; +class SalomeApp_IntSpinBox; class SMESHGUI_IdValidator; class SMESHGUI_SpinBox; class SMESHGUI; @@ -81,6 +81,8 @@ private: int GetConstructorId(); bool IsAxisOk(); + bool isValid(); + SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ SMESHGUI_IdValidator* myIdValidator; LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */ @@ -89,6 +91,8 @@ private: QWidget* myEditCurrentArgument; /* Current argument */ SVTK_Selector* mySelector; + SMESH::SMESH_IDSource_var mySelectedObject; + bool myBusy; SMESH::SMESH_Mesh_var myMesh; SMESH_Actor* myActor; @@ -138,7 +142,7 @@ private: QLabel* TextLabelAngle; SMESHGUI_SpinBox* SpinBox_Angle; QLabel* TextLabelNbSteps; - QSpinBox* SpinBox_NbSteps; + SalomeApp_IntSpinBox* SpinBox_NbSteps; QLabel* TextLabelTolerance; SMESHGUI_SpinBox* SpinBox_Tolerance; @@ -155,13 +159,14 @@ private slots: void ConstructorsClicked( int ); void ClickOnOk(); void ClickOnCancel(); - void ClickOnApply(); + bool ClickOnApply(); void ClickOnHelp(); void SetEditCurrentArgument(); void SelectionIntoArgument(); void DeactivateActiveDialog(); void ActivateThisDialog(); void onTextChange( const QString& ); + void onAngleTextChange( const QString& ); void onSelectMesh( bool ); void onVectorChanged(); void toDisplaySimulation(); diff --git a/src/SMESHGUI/SMESHGUI_RotationDlg.cxx b/src/SMESHGUI/SMESHGUI_RotationDlg.cxx index a2f5460f5..1e7010974 100644 --- a/src/SMESHGUI/SMESHGUI_RotationDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RotationDlg.cxx @@ -91,7 +91,8 @@ SMESHGUI_RotationDlg::SMESHGUI_RotationDlg( SMESHGUI* theModule ) : QDialog( SMESH::GetDesktop( theModule ) ), mySMESHGUI( theModule ), mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), - myFilterDlg(0) + myFilterDlg(0), + mySelectedObject(SMESH::SMESH_IDSource::_nil()) { QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_MESH_ROTATION"))); QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); @@ -365,10 +366,13 @@ void SMESHGUI_RotationDlg::Init (bool ResetControls) // function : ClickOnApply() // purpose : //================================================================================= -void SMESHGUI_RotationDlg::ClickOnApply() +bool SMESHGUI_RotationDlg::ClickOnApply() { if (mySMESHGUI->isActiveStudyLocked()) - return; + return false; + + if( !isValid() ) + return false; if (myNbOkElements && IsAxisOk()) { QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts); @@ -389,6 +393,16 @@ void SMESHGUI_RotationDlg::ClickOnApply() anAxis.vz = SpinBox_DZ->GetValue(); double anAngle = (SpinBox_Angle->GetValue())*PI/180; + + QStringList aParameters; + aParameters << SpinBox_X->text(); + aParameters << SpinBox_Y->text(); + aParameters << SpinBox_Z->text(); + aParameters << SpinBox_DX->text(); + aParameters << SpinBox_DY->text(); + aParameters << SpinBox_DZ->text(); + aParameters << SpinBox_Angle->text(); + int actionButton = ActionGroup->checkedId(); bool makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ); try { @@ -396,19 +410,40 @@ void SMESHGUI_RotationDlg::ClickOnApply() SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); switch ( actionButton ) { case MOVE_ELEMS_BUTTON: - aMeshEditor->Rotate(anElementsId, anAxis, anAngle, false); + if(CheckBoxMesh->isChecked()) + aMeshEditor->RotateObject(mySelectedObject, anAxis, anAngle, false); + else + aMeshEditor->Rotate(anElementsId, anAxis, anAngle, false); + if( !myMesh->_is_nil()) + myMesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters)); break; case COPY_ELEMS_BUTTON: - if ( makeGroups ) - SMESH::ListOfGroups_var groups = - aMeshEditor->RotateMakeGroups(anElementsId, anAxis, anAngle); - else - aMeshEditor->Rotate(anElementsId, anAxis, anAngle, true); + if ( makeGroups ) { + SMESH::ListOfGroups_var groups; + if(CheckBoxMesh->isChecked()) + groups = aMeshEditor->RotateObjectMakeGroups(mySelectedObject, anAxis, anAngle); + else + groups = aMeshEditor->RotateMakeGroups(anElementsId, anAxis, anAngle); + } + else { + if(CheckBoxMesh->isChecked()) + aMeshEditor->RotateObject(mySelectedObject, anAxis, anAngle, true); + else + aMeshEditor->Rotate(anElementsId, anAxis, anAngle, true); + } + if( !myMesh->_is_nil()) + myMesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters)); break; case MAKE_MESH_BUTTON: - SMESH::SMESH_Mesh_var mesh = - aMeshEditor->RotateMakeMesh(anElementsId, anAxis, anAngle, makeGroups, - LineEditNewMesh->text().toLatin1().data()); + SMESH::SMESH_Mesh_var mesh; + if(CheckBoxMesh->isChecked()) + mesh = aMeshEditor->RotateObjectMakeMesh(mySelectedObject, anAxis, anAngle, makeGroups, + LineEditNewMesh->text().toLatin1().data()); + else + mesh = aMeshEditor->RotateMakeMesh(anElementsId, anAxis, anAngle, makeGroups, + LineEditNewMesh->text().toLatin1().data()); + if( !mesh->_is_nil()) + mesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters)); } } catch (...) { } @@ -418,8 +453,11 @@ void SMESHGUI_RotationDlg::ClickOnApply() actionButton == MAKE_MESH_BUTTON ) mySMESHGUI->updateObjBrowser(true); // new groups may appear Init(false); + mySelectedObject = SMESH::SMESH_IDSource::_nil(); SelectionIntoArgument(); } + + return true; } //================================================================================= @@ -428,8 +466,8 @@ void SMESHGUI_RotationDlg::ClickOnApply() //================================================================================= void SMESHGUI_RotationDlg::ClickOnOk() { - ClickOnApply(); - ClickOnCancel(); + if( ClickOnApply() ) + ClickOnCancel(); } //================================================================================= @@ -586,13 +624,18 @@ void SMESHGUI_RotationDlg::SelectionIntoArgument() if (CheckBoxMesh->isChecked()) { SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); - if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //MESH + if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //MESH + mySelectedObject = SMESH::IObjectToInterface(IO); + } + else + return; // get IDs from mesh - SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); - if (!aSMDSMesh) + /* + SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); + if (!aSMDSMesh) return; - for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) { + for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) { const SMDS_MeshElement * e = aSMDSMesh->FindElement(i); if (e) { myElementsId += QString(" %1").arg(i); @@ -600,40 +643,41 @@ void SMESHGUI_RotationDlg::SelectionIntoArgument() } } } else if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //SUBMESH - // get submesh + // get submesh SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(IO); - + // get IDs from submesh SMESH::long_array_var anElementsIds = new SMESH::long_array; anElementsIds = aSubMesh->GetElementsId(); for (int i = 0; i < anElementsIds->length(); i++) { - myElementsId += QString(" %1").arg(anElementsIds[i]); - } + myElementsId += QString(" %1").arg(anElementsIds[i]); + } aNbUnits = anElementsIds->length(); } else { // GROUP // get smesh group SMESH::SMESH_GroupBase_var aGroup = - SMESH::IObjectToInterface(IO); + SMESH::IObjectToInterface(IO); if (aGroup->_is_nil()) - return; + return; - // get IDs from smesh group + // get IDs from smesh group SMESH::long_array_var anElementsIds = new SMESH::long_array; anElementsIds = aGroup->GetListOfID(); for (int i = 0; i < anElementsIds->length(); i++) { - myElementsId += QString(" %1").arg(anElementsIds[i]); - } + myElementsId += QString(" %1").arg(anElementsIds[i]); + } aNbUnits = anElementsIds->length(); - } - } else { + } + */ + } else { aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString); myElementsId = aString; - } - - if (aNbUnits < 1) - return; + if (aNbUnits < 1) + return; + } myNbOkElements = true; + } else { aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString); if (aNbUnits != 1) @@ -719,6 +763,7 @@ void SMESHGUI_RotationDlg::SetEditCurrentArgument() } break; } + } myEditCurrentArgument->setFocus(); @@ -938,3 +983,30 @@ void SMESHGUI_RotationDlg::setFilters() myFilterDlg->show(); } + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool SMESHGUI_RotationDlg::isValid() +{ + bool ok = true; + QString msg; + + ok = SpinBox_X->isValid( msg, true ) && ok; + ok = SpinBox_Y->isValid( msg, true ) && ok; + ok = SpinBox_Z->isValid( msg, true ) && ok; + ok = SpinBox_DX->isValid( msg, true ) && ok; + ok = SpinBox_DY->isValid( msg, true ) && ok; + ok = SpinBox_DZ->isValid( msg, true ) && ok; + ok = SpinBox_Angle->isValid( msg, true ) && ok; + + if( !ok ) { + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); + return false; + } + return true; +} diff --git a/src/SMESHGUI/SMESHGUI_RotationDlg.h b/src/SMESHGUI/SMESHGUI_RotationDlg.h index de192b80b..4dd572f29 100644 --- a/src/SMESHGUI/SMESHGUI_RotationDlg.h +++ b/src/SMESHGUI/SMESHGUI_RotationDlg.h @@ -73,6 +73,8 @@ private: bool IsAxisOk(); void setNewMeshName(); + bool isValid(); + SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ SMESHGUI_IdValidator* myIdValidator; LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */ @@ -86,6 +88,7 @@ private: SMESH::SMESH_Mesh_var myMesh; SMESH_Actor* myActor; SMESH_LogicalFilter* myMeshOrSubMeshOrGroupFilter; + SMESH::SMESH_IDSource_var mySelectedObject; QGroupBox* GroupConstructors; QRadioButton* RadioButton1; @@ -133,7 +136,7 @@ private: private slots: void ClickOnOk(); void ClickOnCancel(); - void ClickOnApply(); + bool ClickOnApply(); void ClickOnHelp(); void SetEditCurrentArgument(); void SelectionIntoArgument(); diff --git a/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx b/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx index e38bf7713..c2144b1f4 100644 --- a/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx @@ -50,6 +50,8 @@ #include #include +#include + #include #include #include @@ -68,7 +70,6 @@ #include #include #include -#include #include #include #include @@ -91,7 +92,8 @@ SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule ) : QDialog( SMESH::GetDesktop( theModule ) ), mySMESHGUI( theModule ), mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), - myFilterDlg(0) + myFilterDlg(0), + mySelectedObject(SMESH::SMESH_IDSource::_nil()) { QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_SMOOTHING"))); QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); @@ -160,7 +162,7 @@ SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule ) // Controls for iteration limit defining TextLabelLimit = new QLabel(tr("ITERATION_LIMIT"), GroupArguments); - SpinBox_IterationLimit = new QSpinBox(GroupArguments); + SpinBox_IterationLimit = new SalomeApp_IntSpinBox(GroupArguments); // Controls for max. aspect ratio defining TextLabelAspectRatio = new QLabel(tr("MAX_ASPECT_RATIO"), GroupArguments); @@ -318,10 +320,13 @@ void SMESHGUI_SmoothingDlg::Init() // function : ClickOnApply() // purpose : Called when user presses button //================================================================================= -void SMESHGUI_SmoothingDlg::ClickOnApply() +bool SMESHGUI_SmoothingDlg::ClickOnApply() { if (mySMESHGUI->isActiveStudyLocked()) - return; + return false; + + if (!isValid()) + return false; if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) { QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts); @@ -345,6 +350,10 @@ void SMESHGUI_SmoothingDlg::ClickOnApply() long anIterationLimit = (long)SpinBox_IterationLimit->value(); double aMaxAspectRatio = SpinBox_AspectRatio->GetValue(); + QStringList aParameters; + aParameters << SpinBox_IterationLimit->text(); + aParameters << SpinBox_AspectRatio->text(); + SMESH::SMESH_MeshEditor::Smooth_Method aMethod = SMESH::SMESH_MeshEditor::LAPLACIAN_SMOOTH; if (ComboBoxMethod->currentIndex() > 0) aMethod = SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH; @@ -354,12 +363,25 @@ void SMESHGUI_SmoothingDlg::ClickOnApply() SUIT_OverrideCursor aWaitCursor; SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); - if ( CheckBoxParametric->isChecked() ) - aResult = aMeshEditor->SmoothParametric(anElementsId.inout(), aNodesId.inout(), - anIterationLimit, aMaxAspectRatio, aMethod); - else - aResult = aMeshEditor->Smooth(anElementsId.inout(), aNodesId.inout(), - anIterationLimit, aMaxAspectRatio, aMethod); + if ( CheckBoxParametric->isChecked() ) { + if(CheckBoxMesh->isChecked()) + aResult = aMeshEditor->SmoothParametricObject(mySelectedObject, aNodesId.inout(), + anIterationLimit, aMaxAspectRatio, aMethod); + else + aResult = aMeshEditor->SmoothParametric(anElementsId.inout(), aNodesId.inout(), + anIterationLimit, aMaxAspectRatio, aMethod); + } + else { + if(CheckBoxMesh->isChecked()) + aResult = aMeshEditor->SmoothObject(mySelectedObject, aNodesId.inout(), + anIterationLimit, aMaxAspectRatio, aMethod); + else + aResult = aMeshEditor->Smooth(anElementsId.inout(), aNodesId.inout(), + anIterationLimit, aMaxAspectRatio, aMethod); + } + + myMesh->SetParameters( SMESHGUI::JoinObjectParameters(aParameters) ); + } catch (...) { } @@ -371,8 +393,12 @@ void SMESHGUI_SmoothingDlg::ClickOnApply() mySelectionMgr->setSelectedObjects(aList, false); SMESH::UpdateView(); Init(); + + mySelectedObject = SMESH::SMESH_IDSource::_nil(); } } + + return true; } //================================================================================= @@ -381,8 +407,8 @@ void SMESHGUI_SmoothingDlg::ClickOnApply() //================================================================================= void SMESHGUI_SmoothingDlg::ClickOnOk() { - ClickOnApply(); - ClickOnCancel(); + if( ClickOnApply() ) + ClickOnCancel(); } //================================================================================= @@ -549,48 +575,15 @@ void SMESHGUI_SmoothingDlg::SelectionIntoArgument() if (CheckBoxMesh->isChecked()) { SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); - if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //MESH - // get IDs from mesh - SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); - if (!aSMDSMesh) - return; - - for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++ ) { - const SMDS_MeshElement * e = aSMDSMesh->FindElement(i); - if (e) { - myElementsId += QString(" %1").arg(i); - aNbUnits++; - } - } - } else if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //SUBMESH - // get submesh - SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(IO); - - // get IDs from submesh - SMESH::long_array_var anElementsIds = new SMESH::long_array; - anElementsIds = aSubMesh->GetElementsId(); - for (int i = 0; i < anElementsIds->length(); i++) { - myElementsId += QString(" %1").arg(anElementsIds[i]); - } - aNbUnits = anElementsIds->length(); - } else { // GROUP - // get smesh group - SMESH::SMESH_GroupBase_var aGroup = - SMESH::IObjectToInterface(IO); - if (aGroup->_is_nil()) - return; - - // get IDs from smesh group - SMESH::long_array_var anElementsIds = new SMESH::long_array; - anElementsIds = aGroup->GetListOfID(); - for (int i = 0; i < anElementsIds->length(); i++) { - myElementsId += QString(" %1").arg(anElementsIds[i]); - } - aNbUnits = anElementsIds->length(); - } + if (!SMESH::IObjectToInterface(IO)->_is_nil()) + mySelectedObject = SMESH::IObjectToInterface(IO); + else + return; } else { aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString); myElementsId = aString; + if (aNbUnits < 1) + return; } } else if (myEditCurrentArgument == LineEditNodes && !myMesh->_is_nil() && myActor) { myNbOkNodes = 0; @@ -598,9 +591,6 @@ void SMESHGUI_SmoothingDlg::SelectionIntoArgument() } else { } - if (aNbUnits < 1) - return; - myBusy = true; myEditCurrentArgument->setText(aString); myEditCurrentArgument->repaint(); @@ -822,3 +812,24 @@ void SMESHGUI_SmoothingDlg::setNodeFilters() { setFilters( false ); } + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool SMESHGUI_SmoothingDlg::isValid() +{ + QString msg; + bool ok = true; + ok = SpinBox_IterationLimit->isValid( msg, true ) && ok; + ok = SpinBox_AspectRatio->isValid( msg, true ) && ok; + + if( !ok ) { + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); + return false; + } + return true; +} diff --git a/src/SMESHGUI/SMESHGUI_SmoothingDlg.h b/src/SMESHGUI/SMESHGUI_SmoothingDlg.h index c01dfc1c7..40b8170a3 100644 --- a/src/SMESHGUI/SMESHGUI_SmoothingDlg.h +++ b/src/SMESHGUI/SMESHGUI_SmoothingDlg.h @@ -43,8 +43,8 @@ class QPushButton; class QRadioButton; class QComboBox; class QCheckBox; -class QSpinBox; class SMESHGUI; +class SalomeApp_IntSpinBox; class SMESHGUI_IdValidator; class SMESHGUI_SpinBox; class SMESHGUI_FilterDlg; @@ -73,6 +73,8 @@ private: void keyPressEvent( QKeyEvent* ); void setFilters( const bool theIsElem ); + bool isValid(); + SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ SMESHGUI_IdValidator* myIdValidator; LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */ @@ -83,6 +85,8 @@ private: QLineEdit* myEditCurrentArgument; /* Current LineEdit */ SVTK_Selector* mySelector; + SMESH::SMESH_IDSource_var mySelectedObject; + bool myBusy; SMESH::SMESH_Mesh_var myMesh; SMESH_Actor* myActor; @@ -106,7 +110,7 @@ private: QLabel* TextLabelMethod; QComboBox* ComboBoxMethod; QLabel* TextLabelLimit; - QSpinBox* SpinBox_IterationLimit; + SalomeApp_IntSpinBox* SpinBox_IterationLimit; QLabel* TextLabelAspectRatio; SMESHGUI_SpinBox* SpinBox_AspectRatio; QCheckBox* CheckBoxParametric; @@ -118,7 +122,7 @@ private: private slots: void ClickOnOk(); void ClickOnCancel(); - void ClickOnApply(); + bool ClickOnApply(); void ClickOnHelp(); void SetEditCurrentArgument(); void SelectionIntoArgument(); diff --git a/src/SMESHGUI/SMESHGUI_SpinBox.cxx b/src/SMESHGUI/SMESHGUI_SpinBox.cxx index f3822e3e7..1b30cb08a 100644 --- a/src/SMESHGUI/SMESHGUI_SpinBox.cxx +++ b/src/SMESHGUI/SMESHGUI_SpinBox.cxx @@ -35,7 +35,7 @@ // purpose : constructor of specific widget accepting floats in double precision. //================================================================================= SMESHGUI_SpinBox::SMESHGUI_SpinBox( QWidget* parent ) - : QtxDoubleSpinBox( parent ) + : SalomeApp_DoubleSpinBox( parent ) { } @@ -90,7 +90,7 @@ QString SMESHGUI_SpinBox::GetString() const //================================================================================= QLineEdit* SMESHGUI_SpinBox::editor() const { - return QtxDoubleSpinBox::lineEdit(); + return SalomeApp_DoubleSpinBox::lineEdit(); } //================================================================================= @@ -116,4 +116,5 @@ void SMESHGUI_SpinBox::RangeStepAndValidator( double min, setDecimals(32); setRange(min, max); setSingleStep( step ); + setDefaultValue( min ); } diff --git a/src/SMESHGUI/SMESHGUI_SpinBox.h b/src/SMESHGUI/SMESHGUI_SpinBox.h index 2fa5872ed..cdca31653 100644 --- a/src/SMESHGUI/SMESHGUI_SpinBox.h +++ b/src/SMESHGUI/SMESHGUI_SpinBox.h @@ -30,7 +30,7 @@ #include "SMESH_SMESHGUI.hxx" // SALOME GUI includes -#include +#include #define COORD_MIN -1e+15 #define COORD_MAX +1e+15 @@ -43,7 +43,7 @@ class QDoubleValidator; // class : SMESHGUI_SpinBox // purpose : Derivated from QtxDoubleSpinBox class //================================================================================= -class SMESHGUI_EXPORT SMESHGUI_SpinBox : public QtxDoubleSpinBox +class SMESHGUI_EXPORT SMESHGUI_SpinBox : public SalomeApp_DoubleSpinBox { Q_OBJECT diff --git a/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx b/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx index 7f0c6d0fe..ed49f5217 100644 --- a/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx @@ -92,7 +92,8 @@ SMESHGUI_SymmetryDlg::SMESHGUI_SymmetryDlg( SMESHGUI* theModule ) : QDialog( SMESH::GetDesktop( theModule ) ), mySMESHGUI( theModule ), mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), - myFilterDlg(0) + myFilterDlg(0), + mySelectedObject(SMESH::SMESH_IDSource::_nil()) { QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_POINT"))); QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_AXIS"))); @@ -437,10 +438,13 @@ void SMESHGUI_SymmetryDlg::ConstructorsClicked (int constructorId) // function : ClickOnApply() // purpose : //================================================================================= -void SMESHGUI_SymmetryDlg::ClickOnApply() +bool SMESHGUI_SymmetryDlg::ClickOnApply() { if (mySMESHGUI->isActiveStudyLocked()) - return; + return false; + + if( !isValid() ) + return false; if (myNbOkElements && IsMirrorOk()) { QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts); @@ -464,6 +468,13 @@ void SMESHGUI_SymmetryDlg::ClickOnApply() aMirror.vz = SpinBox_DZ->GetValue(); } + QStringList aParameters; + aParameters << SpinBox_X->text(); + aParameters << SpinBox_Y->text(); + aParameters << SpinBox_Z->text(); + aParameters << ( GetConstructorId() == 0 ? QString::number(0) : SpinBox_DX->text() ); + aParameters << ( GetConstructorId() == 0 ? QString::number(0) : SpinBox_DY->text() ); + aParameters << ( GetConstructorId() == 0 ? QString::number(0) : SpinBox_DZ->text() ); SMESH::SMESH_MeshEditor::MirrorType aMirrorType; @@ -482,32 +493,60 @@ void SMESHGUI_SymmetryDlg::ClickOnApply() SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); switch ( actionButton ) { - case MOVE_ELEMS_BUTTON: - aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, false ); + case MOVE_ELEMS_BUTTON: { + if(CheckBoxMesh->isChecked()) + aMeshEditor->MirrorObject(mySelectedObject, aMirror, aMirrorType, false ); + else + aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, false ); + + if( !myMesh->_is_nil()) + myMesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters)); + break; + } + case COPY_ELEMS_BUTTON: { + SMESH::ListOfGroups_var groups; + if ( makeGroups ) { + if(CheckBoxMesh->isChecked()) + groups = aMeshEditor->MirrorObjectMakeGroups(mySelectedObject, aMirror, aMirrorType); + else + groups = aMeshEditor->MirrorMakeGroups(anElementsId, aMirror, aMirrorType); + } + else { + if(CheckBoxMesh->isChecked()) + aMeshEditor->MirrorObject(mySelectedObject, aMirror, aMirrorType, true); + else + aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, true); + } + if( !myMesh->_is_nil()) + myMesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters)); break; - case COPY_ELEMS_BUTTON: - if ( makeGroups ) - SMESH::ListOfGroups_var groups = - aMeshEditor->MirrorMakeGroups(anElementsId, aMirror, aMirrorType); + } + case MAKE_MESH_BUTTON: { + SMESH::SMESH_Mesh_var mesh; + if(CheckBoxMesh->isChecked()) + mesh = aMeshEditor->MirrorObjectMakeMesh(mySelectedObject, aMirror, aMirrorType, makeGroups, + LineEditNewMesh->text().toLatin1().data()); else - aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, true); + mesh = aMeshEditor->MirrorMakeMesh(anElementsId, aMirror, aMirrorType, makeGroups, + LineEditNewMesh->text().toLatin1().data()); + if( !mesh->_is_nil()) + mesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters)); break; - case MAKE_MESH_BUTTON: - SMESH::SMESH_Mesh_var mesh = - aMeshEditor->MirrorMakeMesh(anElementsId, aMirror, aMirrorType, makeGroups, - LineEditNewMesh->text().toLatin1().data()); + } } } catch (...) { } - + SMESH::UpdateView(); if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() || actionButton == MAKE_MESH_BUTTON ) mySMESHGUI->updateObjBrowser(true); // new groups may appear Init(false); ConstructorsClicked(GetConstructorId()); + mySelectedObject = SMESH::SMESH_IDSource::_nil(); SelectionIntoArgument(); } + return true; } //================================================================================= @@ -516,8 +555,8 @@ void SMESHGUI_SymmetryDlg::ClickOnApply() //================================================================================= void SMESHGUI_SymmetryDlg::ClickOnOk() { - ClickOnApply(); - ClickOnCancel(); + if( ClickOnApply() ) + ClickOnCancel(); } //================================================================================= @@ -675,8 +714,13 @@ void SMESHGUI_SymmetryDlg::SelectionIntoArgument() if (CheckBoxMesh->isChecked()) { SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString); - if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //MESH - // get IDs from mesh + if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //MESH + mySelectedObject = SMESH::IObjectToInterface(IO); + } + else + return; + // get IDs from mesh + /* SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); if (!aSMDSMesh) return; @@ -688,17 +732,20 @@ void SMESHGUI_SymmetryDlg::SelectionIntoArgument() aNbUnits++; } } + } else if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //SUBMESH // get submesh SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(IO); // get IDs from submesh + /* SMESH::long_array_var anElementsIds = new SMESH::long_array; anElementsIds = aSubMesh->GetElementsId(); for (int i = 0; i < anElementsIds->length(); i++) { myElementsId += QString(" %1").arg(anElementsIds[i]); } aNbUnits = anElementsIds->length(); + } else { // GROUP // get smesh group SMESH::SMESH_GroupBase_var aGroup = @@ -714,14 +761,14 @@ void SMESHGUI_SymmetryDlg::SelectionIntoArgument() } aNbUnits = anElementsIds->length(); } + */ } else { aNbUnits = SMESH::GetNameOfSelectedElements( mySelector, IO, aString); myElementsId = aString; + if (aNbUnits < 1) + return; } - - if (aNbUnits < 1) - return; - + myNbOkElements = true; } else { aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString); @@ -1035,3 +1082,31 @@ void SMESHGUI_SymmetryDlg::setFilters() myFilterDlg->show(); } + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool SMESHGUI_SymmetryDlg::isValid() +{ + bool ok = true; + QString msg; + + ok = SpinBox_X->isValid( msg, true ) && ok; + ok = SpinBox_Y->isValid( msg, true ) && ok; + ok = SpinBox_Z->isValid( msg, true ) && ok; + if (GetConstructorId() != 0) { + ok = SpinBox_DX->isValid( msg, true ) && ok; + ok = SpinBox_DY->isValid( msg, true ) && ok; + ok = SpinBox_DZ->isValid( msg, true ) && ok; + } + + if( !ok ) { + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); + return false; + } + return true; +} diff --git a/src/SMESHGUI/SMESHGUI_SymmetryDlg.h b/src/SMESHGUI/SMESHGUI_SymmetryDlg.h index fc18a65be..c56317d0b 100644 --- a/src/SMESHGUI/SMESHGUI_SymmetryDlg.h +++ b/src/SMESHGUI/SMESHGUI_SymmetryDlg.h @@ -74,6 +74,8 @@ private: bool IsMirrorOk(); void setNewMeshName(); + bool isValid(); + SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ SMESHGUI_IdValidator* myIdValidator; LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */ @@ -83,6 +85,8 @@ private: QWidget* myEditCurrentArgument; /* Current LineEdit */ + SMESH::SMESH_IDSource_var mySelectedObject; + bool myBusy; SMESH::SMESH_Mesh_var myMesh; SMESH_Actor* myActor; @@ -135,7 +139,7 @@ private slots: void ConstructorsClicked( int ); void ClickOnOk(); void ClickOnCancel(); - void ClickOnApply(); + bool ClickOnApply(); void ClickOnHelp(); void SetEditCurrentArgument(); void SelectionIntoArgument(); diff --git a/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx b/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx index b148a5315..091446d10 100644 --- a/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx @@ -109,7 +109,8 @@ SMESHGUI_TranslationDlg::SMESHGUI_TranslationDlg( SMESHGUI* theModule ) : QDialog( SMESH::GetDesktop( theModule ) ), mySMESHGUI( theModule ), mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), - myFilterDlg(0) + myFilterDlg(0), + mySelectedObject(SMESH::SMESH_IDSource::_nil()) { QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_TRANSLATION_POINTS"))); QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_TRANSLATION_VECTOR"))); @@ -436,10 +437,13 @@ void SMESHGUI_TranslationDlg::ConstructorsClicked (int constructorId) // function : ClickOnApply() // purpose : //================================================================================= -void SMESHGUI_TranslationDlg::ClickOnApply() +bool SMESHGUI_TranslationDlg::ClickOnApply() { if (mySMESHGUI->isActiveStudyLocked()) - return; + return false; + + if( !isValid() ) + return false; if (myNbOkElements) { QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts); @@ -461,6 +465,17 @@ void SMESHGUI_TranslationDlg::ClickOnApply() aVector.PS.z = SpinBox1_3->GetValue(); } + QStringList aParameters; + aParameters << SpinBox1_1->text(); + if (GetConstructorId() == 0) + aParameters << SpinBox2_1->text(); + aParameters << SpinBox1_2->text(); + if (GetConstructorId() == 0) + aParameters << SpinBox2_2->text(); + aParameters << SpinBox1_3->text(); + if (GetConstructorId() == 0) + aParameters << SpinBox2_3->text(); + int actionButton = ActionGroup->checkedId(); bool makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ); try { @@ -468,31 +483,55 @@ void SMESHGUI_TranslationDlg::ClickOnApply() SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); switch ( actionButton ) { case MOVE_ELEMS_BUTTON: - aMeshEditor->Translate(anElementsId, aVector, false); + if(CheckBoxMesh->isChecked()) + aMeshEditor->TranslateObject(mySelectedObject, aVector, false); + else + aMeshEditor->Translate(anElementsId, aVector, false); + if( !myMesh->_is_nil()) + myMesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters)); break; case COPY_ELEMS_BUTTON: - if ( makeGroups ) - SMESH::ListOfGroups_var groups = - aMeshEditor->TranslateMakeGroups(anElementsId, aVector); - else - aMeshEditor->Translate(anElementsId, aVector, true); + if ( makeGroups ) { + SMESH::ListOfGroups_var groups; + if(CheckBoxMesh->isChecked()) + groups = aMeshEditor->TranslateObjectMakeGroups(mySelectedObject,aVector); + else + groups = aMeshEditor->TranslateMakeGroups(anElementsId, aVector); + } + else { + if(CheckBoxMesh->isChecked()) + aMeshEditor->TranslateObject(mySelectedObject, aVector, true); + else + aMeshEditor->Translate(anElementsId, aVector, true); + } + if( !myMesh->_is_nil()) + myMesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters)); break; case MAKE_MESH_BUTTON: - SMESH::SMESH_Mesh_var mesh = - aMeshEditor->TranslateMakeMesh(anElementsId, aVector, makeGroups, - LineEditNewMesh->text().toLatin1().data()); + SMESH::SMESH_Mesh_var mesh; + if(CheckBoxMesh->isChecked()) + mesh = aMeshEditor->TranslateObjectMakeMesh(mySelectedObject, aVector, makeGroups, + LineEditNewMesh->text().toLatin1().data()); + else + mesh = aMeshEditor->TranslateMakeMesh(anElementsId, aVector, makeGroups, + LineEditNewMesh->text().toLatin1().data()); + if( !mesh->_is_nil()) + mesh->SetParameters(SMESHGUI::JoinObjectParameters(aParameters)); } } catch (...) { } - + SMESH::UpdateView(); if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() || actionButton == MAKE_MESH_BUTTON ) mySMESHGUI->updateObjBrowser(true); // new groups may appear Init(false); ConstructorsClicked(GetConstructorId()); + mySelectedObject = SMESH::SMESH_IDSource::_nil(); SelectionIntoArgument(); } + + return true; } //================================================================================= @@ -501,8 +540,8 @@ void SMESHGUI_TranslationDlg::ClickOnApply() //================================================================================= void SMESHGUI_TranslationDlg::ClickOnOk() { - ClickOnApply(); - ClickOnCancel(); + if( ClickOnApply() ) + ClickOnCancel(); } //================================================================================= @@ -657,8 +696,13 @@ void SMESHGUI_TranslationDlg::SelectionIntoArgument() if (CheckBoxMesh->isChecked()) { SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aString ); - if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //MESH + if (!SMESH::IObjectToInterface(IO)->_is_nil()) { //MESH, SUBMESH, OR GROUP + mySelectedObject = SMESH::IObjectToInterface(IO); + } + else + return; // get IDs from mesh + /* SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); if (!aSMDSMesh) return; @@ -696,14 +740,14 @@ void SMESHGUI_TranslationDlg::SelectionIntoArgument() } aNbUnits = anElementsIds->length(); } + */ } else { aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString); myElementsId = aString; + if (aNbUnits < 1) + return; } - if (aNbUnits < 1) - return; - myNbOkElements = true; } else { aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString); @@ -986,3 +1030,31 @@ void SMESHGUI_TranslationDlg::setFilters() myFilterDlg->show(); } + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool SMESHGUI_TranslationDlg::isValid() +{ + bool ok = true; + QString msg; + + ok = SpinBox1_1->isValid( msg, true ) && ok; + ok = SpinBox1_2->isValid( msg, true ) && ok; + ok = SpinBox1_3->isValid( msg, true ) && ok; + if (GetConstructorId() == 0) { + ok = SpinBox2_1->isValid( msg, true ) && ok; + ok = SpinBox2_2->isValid( msg, true ) && ok; + ok = SpinBox2_3->isValid( msg, true ) && ok; + } + + if( !ok ) { + QString str( tr( "SMESH_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str ); + return false; + } + return true; +} diff --git a/src/SMESHGUI/SMESHGUI_TranslationDlg.h b/src/SMESHGUI/SMESHGUI_TranslationDlg.h index c551faeee..279ec596b 100644 --- a/src/SMESHGUI/SMESHGUI_TranslationDlg.h +++ b/src/SMESHGUI/SMESHGUI_TranslationDlg.h @@ -73,6 +73,8 @@ private: int GetConstructorId(); void setNewMeshName(); + bool isValid(); + SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ SMESHGUI_IdValidator* myIdValidator; LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */ @@ -88,6 +90,8 @@ private: SMESH_Actor* myActor; SMESH_LogicalFilter* myMeshOrSubMeshOrGroupFilter; + SMESH::SMESH_IDSource_var mySelectedObject; + QGroupBox* ConstructorsBox; QButtonGroup* GroupConstructors; QRadioButton* RadioButton1; @@ -132,7 +136,7 @@ private slots: void ConstructorsClicked( int ); void ClickOnOk(); void ClickOnCancel(); - void ClickOnApply(); + bool ClickOnApply(); void ClickOnHelp(); void SetEditCurrentArgument(); void SelectionIntoArgument(); diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index 304d976fc..a8481122a 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -1280,6 +1280,10 @@ Are you sure want to export to MED 2.1 ? SMESH_ID_NODES Id Nodes + + SMESH_INCORRECT_INPUT + Incorrect input data! + SMESH_INFORMATION Information diff --git a/src/SMESH_I/Makefile.am b/src/SMESH_I/Makefile.am index 35200fa1c..2a15a44df 100644 --- a/src/SMESH_I/Makefile.am +++ b/src/SMESH_I/Makefile.am @@ -47,6 +47,7 @@ salomeinclude_HEADERS = \ SMESH_MEDSupport_i.hxx \ SMESH_Pattern_i.hxx \ SMESH_2smeshpy.hxx \ + SMESH_NoteBook.hxx \ SMESH.hxx # Scripts to be installed. @@ -76,7 +77,8 @@ dist_libSMESHEngine_la_SOURCES = \ SMESH_Filter_i.cxx \ SMESH_Group_i.cxx \ SMESH_Pattern_i.cxx \ - SMESH_2smeshpy.cxx + SMESH_2smeshpy.cxx \ + SMESH_NoteBook.cxx # Executables targets bin_PROGRAMS = SMESHEngine diff --git a/src/SMESH_I/SMESH_2smeshpy.cxx b/src/SMESH_I/SMESH_2smeshpy.cxx index 0a7e57e86..be494755b 100644 --- a/src/SMESH_I/SMESH_2smeshpy.cxx +++ b/src/SMESH_I/SMESH_2smeshpy.cxx @@ -29,6 +29,7 @@ #include "utilities.h" #include "SMESH_PythonDump.hxx" +#include "SMESH_NoteBook.hxx" #include "Resource_DataMapOfAsciiStringAsciiString.hxx" #include "SMESH_Gen_i.hxx" @@ -125,12 +126,31 @@ SMESH_2smeshpy::ConvertScript(const TCollection_AsciiString& theScript, theGen = new _pyGen( theEntry2AccessorMethod, theObjectNames ); // split theScript into separate commands + + SMESH_NoteBook * aNoteBook = new SMESH_NoteBook(); + int from = 1, end = theScript.Length(), to; while ( from < end && ( to = theScript.Location( "\n", from, end ))) + { + if ( to != from ) + // cut out and store a command + aNoteBook->AddCommand( theScript.SubString( from, to - 1 )); + from = to + 1; + } + + aNoteBook->ReplaceVariables(); + + TCollection_AsciiString aNoteScript = aNoteBook->GetResultScript(); + delete aNoteBook; + aNoteBook = 0; + + // split theScript into separate commands + from = 1, end = aNoteScript.Length(); + while ( from < end && ( to = aNoteScript.Location( "\n", from, end ))) { if ( to != from ) // cut out and store a command - theGen->AddCommand( theScript.SubString( from, to - 1 )); + theGen->AddCommand( aNoteScript.SubString( from, to - 1 )); from = to + 1; } @@ -1057,13 +1077,14 @@ void _pyMeshEditor::Process( const Handle(_pyCommand)& theCommand) if ( sameMethods.empty() ) { const char * names[] = { "RemoveElements","RemoveNodes","AddNode","AddEdge","AddFace","AddPolygonalFace", - "AddVolume","AddPolyhedralVolume","AddPolyhedralVolumeByFaces","MoveNode", - "InverseDiag","DeleteDiag","Reorient","ReorientObject","SplitQuad","SplitQuadObject", + "AddVolume","AddPolyhedralVolume","AddPolyhedralVolumeByFaces","MoveNode", "MoveClosestNodeToPoint", + "InverseDiag","DeleteDiag","Reorient","ReorientObject","TriToQuad","SplitQuad","SplitQuadObject", "BestSplit","Smooth","SmoothObject","SmoothParametric","SmoothParametricObject", "ConvertToQuadratic","ConvertFromQuadratic","RenumberNodes","RenumberElements", - "RotationSweep","RotationSweepObject","ExtrusionSweep","AdvancedExtrusion", - "ExtrusionSweepObject","ExtrusionSweepObject1D","ExtrusionSweepObject2D","Mirror", - "MirrorObject","Translate","TranslateObject","Rotate","RotateObject", + "RotationSweep","RotationSweepObject","RotationSweepObject1D","RotationSweepObject2D", + "ExtrusionSweep","AdvancedExtrusion","ExtrusionSweepObject","ExtrusionSweepObject1D","ExtrusionSweepObject2D", + "ExtrusionAlongPath","ExtrusionAlongPathObject","ExtrusionAlongPathObject1D","ExtrusionAlongPathObject2D", + "Mirror","MirrorObject","Translate","TranslateObject","Rotate","RotateObject", "FindCoincidentNodes","FindCoincidentNodesOnPart","MergeNodes","FindEqualElements", "MergeElements","MergeEqualElements","SewFreeBorders","SewConformFreeBorders", "SewBorderToSide","SewSideElements","ChangeElemNodes","GetLastCreatedNodes", @@ -1983,14 +2004,21 @@ const TCollection_AsciiString & _pyCommand::GetArg( int index ) if ( begPos < 1 ) begPos = myString.Location( "(", 1, Length() ) + 1; - int i = 0, prevLen = 0; + int i = 0, prevLen = 0, nbNestings = 0; while ( begPos != EMPTY ) { begPos += prevLen; + if( myString.Value( begPos ) == '(' ) + nbNestings++; // check if we are looking at the closing parenthesis while ( begPos <= Length() && isspace( myString.Value( begPos ))) ++begPos; - if ( begPos > Length() || myString.Value( begPos ) == ')' ) + if ( begPos > Length() ) break; + if ( myString.Value( begPos ) == ')' ) { + nbNestings--; + if( nbNestings == 0 ) + break; + } myArgs.Append( GetWord( myString, begPos, true, true )); SetBegPos( ARG1_IND + i, begPos ); prevLen = myArgs.Last().Length(); @@ -2144,7 +2172,8 @@ void _pyCommand::SetArg( int index, const TCollection_AsciiString& theArg) if ( pos < 1 ) // no index-th arg exist, append inexistent args { // find a closing parenthesis - if ( int lastArgInd = GetNbArgs() ) { + if ( GetNbArgs() != 0 && index <= GetNbArgs() ) { + int lastArgInd = GetNbArgs(); pos = GetBegPos( ARG1_IND + lastArgInd - 1 ) + GetArg( lastArgInd ).Length(); while ( pos > 0 && pos <= Length() && myString.Value( pos ) != ')' ) ++pos; diff --git a/src/SMESH_I/SMESH_Gen_i.hxx b/src/SMESH_I/SMESH_Gen_i.hxx index e06f5db73..836e585c7 100644 --- a/src/SMESH_I/SMESH_Gen_i.hxx +++ b/src/SMESH_I/SMESH_Gen_i.hxx @@ -493,6 +493,11 @@ public: * \brief Find SObject for an algo */ SALOMEDS::SObject_ptr GetAlgoSO(const ::SMESH_Algo* algo); + + void UpdateParameters(CORBA::Object_ptr theObject, const char* theParameters); + char* GetParameters(CORBA::Object_ptr theObject); + char* ParseParameters(const char* theParameters); + private: // Create hypothesis of given type diff --git a/src/SMESH_I/SMESH_Gen_i_1.cxx b/src/SMESH_I/SMESH_Gen_i_1.cxx index 02358c789..b0701ea59 100644 --- a/src/SMESH_I/SMESH_Gen_i_1.cxx +++ b/src/SMESH_I/SMESH_Gen_i_1.cxx @@ -43,8 +43,10 @@ #ifdef _DEBUG_ static int MYDEBUG = 0; +static int VARIABLE_DEBUG = 0; #else static int MYDEBUG = 0; +static int VARIABLE_DEBUG = 0; #endif //============================================================================= @@ -863,3 +865,100 @@ bool SMESH_Gen_i::RemoveHypothesisFromShape(SALOMEDS::Study_ptr theStudy return true; } +//======================================================================= +//function : UpdateParameters +//purpose : +//======================================================================= +void SMESH_Gen_i::UpdateParameters(CORBA::Object_ptr theObject, const char* theParameters) +{ + + if(VARIABLE_DEBUG) + cout<<"UpdateParameters : "<_is_nil() || CORBA::is_nil(theObject)) + return; + + SALOMEDS::SObject_var aSObj = ObjectToSObject(aStudy,theObject); + if(aSObj->_is_nil()) + return; + + SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); + + SALOMEDS::GenericAttribute_var aFindAttr; + bool hasAttr = aSObj->FindAttribute(aFindAttr, "AttributeString"); + if(VARIABLE_DEBUG) + cout<<"Find Attribute "<FindOrCreateAttribute( aSObj, "AttributeString"); + SALOMEDS::AttributeString_var aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr); + + TCollection_AsciiString aNewParams; + TCollection_AsciiString aOldParameters(aStringAttr->Value()); + TCollection_AsciiString anInputParams(ParseParameters(theParameters)); + + if(!hasAttr) + aNewParams = anInputParams; + else + aNewParams = aOldParameters+"|"+anInputParams; + + if(VARIABLE_DEBUG) + { + cout<<"Input Parameters : "<SetValue( aNewParams.ToCString() ); +} + +//======================================================================= +//function : ParseParameters +//purpose : +//======================================================================= +char* SMESH_Gen_i::ParseParameters(const char* theParameters) +{ + const char* aParameters = CORBA::string_dup(theParameters); + TCollection_AsciiString anInputParams; + SALOMEDS::Study_ptr aStudy = GetCurrentStudy(); + if( !aStudy->_is_nil() ) { + SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters); + for(int j=0;jlength();j++) { + SALOMEDS::ListOfStrings aVars= aSections[j]; + for(int i=0;iIsVariable(aVars[i].in()) ? + TCollection_AsciiString(aVars[i].in()) : TCollection_AsciiString(""); + if(i != aVars.length()-1) + anInputParams+=":"; + } + if(j!=aSections->length()-1) + anInputParams+="|"; + } + } + return CORBA::string_dup(anInputParams.ToCString()); +} + +//======================================================================= +//function : GetParameters +//purpose : +//======================================================================= +char* SMESH_Gen_i::GetParameters(CORBA::Object_ptr theObject) +{ + TCollection_AsciiString aResult; + + SALOMEDS::Study_ptr aStudy = GetCurrentStudy(); + SALOMEDS::SObject_var aSObj = ObjectToSObject(aStudy,theObject); + + if(!aStudy->_is_nil() && + !CORBA::is_nil(theObject) && + !aSObj->_is_nil()){ + + SALOMEDS::GenericAttribute_var anAttr; + if ( aSObj->FindAttribute(anAttr, "AttributeString")) { + aResult = TCollection_AsciiString(SALOMEDS::AttributeString::_narrow(anAttr)->Value()); + } + } + + return CORBA::string_dup( aResult.ToCString() ); +} diff --git a/src/SMESH_I/SMESH_Hypothesis_i.cxx b/src/SMESH_I/SMESH_Hypothesis_i.cxx index 95a8c48a2..b677e647b 100644 --- a/src/SMESH_I/SMESH_Hypothesis_i.cxx +++ b/src/SMESH_I/SMESH_Hypothesis_i.cxx @@ -28,6 +28,7 @@ #include #include #include "SMESH_Hypothesis_i.hxx" +#include "SMESH_Gen_i.hxx" #include "utilities.h" using namespace std; @@ -120,6 +121,120 @@ CORBA::Long SMESH_Hypothesis_i::GetId() return myBaseImpl->GetID(); } +//============================================================================= +/*! + * SMESH_Hypothesis_i::IsPublished() + * + */ +//============================================================================= +bool SMESH_Hypothesis_i::IsPublished(){ + bool res = false; + SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen(); + if(gen){ + SALOMEDS::SObject_var SO = + SMESH_Gen_i::ObjectToSObject(gen->GetCurrentStudy() , SMESH::SMESH_Hypothesis::_narrow(_this())); + res = !SO->_is_nil(); + } + return res; +} + +//============================================================================= +/*! + * SMESH_Hypothesis_i::SetParameters() + * + */ +//============================================================================= +void SMESH_Hypothesis_i::SetParameters(const char* theParameters) +{ + SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen(); + char * aParameters = CORBA::string_dup(theParameters); + if(gen){ + if(IsPublished()) { + SMESH_Gen_i::GetSMESHGen()->UpdateParameters(SMESH::SMESH_Hypothesis::_narrow(_this()),aParameters); + } + else { + myBaseImpl->SetParameters(gen->ParseParameters(aParameters)); + } + } +} + +//============================================================================= +/*! + * SMESH_Hypothesis_i::GetParameters() + * + */ +//============================================================================= +char* SMESH_Hypothesis_i::GetParameters() +{ + SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen(); + char* aResult; + if(IsPublished()) { + MESSAGE("SMESH_Hypothesis_i::GetParameters() : Get Parameters from SObject"); + aResult = gen->GetParameters(SMESH::SMESH_Hypothesis::_narrow(_this())); + } + else { + MESSAGE("SMESH_Hypothesis_i::GetParameters() : Get local parameters"); + aResult = myBaseImpl->GetParameters(); + } + return CORBA::string_dup(aResult); +} + +//============================================================================= +/*! + * SMESH_Hypothesis_i::GetLastParameters() + * + */ +//============================================================================= +SMESH::ListOfParameters* SMESH_Hypothesis_i::GetLastParameters() +{ + SMESH::ListOfParameters_var aResult = new SMESH::ListOfParameters(); + SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen(); + if(gen) { + char *aParameters; + if(IsPublished()) + aParameters = GetParameters(); + else + aParameters = myBaseImpl->GetLastParameters(); + + SALOMEDS::Study_ptr aStudy = gen->GetCurrentStudy(); + if(!aStudy->_is_nil()) { + SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters); + if(aSections->length() > 0) { + SALOMEDS::ListOfStrings aVars = aSections[aSections->length()-1]; + aResult->length(aVars.length()); + for(int i = 0;i < aVars.length();i++) + aResult[i] = CORBA::string_dup( aVars[i]); + } + } + } + return aResult._retn(); +} + +//============================================================================= +/*! + * SMESH_Hypothesis_i::SetLastParameters() + * + */ +//============================================================================= +void SMESH_Hypothesis_i::SetLastParameters(const char* theParameters) +{ + if(!IsPublished()) { + myBaseImpl->SetLastParameters(theParameters); + } +} +//============================================================================= +/*! + * SMESH_Hypothesis_i::ClearParameters() + * + */ +//============================================================================= +void SMESH_Hypothesis_i::ClearParameters() +{ + if(!IsPublished()) { + myBaseImpl->ClearParameters(); + } +} + //============================================================================= /*! * SMESH_Hypothesis_i::GetImpl diff --git a/src/SMESH_I/SMESH_Hypothesis_i.hxx b/src/SMESH_I/SMESH_Hypothesis_i.hxx index 944b1694c..13bd7742f 100644 --- a/src/SMESH_I/SMESH_Hypothesis_i.hxx +++ b/src/SMESH_I/SMESH_Hypothesis_i.hxx @@ -64,6 +64,25 @@ public: // Get unique id of hypothesis CORBA::Long GetId(); + + // Set list of parameters separated by ":" symbol, used for Hypothesis creation + void SetParameters (const char* theParameters); + + // Return list of notebook variables used for Hypothesis creation separated by ":" symbol + char* GetParameters(); + + //Return list of last notebook variables used for Hypothesis creation. + SMESH::ListOfParameters* GetLastParameters(); + + //Set last parameters for not published hypothesis + + void SetLastParameters(const char* theParameters); + + // Clear parameters list + void ClearParameters(); + + //Return true if hypothesis was published in study + bool IsPublished(); // Get implementation ::SMESH_Hypothesis* GetImpl(); diff --git a/src/SMESH_I/SMESH_MeshEditor_i.cxx b/src/SMESH_I/SMESH_MeshEditor_i.cxx index 9592ab843..8fb61b896 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.cxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx @@ -1351,12 +1351,13 @@ SMESH_MeshEditor_i::rotationSweep(const SMESH::long_array & theIDsOfElements, CORBA::Double theAngleInRadians, CORBA::Long theNbOfSteps, CORBA::Double theTolerance, - const bool theMakeGroups) + const bool theMakeGroups, + const SMDSAbs_ElementType theElementType) { initData(); TIDSortedElemSet inElements, copyElements; - arrayToSet(theIDsOfElements, GetMeshDS(), inElements); + arrayToSet(theIDsOfElements, GetMeshDS(), inElements, theElementType); TIDSortedElemSet* workElements = & inElements; TPreviewMesh tmpMesh( SMDSAbs_Face ); @@ -1399,10 +1400,9 @@ void SMESH_MeshEditor_i::RotationSweep(const SMESH::long_array & theIDsOfElement CORBA::Double theTolerance) { if ( !myPreviewMode ) { - TPythonDump() << "axis = " << theAxis; TPythonDump() << this << ".RotationSweep( " - << theIDsOfElements - << ", axis, " + << theIDsOfElements << ", " + << theAxis << ", " << theAngleInRadians << ", " << theNbOfSteps << ", " << theTolerance << " )"; @@ -1434,12 +1434,11 @@ SMESH_MeshEditor_i::RotationSweepMakeGroups(const SMESH::long_array& theIDsOfEle theTolerance, true); if ( !myPreviewMode ) { - TPythonDump()<< "axis = " << theAxis; TPythonDump aPythonDump; DumpGroupsList(aPythonDump,aGroups); aPythonDump<< this << ".RotationSweepMakeGroups( " - << theIDsOfElements - << ", axis, " + << theIDsOfElements << ", " + << theAxis << ", " << theAngleInRadians << ", " << theNbOfSteps << ", " << theTolerance << " )"; @@ -1459,10 +1458,9 @@ void SMESH_MeshEditor_i::RotationSweepObject(SMESH::SMESH_IDSource_ptr theObject CORBA::Double theTolerance) { if ( !myPreviewMode ) { - TPythonDump() << "axis = " << theAxis; TPythonDump() << this << ".RotationSweepObject( " - << theObject - << ", axis, " + << theObject << ", " + << theAxis << ", " << theAngleInRadians << ", " << theNbOfSteps << ", " << theTolerance << " )"; @@ -1476,6 +1474,64 @@ void SMESH_MeshEditor_i::RotationSweepObject(SMESH::SMESH_IDSource_ptr theObject false); } +//======================================================================= +//function : RotationSweepObject1D +//purpose : +//======================================================================= + +void SMESH_MeshEditor_i::RotationSweepObject1D(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::AxisStruct & theAxis, + CORBA::Double theAngleInRadians, + CORBA::Long theNbOfSteps, + CORBA::Double theTolerance) +{ + if ( !myPreviewMode ) { + TPythonDump() << this << ".RotationSweepObject1D( " + << theObject << ", " + << theAxis << ", " + << theAngleInRadians << ", " + << theNbOfSteps << ", " + << theTolerance << " )"; + } + SMESH::long_array_var anElementsId = theObject->GetIDs(); + rotationSweep(anElementsId, + theAxis, + theAngleInRadians, + theNbOfSteps, + theTolerance, + false, + SMDSAbs_Edge); +} + +//======================================================================= +//function : RotationSweepObject2D +//purpose : +//======================================================================= + +void SMESH_MeshEditor_i::RotationSweepObject2D(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::AxisStruct & theAxis, + CORBA::Double theAngleInRadians, + CORBA::Long theNbOfSteps, + CORBA::Double theTolerance) +{ + if ( !myPreviewMode ) { + TPythonDump() << this << ".RotationSweepObject2D( " + << theObject << ", " + << theAxis << ", " + << theAngleInRadians << ", " + << theNbOfSteps << ", " + << theTolerance << " )"; + } + SMESH::long_array_var anElementsId = theObject->GetIDs(); + rotationSweep(anElementsId, + theAxis, + theAngleInRadians, + theNbOfSteps, + theTolerance, + false, + SMDSAbs_Face); +} + //======================================================================= //function : RotationSweepObjectMakeGroups //purpose : @@ -1496,12 +1552,77 @@ SMESH_MeshEditor_i::RotationSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr theO theTolerance, true); if ( !myPreviewMode ) { - TPythonDump() << "axis = " << theAxis; TPythonDump aPythonDump; DumpGroupsList(aPythonDump,aGroups); aPythonDump<< this << ".RotationSweepObjectMakeGroups( " - << theObject - << ", axis, " + << theObject << ", " + << theAxis << ", " + << theAngleInRadians << ", " + << theNbOfSteps << ", " + << theTolerance << " )"; + } + return aGroups; +} + +//======================================================================= +//function : RotationSweepObject1DMakeGroups +//purpose : +//======================================================================= + +SMESH::ListOfGroups* +SMESH_MeshEditor_i::RotationSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::AxisStruct& theAxis, + CORBA::Double theAngleInRadians, + CORBA::Long theNbOfSteps, + CORBA::Double theTolerance) +{ + SMESH::long_array_var anElementsId = theObject->GetIDs(); + SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId, + theAxis, + theAngleInRadians, + theNbOfSteps, + theTolerance, + true, + SMDSAbs_Edge); + if ( !myPreviewMode ) { + TPythonDump aPythonDump; + DumpGroupsList(aPythonDump,aGroups); + aPythonDump<< this << ".RotationSweepObject1DMakeGroups( " + << theObject << ", " + << theAxis << ", " + << theAngleInRadians << ", " + << theNbOfSteps << ", " + << theTolerance << " )"; + } + return aGroups; +} + +//======================================================================= +//function : RotationSweepObject2DMakeGroups +//purpose : +//======================================================================= + +SMESH::ListOfGroups* +SMESH_MeshEditor_i::RotationSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::AxisStruct& theAxis, + CORBA::Double theAngleInRadians, + CORBA::Long theNbOfSteps, + CORBA::Double theTolerance) +{ + SMESH::long_array_var anElementsId = theObject->GetIDs(); + SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId, + theAxis, + theAngleInRadians, + theNbOfSteps, + theTolerance, + true, + SMDSAbs_Face); + if ( !myPreviewMode ) { + TPythonDump aPythonDump; + DumpGroupsList(aPythonDump,aGroups); + aPythonDump<< this << ".RotationSweepObject2DMakeGroups( " + << theObject << ", " + << theAxis << ", " << theAngleInRadians << ", " << theNbOfSteps << ", " << theTolerance << " )"; @@ -1561,9 +1682,8 @@ void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElemen { extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, false ); if ( !myPreviewMode ) { - TPythonDump() << "stepVector = " << theStepVector; TPythonDump() << this << ".ExtrusionSweep( " - << theIDsOfElements << ", stepVector, " << theNbOfSteps << " )"; + << theIDsOfElements << ", " << theStepVector <<", " << theNbOfSteps << " )"; } } @@ -1580,9 +1700,8 @@ void SMESH_MeshEditor_i::ExtrusionSweepObject(SMESH::SMESH_IDSource_ptr theObjec SMESH::long_array_var anElementsId = theObject->GetIDs(); extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false ); if ( !myPreviewMode ) { - TPythonDump() << "stepVector = " << theStepVector; TPythonDump() << this << ".ExtrusionSweepObject( " - << theObject << ", stepVector, " << theNbOfSteps << " )"; + << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )"; } } @@ -1598,9 +1717,8 @@ void SMESH_MeshEditor_i::ExtrusionSweepObject1D(SMESH::SMESH_IDSource_ptr theObj SMESH::long_array_var anElementsId = theObject->GetIDs(); extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Edge ); if ( !myPreviewMode ) { - TPythonDump() << "stepVector = " << theStepVector; TPythonDump() << this << ".ExtrusionSweepObject1D( " - << theObject << ", stepVector, " << theNbOfSteps << " )"; + << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )"; } } @@ -1616,9 +1734,8 @@ void SMESH_MeshEditor_i::ExtrusionSweepObject2D(SMESH::SMESH_IDSource_ptr theObj SMESH::long_array_var anElementsId = theObject->GetIDs(); extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false, SMDSAbs_Face ); if ( !myPreviewMode ) { - TPythonDump() << "stepVector = " << theStepVector; TPythonDump() << this << ".ExtrusionSweepObject2D( " - << theObject << ", stepVector, " << theNbOfSteps << " )"; + << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )"; } } @@ -1635,11 +1752,10 @@ SMESH_MeshEditor_i::ExtrusionSweepMakeGroups(const SMESH::long_array& theIDsOfEl SMESH::ListOfGroups* aGroups = extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, true ); if ( !myPreviewMode ) { - TPythonDump() << "stepVector = " << theStepVector; TPythonDump aPythonDump; DumpGroupsList(aPythonDump,aGroups); aPythonDump << this << ".ExtrusionSweepMakeGroups( " - << theIDsOfElements << ", stepVector, " << theNbOfSteps << " )"; + << theIDsOfElements << ", " << theStepVector <<", " << theNbOfSteps << " )"; } return aGroups; } @@ -1657,11 +1773,10 @@ SMESH_MeshEditor_i::ExtrusionSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr the SMESH::ListOfGroups * aGroups = extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true ); if ( !myPreviewMode ) { - TPythonDump() << "stepVector = " << theStepVector; TPythonDump aPythonDump; DumpGroupsList(aPythonDump,aGroups); aPythonDump<< this << ".ExtrusionSweepObjectMakeGroups( " - << theObject << ", stepVector, " << theNbOfSteps << " )"; + << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )"; } return aGroups; } @@ -1679,11 +1794,10 @@ SMESH_MeshEditor_i::ExtrusionSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr t SMESH::long_array_var anElementsId = theObject->GetIDs(); SMESH::ListOfGroups * aGroups = extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true, SMDSAbs_Edge ); if ( !myPreviewMode ) { - TPythonDump() << "stepVector = " << theStepVector; TPythonDump aPythonDump; DumpGroupsList(aPythonDump,aGroups); aPythonDump << this << ".ExtrusionSweepObject1DMakeGroups( " - << theObject << ", stepVector, " << theNbOfSteps << " )"; + << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )"; } return aGroups; } @@ -1701,11 +1815,10 @@ SMESH_MeshEditor_i::ExtrusionSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr t SMESH::long_array_var anElementsId = theObject->GetIDs(); SMESH::ListOfGroups * aGroups = extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true, SMDSAbs_Face ); if ( !myPreviewMode ) { - TPythonDump() << "stepVector = " << theStepVector; TPythonDump aPythonDump; DumpGroupsList(aPythonDump,aGroups); aPythonDump << this << ".ExtrusionSweepObject2DMakeGroups( " - << theObject << ", stepVector, " << theNbOfSteps << " )"; + << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )"; } return aGroups; } @@ -1842,7 +1955,8 @@ SMESH_MeshEditor_i::extrusionAlongPath(const SMESH::long_array & theIDsOfEleme CORBA::Boolean theHasRefPoint, const SMESH::PointStruct & theRefPoint, const bool theMakeGroups, - SMESH::SMESH_MeshEditor::Extrusion_Error & theError) + SMESH::SMESH_MeshEditor::Extrusion_Error & theError, + const SMDSAbs_ElementType theElementType) { initData(); @@ -1867,7 +1981,7 @@ SMESH_MeshEditor_i::extrusionAlongPath(const SMESH::long_array & theIDsOfEleme } TIDSortedElemSet elements; - arrayToSet(theIDsOfElements, GetMeshDS(), elements); + arrayToSet(theIDsOfElements, GetMeshDS(), elements, theElementType); list angles; for (int i = 0; i < theAngles.length(); i++) { @@ -1912,24 +2026,18 @@ SMESH::SMESH_MeshEditor::Extrusion_Error const SMESH::PointStruct & theRefPoint) { if ( !myPreviewMode ) { - TPythonDump() << "rotAngles = " << theAngles; - - if ( theHasRefPoint ) - TPythonDump() << "refPoint = SMESH.PointStruct( " - << theRefPoint.x << ", " - << theRefPoint.y << ", " - << theRefPoint.z << " )"; - else - TPythonDump() << "refPoint = SMESH.PointStruct( 0,0,0 )"; - TPythonDump() << "error = " << this << ".ExtrusionAlongPath( " << theIDsOfElements << ", " << thePathMesh << ", " << thePathShape << ", " << theNodeStart << ", " << theHasAngles << ", " - << "rotAngles" << ", " - << theHasRefPoint << ", refPoint )"; + << theAngles << ", " + << theHasRefPoint << ", " + << "SMESH.PointStruct( " + << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", " + << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", " + << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )"; } SMESH::SMESH_MeshEditor::Extrusion_Error anError; extrusionAlongPath( theIDsOfElements, @@ -1961,24 +2069,18 @@ SMESH_MeshEditor_i::ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr theObje const SMESH::PointStruct & theRefPoint) { if ( !myPreviewMode ) { - TPythonDump() << "rotAngles = " << theAngles; - - if ( theHasRefPoint ) - TPythonDump() << "refPoint = SMESH.PointStruct( " - << theRefPoint.x << ", " - << theRefPoint.y << ", " - << theRefPoint.z << " )"; - else - TPythonDump() << "refPoint = SMESH.PointStruct( 0,0,0 )"; - TPythonDump() << "error = " << this << ".ExtrusionAlongPathObject( " << theObject << ", " << thePathMesh << ", " << thePathShape << ", " << theNodeStart << ", " << theHasAngles << ", " - << "rotAngles" << ", " - << theHasRefPoint << ", refPoint )"; + << theAngles << ", " + << theHasRefPoint << ", " + << "SMESH.PointStruct( " + << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", " + << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", " + << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )"; } SMESH::SMESH_MeshEditor::Extrusion_Error anError; SMESH::long_array_var anElementsId = theObject->GetIDs(); @@ -1995,6 +2097,96 @@ SMESH_MeshEditor_i::ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr theObje return anError; } +//======================================================================= +//function : ExtrusionAlongPathObject1D +//purpose : +//======================================================================= + +SMESH::SMESH_MeshEditor::Extrusion_Error +SMESH_MeshEditor_i::ExtrusionAlongPathObject1D(SMESH::SMESH_IDSource_ptr theObject, + SMESH::SMESH_Mesh_ptr thePathMesh, + GEOM::GEOM_Object_ptr thePathShape, + CORBA::Long theNodeStart, + CORBA::Boolean theHasAngles, + const SMESH::double_array & theAngles, + CORBA::Boolean theHasRefPoint, + const SMESH::PointStruct & theRefPoint) +{ + if ( !myPreviewMode ) { + TPythonDump() << "error = " << this << ".ExtrusionAlongPathObject1D( " + << theObject << ", " + << thePathMesh << ", " + << thePathShape << ", " + << theNodeStart << ", " + << theHasAngles << ", " + << theAngles << ", " + << theHasRefPoint << ", " + << "SMESH.PointStruct( " + << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", " + << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", " + << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )"; + } + SMESH::SMESH_MeshEditor::Extrusion_Error anError; + SMESH::long_array_var anElementsId = theObject->GetIDs(); + extrusionAlongPath( anElementsId, + thePathMesh, + thePathShape, + theNodeStart, + theHasAngles, + theAngles, + theHasRefPoint, + theRefPoint, + false, + anError, + SMDSAbs_Edge); + return anError; +} + +//======================================================================= +//function : ExtrusionAlongPathObject2D +//purpose : +//======================================================================= + +SMESH::SMESH_MeshEditor::Extrusion_Error +SMESH_MeshEditor_i::ExtrusionAlongPathObject2D(SMESH::SMESH_IDSource_ptr theObject, + SMESH::SMESH_Mesh_ptr thePathMesh, + GEOM::GEOM_Object_ptr thePathShape, + CORBA::Long theNodeStart, + CORBA::Boolean theHasAngles, + const SMESH::double_array & theAngles, + CORBA::Boolean theHasRefPoint, + const SMESH::PointStruct & theRefPoint) +{ + if ( !myPreviewMode ) { + TPythonDump() << "error = " << this << ".ExtrusionAlongPathObject2D( " + << theObject << ", " + << thePathMesh << ", " + << thePathShape << ", " + << theNodeStart << ", " + << theHasAngles << ", " + << theAngles << ", " + << theHasRefPoint << ", " + << "SMESH.PointStruct( " + << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", " + << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", " + << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )"; + } + SMESH::SMESH_MeshEditor::Extrusion_Error anError; + SMESH::long_array_var anElementsId = theObject->GetIDs(); + extrusionAlongPath( anElementsId, + thePathMesh, + thePathShape, + theNodeStart, + theHasAngles, + theAngles, + theHasRefPoint, + theRefPoint, + false, + anError, + SMDSAbs_Face); + return anError; +} + //======================================================================= //function : ExtrusionAlongPathMakeGroups @@ -2023,16 +2215,6 @@ SMESH_MeshEditor_i::ExtrusionAlongPathMakeGroups(const SMESH::long_array& theI true, Error); if ( !myPreviewMode ) { - TPythonDump() << "rotAngles = " << theAngles; - - if ( theHasRefPoint ) - TPythonDump() << "refPoint = SMESH.PointStruct( " - << theRefPoint.x << ", " - << theRefPoint.y << ", " - << theRefPoint.z << " )"; - else - TPythonDump() << "refPoint = SMESH.PointStruct( 0,0,0 )"; - bool isDumpGroups = aGroups && aGroups->length() > 0; TPythonDump aPythonDump; if(isDumpGroups) { @@ -2049,8 +2231,12 @@ SMESH_MeshEditor_i::ExtrusionAlongPathMakeGroups(const SMESH::long_array& theI << thePathShape << ", " << theNodeStart << ", " << theHasAngles << ", " - << "rotAngles" << ", " - << theHasRefPoint << ", refPoint )"; + << theAngles << ", " + << theHasRefPoint << ", " + << "SMESH.PointStruct( " + << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", " + << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", " + << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )"; } return aGroups; } @@ -2084,16 +2270,118 @@ ExtrusionAlongPathObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject, Error); if ( !myPreviewMode ) { - TPythonDump() << "rotAngles = " << theAngles; + bool isDumpGroups = aGroups && aGroups->length() > 0; + TPythonDump aPythonDump; + if(isDumpGroups) { + aPythonDump << "("<GetIDs(); + SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId, + thePathMesh, + thePathShape, + theNodeStart, + theHasAngles, + theAngles, + theHasRefPoint, + theRefPoint, + true, + Error, + SMDSAbs_Edge); + + if ( !myPreviewMode ) { + bool isDumpGroups = aGroups && aGroups->length() > 0; + TPythonDump aPythonDump; + if(isDumpGroups) { + aPythonDump << "("<GetIDs(); + SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId, + thePathMesh, + thePathShape, + theNodeStart, + theHasAngles, + theAngles, + theHasRefPoint, + theRefPoint, + true, + Error, + SMDSAbs_Face); + + if ( !myPreviewMode ) { bool isDumpGroups = aGroups && aGroups->length() > 0; TPythonDump aPythonDump; if(isDumpGroups) { @@ -2104,14 +2392,18 @@ ExtrusionAlongPathObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject, else aPythonDump <<"error"; - aPythonDump << " = " << this << ".ExtrusionAlongPathObjectMakeGroups( " + aPythonDump << " = " << this << ".ExtrusionAlongPathObject2DMakeGroups( " << theObject << ", " << thePathMesh << ", " << thePathShape << ", " << theNodeStart << ", " << theHasAngles << ", " - << "rotAngles" << ", " - << theHasRefPoint << ", refPoint )"; + << theAngles << ", " + << theHasRefPoint << ", " + << "SMESH.PointStruct( " + << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", " + << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", " + << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ) )"; } return aGroups; } @@ -2285,12 +2577,11 @@ SMESH_MeshEditor_i::MirrorMakeGroups(const SMESH::long_array& theIDsO { SMESH::ListOfGroups * aGroups = mirror(theIDsOfElements, theMirror, theMirrorType, true, true); if ( !myPreviewMode ) { - TPythonDump()<<"axis = "<GetIDs(); SMESH::ListOfGroups * aGroups = mirror(anElementsId, theMirror, theMirrorType, true, true); if ( !myPreviewMode ) { - TPythonDump()<<"axis = "<GetIDs(); @@ -2495,12 +2784,11 @@ SMESH_MeshEditor_i::TranslateMakeGroups(const SMESH::long_array& theIDsOfElement { SMESH::ListOfGroups * aGroups = translate(theIDsOfElements,theVector,true,true); if ( !myPreviewMode ) { - TPythonDump() << "vector = " << theVector; TPythonDump aPythonDump; DumpGroupsList(aPythonDump,aGroups); aPythonDump << this << ".TranslateMakeGroups( " - << theIDsOfElements - << ", vector )"; + << theIDsOfElements << ", " + << theVector << " )"; } return aGroups; } @@ -2519,12 +2807,11 @@ SMESH_MeshEditor_i::TranslateObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObjec if ( !myPreviewMode ) { - TPythonDump() << "vector = " << theVector; TPythonDump aPythonDump; DumpGroupsList(aPythonDump,aGroups); aPythonDump << this << ".TranslateObjectMakeGroups( " - << theObject - << ", vector )"; + << theObject << ", " + << theVector << " )"; } return aGroups; } @@ -2660,10 +2947,9 @@ void SMESH_MeshEditor_i::Rotate(const SMESH::long_array & theIDsOfElements, CORBA::Boolean theCopy) { if ( !myPreviewMode ) { - TPythonDump() << "axis = " << theAxis; TPythonDump() << this << ".Rotate( " - << theIDsOfElements - << ", axis, " + << theIDsOfElements << ", " + << theAxis << ", " << theAngle << ", " << theCopy << " )"; } @@ -2685,10 +2971,9 @@ void SMESH_MeshEditor_i::RotateObject(SMESH::SMESH_IDSource_ptr theObject, CORBA::Boolean theCopy) { if ( !myPreviewMode ) { - TPythonDump() << "axis = " << theAxis; TPythonDump() << this << ".RotateObject( " - << theObject - << ", axis, " + << theObject << ", " + << theAxis << ", " << theAngle << ", " << theCopy << " )"; } @@ -2712,12 +2997,11 @@ SMESH_MeshEditor_i::RotateMakeGroups(const SMESH::long_array& theIDsOfElements, { SMESH::ListOfGroups * aGroups = rotate(theIDsOfElements,theAxis,theAngle,true,true); if ( !myPreviewMode ) { - TPythonDump() << "axis = " << theAxis; TPythonDump aPythonDump; DumpGroupsList(aPythonDump,aGroups); aPythonDump << this << ".RotateMakeGroups( " - << theIDsOfElements - << ", axis, " + << theIDsOfElements << ", " + << theAxis << ", " << theAngle << " )"; } return aGroups; @@ -2737,13 +3021,12 @@ SMESH_MeshEditor_i::RotateObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject, SMESH::ListOfGroups * aGroups = rotate(anElementsId,theAxis,theAngle,true,true); if ( !myPreviewMode ) { - TPythonDump() << "axis = " << theAxis; TPythonDump aPythonDump; DumpGroupsList(aPythonDump,aGroups); aPythonDump << this << ".RotateObjectMakeGroups( " - << theObject - << ", axis, " - << theAngle << " )"; + << theObject << ", " + << theAxis << ", " + << theAngle << " )"; } return aGroups; } diff --git a/src/SMESH_I/SMESH_MeshEditor_i.hxx b/src/SMESH_I/SMESH_MeshEditor_i.hxx index eff6e21e4..b127f2f89 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.hxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.hxx @@ -181,6 +181,16 @@ class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor CORBA::Double AngleInRadians, CORBA::Long NbOfSteps, CORBA::Double Tolerance); + void RotationSweepObject1D(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::AxisStruct & Axis, + CORBA::Double AngleInRadians, + CORBA::Long NbOfSteps, + CORBA::Double Tolerance); + void RotationSweepObject2D(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::AxisStruct & Axis, + CORBA::Double AngleInRadians, + CORBA::Long NbOfSteps, + CORBA::Double Tolerance); void ExtrusionSweep(const SMESH::long_array & IDsOfElements, const SMESH::DirStruct & StepVector, @@ -219,6 +229,24 @@ class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor const SMESH::double_array & Angles, CORBA::Boolean HasRefPoint, const SMESH::PointStruct & RefPoint); + SMESH::SMESH_MeshEditor::Extrusion_Error + ExtrusionAlongPathObject1D(SMESH::SMESH_IDSource_ptr theObject, + SMESH::SMESH_Mesh_ptr PathMesh, + GEOM::GEOM_Object_ptr PathShape, + CORBA::Long NodeStart, + CORBA::Boolean HasAngles, + const SMESH::double_array & Angles, + CORBA::Boolean HasRefPoint, + const SMESH::PointStruct & RefPoint); + SMESH::SMESH_MeshEditor::Extrusion_Error + ExtrusionAlongPathObject2D(SMESH::SMESH_IDSource_ptr theObject, + SMESH::SMESH_Mesh_ptr PathMesh, + GEOM::GEOM_Object_ptr PathShape, + CORBA::Long NodeStart, + CORBA::Boolean HasAngles, + const SMESH::double_array & Angles, + CORBA::Boolean HasRefPoint, + const SMESH::PointStruct & RefPoint); SMESH::double_array* LinearAnglesVariation(SMESH::SMESH_Mesh_ptr PathMesh, GEOM::GEOM_Object_ptr PathShape, @@ -257,6 +285,16 @@ class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor CORBA::Double AngleInRadians, CORBA::Long NbOfSteps, CORBA::Double Tolerance); + SMESH::ListOfGroups* RotationSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr Object, + const SMESH::AxisStruct& Axix, + CORBA::Double AngleInRadians, + CORBA::Long NbOfSteps, + CORBA::Double Tolerance); + SMESH::ListOfGroups* RotationSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr Object, + const SMESH::AxisStruct& Axix, + CORBA::Double AngleInRadians, + CORBA::Long NbOfSteps, + CORBA::Double Tolerance); SMESH::ListOfGroups* ExtrusionSweepMakeGroups(const SMESH::long_array& IDsOfElements, const SMESH::DirStruct& StepVector, CORBA::Long NbOfSteps); @@ -292,6 +330,24 @@ class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor CORBA::Boolean HasRefPoint, const SMESH::PointStruct& RefPoint, SMESH::SMESH_MeshEditor::Extrusion_Error& Error); + SMESH::ListOfGroups* ExtrusionAlongPathObject1DMakeGroups(SMESH::SMESH_IDSource_ptr Object, + SMESH::SMESH_Mesh_ptr PathMesh, + GEOM::GEOM_Object_ptr PathShape, + CORBA::Long NodeStart, + CORBA::Boolean HasAngles, + const SMESH::double_array& Angles, + CORBA::Boolean HasRefPoint, + const SMESH::PointStruct& RefPoint, + SMESH::SMESH_MeshEditor::Extrusion_Error& Error); + SMESH::ListOfGroups* ExtrusionAlongPathObject2DMakeGroups(SMESH::SMESH_IDSource_ptr Object, + SMESH::SMESH_Mesh_ptr PathMesh, + GEOM::GEOM_Object_ptr PathShape, + CORBA::Long NodeStart, + CORBA::Boolean HasAngles, + const SMESH::double_array& Angles, + CORBA::Boolean HasRefPoint, + const SMESH::PointStruct& RefPoint, + SMESH::SMESH_MeshEditor::Extrusion_Error& Error); SMESH::ListOfGroups* MirrorMakeGroups(const SMESH::long_array& IDsOfElements, const SMESH::AxisStruct& Mirror, SMESH::SMESH_MeshEditor::MirrorType MirrorType); @@ -454,7 +510,8 @@ private: //!< private methods CORBA::Double AngleInRadians, CORBA::Long NbOfSteps, CORBA::Double Tolerance, - const bool MakeGroups); + const bool MakeGroups, + const SMDSAbs_ElementType ElementType=SMDSAbs_All); SMESH::ListOfGroups* extrusionSweep(const SMESH::long_array & IDsOfElements, const SMESH::DirStruct & StepVector, CORBA::Long NbOfSteps, @@ -475,7 +532,8 @@ private: //!< private methods CORBA::Boolean HasRefPoint, const SMESH::PointStruct & RefPoint, const bool MakeGroups, - SMESH::SMESH_MeshEditor::Extrusion_Error & Error); + SMESH::SMESH_MeshEditor::Extrusion_Error & Error, + const SMDSAbs_ElementType ElementType=SMDSAbs_All); SMESH::ListOfGroups* mirror(const SMESH::long_array & IDsOfElements, const SMESH::AxisStruct & Axis, SMESH::SMESH_MeshEditor::MirrorType MirrorType, diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index f38ecd1fc..04697f7d4 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -3112,3 +3112,50 @@ void SMESH_Mesh_i::checkGroupNames() aGrp->SetName( guiName ); } } + +//============================================================================= +/*! + * \brief Sets list of notebook variables used for Mesh operations separated by ":" symbol + */ +//============================================================================= +void SMESH_Mesh_i::SetParameters(const char* theParameters) +{ + SMESH_Gen_i::GetSMESHGen()->UpdateParameters(SMESH::SMESH_Mesh::_narrow(_this()), + CORBA::string_dup(theParameters)); +} + +//============================================================================= +/*! + * \brief Returns list of notebook variables used for Mesh operations separated by ":" symbol + */ +//============================================================================= +char* SMESH_Mesh_i::GetParameters() +{ + SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen(); + return CORBA::string_dup(gen->GetParameters(SMESH::SMESH_Mesh::_narrow(_this()))); +} + +//============================================================================= +/*! + * \brief Returns list of notebook variables used for last Mesh operation + */ +//============================================================================= +SMESH::string_array* SMESH_Mesh_i::GetLastParameters() +{ + SMESH::string_array_var aResult = new SMESH::string_array(); + SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen(); + if(gen) { + char *aParameters = GetParameters(); + SALOMEDS::Study_ptr aStudy = gen->GetCurrentStudy(); + if(!aStudy->_is_nil()) { + SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters); + if(aSections->length() > 0) { + SALOMEDS::ListOfStrings aVars = aSections[aSections->length()-1]; + aResult->length(aVars.length()); + for(int i = 0;i < aVars.length();i++) + aResult[i] = CORBA::string_dup( aVars[i]); + } + } + } + return aResult._retn(); +} diff --git a/src/SMESH_I/SMESH_Mesh_i.hxx b/src/SMESH_I/SMESH_Mesh_i.hxx index a0cd6a7d9..32fe2153d 100644 --- a/src/SMESH_I/SMESH_Mesh_i.hxx +++ b/src/SMESH_I/SMESH_Mesh_i.hxx @@ -468,6 +468,21 @@ public: */ virtual SALOME_MED::MedFileInfo* GetMEDFileInfo(); + /*! + * Sets list of notebook variables used for Mesh operations separated by ":" symbol + */ + void SetParameters (const char* theParameters); + + /*! + * Returns list of notebook variables used for Mesh operations separated by ":" symbol + */ + char* GetParameters(); + + /*! + * Returns list of notebook variables used for last Mesh operation + */ + SMESH::string_array* GetLastParameters(); + std::map _mapSubMesh_i; //NRI std::map _mapSubMesh; //NRI diff --git a/src/SMESH_I/SMESH_NoteBook.cxx b/src/SMESH_I/SMESH_NoteBook.cxx new file mode 100644 index 000000000..bd7268049 --- /dev/null +++ b/src/SMESH_I/SMESH_NoteBook.cxx @@ -0,0 +1,861 @@ +// Copyright (C) 2008 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : SMESH_NoteBook.cxx +// Author : Roman NIKOLAEV + +#include "SMESH_2smeshpy.hxx" +#include "SMESH_NoteBook.hxx" +#include "SMESH_Gen_i.hxx" +#include "SMESH_PythonDump.hxx" + +#include +#include +#include + +#include +#include + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + +using namespace std; + + +void SetVariable(Handle(_pyCommand) theCommand,const ObjectStates* theStates, int position, int theArgNb); + +//================================================================================ +/*! + * \brief Constructor + */ +//================================================================================ +ObjectStates::ObjectStates(TCollection_AsciiString theType) +{ + _type = theType; + _dumpstate = 0; +} + +//================================================================================ +/*! + * \brief Destructor + */ +//================================================================================ +ObjectStates::~ObjectStates() +{ +} + +//================================================================================ +/*! + * \brief Add new object state + * \param theState - Object state (vector of notebook variable) + */ +//================================================================================ +void ObjectStates::AddState(const TState &theState) +{ + _states.push_back(theState); +} + +//================================================================================ +/*! + * \brief Return current object state + * \\retval state - Object state (vector of notebook variable) + */ +//================================================================================ +TState ObjectStates::GetCurrectState() const +{ + if(_states.size() > _dumpstate) + return _states[_dumpstate]; + TState empty; + return empty; +} + + +//================================================================================ +/*! + * + */ +//================================================================================ +TAllStates ObjectStates::GetAllStates() const +{ + return _states; +} + +//================================================================================ +/*! + * + */ +//================================================================================ +void ObjectStates::IncrementState() +{ + _dumpstate++; +} + +//================================================================================ +/*! + * + */ +//================================================================================ +TCollection_AsciiString ObjectStates::GetObjectType() const{ + return _type; +} + + +//================================================================================ +/*! + * \brief Constructor + */ +//================================================================================ +LayerDistributionStates::LayerDistributionStates(): + ObjectStates("LayerDistribution") +{ +} +//================================================================================ +/*! + * \brief Destructor + */ +//================================================================================ +LayerDistributionStates::~LayerDistributionStates() +{ +} + + +//================================================================================ +/*! + * \brief AddDistribution + */ +//================================================================================ +void LayerDistributionStates::AddDistribution(const TCollection_AsciiString& theDistribution) +{ + _distributions.insert(pair(theDistribution,"")); +} + +//================================================================================ +/*! + * \brief HasDistribution + */ +//================================================================================ +bool LayerDistributionStates::HasDistribution(const TCollection_AsciiString& theDistribution) const +{ + return _distributions.find(theDistribution) != _distributions.end(); +} + +//================================================================================ +/*! + * \brief SetDistributionType + */ +//================================================================================ +bool LayerDistributionStates::SetDistributionType(const TCollection_AsciiString& theDistribution, + const TCollection_AsciiString& theType) +{ + TDistributionMap::iterator it = _distributions.find(theDistribution); + if(it == _distributions.end()) + return false; + (*it).second = theType; + return true; +} + +//================================================================================ +/*! + * \brief GetDistributionType + */ +//================================================================================ +TCollection_AsciiString LayerDistributionStates:: +GetDistributionType(const TCollection_AsciiString& theDistribution) const +{ + TDistributionMap::const_iterator it = _distributions.find(theDistribution); + return (it == _distributions.end()) ? TCollection_AsciiString() : (*it).second; +} + +//================================================================================ +/*! + * \brief Constructor + */ +//================================================================================ +SMESH_NoteBook::SMESH_NoteBook() +{ + InitObjectMap(); +} + +//================================================================================ +/*! + * \brief Destructor + */ +//================================================================================ +SMESH_NoteBook::~SMESH_NoteBook() +{ + TVariablesMap::const_iterator it = _objectMap.begin(); + for(;it!=_objectMap.end();it++) { + if((*it).second) + delete (*it).second; + } +} + +//================================================================================ +/*! + * \brief Replace parameters of the functions on the Salome NoteBook Variables + * \param theString - Input string + * \retval TCollection_AsciiString - Convertion result + */ +//================================================================================ +void SMESH_NoteBook::ReplaceVariables() +{ + for(int i=0;i<_commands.size();i++) { + Handle(_pyCommand) aCmd = _commands[i]; + TCollection_AsciiString aMethod = aCmd->GetMethod(); + TCollection_AsciiString aObject = aCmd->GetObject(); + TCollection_AsciiString aResultValue = aCmd->GetResultValue(); + if(MYDEBUG) { + cout<<"Command before : "<< aCmd->GetString()<GetArg(1)); + } + + if(it != _objectMap.end()) { + if(MYDEBUG) + cout << "Found object : " << (*it).first << endl; + ObjectStates *aStates = (*it).second; + // Case for LocalLength hypothesis + if(aStates->GetObjectType().IsEqual("LocalLength") && aStates->GetCurrectState().size() >= 2) { + if(aMethod.IsEqual("SetLength")) { + if(!aStates->GetCurrectState().at(0).IsEmpty() ) + aCmd->SetArg(1,aStates->GetCurrectState().at(0)); + aStates->IncrementState(); + } + else if(aMethod.IsEqual("SetPrecision")) { + if(!aStates->GetCurrectState().at(1).IsEmpty() ) + aCmd->SetArg(1,aStates->GetCurrectState().at(1)); + aStates->IncrementState(); + } + } + + // Case for SegmentLengthAroundVertex hypothesis + else if(aStates->GetObjectType().IsEqual("SegmentLengthAroundVertex") + && aStates->GetCurrectState().size() >= 1) { + if(aMethod == "SetLength") { + if(!aStates->GetCurrectState().at(0).IsEmpty() ) + aCmd->SetArg(1,aStates->GetCurrectState().at(0)); + aStates->IncrementState(); + } + } + + // Case for Arithmetic1D and StartEndLength hypothesis + else if(aStates->GetObjectType().IsEqual("Arithmetic1D") || + aStates->GetObjectType().IsEqual("StartEndLength")) { + if(aMethod == "SetLength" && + aStates->GetCurrectState().size() >= 2) { + if(aCmd->GetArg(2) == "1" && !aStates->GetCurrectState().at(0).IsEmpty()) + aCmd->SetArg(1,aStates->GetCurrectState().at(0)); + else if(!aStates->GetCurrectState().at(1).IsEmpty()) + aCmd->SetArg(1,aStates->GetCurrectState().at(1)); + aStates->IncrementState(); + } + } + + //Case for Deflection1D hypothesis + else if(aStates->GetObjectType().IsEqual("Deflection1D")){ + if(aMethod == "SetDeflection" && aStates->GetCurrectState().size() >= 1) { + if(!aStates->GetCurrectState().at(0).IsEmpty() ) + aCmd->SetArg(1,aStates->GetCurrectState().at(0)); + aStates->IncrementState(); + } + } + + // Case for LayerDistribution hypothesis (not finished yet) + else if(aStates->GetObjectType() == "LayerDistribution") { + if(aMethod == "SetLayerDistribution"){ + LayerDistributionStates* aLDStates = (LayerDistributionStates*)(aStates); + aLDStates->AddDistribution(aCmd->GetArg(1)); + if(MYDEBUG) + cout<<"Add Distribution :"<GetArg(1)<GetObjectType().IsEqual("MaxElementArea")){ + if(aMethod == "SetMaxElementArea" && aStates->GetCurrectState().size() >= 1) { + if(!aStates->GetCurrectState().at(0).IsEmpty() ) + aCmd->SetArg(1,aStates->GetCurrectState().at(0)); + aStates->IncrementState(); + } + } + + // Case for MaxElementVolume hypothesis + else if(aStates->GetObjectType().IsEqual("MaxElementVolume")){ + if(aMethod == "SetMaxElementVolume" && aStates->GetCurrectState().size() >= 1) { + if(!aStates->GetCurrectState().at(0).IsEmpty() ) + aCmd->SetArg(1,aStates->GetCurrectState().at(0)); + aStates->IncrementState(); + } + } + + // Case for NETGEN_Parameters_2D or NETGEN_Parameters_2D hypothesis + else if(aStates->GetObjectType().IsEqual("NETGEN_Parameters_2D") || + aStates->GetObjectType().IsEqual("NETGEN_Parameters")){ + if(aMethod == "SetMaxSize" && aStates->GetCurrectState().size() >= 1) { + if(!aStates->GetCurrectState().at(0).IsEmpty() ) + aCmd->SetArg(1,aStates->GetCurrectState().at(0)); + aStates->IncrementState(); + } + else if(aMethod == "SetGrowthRate" && aStates->GetCurrectState().size() >= 2) { + if(!aStates->GetCurrectState().at(1).IsEmpty() ) + aCmd->SetArg(1,aStates->GetCurrectState().at(1)); + aStates->IncrementState(); + } + else if(aMethod == "SetNbSegPerEdge" && aStates->GetCurrectState().size() >= 3) { + if(!aStates->GetCurrectState().at(2).IsEmpty() ) + aCmd->SetArg(1,aStates->GetCurrectState().at(2)); + aStates->IncrementState(); + } + else if(aMethod == "SetNbSegPerRadius" && aStates->GetCurrectState().size() >= 4) { + if(!aStates->GetCurrectState().at(3).IsEmpty() ) + aCmd->SetArg(1,aStates->GetCurrectState().at(3)); + aStates->IncrementState(); + } + } + + // Case for NETGEN_SimpleParameters_3D or NETGEN_SimpleParameters_2D hypothesis + else if(aStates->GetObjectType().IsEqual("NETGEN_SimpleParameters_3D") || + aStates->GetObjectType().IsEqual("NETGEN_SimpleParameters_2D")){ + + if((aMethod == "SetNumberOfSegments" || aMethod == "SetLocalLength") && + aStates->GetCurrectState().size() >= 1) { + if(!aStates->GetCurrectState().at(0).IsEmpty() ) + aCmd->SetArg(1,aStates->GetCurrectState().at(0)); + aStates->IncrementState(); + } + else if(aMethod == "SetMaxElementArea" && aStates->GetCurrectState().size() >= 2) { + if(!aStates->GetCurrectState().at(1).IsEmpty() ) + aCmd->SetArg(1,aStates->GetCurrectState().at(1)); + aStates->IncrementState(); + } + else if(aMethod == "SetMaxElementVolume" && aStates->GetCurrectState().size() >= 3) { + if(!aStates->GetCurrectState().at(2).IsEmpty() ) + aCmd->SetArg(1,aStates->GetCurrectState().at(2)); + aStates->IncrementState(); + } + else if(aMethod == "LengthFromEdges" || aMethod == "LengthFromFaces"){ + aStates->IncrementState(); + } + } + + // Case for NumberOfLayers hypothesis + else if(aStates->GetObjectType().IsEqual("NumberOfLayers")){ + if(aMethod == "SetNumberOfLayers" && aStates->GetCurrectState().size() >= 1) { + if(!aStates->GetCurrectState().at(0).IsEmpty() ) + aCmd->SetArg(1,aStates->GetCurrectState().at(0)); + aStates->IncrementState(); + } + } + + // Case for NumberOfSegments hypothesis + else if(aStates->GetObjectType().IsEqual("NumberOfSegments")){ + if(aMethod == "SetNumberOfSegments" && aStates->GetCurrectState().size() >= 1) { + if(!aStates->GetCurrectState().at(0).IsEmpty() ) + aCmd->SetArg(1,aStates->GetCurrectState().at(0)); + if(aStates->GetCurrectState().size()==1) + aStates->IncrementState(); + } + else if (aMethod == "SetScaleFactor" && aStates->GetCurrectState().size() >= 2) { + if(!aStates->GetCurrectState().at(1).IsEmpty() ) + aCmd->SetArg(1,aStates->GetCurrectState().at(1)); + aStates->IncrementState(); + } + } + + else if(aStates->GetObjectType().IsEqual("Mesh")) { + TState aCurrentState = aStates->GetCurrectState(); + int aCurrentStateSize = aCurrentState.size(); + if(aMethod.IsEqual("Translate") || + aMethod.IsEqual("TranslateMakeGroups") || + aMethod.IsEqual("TranslateMakeMesh") || + aMethod.IsEqual("TranslateObject") || + aMethod.IsEqual("TranslateObjectMakeGroups") || + aMethod.IsEqual("TranslateObjectMakeMesh")) { + bool isVariableFound = false; + int anArgIndex = 0; + for(int i = 1, n = aCmd->GetNbArgs(); i <= n; i++) { + if(aCmd->GetArg(i).IsEqual("SMESH.PointStruct")) { + anArgIndex = i+1; + break; + } + } + if(anArgIndex > 0) { + if(aCurrentStateSize == 3) { // translation by dx, dy, dz + for(int j = 0; j < aCurrentStateSize; j++) { + if(!aCurrentState.at(j).IsEmpty()) { + isVariableFound = true; + aCmd->SetArg(anArgIndex+j, aCurrentState.at(j)); + } + } + } + else if(aCurrentStateSize == 6) { // translation by x1, x2, y1, y2, z1, z2 + // TODO: limitation until operations on the variables will be introduced + /* + isVariableFound = true; + for(int j = 0; j < 3; j++) { + TCollection_AsciiString anArg = aCmd->GetArg(anArgIndex+j); + TCollection_AsciiString aValue1 = aCurrentState.at(2*j), aValue2 = aCurrentState.at(2*j+1); + bool aV1 = !aValue1.IsEmpty(); + bool aV2 = !aValue2.IsEmpty(); + double aValue, aCurrentValue = anArg.IsRealValue() ? anArg.RealValue() : 0; + if(aV1 && !aV2) { + if(!GetReal(aValue1, aValue)) + aValue = 0; + aValue2 = TCollection_AsciiString( aValue + aCurrentValue ); + } + else if(!aV1 && aV2) { + if(!GetReal(aValue2, aValue)) + aValue = 0; + aValue1 = TCollection_AsciiString( aValue - aCurrentValue ); + } + else if(!aV1 && !aV2) { + aValue1 = TCollection_AsciiString( 0 ); + aValue2 = TCollection_AsciiString( aCurrentValue ); + } + aCmd->SetArg(anArgIndex+j, aValue1 + ", " + aValue2 ); + } + */ + } + } + if(isVariableFound) { + TCollection_AsciiString aDim; + if(aCurrentStateSize == 6) + aDim = "6"; + aCmd->SetArg(anArgIndex - 1, TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".PointStructStr"+aDim); + aCmd->SetArg(anArgIndex - 2, TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".DirStructStr"); + } + aStates->IncrementState(); + } + else if(aMethod.IsEqual("Rotate") || + aMethod.IsEqual("RotateMakeGroups") || + aMethod.IsEqual("RotateMakeMesh") || + aMethod.IsEqual("RotateObject") || + aMethod.IsEqual("RotateObjectMakeGroups") || + aMethod.IsEqual("RotateObjectMakeMesh") || + aMethod.IsEqual("RotationSweep") || + aMethod.IsEqual("RotationSweepObject") || + aMethod.IsEqual("RotationSweepObject1D") || + aMethod.IsEqual("RotationSweepObject2D") || + aMethod.IsEqual("RotationSweepMakeGroups") || + aMethod.IsEqual("RotationSweepObjectMakeGroups") || + aMethod.IsEqual("RotationSweepObject1DMakeGroups") || + aMethod.IsEqual("RotationSweepObject2DMakeGroups") || + aMethod.IsEqual("Mirror") || + aMethod.IsEqual("MirrorMakeMesh") || + aMethod.IsEqual("MirrorMakeGroups") || + aMethod.IsEqual("MirrorObject") || + aMethod.IsEqual("MirrorObjectMakeMesh") || + aMethod.IsEqual("MirrorObjectMakeGroups")) { + bool isSubstitute = false; + int anArgIndex = 0; + for(int i = 1, n = aCmd->GetNbArgs(); i <= n; i++) { + if(aCmd->GetArg(i).IsEqual("SMESH.AxisStruct")) { + anArgIndex = i+1; + break; + } + } + if(anArgIndex > 0) { + for(int j = 0; j < aCurrentStateSize; j++) { + if(!aCurrentState.at(j).IsEmpty()) { + if(j < 6) // 0-5 - axis struct, 6 - angle (rotation & sweep), 7-8 - nbSteps and tolerance (sweep) + isSubstitute = true; + aCmd->SetArg(anArgIndex+j, aCurrentState.at(j)); + } + } + } + if(isSubstitute) + aCmd->SetArg(anArgIndex - 1, TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".AxisStructStr"); + aStates->IncrementState(); + } + else if(aMethod.IsEqual("AddNode") || + aMethod.IsEqual("MoveClosestNodeToPoint")) { + for(int j = 0; j < aCurrentStateSize; j++) { + if(!aCurrentState.at(j).IsEmpty()) + aCmd->SetArg(j+1, aCurrentState.at(j)); + } + aStates->IncrementState(); + } + else if(aMethod.IsEqual("MoveNode")) { + for(int j = 0; j < aCurrentStateSize; j++) { + if(!aCurrentState.at(j).IsEmpty()) + aCmd->SetArg(j+2, aCurrentState.at(j)); + } + aStates->IncrementState(); + } + else if(aMethod.IsEqual("ExtrusionSweep") || + aMethod.IsEqual("ExtrusionSweepObject") || + aMethod.IsEqual("ExtrusionSweepObject1D") || + aMethod.IsEqual("ExtrusionSweepObject2D") || + aMethod.IsEqual("ExtrusionSweepMakeGroups") || + aMethod.IsEqual("ExtrusionSweepObjectMakeGroups") || + aMethod.IsEqual("ExtrusionSweepObject1DMakeGroups") || + aMethod.IsEqual("ExtrusionSweepObject2DMakeGroups")) { + bool isSubstitute = false; + int anArgIndex = 0; + for(int i = 1, n = aCmd->GetNbArgs(); i <= n; i++) { + if(aCmd->GetArg(i).IsEqual("SMESH.PointStruct")) { + anArgIndex = i+1; + break; + } + } + if(anArgIndex > 0) { + for(int j = 0; j < aCurrentStateSize; j++) { + if(!aCurrentState.at(j).IsEmpty()) { + if(j < 3) // 0-2 - dir struct, 3 - number of steps + isSubstitute = true; + aCmd->SetArg(anArgIndex+j, aCurrentState.at(j)); + } + } + } + if(isSubstitute) { + aCmd->SetArg(anArgIndex - 1, TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".PointStructStr"); + aCmd->SetArg(anArgIndex - 2, TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".DirStructStr"); + } + aStates->IncrementState(); + } + else if(aMethod.IsEqual("ExtrusionAlongPath") || + aMethod.IsEqual("ExtrusionAlongPathObject") || + aMethod.IsEqual("ExtrusionAlongPathObject1D") || + aMethod.IsEqual("ExtrusionAlongPathObject2D") || + aMethod.IsEqual("ExtrusionAlongPathMakeGroups") || + aMethod.IsEqual("ExtrusionAlongPathObjectMakeGroups") || + aMethod.IsEqual("ExtrusionAlongPathObject1DMakeGroups") || + aMethod.IsEqual("ExtrusionAlongPathObject2DMakeGroups") || + /* workaround for a bug in the command parsing algorithm */ + aCmd->GetString().Search("ExtrusionAlongPathMakeGroups") != -1 || + aCmd->GetString().Search("ExtrusionAlongPathObjectMakeGroups") != -1 || + aCmd->GetString().Search("ExtrusionAlongPathObject1DMakeGroups") != -1 || + aCmd->GetString().Search("ExtrusionAlongPathObject2DMakeGroups") != -1 ) { + int aNbAngles = aCurrentStateSize-3; // State looks like "Angle1:...:AngleN:X:Y:Z" + bool isSubstitute = false; + int anArgIndex = 0; + for(int i = 1, n = aCmd->GetNbArgs(); i <= n; i++) { + if(aCmd->GetArg(i).IsEqual("SMESH.PointStruct")) { + anArgIndex = i-1-aNbAngles; + break; + } + } + if(anArgIndex > 0) { + int j = 0; + for(; j < aNbAngles; j++) { + if(!aCurrentState.at(j).IsEmpty()) { + aCmd->SetArg(anArgIndex+j-1, aCurrentState.at(j)); + } + } + for(; j < aNbAngles+3; j++) { + if(!aCurrentState.at(j).IsEmpty()) { + isSubstitute = true; + aCmd->SetArg(anArgIndex+j+2, aCurrentState.at(j)); + } + } + } + if(isSubstitute) + aCmd->SetArg(anArgIndex + aNbAngles + 1, + TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".PointStructStr"); + aStates->IncrementState(); + } + else if(aMethod.IsEqual("TriToQuad") || + aMethod.IsEqual("Concatenate") || + aMethod.IsEqual("ConcatenateWithGroups")) { + if(aCurrentStateSize && !aCurrentState.at(0).IsEmpty()) + aCmd->SetArg(aCmd->GetNbArgs(), aCurrentState.at(0)); + aStates->IncrementState(); + } + else if(aMethod.IsEqual("Smooth") || + aMethod.IsEqual("SmoothObject") || + aMethod.IsEqual("SmoothParametric") || + aMethod.IsEqual("SmoothParametricObject")) { + int anArgIndex = aCmd->GetNbArgs() - 2; + for(int j = 0; j < aCurrentStateSize; j++) { + if(!aCurrentState.at(j).IsEmpty()) + aCmd->SetArg(anArgIndex+j, aCurrentState.at(j)); + } + aStates->IncrementState(); + } + else if(aMethod.IsEqual("ApplyToMeshFaces") || + aMethod.IsEqual("ApplyToHexahedrons")) { + int anArgIndex = aCmd->GetNbArgs()-1; + for(int j = 0; j < aCurrentStateSize; j++) + if(!aCurrentState.at(j).IsEmpty()) + aCmd->SetArg(anArgIndex+j, aCurrentState.at(j)); + aStates->IncrementState(); + } + } + } + else { + if(MYDEBUG) + cout << "Object not found" << endl; + } + if(MYDEBUG) { + cout<<"Command after: "<< aCmd->GetString()<GetCurrentStudy(); + if(aStudy->_is_nil()) + return; + + SALOMEDS::SObject_var aSO = aStudy->FindComponent(aGen->ComponentDataType()); + if(CORBA::is_nil(aSO)) + return; + + SALOMEDS::ChildIterator_var Itr = aStudy->NewChildIterator(aSO); + char* aParameters; + for(Itr->InitEx(true); Itr->More(); Itr->Next()) { + SALOMEDS::SObject_var aSObject = Itr->Value(); + SALOMEDS::GenericAttribute_var anAttr; + if ( aSObject->FindAttribute(anAttr, "AttributeString")) { + aParameters = SALOMEDS::AttributeString::_narrow(anAttr)->Value(); + SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters); + if(MYDEBUG) { + cout<<"Entry : "<< aSObject->GetID()<_is_nil()) { + anObjType = TCollection_AsciiString(aHyp->GetName()); + } + else if(SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(anObject)) { + anObjType = TCollection_AsciiString("Mesh"); + } + if(MYDEBUG) + cout<<"The object Type : "<length(); i++) { + TState aVars; + SALOMEDS::ListOfStrings aListOfVars = aSections[i]; + for(int j = 0;jIsVariable(aVar.ToCString())) { + aVar.InsertBefore(1,"\""); + aVar.InsertAfter(aVar.Length(),"\""); + } + aVars.push_back(aVar); + if(MYDEBUG) { + cout<<"Variable: '"<AddState(aVars); + } + _objectMap.insert(pair(TCollection_AsciiString(aSObject->GetID()),aState)); + } + } +} + +//================================================================================ +/*! + * + */ +//================================================================================ +void SMESH_NoteBook::AddCommand(const TCollection_AsciiString& theString) +{ + if(MYDEBUG) + cout<GetMethod() == "GetMeshEditor" ) { // MeshEditor creation + myMeshEditors.insert( make_pair( aCommand->GetResultValue(), + aCommand->GetObject() ) ); + } +} + +//================================================================================ +/*! + * + */ +//================================================================================ +void SMESH_NoteBook::ProcessLayerDistribution() +{ + // 1) Find all LayerDistribution states + vector aLDS; + TVariablesMap::const_iterator it = _objectMap.begin(); + for(;it != _objectMap.end();it++) { + LayerDistributionStates* aLDStates = dynamic_cast(((*it).second)); + if(aLDStates!=NULL) { + aLDS.push_back(aLDStates); + } + } + + if(!aLDS.size()) + return; + + // 2) Initialize all type of 1D Distribution hypothesis + for(int i=0;i<_commands.size();i++){ + for(int j =0;j < aLDS.size();j++){ + TCollection_AsciiString aResultValue = _commands[i]->GetResultValue(); + if(_commands[i]->GetMethod() == "CreateHypothesis" && + aLDS[j]->HasDistribution(aResultValue)){ + TCollection_AsciiString aType = _commands[i]->GetArg(1); + aType.RemoveAll('\''); + aLDS[j]->SetDistributionType(aResultValue,aType); + } + } + } + // 3) ... and replase variables ... + + for(int i=0;i<_commands.size();i++){ + for(int j =0;j < aLDS.size();j++){ + TCollection_AsciiString anObject = _commands[i]->GetObject(); + + if(aLDS[j]->HasDistribution(anObject)) { + TCollection_AsciiString aType = aLDS[j]->GetDistributionType(anObject); + TCollection_AsciiString aMethod = _commands[i]->GetMethod(); + if(aType == "LocalLength") { + if(aMethod == "SetLength") { + SetVariable(_commands[i], aLDS[j],0,1); + aLDS[j]->IncrementState(); + } + else if(aMethod == "SetPrecision") { + SetVariable(_commands[i], aLDS[j],1,1); + aLDS[j]->IncrementState(); + } + } + + // Case for NumberOfSegments hypothesis + else if(aType == "NumberOfSegments"){ + if(aMethod == "SetNumberOfSegments") { + SetVariable(_commands[i], aLDS[j],0,1); + if(aLDS[j]->GetCurrectState().size()==1) + aLDS[j]->IncrementState(); + } + else if (aMethod == "SetScaleFactor") { + SetVariable(_commands[i], aLDS[j],1,1); + aLDS[j]->IncrementState(); + } + } + + else if( aType == "Deflection1D" ){ + if(aMethod == "SetDeflection"){ + SetVariable(_commands[i], aLDS[j],0,1); + aLDS[j]->IncrementState(); + } + } + // Case for Arithmetic1D and StartEndLength hypothesis + else if(aType == "Arithmetic1D" || aType == "StartEndLength") { + if(aMethod == "SetLength") { + int anArgNb = (_commands[i]->GetArg(2) == "1") ? 0 : 1; + SetVariable(_commands[i], aLDS[j],anArgNb,1); + aLDS[j]->IncrementState(); + } + } + } + } + } +} +//================================================================================ +/*! + * \brief Return result script + */ +//================================================================================ +TCollection_AsciiString SMESH_NoteBook::GetResultScript() const +{ + TCollection_AsciiString aResult; + for(int i=0;i<_commands.size();i++) + aResult+=_commands[i]->GetString()+"\n"; + return aResult; +} + +//================================================================================ +/*! + * \brief Return value of the variable + */ +//================================================================================ +bool SMESH_NoteBook::GetReal(const TCollection_AsciiString& theVarName, double& theValue) +{ + bool ok = false; + + SMESH_Gen_i *aGen = SMESH_Gen_i::GetSMESHGen(); + if(!aGen) + return ok; + + SALOMEDS::Study_ptr aStudy = aGen->GetCurrentStudy(); + if(aStudy->_is_nil()) + return ok; + + TCollection_AsciiString aVarName = theVarName; + aVarName.RemoveAll('\"'); + + if(aVarName.IsEmpty()) + return ok; + + const char* aName = aVarName.ToCString(); + if(aStudy->IsVariable(aName) && (aStudy->IsReal(aName) || aStudy->IsInteger(aName))) { + theValue = aStudy->GetReal(aVarName.ToCString()); + ok = true; + } + + return ok; +} + + +/*! + * Set variable of the ObjectStates from position to the _pyCommand + * method as nbArg argument + */ +void SetVariable(Handle(_pyCommand) theCommand, const ObjectStates* theStates, int position, int theArgNb) +{ + if(theStates->GetCurrectState().size() > position) + if(!theStates->GetCurrectState().at(position).IsEmpty()) + theCommand->SetArg(theArgNb,theStates->GetCurrectState().at(position)); +} diff --git a/src/SMESH_I/SMESH_NoteBook.hxx b/src/SMESH_I/SMESH_NoteBook.hxx new file mode 100644 index 000000000..dfeb3b50a --- /dev/null +++ b/src/SMESH_I/SMESH_NoteBook.hxx @@ -0,0 +1,106 @@ +// Copyright (C) 2008 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : SMESH_NoteBook.hxx +// Author : Roman NIKOLAEV () + + +#ifndef SMESH_NoteBook_HeaderFile +#define SMESH_NoteBook_HeaderFile + +#include +#include + +class _pyCommand; + +#include +#include + +typedef std::vector TState; +typedef std::vector TAllStates; +typedef TCollection_AsciiString _pyID; + +class ObjectStates{ + +public: + + ObjectStates(TCollection_AsciiString theType); + virtual ~ObjectStates(); + + void AddState(const TState &theState); + + TState GetCurrectState() const; + TAllStates GetAllStates() const; + void IncrementState(); + TCollection_AsciiString GetObjectType() const; + + + +private: + TCollection_AsciiString _type; + TAllStates _states; + int _dumpstate; +}; + +class LayerDistributionStates : public ObjectStates +{ +public: + typedef std::map TDistributionMap; + LayerDistributionStates(); + virtual ~LayerDistributionStates(); + + void AddDistribution(const TCollection_AsciiString& theDistribution); + bool HasDistribution(const TCollection_AsciiString& theDistribution) const; + + bool SetDistributionType(const TCollection_AsciiString& theDistribution, + const TCollection_AsciiString& theType); + TCollection_AsciiString GetDistributionType(const TCollection_AsciiString& theDistribution) const; + +private: + + TDistributionMap _distributions; +}; + + +class SMESH_NoteBook +{ +public: + typedef std::map TVariablesMap; + typedef std::map TMeshEditorMap; + SMESH_NoteBook(); + ~SMESH_NoteBook(); + void ReplaceVariables(); + + void AddCommand(const TCollection_AsciiString& theString); + TCollection_AsciiString GetResultScript() const; + +private: + void InitObjectMap(); + void ProcessLayerDistribution(); + + bool GetReal(const TCollection_AsciiString& theVarName, double& theValue); + +private: + + TVariablesMap _objectMap; + std::vector _commands; + TMeshEditorMap myMeshEditors; +}; + +#endif //SMESH_NoteBook_HeaderFile diff --git a/src/SMESH_SWIG/smeshDC.py b/src/SMESH_SWIG/smeshDC.py index e956e3c43..7b81262a0 100644 --- a/src/SMESH_SWIG/smeshDC.py +++ b/src/SMESH_SWIG/smeshDC.py @@ -158,6 +158,194 @@ DefaultSize, DefaultGeom, Custom = 0,0,1 PrecisionConfusion = 1e-07 +## Converts an angle from degrees to radians +def DegreesToRadians(AngleInDegrees): + from math import pi + return AngleInDegrees * pi / 180.0 + +# Salome notebook variable separator +var_separator = ":" + +# Parametrized substitute for PointStruct +class PointStructStr: + + x = 0 + y = 0 + z = 0 + xStr = "" + yStr = "" + zStr = "" + + def __init__(self, xStr, yStr, zStr): + self.xStr = xStr + self.yStr = yStr + self.zStr = zStr + if isinstance(xStr, str) and notebook.isVariable(xStr): + self.x = notebook.get(xStr) + else: + self.x = xStr + if isinstance(yStr, str) and notebook.isVariable(yStr): + self.y = notebook.get(yStr) + else: + self.y = yStr + if isinstance(zStr, str) and notebook.isVariable(zStr): + self.z = notebook.get(zStr) + else: + self.z = zStr + +# Parametrized substitute for PointStruct (with 6 parameters) +class PointStructStr6: + + x1 = 0 + y1 = 0 + z1 = 0 + x2 = 0 + y2 = 0 + z2 = 0 + xStr1 = "" + yStr1 = "" + zStr1 = "" + xStr2 = "" + yStr2 = "" + zStr2 = "" + + def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str): + self.x1Str = x1Str + self.x2Str = x2Str + self.y1Str = y1Str + self.y2Str = y2Str + self.z1Str = z1Str + self.z2Str = z2Str + if isinstance(x1Str, str) and notebook.isVariable(x1Str): + self.x1 = notebook.get(x1Str) + else: + self.x1 = x1Str + if isinstance(x2Str, str) and notebook.isVariable(x2Str): + self.x2 = notebook.get(x2Str) + else: + self.x2 = x2Str + if isinstance(y1Str, str) and notebook.isVariable(y1Str): + self.y1 = notebook.get(y1Str) + else: + self.y1 = y1Str + if isinstance(y2Str, str) and notebook.isVariable(y2Str): + self.y2 = notebook.get(y2Str) + else: + self.y2 = y2Str + if isinstance(z1Str, str) and notebook.isVariable(z1Str): + self.z1 = notebook.get(z1Str) + else: + self.z1 = z1Str + if isinstance(z2Str, str) and notebook.isVariable(z2Str): + self.z2 = notebook.get(z2Str) + else: + self.z2 = z2Str + +# Parametrized substitute for AxisStruct +class AxisStructStr: + + x = 0 + y = 0 + z = 0 + dx = 0 + dy = 0 + dz = 0 + xStr = "" + yStr = "" + zStr = "" + dxStr = "" + dyStr = "" + dzStr = "" + + def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr): + self.xStr = xStr + self.yStr = yStr + self.zStr = zStr + self.dxStr = dxStr + self.dyStr = dyStr + self.dzStr = dzStr + if isinstance(xStr, str) and notebook.isVariable(xStr): + self.x = notebook.get(xStr) + else: + self.x = xStr + if isinstance(yStr, str) and notebook.isVariable(yStr): + self.y = notebook.get(yStr) + else: + self.y = yStr + if isinstance(zStr, str) and notebook.isVariable(zStr): + self.z = notebook.get(zStr) + else: + self.z = zStr + if isinstance(dxStr, str) and notebook.isVariable(dxStr): + self.dx = notebook.get(dxStr) + else: + self.dx = dxStr + if isinstance(dyStr, str) and notebook.isVariable(dyStr): + self.dy = notebook.get(dyStr) + else: + self.dy = dyStr + if isinstance(dzStr, str) and notebook.isVariable(dzStr): + self.dz = notebook.get(dzStr) + else: + self.dz = dzStr + +# Parametrized substitute for DirStruct +class DirStructStr: + + def __init__(self, pointStruct): + self.pointStruct = pointStruct + +# Returns list of variable values from salome notebook +def ParsePointStruct(Point): + Parameters = 2*var_separator + if isinstance(Point, PointStructStr): + Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr) + Point = PointStruct(Point.x, Point.y, Point.z) + return Point, Parameters + +# Returns list of variable values from salome notebook +def ParseDirStruct(Dir): + Parameters = 2*var_separator + if isinstance(Dir, DirStructStr): + pntStr = Dir.pointStruct + if isinstance(pntStr, PointStructStr6): + Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator + Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator + Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str) + Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1) + else: + Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr) + Point = PointStruct(pntStr.x, pntStr.y, pntStr.z) + Dir = DirStruct(Point) + return Dir, Parameters + +# Returns list of variable values from salome notebook +def ParseAxisStruct(Axis): + Parameters = 5*var_separator + if isinstance(Axis, AxisStructStr): + Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator + Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr) + Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz) + return Axis, Parameters + +## Return list of variable values from salome notebook +def ParseAngles(list): + Result = [] + Parameters = "" + for parameter in list: + if isinstance(parameter,str) and notebook.isVariable(parameter): + Result.append(DegreesToRadians(notebook.get(parameter))) + pass + else: + Result.append(parameter) + pass + + Parameters = Parameters + str(parameter) + Parameters = Parameters + var_separator + pass + Parameters = Parameters[:len(Parameters)-1] + return Result, Parameters + def IsEqual(val1, val2, tol=PrecisionConfusion): if abs(val1 - val2) < tol: return True @@ -214,11 +402,6 @@ def TreatHypoStatus(status, hypName, geomName, isAlgo): print hypName, "was not assigned to",geomName,":", reason pass -## Converts an angle from degrees to radians -def DegreesToRadians(AngleInDegrees): - from math import pi - return AngleInDegrees * pi / 180.0 - # end of l1_auxiliary ## @} @@ -414,6 +597,25 @@ class smeshDC(SMESH._objref_SMESH_Gen): def SetBoundaryBoxSegmentation(self, nbSegments): SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments) + ## Concatenate the given meshes into one mesh. + # @return an instance of Mesh class + # @param meshes the meshes to combine into one mesh + # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed + # @param mergeNodesAndElements if true, equal nodes and elements aremerged + # @param mergeTolerance tolerance for merging nodes + # @param allGroups forces creation of groups of all elements + def Concatenate( self, meshes, uniteIdenticalGroups, + mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False): + mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance) + if allGroups: + aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups( + self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance) + else: + aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate( + self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance) + aSmeshMesh.SetParameters(Parameters) + aMesh = Mesh(self, self.geompyD, aSmeshMesh) + return aMesh # Filtering. Auxiliary functions: # ------------------------------ @@ -1740,6 +1942,8 @@ class Mesh: # @return Id of the new node # @ingroup l2_modif_add def AddNode(self, x, y, z): + x,y,z,Parameters = geompyDC.ParseParameters(x,y,z) + self.mesh.SetParameters(Parameters) return self.editor.AddNode( x, y, z) ## Creates a linear or quadratic edge (this is determined @@ -1895,8 +2099,21 @@ class Mesh: # @return True if succeed else False # @ingroup l2_modif_movenode def MoveNode(self, NodeID, x, y, z): + x,y,z,Parameters = geompyDC.ParseParameters(x,y,z) + self.mesh.SetParameters(Parameters) return self.editor.MoveNode(NodeID, x, y, z) + ## Finds the node closest to a point and moves it to a point location + # @param x the X coordinate of a point + # @param y the Y coordinate of a point + # @param z the Z coordinate of a point + # @return the ID of a node + # @ingroup l2_modif_throughp + def MoveClosestNodeToPoint(self, x, y, z, NodeID): + x,y,z,Parameters = geompyDC.ParseParameters(x,y,z) + self.mesh.SetParameters(Parameters) + return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID) + ## Finds the node closest to a point # @param x the X coordinate of a point # @param y the Y coordinate of a point @@ -1957,12 +2174,25 @@ class Mesh: # @param theCriterion is FT_...; used to choose a neighbour to fuse with. # @param MaxAngle is the maximum angle between element normals at which the fusion # is still performed; theMaxAngle is mesured in radians. + # Also it could be a name of variable which defines angle in degrees. # @return TRUE in case of success, FALSE otherwise. # @ingroup l2_modif_unitetri def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle): + flag = False + if isinstance(MaxAngle,str): + flag = True + MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle) + if flag: + MaxAngle = DegreesToRadians(MaxAngle) if IDsOfElements == []: IDsOfElements = self.GetElementsId() - return self.editor.TriToQuad(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion), MaxAngle) + self.mesh.SetParameters(Parameters) + Functor = 0 + if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ): + Functor = theCriterion + else: + Functor = self.smeshpyD.GetFunctor(theCriterion) + return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle) ## Fuses the neighbouring triangles of the object into quadrangles # @param theObject is mesh, submesh or group @@ -2180,6 +2410,8 @@ class Mesh: MaxNbOfIterations, MaxAspectRatio, Method): if IDsOfElements == []: IDsOfElements = self.GetElementsId() + MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio) + self.mesh.SetParameters(Parameters) return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes, MaxNbOfIterations, MaxAspectRatio, Method) @@ -2212,6 +2444,8 @@ class Mesh: MaxNbOfIterations, MaxAspectRatio, Method): if IDsOfElements == []: IDsOfElements = self.GetElementsId() + MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio) + self.mesh.SetParameters(Parameters) return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes, MaxNbOfIterations, MaxAspectRatio, Method) @@ -2258,7 +2492,7 @@ class Mesh: ## Generates new elements by rotation of the elements around the axis # @param IDsOfElements the list of ids of elements to sweep # @param Axis the axis of rotation, AxisStruct or line(geom object) - # @param AngleInRadians the angle of Rotation + # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees # @param NbOfSteps the number of steps # @param Tolerance tolerance # @param MakeGroups forces the generation of new groups from existing ones @@ -2268,12 +2502,22 @@ class Mesh: # @ingroup l2_modif_extrurev def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance, MakeGroups=False, TotalAngle=False): + flag = False + if isinstance(AngleInRadians,str): + flag = True + AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians) + if flag: + AngleInRadians = DegreesToRadians(AngleInRadians) if IDsOfElements == []: IDsOfElements = self.GetElementsId() if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)): Axis = self.smeshpyD.GetAxisStruct(Axis) + Axis,AxisParameters = ParseAxisStruct(Axis) if TotalAngle and NbOfSteps: AngleInRadians /= NbOfSteps + NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance) + Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters + self.mesh.SetParameters(Parameters) if MakeGroups: return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance) @@ -2293,18 +2537,98 @@ class Mesh: # @ingroup l2_modif_extrurev def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance, MakeGroups=False, TotalAngle=False): + flag = False + if isinstance(AngleInRadians,str): + flag = True + AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians) + if flag: + AngleInRadians = DegreesToRadians(AngleInRadians) if ( isinstance( theObject, Mesh )): theObject = theObject.GetMesh() if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)): Axis = self.smeshpyD.GetAxisStruct(Axis) + Axis,AxisParameters = ParseAxisStruct(Axis) if TotalAngle and NbOfSteps: AngleInRadians /= NbOfSteps + NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance) + Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters + self.mesh.SetParameters(Parameters) if MakeGroups: return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance) self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance) return [] + ## Generates new elements by rotation of the elements of object around the axis + # @param theObject object which elements should be sweeped + # @param Axis the axis of rotation, AxisStruct or line(geom object) + # @param AngleInRadians the angle of Rotation + # @param NbOfSteps number of steps + # @param Tolerance tolerance + # @param MakeGroups forces the generation of new groups from existing ones + # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size + # of all steps, else - size of each step + # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise + # @ingroup l2_modif_extrurev + def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance, + MakeGroups=False, TotalAngle=False): + flag = False + if isinstance(AngleInRadians,str): + flag = True + AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians) + if flag: + AngleInRadians = DegreesToRadians(AngleInRadians) + if ( isinstance( theObject, Mesh )): + theObject = theObject.GetMesh() + if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)): + Axis = self.smeshpyD.GetAxisStruct(Axis) + Axis,AxisParameters = ParseAxisStruct(Axis) + if TotalAngle and NbOfSteps: + AngleInRadians /= NbOfSteps + NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance) + Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters + self.mesh.SetParameters(Parameters) + if MakeGroups: + return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians, + NbOfSteps, Tolerance) + self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance) + return [] + + ## Generates new elements by rotation of the elements of object around the axis + # @param theObject object which elements should be sweeped + # @param Axis the axis of rotation, AxisStruct or line(geom object) + # @param AngleInRadians the angle of Rotation + # @param NbOfSteps number of steps + # @param Tolerance tolerance + # @param MakeGroups forces the generation of new groups from existing ones + # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size + # of all steps, else - size of each step + # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise + # @ingroup l2_modif_extrurev + def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance, + MakeGroups=False, TotalAngle=False): + flag = False + if isinstance(AngleInRadians,str): + flag = True + AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians) + if flag: + AngleInRadians = DegreesToRadians(AngleInRadians) + if ( isinstance( theObject, Mesh )): + theObject = theObject.GetMesh() + if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)): + Axis = self.smeshpyD.GetAxisStruct(Axis) + Axis,AxisParameters = ParseAxisStruct(Axis) + if TotalAngle and NbOfSteps: + AngleInRadians /= NbOfSteps + NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance) + Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters + self.mesh.SetParameters(Parameters) + if MakeGroups: + return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians, + NbOfSteps, Tolerance) + self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance) + return [] + ## Generates new elements by extrusion of the elements with given ids # @param IDsOfElements the list of elements ids for extrusion # @param StepVector vector, defining the direction and value of extrusion @@ -2317,6 +2641,10 @@ class Mesh: IDsOfElements = self.GetElementsId() if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)): StepVector = self.smeshpyD.GetDirStruct(StepVector) + StepVector,StepVectorParameters = ParseDirStruct(StepVector) + NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps) + Parameters = StepVectorParameters + var_separator + Parameters + self.mesh.SetParameters(Parameters) if MakeGroups: return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps) self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps) @@ -2355,6 +2683,10 @@ class Mesh: theObject = theObject.GetMesh() if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)): StepVector = self.smeshpyD.GetDirStruct(StepVector) + StepVector,StepVectorParameters = ParseDirStruct(StepVector) + NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps) + Parameters = StepVectorParameters + var_separator + Parameters + self.mesh.SetParameters(Parameters) if MakeGroups: return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps) self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps) @@ -2372,6 +2704,10 @@ class Mesh: theObject = theObject.GetMesh() if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)): StepVector = self.smeshpyD.GetDirStruct(StepVector) + StepVector,StepVectorParameters = ParseDirStruct(StepVector) + NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps) + Parameters = StepVectorParameters + var_separator + Parameters + self.mesh.SetParameters(Parameters) if MakeGroups: return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps) self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps) @@ -2389,6 +2725,10 @@ class Mesh: theObject = theObject.GetMesh() if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)): StepVector = self.smeshpyD.GetDirStruct(StepVector) + StepVector,StepVectorParameters = ParseDirStruct(StepVector) + NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps) + Parameters = StepVectorParameters + var_separator + Parameters + self.mesh.SetParameters(Parameters) if MakeGroups: return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps) self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps) @@ -2415,6 +2755,8 @@ class Mesh: def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart, HasAngles, Angles, HasRefPoint, RefPoint, MakeGroups=False, LinearVariation=False): + Angles,AnglesParameters = ParseAngles(Angles) + RefPoint,RefPointParameters = ParsePointStruct(RefPoint) if IDsOfElements == []: IDsOfElements = self.GetElementsId() if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)): @@ -2425,6 +2767,8 @@ class Mesh: if HasAngles and Angles and LinearVariation: Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles ) pass + Parameters = AnglesParameters + var_separator + RefPointParameters + self.mesh.SetParameters(Parameters) if MakeGroups: return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh, PathShape, NodeStart, HasAngles, @@ -2453,6 +2797,8 @@ class Mesh: def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart, HasAngles, Angles, HasRefPoint, RefPoint, MakeGroups=False, LinearVariation=False): + Angles,AnglesParameters = ParseAngles(Angles) + RefPoint,RefPointParameters = ParsePointStruct(RefPoint) if ( isinstance( theObject, Mesh )): theObject = theObject.GetMesh() if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)): @@ -2462,6 +2808,8 @@ class Mesh: if HasAngles and Angles and LinearVariation: Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles ) pass + Parameters = AnglesParameters + var_separator + RefPointParameters + self.mesh.SetParameters(Parameters) if MakeGroups: return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh, PathShape, NodeStart, HasAngles, @@ -2470,6 +2818,90 @@ class Mesh: NodeStart, HasAngles, Angles, HasRefPoint, RefPoint) + ## Generates new elements by extrusion of the elements which belong to the object + # The path of extrusion must be a meshed edge. + # @param theObject the object which elements should be processed + # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds + # @param PathShape shape(edge) defines the sub-mesh for the path + # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion + # @param HasAngles allows the shape to be rotated around the path + # to get the resulting mesh in a helical fashion + # @param Angles list of angles + # @param HasRefPoint allows using the reference point + # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default). + # The User can specify any point as the Reference Point. + # @param MakeGroups forces the generation of new groups from existing ones + # @param LinearVariation forces the computation of rotation angles as linear + # variation of the given Angles along path steps + # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True, + # only SMESH::Extrusion_Error otherwise + # @ingroup l2_modif_extrurev + def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart, + HasAngles, Angles, HasRefPoint, RefPoint, + MakeGroups=False, LinearVariation=False): + Angles,AnglesParameters = ParseAngles(Angles) + RefPoint,RefPointParameters = ParsePointStruct(RefPoint) + if ( isinstance( theObject, Mesh )): + theObject = theObject.GetMesh() + if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)): + RefPoint = self.smeshpyD.GetPointStruct(RefPoint) + if ( isinstance( PathMesh, Mesh )): + PathMesh = PathMesh.GetMesh() + if HasAngles and Angles and LinearVariation: + Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles ) + pass + Parameters = AnglesParameters + var_separator + RefPointParameters + self.mesh.SetParameters(Parameters) + if MakeGroups: + return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh, + PathShape, NodeStart, HasAngles, + Angles, HasRefPoint, RefPoint) + return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape, + NodeStart, HasAngles, Angles, HasRefPoint, + RefPoint) + + ## Generates new elements by extrusion of the elements which belong to the object + # The path of extrusion must be a meshed edge. + # @param theObject the object which elements should be processed + # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds + # @param PathShape shape(edge) defines the sub-mesh for the path + # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion + # @param HasAngles allows the shape to be rotated around the path + # to get the resulting mesh in a helical fashion + # @param Angles list of angles + # @param HasRefPoint allows using the reference point + # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default). + # The User can specify any point as the Reference Point. + # @param MakeGroups forces the generation of new groups from existing ones + # @param LinearVariation forces the computation of rotation angles as linear + # variation of the given Angles along path steps + # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True, + # only SMESH::Extrusion_Error otherwise + # @ingroup l2_modif_extrurev + def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart, + HasAngles, Angles, HasRefPoint, RefPoint, + MakeGroups=False, LinearVariation=False): + Angles,AnglesParameters = ParseAngles(Angles) + RefPoint,RefPointParameters = ParsePointStruct(RefPoint) + if ( isinstance( theObject, Mesh )): + theObject = theObject.GetMesh() + if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)): + RefPoint = self.smeshpyD.GetPointStruct(RefPoint) + if ( isinstance( PathMesh, Mesh )): + PathMesh = PathMesh.GetMesh() + if HasAngles and Angles and LinearVariation: + Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles ) + pass + Parameters = AnglesParameters + var_separator + RefPointParameters + self.mesh.SetParameters(Parameters) + if MakeGroups: + return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh, + PathShape, NodeStart, HasAngles, + Angles, HasRefPoint, RefPoint) + return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape, + NodeStart, HasAngles, Angles, HasRefPoint, + RefPoint) + ## Creates a symmetrical copy of mesh elements # @param IDsOfElements list of elements ids # @param Mirror is AxisStruct or geom object(point, line, plane) @@ -2484,6 +2916,8 @@ class Mesh: IDsOfElements = self.GetElementsId() if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)): Mirror = self.smeshpyD.GetAxisStruct(Mirror) + Mirror,Parameters = ParseAxisStruct(Mirror) + self.mesh.SetParameters(Parameters) if Copy and MakeGroups: return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType) self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy) @@ -2503,8 +2937,10 @@ class Mesh: IDsOfElements = self.GetElementsId() if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)): Mirror = self.smeshpyD.GetAxisStruct(Mirror) + Mirror,Parameters = ParseAxisStruct(Mirror) mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType, MakeGroups, NewMeshName) + mesh.SetParameters(Parameters) return Mesh(self.smeshpyD,self.geompyD,mesh) ## Creates a symmetrical copy of the object @@ -2521,6 +2957,8 @@ class Mesh: theObject = theObject.GetMesh() if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)): Mirror = self.smeshpyD.GetAxisStruct(Mirror) + Mirror,Parameters = ParseAxisStruct(Mirror) + self.mesh.SetParameters(Parameters) if Copy and MakeGroups: return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType) self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy) @@ -2540,8 +2978,10 @@ class Mesh: theObject = theObject.GetMesh() if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)): Mirror = self.smeshpyD.GetAxisStruct(Mirror) + Mirror,Parameters = ParseAxisStruct(Mirror) mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType, MakeGroups, NewMeshName) + mesh.SetParameters(Parameters) return Mesh( self.smeshpyD,self.geompyD,mesh ) ## Translates the elements @@ -2556,6 +2996,8 @@ class Mesh: IDsOfElements = self.GetElementsId() if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)): Vector = self.smeshpyD.GetDirStruct(Vector) + Vector,Parameters = ParseDirStruct(Vector) + self.mesh.SetParameters(Parameters) if Copy and MakeGroups: return self.editor.TranslateMakeGroups(IDsOfElements, Vector) self.editor.Translate(IDsOfElements, Vector, Copy) @@ -2573,7 +3015,9 @@ class Mesh: IDsOfElements = self.GetElementsId() if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)): Vector = self.smeshpyD.GetDirStruct(Vector) + Vector,Parameters = ParseDirStruct(Vector) mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName) + mesh.SetParameters(Parameters) return Mesh ( self.smeshpyD, self.geompyD, mesh ) ## Translates the object @@ -2588,6 +3032,8 @@ class Mesh: theObject = theObject.GetMesh() if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)): Vector = self.smeshpyD.GetDirStruct(Vector) + Vector,Parameters = ParseDirStruct(Vector) + self.mesh.SetParameters(Parameters) if Copy and MakeGroups: return self.editor.TranslateObjectMakeGroups(theObject, Vector) self.editor.TranslateObject(theObject, Vector, Copy) @@ -2605,22 +3051,33 @@ class Mesh: theObject = theObject.GetMesh() if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)): Vector = self.smeshpyD.GetDirStruct(Vector) + Vector,Parameters = ParseDirStruct(Vector) mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName) + mesh.SetParameters(Parameters) return Mesh( self.smeshpyD, self.geompyD, mesh ) ## Rotates the elements # @param IDsOfElements list of elements ids # @param Axis the axis of rotation (AxisStruct or geom line) - # @param AngleInRadians the angle of rotation (in radians) + # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees # @param Copy allows copying the rotated elements # @param MakeGroups forces the generation of new groups from existing ones (if Copy) # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise # @ingroup l2_modif_trsf def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False): + flag = False + if isinstance(AngleInRadians,str): + flag = True + AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians) + if flag: + AngleInRadians = DegreesToRadians(AngleInRadians) if IDsOfElements == []: IDsOfElements = self.GetElementsId() if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)): Axis = self.smeshpyD.GetAxisStruct(Axis) + Axis,AxisParameters = ParseAxisStruct(Axis) + Parameters = AxisParameters + var_separator + Parameters + self.mesh.SetParameters(Parameters) if Copy and MakeGroups: return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians) self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy) @@ -2629,33 +3086,51 @@ class Mesh: ## Creates a new mesh of rotated elements # @param IDsOfElements list of element ids # @param Axis the axis of rotation (AxisStruct or geom line) - # @param AngleInRadians the angle of rotation (in radians) + # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees # @param MakeGroups forces the generation of new groups from existing ones # @param NewMeshName the name of the newly created mesh # @return instance of Mesh class # @ingroup l2_modif_trsf def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""): + flag = False + if isinstance(AngleInRadians,str): + flag = True + AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians) + if flag: + AngleInRadians = DegreesToRadians(AngleInRadians) if IDsOfElements == []: IDsOfElements = self.GetElementsId() if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)): Axis = self.smeshpyD.GetAxisStruct(Axis) + Axis,AxisParameters = ParseAxisStruct(Axis) + Parameters = AxisParameters + var_separator + Parameters mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians, MakeGroups, NewMeshName) + mesh.SetParameters(Parameters) return Mesh( self.smeshpyD, self.geompyD, mesh ) ## Rotates the object # @param theObject the object to rotate( mesh, submesh, or group) # @param Axis the axis of rotation (AxisStruct or geom line) - # @param AngleInRadians the angle of rotation (in radians) + # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees # @param Copy allows copying the rotated elements # @param MakeGroups forces the generation of new groups from existing ones (if Copy) # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise # @ingroup l2_modif_trsf def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False): + flag = False + if isinstance(AngleInRadians,str): + flag = True + AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians) + if flag: + AngleInRadians = DegreesToRadians(AngleInRadians) if (isinstance(theObject, Mesh)): theObject = theObject.GetMesh() if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)): Axis = self.smeshpyD.GetAxisStruct(Axis) + Axis,AxisParameters = ParseAxisStruct(Axis) + Parameters = AxisParameters + ":" + Parameters + self.mesh.SetParameters(Parameters) if Copy and MakeGroups: return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians) self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy) @@ -2664,18 +3139,27 @@ class Mesh: ## Creates a new mesh from the rotated object # @param theObject the object to rotate (mesh, submesh, or group) # @param Axis the axis of rotation (AxisStruct or geom line) - # @param AngleInRadians the angle of rotation (in radians) + # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees # @param MakeGroups forces the generation of new groups from existing ones # @param NewMeshName the name of the newly created mesh # @return instance of Mesh class # @ingroup l2_modif_trsf def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""): + flag = False + if isinstance(AngleInRadians,str): + flag = True + AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians) + if flag: + AngleInRadians = DegreesToRadians(AngleInRadians) if (isinstance( theObject, Mesh )): theObject = theObject.GetMesh() if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)): Axis = self.smeshpyD.GetAxisStruct(Axis) + Axis,AxisParameters = ParseAxisStruct(Axis) + Parameters = AxisParameters + ":" + Parameters mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians, MakeGroups, NewMeshName) + mesh.SetParameters(Parameters) return Mesh( self.smeshpyD, self.geompyD, mesh ) ## Finds groups of ajacent nodes within Tolerance. @@ -4191,3 +4675,324 @@ class Mesh_UseExisting(Mesh_Algorithm): self.Create(mesh, geom, "UseExisting_1D") else: self.Create(mesh, geom, "UseExisting_2D") + + +import salome_notebook +notebook = salome_notebook.notebook + +##Return values of the notebook variables +def ParseParameters(last, nbParams,nbParam, value): + result = None + strResult = "" + counter = 0 + listSize = len(last) + for n in range(0,nbParams): + if n+1 != nbParam: + if counter < listSize: + strResult = strResult + last[counter] + else: + strResult = strResult + "" + else: + if isinstance(value, str): + if notebook.isVariable(value): + result = notebook.get(value) + strResult=strResult+value + else: + raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!" + else: + strResult=strResult+str(value) + result = value + if nbParams - 1 != counter: + strResult=strResult+var_separator #":" + counter = counter+1 + return result, strResult + +#Wrapper class for StdMeshers_LocalLength hypothesis +class LocalLength(StdMeshers._objref_StdMeshers_LocalLength): + + ## Set Length parameter value + # @param length numerical value or name of variable from notebook + def SetLength(self, length): + length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length) + StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters) + StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length) + + ## Set Precision parameter value + # @param precision numerical value or name of variable from notebook + def SetPrecision(self, precision): + precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision) + StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters) + StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision) + +#Registering the new proxy for LocalLength +omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength) + + +#Wrapper class for StdMeshers_LayerDistribution hypothesis +class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution): + + def SetLayerDistribution(self, hypo): + StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters()) + hypo.ClearParameters(); + StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo) + +#Registering the new proxy for LayerDistribution +omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution) + +#Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis +class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex): + + ## Set Length parameter value + # @param length numerical value or name of variable from notebook + def SetLength(self, length): + length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length) + StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters) + StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length) + +#Registering the new proxy for SegmentLengthAroundVertex +omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex) + + +#Wrapper class for StdMeshers_Arithmetic1D hypothesis +class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D): + + ## Set Length parameter value + # @param length numerical value or name of variable from notebook + # @param isStart true is length is Start Length, otherwise false + def SetLength(self, length, isStart): + nb = 2 + if isStart: + nb = 1 + length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length) + StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters) + StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart) + +#Registering the new proxy for Arithmetic1D +omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D) + +#Wrapper class for StdMeshers_Deflection1D hypothesis +class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D): + + ## Set Deflection parameter value + # @param deflection numerical value or name of variable from notebook + def SetDeflection(self, deflection): + deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection) + StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters) + StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection) + +#Registering the new proxy for Deflection1D +omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D) + +#Wrapper class for StdMeshers_StartEndLength hypothesis +class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength): + + ## Set Length parameter value + # @param length numerical value or name of variable from notebook + # @param isStart true is length is Start Length, otherwise false + def SetLength(self, length, isStart): + nb = 2 + if isStart: + nb = 1 + length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length) + StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters) + StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart) + +#Registering the new proxy for StartEndLength +omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength) + +#Wrapper class for StdMeshers_MaxElementArea hypothesis +class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea): + + ## Set Max Element Area parameter value + # @param area numerical value or name of variable from notebook + def SetMaxElementArea(self, area): + area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area) + StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters) + StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area) + +#Registering the new proxy for MaxElementArea +omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea) + + +#Wrapper class for StdMeshers_MaxElementVolume hypothesis +class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume): + + ## Set Max Element Volume parameter value + # @param area numerical value or name of variable from notebook + def SetMaxElementVolume(self, volume): + volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume) + StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters) + StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume) + +#Registering the new proxy for MaxElementVolume +omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume) + + +#Wrapper class for StdMeshers_NumberOfLayers hypothesis +class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers): + + ## Set Number Of Layers parameter value + # @param nbLayers numerical value or name of variable from notebook + def SetNumberOfLayers(self, nbLayers): + nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers) + StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters) + StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers) + +#Registering the new proxy for NumberOfLayers +omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers) + +#Wrapper class for StdMeshers_NumberOfSegments hypothesis +class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments): + + ## Set Number Of Segments parameter value + # @param nbSeg numerical value or name of variable from notebook + def SetNumberOfSegments(self, nbSeg): + lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self) + nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg) + StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters) + StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg) + + ## Set Scale Factor parameter value + # @param factor numerical value or name of variable from notebook + def SetScaleFactor(self, factor): + factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor) + StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters) + StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor) + +#Registering the new proxy for NumberOfSegments +omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments) + + +#Wrapper class for NETGENPlugin_Hypothesis hypothesis +class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis): + + ## Set Max Size parameter value + # @param maxsize numerical value or name of variable from notebook + def SetMaxSize(self, maxsize): + lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self) + maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize) + NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters) + NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize) + + ## Set Growth Rate parameter value + # @param value numerical value or name of variable from notebook + def SetGrowthRate(self, value): + lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self) + value, parameters = ParseParameters(lastParameters,4,2,value) + NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters) + NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value) + + ## Set Number of Segments per Edge parameter value + # @param value numerical value or name of variable from notebook + def SetNbSegPerEdge(self, value): + lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self) + value, parameters = ParseParameters(lastParameters,4,3,value) + NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters) + NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value) + + ## Set Number of Segments per Radius parameter value + # @param value numerical value or name of variable from notebook + def SetNbSegPerRadius(self, value): + lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self) + value, parameters = ParseParameters(lastParameters,4,4,value) + NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters) + NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value) + +#Registering the new proxy for NETGENPlugin_Hypothesis +omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis) + + +#Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis +class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D): + pass + +#Registering the new proxy for NETGENPlugin_Hypothesis_2D +omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D) + +#Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis +class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D): + + ## Set Number of Segments parameter value + # @param nbSeg numerical value or name of variable from notebook + def SetNumberOfSegments(self, nbSeg): + lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self) + nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg) + NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters) + NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg) + + ## Set Local Length parameter value + # @param length numerical value or name of variable from notebook + def SetLocalLength(self, length): + lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self) + length, parameters = ParseParameters(lastParameters,2,1,length) + NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters) + NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length) + + ## Set Max Element Area parameter value + # @param area numerical value or name of variable from notebook + def SetMaxElementArea(self, area): + lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self) + area, parameters = ParseParameters(lastParameters,2,2,area) + NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters) + NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area) + + def LengthFromEdges(self): + lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self) + value = 0; + value, parameters = ParseParameters(lastParameters,2,2,value) + NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters) + NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self) + +#Registering the new proxy for NETGEN_SimpleParameters_2D +omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D) + + +#Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis +class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D): + ## Set Max Element Volume parameter value + # @param volume numerical value or name of variable from notebook + def SetMaxElementVolume(self, volume): + lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self) + volume, parameters = ParseParameters(lastParameters,3,3,volume) + NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters) + NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume) + + def LengthFromFaces(self): + lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self) + value = 0; + value, parameters = ParseParameters(lastParameters,3,3,value) + NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters) + NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self) + +#Registering the new proxy for NETGEN_SimpleParameters_3D +omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D) + +class Pattern(SMESH._objref_SMESH_Pattern): + + def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse): + flag = False + if isinstance(theNodeIndexOnKeyPoint1,str): + flag = True + theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1) + if flag: + theNodeIndexOnKeyPoint1 -= 1 + theMesh.SetParameters(Parameters) + return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse ) + + def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index): + flag0 = False + flag1 = False + if isinstance(theNode000Index,str): + flag0 = True + if isinstance(theNode001Index,str): + flag1 = True + theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index) + if flag0: + theNode000Index -= 1 + if flag1: + theNode001Index -= 1 + theMesh.SetParameters(Parameters) + return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index ) + +#Registering the new proxy for Pattern +omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern) diff --git a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.cxx b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.cxx index 33d2c3be0..9e8e0bda8 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.cxx @@ -27,6 +27,7 @@ #include "StdMeshersGUI_DistrTable.h" #include "StdMeshersGUI_DistrPreview.h" +#include #include #include #include @@ -36,7 +37,7 @@ // SALOME GUI includes #include -#include +#include #include // Qt includes @@ -78,13 +79,17 @@ StdMeshersGUI_NbSegmentsCreator::~StdMeshersGUI_NbSegmentsCreator() { } -bool StdMeshersGUI_NbSegmentsCreator::checkParams() const +bool StdMeshersGUI_NbSegmentsCreator::checkParams( QString& msg ) const { + if( !SMESHGUI_GenericHypothesisCreator::checkParams( msg ) ) + return false; NbSegmentsHypothesisData data_old, data_new; readParamsFromHypo( data_old ); readParamsFromWidgets( data_new ); bool res = storeParamsToHypo( data_new ); storeParamsToHypo( data_old ); + res = myNbSeg->isValid( msg, true ) && res; + res = myScale->isValid( msg, true ) && res; return res; } @@ -122,7 +127,7 @@ QFrame* StdMeshersGUI_NbSegmentsCreator::buildFrame() // 1) number of segments myGroupLayout->addWidget( new QLabel( tr( "SMESH_NB_SEGMENTS_PARAM" ), GroupC1 ), row, 0 ); - myNbSeg = new QtxIntSpinBox( GroupC1 ); + myNbSeg = new SalomeApp_IntSpinBox( GroupC1 ); myNbSeg->setMinimum( 1 ); myNbSeg->setMaximum( 9999 ); myGroupLayout->addWidget( myNbSeg, row, 1 ); @@ -206,9 +211,16 @@ void StdMeshersGUI_NbSegmentsCreator::retrieveParams() const if( myName ) myName->setText( data.myName ); - myNbSeg->setValue( data.myNbSeg ); + if(data.myNbSegVarName.isEmpty()) + myNbSeg->setValue( data.myNbSeg ); + else + myNbSeg->setText( data.myNbSegVarName ); + myDistr->setCurrentIndex( data.myDistrType ); - myScale->setValue( data.myScale ); + if(data.myScaleVarName.isEmpty()) + myScale->setValue( data.myScale ); + else + myScale->setText( data.myScaleVarName ); myConv->button( data.myConv )->setChecked( true ); myTable->setFuncMinValue(myConv->checkedId()==0 ? -1E20 : 0); myTable->setData( data.myTable ); @@ -223,7 +235,7 @@ QString StdMeshersGUI_NbSegmentsCreator::storeParams() const NbSegmentsHypothesisData data; readParamsFromWidgets( data ); storeParamsToHypo( data ); - + QString valStr = QString::number( data.myNbSeg ) += "; "; enum DistrType @@ -238,8 +250,8 @@ QString StdMeshersGUI_NbSegmentsCreator::storeParams() const case Regular : valStr += tr("SMESH_DISTR_REGULAR"); break; - case Scale : - valStr += tr("SMESH_NB_SEGMENTS_SCALE_PARAM") + " = " + QString::number( data.myScale ); + case Scale : + valStr += tr("SMESH_NB_SEGMENTS_SCALE_PARAM") + " = " + QString::number( data.myScale );\ break; case TabFunc : { //valStr += tr("SMESH_TAB_FUNC"); @@ -275,9 +287,21 @@ bool StdMeshersGUI_NbSegmentsCreator::readParamsFromHypo( NbSegmentsHypothesisDa h_data.myName = hypName(); h_data.myNbSeg = (int) h->GetNumberOfSegments(); + + SMESH::ListOfParameters_var aParameters = h->GetLastParameters(); + + h_data.myNbSegVarName = (aParameters->length() > 0) ? QString(aParameters[0].in()) : QString(""); + int distr = (int) h->GetDistrType(); h_data.myDistrType = distr; h_data.myScale = distr==1 ? h->GetScaleFactor() : 1.0; + + if(distr==1){ + h_data.myScaleVarName = (aParameters->length() > 1) ? QString(aParameters[1].in()) : QString(""); + } + else + h_data.myScaleVarName = QString(""); + if( distr==2 ) { SMESH::double_array* a = h->GetTableFunction(); @@ -310,13 +334,17 @@ bool StdMeshersGUI_NbSegmentsCreator::storeParamsToHypo( const NbSegmentsHypothe if( isCreation() ) SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().data() ); + QStringList aVariablesList; + aVariablesList.append(h_data.myNbSegVarName); + h->SetNumberOfSegments( h_data.myNbSeg ); int distr = h_data.myDistrType; h->SetDistrType( distr ); - - if( distr==1 ) + + if( distr==1 ) { h->SetScaleFactor( h_data.myScale ); - + aVariablesList.append(h_data.myScaleVarName); + } if( distr==2 || distr==3 ) h->SetConversionMode( h_data.myConv ); @@ -328,6 +356,8 @@ bool StdMeshersGUI_NbSegmentsCreator::storeParamsToHypo( const NbSegmentsHypothe //setting of function must follow after setConversionMode, because otherwise //the function will be checked with old conversion mode, so that it may occurs //unexpected errors for user + + h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); } catch(const SALOME::SALOME_Exception& ex) { @@ -341,6 +371,8 @@ bool StdMeshersGUI_NbSegmentsCreator::readParamsFromWidgets( NbSegmentsHypothesi { h_data.myName = myName ? myName->text() : ""; h_data.myNbSeg = myNbSeg->value(); + h_data.myNbSegVarName = myNbSeg->text(); + h_data.myScaleVarName = myScale->text(); h_data.myDistrType = myDistr->currentIndex(); h_data.myConv = myConv->checkedId(); h_data.myScale = myScale->value(); diff --git a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.h b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.h index b64ea664a..ba7c7bff8 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.h +++ b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.h @@ -34,7 +34,7 @@ #include #include CORBA_SERVER_HEADER(SMESH_Mesh) -class QtxIntSpinBox; +class SalomeApp_IntSpinBox; class QtxComboBox; class SMESHGUI_SpinBox; class StdMeshersGUI_DistrTableFrame; @@ -51,6 +51,7 @@ typedef struct double myScale; SMESH::double_array myTable; QString myName, myExpr; + QString myNbSegVarName, myScaleVarName; } NbSegmentsHypothesisData; @@ -62,7 +63,7 @@ public: StdMeshersGUI_NbSegmentsCreator(); virtual ~StdMeshersGUI_NbSegmentsCreator(); - virtual bool checkParams() const; + virtual bool checkParams( QString& ) const; protected: virtual QFrame* buildFrame(); @@ -78,7 +79,7 @@ private: bool storeParamsToHypo( const NbSegmentsHypothesisData& ) const; private: - QtxIntSpinBox* myNbSeg; + SalomeApp_IntSpinBox* myNbSeg; QtxComboBox* myDistr; SMESHGUI_SpinBox* myScale; StdMeshersGUI_DistrTableFrame* myTable; diff --git a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx index ca8e3a684..56e31b5a6 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx @@ -33,6 +33,7 @@ #include #include #include +#include // SALOME GUI includes #include @@ -340,8 +341,11 @@ namespace { */ //================================================================================ -bool StdMeshersGUI_StdHypothesisCreator::checkParams() const +bool StdMeshersGUI_StdHypothesisCreator::checkParams( QString& msg ) const { + if( !SMESHGUI_GenericHypothesisCreator::checkParams( msg ) ) + return false; + // check if object reference parameter is set, as it has no default value bool ok = true; if ( hypType().startsWith("ProjectionSource" )) @@ -399,6 +403,7 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const } QString valueStr = stdParamValues( params ); + QStringList aVariablesList = getVariablesFromDlg(); if( res && !params.isEmpty() ) { @@ -408,7 +413,9 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() ); h->SetLength( params[0].myValue.toDouble() ); + h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); h->SetPrecision( params[1].myValue.toDouble() ); + h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); } else if( hypType()=="MaxLength" ) { @@ -429,6 +436,7 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hypothesis() ); h->SetLength( params[0].myValue.toDouble() ); + h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); } else if( hypType()=="Arithmetic1D" ) { @@ -436,13 +444,15 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() ); h->SetLength( params[0].myValue.toDouble(), true ); + h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); h->SetLength( params[1].myValue.toDouble(), false ); + h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); } else if( hypType()=="MaxElementArea" ) { StdMeshers::StdMeshers_MaxElementArea_var h = StdMeshers::StdMeshers_MaxElementArea::_narrow( hypothesis() ); - + h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); h->SetMaxElementArea( params[0].myValue.toDouble() ); } else if( hypType()=="MaxElementVolume" ) @@ -451,6 +461,7 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const StdMeshers::StdMeshers_MaxElementVolume::_narrow( hypothesis() ); h->SetMaxElementVolume( params[0].myValue.toDouble() ); + h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); } else if( hypType()=="StartEndLength" ) { @@ -458,13 +469,15 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() ); h->SetLength( params[0].myValue.toDouble(), true ); + h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); h->SetLength( params[1].myValue.toDouble(), false ); + h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); } else if( hypType()=="Deflection1D" ) { StdMeshers::StdMeshers_Deflection1D_var h = StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() ); - + h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); h->SetDeflection( params[0].myValue.toDouble() ); } else if( hypType()=="AutomaticLength" ) @@ -480,6 +493,7 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const StdMeshers::StdMeshers_NumberOfLayers::_narrow( hypothesis() ); h->SetNumberOfLayers( params[0].myValue.toInt() ); + h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); } else if( hypType()=="LayerDistribution" ) { @@ -487,8 +501,10 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const StdMeshers::StdMeshers_LayerDistribution::_narrow( hypothesis() ); StdMeshersGUI_LayerDistributionParamWdg* w = widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 ); - + h->SetLayerDistribution( w->GetHypothesis() ); + h->SetParameters(w->GetHypothesis()->GetParameters()); + w->GetHypothesis()->ClearParameters(); } else if( hypType()=="ProjectionSource1D" ) { @@ -558,20 +574,25 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const p.append( item ); customWidgets()->append(0); } - + SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis(); + SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters(); if( hypType()=="LocalLength" ) { StdMeshers::StdMeshers_LocalLength_var h = StdMeshers::StdMeshers_LocalLength::_narrow( hyp ); - + item.myName = tr("SMESH_LOCAL_LENGTH_PARAM"); - item.myValue = h->GetLength(); - p.append( item ); + if(!initVariableName(aParameters,item,0)) + item.myValue = h->GetLength(); + p.append( item ); + item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION"); - item.myValue = h->GetPrecision(); + if(!initVariableName(aParameters,item,1)) + item.myValue = h->GetPrecision(); p.append( item ); + } else if( hypType()=="MaxLength" ) { @@ -612,7 +633,9 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hyp ); item.myName = tr("SMESH_LOCAL_LENGTH_PARAM"); - item.myValue = h->GetLength(); + if(!initVariableName(aParameters,item,0)) + item.myValue = h->GetLength(); + p.append( item ); } else if( hypType()=="Arithmetic1D" ) @@ -621,10 +644,13 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp ); item.myName = tr( "SMESH_START_LENGTH_PARAM" ); - item.myValue = h->GetLength( true ); + if(!initVariableName(aParameters,item,0)) + item.myValue = h->GetLength( true ); p.append( item ); + item.myName = tr( "SMESH_END_LENGTH_PARAM" ); - item.myValue = h->GetLength( false ); + if(!initVariableName(aParameters,item,1)) + item.myValue = h->GetLength( false ); p.append( item ); } else if( hypType()=="MaxElementArea" ) @@ -633,8 +659,10 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const StdMeshers::StdMeshers_MaxElementArea::_narrow( hyp ); item.myName = tr( "SMESH_MAX_ELEMENT_AREA_PARAM" ); - item.myValue = h->GetMaxElementArea(); + if(!initVariableName(aParameters,item,0)) + item.myValue = h->GetMaxElementArea(); p.append( item ); + } else if( hypType()=="MaxElementVolume" ) { @@ -642,7 +670,8 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const StdMeshers::StdMeshers_MaxElementVolume::_narrow( hyp ); item.myName = tr( "SMESH_MAX_ELEMENT_VOLUME_PARAM" ); - item.myValue = h->GetMaxElementVolume(); + if(!initVariableName(aParameters,item,0)) + item.myValue = h->GetMaxElementVolume(); p.append( item ); } else if( hypType()=="StartEndLength" ) @@ -651,19 +680,25 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const StdMeshers::StdMeshers_StartEndLength::_narrow( hyp ); item.myName = tr( "SMESH_START_LENGTH_PARAM" ); - item.myValue = h->GetLength( true ); + + if(!initVariableName(aParameters,item,0)) + item.myValue = h->GetLength( true ); p.append( item ); + item.myName = tr( "SMESH_END_LENGTH_PARAM" ); - item.myValue = h->GetLength( false ); + if(!initVariableName(aParameters,item,1)) + item.myValue = h->GetLength( false ); p.append( item ); + } else if( hypType()=="Deflection1D" ) { StdMeshers::StdMeshers_Deflection1D_var h = StdMeshers::StdMeshers_Deflection1D::_narrow( hyp ); - + item.myName = tr( "SMESH_DEFLECTION1D_PARAM" ); - item.myValue = h->GetDeflection(); + if(!initVariableName(aParameters,item,0)) + item.myValue = h->GetDeflection(); p.append( item ); } else if( hypType()=="AutomaticLength" ) @@ -683,15 +718,25 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const StdMeshers::StdMeshers_NumberOfLayers::_narrow( hyp ); item.myName = tr( "SMESH_NUMBER_OF_LAYERS" ); - item.myValue = (int) h->GetNumberOfLayers(); + if(!initVariableName(aParameters,item,0)) + item.myValue = (int) h->GetNumberOfLayers(); p.append( item ); } else if( hypType()=="LayerDistribution" ) - { - StdMeshers::StdMeshers_LayerDistribution_var h = + { + StdMeshers::StdMeshers_LayerDistribution_var h = StdMeshers::StdMeshers_LayerDistribution::_narrow( hyp ); item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item ); + + //Set into not published hypo last variables + QStringList aLastVarsList; + for(int i = 0;ilength();i++) + aLastVarsList.append(QString(aParameters[i].in())); + + if(!aLastVarsList.isEmpty()) + h->GetLayerDistribution()->SetLastParameters(SMESHGUI::JoinObjectParameters(aLastVarsList)); + customWidgets()->append ( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg())); } @@ -988,3 +1033,21 @@ void StdMeshersGUI_StdHypothesisCreator::valueChanged( QWidget* paramWidget) } } } + +//================================================================================ +/*! + * + */ +//================================================================================ + +bool StdMeshersGUI_StdHypothesisCreator::initVariableName(SMESH::ListOfParameters_var theParameters, + StdParam &theParams, + int order) const +{ + QString aVaribaleName = (theParameters->length() > order) ? QString(theParameters[order].in()) : QString(""); + theParams.isVariable = !aVaribaleName.isEmpty(); + if(theParams.isVariable) + theParams.myValue = aVaribaleName; + + return theParams.isVariable; +} diff --git a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.h b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.h index 8d45eb94d..0973c5c03 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.h +++ b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.h @@ -27,9 +27,9 @@ // SMESH includes #include "SMESH_StdMeshersGUI.hxx" - #include + /*! * \brief Class for creation of standard hypotheses */ @@ -41,7 +41,7 @@ public: StdMeshersGUI_StdHypothesisCreator( const QString& ); virtual ~StdMeshersGUI_StdHypothesisCreator(); - virtual bool checkParams() const; + virtual bool checkParams( QString& ) const; protected: virtual QFrame* buildFrame (); @@ -59,6 +59,7 @@ protected: virtual QWidget* getWidgetForParam( int paramIndex ) const; virtual ListOfWidgets* customWidgets() const; virtual void onReject(); + virtual bool initVariableName(SMESH::ListOfParameters_var theParameters, StdParam& theParams, int order) const; virtual void valueChanged( QWidget* ); -- 2.39.2