# search Salome binaries in PATH variable
AC_PATH_PROG(TEMP, $1)
if test "x${TEMP}" != "x" ; then
- AC_MSG_RESULT(libLightApp.so was found at : ${TEMP})
+ AC_MSG_RESULT($1 was found at : ${TEMP})
SALOME_BIN_DIR=`dirname ${TEMP}`
SALOME_GUI_DIR=`cd ${SALOME_BIN_DIR}/../..; pwd`
fi
fi
fi
-if test -f ${SALOME_GUI_DIR}/lib${LIB_LOCATION_SUFFIX}/salome/$1 ; then
+if test -f ${SALOME_GUI_DIR}/bin/salome/$1 ; then
SalomeGUI_ok=yes
AC_MSG_RESULT(Using SALOME GUI distribution in ${SALOME_GUI_DIR})
])dnl
AC_DEFUN([CHECK_SALOME_GUI],[
- CHECK_GUI([libLightApp.so],
+ CHECK_GUI([SUITApp],
[SALOME GUI])
-])dnl
\ No newline at end of file
+])dnl
#------------------------------------------------------------
AC_DEFUN([CHECK_CORBA_IN_GUI],[
- CHECK_GUI([libSalomeApp.so],
+ CHECK_GUI([SALOME_Session_Server],
[CORBA SALOME GUI])
CORBA_IN_GUI=${SalomeGUI_ok}
AC_SUBST(CORBA_IN_GUI)
fi
fi
fi
+if test "x$pyqt_uic_ok" == "xno"; then
+ dnl try in $PATH
+ AC_PATH_PROG(PYUIC, pyuic)
+ if test "x$PYUIC" != x; then
+ PYQTDIR=$PYUIC
+ PYQTDIR=`dirname $PYQTDIR`
+ PYQTDIR=`dirname $PYQTDIR`
+ pyqt_uic_ok=yes
+ fi
+fi
if test "x$pyqt_uic_ok" == "xno"; then
dnl try ${SIPDIR}
if test "x${SIPDIR}" != "x"; then
fi
fi
if test "x$pyqt_lib_ok" == "xno"; then
- dnl try {PYQTDIR}/lib
- if test -d {PYQTDIR}/lib; then
+ dnl try ${PYQTDIR}/lib
+ if test -d ${PYQTDIR}/lib; then
AC_CHECK_FILE(${PYQTDIR}/lib/libqtcmodule.so,pyqt_lib_ok=yes,pyqt_lib_ok=no)
if test "x$pyqt_lib_ok" == "xyes"; then
PYQT_LIBS="-L${PYQTDIR}/lib -lqtcmodule"
fi
fi
if test "x$pyqt_lib_ok" == "xno"; then
- dnl try {PYQTDIR}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/site-packages
- if test -d {PYQTDIR}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/site-packages; then
+ dnl try ${PYQTDIR}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/site-packages
+ if test -d ${PYQTDIR}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/site-packages; then
AC_CHECK_FILE(${PYQTDIR}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/site-packages/libqtcmodule.so,pyqt_lib_ok=yes,pyqt_lib_ok=no)
if test "x$pyqt_lib_ok" == "xyes"; then
PYQT_LIBS="-L${PYQTDIR}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/site-packages -lqtcmodule"
fi
fi
fi
+if test "x$pyqt_sips_ok" == "xno"; then
+ dnl try ${PYQTDIR}/share/sip/qt
+ if test "x${PYQTDIR}" != "x"; then
+ if test -d ${PYQTDIR}/share/sip/qt ; then
+ AC_CHECK_FILE(${PYQTDIR}/share/sip/qt/qglobal.sip,pyqt_sips_ok=yes,pyqt_sips_ok=no)
+ if test "x$pyqt_sips_ok" == "xyes"; then
+ PYQT_SIPS="${PYQTDIR}/share/sip/qt"
+ fi
+ fi
+ fi
+fi
if test "x$pyqt_sips_ok" == "xno"; then
dnl try ${SIPDIR}/sip
if test "x${SIPDIR}" != "x"; then
SIP_VERS=v4_old ;;
4.2*)
SIP_VERS=v4_new ;;
+ 4.3*)
+ SIP_VERS=v4_new ;;
+ 4.4*)
+ SIP_VERS=v4_new ;;
*)
AC_MSG_RESULT(sip version $version not supported)
SIP_VERS=unsupported ;;
esac
+ if test "x$SIPDIR" = "x" ; then
+ SIPDIR=`dirname $SIP`
+ SIPDIR=`dirname $SIPDIR`
+ fi
+
sip_ok=no
dnl Search sip.h file
if test "x$SIPDIR" != "x" ; then
PACKAGE=salome
AC_SUBST(PACKAGE)
-VERSION=3.2.2
-XVERSION=0x030202
+VERSION=3.2.4
+XVERSION=0x030204
AC_SUBST(VERSION)
AC_SUBST(XVERSION)
<style type="text/css">\r
<!--\r
p.whs1 { font-weight:bold; }\r
-img_whs2 { border:none; border-style:none; width:752px; height:646px; float:none; }\r
+img_whs2 { border:none; width:752px; height:646px; float:none; border-style:none; }\r
ul.whs3 { list-style:disc; }\r
-p.whs4 { font-weight:normal; }\r
-p.whs5 { font-weight:bold; margin-left:57px; }\r
-p.whs6 { font-weight:bold; margin-left:0px; }\r
-p.whs7 { font-weight:bold; margin-left:38px; }\r
-p.whs8 { margin-left:0px; font-weight:bold; }\r
-p.whs9 { margin-left:38px; font-weight:bold; }\r
-p.whs10 { margin-left:0px; text-align:justify; }\r
-p.whs11 { margin-left:38px; }\r
-img_whs12 { border:none; width:752px; height:646px; float:none; }\r
-p.whs13 { font-weight:bold; margin-left:36px; }\r
-p.whs14 { margin-left:0px; text-align:justify; font-weight:bold; }\r
-p.whs15 { margin-left:0px; text-align:justify; font-weight:normal; }\r
-p.whs16 { text-align:justify; font-weight:bold; margin-left:38px; }\r
-ol.whs17 { list-style:disc; }\r
-ul.whs18 { list-style:square; }\r
-p.whs19 { font-style:normal; }\r
-p.whs20 { margin-left:76px; }\r
-p.whs21 { text-align:justify; font-weight:bold; margin-left:0px; }\r
-p.whs22 { margin-left:38px; text-align:justify; font-weight:bold; }\r
-p.whs23 { text-align:justify; font-weight:bold; margin-left:76px; }\r
+p.whs4 { font-weight:bold; margin-left:38px; }\r
+p.whs5 { margin-left:38px; }\r
+p.whs6 { font-weight:normal; }\r
+p.whs7 { font-weight:bold; margin-left:57px; }\r
+p.whs8 { font-weight:bold; margin-left:0px; }\r
+p.whs9 { margin-left:0px; font-weight:bold; }\r
+p.whs10 { margin-left:38px; font-weight:bold; }\r
+p.whs11 { margin-left:36px; }\r
+p.whs12 { margin-left:0px; text-align:justify; }\r
+ol.whs13 { list-style:disc; }\r
+p.whs14 { font-family:'Times New Roman' , serif; margin-left:0px; font-weight:normal; }\r
+p.whs15 { font-family:'Times New Roman' , serif; margin-left:0px; font-weight:bold; }\r
+img_whs16 { border:none; width:752px; height:646px; float:none; }\r
+p.whs17 { font-weight:bold; margin-left:36px; }\r
+p.whs18 { margin-left:0px; text-align:justify; font-weight:bold; }\r
+p.whs19 { margin-left:0px; text-align:justify; font-weight:normal; }\r
+p.whs20 { text-align:justify; font-weight:bold; margin-left:38px; }\r
+ul.whs21 { list-style:square; }\r
+p.whs22 { font-style:normal; }\r
+p.whs23 { margin-left:76px; }\r
+p.whs24 { text-align:justify; font-weight:bold; margin-left:0px; }\r
+p.whs25 { margin-left:38px; text-align:justify; font-weight:bold; }\r
+p.whs26 { text-align:justify; font-weight:bold; margin-left:76px; }\r
-->\r
</style><script type="text/javascript" language="JavaScript">\r
<!--\r
if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4))\r
{\r
var strNSS = "<style type='text/css'>";\r
- strNSS += "p.whs6 {margin-left:1pt; }";\r
strNSS += "p.whs8 {margin-left:1pt; }";\r
- strNSS += "p.whs10 {margin-left:1pt; }";\r
+ strNSS += "p.whs9 {margin-left:1pt; }";\r
+ strNSS += "p.whs12 {margin-left:1pt; }";\r
strNSS += "p.whs14 {margin-left:1pt; }";\r
strNSS += "p.whs15 {margin-left:1pt; }";\r
- strNSS += "p.whs21 {margin-left:1pt; }";\r
+ strNSS += "p.whs18 {margin-left:1pt; }";\r
+ strNSS += "p.whs19 {margin-left:1pt; }";\r
+ strNSS += "p.whs24 {margin-left:1pt; }";\r
strNSS +="</style>";\r
document.write(strNSS);\r
}\r
\r
<p> </p>\r
\r
+<p class="whs1"><span><B>MED import Preferences</B></span></p>\r
+\r
+<p> </p>\r
+\r
+<p><img src="pics/ppref1.png" x-maintain-ratio="TRUE" width="752px" height="646px" border="0" class="img_whs2"></p>\r
+\r
+<p> </p>\r
+\r
+<ul type="disc" class="whs3">\r
+ \r
+ <li class=kadov-p><p class="whs1">MED files import </p></li>\r
+ \r
+ <li class=kadov-p><p class="whs4">Use \r
+ Build Progress - <span style="font-weight: normal;">when this option is \r
+ checked you can choose all other import MED options at the moment of loading \r
+ of each file using </span>Build Progress<span style="font-weight: normal;"> \r
+ menu, otherwise the loading will be done according to the </span>Preferences<span \r
+ style="font-weight: normal;"> without addressing to the user.</span> </p></li>\r
+ \r
+ <li class=kadov-p><p class="whs4">Full \r
+ MED Loading - <span style="font-weight: normal;">when this option is checked, \r
+ the MED file is fully loaded in the study, and no additional access to \r
+ the MED file is needed during the session. Reversibly, when unchecked, \r
+ the MED file is loaded on demand. This is the default behaviour in SALOME \r
+ and recommended for big files to optimize memory usage.</span> </p></li>\r
+ \r
+ <li class=kadov-p><p class="whs5"><span style="font-weight: bold;"><B>Build \r
+ at once</B></span> - when this option is checked, you can't perform any operations \r
+ until the MED file is fully loaded and processed. </p></li>\r
+ \r
+ <li class=kadov-p><p class="whs4">Build \r
+ fields - <span style="font-weight: normal;">when \r
+ this</span> <span style="font-weight: normal;">option is checked, the \r
+ fields are built automatically at loading. </span></p></li>\r
+ \r
+ <li class=kadov-p><p class="whs4">Build \r
+ min/max - <span style="font-weight: normal;">when this option is checked, \r
+ minimum and maximum values of the time stamps are found at loading. </span></p></li>\r
+ \r
+ <li class=kadov-p><p class="whs4">Build \r
+ groups - <span style="font-weight: normal;">when this</span> <span style="font-weight: normal;">option \r
+ is checked, the groups and families are built automatically at loading. \r
+ </span></p></li>\r
+ \r
+ <li class=kadov-p><p class="whs4">Close \r
+ dialog at finish - <span style="font-weight: normal;">when this option \r
+ is checked, the dialog box is closed after loading of the selected MED \r
+ file. When unchecked, it allows loading other MED files. </span></p></li>\r
+</ul>\r
+\r
+<p> </p>\r
+\r
<p class="whs1">Scalar Bar Preferences</p>\r
\r
<p> </p>\r
\r
<ul type="disc" class="whs3">\r
\r
- <li class=kadov-p><p class="whs4"><span style="font-weight: bold;"><B>Scalar \r
+ <li class=kadov-p><p class="whs6"><span style="font-weight: bold;"><B>Scalar \r
Mode</B></span> - this feature allows refining the value to be inspected:</p></li>\r
\r
- <li class=kadov-p><p class="whs5">Modulus: \r
+ <li class=kadov-p><p class="whs7">Modulus: \r
<span style="font-weight: normal;">value of a scalar or modulus of a vector.</span></p></li>\r
\r
- <li class=kadov-p><p class="whs5">Component \r
+ <li class=kadov-p><p class="whs7">Component \r
N: <span style="font-weight: normal;">Nth component of a vector, a tensor \r
or a matrix..</span></p></li>\r
\r
- <li class=kadov-p><p class="whs4"><span style="font-weight: bold;"><B>Logarithmic \r
+ <li class=kadov-p><p class="whs6"><span style="font-weight: bold;"><B>Logarithmic \r
Scaling</B></span> - this checkbox toggles logarithmic scaling.</p></li>\r
\r
- <li class=kadov-p><p class="whs4"><span style="font-weight: bold;"><B>Ranges \r
+ <li class=kadov-p><p class="whs6"><span style="font-weight: bold;"><B>Ranges \r
to Use</B></span> - you can use either Field Range or Imposed Range.<span \r
style="margin-left: 0px;"> </span><span style="margin-left: 0px; text-indent: 12px;">.</span></p></li>\r
</ul>\r
horizontal orientation of the</span> <span style="font-weight: normal;">Scalar \r
Bar.</span></p></li>\r
\r
- <li class=kadov-p><p class="whs6">Origin \r
+ <li class=kadov-p><p class="whs8">Origin \r
& Size Vertical & Horizontal - a<span style="font-weight: normal;">llows \r
to define placement (</span>X <span style="font-weight: normal;">and</span> \r
Y<span style="font-weight: normal;">) and lookout (</span>Width and Height) \r
<span style="font-weight: normal;">of Scalar Bars</span></p></li>\r
\r
- <li class=kadov-p><p class="whs7">X: \r
+ <li class=kadov-p><p class="whs4">X: \r
<span style="font-weight: normal;">abscissa of the point of origin (from \r
the left side)</span></p></li>\r
\r
- <li class=kadov-p><p class="whs7">Y: \r
+ <li class=kadov-p><p class="whs4">Y: \r
<span style="font-weight: normal;">ordinate of the origin of the bar (from \r
the bottom)</span></p></li>\r
\r
- <li class=kadov-p><p class="whs8">Scalar \r
+ <li class=kadov-p><p class="whs9">Scalar \r
bars default position</p></li>\r
\r
- <li class=kadov-p><p class="whs9">Arrange \r
+ <li class=kadov-p><p class="whs10">Arrange \r
Scalar Bars - <span style="font-weight: normal;">this option prevents \r
superposition of scalar bars during visualisation of several fields in \r
the same window. If checked, a separate scalar bar is displayed for each \r
\r
<p> </p>\r
\r
-<p class="whs1">Sweep, MED Import Preferences</p>\r
+<p class="whs1">Cut Lines Preferences</p>\r
\r
<p class="whs1"> </p>\r
\r
-<p class="whs4"><img src="pics/pref32.png" x-maintain-ratio="TRUE" width="752px" height="646px" border="0" class="img_whs2"></p>\r
+<p class="whs1"><img src="pics/ppref2.png" x-maintain-ratio="TRUE" width="752px" height="646px" border="0" class="img_whs2"></p>\r
\r
-<p class="whs4"> </p>\r
+<p class="whs1"> </p>\r
+\r
+<ul type="disc" class="whs3">\r
+ \r
+ <li class=kadov-p><p class="whs1">CutLine Preferences \r
+ </p></li>\r
+</ul>\r
+\r
+<ul type="disc" class="whs3">\r
+ \r
+ <li class=kadov-p><p class="whs11"><span style="font-weight: bold;"><B>Show \r
+ preview </B></span>check box allows to edit the parameters of the presentation \r
+ and simultaneously observe the preview of this presentation in the viewer.</p></li>\r
+ \r
+ <li class=kadov-p><p class="whs11"><span style="font-weight: bold;"><B>Invert \r
+ all curves</B></span> check box allows to invert the resulting curves. </p></li>\r
+ \r
+ <li class=kadov-p><p class="whs11"><span style="font-weight: bold;"><B>Use \r
+ absolute length </B></span>check box allows to use absolute length for curves. \r
+ </p></li>\r
+ \r
+ <li class=kadov-p><p class="whs11"><span style="font-weight: bold;"><B>Generate \r
+ Data Table: </B></span>If this check box is marked, <span style="font-weight: bold;"><B>Post \r
+ Pro</B></span> will automatically generate a data table on the basis of your \r
+ Cut Lines presentation. This table will be created in the structure of \r
+ the study. <span style="font-weight: bold;"><B> </B></span></p></li>\r
+ \r
+ <li class=kadov-p><p class="whs11"><span style="font-weight: bold;"><B>Generate \r
+ Curves: </B></span>If this check box is marked, <span style="font-weight: bold;"><B>Post \r
+ Pro</B></span> will \r
+ automatically generate curve lines on the basis of values taken from the \r
+ generated data table. These curves will be created in the structure of \r
+ the study and can be visualized in a XY plot. </p></li>\r
+</ul>\r
+\r
+<p class="whs11"> </p>\r
+\r
+<p class="whs1"><span><B>Sweep Preferences</B></span></p>\r
+\r
+<p class="whs1"> </p>\r
+\r
+<p class="whs6"><img src="pics/ppref3.png" x-maintain-ratio="TRUE" width="752px" height="646px" border="0" class="img_whs2"></p>\r
+\r
+<p class="whs6"> </p>\r
\r
<ul type="disc" class="whs3">\r
\r
\r
<ul type="disc" class="whs3">\r
\r
- <li class=kadov-p><p class="whs10"><span \r
+ <li class=kadov-p><p class="whs12"><span \r
style="font-weight: bold;"><B>Time step -</B></span> in this menu you can set \r
the<span style="font-weight: bold;"> <B></B></span>time of representation of \r
one step.</p></li>\r
\r
- <li class=kadov-p><p class="whs10"><span \r
+ <li class=kadov-p><p class="whs12"><span \r
style="font-weight: bold;"><B>Number of cycles -</B></span> in this menu you \r
can define the number of times this animation will be repeated.</p></li>\r
\r
- <li class=kadov-p><p class="whs10"><span \r
+ <li class=kadov-p><p class="whs12"><span \r
style="font-weight: bold;"><B>Number of steps</B></span> - in this menu you can \r
define the number of steps, which will compose the whole animation.</p></li>\r
</ul>\r
</ul>\r
\r
-<p class="whs10"> </p>\r
+<p class="whs12"> </p>\r
\r
<ul type="disc" class="whs3">\r
\r
- <li class=kadov-p><p class="whs1">MED files import </p></li>\r
- \r
- <li class=kadov-p><p class="whs7">Use \r
- Build Progress - <span style="font-weight: normal;">when this option is \r
- checked you can choose all other import MED options at the moment of loading \r
- of each file using </span>Build Progress<span style="font-weight: normal;"> \r
- menu, otherwise the loading will be done according to the </span>Preferences<span \r
- style="font-weight: normal;"> without addressing to the user.</span> </p></li>\r
- \r
- <li class=kadov-p><p class="whs7">Full \r
- MED Loading - <span style="font-weight: normal;">when this option is checked, \r
- the MED file is fully loaded in the study, and no additional access to \r
- the MED file is needed during the session. Reversibly, when unchecked, \r
- the MED file is loaded on demand. This is the default behaviour in SALOME \r
- and recommended for big files to optimize memory usage.</span> </p></li>\r
- \r
- <li class=kadov-p><p class="whs11"><span style="font-weight: bold;"><B>Build \r
- at once</B></span> - when this option is checked, you can't perform any operations \r
- until the MED file is fully loaded and processed. </p></li>\r
- \r
- <li class=kadov-p><p class="whs7">Build \r
- fields - <span style="font-weight: normal;">when \r
- this</span> <span style="font-weight: normal;">option is checked, the \r
- fields are built automatically at loading. </span></p></li>\r
- \r
- <li class=kadov-p><p class="whs7">Build \r
- min/max - <span style="font-weight: normal;">when this option is checked, \r
- minimum and maximum values of the time stamps are found at loading. </span></p></li>\r
- \r
- <li class=kadov-p><p class="whs7">Build \r
- groups - <span style="font-weight: normal;">when this</span> <span style="font-weight: normal;">option \r
- is checked, the groups and families are built automatically at loading. \r
- </span></p></li>\r
- \r
- <li class=kadov-p><p class="whs7">Close \r
- dialog at finish - <span style="font-weight: normal;">when this option \r
- is checked, the dialog box is closed after loading of the selected MED \r
- file. When unchecked, it allows loading other MED files. </span></p></li>\r
+ <li class=kadov-p><p class="whs1">Animation preferences</p></li>\r
</ul>\r
\r
-<p class="whs7"> </p>\r
+<ol type="disc" class="whs13">\r
+ \r
+ <ul type="disc" class="whs3">\r
+ \r
+ <li class=kadov-p><p class="whs14"><span style="font-weight: bold;"><B>Speed</B></span> \r
+ - allows to define the speed of the animation.</p></li>\r
+ \r
+ <li class=kadov-p><p class="whs14"><span style="font-weight: bold;"><B>Cycled \r
+ animation</B></span> - allows to start a cycled animation of the presentation.</p></li>\r
+ \r
+ <li class=kadov-p><p class="whs15">Use proportional \r
+ timing -<span style="font-weight: normal;"> allows to render the animation \r
+ with proportional periods of time between every frame (not depending on \r
+ the time stamps).</span></p></li>\r
+ \r
+ <li class=kadov-p><p class="whs15">Clean memory at \r
+ each frame - <span style="font-weight: normal;">this option allows to \r
+ optimize the performance of the operation.</span></p></li>\r
+ </ul>\r
+</ol>\r
\r
-<p class="whs8">Representation Preferences</p>\r
+<p class="whs12"> </p>\r
\r
-<p class="whs8"> </p>\r
+<p class="whs4"> </p>\r
\r
-<p class="whs6"><img src="pics/pref33.png" x-maintain-ratio="TRUE" width="752px" height="646px" border="0" class="img_whs12"></p>\r
+<p class="whs9">Representation Preferences</p>\r
\r
-<p class="whs6"> </p>\r
+<p class="whs9"> </p>\r
+\r
+<p class="whs8"><img src="pics/pref33.png" x-maintain-ratio="TRUE" width="752px" height="646px" border="0" class="img_whs16"></p>\r
+\r
+<p class="whs8"> </p>\r
\r
<ul type="disc" class="whs3">\r
\r
the default representation type for each field presentation.</span><span \r
style="margin-left: 40px; text-align: justify;"> </span></p></li>\r
\r
- <li class=kadov-p><p class="whs7">Use \r
+ <li class=kadov-p><p class="whs4">Use \r
Shading - <span style="font-weight: normal;">when this</span> <span style="font-weight: normal;">option \r
is checked, the objects will be displayed with shading.</span></p></li>\r
+ \r
+ <li class=kadov-p><p class="whs4">Display \r
+ only on creation<span style="font-weight: normal;"> - when this option \r
+ is checked, all previously created presentations will be automatically \r
+ removed from the viewer when a new presentation is created and displayed. \r
+ You can restore the previously created presentations using the Object \r
+ Browser. </span></p></li>\r
</ul>\r
\r
-<p class="whs6"> </p>\r
-\r
-<p class="whs6"> </p>\r
+<p class="whs8"> </p>\r
\r
-<p class="whs6">Gauss Points Preferences</p>\r
+<p class="whs8">Gauss Points Preferences</p>\r
\r
-<p class="whs13"> </p>\r
+<p class="whs17"> </p>\r
\r
-<p class="whs6"><img src="pics/pref34.png" x-maintain-ratio="TRUE" width="752px" height="646px" border="0" class="img_whs2"></p>\r
+<p class="whs8"><img src="pics/pref34.png" x-maintain-ratio="TRUE" width="752px" height="646px" border="0" class="img_whs2"></p>\r
\r
-<p class="whs13"> </p>\r
+<p class="whs17"> </p>\r
\r
<ul type="disc" class="whs3">\r
\r
\r
<ul type="disc" class="whs3">\r
\r
- <li class=kadov-p><p class="whs14">Primitive type \r
+ <li class=kadov-p><p class="whs18">Primitive type \r
- <span style="font-weight: normal;">provides choice between </span>Point \r
sprites<span style="font-weight: normal;">, </span>Open GL points<span \r
style="font-weight: normal;"> and </span>Geometrical Spheres<span style="font-weight: normal;">.</span></p></li>\r
\r
- <li class=kadov-p><p class="whs15"><span style="font-weight: bold;"><B>Maximum \r
+ <li class=kadov-p><p class="whs19"><span style="font-weight: bold;"><B>Maximum \r
Size</B></span> <span style="font-weight: bold;"><B>(Clamp)</B></span> - defines \r
the maximum size of sprite points ranging from 1 to 512. By default the \r
value is set to 256 pixels. </p></li>\r
\r
- <li class=kadov-p><p class="whs14">Main Texture - \r
+ <li class=kadov-p><p class="whs18">Main Texture - \r
<span style="font-weight: normal;">path \r
to the </span>Main Texture<span style="font-weight: normal;"> (16x16 pixels) \r
which defines the shape of the point sprite used for rendering.</span></p></li>\r
\r
- <li class=kadov-p><p class="whs10"><span \r
+ <li class=kadov-p><p class="whs12"><span \r
style="font-weight: bold;"><B>Alpha Channel Texture (16*16) -</B></span> path \r
to the <span style="font-weight: bold;"><B>Alpha Channel Texture</B></span> which \r
defines the transparency of the point sprite.</p></li>\r
\r
- <li class=kadov-p><p class="whs14">Alpha Channel Threshold \r
+ <li class=kadov-p><p class="whs18">Alpha Channel Threshold \r
- <span style="font-weight: normal;">defines the level of transparency \r
ranging from 0 to 1.</span> </p></li>\r
\r
- <li class=kadov-p><p class="whs14">Geometrical Sphere \r
+ <li class=kadov-p><p class="whs18">Geometrical Sphere \r
Resolution - <span style="font-weight: normal;">defines the number of \r
faces of</span> Geometry Spheres.</p></li>\r
\r
- <li class=kadov-p><p class="whs14">Notify when number \r
+ <li class=kadov-p><p class="whs18">Notify when number \r
of faces exceeds -<span style="font-weight: normal;"> limitation of the \r
number of faces;</span> <span style="font-weight: normal;">the user will \r
be warned if it exceeds the given value.</span></p></li>\r
</ul>\r
</ul>\r
\r
-<p class="whs13"> </p>\r
+<p class="whs17"> </p>\r
\r
<ul type="disc" class="whs3">\r
\r
\r
<ul type="disc" class="whs3">\r
\r
- <li class=kadov-p><p class="whs16">Range value for min \r
+ <li class=kadov-p><p class="whs20">Range value for min \r
and max size - <span style="font-weight: normal;">these two parameters \r
will be respectively multiplied by a reference length (average size of \r
cells of the mesh) to define the range for minimum and maximum size of \r
a point during rendering (at magnification = 100%). Default values are:</span></p></li>\r
\r
- <ol type="disc" class="whs17">\r
+ <ul type="disc" class="whs3">\r
\r
<ul type="disc" class="whs3">\r
\r
scale: <span style="font-weight: bold;"><B>min = 10%</B></span>, <span style="font-weight: bold;"><B>max \r
= 33%</B></span></p></li>\r
\r
- <ul type="square" class="whs18">\r
+ <ul type="square" class="whs21">\r
\r
- <li class=kadov-p><p class="whs19">Min size \r
+ <li class=kadov-p><p class="whs22">Min size \r
is associated to the smallest real value (including negative values).</p></li>\r
\r
- <li class=kadov-p><p class="whs19">Max size \r
+ <li class=kadov-p><p class="whs22">Max size \r
is associated to the largest real value.</p></li>\r
</ul>\r
\r
scale: <span style="font-weight: bold;"><B>min = 0</B></span> (not editable), \r
<span style="font-weight: bold;"><B>max = 33%</B></span></p></li>\r
\r
- <ul type="square" class="whs18">\r
+ <ul type="square" class="whs21">\r
\r
- <li class=kadov-p><p class="whs19">Null size \r
+ <li class=kadov-p><p class="whs22">Null size \r
is associated to the 0 scalar value.</p></li>\r
\r
- <li class=kadov-p><p class="whs19">Max size \r
+ <li class=kadov-p><p class="whs22">Max size \r
is associated to the largest absolute value.</p></li>\r
</ul>\r
</ul>\r
- </ol>\r
+ </ul>\r
</ul>\r
\r
-<p class="whs20">Both values are dynamically updated by the \r
+<p class="whs23">Both values are dynamically updated by the \r
system according to the selected scalar bar. In the case of a <span style="font-weight: bold;"><B>Bicolor</B></span> \r
scale, the minimum value is set to 0 in the dialog and the control is \r
disabled.</p>\r
\r
<ul type="disc" class="whs3">\r
\r
- <li class=kadov-p><p class="whs11"><span style="font-weight: bold;"><B>Magnification \r
+ <li class=kadov-p><p class="whs5"><span style="font-weight: bold;"><B>Magnification \r
(%)</B></span> corresponds to the change of size of results at Gauss point \r
primitives in 2D space. Acceptable values range from 0 to N; 100% means \r
no magnification, 50% means half of its size, 200% mean twice its size \r
and so forth. By default this value is set to 100%.</p></li>\r
\r
- <li class=kadov-p><p class="whs11"><span style="font-weight: bold;"><B>+/- \r
+ <li class=kadov-p><p class="whs5"><span style="font-weight: bold;"><B>+/- \r
Ratio</B></span> corresponds to the number by which the magnification will \r
be respectively multiplied or divided at edition, ranging from 0.01 to \r
10. By default this value is set to 2.</p></li>\r
\r
<li class=kadov-p><p class="whs1">Geometry </p></li>\r
\r
- <li class=kadov-p><p class="whs11"><span style="font-weight: bold;"><B>Size \r
+ <li class=kadov-p><p class="whs5"><span style="font-weight: bold;"><B>Size \r
of points (%) </B></span>defines a value that will be multiplied by a reference \r
length (representative of the average size of cells of the mesh) to define \r
the size of points during rendering (at magnification = 100%). Default \r
values 10%.</p></li>\r
\r
- <li class=kadov-p><p class="whs13">Background \r
+ <li class=kadov-p><p class="whs17">Background \r
Color - <span style="font-weight: normal;"> allows \r
to select the color of points used for presentations. Click on the colored \r
line to access to the </span><a href="select_color_and_font.htm">Select \r
Color</a><span style="font-weight: normal;"> dialog box. </span></p></li>\r
</ul>\r
\r
-<p class="whs14"> </p>\r
+<p class="whs18"> </p>\r
\r
<ul type="disc" class="whs3">\r
\r
<li class=kadov-p><p class="whs1">Gauss Points Scalar \r
Bar</p></li>\r
\r
- <li class=kadov-p><p class="whs7">Active \r
+ <li class=kadov-p><p class="whs4">Active \r
Bar - <span style="font-weight: normal;">this option allows to choose</span> \r
Local<span style="font-weight: normal;"> or</span> Global <span style="font-weight: normal;">Bar \r
as active.</span></p></li>\r
\r
- <li class=kadov-p><p class="whs7">Display \r
+ <li class=kadov-p><p class="whs4">Display \r
Global Bar - <span style="font-weight: normal;">this option allows to \r
visualize or to hide the Global Bar.</span></p></li>\r
\r
- <li class=kadov-p><p class="whs7">Scalar \r
+ <li class=kadov-p><p class="whs4">Scalar \r
Bar Mode - <span style="font-weight: normal;">this option allows to choose</span> \r
<span style="font-weight: normal;">between</span> Bicolor <span style="font-weight: normal;">and</span> \r
Rainbow <span style="font-weight: normal;">Scalar Bar Mode.</span></p></li>\r
\r
- <li class=kadov-p><p class="whs7">Spacing \r
+ <li class=kadov-p><p class="whs4">Spacing \r
- <span style="font-weight: normal;">allows to define Spacing from 0.01 \r
to 1.</span></p></li>\r
</ul>\r
\r
-<p class="whs14"> </p>\r
+<p class="whs18"> </p>\r
\r
-<p class="whs6">Inside <span style="font-weight: normal;">and</span> \r
+<p class="whs8">Inside <span style="font-weight: normal;">and</span> \r
Outside Cursor Preferences<span style="font-weight: normal;"> allow to \r
set</span> Primitives, Size<span style="font-weight: normal;"> and</span> \r
Magnification<span style="font-weight: normal;"> for the respective zones.</span> \r
</p>\r
\r
-<p class="whs6"> </p>\r
+<p class="whs8"> </p>\r
\r
-<p class="whs21">Picking Preferences</p>\r
+<p class="whs24">Picking Preferences</p>\r
\r
-<p class="whs21"> </p>\r
+<p class="whs24"> </p>\r
\r
-<p class="whs21"><img src="pics/pref37.png" x-maintain-ratio="TRUE" width="752px" height="646px" border="0" class="img_whs2"></p>\r
+<p class="whs24"><img src="pics/pref37.png" x-maintain-ratio="TRUE" width="752px" height="646px" border="0" class="img_whs2"></p>\r
\r
-<p class="whs5"> </p>\r
+<p class="whs7"> </p>\r
\r
<ul type="disc" class="whs3">\r
\r
(from 0% = opaque to 100% = transparent) and <span style="font-weight: bold;"><B>Position</B></span> \r
of the window, which can be: </p></li>\r
\r
- <li class=kadov-p><p class="whs11"><span style="font-weight: bold;"><B>Centred \r
+ <li class=kadov-p><p class="whs5"><span style="font-weight: bold;"><B>Centred \r
below the point</B></span>, or</p></li>\r
\r
- <li class=kadov-p><p class="whs11">located at <span style="font-weight: bold;"><B>Top-left \r
+ <li class=kadov-p><p class="whs5">located at <span style="font-weight: bold;"><B>Top-left \r
corner of the 3D view</B></span></p></li>\r
\r
- <li class=kadov-p><p class="whs8">Movement \r
+ <li class=kadov-p><p class="whs9">Movement \r
of the Camera <span style="font-weight: normal;">can also be define by \r
the user. </span></p></li>\r
\r
- <li class=kadov-p><p class="whs11"><span style="font-weight: bold;"><B>Zoom \r
+ <li class=kadov-p><p class="whs5"><span style="font-weight: bold;"><B>Zoom \r
at first selected point -</B></span> This value is used to define the focal \r
distance at the first selected point (at the end of the movement of the \r
camera). This value is a ratio that will be multiplied by the current \r
zoom value.</p></li>\r
\r
- <li class=kadov-p><p class="whs9">Number \r
+ <li class=kadov-p><p class="whs10">Number \r
of steps between two positions - <span style="font-weight: normal;">defines \r
the smoothness of camera movement at selection by the number of iterations. \r
If set to 1 the camera is zoomed and centered at the point momentarily. \r
Greater numbers mean very slow camera movement.</span> </p></li>\r
\r
- <li class=kadov-p><p class="whs6">Display \r
+ <li class=kadov-p><p class="whs8">Display \r
parent mesh element - <span style="font-weight: normal;">allows to visualize \r
or hide the patent mesh element of the selected gauss point.</span> </p></li>\r
</ul>\r
\r
-<p class="whs16"> </p>\r
+<p class="whs20"> </p>\r
\r
-<p class="whs21">Navigation Preferences</p>\r
+<p class="whs24">Navigation Preferences</p>\r
\r
-<p class="whs16"> </p>\r
+<p class="whs20"> </p>\r
\r
-<p class="whs21"><img src="pics/pref38.png" x-maintain-ratio="TRUE" width="752px" height="646px" border="0" class="img_whs2"></p>\r
+<p class="whs24"><img src="pics/pref38.png" x-maintain-ratio="TRUE" width="752px" height="646px" border="0" class="img_whs2"></p>\r
\r
-<p class="whs22"> </p>\r
+<p class="whs25"> </p>\r
\r
-<p class="whs13"> </p>\r
+<p class="whs17"> </p>\r
\r
<ul type="disc" class="whs3">\r
\r
\r
<ul type="disc" class="whs3">\r
\r
- <li class=kadov-p><p class="whs16">Mouse Behaviour - <span \r
+ <li class=kadov-p><p class="whs20">Mouse Behaviour - <span \r
style="font-weight: normal;">this option allows to choose one of the modes \r
of work with mouse in Gauss Viewer. </span></p></li>\r
\r
- <li class=kadov-p><p class="whs23">Salome Standard Controls \r
+ <li class=kadov-p><p class="whs26">Salome Standard Controls \r
- <span style="font-weight: normal;">allows to manipulate objects in the \r
viewer with the mouse and locked Ctrl button: increase or decrease the \r
zoom ratio with the left mouse button, translate object in any direction \r
with the central mouse button or rotate it with the right mouse button. \r
</span></p></li>\r
\r
- <li class=kadov-p><p class="whs23">Keyboard Free - <span \r
+ <li class=kadov-p><p class="whs26">Keyboard Free - <span \r
style="font-weight: normal;">allows to manipulate objects in the viewer \r
with the mouse without locking Ctrl button</span>. <span style="font-weight: normal;">In \r
this case the operations are assigned to the buttons differently: rotation \r
both pressed in the same time.</span> </p></li>\r
</ul>\r
\r
-<p class="whs13"> </p>\r
+<p class="whs17"> </p>\r
\r
<ul type="disc" class="whs3">\r
\r
\r
<ul type="disc" class="whs3">\r
\r
- <li class=kadov-p><p class="whs16">[+]/[-] Speed Increment \r
+ <li class=kadov-p><p class="whs20">[+]/[-] Speed Increment \r
- <span style="font-weight: normal;">defines the number of units by which \r
the speed increases or respectively decreases after pressing [+] or [-] \r
keyboard buttons.</span></p></li>\r
</ul>\r
\r
-<p class="whs13"> </p>\r
+<p class="whs17"> </p>\r
\r
<ul type="disc" class="whs3">\r
\r
\r
<ul type="disc" class="whs3">\r
\r
- <li class=kadov-p><p class="whs16">Decrease Speed Increment \r
+ <li class=kadov-p><p class="whs20">Decrease Speed Increment \r
- <span style="font-weight: normal;">decreases by 1 the speed increment \r
used for the keyboard (same as [-] key).</span></p></li>\r
\r
- <li class=kadov-p><p class="whs16">Increase Speed Increment \r
+ <li class=kadov-p><p class="whs20">Increase Speed Increment \r
- <span style="font-weight: normal;">increase by 1 the speed increment \r
used for the keyboard (same as [+] key).</span></p></li>\r
\r
- <li class=kadov-p><p class="whs16">Decrease Gauss Points \r
+ <li class=kadov-p><p class="whs20">Decrease Gauss Points \r
Magnification - <span style="font-weight: normal;">divides the current \r
magnification by the magnification ratio.</span></p></li>\r
\r
- <li class=kadov-p><p class="whs16">Increase Gauss Points \r
+ <li class=kadov-p><p class="whs20">Increase Gauss Points \r
Magnification -<span style="font-weight: normal;"> multiplies the current \r
magnification by the magnification ratio.</span></p></li>\r
\r
- <li class=kadov-p><p class="whs16">Dominant / combined \r
+ <li class=kadov-p><p class="whs20">Dominant / combined \r
switch -<span style="font-weight: normal;"> toggles button to switch to \r
dominant or combined movements.</span></p></li>\r
</ul>\r
\r
-<p class="whs16"> </p>\r
+<p class="whs20"> </p>\r
\r
-<p class="whs16"> </p>\r
+<p class="whs20"> </p>\r
\r
-<p class="whs21">Recorder Preferences</p>\r
+<p class="whs24">Recorder Preferences</p>\r
\r
-<p class="whs21"> </p>\r
+<p class="whs24"> </p>\r
\r
-<p class="whs21"><img src="pics/pref39.png" x-maintain-ratio="TRUE" width="752px" height="646px" border="0" class="img_whs2"></p>\r
+<p class="whs24"><img src="pics/pref39.png" x-maintain-ratio="TRUE" width="752px" height="646px" border="0" class="img_whs2"></p>\r
\r
<p class="whs1"> </p>\r
\r
\r
<ul type="disc" class="whs3">\r
\r
- <li class=kadov-p><p class="whs16">Mode - <span style="font-weight: normal;">allows \r
+ <li class=kadov-p><p class="whs20">Mode - <span style="font-weight: normal;">allows \r
to choose from</span> <span style="font-weight: normal;">two recording \r
regimes:</span></p></li>\r
\r
- <li class=kadov-p><p class="whs23">Recording all displayed \r
+ <li class=kadov-p><p class="whs26">Recording all displayed \r
frames - <span style="font-weight: normal;">records exactly at the FPS \r
rate specified by the user.</span> </p></li>\r
\r
- <li class=kadov-p><p class="whs23">Recording at a given \r
+ <li class=kadov-p><p class="whs26">Recording at a given \r
FPS - <span style="font-weight: normal;">records only when the contents \r
of the viewer change (some activity is performed). In \r
the AVI file non-recorded images are substituted with the copies of the \r
latest recorded image, which produces files with lower quality but requires \r
less system resources.</span> </p></li>\r
\r
- <li class=kadov-p><p class="whs16">FPS - <span style="font-weight: normal;">allows \r
+ <li class=kadov-p><p class="whs20">FPS - <span style="font-weight: normal;">allows \r
to define the FPS (frames per second) rate for the clip. Set greater value \r
for better quality. </span></p></li>\r
\r
- <li class=kadov-p><p class="whs16">Quality - <span style="font-weight: normal;">allows \r
+ <li class=kadov-p><p class="whs20">Quality - <span style="font-weight: normal;">allows \r
to set the quality of the clip in the interval between 0 and 100.</span> \r
</p></li>\r
\r
- <li class=kadov-p><p class="whs16">Progressive - <span \r
+ <li class=kadov-p><p class="whs20">Progressive - <span \r
style="font-weight: normal;">allows to record a progressive API file.</span> \r
</p></li>\r
</ul>\r
\r
-<p class="whs16"> </p>\r
+<p class="whs20"> </p>\r
\r
-<p class="whs16"> </p>\r
+<p class="whs20"> </p>\r
\r
<p> </p>\r
\r
void CAM_Module::initialize( CAM_Application* app )
{
myApp = app;
- if (myApp) {
+ if ( myApp )
+ {
SUIT_Session* aSession = SUIT_Session::session();
- connect(aSession, SIGNAL( applicationClosed( SUIT_Application* ) ),
- this, SLOT( onApplicationClosed( SUIT_Application* ) ));
+ connect( aSession, SIGNAL( applicationClosed( SUIT_Application* ) ),
+ this, SLOT( onApplicationClosed( SUIT_Application* ) ) );
+
+ connect( myApp, SIGNAL( infoChanged( QString ) ), this, SLOT( onInfoChanged( QString ) ) );
}
}
{
}
+/*!Return true if module is active.*/
+bool CAM_Module::isActiveModule() const
+{
+ return application() ? application()->activeModule() == this : false;
+}
+
+/*!
+ Put the message into the status bar of the desktop. Message will be displayed
+ during specified \amscec milliseconds. If parameter \amsec is negative then
+ message will be persistently displayed when module is active.
+*/
+void CAM_Module::putInfo( const QString& msg, const int msec )
+{
+ if ( application() )
+ application()->putInfo( msg, msec );
+
+ if ( msec < 0 )
+ myInfo = msg;
+}
+
+/*!
+ Restore persistently displayed info string when previos information status string erasing
+ if module is active.
+*/
+void CAM_Module::onInfoChanged( QString txt )
+{
+ if ( txt.isEmpty() && isActiveModule() && !myInfo.isEmpty() && application() )
+ application()->putInfo( myInfo );
+}
+
+
+
/*!Public slot, nullify application pointer if the application was closed.*/
void CAM_Module::onApplicationClosed( SUIT_Application* theApp )
{
CAM_DataModel* dm = it.current()->dataModel();
if( it.current() == this && !camStudy->containsDataModel( dm ) )
{
- if( prev )
- camStudy->insertDataModel( it.current()->dataModel(), prev );
+ if ( prev )
+ camStudy->insertDataModel( it.current()->dataModel(), prev );
else
- camStudy->insertDataModel( it.current()->dataModel(), 0 );
+ camStudy->insertDataModel( it.current()->dataModel(), 0 );
}
prev = dm;
}
virtual void contextMenuPopup( const QString&, QPopupMenu*, QString& title ) {};
virtual void updateCommandsStatus() {};
+ virtual void putInfo( const QString&, const int = -1 );
+
+ bool isActiveModule() const;
+
/** @name Set Menu Shown*/
//@{
virtual void setMenuShown( const bool );
virtual void onApplicationClosed( SUIT_Application* );
+private slots:
+ void onInfoChanged( QString );
+
protected:
virtual CAM_DataModel* createDataModel();
CAM_Application* myApp;
QString myName;
QPixmap myIcon;
+ QString myInfo;
CAM_DataModel* myDataModel;
QMap<int, QAction*> myActionMap;
#pragma warning( default: 4251 )
#endif
-extern "C" {
+extern "C"
+{
typedef CAM_Module* (*GET_MODULE_FUNC)();
}
openDataModel( studyName(), dm );
else // no, just need to update data model's connection to study tree
//(some application may want to show model's root in a study tree even if a model is empty)
- {
dm->create( this );
- updateModelRoot( dm );
- }
+ updateModelRoot( dm );
}
/*! \retval false*/
IMPLEMENT_STANDARD_HANDLE(DDS_DicGroup, MMgt_TShared)
IMPLEMENT_STANDARD_RTTIEXT(DDS_DicGroup, MMgt_TShared)
+/*!
+ \class DDS_DicGroup
+
+ This class to provide set of DDS_DicItem objects from one component.
+*/
+
+/*!
+ Constructor. Create the group with name \aname.
+*/
DDS_DicGroup::DDS_DicGroup( const TCollection_AsciiString& name )
: MMgt_TShared(),
myName( name ),
{
}
+/*!
+ Copy constructor.
+*/
DDS_DicGroup::DDS_DicGroup( const DDS_DicGroup& )
{
}
+/*!
+ Get the name of group (component).
+*/
TCollection_AsciiString DDS_DicGroup::GetName() const
{
return myName;
}
+/*!
+ Returns the names list of defined unit systems.
+ Parameter \atheSystems will contains the sequence of string names.
+*/
void DDS_DicGroup::GetUnitSystems( TColStd_SequenceOfAsciiString& theSystemSeq ) const
{
theSystemSeq.Clear();
}
}
+/*!
+ Returns the label of unit system \aname. If unit system not found then empty string returned.
+*/
TCollection_ExtendedString DDS_DicGroup::GetUnitSystemLabel( const TCollection_AsciiString& name ) const
{
TCollection_ExtendedString aLabel;
return aLabel;
}
+/*!
+ Gets the name of active unit system.
+*/
TCollection_AsciiString DDS_DicGroup::GetActiveUnitSystem() const
{
return myActiveSystem;
}
+/*!
+ Sets the name of active unit system.
+*/
void DDS_DicGroup::SetActiveUnitSystem( const TCollection_AsciiString& theSystem )
{
if ( myUnitSystem.IsBound( theSystem ) )
myActiveSystem = theSystem;
}
+/*!
+ Assignment operator.
+*/
void DDS_DicGroup::operator=( const DDS_DicGroup& )
{
}
+/*!
+ Fill the internal data structures from XML parsed structures. Internal.
+*/
void DDS_DicGroup::FillDataMap( const LDOM_Element& theComponentData, const LDOM_Element& theDocElement )
{
TCollection_AsciiString aCompName = theComponentData.getAttribute( DDS_Dictionary::KeyWord( "COMPONENT_NAME" ) );
}
/*!
- Returns DicItem with all attached data
+ Gets dictionary item with specified identifier \atheID.
+ If dictionary item not found then null handle returned.
*/
-
Handle(DDS_DicItem) DDS_DicGroup::GetDicItem( const TCollection_AsciiString& theID ) const
{
Handle(DDS_DicItem) aDicItem;
IMPLEMENT_STANDARD_HANDLE(DDS_DicItem, MMgt_TShared)
IMPLEMENT_STANDARD_RTTIEXT(DDS_DicItem, MMgt_TShared)
+/*!
+ \class DDS_DicItem
+
+ This class to provide information about datum (phisical characteristic parameter).
+*/
+
+/*!
+ Constructor. Creates the instance of empty dictionary item.
+*/
DDS_DicItem::DDS_DicItem()
: myType( 0 ),
myDefValue( 0 ),
{
}
+/*!
+ Copy constructor. Internal.
+*/
DDS_DicItem::DDS_DicItem( const DDS_DicItem& )
{
}
+/*!
+ Assignment operator. Internal.
+*/
void DDS_DicItem::operator=( const DDS_DicItem& )
{
}
+/*!
+ Gets the identifier of parameter.
+*/
TCollection_AsciiString DDS_DicItem::GetId() const
{
return myId;
}
+/*!
+ Gets the type of parameter.
+*/
DDS_DicItem::Type DDS_DicItem::GetType() const
{
return (DDS_DicItem::Type)myType;
}
+/*!
+ Gets the label of the parameter.
+*/
TCollection_ExtendedString DDS_DicItem::GetLabel() const
{
return myLabel;
}
+/*!
+ Gets the filter (regular expression) for the parameter values.
+*/
TCollection_ExtendedString DDS_DicItem::GetFilter() const
{
return myFilter;
}
+/*!
+ Gets the Required attribute of the parameter.
+*/
TCollection_ExtendedString DDS_DicItem::GetRequired() const
{
return myRequired;
}
+/*!
+ Gets the wrong value warning level of the parameter.
+*/
DDS_MsgType DDS_DicItem::GetWarningLevel() const
{
return (DDS_MsgType)myWarnLevel;
}
+/*!
+ Gets the long description of the parameter.
+*/
TCollection_ExtendedString DDS_DicItem::GetLongDescription() const
{
return myLongDescr;
}
+/*!
+ Gets the short description of the parameter.
+*/
TCollection_ExtendedString DDS_DicItem::GetShortDescription() const
{
return myShortDescr;
}
+/*!
+ Gets the name of component - owner of parameter.
+*/
TCollection_AsciiString DDS_DicItem::GetComponent() const
{
TCollection_AsciiString aCompName;
return aCompName;
}
+/*!
+ Gets the parameter unit of measure for active unit system.
+*/
TCollection_AsciiString DDS_DicItem::GetUnits() const
{
return GetUnits( GetActiveUnitSystem() );
}
+/*!
+ Gets the parameter unit of measure for specified unit system \atheSystem.
+ If specified unit system doesn't exist then empty string returned.
+*/
TCollection_AsciiString DDS_DicItem::GetUnits( const UnitSystem& theSystem ) const
{
TCollection_AsciiString anUnits;
return anUnits;
}
+/*!
+ Gets the minimum value of parameter for active unit system.
+ Returned value converted to SI.
+*/
Standard_Real DDS_DicItem::GetMinValue() const
{
return GetMinValue( GetActiveUnitSystem() );
}
+/*!
+ Gets the minimum value of parameter for specified unit system \atheSystem.
+ Returned value converted to SI.
+*/
Standard_Real DDS_DicItem::GetMinValue( const UnitSystem& theUnitsSystem ) const
{
return FromSI( myMin, theUnitsSystem );
}
+/*!
+ Gets the maximum value of parameter for active unit system.
+ Returned value converted to SI.
+*/
Standard_Real DDS_DicItem::GetMaxValue() const
{
return GetMaxValue( GetActiveUnitSystem() );
}
+/*!
+ Gets the maximum value of parameter for specified unit system \atheSystem.
+ Returned value converted to SI.
+*/
Standard_Real DDS_DicItem::GetMaxValue( const UnitSystem& theUnitsSystem ) const
{
return FromSI( myMax, theUnitsSystem );
}
+/*!
+ Gets the precision (number of digit after decimal point) of parameter for active unit system.
+*/
Standard_Integer DDS_DicItem::GetPrecision() const
{
return GetPrecision( GetActiveUnitSystem() );
}
+/*!
+ Gets the precision (number of digit after decimal point) of parameter for specified
+ unit system \atheSystem. If specified unit system doesn't exist then zero returned.
+*/
Standard_Integer DDS_DicItem::GetPrecision( const UnitSystem& theSystem ) const
{
Standard_Integer aRes = 0;
return aRes;
}
+/*!
+ Gets the default value of parameter for active unit system. Default value returned as string.
+ If type of value is numeric (Float or Integer) and default value defined then returned number
+ converted to SI.
+*/
TCollection_ExtendedString DDS_DicItem::GetDefaultValue() const
{
return GetDefaultValue( GetActiveUnitSystem() );
}
+/*!
+ Gets the default value of parameter for specified unit system \atheSystem. Default value returned
+ as string. If type of value is numeric (Float or Integer) and default value defined then returned
+ number converted to SI.
+*/
TCollection_ExtendedString DDS_DicItem::GetDefaultValue( const UnitSystem& theSystem ) const
{
if ( !myDefString.Length() )
return aStr;
}
+/*!
+ Gets the format string of parameter for active unit system. If argument \atheCanonical
+ is true then format string will be reduced to sprintf() specification (without extra
+ non standard qualifiers).
+*/
TCollection_AsciiString DDS_DicItem::GetFormat( const Standard_Boolean theCanonical ) const
{
return GetFormat( GetActiveUnitSystem(), theCanonical );
}
+/*!
+ Gets the format string of parameter for specified unit system \atheSystem. If argument
+ \atheCanonical is true then format string will be reduced to sprintf() specification
+ (without extra non standard qualifiers).
+*/
TCollection_AsciiString DDS_DicItem::GetFormat( const UnitSystem& theSystem,
const Standard_Boolean theCanonical ) const
{
}
/*!
- Access valueList:name of the parameter. This string is void if the list is
- not defined - then use other properties: Type, DefaultValue, MaxValue, MinValue
+ Gets name of a list referenced by the parameter. This string is empty if the list
+ refernce is not defined - then use other properties: Type, DefaultValue, MaxValue, MinValue
*/
TCollection_ExtendedString DDS_DicItem::GetNameOfValues() const
{
}
/*!
- Access valueList of the parameter. This sequence is empty if the list is
- not defined - then use other properties: Type, DefaultValue, MaxValue, MinValue
+ Gets item names and item ids of a list referenced by the parameter. This sequences is empty if
+ the list reference is not defined - then use other properties: Type, DefaultValue, MaxValue, MinValue
*/
Standard_Boolean DDS_DicItem::GetListOfValues( Handle(TColStd_HArray1OfExtendedString)& theStrings,
Handle(TColStd_HArray1OfInteger)& theIntegers ) const
}
/*!
- Access valueList of the parameter. This sequence is empty if the list is not
- defined - then use other properties: Type, DefaultValue, MaxValue, MinValue
+ Gets item names, item ids and item icons of a list referenced by the parameter. This sequences is empty
+ if the list reference is not defined - then use other properties: Type, DefaultValue, MaxValue, MinValue
*/
Standard_Boolean DDS_DicItem::GetListOfValues( Handle(TColStd_HArray1OfExtendedString)& theStrings,
Handle(TColStd_HArray1OfInteger)& theIntegers,
return !theIntegers.IsNull() && !theStrings.IsNull() && !theIcons.IsNull();
}
+
+/*!
+ Gets special values of the parameter.
+*/
Standard_Boolean DDS_DicItem::GetSpecialValues( TColStd_MapOfReal& theMap ) const
{
theMap.Clear();
}
/*!
- Returns min value of lateral zooming
+ Gets minimum value of lateral zooming
*/
Standard_Real DDS_DicItem::GetMinZoom() const
{
}
/*!
- Returns Max Value of lateral zooming
+ Gets maximum value of lateral zooming
*/
Standard_Real DDS_DicItem::GetMaxZoom() const
{
}
/*!
- Get Order of lateral zooming
+ Gets order of lateral zooming
*/
Standard_Real DDS_DicItem::GetZoomOrder() const
{
return myZoomOrder;
}
+/*!
+ Convert value \atheVal to default SI units according to active unit system.
+*/
Standard_Real DDS_DicItem::ToSI( const Standard_Real theVal ) const
{
return ToSI( theVal, GetActiveUnitSystem() );
}
+/*!
+ Convert value \atheVal from default SI units according to active unit system.
+*/
Standard_Real DDS_DicItem::FromSI( const Standard_Real theVal ) const
{
return FromSI( theVal, GetActiveUnitSystem() );
}
/*!
- Convert value to default SI units according to current units
+ Convert value to default SI units according to unit system \atheUnitsSystem.
*/
Standard_Real DDS_DicItem::ToSI( const Standard_Real theVal, const UnitSystem& theUnitsSystem ) const
{
}
/*!
- Convert value from default SI units according to current units
+ Convert value from default SI units according to unit system \atheUnitsSystem.
*/
Standard_Real DDS_DicItem::FromSI( const Standard_Real theVal, const UnitSystem& theUnitsSystem ) const
{
}
/*!
- Returns 'true' if specified data exist.
+ Returns 'true' if data specified by \aflag exist.
*/
Standard_Boolean DDS_DicItem::HasData( const Standard_Integer flag ) const
{
}
/*!
- Parse record in XML file and retrieve information relevant for this data dic item
+ Returns options for specified name \aname. If option not found then empty string returned.
+*/
+TCollection_ExtendedString DDS_DicItem::GetOption( const TCollection_AsciiString& name ) const
+{
+ TCollection_ExtendedString res;
+ if ( myOptions.IsBound( name ) )
+ res = myOptions.Find( name );
+ return res;
+}
+
+/*!
+ Returns names list of existing options in the specified sequence \anames.
+ If list not empty retunrs 'true' otherwise 'false'.
+*/
+Standard_Boolean DDS_DicItem::GetOptionNames( TColStd_SequenceOfAsciiString& names ) const
+{
+ names.Clear();
+
+ for ( OptionsMap::Iterator it( myOptions ); it.More(); it.Next() )
+ names.Append( it.Key() );
+
+ return !names.IsEmpty();
+}
+
+
+/*!
+ Parse record in XML file and retrieve information relevant for this dictionary item
*/
void DDS_DicItem::FillDataMap( TCollection_AsciiString theID, const LDOM_Element& theDatum,
const LDOM_Element& theCompElement, const LDOM_Element& theDocElement,
}
}
+ // Quantity::Options
+ LDOM_Element anOpt = theDatum.GetChildByTagName( DDS_Dictionary::KeyWord( "OPTIONS" ) );
+ if ( !anOpt.isNull() )
+ {
+ LDOM_NodeList anOptions = anOpt.getElementsByTagName( DDS_Dictionary::KeyWord( "OPTION" ) );
+ for ( Standard_Integer oi = 0; oi < anOptions.getLength(); oi++ )
+ {
+ LDOM_Node node = anOptions.item( oi );
+ if ( node.getNodeType() != LDOM_Node::ELEMENT_NODE )
+ continue;
+
+ LDOM_Element& elem = (LDOM_Element&)node;
+ TCollection_AsciiString name = elem.getAttribute( DDS_Dictionary::KeyWord( "OPTION_NAME" ) );
+
+ TCollection_ExtendedString value;
+ const LDOM_Text& aText = (const LDOM_Text&)elem.getFirstChild();
+ LDOM_Text anOptTxt( aText );
+ if ( !anOptTxt.isNull() )
+ value = anOptTxt.getData();
+
+ if ( !name.IsEmpty() && value.Length() && !myOptions.IsBound( name ) )
+ myOptions.Bind( name, value );
+ }
+ }
+
NCollection_DataMap<UnitSystem, Handle(Units_Dimensions)> aDimMap;
for ( NCollection_DataMap<UnitSystem, UnitData>::Iterator it( myUnitData ); it.More(); it.Next() )
}
/*!
- Prepares three formants for each unit systems
+ Prepares formats for each unit systems
*/
void DDS_DicItem::PrepareFormats( const TCollection_AsciiString& theFormat )
{
}
}
+/*!
+ Split the string \atheStr by spaces and returns substrings in array \aaRes.
+*/
void DDS_DicItem::Split( const TCollection_AsciiString& theStr, Handle(TColStd_HArray1OfExtendedString)& aRes )
{
aRes.Nullify();
}
}
+/*!
+ Returns unit structure for given unit system \asys.
+*/
DDS_DicItem::UnitData* DDS_DicItem::GetUnitData( const UnitSystem& sys ) const
{
UnitData* unit = 0;
return unit;
}
+/*!
+ Gets the active unit system.
+*/
DDS_DicItem::UnitSystem DDS_DicItem::GetActiveUnitSystem() const
{
UnitSystem aSystem;
class DDS_DicItem : public MMgt_TShared
{
public:
- enum Type { String, Float, Integer, List, Unknown };
- enum Data { MinValue = 0x01, MaxValue = 0x02, DefaultValue = 0x04 };
+ /*! Enum describes type of datum value */
+ enum Type
+ {
+ String, //!< String type of value
+ Float, //!< Real (double) numeric type of value
+ Integer, //!< Integer (int) numeric type of value
+ List, //!< List type of enumerable value
+ Unknown //!< Unknown or undefined type of value
+ };
+
+ /*! Enum describes the flags for existance of domain data */
+ enum Data
+ {
+ MinValue = 0x01, //!< Flag of minimum value definition existence
+ MaxValue = 0x02, //!< Flag of maximum value definition existence
+ DefaultValue = 0x04 //!< Flag of default value definition existence
+ };
// This struct is intended for map of Format, Units, Precision and Scale
struct UnitData
DDS_DicItem();
Standard_EXPORT TCollection_AsciiString GetId() const;
- // to access Type of the parameter
-
Standard_EXPORT DDS_DicItem::Type GetType() const;
- // to access Type of the parameter
-
Standard_EXPORT TCollection_ExtendedString GetLabel() const;
- // to access Label (name) of the parameter
-
Standard_EXPORT TCollection_ExtendedString GetFilter() const;
- // to access filter (regexp) for the parameter values
-
Standard_EXPORT TCollection_ExtendedString GetRequired() const;
- // to access Required of the parameter
-
Standard_EXPORT DDS_MsgType GetWarningLevel() const;
- // to access wrong value warning level of the parameter
-
Standard_EXPORT TCollection_ExtendedString GetLongDescription() const;
- // to access Long Description of the parameter
-
Standard_EXPORT TCollection_ExtendedString GetShortDescription() const;
- // to access Short Description of the parameter
-
Standard_EXPORT TCollection_AsciiString GetComponent() const;
Standard_EXPORT TCollection_AsciiString GetUnits() const;
Standard_EXPORT TCollection_AsciiString GetUnits( const UnitSystem& ) const;
- // returns units for indicated unit systems
Standard_EXPORT TCollection_ExtendedString GetDefaultValue() const;
Standard_EXPORT TCollection_ExtendedString GetDefaultValue( const UnitSystem& ) const;
- // to access Default Value of the parameter
Standard_EXPORT Standard_Real GetMinValue() const;
Standard_EXPORT Standard_Real GetMinValue( const UnitSystem& ) const;
- // get Min Value of the parameter, either in specified unit system or in internal units (basic SI)
Standard_EXPORT Standard_Real GetMaxValue() const;
Standard_EXPORT Standard_Real GetMaxValue( const UnitSystem& ) const;
- // get Max Value of the parameter, either in specified unit system or in internal units (basic SI)
Standard_EXPORT Standard_Integer GetPrecision() const;
Standard_EXPORT Standard_Integer GetPrecision( const UnitSystem& ) const;
- // returns precision for indicated unit systems
Standard_EXPORT TCollection_AsciiString GetFormat( const Standard_Boolean = Standard_True ) const;
Standard_EXPORT TCollection_AsciiString GetFormat( const UnitSystem&,
const Standard_Boolean = Standard_True ) const;
- // returns format for indicated unit systems
-
Standard_EXPORT TCollection_ExtendedString GetNameOfValues() const;
- // to access valueList:name of the parameter.
- // This string is void if the list is not defined - then use other properties:
- // Type, DefaultValue, MaxValue, MinValue
-
Standard_EXPORT Standard_Boolean GetListOfValues( Handle(TColStd_HArray1OfExtendedString)&,
Handle(TColStd_HArray1OfInteger)& ) const;
- // to access valueList of the parameter
- // This sequence is empty if the list not defined - then use other properties:
- // Type, DefaultValue, MaxValue, MinValue
-
Standard_EXPORT Standard_Boolean GetListOfValues( Handle(TColStd_HArray1OfExtendedString)&,
Handle(TColStd_HArray1OfInteger)&,
Handle(TColStd_HArray1OfExtendedString)& ) const;
- // to access valueList of the parameter
- // This sequence is empty if the list not defined - then use other properties:
- // Type, DefaultValue, MaxValue, MinValue
-
Standard_EXPORT Standard_Boolean GetSpecialValues( TColStd_MapOfReal& ) const;
- // get values from specVal
Standard_EXPORT Standard_Real GetMinZoom() const;
- // get Min Value of lateral zooming
-
Standard_EXPORT Standard_Real GetMaxZoom() const;
- // get Max Value of lateral zooming
-
Standard_EXPORT Standard_Real GetZoomOrder() const;
- // get Order of lateral zooming
- Standard_EXPORT Standard_Real ToSI( const Standard_Real ) const;
- Standard_EXPORT Standard_Real FromSI( const Standard_Real ) const;
+ Standard_EXPORT Standard_Real ToSI( const Standard_Real ) const;
+ Standard_EXPORT Standard_Real FromSI( const Standard_Real ) const;
- Standard_EXPORT Standard_Real ToSI( const Standard_Real, const UnitSystem& ) const;
- Standard_EXPORT Standard_Real FromSI( const Standard_Real, const UnitSystem& ) const;
- // convert value to and from default SI units according to current units
+ Standard_EXPORT Standard_Real ToSI( const Standard_Real, const UnitSystem& ) const;
+ Standard_EXPORT Standard_Real FromSI( const Standard_Real, const UnitSystem& ) const;
Standard_EXPORT Standard_Boolean HasData( const Standard_Integer ) const;
+ Standard_EXPORT TCollection_ExtendedString GetOption( const TCollection_AsciiString& ) const;
+ Standard_EXPORT Standard_Boolean GetOptionNames( TColStd_SequenceOfAsciiString& ) const;
+
private:
DDS_DicItem( const DDS_DicItem& );
- // Copy constructor
-
void operator=( const DDS_DicItem& );
- // Assignment operator
-
void FillDataMap( TCollection_AsciiString, const LDOM_Element&,
const LDOM_Element&, const LDOM_Element&,
const TColStd_SequenceOfAsciiString& );
- // prepares formants for each unit systems
-
-
void PrepareFormats( const TCollection_AsciiString& );
- // prepares three formats for each unit systems
-
void GetDefaultFormat();
- // returns three default formants for each unit systems
-
UnitSystem GetActiveUnitSystem() const;
void GetStringFormat( const TCollection_AsciiString&,
const TCollection_AsciiString&,
const TCollection_AsciiString&,
TCollection_AsciiString& );
- // returns format for the string
-
void GetIntegerFormat( const TCollection_AsciiString&,
const TCollection_AsciiString&,
const TCollection_AsciiString&,
const TCollection_AsciiString&,
const Standard_Character,
TCollection_AsciiString& );
- // returns format for the integer
-
void GetFloatFormat( const TCollection_AsciiString&,
const TCollection_AsciiString&,
const TCollection_AsciiString&,
const TCollection_AsciiString&,
const Standard_Character,
TCollection_AsciiString& );
- // returns format for the float
-
void Split( const TCollection_AsciiString&,
Handle(TColStd_HArray1OfExtendedString)& );
UnitData* GetUnitData( const UnitSystem& ) const;
+private:
+ typedef NCollection_DataMap<TCollection_AsciiString, TCollection_ExtendedString> OptionsMap;
+
private:
TCollection_AsciiString myId;
TCollection_ExtendedString myLabel;
Handle(Standard_Transient) myComponent;
+ OptionsMap myOptions;
// unitData
NCollection_DataMap<UnitSystem, UnitData> myUnitData;
DEFINE_STANDARD_RTTI(DDS_DicItem)
};
-// Definition of HANDLE object using Standard_DefineHandle.hxx
DEFINE_STANDARD_HANDLE(DDS_DicItem, MMgt_TShared)
-// Container class XMLTools_IndexedDataMapOfDicItems (map of handles)
DEFINE_BASECOLLECTION(DDS_BaseCollectionOfDicItems, Handle(DDS_DicItem))
DEFINE_INDEXEDDATAMAP(DDS_IndexedDataMapOfDicItems, DDS_BaseCollectionOfDicItems,
TCollection_AsciiString, Handle(DDS_DicItem))
IMPLEMENT_STANDARD_HANDLE(DDS_Dictionary, MMgt_TShared)
IMPLEMENT_STANDARD_RTTIEXT(DDS_Dictionary, MMgt_TShared)
+/*!
+ \class DDS_Dictionary
+
+ This class to provide information about used datums, reading them from 'xml' file
+
+ Datum is the set of parameters described a phisical characteristic. These parameters loaded from
+ special XML which has following format:
+
+ \hr
+
+ <D_URI>
+ <COMPONENT COMPONENT_NAME="component_name">
+ <UNIT_SYSTEMS>
+ <UNIT_SYSTEM UNIT_SYSTEM_NAME="[system_internal_name]" UNIT_SYSTEM_LABEL="[system_label]">
+ <UNIT_SYSTEM UNIT_SYSTEM_NAME="[system_internal_name]" UNIT_SYSTEM_LABEL="[system_label]">
+ ...
+ <UNIT_SYSTEM UNIT_SYSTEM_NAME="[system_internal_name]" UNIT_SYSTEM_LABEL="[system_label]">
+ </UNIT_SYSTEMS>
+
+ <DATUM DATUM_UNITS="[base_system_internal_name]" DATUM_FORMAT="[sprintf_format_specification]"
+ DATUM_ID="[datum_id]" DATUM_LABEL="[datum_label]" DATUM_REQUIRED="[requred_value]"
+ DATUM_FILTER="[string_regular_expression]">
+ <DY_DOMAIN>
+ <VALUE_DESCR VD_DEFV="[default_value]" VD_MAXV="[max_value]" VD_MINV="[min_value]" VD_TYPE="[value_type]"/>
+ <VALUE_LIST_REF VLR_LIST="[referenced_list_id]"/>
+ </DY_DOMAIN>
+ <DESCR>
+ <SHORT_D>[brief_desription_text]</SHORT_D>
+ <LONG_D>[full_description_text]</LONG_D>
+ </DESCR>
+ <OPTIONS>
+ <OPTION OPTION_NAME="[option_name_1]">[option_value_1]</OPTION>
+ <OPTION OPTION_NAME="[option_name_2]">[option_value_2]</OPTION>
+ ...
+ <OPTION OPTION_NAME="[option_name_n]">[option_value_n]</OPTION>
+ </OPTIONS>
+ </DATUM>
+
+ ...
+
+ <VALUE_LIST VALUE_LIST_ID="[list_id]" VALUE_LIST_NAME="[list_name]">
+ <VALUE_LIST_VALUE VALUE_LIST_VALUEID="[list_element_id]" VALUE_LIST_VALUEICON="[list_element_icon_file]">[list_element_name]</VALUE_LIST_VALUE>
+ <VALUE_LIST_VALUE VALUE_LIST_VALUEID="[list_element_id]" VALUE_LIST_VALUEICON="[list_element_icon_file]">[list_element_name]</VALUE_LIST_VALUE>
+ ...
+ <VALUE_LIST_VALUE VALUE_LIST_VALUEID="[list_element_id]" VALUE_LIST_VALUEICON="[list_element_icon_file]">[list_element_name]</VALUE_LIST_VALUE>
+ </VALUE_LIST>
+
+ ...
+
+ </COMPONENT>
+ </D_URI>
+
+ \hr
+
+ In description of datum file format used internal keys as XML tag and attributes names.
+ Concrete XML keywords defined by DDS_KeyWords class.
+
+ Describe datum file format more detailed. XML file should have one main tag named as "dictionary" (key "D_URI").
+ This tag should contains one or several components. Component is a independent set of datums and unit systems.
+ Components defined as XML tag named "component" (key "COMPONENT") with attribute "name" (key COMPONENT_NAME).
+ Component name used as component identifier and should be unique. Component tag can contains:
+
+ \li Tag "unit_systems" (key UNIT_SYSTEMS) defines set of used unit systems. Should exist at least one unit
+ system named SI ("System International"). If this system not exist then it will be defined automatically.
+ Each unit system defined by XML tag "unit system" (key UNIT_SYSTEM) under tag "unit_systems" with attributes
+ "name" (key UNIT_SYSTEM_NAME) and "label" (key UNIT_SYSTEM_LABEL). Name is identifier of unit system. Label is
+ human readable description.
+
+ \li One or several tag "datum" (key DATUM). For this tag can be defined following attributes:
+
+ \lo Identifier (key DATUM_ID) specify the unique id string for the datum.
+ \lo Label (key DATUM_LABEL) specify human readable name of the datum.
+ \lo Units of measure (key DATUM_UNITS) for given unit system. Attribute name consist of a name
+ of unit system and a keyword got from DDS_KeyWords by key DATUM_UNITS. For example for unit system
+ named SI and default keyword attribute name will be "SIunits". This attribute should be specified
+ for each deaclared unit system. Value of this attribute should be string describs units of measure.
+ Possible designations for units of measure and their multiple prefixes see in package UnitsAPI of
+ library OpenCascade (files Units.dat and Lexi_Expr.dat). Units of measure will be used for numeric
+ value conversion from one unit system to another one.
+ \lo Format (key DATUM_FORMAT) specify the format string which will be used during initial formatting
+ of value. This string should be specified in sprintf() format.
+ \lo Filter (key DATUM_FILTER) specify the regualr expression. Each user entered string will be checked up
+ on matching to this expression (if it defined). Non matched strings will be rejected.
+ \lo Required value (key DATUM_REQUIRED). If this attributed defined and value is true then user can't
+ leave a input filed blank (parameter must be always entered).
+
+ Tag "description" (key DESCR) can be defined under the tag "datum". This tag contains two sub tags:
+ \lo "short description" (key SHORT_D) specify a brief datum description text
+ \lo "long description" (key LONG_D) specify a detailed description text
+
+ Tag "options" (key OPTIONS) can be defined under the tag "datum". This tag contains one or more sub
+ tags "option" (key OPTION). Each of these XML elements should contain text option value and attribute
+ "name" (key OPTION_NAME) which specified option name.
+
+ Each tag "datum" define most common parameters of phisical characteristic.
+ This parameters placed in two groups:
+ \lo Domain parameters under tag "domain" (key DY_DOMAIN). This tag can contains value description tag
+ (key VALUE_DESCR) for discrete data or list reference tag (key VALUE_LIST_REF) for enumerable data.
+ Discrete data described following parameters:
+ default value (key VD_DEFV)
+ maximum value (key VD_MAXV)
+ minimum value (key VD_MINV)
+ type of value (key VD_TYPE) - possible values: String, Integer, Float, List
+ Enumerable data described by "list reference" attribute (key VLR_LIST) which reference on
+ list (see "list definition" tag) by list id.
+
+ \li One or several tag "list definition" (key VALUE_LIST). This tag define the list of items for enumerable
+ data. Attribute "list id" (key VALUE_LIST_ID) specify the identifier string for the list and attribute
+ "list name" (key VALUE_LIST_NAME) define a list name string. Each list item described by tag "list value"
+ (key VALUE_LIST_VALUE) under tag "list definition". Each this tag contains item string text and have
+ following attributes:
+ \lo "list item id" (key VALUE_LIST_VALUEID) - integer numerical identifier for item
+ \lo "list item icon" (key VALUE_LIST_VALUEICON) - icon file name for item
+
+ Below the example of a XML file with use default keywords.
+
+ <datadictionary version="1.0">
+ <component name="My Component">
+
+ <!-- specify two unit systems -->
+
+ <unitSystems>
+ <system name="SI" label="System international">
+ <system name="AS" label="Anglo - sacson system">
+ </unitSystems>
+
+ <!-- specify datum -->
+ <!-- units of measure for SI - meters (m), for AS - inches (in) -->
+ <datum SIunits="m" ASunits="in" format="%.25f" id="X" label="X coordinate" required="">
+ <domain>
+ <!-- default value not specified -->
+ <valueDescr default="" max="999999999.999" min="0.000" type="Float"/>
+ </domain>
+ <description>
+ <shortDescr>X coordinate for object</shortDescr>
+ <longDescr>X multiplier of object coordinates. Describe position of object in direction of X axis</longDescr>
+ </description>
+ </datum>
+
+ <datum SIunits="m" ASunits="in" format="%.25f" id="Y" label="Y coordinate" required="">
+ <domain>
+ <valueDescr default="" max="999999999.999" min="0.000" type="Float"/>
+ </domain>
+ <description>
+ <shortDescr>Y coordinate for object</shortDescr>
+ <longDescr>Y multiplier of object coordinates. Describe position of object in direction of Y axis</longDescr>
+ </description>
+ </datum>
+
+ <!-- datum for object name with filter which not allow to input more that 8 letters,
+ numbers or unerscores with first letter only -->
+ <datum format="%.8us" id="ObjectName" label="Name" required="yes"
+ filter="^([A-Z]+)([A-Z,0-9,_]*)$">
+ <domain>
+ <!-- limits and default not specified, type is string -->
+ <valueDescr default="" max="" min="" type="String" />
+ </domain>
+ <description>
+ <!-- long description not specified -->
+ <shortDescr>Name of object</shortDescr>
+ </description>
+ </datum>
+
+
+ <!-- datum for enumeration of side -->
+ <datum format="" id="Side" label="Side" required="">
+ <domain>
+ <!-- default list item is item with id 0 -->
+ <valueDescr default="0" type="List"/>
+ <!-- list reference on list named "side_list" -->
+ <listRef list="side_list"/>
+ </domain>
+ <description>
+ <shortDescr>Side of object</shortDescr>
+ </description>
+ </datum>
+
+ <!-- list definition for enumeration of side -->
+ <valueList listid="side_list" name="Side">
+ <value id="1">left</value>
+ <value id="2">right</value>
+ <value id="3">top</value>
+ <value id="4">bottom</value>
+ <value id="0">undefined</value>
+ </valueList>
+
+ </component>
+ </datadictionary>
+
+
+*/
+
+/*!
+ Constructor. Creates the instance of dictionary. Private method. Use DDS_Dictionary::Get() instead.
+*/
DDS_Dictionary::DDS_Dictionary()
: MMgt_TShared()
{
}
+/*!
+ Copy constructor. Internal.
+*/
DDS_Dictionary::DDS_Dictionary( const DDS_Dictionary& )
{
}
+/*!
+ Assigment operator. Internal.
+*/
void DDS_Dictionary::operator=( const DDS_Dictionary& )
{
}
+/*!
+ Returns the names list of defined unit systems from all components.
+ Parameter \atheSystems will contains the sequence of string names.
+*/
void DDS_Dictionary::GetUnitSystems( TColStd_SequenceOfAsciiString& theSystems ) const
{
theSystems.Clear();
}
+/*!
+ Returns the names list of defined unit systems from the specified component \atheComponent.
+ Parameter \atheSystems will contains the sequence of string names. If component not found then
+ empty list returned.
+*/
void DDS_Dictionary::GetUnitSystems( TColStd_SequenceOfAsciiString& theSystems,
const TCollection_AsciiString& theComponent ) const
{
myGroupMap.FindFromKey( theComponent )->GetUnitSystems( theSystems );
}
+/*!
+ Returns the label of unit system \atheSystem. Function find the given unit system in
+ all components. If unit system not found in any component then empty string returned.
+*/
TCollection_ExtendedString DDS_Dictionary::GetUnitSystemLabel( const TCollection_AsciiString& theSystem ) const
{
TCollection_ExtendedString aLabel;
return aLabel;
}
+/*!
+ Returns the label of unit system \atheSystem from component \atheComponent. Function find
+ the given unit system in the specified component only. If unit system not found in the
+ component then empty string returned.
+*/
TCollection_ExtendedString DDS_Dictionary::GetUnitSystemLabel( const TCollection_AsciiString& theSystem,
const TCollection_AsciiString& theComponent ) const
{
return aLabel;
}
+/*!
+ Gets the name of active unit system from first got component. If any component exist then
+ active unit system name returned or empty string otherwise.
+*/
TCollection_AsciiString DDS_Dictionary::GetActiveUnitSystem() const
{
TCollection_AsciiString aSystem;
return aSystem;
}
+/*!
+ Gets the name of active unit system from component \atheComponent. If this component exist
+ active unit system name returned or empty string otherwise.
+*/
TCollection_AsciiString DDS_Dictionary::GetActiveUnitSystem( const TCollection_AsciiString& theComponent ) const
{
TCollection_AsciiString aSystem;
return aSystem;
}
+/*!
+ Sets the active unit system named \atheSystem. This unit system will be activated in all
+ existing components if component have it.
+*/
void DDS_Dictionary::SetActiveUnitSystem( const TCollection_AsciiString& theSystem )
{
for ( Standard_Integer i = 1; i <= myGroupMap.Extent(); i++ )
myGroupMap.FindFromIndex( i )->SetActiveUnitSystem( theSystem );
}
+/*!
+ Sets the active unit system named \atheSystem for component \atheComponent. If specified unit
+ system doesn't exist in the component then function do nothing.
+*/
void DDS_Dictionary::SetActiveUnitSystem( const TCollection_AsciiString& theSystem,
const TCollection_AsciiString& theComponent )
{
return sDictionary;
}
+/*!
+ Load datum definitions in the dictionary from XML file \atheFileName. Returns true if load
+ successed or false otherwise.
+*/
Standard_Boolean DDS_Dictionary::Load( const TCollection_AsciiString theFileName )
{
static NCollection_Map<TCollection_AsciiString> _LoadMap;
return Standard_True;
}
+/*!
+ Gets XML keyword as LDOMString by specified \akey. If key doesn't exist then empty string
+ returned. This function provided for convenience.
+*/
LDOMString DDS_Dictionary::KeyWord( const TCollection_AsciiString& key )
{
LDOMString keyWord;
}
/*!
- Returns DicItem from specified group with all attached data
+ Gets dictionary item with specified identifier \atheID from specified component \atheComponent.
+ If component or item not found then null handle returned.
*/
-
Handle(DDS_DicItem) DDS_Dictionary::GetDicItem( const TCollection_AsciiString& theID,
- const TCollection_AsciiString& theGroup ) const
+ const TCollection_AsciiString& theComponent ) const
{
Handle(DDS_DicItem) aDicItem;
Handle(DDS_DicGroup) aDicGroup;
- if ( myGroupMap.Contains( theGroup ) )
- aDicGroup = myGroupMap.FindFromKey( theGroup );
+ if ( myGroupMap.Contains( theComponent ) )
+ aDicGroup = myGroupMap.FindFromKey( theComponent );
if ( !aDicGroup.IsNull() )
aDicItem = aDicGroup->GetDicItem( theID );
return aDicItem;
}
/*!
- Returns DicItem with all attached data
+ Gets dictionary item with specified identifier \atheID. Function find the item in all components.
+ If item not found in any component then null handle returned.
*/
-
Handle(DDS_DicItem) DDS_Dictionary::GetDicItem( const TCollection_AsciiString& theID ) const
{
Handle(DDS_DicItem) aDicItem;
return aDicItem;
}
+/*!
+ Fill the internal data structures from XML parsed structures. Internal.
+*/
void DDS_Dictionary::FillDataMap( const LDOM_Element& theComponentData, const LDOM_Element& theDocElement )
{
TCollection_AsciiString aCompName = theComponentData.getAttribute( KeyWord( "COMPONENT_NAME" ) );
myGroupMap.Add( aCompName, aDicGroup );
}
+/*!
+ Convert numeric value \atheValue from specified unit of measure \atheUnits to SI unit of measure
+ (mm for Length, radians for Angles, etc). Converted value returned.
+*/
Standard_Real DDS_Dictionary::ToSI( const Standard_Real theValue, const Standard_CString theUnits )
{
Standard_Real aRetValue = theValue;
return aRetValue;
}
+/*!
+ Convert numeric value \atheValue to specified unit of measure \atheUnits from SI unit of measure
+ (mm for Length, radians for Angles, etc). Converted value returned.
+*/
Standard_Real DDS_Dictionary::FromSI( const Standard_Real theValue, const Standard_CString theUnits )
{
Standard_Real aRetValue = theValue;
DEFINE_STANDARD_HANDLE(DDS_Dictionary, MMgt_TShared)
-// Class to provide information about used parameters,
-// reading them from 'xml' file
class DDS_Dictionary : public MMgt_TShared
{
public:
void operator=( const DDS_Dictionary& );
- // prepares formants for each unit systems
void FillDataMap( const LDOM_Element&, const LDOM_Element& );
private:
IMPLEMENT_STANDARD_HANDLE(DDS_KeyWords, MMgt_TShared)
IMPLEMENT_STANDARD_RTTIEXT(DDS_KeyWords, MMgt_TShared)
+/*!
+ \class DDS_KeyWords
+
+ This object contains the pairs of internal keys and XML tag or attribute names. This class allow to user
+ define set of XML keywords used in datums definition file.
+
+ Default keywords table:
+ \li D_URI - dictionary
+ \li COMPONENT - component
+ \li COMPONENT_NAME - name
+ \li UNIT_SYSTEMS - unitSystems
+ \li UNIT_SYSTEM - system
+ \li UNIT_SYSTEM_NAME - name
+ \li UNIT_SYSTEM_LABEL - label
+ \li DATUM - datum
+ \li DATUM_ID - id
+ \li DATUM_LABEL - label
+ \li DATUM_UNITS - units
+ \li DATUM_FORMAT - format
+ \li DATUM_FILTER - filter
+ \li DATUM_REQUIRED - required
+ \li VALUE_LIST - valueList
+ \li VALUE_LIST_ID - listid
+ \li VALUE_LIST_NAME - name
+ \li VALUE_LIST_TYPE - type
+ \li VALUE_LIST_VALUE - value
+ \li VALUE_LIST_VALUEID - id
+ \li VALUE_LIST_VALUEICON - icon
+ \li DY_DOMAIN - domain
+ \li WARNING_LEVEL - warningLevel
+ \li WRONG_VALUE - wrongValue
+ \li VALUE_DESCR - valueDescr
+ \li VALUE_LIST_REF - listRef
+ \li DESCR - description
+ \li LONG_D - longDescr
+ \li SHORT_D - shortDescr
+ \li VD_TYPE - type
+ \li VD_DEFV - default
+ \li VD_MAXV - max
+ \li VD_MINV - min
+ \li VD_SPEC - specVal
+ \li VLR_LIST - list
+ \li PRS - presentation
+ \li LATERAL_ZOOM - lateralZoom
+ \li LZ_MINV - min
+ \li LZ_MAXV - max
+ \li LZ_ORDER - order
+ \li OPTIONS - options
+ \li OPTION - option
+ \li OPTION_NAME - name
+*/
+
+/*!
+ Constructor
+*/
+
DDS_KeyWords::DDS_KeyWords()
: MMgt_TShared()
{
SetKeyWord( "LZ_MINV", "min" );
SetKeyWord( "LZ_MAXV", "max" );
SetKeyWord( "LZ_ORDER", "order" );
+
+ SetKeyWord( "OPTIONS", "options" );
+ SetKeyWord( "OPTION", "option" );
+ SetKeyWord( "OPTION_NAME", "name" );
}
+/*!
+ Returns the static instance of the class DDS_KeyWords
+*/
+
Handle(DDS_KeyWords) DDS_KeyWords::Get()
{
static Handle(DDS_KeyWords) keyWords;
return keyWords;
}
+/*!
+ Returns the XML keyword by specified internal key \a key. If the internal key isn't registered
+ then empty string will be returned.
+*/
+
TCollection_AsciiString DDS_KeyWords::GetKeyWord( const TCollection_AsciiString& key ) const
{
TCollection_AsciiString keyWord;
return keyWord;
}
+/*!
+ Register the pair of the internal key \a key and XML keyword \a keyWord.
+*/
+
void DDS_KeyWords::SetKeyWord( const TCollection_AsciiString& key,
const TCollection_AsciiString& keyWord )
{
class TCollection_AsciiString;
-class DDS_KeyWords: public MMgt_TShared
+class DDS_KeyWords : public MMgt_TShared
{
public:
Standard_EXPORT static Handle(DDS_KeyWords) Get();
\class TMemFunEvent
\brief Template class for member function
*/
-template<class TObject, typename TRes> class EVENT_EXPORT TMemFunEvent: public SALOME_Event{
+template<class TObject, typename TRes> class /*EVENT_EXPORT */TMemFunEvent: public SALOME_Event{
public:
typedef TRes TResult;
TResult myResult;
\class TVoidMemFunEvent
\brief Template class for member function
*/
-template<class TObject> class EVENT_EXPORT TVoidMemFunEvent: public SALOME_Event{
+template<class TObject> class /*EVENT_EXPORT */TVoidMemFunEvent: public SALOME_Event{
public:
typedef void (TObject::* TAction)();
TVoidMemFunEvent(TObject* theObject, TAction theAction):
\class TMemFun1ArgEvent
\brief Template for member function with one argument
*/
-template<class TObject, typename TRes, typename TArg, typename TStoreArg = TArg> class EVENT_EXPORT TMemFun1ArgEvent:
+template<class TObject, typename TRes, typename TArg, typename TStoreArg = TArg> class/* EVENT_EXPORT */TMemFun1ArgEvent:
public SALOME_Event{
public:
typedef TRes TResult;
\class TVoidMemFun1ArgEvent
\brief Template for member function with one argument
*/
-template<class TObject, typename TArg, typename TStoreArg = TArg> class EVENT_EXPORT TVoidMemFun1ArgEvent: public SALOME_Event{
+template<class TObject, typename TArg, typename TStoreArg = TArg> class /*EVENT_EXPORT */TVoidMemFun1ArgEvent: public SALOME_Event{
public:
typedef void (TObject::* TAction)(TArg);
TVoidMemFun1ArgEvent(TObject* theObject, TAction theAction, TArg theArg):
\brief Template for member function with two arguments
*/
template<class TObject, typename TRes, typename TArg, typename TArg1, typename TStoreArg = TArg, typename TStoreArg1 = TArg1> class
-EVENT_EXPORT TMemFun2ArgEvent: public SALOME_Event{
+/*EVENT_EXPORT */TMemFun2ArgEvent: public SALOME_Event{
public:
typedef TRes TResult;
TResult myResult;
\brief Template for member function with two arguments
*/
template<class TObject, typename TArg, typename TArg1, typename TStoreArg = TArg, typename TStoreArg1 = TArg1> class
-EVENT_EXPORT TVoidMemFun2ArgEvent: public SALOME_Event{
+/*EVENT_EXPORT*/ TVoidMemFun2ArgEvent: public SALOME_Event{
public:
typedef void (TObject::* TAction)(TArg,TArg1);
TVoidMemFun2ArgEvent(TObject* theObject, TAction theAction, TArg theArg, TArg1 theArg1):
aResult[i] = *aPointer;
- for( ; i < aResult.size(); i++ )
+ for ( ; i < (int)aResult.size(); i++ )
aResult[i] = aObject[i - anISize - 2*aFSize*myNumber - aFSize];
return aResult;
for( ; i < anISize + 2*aFSize*myNumber + 2*aBSize; i++, aPointer++ )
aResult[i] = *aPointer;
- for( ; i < aResult.size(); i++ )
+ for ( ; i < (int)aResult.size(); i++ )
aResult[i] = aObject[i - anISize - 2*aFSize*myNumber - 2*aBSize];
return aResult;
float aDY = ( aRowPixelHeight - 1 ) / aYScale, aDX;
char aLetter;
int aLettIndex, row;
- for( int i = 0; i < theStr.length(); i++ )
+ for ( int i = 0; i < (int)theStr.length(); i++ )
{
aLetter = theStr.data()[i];
aLettIndex = (int)aLetter - FirstSymbolNumber;
int GLViewer_TexFont::getStringWidth( QString theStr )
{
int aWidth = 0;
- for( int i = 0; i < theStr.length(); i ++ )
+ for ( int i = 0; i < (int)theStr.length(); i ++ )
{
char aLetter = theStr.data()[i];
int aLettIndex = (int)aLetter - FirstSymbolNumber;
int aCurPos = 2*anISize + sizeOf8Float + aTypeLength + aToolTipLength;
// adds aspect byte array
- for( i = aCurPos; i < aCurPos + aAspect.size(); i++ )
+ for ( i = aCurPos; i < (int)( aCurPos + aAspect.size() ); i++ )
aResult[i] = aAspect[i - aCurPos];
aCurPos = aCurPos + aAspect.size();
// adds GL text byte array
- for( i = aCurPos; i < aCurPos + aGLText.size(); i++ )
+ for ( i = aCurPos; i < (int)( aCurPos + aGLText.size() ); i++ )
aResult[i] = aGLText[i - aCurPos];
aCurPos += aGLText.size();
aPointer = (char*)&myOwner;
- for( i = 0; i < sizeof( GLViewer_Owner* ); i++, aPointer++ )
+ for( i = 0; i < sizeof( SUIT_DataOwner* ); i++, aPointer++ )
aResult[ aCurPos + i ] = *aPointer;
return aResult;
class GLViewer_Group;
class GLViewer_CoordSystem;
class GLViewer_Text;
-class GLViewer_Owner;
+//class GLViewer_Owner;
/*!
* Class GLViewer_Object
virtual bool translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS ) = 0;
#endif
//!\warning It is for ouv
- GLViewer_Owner* owner() const { return myOwner; }
+ SUIT_DataOwner* owner() const { return myOwner; }
//!\warning It is for ouv
- void setOwner( GLViewer_Owner* owner ) { myOwner = owner; }
+ void setOwner( SUIT_DataOwner* owner ) { myOwner = owner; }
//! Adds object to group theGroup
void setGroup( GLViewer_Group* theGroup );
bool myIsVisible;
//!\warning It is for ouv
- GLViewer_Owner* myOwner;
+ SUIT_DataOwner* myOwner;
//! Object Group
GLViewer_Group* myGroup;
};
-
-//!\warning It is for ouv
-class GLVIEWER_API GLViewer_Owner : public SUIT_DataOwner
-{
-public:
- //!\warning It is for ouv
- GLViewer_Owner() : SUIT_DataOwner() {}
- //!\warning It is for ouv
- ~GLViewer_Owner() {}
-
-protected:
-
-};
-
#ifdef WNT
#pragma warning ( default:4251 )
#endif
// File: GLViewer_Tools.cxx
// Created: April, 2005
-//#include "GLViewerAfx.h"
#include "GLViewer_Tools.h"
#include <GL/gl.h>
-#include <iostream.h>
+#include <iostream>
/*!
Constructor
if( !myArray )
{
- cout << "Can't allocate memory: " << size << endl;
+ std::cout << "Can't allocate memory: " << size << std::endl;
myRealSize = 0;
}
else
*/
void GLViewer_LineList::print()
{
- cout << "MainCoord: " << myMainCoord <<" SIZE: " << myRealSize << " ENum: " << mySegmentNumber << " :::";
+ std::cout << "MainCoord: " << myMainCoord <<" SIZE: " << myRealSize << " ENum: " << mySegmentNumber << " :::";
for( int i = 0; i < mySegmentNumber; i++ )
- cout << " " << myArray[2*i] << " " << myArray[2*i+1] << " | ";
+ std::cout << " " << myArray[2*i] << " " << myArray[2*i+1] << " | ";
- cout << endl;
+ std::cout << std::endl;
}
/*!
*/
void GLViewer_LineField::print()
{
- cout << "My X matrix Number: " << myXSize << endl;
+ std::cout << "My X matrix Number: " << myXSize << std::endl;
for( int i = 0; i < myXSize; i++ )
myXLineArray[i]->print();
- cout << "My Y matrix Number: " << myYSize << endl;
+ std::cout << "My Y matrix Number: " << myYSize << std::endl;
for( int j = 0; j < myYSize; j++ )
myYLineArray[j]->print();
}
}
glEnd();
delete[] anArray;
- cout << "Show function" << endl;
+ std::cout << "Show function" << std::endl;
}
/*!
aCurArray[i].myLineIndex == myEndPoint.myXLineIndex &&
aCurArray[i].mySegmentindex == myEndPoint.myXSegmentIndex )
{
- cout << "Algorithm complete X!!!!!!!" << endl;
+ std::cout << "Algorithm complete X!!!!!!!" << std::endl;
myEndPoint.mySolveIndex = i;
return IS_SOLVED;
}
aCurArray[i].myLineIndex == myEndPoint.myYLineIndex &&
aCurArray[i].mySegmentindex == myEndPoint.myYSegmentIndex )
{
- cout << "Algorithm complete Y!!!!!!!" << endl;
+ std::cout << "Algorithm complete Y!!!!!!!" << std::endl;
myEndPoint.mySolveIndex = i;
return IS_SOLVED;
}
else
myCurArrayIndex = 0;
- cout << "Number of ways: " << count << endl;
+ std::cout << "Number of ways: " << count << std::endl;
if( count == 0 )
return IS_LOOP;
while( true )
{
- cout << "-----------Iteration #" << myCurCount << "-------------" << endl;
+ std::cout << "-----------Iteration #" << myCurCount << "-------------" << std::endl;
iteration();
IterationStatus is = checkComplete();
#include "GLViewer_Viewer2d.h"
#include "SUIT_Desktop.h"
-int GLViewer_ViewManager::myMaxId = 0;
-
/*!Constructor.*/
GLViewer_ViewManager::GLViewer_ViewManager( SUIT_Study* theStudy, SUIT_Desktop* theDesktop )
-: SUIT_ViewManager( theStudy, theDesktop )
+: SUIT_ViewManager( theStudy, theDesktop, new GLViewer_Viewer2d( "GLViewer" ) )
{
- myId = ++myMaxId;
- setViewModel( new GLViewer_Viewer2d( "GLViewer" ) );
+ setTitle( tr( "GL_VIEW_TITLE" ) );
}
/*!Destructor.*/
{
}
-/*!Sets view name for view window \a theView.*/
-void GLViewer_ViewManager::setViewName(SUIT_ViewWindow* theView)
-{
- int aPos = myViews.find(theView);
- theView->setCaption( QString( "GL scene:%1 - viewer:%2" ).arg(myId).arg(aPos+1));
-}
-
/*!Context menu popup for \a popup.*/
void GLViewer_ViewManager::contextMenuPopup( QPopupMenu* popup )
{
Q_OBJECT
public:
GLViewer_ViewManager( SUIT_Study* theStudy, SUIT_Desktop* theDesktop );
- ~GLViewer_ViewManager();
+ virtual ~GLViewer_ViewManager();
GLViewer_Viewer* getGLViewer() { return (GLViewer_Viewer*) myViewModel; }
virtual void contextMenuPopup( QPopupMenu* );
-
-protected:
- void setViewName(SUIT_ViewWindow* theView);
-
-protected:
- static int myMaxId;
- int myId;
};
#endif // GLVIEWER_VIEWMANAGER_H
int str_size = aList.first().length();
for( int i = 1, size = aList.count(); i < size; i++ )
{
- if( str_size < aList[i].length() )
+ if ( str_size < (int)aList[i].length() )
{
index = i;
str_size = aList[i].length();
msgid "GLViewer_ViewFrame::DUMP_VIEW_ERROR_DLG_TEXT"
msgstr "Can't save Dump View in file"
+
+msgid "GLViewer_ViewManager::GL_VIEW_TITLE"
+msgstr "GL Scene:%M - viewer:%V"
#include "LightApp_OBSelector.h"
#include "LightApp_SelectionMgr.h"
+#include "LightApp_DataObject.h"
#include <CAM_Module.h>
#include <CAM_DataModel.h>
#include <QtxMRUAction.h>
#include <QtxDockAction.h>
#include <QtxToolBar.h>
+#include <qprocess.h>
#include <LogWindow.h>
#include <OB_Browser.h>
myAccel->setActionKey( SUIT_Accel::RotateUp, ALT+Key_Up, VTKViewer_Viewer::Type() );
myAccel->setActionKey( SUIT_Accel::RotateDown, ALT+Key_Down, VTKViewer_Viewer::Type() );
#endif
-#ifndef DISABLE_PLOT2DKVIEWER
+#ifndef DISABLE_PLOT2DVIEWER
myAccel->setActionKey( SUIT_Accel::PanLeft, CTRL+Key_Left, Plot2d_Viewer::Type() );
myAccel->setActionKey( SUIT_Accel::PanRight, CTRL+Key_Right, Plot2d_Viewer::Type() );
myAccel->setActionKey( SUIT_Accel::PanUp, CTRL+Key_Up, Plot2d_Viewer::Type() );
if ( modIcon.isNull() )
modIcon = QPixmap( imageEmptyIcon );
- QToolBar* modTBar = new QtxToolBar( true, desk );
- modTBar->setLabel( tr( "INF_TOOLBAR_MODULES" ) );
+ QStringList modList;
+ modules( modList, false );
- QActionGroup* modGroup = new QActionGroup( this );
- modGroup->setExclusive( true );
- modGroup->setUsesDropDown( true );
+ if( modList.count()>1 )
+ {
+ QToolBar* modTBar = new QtxToolBar( true, desk );
+ modTBar->setLabel( tr( "INF_TOOLBAR_MODULES" ) );
- a = createAction( -1, tr( "APP_NAME" ), defIcon, tr( "APP_NAME" ),
- tr( "PRP_APP_MODULE" ), 0, desk, true );
- modGroup->add( a );
- myActions.insert( QString(), a );
+ QActionGroup* modGroup = new QActionGroup( this );
+ modGroup->setExclusive( true );
+ modGroup->setUsesDropDown( true );
- QMap<QString, QString> iconMap;
- moduleIconNames( iconMap );
+ a = createAction( -1, tr( "APP_NAME" ), defIcon, tr( "APP_NAME" ),
+ tr( "PRP_APP_MODULE" ), 0, desk, true );
+ modGroup->add( a );
+ myActions.insert( QString(), a );
- const int iconSize = 20;
+ QMap<QString, QString> iconMap;
+ moduleIconNames( iconMap );
- modGroup->addTo( modTBar );
- QObjectList *l = modTBar->queryList( "QComboBox" );
- QObjectListIt oit( *l );
- while ( QObject* obj = oit.current() ) {
- QComboBox* cb = (QComboBox*)obj;
- if ( cb ) cb->setFocusPolicy( QWidget::NoFocus );
+ const int iconSize = 20;
+
+ modGroup->addTo( modTBar );
+ QObjectList *l = modTBar->queryList( "QComboBox" );
+ QObjectListIt oit( *l );
+ while ( QObject* obj = oit.current() ) {
+ QComboBox* cb = (QComboBox*)obj;
+ if ( cb ) cb->setFocusPolicy( QWidget::NoFocus );
++oit;
- }
- delete l;
+ }
+ delete l;
- modTBar->addSeparator();
-
- QStringList modList;
- modules( modList, false );
+ modTBar->addSeparator();
- for ( it = modList.begin(); it != modList.end(); ++it )
- {
- if ( !isLibExists( *it ) )
- continue;
+ for ( it = modList.begin(); it != modList.end(); ++it )
+ {
+ if ( !isLibExists( *it ) )
+ continue;
- QString iconName;
- if ( iconMap.contains( *it ) )
- iconName = iconMap[*it];
+ QString iconName;
+ if ( iconMap.contains( *it ) )
+ iconName = iconMap[*it];
- QString modName = moduleName( *it );
+ QString modName = moduleName( *it );
- QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
- if ( icon.isNull() )
+ QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
+ if ( icon.isNull() )
{
icon = modIcon;
printf( "****************************************************************\n" );
printf( "****************************************************************\n" );
}
- icon.convertFromImage( icon.convertToImage().smoothScale( iconSize, iconSize, QImage::ScaleMin ) );
+ icon.convertFromImage( icon.convertToImage().smoothScale( iconSize, iconSize, QImage::ScaleMin ) );
- QAction* a = createAction( -1, *it, icon, *it, tr( "PRP_MODULE" ).arg( *it ), 0, desk, true );
- a->addTo( modTBar );
- modGroup->add( a );
+ QAction* a = createAction( -1, *it, icon, *it, tr( "PRP_MODULE" ).arg( *it ), 0, desk, true );
+ a->addTo( modTBar );
+ modGroup->add( a );
- myActions.insert( *it, a );
- }
+ myActions.insert( *it, a );
+ }
- SUIT_Tools::simplifySeparators( modTBar );
+ SUIT_Tools::simplifySeparators( modTBar );
+ connect( modGroup, SIGNAL( selected( QAction* ) ), this, SLOT( onModuleActivation( QAction* ) ) );
+ }
// New window
int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 );
SHIFT+Key_R, desk, false, this, SLOT( onRenameWindow() ) );
createMenu( RenameId, windowMenu, -1 );
- connect( modGroup, SIGNAL( selected( QAction* ) ), this, SLOT( onModuleActivation( QAction* ) ) );
-
int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
createMenu( PreferencesId, fileMenu, 15, -1 );
createMenu( separator(), fileMenu, -1, 15, -1 );
if ( !myApp.isEmpty())
{
aCommand.sprintf("%s %s %s",myApp.latin1(),myParams.latin1(),myHelpFile.latin1());
- myStatus = system(aCommand);
- if(myStatus != 0)
+
+ QProcess* proc = new QProcess();
+ proc->addArgument( aCommand );
+ //myStatus = system(aCommand);
+
+ //if(myStatus != 0)
+ if(!proc->start())
{
QCustomEvent* ce2000 = new QCustomEvent( 2000 );
QString* msg = new QString( QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").arg(myApp).arg(myHelpFile) );
QString helpFile = QFileInfo( homeDir + (!aComponentName.compare(QString("KERNEL")) ? aFileNameKernel : aFileName) ).absFilePath();
SUIT_ResourceMgr* resMgr = resourceMgr();
- QString anApp = resMgr->stringValue("ExternalBrowser", "application");
+ QString platform;
+#ifdef WIN32
+ platform = "winapplication";
+#else
+ platform = "application";
+#endif
+ QString anApp = resMgr->stringValue("ExternalBrowser", platform);
+#ifdef WIN32
+ QString quote("\"");
+ anApp.prepend( quote );
+ anApp.append( quote );
+#endif
QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
if (!anApp.isEmpty()) {
QString helpFile = QFileInfo( homeDir + theFileName ).absFilePath();
SUIT_ResourceMgr* resMgr = resourceMgr();
- QString anApp = resMgr->stringValue("ExternalBrowser", "application");
+ QString platform;
+#ifdef WIN32
+ platform = "winapplication";
+#else
+ platform = "application";
+#endif
+ QString anApp = resMgr->stringValue("ExternalBrowser", platform);
+#ifdef WIN32
+ QString quote("\"");
+ anApp.prepend( quote );
+ anApp.append( quote );
+#endif
QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
if (!anApp.isEmpty()) {
sId = activeStudy()->id();
}
+ bool anIsEmpty = !myWindows[flag]->isEmpty();
QWidget* wid = myWindows[flag]->widget( sId );
myWindows[flag]->remove( sId );
delete wid;
- setWindowShown( flag, !myWindows[flag]->isEmpty() );
+ //setWindowShown( flag, !myWindows[flag]->isEmpty() );
+ setWindowShown( flag, anIsEmpty );
}
/*!
activateModule( defaultModule() );
+ if ( objectBrowser() )
+ objectBrowser()->openLevels();
+
activateWindows();
}
//aRoot->dump();
}
getWindow( WT_ObjectBrowser );
- if ( objectBrowser() != 0 ) {
+ if ( objectBrowser() )
objectBrowser()->setRootObject( aRoot );
- }
activateModule( defaultModule() );
+ if ( objectBrowser() )
+ objectBrowser()->openLevels();
+
activateWindows();
emit studyOpened();
}
/*!Protected SLOT. On study closed.*/
-void LightApp_Application::onStudyClosed( SUIT_Study* )
+void LightApp_Application::onStudyClosed( SUIT_Study* s )
{
- emit studyClosed();
-
// Bug 10396: clear selection
mySelMgr->clearSelected();
+ // Bug 12944: emit signal only after clear selection
+ emit studyClosed();
+
activateModule( "" );
- saveWindowsGeometry();
+ for ( WindowMap::ConstIterator itr = myWindows.begin(); s && itr != myWindows.end(); ++itr )
+ removeWindow( itr.key(), s->id() );
}
/*!Protected SLOT.On desktop activated.*/
sMod->preferencesChanged( section, param );
else
preferencesChanged( section, param );
+ // emit signal to allow additional preferences changing processing
+ emit preferenceChanged( modName, section, param );
}
/*!Private SLOT. On open document with name \a aName.*/
void LightApp_Application::beforeCloseDoc( SUIT_Study* s )
{
CAM_Application::beforeCloseDoc( s );
-
- for ( WindowMap::ConstIterator itr = myWindows.begin(); s && itr != myWindows.end(); ++itr )
- removeWindow( itr.key(), s->id() );
}
/*!Update actions.*/
int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab );
pref->setItemProperty( extgroup, "columns", 1 );
- int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", "application" );
+ QString platform;
+#ifdef WIN32
+ platform = "winapplication";
+#else
+ platform = "application";
+#endif
+ int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", platform );
pref->setItemProperty( apppref, "existing", true );
pref->setItemProperty( apppref, "flags", QFileInfo::ExeUser );
pref->setItemProperty( apppref, "readOnly", false );
currentWindows( winMap );
if ( activeStudy() ) {
- for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
- getWindow( it.key() );
+ for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it ) {
+ getWindow( it.key() );
+
+ Dock dock; int index, extraOffset; bool nl;
+ if ( desktop()->getLocation( myWindows[it.key()], dock, index, nl, extraOffset )
+ &&
+ dock != (Dock)it.data() )
+ desktop()->moveDockWindow( myWindows[it.key()], (Dock)it.data() );
+ }
loadWindowsGeometry();
}
\param moduleTitle - title of module
*/
bool LightApp_Application::isLibExists( const QString& moduleTitle ) const
-{
+{
if( moduleTitle.isEmpty() )
return false;
QString lib = moduleLibrary( moduleTitle );
- bool isPythonModule = lib.contains("libSalomePyQtGUI");
+ //abd: changed libSalomePyQtGUI to SalomePyQtGUI for WIN32
+ bool isPythonModule = lib.contains("SalomePyQtGUI");
QStringList paths;
#ifdef WIN32
printf( "* No module named %s\n", (moduleName( moduleTitle ) + QString("GUI")).latin1() );
printf( "****************************************************************\n" );
return true;
- }
-
+ }
return false;
}
}
return CAM_Application::event( e );
}
+
+/*! Check data object */
+bool LightApp_Application::checkDataObject(LightApp_DataObject* theObj)
+{
+ if (theObj)
+ {
+ bool isSuitable = !theObj->entry().isEmpty() &&
+ !theObj->componentDataType().isEmpty() &&
+ !theObj->name().isEmpty();
+ return isSuitable;
+ }
+
+ return false;
+}
class LightApp_WidgetContainer;
class LightApp_Preferences;
class LightApp_SelectionMgr;
+class LightApp_DataObject;
class SUIT_Study;
class SUIT_Accel;
class CAM_Module;
SUIT_ViewManager* getViewManager( const QString&, const bool );
virtual void addViewManager( SUIT_ViewManager* );
virtual void removeViewManager( SUIT_ViewManager* );
+ virtual SUIT_ViewManager* createViewManager( const QString& vmType );
+
QWidget* getWindow( const int, const int = -1 );
QWidget* window( const int, const int = -1 ) const;
void addWindow( QWidget*, const int, const int = -1 );
static int studyId();
virtual bool event( QEvent* );
+
+ virtual bool checkDataObject( LightApp_DataObject* theObj );
signals:
void studyOpened();
void studySaved();
void studyClosed();
+ void preferenceChanged( const QString&, const QString&, const QString& );
public slots:
virtual void onHelpContentsModule();
virtual void preferencesChanged( const QString&, const QString& );
virtual void savePreferences();
virtual void updateDesktopTitle();
-
+
protected slots:
virtual void onDesktopActivated();
QString defaultModule() const;
void currentWindows( QMap<int, int>& ) const;
void currentViewManagers( QStringList& ) const;
- virtual SUIT_ViewManager* createViewManager( const QString& vmType );
void moduleIconNames( QMap<QString, QString>& ) const;
void activateWindows();
{
LightApp_ModuleObject* modelRoot = dynamic_cast<LightApp_ModuleObject*>( root() );
DataObjectList ch;
+ QMap<SUIT_DataObject*,int> aMap;
if( modelRoot )
{
ch = modelRoot->children();
for ( DataObjectListIterator it( ch ); it.current(); ++it )
it.current()->setParent( 0 );
}
+
build();
+
+ modelRoot = dynamic_cast<LightApp_ModuleObject*>( root() );
+ if( modelRoot )
+ {
+ DataObjectList new_ch = modelRoot->children();
+ for ( DataObjectListIterator it1( new_ch ); it1.current(); ++it1 )
+ aMap.insert( it1.current(), 0 );
+ }
+
updateWidgets();
+
for( DataObjectListIterator it( ch ); it.current(); ++it )
- delete it.current();
+ if( !aMap.contains( it.current() ) )
+ delete it.current();
}
/*!
#include <iostream>
/*!Constructor. Initialize by \a theEntry.*/
-LightApp_DataOwner
-::LightApp_DataOwner( const QString& theEntry ):
- myEntry( theEntry )
+LightApp_DataOwner::LightApp_DataOwner( const QString& theEntry )
+: myEntry( theEntry )
+{
+}
+
+LightApp_DataOwner::LightApp_DataOwner( const LightApp_DataObject* obj )
+: myEntry( obj ? obj->entry() : QString::null )
{
}
#ifndef DISABLE_SALOMEOBJECT
/*!Constructor. Initialize by \a SALOME_InteractiveObject.*/
-LightApp_DataOwner
-::LightApp_DataOwner( const Handle(SALOME_InteractiveObject)& theIO ):
- myEntry(!theIO.IsNull()? theIO->getEntry(): ""),
- myIO(theIO)
+LightApp_DataOwner::LightApp_DataOwner( const Handle(SALOME_InteractiveObject)& theIO )
+: myEntry( !theIO.IsNull() ? theIO->getEntry() : "" ),
+myIO( theIO )
{
}
#endif
/*!Destructor. Do nothing.*/
-LightApp_DataOwner
-::~LightApp_DataOwner()
+LightApp_DataOwner::~LightApp_DataOwner()
{
}
/*!Checks: Is current data owner equal \a obj.*/
-bool
-LightApp_DataOwner
-::isEqual( const SUIT_DataOwner& obj ) const
+bool LightApp_DataOwner::isEqual( const SUIT_DataOwner& obj ) const
{
const LightApp_DataOwner* other = dynamic_cast<const LightApp_DataOwner*>( &obj );
-
return other && entry() == other->entry();
}
-bool LightApp_DataOwner::operator<( const SUIT_DataOwner& obj ) const
+bool LightApp_DataOwner::isLess( const SUIT_DataOwner& obj ) const
{
const LightApp_DataOwner* other = dynamic_cast<const LightApp_DataOwner*>( &obj );
- return entry() < other->entry();
+ return other && entry() < other->entry();
}
/*!Gets entry.*/
#include "SALOME_InteractiveObject.hxx"
#endif
+class LightApp_DataObject;
+
/*!
This class provide data owner objects.
*/
#ifndef DISABLE_SALOMEOBJECT
LightApp_DataOwner( const Handle(SALOME_InteractiveObject)& theIO );
#endif
+ LightApp_DataOwner( const LightApp_DataObject* );
LightApp_DataOwner( const QString& );
virtual ~LightApp_DataOwner();
virtual bool isEqual( const SUIT_DataOwner& ) const;
- virtual bool operator<( const SUIT_DataOwner& ) const;
+ virtual bool isLess( const SUIT_DataOwner& ) const;
#ifndef DISABLE_SALOMEOBJECT
const Handle(SALOME_InteractiveObject)& IO() const;
return false;
}
+/*!Checks: Is current data sub owner less \a obj.*/
+bool LightApp_DataSubOwner::isLess( const SUIT_DataOwner& obj ) const
+{
+ const LightApp_DataSubOwner* other = dynamic_cast<const LightApp_DataSubOwner*>( &obj );
+ if(other && entry() == other->entry()){
+ return index() < other->index();
+ }
+ return other && entry() < other->entry();
+}
+
/*!Gets index.*/
int LightApp_DataSubOwner::index() const
{
virtual ~LightApp_DataSubOwner();
virtual bool isEqual( const SUIT_DataOwner& ) const;
+ virtual bool isLess( const SUIT_DataOwner& obj ) const;
int index() const;
private:
class SUIT_ResourceMgr;
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
/*!
\class LightApp_Dialog
Base class for all LightApp dialogs.
public:
typedef QValueList<int> TypesList;
typedef QMap<int,QStringList> SelectedObjects;
-
+
enum ObjectWg
{
Label = 0x00000001,
//! Set all object selection buttons to inactive state
void deactivateAll();
-
+
signals:
//! selection in certain widget is changed
void selectionChanged ( int );
private:
ObjectMap myObjects;
+
QMap<int,QString> myTypeNames;
bool myIsExclusive, myIsBusy;
QPixmap myPixmap;
};
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
#endif
#ifndef LIGHTAPP_DISPLAYER_HEADER
#define LIGHTAPP_DISPLAYER_HEADER
+#include "LightApp.h"
+
#include <SALOME_Prs.h>
class QString;
Uniform mechanism of display/erase of objects in different views.
Objects are specified by string entry
*/
-class LightApp_Displayer : public SALOME_Displayer
+class LIGHTAPP_EXPORT LightApp_Displayer : public SALOME_Displayer
{
public:
LightApp_Displayer();
#include "LightApp_GLSelector.h"
#include "LightApp_DataOwner.h"
+#include "LightApp_DataObject.h"
#include <GLViewer_Context.h>
GLViewer_Object* obj = cont->SelectedObject();
if ( obj )
{
- LightApp_GLOwner* owner = dynamic_cast< LightApp_GLOwner* >( obj->owner() );
- if( owner )
+ LightApp_DataOwner* owner = dynamic_cast<LightApp_DataOwner*>( obj->owner() );
+ if ( owner )
aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( owner->entry() ) ) );
}
}
if ( !cont )
return;
- QMap<QString, GLViewer_Object*> aDisplayed;
- const ObjList& displayed = cont->getObjects();
- for ( ObjList::const_iterator it = displayed.begin(); it != displayed.end(); ++it )
- {
- GLViewer_Object* obj = *it;
- if ( obj && obj->getVisible() )
- {
- LightApp_GLOwner* owner = dynamic_cast< LightApp_GLOwner* >( obj->owner() );
- if ( owner )
- aDisplayed.insert( owner->entry(), obj );
- }
- }
-
- int Nb = 0;
- cont->clearSelected( false );
+ QMap<QString, int> aSelected;
for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr )
{
const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*itr).operator->() );
- if ( !owner )
- continue;
+ if ( owner )
+ aSelected.insert( owner->entry(), 0 );
+ }
- if ( aDisplayed.contains( owner->entry() ) )
+ bool changed = false;
+ const ObjList& displayed = cont->getObjects();
+ for ( ObjList::const_iterator it = displayed.begin(); it != displayed.end(); ++it )
+ {
+ GLViewer_Object* obj = *it;
+ if ( obj && obj->getVisible() )
{
- cont->setSelected( aDisplayed[owner->entry()], false );
- Nb++;
+ LightApp_DataOwner* owner = dynamic_cast<LightApp_DataOwner*>( obj->owner() );
+ bool sel = owner && aSelected.contains( owner->entry() );
+ changed = changed || sel != (bool)obj->isSelected();
+ if ( sel && !obj->isSelected() )
+ cont->setSelected( obj, false );
+ else if ( !sel && obj->isSelected() )
+ cont->remSelected( obj, false );
}
}
- if ( Nb > 0 )
+ if ( changed )
myViewer->updateAll();
}
-
-
-/*!
- Constructor
- \param entry - entry of object
-*/
-LightApp_GLOwner::LightApp_GLOwner( const char* entry )
-: GLViewer_Owner()
-{
- setEntry( entry );
-}
-
-/*!
- Destructor
-*/
-LightApp_GLOwner::~LightApp_GLOwner()
-{
-}
-
-/*!
- \return entry
-*/
-const char* LightApp_GLOwner::entry() const
-{
- return myEntry.c_str();
-}
-
-/*!
- Sets new entry
- \param entry - entry of object
-*/
-void LightApp_GLOwner::setEntry( const char* entry )
-{
- myEntry = entry;
-}
#include <string>
#include <GLViewer_Object.h>
+class LightApp_DataObject;
+
/*!
\class LightApp_GLSelector
Custom selector to get/set selection from GL viewer
};
-/*!
- This class provide data owner objects for GLViewer.
-*/
-class LIGHTAPP_EXPORT LightApp_GLOwner : public GLViewer_Owner
-{
-public:
- LightApp_GLOwner( const char* );
- ~LightApp_GLOwner();
-
- const char* entry() const;
- void setEntry( const char* );
-
-private:
- std::string myEntry;
-};
-
#endif
bool upd = getApp()->objectBrowser()->isAutoUpdate();
getApp()->objectBrowser()->setAutoUpdate( false );
- SUIT_DataObject* aDataObject = theDataObject;
if( theIsUpdateDataModel ){
if( CAM_DataModel* aDataModel = dataModel() ){
if ( LightApp_DataModel* aModel = dynamic_cast<LightApp_DataModel*>( aDataModel ) ) {
LightApp_DataObject* anObject = dynamic_cast<LightApp_DataObject*>(theDataObject);
LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(getApp()->activeStudy());
aModel->update( anObject, aStudy );
-
- if(aParent && aParent->childPos(anObject) < 0)
- aDataObject = dynamic_cast<LightApp_DataObject*>(aParent);
}
}
}
getApp()->objectBrowser()->setAutoUpdate( upd );
- getApp()->objectBrowser()->updateTree( 0, false /*aDataObject*/ );
+ getApp()->objectBrowser()->updateTree( 0, false );
}
/*!NOT IMPLEMENTED*/
myPopupMgr->insert( eraseAll, -1, 0 );
myPopupMgr->insert( separator(), -1, 0 );
- QString oneAndNotActive = "( count( $component ) = 1 ) and ( component != activeModule )";
+ QString oneAndNotActive = "( count( $component ) = 1 ) and ( not( activeModule in $component ) )";
QString uniform = "true in $canBeDisplayed and %1 and ( activeModule = '%2' )";
uniform = uniform.arg( oneAndNotActive ).arg( name() );
myPopupMgr->setRule( disp, /*QString( "( not isVisible ) and " ) + */ uniform, true );
class QString;
class QVariant;
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
/*!
\class LightApp_Module
Base class for all light modules
virtual void studyActivated() {};
virtual LightApp_Displayer* displayer();
+ virtual LightApp_Selection* createSelection() const;
public slots:
virtual bool activateModule( SUIT_Study* );
LightApp_Preferences* preferences() const;
virtual CAM_DataModel* createDataModel();
- virtual LightApp_Selection* createSelection() const;
int addPreference( const QString& label );
int addPreference( const QString& label, const int pId, const int = -1,
int myDisplay, myErase, myDisplayOnly, myEraseAll;
};
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
#endif
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// File : LightApp_ModuleDlg.cxx\r
-// Author : Michael Zorin (mzn)\r
-// Module : LightApp\r
-\r
-#include <LightApp_ModuleDlg.h>\r
-\r
-#include <qframe.h>\r
-#include <qlabel.h>\r
-#include <qpushbutton.h>\r
-#include <qlayout.h>\r
-#include <qpixmap.h>\r
-\r
-#ifndef WIN32\r
-using namespace std;\r
-#endif\r
-\r
-/*!Default icon*/\r
-static const char* const default_icon[] = { \r
-"48 48 17 1",\r
-". c None",\r
-"# c #161e4c",\r
-"b c #1d3638",\r
-"e c #2f585b",\r
-"i c #345b5e",\r
-"c c #386266",\r
-"g c #3f7477",\r
-"d c #4d8589",\r
-"m c #519099",\r
-"o c #6abbc1",\r
-"a c #70c9d3",\r
-"f c #79ddea",\r
-"n c #7adff2",\r
-"k c #7ce2f4",\r
-"j c #993550",\r
-"h c #d84b71",\r
-"l c #ef537d",\r
-"................................................",\r
-"................................................",\r
-"................................................",\r
-"................................................",\r
-"................................................",\r
-"................########.########.########......",\r
-"...............#aaaaaa###aaaaaa###aaaaaa##......",\r
-"..............#aaaaaa#b#aaaaaa#b#aaaaaa#c#......",\r
-".............########b########b########cc#......",\r
-".............#dddddd#b#dddddd#b#dddddd#cc#......",\r
-"...........########d########d########d#cc#......",\r
-"..........#aaaaaa###aaaaaa###aaaaaa##d#cc#......",\r
-".........#aaaaaa#b#aaaaaa#b#aaaaaa#c#d#cc#......",\r
-"........########b########e########cc#d#c#.......",\r
-"........#dddddd#b#dddddd#e#ffffff#cc#d####......",\r
-"......########d########d########f#cc###g##......",\r
-".....#aaaaaa###aaaaaa###hhhhhh##f#cc#gg#c#......",\r
-"....#aaaaaa#b#aaaaaa#i#hhhhhh#j#f#cc###cc#......",\r
-"...########b########i########jj#f#c#gg#cc#......",\r
-"...#kkkkkk#b#kkkkkk#i#llllll#jj#f####g#cc#......",\r
-"...#kkkkkk#b#kkkkkk#i#llllll#jj###m##g#cc#......",\r
-"...#knnkkk#b#kkkkkk#i#llllll#jj#mm#c#g#cc#......",\r
-"...#knnkkk#b#kkkkkk#i#llllll#jj###cc#g#c#.......",\r
-"...#kkkkkk#b#kkkkkk#i#llllll#j#dd#cc#g####......",\r
-"...#kkkkkk###kkkkkk###llllll####d#cc###g##......",\r
-"...########g########g########o##d#cc#gg#c#......",\r
-"....#gggggg#b#gggggg#b#oooooo#c#d#cc###cc#......",\r
-"...########b########b########cc#d#c#gg#cc#......",\r
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#d####g#cc#......",\r
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###g##g#cc#......",\r
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#gg#c#g#cc#......",\r
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###cc#g#c#.......",\r
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#c#gg#cc#g##........",\r
-"...#kkkkkk###kkkkkk###kkkkkk####g#cc###.........",\r
-"...########g########g########g##g#cc#...........",\r
-"....#gggggg#b#gggggg#b#gggggg#c#g#cc#...........",\r
-"...########b########b########cc#g#c#............",\r
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#g##.............",\r
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###..............",\r
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#................",\r
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#................",\r
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#c#.................",\r
-"...#kkkkkk###kkkkkk###kkkkkk##..................",\r
-"...########.########.########...................",\r
-"................................................",\r
-"................................................",\r
-"................................................",\r
-"................................................"};\r
-\r
-//==============================================================================================================================\r
-/*!\r
- * LightApp_ModuleDlg::LightApp_ModuleDlg \n\r
- *\r
- * Constructor.\r
- */\r
-//==============================================================================================================================\r
-LightApp_ModuleDlg::LightApp_ModuleDlg ( QWidget * parent, const QString& component, const QPixmap icon )\r
- : QDialog ( parent, "ActivateModuleDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )\r
-{\r
- QPixmap defaultIcon( ( const char** ) default_icon );\r
- setCaption( tr( "CAPTION" ) );\r
- setSizeGripEnabled( TRUE );\r
- \r
- QGridLayout* ActivateModuleDlgLayout = new QGridLayout( this ); \r
- ActivateModuleDlgLayout->setMargin( 11 ); ActivateModuleDlgLayout->setSpacing( 6 );\r
-\r
- // Module's name and icon\r
- myComponentFrame = new QFrame( this, "myComponentFrame" );\r
- myComponentFrame->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ) );\r
- myComponentFrame->setMinimumHeight( 100 );\r
- myComponentFrame->setFrameStyle( QFrame::Box | QFrame::Sunken );\r
- \r
- QGridLayout* myComponentFrameLayout = new QGridLayout( myComponentFrame ); \r
- myComponentFrameLayout->setMargin( 11 ); myComponentFrameLayout->setSpacing( 6 );\r
-\r
- // --> icon\r
- myComponentIcon = new QLabel( myComponentFrame, "myComponentIcon" );\r
- myComponentIcon->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );\r
- myComponentIcon->setPixmap( !icon.isNull() ? icon : defaultIcon );\r
- myComponentIcon->setScaledContents( false );\r
- myComponentIcon->setAlignment( AlignCenter );\r
- // --> name\r
- myComponentLab = new QLabel( component, myComponentFrame, "myComponentLab" );\r
- QFont fnt = myComponentLab->font(); fnt.setBold( TRUE ); myComponentLab->setFont( fnt ); \r
- myComponentLab->setAlignment( AlignCenter );\r
-\r
- myComponentFrameLayout->addWidget( myComponentIcon, 0, 0 );\r
- myComponentFrameLayout->addWidget( myComponentLab, 0, 1 );\r
-\r
- // Info\r
- QVBoxLayout* infoLayout = new QVBoxLayout();\r
- infoLayout->setMargin( 0 ); infoLayout->setSpacing( 6 );\r
- \r
- // --> top line\r
- QFrame* myLine1 = new QFrame( this, "myLine1" );\r
- myLine1->setFrameStyle( QFrame::HLine | QFrame::Plain );\r
- // --> info label \r
- myInfoLabel = new QLabel( tr ("ActivateComponent_DESCRIPTION"), this, "myInfoLabel" );\r
- myInfoLabel->setAlignment( AlignCenter );\r
- // --> bottom line\r
- QFrame* myLine2 = new QFrame( this, "myLine2" );\r
- myLine2->setFrameStyle( QFrame::HLine | QFrame::Plain );\r
- \r
- infoLayout->addStretch();\r
- infoLayout->addWidget( myLine1 );\r
- infoLayout->addWidget( myInfoLabel );\r
- infoLayout->addWidget( myLine2 );\r
- infoLayout->addStretch();\r
- \r
- // Buttons\r
- QHBoxLayout* btnLayout = new QHBoxLayout(); \r
- btnLayout->setMargin( 0 ); btnLayout->setSpacing( 6 );\r
- \r
- // --> New\r
- myNewBtn = new QPushButton( tr( "NEW" ), this, "myNewBtn" );\r
- myNewBtn->setDefault( true ); myNewBtn->setAutoDefault( true );\r
- // --> Open\r
- myOpenBtn = new QPushButton( tr( "OPEN" ), this, "myOpenBtn" );\r
- myOpenBtn->setAutoDefault( true );\r
- // --> Load\r
- myLoadBtn = new QPushButton( tr( "LOAD" ), this, "myLoadBtn" );\r
- myLoadBtn->setAutoDefault( true );\r
- // --> Cancel\r
- myCancelBtn = new QPushButton( tr( "CANCEL" ), this, "myCancelBtn" );\r
- myCancelBtn->setAutoDefault( true );\r
- \r
- btnLayout->addWidget( myNewBtn );\r
- btnLayout->addWidget( myOpenBtn );\r
- btnLayout->addWidget( myLoadBtn );\r
- btnLayout->addStretch();\r
- btnLayout->addSpacing( 70 );\r
- btnLayout->addStretch();\r
- btnLayout->addWidget( myCancelBtn );\r
-\r
- ActivateModuleDlgLayout->addWidget( myComponentFrame, 0, 0 );\r
- ActivateModuleDlgLayout->addLayout( infoLayout, 0, 1 );\r
- ActivateModuleDlgLayout->addMultiCellLayout( btnLayout, 1, 1, 0, 1 );\r
-\r
- // signals and slots connections\r
- connect( myNewBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );\r
- connect( myOpenBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );\r
- connect( myLoadBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );\r
- connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );\r
-}\r
-\r
-//==============================================================================================================================\r
-/*!\r
- * LightApp_ModuleDlg::onButtonClicked\r
- *\r
- * Buttons slot\r
- */\r
-//==============================================================================================================================\r
-void LightApp_ModuleDlg::onButtonClicked()\r
-{\r
- QPushButton* btn = ( QPushButton* )sender();\r
- if ( btn == myNewBtn )\r
- done( 1 );\r
- if ( btn == myOpenBtn )\r
- done( 2 );\r
- if ( btn == myLoadBtn )\r
- done( 3 );\r
-}\r
+// File : LightApp_ModuleDlg.cxx
+// Author : Michael Zorin (mzn)
+// Module : LightApp
+
+#include <LightApp_ModuleDlg.h>
+
+#include <qframe.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qlayout.h>
+#include <qpixmap.h>
+
+#ifndef WIN32
+using namespace std;
+#endif
+
+/*!Default icon*/
+static const char* const default_icon[] = {
+"48 48 17 1",
+". c None",
+"# c #161e4c",
+"b c #1d3638",
+"e c #2f585b",
+"i c #345b5e",
+"c c #386266",
+"g c #3f7477",
+"d c #4d8589",
+"m c #519099",
+"o c #6abbc1",
+"a c #70c9d3",
+"f c #79ddea",
+"n c #7adff2",
+"k c #7ce2f4",
+"j c #993550",
+"h c #d84b71",
+"l c #ef537d",
+"................................................",
+"................................................",
+"................................................",
+"................................................",
+"................................................",
+"................########.########.########......",
+"...............#aaaaaa###aaaaaa###aaaaaa##......",
+"..............#aaaaaa#b#aaaaaa#b#aaaaaa#c#......",
+".............########b########b########cc#......",
+".............#dddddd#b#dddddd#b#dddddd#cc#......",
+"...........########d########d########d#cc#......",
+"..........#aaaaaa###aaaaaa###aaaaaa##d#cc#......",
+".........#aaaaaa#b#aaaaaa#b#aaaaaa#c#d#cc#......",
+"........########b########e########cc#d#c#.......",
+"........#dddddd#b#dddddd#e#ffffff#cc#d####......",
+"......########d########d########f#cc###g##......",
+".....#aaaaaa###aaaaaa###hhhhhh##f#cc#gg#c#......",
+"....#aaaaaa#b#aaaaaa#i#hhhhhh#j#f#cc###cc#......",
+"...########b########i########jj#f#c#gg#cc#......",
+"...#kkkkkk#b#kkkkkk#i#llllll#jj#f####g#cc#......",
+"...#kkkkkk#b#kkkkkk#i#llllll#jj###m##g#cc#......",
+"...#knnkkk#b#kkkkkk#i#llllll#jj#mm#c#g#cc#......",
+"...#knnkkk#b#kkkkkk#i#llllll#jj###cc#g#c#.......",
+"...#kkkkkk#b#kkkkkk#i#llllll#j#dd#cc#g####......",
+"...#kkkkkk###kkkkkk###llllll####d#cc###g##......",
+"...########g########g########o##d#cc#gg#c#......",
+"....#gggggg#b#gggggg#b#oooooo#c#d#cc###cc#......",
+"...########b########b########cc#d#c#gg#cc#......",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#d####g#cc#......",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###g##g#cc#......",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#gg#c#g#cc#......",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###cc#g#c#.......",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#c#gg#cc#g##........",
+"...#kkkkkk###kkkkkk###kkkkkk####g#cc###.........",
+"...########g########g########g##g#cc#...........",
+"....#gggggg#b#gggggg#b#gggggg#c#g#cc#...........",
+"...########b########b########cc#g#c#............",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#g##.............",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###..............",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#................",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#................",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#c#.................",
+"...#kkkkkk###kkkkkk###kkkkkk##..................",
+"...########.########.########...................",
+"................................................",
+"................................................",
+"................................................",
+"................................................"};
+
+//==============================================================================================================================
+/*!
+ * LightApp_ModuleDlg::LightApp_ModuleDlg \n
+ *
+ * Constructor.
+ */
+//==============================================================================================================================
+LightApp_ModuleDlg::LightApp_ModuleDlg ( QWidget * parent, const QString& component, const QPixmap icon )
+ : QDialog ( parent, "ActivateModuleDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+{
+ QPixmap defaultIcon( ( const char** ) default_icon );
+ setCaption( tr( "CAPTION" ) );
+ setSizeGripEnabled( TRUE );
+
+ QGridLayout* ActivateModuleDlgLayout = new QGridLayout( this );
+ ActivateModuleDlgLayout->setMargin( 11 ); ActivateModuleDlgLayout->setSpacing( 6 );
+
+ // Module's name and icon
+ myComponentFrame = new QFrame( this, "myComponentFrame" );
+ myComponentFrame->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ) );
+ myComponentFrame->setMinimumHeight( 100 );
+ myComponentFrame->setFrameStyle( QFrame::Box | QFrame::Sunken );
+
+ QGridLayout* myComponentFrameLayout = new QGridLayout( myComponentFrame );
+ myComponentFrameLayout->setMargin( 11 ); myComponentFrameLayout->setSpacing( 6 );
+
+ // --> icon
+ myComponentIcon = new QLabel( myComponentFrame, "myComponentIcon" );
+ myComponentIcon->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
+ myComponentIcon->setPixmap( !icon.isNull() ? icon : defaultIcon );
+ myComponentIcon->setScaledContents( false );
+ myComponentIcon->setAlignment( AlignCenter );
+ // --> name
+ myComponentLab = new QLabel( component, myComponentFrame, "myComponentLab" );
+ QFont fnt = myComponentLab->font(); fnt.setBold( TRUE ); myComponentLab->setFont( fnt );
+ myComponentLab->setAlignment( AlignCenter );
+
+ myComponentFrameLayout->addWidget( myComponentIcon, 0, 0 );
+ myComponentFrameLayout->addWidget( myComponentLab, 0, 1 );
+
+ // Info
+ QVBoxLayout* infoLayout = new QVBoxLayout();
+ infoLayout->setMargin( 0 ); infoLayout->setSpacing( 6 );
+
+ // --> top line
+ QFrame* myLine1 = new QFrame( this, "myLine1" );
+ myLine1->setFrameStyle( QFrame::HLine | QFrame::Plain );
+ // --> info label
+ myInfoLabel = new QLabel( tr ("ActivateComponent_DESCRIPTION"), this, "myInfoLabel" );
+ myInfoLabel->setAlignment( AlignCenter );
+ // --> bottom line
+ QFrame* myLine2 = new QFrame( this, "myLine2" );
+ myLine2->setFrameStyle( QFrame::HLine | QFrame::Plain );
+
+ infoLayout->addStretch();
+ infoLayout->addWidget( myLine1 );
+ infoLayout->addWidget( myInfoLabel );
+ infoLayout->addWidget( myLine2 );
+ infoLayout->addStretch();
+
+ // Buttons
+ QHBoxLayout* btnLayout = new QHBoxLayout();
+ btnLayout->setMargin( 0 ); btnLayout->setSpacing( 6 );
+
+ // --> New
+ myNewBtn = new QPushButton( tr( "NEW" ), this, "myNewBtn" );
+ myNewBtn->setDefault( true ); myNewBtn->setAutoDefault( true );
+ // --> Open
+ myOpenBtn = new QPushButton( tr( "OPEN" ), this, "myOpenBtn" );
+ myOpenBtn->setAutoDefault( true );
+ // --> Load
+ myLoadBtn = new QPushButton( tr( "LOAD" ), this, "myLoadBtn" );
+ myLoadBtn->setAutoDefault( true );
+ // --> Cancel
+ myCancelBtn = new QPushButton( tr( "CANCEL" ), this, "myCancelBtn" );
+ myCancelBtn->setAutoDefault( true );
+
+ btnLayout->addWidget( myNewBtn );
+ btnLayout->addWidget( myOpenBtn );
+ btnLayout->addWidget( myLoadBtn );
+ btnLayout->addStretch();
+ btnLayout->addSpacing( 70 );
+ btnLayout->addStretch();
+ btnLayout->addWidget( myCancelBtn );
+
+ ActivateModuleDlgLayout->addWidget( myComponentFrame, 0, 0 );
+ ActivateModuleDlgLayout->addLayout( infoLayout, 0, 1 );
+ ActivateModuleDlgLayout->addMultiCellLayout( btnLayout, 1, 1, 0, 1 );
+
+ // signals and slots connections
+ connect( myNewBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
+ connect( myOpenBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
+ connect( myLoadBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
+ connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
+}
+
+//==============================================================================================================================
+/*!
+ * LightApp_ModuleDlg::onButtonClicked
+ *
+ * Buttons slot
+ */
+//==============================================================================================================================
+void LightApp_ModuleDlg::onButtonClicked()
+{
+ QPushButton* btn = ( QPushButton* )sender();
+ if ( btn == myNewBtn )
+ done( 1 );
+ if ( btn == myOpenBtn )
+ done( 2 );
+ if ( btn == myLoadBtn )
+ done( 3 );
+}
#include "LightApp_DataOwner.h"
#include "LightApp_DataObject.h"
+#include "LightApp_Application.h"
#include <OB_Browser.h>
+#include <SUIT_Session.h>
#include <SUIT_DataObjectIterator.h>
+
#include <qdatetime.h>
+#include <time.h>
+
/*!
Constructor
*/
void LightApp_OBSelector::getSelection( SUIT_DataOwnerPtrList& theList ) const
{
if (mySelectedList.count() == 0 ) {
+ SUIT_Session* session = SUIT_Session::session();
+ SUIT_Application* sapp = session ? session->activeApplication() : 0;
+ LightApp_Application* app = dynamic_cast<LightApp_Application*>( sapp );
+ if( !app )
+ return;
+
if ( !myBrowser )
return;
DataObjectList objlist;
for ( DataObjectListIterator it( objlist ); it.current(); ++it )
{
LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>( it.current() );
- if ( obj )
+ if ( obj && app->checkDataObject(obj) )
{
#ifndef DISABLE_SALOMEOBJECT
Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject
: SUIT_Selector( mgr, viewer ),
myViewer( viewer )
{
- if ( myViewer )
+ if ( myViewer ) {
connect( myViewer, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) );
+ connect( myViewer, SIGNAL( deselection() ), this, SLOT( onDeselection() ) );
+ }
}
/*!
return myViewer;
}
+/*!
+ Acess to external selection for reading( protected )
+*/
+const SUIT_DataOwnerPtrList& LightApp_OCCSelector::getSelectedExt() const
+{
+ return mySelectedExternals;
+}
+
+
+/*!
+ Append owner to external selection ( protected )
+*/
+void LightApp_OCCSelector::appendSelExtOwner( SUIT_DataOwner* theOwner )
+{
+ if ( theOwner )
+ mySelectedExternals.append( theOwner );
+}
+
+/*!
+ Clear external selection
+*/
+void LightApp_OCCSelector::clearSelExtOwners()
+{
+ mySelectedExternals.clear();
+}
+
+
+
/*!On selection changed.*/
void LightApp_OCCSelector::onSelectionChanged()
{
selectionChanged();
}
+/*!On selection cleared.*/
+void LightApp_OCCSelector::onDeselection()
+{
+ clearSelExtOwners();
+}
+
/*!Gets selection list.*/
void LightApp_OCCSelector::getSelection( SUIT_DataOwnerPtrList& aList ) const
{
aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( entry( anIt.Value() ) ) ) );
#endif
}
+ // add externally selected objects
+ SUIT_DataOwnerPtrList::const_iterator anExtIter;
+ for(anExtIter = getSelectedExt().begin(); anExtIter != getSelectedExt().end(); anExtIter++) {
+ aList.append(*anExtIter);
+ }
}
/*!Sets selection list.*/
if ( !entryStr.isEmpty() )
aDisplayed.insert( entryStr, it.Value() );
}
+
+ clearSelExtOwners();
for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr )
{
const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*itr).operator->() );
if ( owner && aDisplayed.contains( owner->entry() ) )
aSelList.Append( aDisplayed[owner->entry()] );
+ else
+ appendSelExtOwner( *itr );
}
myViewer->unHighlightAll( false );
#include "LightApp.h"
#include <SUIT_Selector.h>
+#include <SUIT_DataOwner.h>
#include <OCCViewer_ViewModel.h>
private slots:
virtual void onSelectionChanged();
+ virtual void onDeselection();
protected:
virtual void getSelection( SUIT_DataOwnerPtrList& ) const;
QString entry( const Handle_AIS_InteractiveObject& ) const;
+ const SUIT_DataOwnerPtrList& getSelectedExt() const;
+ void appendSelExtOwner( SUIT_DataOwner* );
+ void clearSelExtOwners();
private:
- OCCViewer_Viewer* myViewer;
+ OCCViewer_Viewer* myViewer;
+ SUIT_DataOwnerPtrList mySelectedExternals;
};
#endif
LightApp_DataOwner* sowner = dynamic_cast<LightApp_DataOwner*>( (*anIt ).get() );
if( sowner )
{
- entry = myStudy->referencedToEntry( sowner->entry() );
+ entry = referencedToEntry( sowner->entry() );
if( entries.contains( entry ) )
continue;
}
}
+QString LightApp_Selection::referencedToEntry( const QString& entry ) const
+{
+ return myStudy->referencedToEntry( entry );
+}
+
/*!
Gets count of entries.
*/
else if( p=="isReference" )
return QtxValue( isReference( ind ), false );
+ else if( p=="displayer" )
+ return param( ind, "component" );
+
else if( p=="canBeDisplayed" )
{
QString mod_name = app->moduleTitle( param( ind, "component" ).toString() );
LightApp_Study* study() const { return myStudy; }
QString activeViewType() const;
SUIT_ViewWindow* activeVW() const;
+ virtual QString referencedToEntry( const QString& ) const;
private:
QString myPopupClient;
}
LightApp_SelectionMgr* mgr = app->selectionMgr();
- LightApp_Selection sel; sel.init( "", mgr );
- if( sel.count()==0 && myActionType!=ERASE_ALL )
+ LightApp_Module* mod = dynamic_cast<LightApp_Module*>( app->activeModule() );
+ if( !mod )
+ return;
+
+ LightApp_Selection* sel = mod->createSelection();
+ if( !sel )
+ return;
+
+ sel->init( "", mgr );
+ if( sel->count()==0 && myActionType!=ERASE_ALL )
{
abort();
return;
}
QString mod_name;
- if( sel.count()>0 )
+ if( sel->count()>0 )
{
- QString aStr = sel.param( 0, "component" ).toString();
+ QString aStr = sel->param( 0, "displayer" ).toString();
mod_name = app->moduleTitle( aStr );
}
else if( app->activeModule() )
}
d->UpdateViewer();
commit();
+
+ delete sel;
}
/*!
Constructor.
*/
-LightApp_SVTKDataOwner
-::LightApp_SVTKDataOwner( const Handle(SALOME_InteractiveObject)& theIO,
- SUIT_Desktop* theDesktop ):
- LightApp_DataOwner( theIO ),
- myDesktop( theDesktop )
-{}
-#endif
-
-/*!
- Destuctor.
-*/
-LightApp_SVTKDataOwner
-::~LightApp_SVTKDataOwner()
+LightApp_SVTKDataOwner::LightApp_SVTKDataOwner( const Handle(SALOME_InteractiveObject)& theIO,
+ SUIT_Desktop* theDesktop )
+: LightApp_DataOwner( theIO ),
+myDesktop( theDesktop )
+{
+}
+#else
+LightApp_SVTKDataOwner::LightApp_SVTKDataOwner( const QString& theEntry )
+: LightApp_DataOwner( theEntry )
{
}
+#endif
/*!
\return active SVTK view window
#endif
+/*!
+ Destuctor.
+*/
+/*
+LightApp_SVTKDataOwner::~LightApp_SVTKDataOwner()
+{
+}
+*/
#ifndef DISABLE_VTKVIEWER
/*!
connect( myViewer, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) );
}
-/*!
- Destructor.
-*/
-LightApp_VTKSelector
-::~LightApp_VTKSelector()
-{
-}
-
/*!
Gets viewer.
*/
class LIGHTAPP_EXPORT LightApp_SVTKDataOwner : public LightApp_DataOwner
{
public:
+ virtual ~LightApp_SVTKDataOwner() {};
#ifndef DISABLE_VTKVIEWER
#ifndef DISABLE_SALOMEOBJECT
- LightApp_SVTKDataOwner( const Handle(SALOME_InteractiveObject)& theIO,
- SUIT_Desktop* theDesktop );
+ LightApp_SVTKDataOwner( const Handle(SALOME_InteractiveObject)&, SUIT_Desktop* );
+ #else
+ LightApp_SVTKDataOwner( const QString& );
#endif
- virtual ~LightApp_SVTKDataOwner();
/*!Gets dataowners ids list.*/
const TColStd_IndexedMapOfInteger& GetIds() const;
SVTK_ViewWindow* GetActiveViewWindow() const;
SUIT_Desktop* myDesktop;
-
-#else
- LightApp_SVTKDataOwner( const QString& );
#endif
};
Q_OBJECT;
public:
+ virtual ~LightApp_VTKSelector() {};
#ifndef DISABLE_VTKVIEWER
LightApp_VTKSelector( SVTK_ViewModelBase*, SUIT_SelectionMgr* );
- virtual ~LightApp_VTKSelector();
SVTK_ViewModelBase* viewer() const;
@COMMENCE@
-SUBDIRS = Qtx DDS QDS SUIT STD CAF CAM SUITApp LogWindow ObjBrowser Prs
+SUBDIRS = Qtx Style DDS QDS SUIT STD CAF CAM SUITApp LogWindow ObjBrowser Prs
ifneq ($(DISABLE_SALOMEOBJECT),yes)
SUBDIRS += OBJECT
ifneq ($(DISABLE_SUPERVGRAPHVIEWER),yes)
SUBDIRS += SUPERVGraph
endif
-SUBDIRS += LightApp Style ResExporter
+SUBDIRS += LightApp ResExporter
ifneq ($(GUI_DISABLE_CORBA),yes)
SUBDIRS += RegistryDisplay TOOLSGUI \
OCCViewer_ViewWindow.cxx \
OCCViewer_VService.cxx \
OCCViewer_CreateRestoreViewDlg.cxx \
- OCCViewer_ClippingDlg.cxx
+ OCCViewer_ClippingDlg.cxx \
+ OCCViewer_SetRotationPointDlg.cxx
LIB_MOC = OCCViewer_AISSelector.h \
OCCViewer_ViewModel.h \
OCCViewer_ViewWindow.h \
OCCViewer_ViewManager.h \
OCCViewer_CreateRestoreViewDlg.h \
- OCCViewer_ClippingDlg.h
+ OCCViewer_ClippingDlg.h \
+ OCCViewer_SetRotationPointDlg.h
RESOURCES_FILES = \
view_back.png \
connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
myBusy = false;
+
+ connect(view, SIGNAL(Show( QShowEvent * )), this, SLOT(onViewShow()));
+ connect(view, SIGNAL(Hide( QHideEvent * )), this, SLOT(onViewHide()));
}
/*!
myClippingPlane = aView3d->ActivePlane();
}
}
+
+void OCCViewer_ClippingDlg::onViewShow()
+{
+ if(myAction->isOn())
+ show();
+ else
+ hide();
+}
+
+void OCCViewer_ClippingDlg::onViewHide()
+{
+ hide();
+}
+
void onModeChanged( int mode );
void onValueChanged();
void onPreview( bool on );
+
+ void onViewShow();
+ void onViewHide();
};
#endif // OCCVIEWER_CLIPPINGDLG_H
int index = curItem->listBox()->index( curItem );
if( myKeyFlag == 2 )
{
- for( int i = 0; i < myListBox->count(); i++ )
+ for( int i = 0; i < (int)myListBox->count(); i++ )
{
if( myListBox->isSelected( i ) && i != index )
{
if( myListBox->count() && myListBox->isEditEnabled() )
{
int curIndex = -1;
- for( int i = 0; i < myListBox->count(); i++ )
+ for( int i = 0; i < (int)myListBox->count(); i++ )
if( myListBox->isSelected( i ) )
{
myListBox->removeItem( i );
- for( int j = i; j < myParametersMap.count(); j++ )
+ for( int j = i; j < (int)myParametersMap.count(); j++ )
if( j != myParametersMap.count() - 1 )
myParametersMap[ j ] = myParametersMap[ j + 1 ];
else
--- /dev/null
+// Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
+//
+// 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
+//
+#include "OCCViewer_SetRotationPointDlg.h"
+
+#include <QtxAction.h>
+
+#include "OCCViewer_ViewWindow.h"
+
+#include <qlineedit.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qlayout.h>
+#include <qvalidator.h>
+#include <qbuttongroup.h>
+#include <qobjectlist.h>
+#include <qcheckbox.h>
+#include <qhbox.h>
+
+/*!
+ Constructor
+ \param view - view window
+ \param parent - parent widget
+ \param name - dialog name
+ \param modal - is this dialog modal
+ \param fl - flags
+*/
+OCCViewer_SetRotationPointDlg::OCCViewer_SetRotationPointDlg( OCCViewer_ViewWindow* view, QWidget* parent, const char* name, bool modal, WFlags fl )
+: QDialog( parent, "OCCViewer_SetRotationPointDlg", modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ),
+ myView( view )
+{
+ setCaption(tr("CAPTION"));
+ setSizeGripEnabled(TRUE);
+
+ // Create layout for this dialog
+ QGridLayout* layoutDlg = new QGridLayout (this);
+ layoutDlg->setSpacing(6);
+ layoutDlg->setMargin(11);
+
+ // Create check box "Use Bounding Box Center"
+ QHBox* aCheckBox = new QHBox(this);
+
+ myIsBBCenter = new QCheckBox(tr("USE_BBCENTER"), aCheckBox);
+ myIsBBCenter->setChecked(true);
+ connect(myIsBBCenter, SIGNAL(stateChanged(int)), SLOT(onBBCenterChecked()));
+
+ // Create croup button with radio buttons
+ myGroupSelButton = new QButtonGroup(2,Qt::Vertical,"",this);
+ myGroupSelButton->setMargin(11);
+
+ // Create "Set to Origin" button
+ myToOrigin = new QPushButton(myGroupSelButton);
+ myToOrigin->setText(tr("LBL_TOORIGIN"));
+ connect(myToOrigin, SIGNAL(clicked()), this, SLOT(onToOrigin()));
+
+ // Create "Select Point from View" button
+ mySelectPoint = new QPushButton(myGroupSelButton);
+ mySelectPoint->setText(tr("LBL_SELECTPOINT"));
+ mySelectPoint->setToggleButton(true);
+ connect(mySelectPoint, SIGNAL(clicked()), this, SLOT(onSelectPoint()));
+
+ // Create croup box with grid layout
+ myGroupBoxCoord = new QGroupBox(this, "GroupBox");
+ QHBoxLayout* aHBoxLayout = new QHBoxLayout(myGroupBoxCoord);
+ aHBoxLayout->setMargin(11);
+ aHBoxLayout->setSpacing(6);
+
+ // "X" coordinate
+ QLabel* TextLabelX = new QLabel (tr("LBL_X"), myGroupBoxCoord, "TextLabelX");
+ TextLabelX->setFixedWidth(15);
+ myX = new QLineEdit(myGroupBoxCoord);
+ myX->setValidator(new QDoubleValidator(myX));
+ myX->setText(QString::number(0.0));
+ connect(myX, SIGNAL(textChanged(const QString&)), this, SLOT(onCoordChanged()));
+
+ // "Y" coordinate
+ QLabel* TextLabelY = new QLabel (tr("LBL_Y"), myGroupBoxCoord, "TextLabelY");
+ TextLabelY->setFixedWidth(15);
+ myY = new QLineEdit(myGroupBoxCoord);
+ myY->setValidator(new QDoubleValidator(myY));
+ myY->setText(QString::number(0.0));
+ connect(myY, SIGNAL(textChanged(const QString&)), this, SLOT(onCoordChanged()));
+
+ // "Z" coordinate
+ QLabel* TextLabelZ = new QLabel (tr("LBL_Z"), myGroupBoxCoord, "TextLabelZ");
+ TextLabelZ->setFixedWidth(15);
+ myZ = new QLineEdit(myGroupBoxCoord);
+ myZ->setValidator(new QDoubleValidator(myZ));
+ myZ->setText(QString::number(0.0));
+ connect(myZ, SIGNAL(textChanged(const QString&)), this, SLOT(onCoordChanged()));
+
+ // Layout widgets in the horizontal group box
+ aHBoxLayout->addWidget(TextLabelX);
+ aHBoxLayout->addWidget(myX);
+ aHBoxLayout->addWidget(TextLabelY);
+ aHBoxLayout->addWidget(myY);
+ aHBoxLayout->addWidget(TextLabelZ);
+ aHBoxLayout->addWidget(myZ);
+
+ // "Close" button
+ QGroupBox* aGroupBox = new QGroupBox(this);
+ QHBoxLayout* aHBoxLayout2 = new QHBoxLayout(aGroupBox);
+ aHBoxLayout2->setMargin(11);
+ aHBoxLayout2->setSpacing(6);
+
+ QPushButton* m_bClose = new QPushButton(tr("&Close"), aGroupBox, "m_bClose");
+ m_bClose->setAutoDefault(TRUE);
+ m_bClose->setFixedSize(m_bClose->sizeHint());
+ connect(m_bClose, SIGNAL(clicked()), this, SLOT(onClickClose()));
+
+ // Layout buttons
+ aHBoxLayout2->addWidget(m_bClose);
+
+ // Layout top level widgets
+ layoutDlg->addWidget(aCheckBox,0,0);
+ layoutDlg->addWidget(myGroupSelButton,1,0);
+ layoutDlg->addWidget(myGroupBoxCoord,2,0);
+ layoutDlg->addWidget(aGroupBox,3,0);
+
+ setEnabled(myGroupSelButton,!myIsBBCenter->isChecked());
+ setEnabled(myGroupBoxCoord,!myIsBBCenter->isChecked());
+
+ this->resize(400, this->sizeHint().height());
+
+ connect(view, SIGNAL(Show( QShowEvent * )), this, SLOT(onViewShow()));
+ connect(view, SIGNAL(Hide( QHideEvent * )), this, SLOT(onViewHide()));
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+OCCViewer_SetRotationPointDlg
+::~OCCViewer_SetRotationPointDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+/*!
+ Return true if it is the first show for this dialog
+*/
+bool
+OCCViewer_SetRotationPointDlg
+::IsFirstShown()
+{
+ return myIsBBCenter->isChecked() && myX->text().toDouble() == 0.
+ && myY->text().toDouble() == 0. && myZ->text().toDouble() == 0.;
+}
+
+void
+OCCViewer_SetRotationPointDlg
+::setEnabled(QGroupBox* theGrp, const bool theState)
+{
+ QObjectList aChildren(*theGrp->children());
+ QObject* anObj;
+ for(anObj = aChildren.first(); anObj !=0; anObj = aChildren.next())
+ {
+ if (anObj !=0 && anObj->inherits("QLineEdit"))
+ ((QLineEdit*)anObj)->setReadOnly(!theState);
+ if (anObj !=0 && anObj->inherits("QPushButton"))
+ ((QLineEdit*)anObj)->setEnabled(theState);
+ }
+
+}
+
+void
+OCCViewer_SetRotationPointDlg
+::onBBCenterChecked()
+{
+ setEnabled(myGroupSelButton,!myIsBBCenter->isChecked());
+ setEnabled(myGroupBoxCoord,!myIsBBCenter->isChecked());
+
+ if ( myIsBBCenter->isChecked() )
+ {
+ if ( mySelectPoint->state() == QButton::On )
+ mySelectPoint->toggle();
+ myView->activateSetRotationGravity();
+ }
+ else
+ myView->activateSetRotationSelected(myX->text().toDouble(),
+ myY->text().toDouble(),
+ myZ->text().toDouble());
+}
+
+void
+OCCViewer_SetRotationPointDlg
+::onToOrigin()
+{
+ if ( mySelectPoint->state() == QButton::On )
+ mySelectPoint->toggle();
+ setCoords();
+ myView->activateSetRotationSelected(myX->text().toDouble(),
+ myY->text().toDouble(),
+ myZ->text().toDouble());
+}
+
+void
+OCCViewer_SetRotationPointDlg
+::onSelectPoint()
+{
+ if ( mySelectPoint->state() == QButton::On )
+ myView->activateStartPointSelection();
+ else
+ mySelectPoint->toggle();
+}
+
+void
+OCCViewer_SetRotationPointDlg
+::onCoordChanged()
+{
+ if ( !myIsBBCenter->isChecked() )
+ {
+ if ( mySelectPoint->state() == QButton::On
+ &&
+ ( myX->hasFocus() || myY->hasFocus() || myZ->hasFocus() ) )
+ mySelectPoint->toggle();
+ myView->activateSetRotationSelected(myX->text().toDouble(),
+ myY->text().toDouble(),
+ myZ->text().toDouble());
+ }
+}
+
+void
+OCCViewer_SetRotationPointDlg
+::setCoords(double theX, double theY, double theZ)
+{
+ myX->setText(QString::number(theX));
+ myY->setText(QString::number(theY));
+ myZ->setText(QString::number(theZ));
+}
+
+void
+OCCViewer_SetRotationPointDlg
+::toggleChange()
+{
+ if ( !myIsBBCenter->isChecked() )
+ mySelectPoint->toggle();
+}
+
+void
+OCCViewer_SetRotationPointDlg
+::onClickClose()
+{
+ myAction->setOn( false );
+ reject();
+}
+
+void
+OCCViewer_SetRotationPointDlg
+::onViewShow()
+{
+ if(myAction->isOn())
+ show();
+ else
+ hide();
+}
+
+void
+OCCViewer_SetRotationPointDlg
+::onViewHide()
+{
+ hide();
+}
--- /dev/null
+// Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
+//
+// 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
+//
+#ifndef OCCVIEWER_SETROTATIONPOINTDLG_H
+#define OCCVIEWER_SETROTATIONPOINTDLG_H
+
+#include "OCCViewer.h"
+
+#include <qdialog.h>
+
+class QtxAction;
+
+class QLineEdit;
+class QPushButton;
+class QGroupBox;
+class QButtonGroup;
+class QCheckBox;
+
+class OCCViewer_ViewWindow;
+
+class OCCVIEWER_EXPORT OCCViewer_SetRotationPointDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ OCCViewer_SetRotationPointDlg(OCCViewer_ViewWindow* , QWidget* parent = 0,
+ const char* name = 0, bool modal = FALSE, WFlags fl = 0);
+ ~OCCViewer_SetRotationPointDlg();
+
+ void SetAction( QtxAction* theAction ) { myAction = theAction; }
+ bool IsFirstShown();
+
+ void setCoords(double theX=0., double theY=0., double theZ=0.);
+ void toggleChange();
+
+protected:
+ OCCViewer_ViewWindow* myView;
+ QtxAction* myAction;
+
+ QCheckBox* myIsBBCenter;
+
+ QButtonGroup* myGroupSelButton;
+ QPushButton* myToOrigin;
+ QPushButton* mySelectPoint;
+
+ QGroupBox* myGroupBoxCoord;
+ QLineEdit* myX;
+ QLineEdit* myY;
+ QLineEdit* myZ;
+
+ void setEnabled(QGroupBox* theGrp, const bool theState);
+
+protected slots:
+ void onBBCenterChecked();
+
+ void onToOrigin();
+ void onSelectPoint();
+
+ void onCoordChanged();
+
+ void onClickClose();
+
+ void onViewShow();
+ void onViewHide();
+};
+
+#endif // OCCVIEWER_SETROTATIONPOINTDLG_H
#include "OCCViewer_ViewWindow.h"
#include "SUIT_Desktop.h"
-int OCCViewer_ViewManager::myMaxId = 0;
-
/*!
Constructor
*/
OCCViewer_ViewManager::OCCViewer_ViewManager( SUIT_Study* study, SUIT_Desktop* theDesktop, bool DisplayTrihedron )
-: SUIT_ViewManager( study, theDesktop )
+: SUIT_ViewManager( study, theDesktop, new OCCViewer_Viewer( DisplayTrihedron ) )
{
- myId = ++myMaxId;
- setViewModel( new OCCViewer_Viewer( DisplayTrihedron ) );
+ setTitle( tr( "OCC_VIEW_TITLE" ) );
}
/*!
{
}
-/*!
- Sets view name
- \param theView - view to assign name
-*/
-void OCCViewer_ViewManager::setViewName(SUIT_ViewWindow* theView)
-{
- int aPos = myViews.find(theView);
- theView->setCaption( tr( "OCC_VIEW_TITLE" ).arg( myId ).arg( aPos + 1 ) );
-}
-
/*!
Fills popup menu with custom actions
\param popup - popup menu to be filled with
OCCViewer_Viewer* getOCCViewer() { return (OCCViewer_Viewer*) myViewModel; }
virtual void contextMenuPopup( QPopupMenu* );
-
-protected:
- void setViewName(SUIT_ViewWindow* theView);
-
-protected:
- static int myMaxId;
- int myId;
};
#endif
myEndPnt.setX(theEvent->x()); myEndPnt.setY(theEvent->y());
OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow;
bool aHasShift = (theEvent->state() & Qt::ShiftButton);
+
+ if (!aHasShift) emit deselection();
if (myStartPnt == myEndPnt)
{
return;
QPtrVector<SUIT_ViewWindow> wins = myViewManager->getViews();
- for ( int i = 0; i < wins.count(); i++ )
+ for ( int i = 0; i < (int)wins.count(); i++ )
{
OCCViewer_ViewWindow* win = ::qt_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
if ( win )
return;
QPtrVector<SUIT_ViewWindow> wins = myViewManager->getViews();
- for ( int i = 0; i < wins.count(); i++ )
+ for ( int i = 0; i < (int)wins.count(); i++ )
{
OCCViewer_ViewWindow* win = ::qt_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
if ( win )
{
if (!myV3dViewer.IsNull())
myV3dViewer->Update();
+
+ OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
+ if ( aView )
+ aView->updateGravityCoords();
}
/*!
{
AIS_ListIteratorOfListOfInteractive aIt;
for (aIt.Initialize(theList); aIt.More(); aIt.Next())
- myAISContext->SetSelected(aIt.Value(), false);
+ myAISContext->AddOrRemoveSelected(aIt.Value(), false);
myAISContext->UpdateCurrentViewer();
}
signals:
void selectionChanged();
+ void deselection();
protected:
void initView( OCCViewer_ViewWindow* view );
class OCCViewer_ViewSketcher;
class OCCViewer_ViewTransformer;
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
/*!
\class OCCViewer_ViewPort
Visualisation canvas of SUIT-based application
static int nCounter; /* objects counter */
};
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
#endif
#include "OCCViewer_ViewPort3d.h"
#include "OCCViewer_VService.h"
+#include "OCCViewer_ViewWindow.h"
#include <qrect.h>
#include <qevent.h>
#include <Xw_Window.hxx>
#endif
+static double rx = 0.;
+static double ry = 0.;
+static int sx = 0;
+static int sy = 0;
+static Standard_Boolean zRotation = Standard_False;
+
/*!
Constructor
*/
/*!
Inits 'rotation' transformation. [ protected ]
*/
-void OCCViewer_ViewPort3d::startRotation( int x, int y )
+void OCCViewer_ViewPort3d::startRotation( int x, int y,
+ int theRotationPointType,
+ const gp_Pnt& theSelectedPoint )
{
- if ( !activeView().IsNull() )
- {
- myDegenerated = activeView()->DegenerateModeIsOn();
- activeView()->SetDegenerateModeOn();
- if (myAnimate) activeView()->SetAnimationModeOn();
- activeView()->StartRotation( x, y, 0.45 );
+ if ( !activeView().IsNull() )
+ {
+ myDegenerated = activeView()->DegenerateModeIsOn();
+ activeView()->SetDegenerateModeOn();
+ if (myAnimate) activeView()->SetAnimationModeOn();
+
+ //double gx, gy, gz;
+ //double gx = activeView()->gx;
+ //activeView()->Gravity(gx,gy,gz);
+
+ switch ( theRotationPointType ) {
+ case OCCViewer_ViewWindow::GRAVITY:
+ activeView()->StartRotation( x, y, 0.45 );
+ break;
+ case OCCViewer_ViewWindow::SELECTED:
+ sx = x; sy = y;
+
+ double X,Y;
+ activeView()->Size(X,Y);
+ rx = Standard_Real(activeView()->Convert(X));
+ ry = Standard_Real(activeView()->Convert(Y));
+
+ activeView()->Rotate( 0., 0., 0.,
+ theSelectedPoint.X(),theSelectedPoint.Y(), theSelectedPoint.Z(),
+ Standard_True );
+
+ Quantity_Ratio zRotationThreshold;
+ zRotation = Standard_False;
+ zRotationThreshold = 0.45;
+ if( zRotationThreshold > 0. ) {
+ Standard_Real dx = Abs(sx - rx/2.);
+ Standard_Real dy = Abs(sy - ry/2.);
+ Standard_Real dd = zRotationThreshold * (rx + ry)/2.;
+ if( dx > dd || dy > dd ) zRotation = Standard_True;
}
+ break;
+ default:
+ break;
+ }
+ }
}
/*!
Rotates the viewport. [ protected ]
*/
-void OCCViewer_ViewPort3d::rotate( int x, int y )
+void OCCViewer_ViewPort3d::rotate( int x, int y,
+ int theRotationPointType,
+ const gp_Pnt& theSelectedPoint )
{
- if ( !activeView().IsNull() )
- activeView()->Rotation( x, y );
-// setZSize( getZSize() );
+ if ( !activeView().IsNull() ) {
+ switch ( theRotationPointType ) {
+ case OCCViewer_ViewWindow::GRAVITY:
+ activeView()->Rotation( x, y );
+ break;
+ case OCCViewer_ViewWindow::SELECTED:
+ double dx, dy, dz;
+ if( zRotation ) {
+ dz = atan2(Standard_Real(x)-rx/2., ry/2.-Standard_Real(y)) -
+ atan2(sx-rx/2.,ry/2.-sy);
+ dx = dy = 0.;
+ }
+ else {
+ dx = (Standard_Real(x) - sx) * Standard_PI/rx;
+ dy = (sy - Standard_Real(y)) * Standard_PI/ry;
+ dz = 0.;
+ }
+
+ activeView()->Rotate( dx, dy, dz,
+ theSelectedPoint.X(),theSelectedPoint.Y(), theSelectedPoint.Z(),
+ Standard_False );
+ break;
+ default:
+ break;
+ }
+ }
+ // setZSize( getZSize() );
}
/*!
*/
void OCCViewer_ViewPort3d::endRotation()
{
- if ( !activeView().IsNull() )
- {
- if (myAnimate) activeView()->SetAnimationModeOff();
- if ( !myDegenerated )
- activeView()->SetDegenerateModeOff();
- activeView()->ZFitAll(1.);
- activeView()->SetZSize(0.);
- activeView()->Update();
- }
+ if ( !activeView().IsNull() )
+ {
+ if (myAnimate) activeView()->SetAnimationModeOff();
+ if ( !myDegenerated )
+ activeView()->SetDegenerateModeOff();
+ activeView()->ZFitAll(1.);
+ activeView()->SetZSize(0.);
+ activeView()->Update();
+ }
}
/*!
class QRect;
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
class OCCVIEWER_EXPORT OCCViewer_ViewPort3d: public OCCViewer_ViewPort
{
Q_OBJECT
virtual void zoom( int, int, int, int );
virtual void fitAll( bool keepScale = false, bool withZ = true, bool upd = true );
- void startRotation( int, int );
- void rotate( int, int );
+ void startRotation( int, int, int, const gp_Pnt& );
+ void rotate( int, int, int, const gp_Pnt& );
void endRotation();
protected:
double myScale;
};
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
#endif
#include "OCCViewer_ViewPort3d.h"
#include "OCCViewer_CreateRestoreViewDlg.h"
#include "OCCViewer_ClippingDlg.h"
+#include "OCCViewer_SetRotationPointDlg.h"
#include "SUIT_Desktop.h"
#include "SUIT_Session.h"
#include <gp_Dir.hxx>
#include <gp_Pln.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <AIS_Shape.hxx>
+
+#include <BRep_Tool.hxx>
+#include <TopoDS.hxx>
+
+#include <BRepBndLib.hxx>
+#include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
+#include <Visual3d_View.hxx>
+#include <Graphic3d_MapOfStructure.hxx>
+#include <Graphic3d_Structure.hxx>
+
+
const char* imageZoomCursor[] = {
"32 32 3 1",
". c None",
myEnableDrawMode = false;
updateEnabledDrawMode();
myClippingDlg = 0;
+ mySetRotationPointDlg = 0;
}
/*!
myViewPort = new OCCViewer_ViewPort3d( this, myModel->getViewer3d(), V3d_ORTHOGRAPHIC );
myViewPort->setBackgroundColor(black);
myViewPort->installEventFilter(this);
- setCentralWidget(myViewPort);
+ setCentralWidget(myViewPort);
myOperation = NOTHING;
+ myCurrPointType = GRAVITY;
+ myPrevPointType = GRAVITY;
+ mySelectedPoint = gp_Pnt(0.,0.,0.);
+ myRotationPointSelection = false;
+
setTransformRequested ( NOTHING );
setTransformInProcess ( false );
case ROTATE:
if ( theEvent->button() == Qt::LeftButton ) {
- myViewPort->startRotation(myStartX, myStartY);
+ myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint);
emit vpTransformationStarted ( ROTATE );
}
break;
break;
case ROTATE:
activateRotation();
- myViewPort->startRotation(myStartX, myStartY);
+ myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint);
break;
default:
- emit mousePressed(this, theEvent);
+ if ( myRotationPointSelection )
+ {
+ if ( theEvent->button() == Qt::LeftButton )
+ {
+ Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
+ ic->Select();
+ for ( ic->InitSelected(); ic->MoreSelected(); ic->NextSelected() )
+ {
+ TopoDS_Shape aShape = ic->SelectedShape();
+ if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
+ {
+ gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( ic->SelectedShape() ) );
+ if ( mySetRotationPointDlg )
+ {
+ myRotationPointSelection = false;
+ mySetRotationPointDlg->setCoords(aPnt.X(), aPnt.Y(), aPnt.Z());
+ }
+ }
+ else
+ {
+ myCurrPointType = myPrevPointType;
+ break;
+ }
+ }
+ if ( ic->NbSelected() == 0 ) myCurrPointType = myPrevPointType;
+ if ( mySetRotationPointDlg ) mySetRotationPointDlg->toggleChange();
+ ic->CloseAllContexts();
+ myOperation = NOTHING;
+ setCursor( myCursor );
+ myCursorIsHand = false;
+ myRotationPointSelection = false;
+ }
+ }
+ else
+ emit mousePressed(this, theEvent);
break;
}
/* notify that we start a transformation */
}
}
+/*!
+ Compute the gravity center
+*/
+bool OCCViewer_ViewWindow::computeGravityCenter( double& theX, double& theY, double& theZ )
+{
+ Handle(Visual3d_View) aView = myViewPort->getView()->View();
+
+ Standard_Real Xmin,Ymin,Zmin,Xmax,Ymax,Zmax,U,V,W ;
+ Standard_Real Umin,Vmin,Umax,Vmax ;
+ Standard_Integer Nstruct,Npoint ;
+ Graphic3d_MapOfStructure MySetOfStructures;
+
+ aView->DisplayedStructures (MySetOfStructures);
+ Nstruct = MySetOfStructures.Extent() ;
+
+ Graphic3d_MapIteratorOfMapOfStructure MyIterator(MySetOfStructures) ;
+ aView->ViewMapping().WindowLimit(Umin,Vmin,Umax,Vmax) ;
+ Npoint = 0 ; theX = theY = theZ = 0. ;
+ for( ; MyIterator.More(); MyIterator.Next()) {
+ if (!(MyIterator.Key())->IsEmpty()) {
+ (MyIterator.Key())->MinMaxValues(Xmin,Ymin,Zmin,
+ Xmax,Ymax,Zmax) ;
+
+ Standard_Real LIM = ShortRealLast() -1.;
+ if (! (fabs(Xmin) > LIM || fabs(Ymin) > LIM || fabs(Zmin) > LIM
+ || fabs(Xmax) > LIM || fabs(Ymax) > LIM || fabs(Zmax) > LIM )) {
+
+ aView->Projects(Xmin,Ymin,Zmin,U,V,W) ;
+ if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
+ Npoint++ ; theX += Xmin ; theY += Ymin ; theZ += Zmin ;
+ }
+ aView->Projects(Xmax,Ymin,Zmin,U,V,W) ;
+ if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
+ Npoint++ ; theX += Xmax ; theY += Ymin ; theZ += Zmin ;
+ }
+ aView->Projects(Xmin,Ymax,Zmin,U,V,W) ;
+ if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
+ Npoint++ ; theX += Xmin ; theY += Ymax ; theZ += Zmin ;
+ }
+ aView->Projects(Xmax,Ymax,Zmin,U,V,W) ;
+ if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
+ Npoint++ ; theX += Xmax ; theY += Ymax ; theZ += Zmin ;
+ }
+ aView->Projects(Xmin,Ymin,Zmax,U,V,W) ;
+ if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
+ Npoint++ ; theX += Xmin ; theY += Ymin ; theZ += Zmax ;
+ }
+ aView->Projects(Xmax,Ymin,Zmax,U,V,W) ;
+ if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
+ Npoint++ ; theX += Xmax ; theY += Ymin ; theZ += Zmax ;
+ }
+ aView->Projects(Xmin,Ymax,Zmax,U,V,W) ;
+ if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
+ Npoint++ ; theX += Xmin ; theY += Ymax ; theZ += Zmax ;
+ }
+ aView->Projects(Xmax,Ymax,Zmax,U,V,W) ;
+ if( U >= Umin && U <= Umax && V >= Vmin && V <= Vmax ) {
+ Npoint++ ; theX += Xmax ; theY += Ymax ; theZ += Zmax ;
+ }
+ }
+ }
+ }
+ if( Npoint > 0 ) {
+ theX /= Npoint ; theY /= Npoint ; theZ /= Npoint ;
+ }
+ return true;
+}
+
+/*!
+ Set the gravity center as a rotation point
+*/
+void OCCViewer_ViewWindow::activateSetRotationGravity()
+{
+ if ( myRotationPointSelection )
+ {
+ Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
+ ic->CloseAllContexts();
+ myOperation = NOTHING;
+ setCursor( myCursor );
+ myCursorIsHand = false;
+ myRotationPointSelection = false;
+ }
+
+ myPrevPointType = myCurrPointType;
+ myCurrPointType = GRAVITY;
+
+ Standard_Real Xcenter, Ycenter, Zcenter;
+ if ( computeGravityCenter( Xcenter, Ycenter, Zcenter ) )
+ mySetRotationPointDlg->setCoords( Xcenter, Ycenter, Zcenter );
+}
+
+/*!
+ Update gravity center in the SetRotationPointDlg
+*/
+void OCCViewer_ViewWindow::updateGravityCoords()
+{
+ if ( mySetRotationPointDlg && mySetRotationPointDlg->isShown() && myCurrPointType == GRAVITY )
+ {
+ Standard_Real Xcenter, Ycenter, Zcenter;
+ if ( computeGravityCenter( Xcenter, Ycenter, Zcenter ) )
+ mySetRotationPointDlg->setCoords( Xcenter, Ycenter, Zcenter );
+ }
+}
+
+/*!
+ Set the point selected by user as a rotation point
+*/
+void OCCViewer_ViewWindow::activateSetRotationSelected(double theX, double theY, double theZ)
+{
+ if ( myRotationPointSelection )
+ {
+ Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
+ ic->CloseAllContexts();
+ myOperation = NOTHING;
+ setCursor( myCursor );
+ myCursorIsHand = false;
+ myRotationPointSelection = false;
+ }
+
+ myPrevPointType = myCurrPointType;
+ myCurrPointType = SELECTED;
+ mySelectedPoint.SetCoord(theX,theY,theZ);
+}
+
+/*!
+ Start the point selection process
+*/
+void OCCViewer_ViewWindow::activateStartPointSelection()
+{
+ myPrevPointType = myCurrPointType;
+ myCurrPointType = SELECTED;
+
+ // activate selection ------>
+ Handle(AIS_InteractiveContext) ic = myModel->getAISContext();
+
+ ic->OpenLocalContext();
+
+ AIS_ListOfInteractive aList;
+ ic->DisplayedObjects( aList );
+ for ( AIS_ListIteratorOfListOfInteractive it( aList ); it.More(); it.Next() )
+ {
+ Handle(AIS_InteractiveObject) anObj = it.Value();
+ if ( !anObj.IsNull() && anObj->HasPresentation() &&
+ anObj->IsKind( STANDARD_TYPE(AIS_Shape) ) )
+ {
+ ic->Load(anObj,-1);
+ ic->Activate(anObj,AIS_Shape::SelectionMode(TopAbs_VERTEX));
+ }
+ }
+ // activate selection <------
+
+ if ( !myCursorIsHand )
+ {
+ QCursor handCursor (Qt::PointingHandCursor);
+ myCursorIsHand = true;
+ myCursor = cursor();
+ setCursor( handCursor );
+ }
+ myRotationPointSelection = true;
+}
+
/*!
Starts global panning operation, sets corresponding cursor
*/
void OCCViewer_ViewWindow::setTransformRequested ( OperationType op )
{
myOperation = op;
- myViewPort->setMouseTracking( myOperation == NOTHING );
+ myViewPort->setMouseTracking( myOperation == NOTHING );
}
myCurrY = theEvent->y();
switch (myOperation) {
case ROTATE:
- myViewPort->rotate(myCurrX, myCurrY);
+ myViewPort->rotate(myCurrX, myCurrY, myCurrPointType, mySelectedPoint);
break;
case ZOOMVIEW:
break;
default:
- int aState = theEvent->state();
- //int aButton = theEvent->button();
- if ( aState == Qt::LeftButton ||
- aState == ( Qt::LeftButton | Qt::ShiftButton) ) {
- myDrawRect = myEnableDrawMode;
- if ( myDrawRect ) {
- drawRect();
- if ( !myCursorIsHand ) { // we are going to sketch a rectangle
- QCursor handCursor (Qt::PointingHandCursor);
- myCursorIsHand = true;
- myCursor = cursor();
- setCursor( handCursor );
- }
- }
- }
- else {
+ if ( myRotationPointSelection )
emit mouseMoving( this, theEvent );
- }
+ else
+ {
+ int aState = theEvent->state();
+ //int aButton = theEvent->button();
+ if ( aState == Qt::LeftButton ||
+ aState == ( Qt::LeftButton | Qt::ShiftButton) ) {
+ myDrawRect = myEnableDrawMode;
+ if ( myDrawRect ) {
+ drawRect();
+ if ( !myCursorIsHand ) { // we are going to sketch a rectangle
+ QCursor handCursor (Qt::PointingHandCursor);
+ myCursorIsHand = true;
+ myCursor = cursor();
+ setCursor( handCursor );
+ }
+ }
+ }
+ else {
+ emit mouseMoving( this, theEvent );
+ }
+ }
}
}
myRect.setLeft(2);
myRect.setRight(0);
- if ( transformRequested() || myCursorIsHand )
- setCursor( myCursor );
- myCursorIsHand = false;
+ if ( myRotationPointSelection )
+ {
+ QCursor handCursor (Qt::PointingHandCursor);
+ setCursor( handCursor );
+ }
+ else
+ {
+ if ( transformRequested() || myCursorIsHand )
+ setCursor( myCursor );
+ myCursorIsHand = false;
+ }
if ( transformRequested() )
emit vpTransformationFinished (myOperation);
tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
connect(aAction, SIGNAL(activated()), this, SLOT(activateGlobalPanning()));
- myActionsMap[ GlobalPanId ] = aAction;
+ myActionsMap[ GlobalPanId ] = aAction;
+
+ // Rotation Point
+ mySetRotationPointAction = new QtxAction(tr("MNU_CHANGINGROTATIONPOINT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ROTATION_POINT" ) ),
+ tr( "MNU_CHANGINGROTATIONPOINT_VIEW" ), 0, this);
+ mySetRotationPointAction->setStatusTip(tr("DSC_CHANGINGROTATIONPOINT_VIEW"));
+ mySetRotationPointAction->setToggleAction( true );
+ connect(mySetRotationPointAction, SIGNAL(toggled( bool )), this, SLOT(onSetRotationPoint( bool )));
+ myActionsMap[ ChangeRotationPointId ] = mySetRotationPointAction;
// Rotation
aAction = new QtxAction(tr("MNU_ROTATE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ROTATE" ) ),
myClippingAction->setStatusTip(tr("DSC_CLIPPING"));
myClippingAction->setToggleAction( true );
connect(myClippingAction, SIGNAL(toggled( bool )), this, SLOT(onClipping( bool )));
- myActionsMap[ ClippingId ] = myClippingAction;
+ myActionsMap[ ClippingId ] = myClippingAction;
aAction = new QtxAction(tr("MNU_SHOOT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SHOOT_VIEW" ) ),
tr( "MNU_SHOOT_VIEW" ), 0, this);
aPanningBtn->AddAction(myActionsMap[PanId]);
aPanningBtn->AddAction(myActionsMap[GlobalPanId]);
+ myActionsMap[ChangeRotationPointId]->addTo(myToolBar);
+
myActionsMap[RotationId]->addTo(myToolBar);
SUIT_ToolButton* aViewsBtn = new SUIT_ToolButton(myToolBar, "projection");
myViewPort->fitAll();
}
+/*!
+ SLOT: called if change rotation point operation is activated
+*/
+void OCCViewer_ViewWindow::onSetRotationPoint( bool on )
+{
+ if ( on )
+ {
+ if ( !mySetRotationPointDlg )
+ {
+ mySetRotationPointDlg = new OCCViewer_SetRotationPointDlg( this, myDesktop );
+ mySetRotationPointDlg->SetAction( mySetRotationPointAction );
+ }
+
+ if ( !mySetRotationPointDlg->isShown() )
+ {
+ if ( mySetRotationPointDlg->IsFirstShown() )
+ {
+ Standard_Real Xcenter, Ycenter, Zcenter;
+ if ( computeGravityCenter( Xcenter, Ycenter, Zcenter ) )
+ mySetRotationPointDlg->setCoords( Xcenter, Ycenter, Zcenter );
+ }
+ mySetRotationPointDlg->show();
+ }
+ }
+ else
+ {
+ if ( mySetRotationPointDlg->isShown() )
+ mySetRotationPointDlg->hide();
+ }
+}
+
/*!
Creates one more window with same content
*/
performRestoring( params );
}
}
+
+/*!
+ Custom show event handler
+*/
+void OCCViewer_ViewWindow::showEvent( QShowEvent * theEvent )
+{
+ emit Show( theEvent );
+}
+
+/*!
+ Custom hide event handler
+*/
+void OCCViewer_ViewWindow::hideEvent( QHideEvent * theEvent )
+{
+ emit Hide( theEvent );
+}
+
class OCCViewer_ViewPort3d;
class OCCViewer_ClippingDlg;
+class OCCViewer_SetRotationPointDlg;
#ifdef WIN32
#pragma warning( disable:4251 )
Q_OBJECT
public:
- enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE, PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW,
+ enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE,
+ PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW,
FRONTVIEW, BACKVIEW, TOPVIEW, BOTTOMVIEW, LEFTVIEW, RIGHTVIEW };
+ enum RotationPointType{ GRAVITY, SELECTED };
+
OCCViewer_ViewWindow(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel);
virtual ~OCCViewer_ViewWindow() {};
void activateRotation();
void activatePanning();
void activateGlobalPanning();
+ void onSetRotationPoint( bool on );
void onCloneView();
void onClipping( bool on );
void onMemorizeView();
void onRestoreView();
void onTrihedronShow();
void setRestoreFlag();
-
+
+ void activateSetRotationGravity();
+ void activateSetRotationSelected( double theX, double theY, double theZ );
+ void activateStartPointSelection();
+ void updateGravityCoords();
+
+ virtual void showEvent( QShowEvent * );
+ virtual void hideEvent( QHideEvent * );
+
signals:
void vpTransformationStarted(OCCViewer_ViewWindow::OperationType type);
void vpTransformationFinished(OCCViewer_ViewWindow::OperationType type);
void cloneView();
+ void Show( QShowEvent * );
+ void Hide( QHideEvent * );
+
protected:
- enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId,
+ enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId,
+ ChangeRotationPointId, RotationId,
FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, CloneId, ClippingId, MemId, RestoreId,
TrihedronShowId };
viewAspect getViewParams() const;
+ bool computeGravityCenter( double& theX, double& theY, double& theZ );
+
OperationType myOperation;
OCCViewer_Viewer* myModel;
OCCViewer_ViewPort3d* myViewPort;
+ RotationPointType myCurrPointType;
+ RotationPointType myPrevPointType;
+ gp_Pnt mySelectedPoint;
+ bool myRotationPointSelection;
+
int myRestoreFlag;
int myStartX;
private:
OCCViewer_ClippingDlg* myClippingDlg;
QtxAction* myClippingAction;
+
+ OCCViewer_SetRotationPointDlg* mySetRotationPointDlg;
+ QtxAction* mySetRotationPointAction;
};
msgid "ICON_OCCVIEWER_VIEW_RIGHT"
msgstr "view_right.png"
+msgid "ICON_OCCVIEWER_VIEW_ROTATION_POINT"
+msgstr "view_rotation_point.png"
+
msgid "ICON_OCCVIEWER_VIEW_ROTATE"
msgstr "view_rotate.png"
msgid "MNU_GLOBALPAN_VIEW"
msgstr "Global Panning"
+msgid "DSC_CHANGINGROTATIONPOINT_VIEW"
+msgstr "Change the point, around which the rotation is performed"
+
msgid "DSC_ROTATE_VIEW"
msgstr "Rotation of the point of view around the scene center"
+msgid "OCCViewer_SetRotationPointDlg::CAPTION"
+msgstr "Set Rotation Point"
+
+msgid "OCCViewer_SetRotationPointDlg::USE_BBCENTER"
+msgstr "Use Bounding Box Center"
+
+msgid "OCCViewer_SetRotationPointDlg::LBL_TOORIGIN"
+msgstr "Set to Origin"
+
+msgid "OCCViewer_SetRotationPointDlg::LBL_SELECTPOINT"
+msgstr "Select Point from View"
+
+msgid "OCCViewer_SetRotationPointDlg::LBL_X"
+msgstr "X :"
+
+msgid "OCCViewer_SetRotationPointDlg::LBL_Y"
+msgstr "Y :"
+
+msgid "OCCViewer_SetRotationPointDlg::LBL_Z"
+msgstr "Z :"
+
+msgid "MNU_CHANGINGROTATIONPOINT_VIEW"
+msgstr "Change Rotation Point"
+
+msgid "MNU_ROTATIONPOINTGRAVITY_VIEW"
+msgstr "Rotation Point : the gravity center"
+
+msgid "MNU_ROTATIONPOINT000_VIEW"
+msgstr "Rotation Point : (0,0,0)"
+
+msgid "MNU_ROTATIONPOINTSELECTED_VIEW"
+msgstr "Rotation Point : the point selected by the user"
+
msgid "MNU_ROTATE_VIEW"
msgstr "Rotation"
msgstr "Change background..."
msgid "OCCViewer_ViewManager::OCC_VIEW_TITLE"
-msgstr "OCC scene:%1 - viewer:%2"
+msgstr "OCC scene:%M - viewer:%V"
msgid "OCCViewer_CreateRestoreViewDlg::CAPTION"
ObjPtr nullSrc() const;
ItemPtr nullTrg() const;
ItemPtr createItem( const ObjPtr&, const ItemPtr&, const ItemPtr&, const bool ) const;
- void updateItem( const ItemPtr& ) const;
+ void updateItem( const ObjPtr& , const ItemPtr& ) const;
void deleteItemWithChildren( const ItemPtr& ) const;
void children( const ObjPtr&, QValueList<ObjPtr>& ) const;
void children( const ItemPtr&, QValueList<ItemPtr>& ) const;
Updates item
\param p - item
*/
-void OB_BrowserSync::updateItem( const ItemPtr& p ) const
+void OB_BrowserSync::updateItem( const ObjPtr& o, const ItemPtr& p ) const
{
if ( p && needUpdate( p ) ) {
// printf( "--- needUpdate for %s = true ---\n", p->text( 0 ).latin1() );
myBrowser->updateText( p );
p->update();
}
+ if( o && myBrowser->getUpdater() )
+ {
+ myBrowser->getUpdater()->update( o, p );
+ }
}
/*!
myRoot( 0 ),
myTooltip( 0 ),
+myUpdater( 0 ),
myAutoOpenLevel( 0 ),
myAutoUpdate( false ),
myAutoDelObjs( false ),
{
myItems.clear();
delete myTooltip;
+ setUpdater( 0 );
}
/*!
return;
myAutoOpenLevel = level;
+}
- autoOpenBranches();
+/*!
+ Opens branches from 1 to \alevels. If parameter value negative then autoOpenLevel() value will be used.
+ \sa autoOpenLevel()
+*/
+void OB_Browser::openLevels( const int levels )
+{
+ int level = levels < 0 ? autoOpenLevel() : levels;
+ QListView* lv = listView();
+ if ( !lv || level < 1 )
+ return;
+
+ QListViewItem* item = lv->firstChild();
+ while ( item )
+ {
+ openBranch( item, level );
+ item = item->nextSibling();
+ }
}
/*!
myAutoDelObjs = on;
}
+/*!
+ \return updater of browser
+*/
+OB_Updater* OB_Browser::getUpdater() const
+{
+ return myUpdater;
+}
+
+/*!
+ \sets new updater of browser
+*/
+void OB_Browser::setUpdater( OB_Updater* theUpdate )
+{
+ if( myUpdater )
+ delete myUpdater;
+ myUpdater = theUpdate;
+}
+
/*!
\return root SUIT object of browser
*/
restoreState( selObjs, openObjs, curObj, selKeys, openKeys, curKey );
- if( autoOpen )
+ if ( autoOpen )
autoOpenBranches();
setModified();
restoreState( selObjs, openObjs, curObj, selKeys, openKeys, curKey );
- autoOpenBranches();
-
setModified();
if ( selNum != numberOfSelected() )
*/
void OB_Browser::autoOpenBranches()
{
- int level = autoOpenLevel();
- QListView* lv = listView();
- if ( !lv || level < 1 )
- return;
-
- QListViewItem* item = lv->firstChild();
- while ( item )
- {
- openBranch( item, level );
- item = item->nextSibling();
- }
+ openLevels();
}
/*!
class OB_ListView;
class OB_ListItem;
+class OB_Updater
+{
+public:
+ OB_Updater(){};
+ virtual ~OB_Updater(){};
+ virtual void update( SUIT_DataObject* theObj, OB_ListItem* theLI ) = 0;
+};
+
/*!
\class OB_Browser
Represents object browser. Allows to get/set selection,
bool isAutoDeleteObjects() const;
virtual void setAutoDeleteObjects( const bool );
- virtual void updateTree( SUIT_DataObject* = 0, const bool autoOpen = true );
+ virtual void updateTree( SUIT_DataObject* = 0, const bool = false );
virtual void replaceTree( SUIT_DataObject*, SUIT_DataObject* );
bool isShowToolTips();
int autoOpenLevel() const;
void setAutoOpenLevel( const int );
+ void openLevels( const int = -1 );
virtual int addColumn( const QString&, const int id = -1, const int width = -1 );
virtual int addColumn( const QIconSet&, const QString&, const int id = -1, const int width = -1 );
void setModified();
unsigned long getModifiedTime() { return myModifiedTime; }
+
+ OB_Updater* getUpdater() const;
+ virtual void setUpdater( OB_Updater* theUpdate = 0 );
signals:
void selectionChanged();
SUIT_DataObject* myRoot;
ItemMap myItems;
QToolTip* myTooltip;
+ OB_Updater* myUpdater;
QMap<int, int> myColumnIds;
bool myAutoUpdate;
bool myAutoDelObjs;
#include <iostream>
using namespace std;
+#ifdef WNT
+#define min(a, b) (((a) < (b)) ? (a) : (b))
+#endif
+
/*!
Constructor
*/
else
myT->setPixmap( 0, p );
}
+ else if ( p.isNull() )
+ myT->setPixmap( 0, p );
myT->setDragEnabled( obj->isDragable() );
myT->setDropEnabled( true );
void OB_ListView::setColumnWidth( int col, int width )
{
int max = columnMaxWidth( col );
- if( max>0 && width>max )
+ if ( max>0 && width>max )
width = max;
- QListView::setColumnWidth( col, width );
+
+ QtxListView::setColumnWidth( col, width );
}
/*!
#ifndef Plot2d_SetupCurveDlg_H
#define Plot2d_SetupCurveDlg_H
+#include "Plot2d.h"
+
#include <qdialog.h>
/*!
class QSpinBox;
class QToolButton;
-class Plot2d_SetupCurveDlg : public QDialog
+class PLOT2D_EXPORT Plot2d_SetupCurveDlg : public QDialog
{
Q_OBJECT
#include <qmap.h>
#include <qpainter.h>
#include <qpaintdevicemetrics.h>
+#include <qevent.h>
#include <qwt_math.h>
#include <qwt_plot_canvas.h>
#define DEFAULT_MARKER_SIZE 9 // default marker size
#define MIN_RECT_SIZE 11 // min sensibility area size
+#define FITALL_EVENT ( QEvent::User + 9999 )
+
const char* imageZoomCursor[] = {
"32 32 3 1",
". c None",
*/
void Plot2d_ViewFrame::fitAll()
{
+ // Postpone fitAll operation until QwtPlot geometry
+ // has been fully defined
+ if ( !myPlot->polished() ){
+ QApplication::postEvent( this, new QCustomEvent( FITALL_EVENT ) );
+ return;
+ }
+
QwtDiMap xMap1 = myPlot->canvasMap( QwtPlot::xBottom );
myPlot->setAxisAutoScale( QwtPlot::yLeft );
Constructor
*/
Plot2d_Plot2d::Plot2d_Plot2d( QWidget* parent )
- : QwtPlot( parent )
+ : QwtPlot( parent ),
+ myIsPolished( false )
{
// outline
enableOutline( true );
return false;
}
+/*!
+ Sets the flag saying that QwtPlot geometry has been fully defined.
+*/
+void Plot2d_Plot2d::polish()
+{
+ QwtPlot::polish();
+ myIsPolished = true;
+}
+
+
/*!
Creates presentation of object
Default implementation is empty
{
this->incrementalZoom( -INCREMENT_FOR_OP, -INCREMENT_FOR_OP );
}
+
+/*!
+ Schedules a FitAll operation by putting it to the application's
+ event queue. This ensures that other important events (show, resize, etc.)
+ are processed first.
+*/
+void Plot2d_ViewFrame::customEvent( QCustomEvent* ce )
+{
+ if ( ce->type() == FITALL_EVENT )
+ fitAll();
+}
class Plot2d_Plot2d;
class Plot2d_Prs;
+class QCustomEvent;
typedef QIntDict<Plot2d_Curve> CurveDict;
void onZoomIn();
void onZoomOut();
+protected:
+ virtual void customEvent( QCustomEvent* );
+
protected slots:
void plotMousePressed( const QMouseEvent& );
void plotMouseMoved( const QMouseEvent& );
class Plot2d_Plot2d : public QwtPlot
{
+ Q_OBJECT
public:
Plot2d_Plot2d( QWidget* parent );
virtual QSizePolicy sizePolicy() const;
virtual QSize minimumSizeHint() const;
+ bool polished() const { return myIsPolished; }
+
+public slots:
+ virtual void polish();
+
protected:
bool existMarker( const QwtSymbol::Style typeMarker, const QColor& color, const Qt::PenStyle typeLine );
protected:
QValueList<QColor> myColors;
+ bool myIsPolished;
};
#endif
#include "Plot2d_ViewModel.h"
#include "Plot2d_ViewWindow.h"
-int Plot2d_ViewManager::myMaxId = 0;
-
/*!
Constructor
*/
Plot2d_ViewManager::Plot2d_ViewManager( SUIT_Study* study, SUIT_Desktop* desk )
-: SUIT_ViewManager( study, desk )
+: SUIT_ViewManager( study, desk, new Plot2d_Viewer() )
{
- myId = ++myMaxId;
- Plot2d_Viewer* v = new Plot2d_Viewer();
- setViewModel( v );
+ setTitle( tr( "PLOT2D_VIEW_TITLE" ) );
}
/*!
return (Plot2d_Viewer*)myViewModel;
}
-/*!
- Sets default name of view
- \param the View - view to be renamed
-*/
-void Plot2d_ViewManager::setViewName( SUIT_ViewWindow* theView )
-{
- int aPos = myViews.find(theView);
- theView->setCaption( QString( "Plot2d scene:%1 - viewer:%2" ).arg(myId).arg(aPos+1));
-}
-
/*!
Adds new view
\param theView - view to be added
Plot2d_Viewer* getPlot2dModel() const;
protected:
- void setViewName(SUIT_ViewWindow* theView);
bool insertView(SUIT_ViewWindow* theView);
public slots:
signals:
void cloneView( Plot2d_ViewFrame*, Plot2d_ViewFrame* );
-
-protected:
- static int myMaxId;
- int myId;
};
#endif
msgid "POSTSCRIPT_FILES"
msgstr "PostScript files (*.ps)"
+
+msgid "Plot2d_ViewManager::PLOT2D_VIEW_TITLE"
+msgstr "Plot2d scene:%M - viewer:%V"
#endif // WNT
// ========================================================
-// little trick - we do not have debug python libraries
+// little trick - if we do not have debug python libraries
#ifdef _DEBUG
-
-#undef _DEBUG
-#include <Python.h>
-#define _DEBUG
-
-#else // _DEBUG
+ #ifndef HAVE_DEBUG_PYTHON
+ #undef _DEBUG
+ #endif
+#endif
#include <Python.h>
-#endif // _DEBUG
+#ifdef _DEBUG
+ #ifndef HAVE_DEBUG_PYTHON
+ #define _DEBUG
+ #endif
+#endif
// ========================================================
// avoid warning messages
#endif // WNT
// ========================================================
-// little trick - we do not have debug python libraries
+// little trick - if we do not have debug python libraries
#ifdef _DEBUG
-
+#ifndef HAVE_DEBUG_PYTHON
#undef _DEBUG
-#include <Python.h>
-#define _DEBUG
-
-#else // _DEBUG
+#endif
+#endif
-#include <Python.h>
+//#include <Python.h>
-#endif // _DEBUG
+#ifdef _DEBUG
+#ifndef HAVE_DEBUG_PYTHON
+#define _DEBUG
+#endif
+#endif
// ========================================================
// avoid warning messages
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
+#include <Python.h>
#include "PythonConsole_PyConsole.h"
#include "PythonConsole_PyEditor.h"
#include "PyInterp_base.h"
myEditor->exec( command );
}
+/*!
+ Blocks execution of main application until command is executed
+ \param command - string with command and arguments
+*/
+void PythonConsole::execAndWait( const QString& command )
+{
+ if ( myEditor )
+ myEditor->execAndWait( command );
+}
+
/*!
Changes font of python console
\param f - new font
virtual void setFont( const QFont& );
void exec( const QString& command );
-
+ void execAndWait( const QString& command );
protected:
PyInterp_base* myInterp;
PythonConsole_PyEditor* myEditor;
static QString READY_PROMPT = ">>> ";
static QString DOTS_PROMPT = "... ";
-#define PROMPT_SIZE _currentPrompt.length()
+
+#define PROMPT_SIZE (int)_currentPrompt.length()
class ExecCommand : public PyInterp_LockRequest
{
*/
PythonConsole_PyEditor::PythonConsole_PyEditor(PyInterp_base* theInterp, QWidget *theParent, const char* theName):
QTextEdit(theParent,theName),
- myInterp( 0 )
+ myInterp( 0 ),
+ myIsInLoop( false )
{
QString fntSet( "" );
QFont aFont = SUIT_Tools::stringToFont( fntSet );
void PythonConsole_PyEditor::exec( const QString& command )
{
// Some interactive command is being executed in this editor -> do nothing
- if ( isReadOnly() )
+ if ( isReadOnly() ) {
+ myQueue.push_back( command );
return;
+ }
int para=paragraphs()-1;
removeParagraph( para );
_currentPrompt = READY_PROMPT;
handleReturn();
}
+void PythonConsole_PyEditor::execAndWait( const QString& command )
+{
+ if( myIsInLoop )
+ return;
+
+ myIsInLoop = true;
+ exec( command );
+ qApp->enter_loop();
+ myIsInLoop = false;
+}
+
/*!
Called when an handleReturn
*/
if ( ctrlPressed && !hasSelectedText() ) {
QString txt = text( curLine );
int ind = curCol;
- while ( ind < txt.length()-1 && txt[ ind ] == ' ' ) ind++;
+ while ( ind < (int)( txt.length() - 1 ) && txt[ind] == ' ' ) ind++;
ind = txt.find( ' ', ind );
- while ( ind < txt.length()-1 && txt[ ind ] == ' ' ) ind++;
+ while ( ind < (int)( txt.length() - 1 ) && txt[ ind ] == ' ' ) ind++;
if ( ind > PROMPT_SIZE-1 ) {
setSelection( curLine, curCol, curLine, ind );
removeSelectedText();
_currentPrompt = READY_PROMPT;
setText(_currentPrompt);
viewport()->unsetCursor();
+ if( myIsInLoop )
+ qApp->exit_loop();
break;
}
case PyInterp_Event::INCOMPLETE:
_currentPrompt = DOTS_PROMPT;
setText(_currentPrompt);
viewport()->unsetCursor();
+ if( myIsInLoop )
+ qApp->exit_loop();
break;
}
default:
setReadOnly( false );
_isInHistory = false;
+
+ if ( e->type() == PyInterp_Event::OK && myQueue.count() > 0 ) {
+ QString nextcmd = myQueue[0];
+ myQueue.pop_front();
+ exec( nextcmd );
+ }
}
/*!
_isInHistory = false;
setText(_currentPrompt);
viewport()->unsetCursor();
+ if( myIsInLoop )
+ qApp->exit_loop();
}
else {
clear();
QPopupMenu* popup = QTextEdit::createPopupMenu( pos );
QValueList<int> ids;
- for ( int i = 0; popup && i < popup->count(); i++ )
+ for ( int i = 0; popup && i < (int)popup->count(); i++ )
{
if ( !popup->isItemEnabled( popup->idAt( i ) ) )
ids.append( popup->idAt( i ) );
bool isCommand(const QString& str) const;
virtual void exec( const QString& command );
+ void execAndWait( const QString& command );
protected:
virtual void contentsDropEvent( QDropEvent* event );
QString _buf;
QString _currentCommand;
QString _currentPrompt;
- bool _isInHistory;
+ bool _isInHistory, myIsInLoop;
PyInterp_base* myInterp;
- QString myBanner;
- QString myOutput;
- QString myError;
+ QString myBanner;
+ QString myOutput;
+ QString myError;
+ QStringList myQueue;
};
#endif
* It is the caller responsability to release the lock if needed
*/
PyEval_AcquireLock();
- _tstate = Py_NewInterpreter(); // create an interpreter and save current state
- PySys_SetArgv(PyInterp_base::_argc,PyInterp_base::_argv); // initialize sys.argv
-// if(MYDEBUG) MESSAGE("PythonConsole_PyInterp::initState - this = "<<this<<"; _tstate = "<<_tstate);
+#ifdef WNT
+ _tstate = PyGILState_GetThisThreadState();
+ // if no thread state defined
+ if ( _tstate )
+ PyThreadState_Swap(_tstate);
+ else
+#endif
+ {
+ _tstate = Py_NewInterpreter(); // create an interpreter and save current state
+ PySys_SetArgv(PyInterp_base::_argc,PyInterp_base::_argv); // initialize sys.argv
+ //if(MYDEBUG) MESSAGE("PythonConsole_PyInterp::initState - this = "<<this<<"; _tstate = "<<_tstate);
+ }
/*
* If builtinmodule has been initialized all the sub interpreters
* will have the same __builtin__ module
*/
- if(builtinmodule){
+
+ if(builtinmodule)
+ {
PyObject *m = PyImport_GetModuleDict();
PyDict_SetItemString(m, "__builtin__", builtinmodule);
// SCRUTE(builtinmodule->ob_refcnt); // builtinmodule reference counter
_tstate->interp->builtins = PyModule_GetDict(builtinmodule);
Py_INCREF(_tstate->interp->builtins);
- }
+ }
PyEval_ReleaseThread(_tstate);
return true;
}
QValueList<QDS_Datum*> QDS::_datumList;
+/*!
+ Convert the OpenCascade ascii string to Qt string.
+*/
QString QDS::toQString( const TCollection_AsciiString& src )
{
QTextCodec* codec = QTextCodec::codecForLocale();
return res;
}
+/*!
+ Convert the OpenCascade unicode string to Qt string.
+*/
QString QDS::toQString( const TCollection_ExtendedString& src )
{
if ( src.IsAscii() )
return QString( (QChar*)src.ToExtString(), src.Length() );
}
+/*!
+ Convert the OpenCascade ascii string to Qt string.
+*/
QString QDS::toQString( const Handle(TCollection_HAsciiString)& src )
{
if ( src.IsNull() )
return toQString( src->String() );
}
+/*!
+ Convert the OpenCascade unicode string to Qt string.
+*/
QString QDS::toQString( const Handle(TCollection_HExtendedString)& src )
{
if ( src.IsNull() )
return toQString( src->String() );
}
+/*!
+ Convert the Qt string to OpenCascade ascii string.
+*/
TCollection_AsciiString QDS::toAsciiString( const QString& src )
{
TCollection_AsciiString res;
return res;
}
+/*!
+ Convert the OpenCascade unicode string to OpenCascade ascii string.
+*/
TCollection_AsciiString QDS::toAsciiString( const TCollection_ExtendedString& src )
{
return TCollection_AsciiString( src );
}
+/*!
+ Convert the OpenCascade unicode string to OpenCascade ascii string.
+*/
TCollection_AsciiString QDS::toAsciiString( const Handle(TCollection_HExtendedString)& src )
{
TCollection_AsciiString res;
return res;
}
+/*!
+ Convert the Qt string to OpenCascade unicode string.
+*/
TCollection_ExtendedString QDS::toExtString( const QString& src )
{
if ( src.isEmpty() )
return trg;
}
+/*!
+ Convert the OpenCascade ascii string to OpenCascade unicode string.
+*/
TCollection_ExtendedString QDS::toExtString( const TCollection_AsciiString& src )
{
return TCollection_ExtendedString( src );
}
+/*!
+ Load datum definitions in the dictionary from XML file \adictPath.
+ Returns true if load successed or false otherwise.
+*/
bool QDS::load( const QString& dictPath )
{
if ( dictPath.isEmpty() )
return DDS_Dictionary::Load( toAsciiString( dictPath ) );
}
+/*!
+ Returns the label of unit system \asys. If component \acomp specified and not empty then
+ function find the given unit system in the given component otherwise all components will be searched.
+ If unit system not found then empty string returned.
+*/
QString QDS::unitSystemLabel( const QString& sys, const QString& comp )
{
QString lab;
return lab;
}
+/*!
+ Gets the name of active unit system from the specified component \acomp.
+ If component not specified or component is empty string then first got component will be used.
+ If component exist then active unit system name returned or empty string otherwise.
+*/
QString QDS::activeUnitSystem( const QString& comp )
{
QString sys;
return sys;
}
+/*!
+ Sets the active unit system named \asys. If not empty component name \acomp specified then
+ unit system will be activated in the given component otherwise all components will be processed.
+
+ After the changing of active unit system function notify about it to all registered datums
+ from processed components using method QDS_Datum::unitSystemChanged();
+*/
void QDS::setActiveUnitSystem( const QString& sys, const QString& comp )
{
Handle(DDS_Dictionary) dic = DDS_Dictionary::Get();
}
}
+/*!
+ Register given datum \adatum in the static list.
+ This function invoked by QDS_Datum constructor.
+*/
void QDS::insertDatum( QDS_Datum* datum )
{
if ( !datum )
_datumList.append( datum );
}
+/*!
+ Remove given datum \adatum from the static list.
+ This function invoked by QDS_Datum destructor.
+*/
void QDS::removeDatum( QDS_Datum* datum )
{
if ( !datum )
class QDS_EXPORT QDS
{
public:
- typedef enum { None = 0x00, Label = 0x01, Control = 0x02, Units = 0x04,
- NotFormat = 0x08, NotAccel = 0x10, UnitsWithLabel = 0x20,
- All = Label | Control | Units } DatumFlags;
+ /*! Enum describes bit flags of the Qt datum view and behaviour */
+ typedef enum
+ {
+ None = 0x00, //!< Non specified any flags (Default behaviour)
+ Label = 0x01, //!< Create subwidget for datum label
+ Control = 0x02, //!< Create subwidget for datum input control
+ Units = 0x04, //!< Create subwidget for datum units of measure
+ NotFormat = 0x08, //!< Don't format initial value
+ NotAccel = 0x10, //!< Not support accelerators in datum label
+ UnitsWithLabel = 0x20, //!< Display units of measure in label like "<label_text> (<units_text>) instead separate text"
+ All = Label | Control | Units //!< Create all subwidgets
+ } DatumFlags;
public:
static bool load( const QString& );
#include <qcheckbox.h>
+/*
+ \class QDS_CheckBox
+
+ Datum with control corresponding to check box. This control can have only two states:
+ 1 (on/true) or 0 (off/false). QDS_CheckBox don't take into account standard parameter
+ properties (minimum, maximum, filter, etc).
+
+ QDS_CheckBox can set and get following values for access methods (setStringValue(),
+ setIntegerValue(), setDoubleValue(), stringValue(), integerValue(), doubleValue()):
+ \li "1" - check box state is setted as on.
+ \li "0" - check box state is setted as off.
+ \li "-1" - check box state is setted as "NoChage" (undefined).
+
+ User can set and check a state "NoChange" using methods clear() and isEmpty() accordingly.
+*/
+
/*!
- Constructor. This method is protected. Object can't be directly constructed.
- Use static method QDS_CheckBox::Create instead.
+ Constructor. Create check box datum object with datum identifier \aid under widget \aparent.
+ Parameter \aflags define behaviour of datum and set of created subwidgets. Default value of
+ this parameter is QDS::All. Parameter \acomp specify the component name which will be used
+ during search of dictionary item.
*/
QDS_CheckBox::QDS_CheckBox( const QString& id, QWidget* parent, const int flags, const QString& comp )
: QDS_Datum( id, parent, flags, comp )
}
/*!
- Returns string from QCheckBox widget.
+ Returns string from QCheckBox widget. If the check box state is on then 1 returned otherwise 0.
*/
QString QDS_CheckBox::getString() const
{
}
/*!
- Sets the string into QCheckBox widget.
+ Sets the string into QCheckBox widget. If argument \atxt is string with number "1" then check box
+ state is setted as on. If argument \atxt is string with number "0" then state is setted as off.
+ If argument \atxt is string with number "-1" then state is setted as "NoChage" (undefined).
*/
void QDS_CheckBox::setString( const QString& txt )
{
}
/*!
- Notify about shanging of control state
+ Notify about ñhanging of control state
*/
void QDS_CheckBox::onParamChanged()
{
emit paramChanged();
}
+/*!
+ Notify about ñhanging of control state. Switch off check box property "tristate" when
+ state changed by user.
+*/
void QDS_CheckBox::onStateChanged( int state )
{
if ( state != QButton::NoChange && checkBox() )
checkBox()->setTristate( false );
}
+/*!
+ Sets the check box state \atheState.
+*/
void QDS_CheckBox::setChecked( const bool theState )
{
if ( checkBox() )
checkBox()->setChecked( theState );
}
+/*!
+ Returns current check box state.
+*/
bool QDS_CheckBox::isChecked() const
{
return checkBox() ? checkBox()->isChecked() : false;
#include <qlineedit.h>
+/*
+ \class QDS_ComboBox
+
+ Datum with control corresponding to combo box. This control used for datum with enumerable values.
+ It can be used for datum which has type of value 'List'. Each item of combobox defined two properties:
+ integer identifier and string name. All operations on items performed via identifier.
+*/
+
/*!
- Constructor.
+ Constructor. Create combobox datum object with datum identifier \aid under widget \aparent. Parameter \aflags
+ define behaviour of datum and set of created subwidgets. Default value of this parameter is QDS::All.
+ Parameter \acomp specify the component name which will be used during search of dictionary item.
*/
QDS_ComboBox::QDS_ComboBox( const QString& id, QWidget* parent, const int flags, const QString& comp )
: QDS_Datum( id, parent, flags, comp )
}
/*!
- Returns true if ComboBox allow to edit current Text.
+ Returns true if ComboBox allow to edit current text.
*/
bool QDS_ComboBox::editable() const
{
}
/*!
- Returns number of items in ComboBox. If total is 'false' then only
+ Returns number of items in ComboBox. If \atotal is 'false' then only
visible items are taken into account otherwise all items.
*/
int QDS_ComboBox::count( bool total ) const
}
/*!
- Returns list of ids. If total is 'false' then only visible items
+ Returns list of list item identifiers \aids. If \atotal is 'false' then only visible items
are taken into account otherwise all items.
*/
void QDS_ComboBox::values( QValueList<int>& ids, bool total ) const
}
/*!
- Returns the current id as integer.
+ Returns the current id as integer. Reimplemented.
*/
int QDS_ComboBox::integerValue() const
{
}
/*!
- Returns the current id as double.
+ Returns the current id as double. Reimplemented.
*/
double QDS_ComboBox::doubleValue() const
{
}
/*!
- Set the current item acording to specified id.
+ Set the current item acording to specified id. Reimplemented.
*/
void QDS_ComboBox::setIntegerValue( const int id )
{
}
/*!
- Get the integer part of specified value and use it as new current identifier.
+ Get the integer part of specified value and use it as new current identifier. Reimplemented.
*/
void QDS_ComboBox::setDoubleValue( const double val )
{
}
/*!
- Returns visible state of identificator.
+ Returns visible state of item specified by \aid.
*/
bool QDS_ComboBox::state( const int id ) const
{
}
/*!
- Sets the visible state of identificator. If 'id' is -1 then specified
- state will be set to all ids.
+ Sets the visible state of item specified by \aid. If \aid is -1 then specified
+ state will be set to all items. If \aappend is set then keep status for other items
+ otherwise status of other items will be cleared.
*/
void QDS_ComboBox::setState( const bool on, const int id, const bool append )
{
}
/*!
- Sets the visible state of identificator from the specified list.
+ Sets the visible state of items specified by list of identifiers \aids.
+ If \aappend is set then keep status for other items otherwise status of other
+ items will be cleared.
*/
void QDS_ComboBox::setState( const bool on, const QValueList<int>& ids, const bool append )
{
}
/*!
- Sets the user items into the combo box.
+ Sets the custom user items into the combo box. User items like standard dictionary
+ list items will be added into the combobox. This functionality allow to user override
+ items.
*/
void QDS_ComboBox::setValues( const QValueList<int>& ids, const QStringList& names )
{
/*!
This is an overloaded member function, provided for convenience.
It behaves essentially like the above function. It creates
- QValueList (0, 1, 2 ... ) and call previous method
+ QValueList (0, 1, 2 ... ) and call previous method.
*/
void QDS_ComboBox::setValues( const QStringList& names )
{
}
/*!
- Returns string from QLineEdit widget.
+ Returns string from QComboBox widget. Reimplemented.
*/
QString QDS_ComboBox::getString() const
{
}
/*!
- Sets the string into QLineEdit widget.
+ Sets the string into QComboBox widget. Reimplemented.
*/
void QDS_ComboBox::setString( const QString& txt )
{
}
/*!
- Create QComboBox widget as control subwidget.
+ Create QComboBox widget as control subwidget. Reimplemented.
*/
QWidget* QDS_ComboBox::createControl( QWidget* parent )
{
return cb;
}
+/*!
+ Notification about active unit system changing. Reimplemented from QDS_Datum.
+ Update combobox content.
+*/
void QDS_ComboBox::unitSystemChanged( const QString& system )
{
QDS_Datum::unitSystemChanged( system );
}
/*!
- Notify about activation new item.
+ Notify about activation combobox item.
*/
void QDS_ComboBox::onActivated( int idx )
{
}
/*!
- Updates ComboBox after have change of visible state or items have been inserted / removed.
+ Updates ComboBox after have change of visible state or items have been inserted/removed.
*/
void QDS_ComboBox::updateComboBox()
{
#include <qvalidator.h>
#include <qmessagebox.h>
+#include <TColStd_SequenceOfAsciiString.hxx>
+
/*!
- Class: QDS_Datum::Wrapper
- Descr: Wrapper widget for sub widgets. [internal]
+ class: QDS_Datum::Wrapper
+ descr: Wrapper widget for sub widgets. [internal]
*/
class QDS_Datum::Wrapper : public QWidget
QWidget* widget() const;
void setWidget( QWidget* );
- virtual bool eventFilter( QObject*, QEvent* );
-
-protected:
- virtual void resizeEvent( QResizeEvent* );
+ virtual void setGeometry( int x, int y, int w, int h );
+ virtual void setSizePolicy( QSizePolicy );
private:
QWidget* myWid;
};
-
QDS_Datum::Wrapper::Wrapper( QWidget* parent )
: QWidget( parent ),
myWid( 0 )
if ( myWid == wid )
return;
- if ( myWid )
- myWid->removeEventFilter( this );
-
myWid = wid;
if ( !myWid )
myWid->updateGeometry();
updateGeometry();
-
- myWid->installEventFilter( this );
}
-bool QDS_Datum::Wrapper::eventFilter( QObject* o, QEvent* e )
+void QDS_Datum::Wrapper::setSizePolicy( QSizePolicy sp )
{
- if ( e->type() == QEvent::Resize && o == widget() )
- {
- QResizeEvent* re = (QResizeEvent*)e;
- if ( re->size() != size() )
- resize( re->size() );
- }
- return QWidget::eventFilter( o, e );
+ QWidget::setSizePolicy( sp );
+
+ if ( widget() )
+ widget()->setSizePolicy( sp );
}
-void QDS_Datum::Wrapper::resizeEvent( QResizeEvent* e )
+void QDS_Datum::Wrapper::setGeometry( int x, int y, int w, int h )
{
- QWidget::resizeEvent( e );
+ QWidget::setGeometry( x, y, w, h );
if ( widget() && widget()->size() != size() )
- widget()->resize( size() );
+ widget()->setGeometry( 0, 0, width(), height() );
}
/*!
- Class: QDS_Datum
- Descr: Base class for control used data dictionary. [public]
+ \class QDS_Datum
+
+ This is a base class for control using the data dictionary. Datum is successor of QObject (not QWidget).
+ This object can have three sub widgets named as Label, Control and Units. User can skip creation of
+ some of them manipulate by parameter \aflags. Label widget display label of datum, Control widget allow
+ to input value, Units widget display units of measure in the active system.
+
+ These widgets constructs under parent of datum. If this parent has layout which can automaticaly add child
+ widgets (see QLayout::setAutoAdd()) then these subwidgets will be placed in following order: first widget
+ is Label, second - Control, third - Unints. User can add these widgets to layout manually using methods
+ QDS_Datum::addTo() or QDS_Datum::widget(). In last case User can retrieve desired widget and place it into
+ layout.
+
+ If use QGroupBox as parent widget for datum object then all subwidgets will be arranged automatically by
+ group box according to column and orientation properties of QGroupBox.
+
+ For example:
+ QGroupBox* box = new QGroupBox( 3, Qt::Horizontal, "datum box" );
+ QDS_Datum* d1 = new QDS_Datum( "datum_1", box, All );
+ QDS_Datum* d2 = new QDS_Datum( "datum_2", box, All );
+ QDS_Datum* d3 = new QDS_Datum( "datum_3", box, All );
+
+ In this example we create the QGroupBox with 3 horizontal columns. All created datum widgets will be
+ placed automatically three widgets in a row. Each datum will be placed from up to bottom one by one.
+
+ Datum value is stored as string. User can get/set this value in different kinds:
+ \liAs string - methods stringValue()/setStringValue().
+ \liAs integer - methods integerValue()/setIntegerValue(). Given value converted to/from SI.
+ \liAs double - methods doubleValue()/setDoubleValue(). Given value converted to/from SI.
+ \liAs variant - methods value()/setValue().
+
+ User can perform some actions on datum subwidgets using following methods: isEnabled(),
+ setEnabled(), show(), hide(), setShown(), setFocus(), setAlignment().
*/
+/*!
+ Constructor. Create datum object with datum identifier \aid under widget \aparent. Parameter \aflags
+ define behaviour of datum and set of created subwidgets. Default value of this parameter is QDS::All.
+ Parameter \acomp specify the component name which will be used during search of dictionary item.
+
+ Datum register self in the static list by QDS::insertDatum().
+*/
QDS_Datum::QDS_Datum( const QString& id, QWidget* parent, const int flags, const QString& comp )
: QObject( parent ),
myId( id ),
insertDatum( this );
}
+/*!
+ Destructor. Destroy all subwidget.
+ Datum unregister self from the static list by QDS::removeDatum().
+*/
QDS_Datum::~QDS_Datum()
{
removeDatum( this );
*/
}
+/*!
+ Overloaded operator allow to retrieve main subwidget named Control.
+*/
QDS_Datum::operator QWidget*() const
{
return widget( Control );
}
+/*!
+ Returns the datum id.
+*/
QString QDS_Datum::id() const
{
initDatum();
return myId;
}
+/*!
+ Returns the datum type of value.
+*/
int QDS_Datum::type() const
{
initDatum();
return res;
}
+/*!
+ Returns the datum label string.
+*/
QString QDS_Datum::label() const
{
initDatum();
return labStr;
}
+/*!
+ Returns the datum units string.
+*/
QString QDS_Datum::units() const
{
initDatum();
return unitStr;
}
+/*!
+ Returns the datum value filter string.
+*/
QString QDS_Datum::filter() const
{
initDatum();
return fltr;
}
+/*!
+ Returns the datum value format string.
+*/
QString QDS_Datum::format() const
{
initDatum();
return fmtStr;
}
+/*!
+ Returns the datum default value string.
+*/
QString QDS_Datum::defaultValue() const
{
initDatum();
return aDef;
}
+/*!
+ Returns the datum minimum value string.
+*/
QString QDS_Datum::minimumValue() const
{
initDatum();
return min;
}
+/*!
+ Returns the datum maximum value string.
+*/
QString QDS_Datum::maximumValue() const
{
initDatum();
return max;
}
+/*!
+ Returns the datum long description.
+*/
QString QDS_Datum::longDescription() const
{
initDatum();
return ldStr;
}
+/*!
+ Returns the datum short description.
+*/
QString QDS_Datum::shortDescription() const
{
initDatum();
return sdStr;
}
+/*!
+ Returns the list of option names.
+*/
+QStringList QDS_Datum::options() const
+{
+ QStringList res;
+ if ( !dicItem().IsNull() )
+ {
+ TColStd_SequenceOfAsciiString lst;
+ dicItem()->GetOptionNames( lst );
+ for ( int i = 1; i <= lst.Length(); i++ )
+ res.append( toQString( lst.Value( i ) ) );
+ }
+ return res;
+}
+
+/*!
+ Returns the option specified by \aname as QVariant.
+ If option not exist then not valid QVariant returned.
+*/
+QVariant QDS_Datum::option( const QString& name ) const
+{
+ QVariant res;
+ if ( !dicItem().IsNull() )
+ res = QVariant( toQString( dicItem()->GetOption( toAsciiString( name ) ) ) );
+ return res;
+}
+
+/*!
+ Returns the option specified by \aname as QString.
+ If option not exist then empty string returned.
+*/
+QString QDS_Datum::optionString( const QString& name ) const
+{
+ QString res;
+ if ( !dicItem().IsNull() )
+ res = toQString( dicItem()->GetOption( toAsciiString( name ) ) );
+ return res;
+}
+
+/*!
+ Returns the option specified by \aname as double.
+ If option not exist then 0 returned.
+*/
+double QDS_Datum::optionDouble( const QString& name ) const
+{
+ double res = 0;
+ QVariant opt = option( name );
+ if ( opt.isValid() && opt.canCast( QVariant::Double ) )
+ res = opt.toDouble();
+ return res;
+}
+
+/*!
+ Returns the option specified by \aname as integer.
+ If option not exist then 0 returned.
+*/
+int QDS_Datum::optionInteger( const QString& name ) const
+{
+ int res = 0;
+ QVariant opt = option( name );
+ if ( opt.isValid() && opt.canCast( QVariant::Int ) )
+ res = opt.toInt();
+ return res;
+}
+
+/*!
+ Returns the datum value as variant (QVariant object).
+*/
QVariant QDS_Datum::value() const
{
QVariant val;
return val;
}
+/*!
+ Returns the datum value as string (QString object).
+*/
QString QDS_Datum::stringValue() const
{
initDatum();
return getString();
}
+/*!
+ Returns the datum value as double. This value converted from units of measure in active unit system
+ to units of measure in unit system "SI".
+*/
double QDS_Datum::doubleValue() const
{
initDatum();
return res;
}
+/*!
+ Returns the datum value as integer. This value converted from units of measure in active unit system
+ to units of measure in unit system "SI".
+*/
int QDS_Datum::integerValue() const
{
initDatum();
return res;
}
+/*!
+ Returns the text from datum. Text consist of label, string value and units.
+*/
QString QDS_Datum::text() const
{
initDatum();
return res;
}
+/*!
+ Returns false if datum control has inputted value.
+*/
bool QDS_Datum::isEmpty() const
{
return stringValue().isEmpty();
}
+/*!
+ Reset datum state and set default value as current.
+*/
void QDS_Datum::reset()
{
initDatum();
emit paramChanged( str );
}
+/*!
+ Clear the control.
+*/
void QDS_Datum::clear()
{
initDatum();
}
}
+/*!
+ Set varian value (QVariant object) into datum.
+*/
void QDS_Datum::setValue( const QVariant& val )
{
if ( val.isValid() && val.canCast( QVariant::String ) )
clear();
}
+/*!
+ Set string value (QString object) into datum.
+*/
void QDS_Datum::setStringValue( const QString& txt )
{
initDatum();
emit paramChanged( str );
}
+/*!
+ Set double value into datum. This value converted from units of measure in unit system "SI"
+ to units of measure in active unit system. Format the value using datum format if it required.
+*/
void QDS_Datum::setDoubleValue( const double num )
{
initDatum();
emit paramChanged( str );
}
+/*!
+ Set integer value into datum. This value converted from units of measure in unit system "SI"
+ to units of measure in active unit system. Format the value using datum format if it required.
+*/
void QDS_Datum::setIntegerValue( const int num )
{
initDatum();
}
/*!
- Returns true if all subwidgets specified by 'element' enabled.
+ Returns true if all subwidgets specified by \aelement enabled.
*/
bool QDS_Datum::isEnabled( const int element ) const
{
}
/*!
- Enable/Disable subwidgets specified by 'element'.
- Values: Label, Control, Units or their combinations.
+ Enable/Disable subwidgets specified by \aelement.
+ Possible values of \aelement: Label, Control, Units or their combinations.
*/
void QDS_Datum::setEnabled( const bool on, const int element )
{
setEnabled( on, Control );
}
+/*!
+ Show/hide subwidgets specified by \aelement.
+ Possible values of \aelement: Label, Control, Units or their combinations.
+*/
void QDS_Datum::setShown( const bool visible, const int flags )
{
- if ( visible )
- show( flags );
- else
- hide( flags );
+ initDatum();
+
+ uint flag = Units;
+ while ( flag )
+ {
+ if ( flags & flag && widget( flag ) )
+ widget( flag )->setShown( visible );
+ flag = flag >> 1;
+ }
}
/*!
- Show subwidgets specified by 'element'.
- Values: Label, Control, Units or their combinations.
+ Show subwidgets specified by \aelement.
+ Possible values of \aelement: Label, Control, Units or their combinations.
*/
void QDS_Datum::show( const int element )
{
- initDatum();
-
- if ( ( element & Label ) && labelWidget() )
- labelWidget()->show();
- if ( ( element & Units ) && unitsWidget() )
- unitsWidget()->show();
- if ( ( element & Control ) && controlWidget() )
- controlWidget()->show();
+ setShown( true, element );
}
/*!
- Hide subwidgets specified by 'element'.
- Values: Label, Control, Units or their combinations.
+ Hide subwidgets specified by \aelement.
+ Possible values of \aelement: Label, Control, Units or their combinations.
*/
void QDS_Datum::hide( const int element )
{
- initDatum();
-
- if ( ( element & Label ) && labelWidget() )
- labelWidget()->hide();
- if ( ( element & Units ) && unitsWidget() )
- unitsWidget()->hide();
- if ( ( element & Control ) && controlWidget() )
- controlWidget()->hide();
+ setShown( false, element );
}
/*!
- Returns subwidget specified by 'element'.
- Possible values: Label, Control, Units.
+ Returns subwidget specified by \aelement.
+ Possible values of \aelement: Label, Control, Units.
*/
QWidget* QDS_Datum::widget( const int element ) const
{
/*!
Returns true if control contains valid value otherwise returns false
- and display warning message box if parameter msgBox is set.
+ and display warning message box if parameter \amsgBox is set.
*/
bool QDS_Datum::isValid( const bool msgBox, const QString& extMsg, const QString& extLabel ) const
{
}
/*!
- Add widgets to the vertical layout.
+ Add widgets to the vertical box layout.
*/
void QDS_Datum::addTo( QVBoxLayout* l )
{
}
/*!
- Add widgets to the horizaontal layout.
+ Add widgets to the horizaontal box layout.
*/
void QDS_Datum::addTo( QHBoxLayout* l )
{
unitsWidget()->setAlignment( align );
}
+/*!
+ Perform delayed initialisation. Reimplemented for internal reasons.
+*/
bool QDS_Datum::eventFilter( QObject* o, QEvent* e )
{
if ( o == parent() )
}
/*!
- Notify about parameter changing.
+ Notify about parameter value changing.
*/
void QDS_Datum::onParamChanged()
{
}
/*!
- Delayed initialization.
+ Perform delayed initialization.
*/
void QDS_Datum::onInitDatum()
{
}
/*!
- Returns QLabel instance which contains data dictionary label.
+ Returns QLabel widget which contains dictionary item label.
*/
QLabel* QDS_Datum::labelWidget() const
{
}
/*!
- Returns QLabel instance which contains data dictionary units.
+ Returns QLabel widget which contains dictionary item units.
*/
QLabel* QDS_Datum::unitsWidget() const
{
}
/*!
- Creates QLabel widget for data label.
+ Creates QLabel widget for dictionary item label.
*/
QLabel* QDS_Datum::createLabel( QWidget* parent )
{
}
/*!
- Creates QLabel widget for data units.
+ Creates QLabel widget for dictionary item units.
*/
QLabel* QDS_Datum::createUnits( QWidget* parent )
{
}
/*!
- Returns validator accordance to data type.
+ Creates and returns validator accordance to datum type of value.
*/
QValidator* QDS_Datum::validator( const bool limits ) const
{
}
/*!
- Retrieves information from data dictionary and create subwidgets using virtual mechanism.
+ Retrieves information from dictionary and create subwidgets using virtual mechanism.
Virtual mechanism doesn't work in constructor and destructor, therefore this method should
be called outside the constructor.
*/
labelWidget()->setBuddy( ctrl );
}
+/*!
+ Notification about active unit system changing. Update label and units texts.
+*/
void QDS_Datum::unitSystemChanged( const QString& unitSystem )
{
QString labText = label();
}
/*!
- Format the specified integer as data dictionary value.
+ Format the specified integer as dictionary item value.
*/
QString QDS_Datum::format( const int num, const QString& id, const bool convert )
{
}
/*!
- Format the specified double as data dictionary value.
+ Format the specified double as dictionary item value.
*/
QString QDS_Datum::format( const double num, const QString& id, const bool convert )
{
}
/*!
- Format the specified string as data dictionary value.
+ Format the specified string as dictionary item value.
*/
QString QDS_Datum::format( const QString& str, const QString& id, const bool convert )
{
}
/*!
- Format the given string accordance to data format.
+ Format the given string accordance to dictionary item format.
*/
QString QDS_Datum::format( const QString& aFormat, const int aType, const int aValue )
{
}
/*!
- Format the given string accordance to data format.
+ Format the given string accordance to dictionary item format.
*/
QString QDS_Datum::format( const QString& aFormat, const int aType, const double aValue )
{
}
/*!
- Format the given string accordance to data format.
+ Format the given string accordance to dictionary item format.
*/
QString QDS_Datum::format( const QString& aFormat, const int aType, const QString& aValue )
{
}
/*!
- Returns displayable units string for given DD ID
+ Returns displayable units string for given dictionary item id
*/
QString QDS_Datum::units( const QString& id )
{
myTargetValue = QString::null;
}
+/*!
+ Remove the acceleartor tags '&' from specified label string \asrc.
+*/
QString QDS_Datum::removeAccel( const QString& src )
{
QString trg = src;
return trg;
}
+/*!
+ Returns true if given format string \atheFormat has specificator for double values.
+*/
bool QDS_Datum::isDoubleFormat( const QString& theFormat )
{
if ( theFormat.length() > 0 )
return false;
}
+/*!
+ Returns datum flags.
+*/
int QDS_Datum::flags() const
{
return myFlags;
}
+/*!
+ Perform intialization if it needed. [internal]
+*/
void QDS_Datum::initDatum() const
{
if ( myInitialised )
parent()->removeEventFilter( this );
}
+/*!
+ Return wrapper for specified subwidget. [internal]
+*/
QDS_Datum::Wrapper* QDS_Datum::wrapper( QWidget* wid ) const
{
if ( !wid )
return wrap;
}
+/*!
+ Return wrapper for specified subwidget name. [internal]
+*/
QDS_Datum::Wrapper* QDS_Datum::wrapper( const int id ) const
{
Wrapper* wrap = 0;
return wrap;
}
+/*!
+ Return subwidget name for specified wrapper. [internal]
+*/
int QDS_Datum::wrapperType( QDS_Datum::Wrapper* wrap ) const
{
int id = -1;
#include "QDS.h"
-#include <qobject.h>
+#include <qwidget.h>
#include <qstring.h>
#include <qvariant.h>
#include <qguardedptr.h>
QString minimumValue() const;
QString maximumValue() const;
+ QStringList options() const;
+ QVariant option( const QString& ) const;
+ QString optionString( const QString& ) const;
+ double optionDouble( const QString& ) const;
+ int optionInteger( const QString& ) const;
+
virtual QVariant value() const;
virtual QString stringValue() const;
virtual bool isEnabled( const int = Control ) const;
virtual void setEnabled( const bool, const int );
- void show( const int = -1 );
- void hide( const int = -1 );
- void setShown( const bool, const int = -1 );
+ void show( const int = All );
+ void hide( const int = All );
+ virtual void setShown( const bool, const int = All );
QWidget* widget( const int ) const;
void setFocus();
#include <qvalidator.h>
/*
- Class: QDS_LineEdit::Editor
- Descr: Internal class inherited from line edit
+ class: QDS_LineEdit::Editor
+ descr: Internal class inherited from line edit
*/
class QDS_LineEdit::Editor : public QLineEdit
};
/*
- Class: QDS_LineEdit
- Descr: Data control corresponding to line edit
+ \class QDS_LineEdit
+
+ Datum with control corresponding to line edit. User can enter parameter value in single line editor.
+ User inputted values will be checked by validator according to type if value and parameter properties
+ (minimum, maximum, filter, precision, etc). If user input not valid value then this value will be
+ displayed in red color.
*/
/*!
- Constructor.
+ Constructor. Create line edit datum object with datum identifier \aid under widget \aparent. Parameter \aflags
+ define behaviour of datum and set of created subwidgets. Default value of this parameter is QDS::All.
+ Parameter \acomp specify the component name which will be used during search of dictionary item.
*/
QDS_LineEdit::QDS_LineEdit( const QString& id, QWidget* parent, const int flags, const QString& comp )
: QDS_Datum( id, parent, flags, comp )
{
}
+/*!
+ Notification about active unit system changing. Reimplemented from QDS_Datum.
+ Update validator settings for line edit.
+*/
void QDS_LineEdit::unitSystemChanged( const QString& system )
{
QDS_Datum::unitSystemChanged( system );
}
/*!
- Set the aligment of line edit.
+ Select all text in the editor.
+*/
+void QDS_LineEdit::selectAll()
+{
+ if ( lineEdit() )
+ lineEdit()->selectAll();
+}
+
+/*!
+ Deselect all text in the editor.
+*/
+void QDS_LineEdit::deselect()
+{
+ if ( lineEdit() )
+ lineEdit()->deselect();
+}
+
+/*!
+ Select or deselect all text in the editor.
+*/
+void QDS_LineEdit::setSelection( const bool on )
+{
+ if ( on )
+ selectAll();
+ else
+ deselect();
+}
+
+/*!
+ Returns true if the editor has selected text.
+*/
+bool QDS_LineEdit::hasSelection() const
+{
+ return lineEdit() ? lineEdit()->hasSelectedText() : false;
+}
+
+/*!
+ Set the aligment of line edit. Reimplemented from QDS_Datum.
*/
void QDS_LineEdit::setAlignment( const int align, const int type )
{
}
/*!
- Returns string from QLineEdit widget.
+ Returns string value from QLineEdit widget. Reimplemented from QDS_Datum.
*/
QString QDS_LineEdit::getString() const
{
}
/*!
- Sets the string into QLineEdit widget.
+ Sets the string value into QLineEdit widget. Reimplemented from QDS_Datum.
*/
void QDS_LineEdit::setString( const QString& txt )
{
}
/*!
- Create QLineEdit widget as control subwidget.
+ Create QLineEdit widget as control subwidget. Reimplemented from QDS_Datum.
*/
QWidget* QDS_LineEdit::createControl( QWidget* parent )
{
}
/*!
- Checks the current parameter value on validity.
+ Checks the current parameter value on validity. If value is not valid then set text color as red.
*/
void QDS_LineEdit::onParamChanged()
{
{
Q_OBJECT
+ Q_PROPERTY( bool Selection READ hasSelection WRITE setSelection )
+
protected:
class Editor;
QDS_LineEdit( const QString&, QWidget* = 0, const int = All, const QString& = QString::null );
virtual ~QDS_LineEdit();
+ virtual void deselect();
+ virtual void selectAll();
virtual void setAlignment( const int, const int = Label );
+ bool hasSelection() const;
+ void setSelection( const bool );
+
signals:
void returnPressed();
#include <qbuttongroup.h>
#include <qradiobutton.h>
+/*
+ \class QDS_RadioBox
+
+ Datum with control corresponding to button group with set of exclusive radio buttons.
+ This control used for datum with enumerable values. It can be used for datum which has
+ type of value 'List'. Each radio button of combobox defined two properties:
+ integer identifier and string name. All operations on radio buttons performed via identifier.
+
+ If datum label text is specified then it displayed in group box title.
+*/
+
/*!
- Constructor.
+ Constructor. Create radio button box datum object with datum identifier \aid under widget \aparent.
+ Parameter \aflags define behaviour of datum and set of created subwidgets. Default value of this
+ parameter is QDS::Control. Parameter \acomp specify the component name which will be used during
+ search of dictionary item.
*/
QDS_RadioBox::QDS_RadioBox( const QString& id, QWidget* parent, const int flags, const QString& comp )
: QDS_Datum( id, parent, flags & ~( Label | Units ), comp )
}
/*!
- Returns number of items in ComboBox. If total is 'false' then only
- visible items are taken into account otherwise all items.
+ Returns number of buttons in radio box. If total is 'false' then only
+ visible buttons are taken into account otherwise all buttons.
*/
int QDS_RadioBox::count( bool total ) const
{
}
/*!
- Returns list of ids. If total is 'false' then only visible items
- are taken into account otherwise all items.
+ Returns list of button identifiers \aids. If \atotal is 'false' then only visible
+ buttons are taken into account otherwise all buttons.
*/
void QDS_RadioBox::values( QValueList<int>& ids, bool total ) const
{
}
/*!
- Returns visible state of identificator.
+ Returns visible state of button specified by \aid.
*/
bool QDS_RadioBox::state( const int id ) const
{
}
/*!
- Sets the visible state of identificator. If 'id' is -1 then specified
- state will be set to all ids.
+ Sets the visible state of button specified by \aid. If \aid is -1 then specified
+ state will be set to all buttons. If \aappend is set then keep status for other
+ buttons otherwise status of other buttons will be cleared.
*/
void QDS_RadioBox::setState( const bool on, const int id, const bool append )
{
}
/*!
- Sets the visible state of identificator from the specified list.
+ Sets the visible state of buttons specified by list of identifiers \aids.
+ If \aappend is set then keep status for other buttons otherwise status of other
+ buttons will be cleared.
*/
void QDS_RadioBox::setState( const bool on, const QValueList<int>& ids, const bool append )
{
}
/*!
- Sets the user items into the combo box.
+ Sets the custom user buttons into the radio box. User buttons like standard dictionary
+ button from list will be added into the radio box. This functionality allow to user override
+ buttons.
*/
void QDS_RadioBox::setValues( const QValueList<int>& ids, const QStringList& names )
{
}
/*!
- Returns string from control.
+ Returns string from radio box. Reimplemented. String which contains identifier of
+ currently selected button returned.
*/
QString QDS_RadioBox::getString() const
{
}
/*!
- Sets the string into control.
+ Sets the string into radio box. Reimplemented. Button with identifier from specified
+ string \atxt became selected in radio box.
*/
void QDS_RadioBox::setString( const QString& txt )
{
}
/*!
- Create QComboBox widget as control subwidget.
+ Create QButtonGroup widget as control subwidget.
*/
QWidget* QDS_RadioBox::createControl( QWidget* parent )
{
return bg;
}
+/*!
+ Notification about active unit system changing. Reimplemented from QDS_Datum.
+ Update radio box content.
+*/
void QDS_RadioBox::unitSystemChanged( const QString& system )
{
QDS_Datum::unitSystemChanged( system );
}
/*!
- Notify about state changed in line edit of RadioBox.
+ Notify about activation radio button.
*/
void QDS_RadioBox::onToggled( bool on )
{
}
/*!
- Updates RadioBox after have change of visible state or items have been inserted / removed.
+ Updates RadioBox after have change of visible state or buttons have been inserted/removed.
*/
void QDS_RadioBox::updateRadioBox()
{
}
}
+/*!
+ Returns the list of the radio buttons from the button group.
+*/
void QDS_RadioBox::buttons( QPtrList<QRadioButton>& lst ) const
{
lst.setAutoDelete( false );
Q_OBJECT
public:
- QDS_RadioBox( const QString&, QWidget* = 0, const int = All, const QString& = QString::null );
+ QDS_RadioBox( const QString&, QWidget* = 0, const int = Control, const QString& = QString::null );
virtual ~QDS_RadioBox();
int count( bool = false ) const;
#include <qvalidator.h>
+/*
+ \class QDS_SpinBox
+
+ Datum with control corresponding to spin box. This control used for integer numbers.
+ User can input data directly in spin box or can modify current value with given
+ increment.
+*/
+
/*!
- Constructor.
+ Constructor. Create spin box datum object with datum identifier \aid under widget \aparent. Parameter \aflags
+ define behaviour of datum and set of created subwidgets. Default value of this parameter is QDS::All.
+ Parameter \acomp specify the component name which will be used during search of dictionary item.
*/
QDS_SpinBox::QDS_SpinBox( const QString& id, QWidget* parent, const int flags, const QString& comp )
: QDS_Datum( id, parent, flags, comp )
}
/*!
- Returns string from QSpinBox widget.
+ Returns string from QSpinBox widget. Reimplemented.
*/
QString QDS_SpinBox::getString() const
{
}
/*!
- Sets the string into QSpinBox widget.
+ Sets the string into QSpinBox widget. Reimplemented.
*/
void QDS_SpinBox::setString( const QString& txt )
{
}
/*!
- Create QSpinBox widget as control subwidget.
+ Create QSpinBox widget as control subwidget. Reimplemented.
*/
QWidget* QDS_SpinBox::createControl( QWidget* parent )
{
}
/*!
- Notify about text changing in spin box.
+ Notify about value changing in spin box.
*/
void QDS_SpinBox::onValueChanged( int val )
{
}
/*!
- This method is redefined from ancestor class to perform own initialization ( suffix, prefix, etc ).
+ Notification about active unit system changing. Reimplemented from QDS_Datum.
+ Update validator and spin box parameters: suffix, prefix, minimum, maximum.
*/
void QDS_SpinBox::unitSystemChanged( const QString& system )
{
#include <QtxDblSpinBox.h>
+/*
+ \class QDS_SpinBoxDbl
+
+ Datum with control corresponding to spin box. This control used for double numbers.
+ User can input data directly in spin box or can modify current value with given
+ increment.
+*/
+
/*!
- Constructor.
+ Constructor. Create spin box datum object with datum identifier \aid under widget \aparent. Parameter \aflags
+ define behaviour of datum and set of created subwidgets. Default value of this parameter is QDS::All.
+ Parameter \acomp specify the component name which will be used during search of dictionary item.
*/
QDS_SpinBoxDbl::QDS_SpinBoxDbl( const QString& id, QWidget* parent, const int flags, const QString& comp )
: QDS_Datum( id, parent, flags, comp )
}
/*!
- Returns string from QSpinBox widget.
+ Returns string from QSpinBox widget. Reimplemented.
*/
QString QDS_SpinBoxDbl::getString() const
{
}
/*!
- Sets the string into QSpinBox widget.
+ Sets the string into QSpinBox widget. Reimplemented.
*/
void QDS_SpinBoxDbl::setString( const QString& txt )
{
}
/*!
- Create QSpinBox widget as control subwidget.
+ Create QSpinBox widget as control subwidget. Reimplemented.
*/
QWidget* QDS_SpinBoxDbl::createControl( QWidget* parent )
{
}
/*!
- Notify about text changing in spin box.
+ Notify about value changing in spin box.
*/
void QDS_SpinBoxDbl::onValueChanged( double )
{
spinBox()->setLineStep( step );
}
+/*!
+ Notification about active unit system changing. Reimplemented from QDS_Datum.
+ Update validator and spin box parameters: suffix, prefix, minimum, maximum.
+*/
void QDS_SpinBoxDbl::unitSystemChanged( const QString& system )
{
QDS_Datum::unitSystemChanged( system );
--- /dev/null
+// Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
+//
+// 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
+//
+
+#include "QDS_Table.h"
+
+#include "QDS_LineEdit.h"
+
+class QDS_Table::DeleteFilter : public QObject
+{
+public:
+ DeleteFilter( QObject* = 0 );
+ virtual ~DeleteFilter();
+
+ virtual bool eventFilter( QObject*, QEvent* );
+};
+
+QDS_Table::DeleteFilter::DeleteFilter( QObject* parent )
+: QObject( parent )
+{
+}
+
+QDS_Table::DeleteFilter::~DeleteFilter()
+{
+}
+
+bool QDS_Table::DeleteFilter::eventFilter( QObject* o, QEvent* e )
+{
+ if ( e->type() == QEvent::DeferredDelete )
+ return true;
+ else
+ return false;
+}
+
+QDS_Table::QDS_Table( QWidget* parent, const char* name )
+: QtxTable( parent, name ),
+myHorEdit( 0 ),
+myVerEdit( 0 ),
+myTableEdit( 0 ),
+myKeepEdits( false )
+{
+}
+
+QDS_Table::QDS_Table( int r, int c, QWidget* parent, const char* name )
+: QtxTable( r, c, parent, name ),
+myHorEdit( 0 ),
+myVerEdit( 0 ),
+myTableEdit( 0 ),
+myKeepEdits( false )
+{
+ myRowEdit.resize( r );
+ myColEdit.resize( c );
+}
+
+QDS_Table::~QDS_Table()
+{
+}
+
+QDS_Datum* QDS_Table::horizontalHeaderEditor() const
+{
+ return myHorEdit;
+}
+
+QDS_Datum* QDS_Table::verticalHeaderEditor() const
+{
+ return myVerEdit;
+}
+
+QDS_Datum* QDS_Table::headerEditor( const Orientation o ) const
+{
+ return o == Horizontal ? myHorEdit : myVerEdit;
+}
+
+void QDS_Table::setVerticalHeaderEditor( QDS_Datum* dat )
+{
+ setHeaderEditor( Vertical, dat );
+}
+
+void QDS_Table::setHorizontalHeaderEditor( QDS_Datum* dat )
+{
+ setHeaderEditor( Horizontal, dat );
+}
+
+void QDS_Table::setHeaderEditor( QDS_Datum* dat )
+{
+ setHeaderEditor( Vertical, dat );
+ setHeaderEditor( Horizontal, dat );
+}
+
+void QDS_Table::setHeaderEditor( const Orientation o, QDS_Datum* dat )
+{
+ if ( headerEditor( o ) == dat )
+ return;
+
+ if ( isHeaderEditing() )
+ endEditHeader();
+
+ if ( o == Horizontal )
+ myHorEdit = dat;
+ else
+ myVerEdit = dat;
+
+ initEditor( dat );
+}
+
+QDS_Datum* QDS_Table::tableEditor() const
+{
+ return myTableEdit;
+}
+
+QDS_Datum* QDS_Table::rowEditor( const int row ) const
+{
+ if ( row < 0 || row >= (int)myRowEdit.size() )
+ return 0;
+
+ return myRowEdit.at( row );
+}
+
+QDS_Datum* QDS_Table::columnEditor( const int col ) const
+{
+ if ( col < 0 || col >= (int)myColEdit.size() )
+ return 0;
+
+ return myColEdit.at( col );
+}
+
+QDS_Datum* QDS_Table::cellEditor( const int row, const int col ) const
+{
+ if ( !myCellEdit.contains( row ) )
+ return 0;
+
+ const DatumMap& map = myCellEdit[row];
+ return map.contains( col ) ? map[col] : 0;
+}
+
+void QDS_Table::setTableEditor( QDS_Datum* dat )
+{
+ if ( tableEditor() == dat )
+ return;
+
+ if ( isEditing() && !cellEditor( currEditRow(), currEditCol() ) &&
+ !columnEditor( currEditCol() ) && !rowEditor( currEditRow() ) )
+ endEdit( currEditRow(), currEditCol(), false, false );
+
+ myTableEdit = dat;
+ initEditor( dat );
+}
+
+void QDS_Table::setRowEditor( const int row, QDS_Datum* dat )
+{
+ if ( row < 0 || row >= (int)myRowEdit.size() || rowEditor( row ) == dat )
+ return;
+
+ if ( isEditing() && row == currEditRow()&&
+ !cellEditor( currEditRow(), currEditCol() ) )
+ endEdit( currEditRow(), currEditCol(), false, false );
+
+ myRowEdit.insert( row, dat );
+ initEditor( dat );
+}
+
+void QDS_Table::setColumnEditor( const int col, QDS_Datum* dat )
+{
+ if ( col < 0 || col >= (int)myColEdit.size() || columnEditor( col ) == dat )
+ return;
+
+ if ( isEditing() && col == currEditCol()&&
+ !cellEditor( currEditRow(), currEditCol() ) )
+ endEdit( currEditRow(), currEditCol(), false, false );
+
+ myColEdit.insert( col, dat );
+ initEditor( dat );
+}
+
+void QDS_Table::setCellEditor( const int row, const int col, QDS_Datum* dat )
+{
+ if ( row < 0 || row >= numRows() || col < 0 || col >= numCols() || cellEditor( row, col ) == dat )
+ return;
+
+ if ( isEditing() && currEditRow() == row && currEditCol() == col && actualCellEditor( row, col ) != dat )
+ endEdit( currEditRow(), currEditCol(), false, false );
+
+ if ( !myCellEdit.contains( row ) )
+ myCellEdit.insert( row, DatumMap() );
+
+ myCellEdit[row].insert( col, dat );
+ initEditor( dat );
+}
+
+QDS_Datum* QDS_Table::actualCellEditor( const int row, const int col ) const
+{
+ QDS_Datum* dat = cellEditor( row, col );
+ if ( !dat )
+ dat = columnEditor( col );
+ if ( !dat )
+ dat = rowEditor( row );
+ if ( !dat )
+ dat = tableEditor();
+ return dat;
+}
+
+void QDS_Table::setNumRows( int r )
+{
+ int old = numRows();
+ QtxTable::setNumRows( r );
+
+ if ( isKeepEditors() )
+ myRowEdit.resize( QMAX( (int)myRowEdit.size(), r ) );
+ else
+ {
+ myRowEdit.resize( r );
+ for ( int i = r + 1; i <= old; i++ )
+ myCellEdit.remove( i );
+ }
+}
+
+void QDS_Table::setNumCols( int c )
+{
+ int old = numCols();
+ QtxTable::setNumCols( c );
+
+ if ( isKeepEditors() )
+ myColEdit.resize( QMAX( (int)myColEdit.size(), c ) );
+ else
+ {
+ myColEdit.resize( c );
+ for ( CellMap::Iterator it = myCellEdit.begin(); it != myCellEdit.end(); ++it )
+ {
+ DatumMap& map = it.data();
+ for ( int i = c + 1; i <= old; i++ )
+ map.remove( i );
+ }
+ }
+}
+
+void QDS_Table::clearCellWidget( int row, int col )
+{
+ QDS_Datum* dat = actualCellEditor( row, col );
+ if ( dat )
+ dat->hide();
+
+ QtxTable::clearCellWidget( row, col );
+}
+
+bool QDS_Table::isKeepEditors() const
+{
+ return myKeepEdits;
+}
+
+void QDS_Table::setKeepEditors( const bool on )
+{
+ myKeepEdits = on;
+}
+
+QWidget* QDS_Table::createHeaderEditor( QHeader* header, const int sect, const bool init )
+{
+ if ( !header )
+ return 0;
+
+ QDS_Datum* dat = headerEditor( header->orientation() );
+ QWidget* wid = dat ? dat->widget( QDS::Control ) : 0;
+ if ( wid )
+ {
+ if ( init )
+ dat->setStringValue( header->label( sect ) );
+ else
+ dat->clear();
+ dat->setProperty( "Selection", true );
+ }
+ else
+ wid = QtxTable::createHeaderEditor( header, sect, init );
+
+ return wid;
+}
+
+QWidget* QDS_Table::createEditor( int row, int col, bool init ) const
+{
+ QDS_Datum* dat = actualCellEditor( row, col );
+ QWidget* wid = dat ? dat->widget( QDS::Control ) : 0;
+ if ( wid )
+ {
+ if ( init )
+ dat->setStringValue( text( row, col ) );
+ else
+ dat->clear();
+ dat->setProperty( "Selection", true );
+ }
+ else
+ wid = QtxTable::createEditor( row, col, init );
+
+ return wid;
+}
+
+void QDS_Table::endEdit( int row, int col, bool accept, bool )
+{
+ QtxTable::endEdit( row, col, accept, true );
+}
+
+void QDS_Table::setCellContentFromEditor( int row, int col )
+{
+ QDS_Datum* dat = actualCellEditor( row, col );
+ if ( dat )
+ setText( row, col, dat->stringValue() );
+ else
+ QtxTable::setCellContentFromEditor( row, col );
+}
+
+void QDS_Table::setHeaderContentFromEditor( QHeader* header, const int sect, QWidget* editor )
+{
+ if ( !header )
+ return;
+
+ QDS_Datum* dat = headerEditor( header->orientation() );
+ if ( dat )
+ header->setLabel( sect, dat->stringValue() );
+ else
+ QtxTable::setHeaderContentFromEditor( header, sect, editor );
+}
+
+void QDS_Table::initEditor( QDS_Datum* dat )
+{
+ if ( !dat )
+ return;
+
+ dat->hide();
+
+ static QGuardedPtr<DeleteFilter> _filter = 0;
+ if ( !_filter )
+ _filter = new DeleteFilter( 0 );
+
+ if ( dat->widget( QDS::Control ) )
+ dat->widget( QDS::Control )->installEventFilter( _filter );
+}
--- /dev/null
+// Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
+//
+// 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
+//
+#ifndef QDS_TABLE_H
+#define QDS_TABLE_H
+
+#include "QDS_Datum.h"
+
+#include <QtxTable.h>
+
+#include <qmap.h>
+#include <qptrvector.h>
+
+class QDS_EXPORT QDS_Table : public QtxTable
+{
+ class DeleteFilter;
+
+ Q_OBJECT
+
+ Q_PROPERTY( bool KeepEditors READ isKeepEditors WRITE setKeepEditors )
+
+public:
+ QDS_Table( QWidget* = 0, const char* = 0 );
+ QDS_Table( int, int, QWidget* = 0, const char* = 0 );
+ virtual ~QDS_Table();
+
+ QDS_Datum* verticalHeaderEditor() const;
+ QDS_Datum* horizontalHeaderEditor() const;
+ QDS_Datum* headerEditor( const Orientation ) const;
+
+ void setVerticalHeaderEditor( QDS_Datum* );
+ void setHorizontalHeaderEditor( QDS_Datum* );
+
+ void setHeaderEditor( QDS_Datum* );
+ virtual void setHeaderEditor( const Orientation, QDS_Datum* );
+
+ QDS_Datum* tableEditor() const;
+ virtual void setTableEditor( QDS_Datum* );
+
+ QDS_Datum* rowEditor( const int ) const;
+ QDS_Datum* columnEditor( const int ) const;
+
+ virtual void setRowEditor( const int, QDS_Datum* );
+ virtual void setColumnEditor( const int, QDS_Datum* );
+
+ QDS_Datum* cellEditor( const int, const int ) const;
+ virtual void setCellEditor( const int, const int, QDS_Datum* );
+
+ QDS_Datum* actualCellEditor( const int, const int ) const;
+
+ virtual void setNumRows( int );
+ virtual void setNumCols( int );
+ virtual void clearCellWidget( int, int );
+
+ bool isKeepEditors() const;
+ void setKeepEditors( const bool );
+
+protected:
+ virtual QWidget* createHeaderEditor( QHeader*, const int, const bool = true );
+ virtual QWidget* createEditor( int, int, bool ) const;
+ virtual void endEdit( int, int, bool, bool );
+ virtual void setCellContentFromEditor( int, int );
+ virtual void setHeaderContentFromEditor( QHeader*, const int, QWidget* );
+
+private:
+ void initEditor( QDS_Datum* );
+ QDS_Datum* datum( const QWidget* ) const;
+
+private:
+ typedef QPtrVector<QDS_Datum> DatumVector;
+ typedef QMap<int, QDS_Datum*> DatumMap;
+ typedef QMap<int, DatumMap> CellMap;
+
+private:
+ QDS_Datum* myHorEdit;
+ QDS_Datum* myVerEdit;
+ DatumVector myRowEdit;
+ DatumVector myColEdit;
+ CellMap myCellEdit;
+ QDS_Datum* myTableEdit;
+ bool myKeepEdits;
+};
+
+#endif
#include <qtextedit.h>
+/*
+ \class QDS_TextEdit
+
+ Datum with control corresponding to text edit. User can enter parameter value in multiple line editor.
+*/
+
/*!
- Constructor.
+ Constructor. Create text edit datum object with datum identifier \aid under widget \aparent.
+ Parameter \aflags define behaviour of datum and set of created subwidgets. Default value of this
+ parameter is QDS::All. Parameter \acomp specify the component name which will be used during search
+ of dictionary item.
*/
QDS_TextEdit::QDS_TextEdit( const QString& id, QWidget* parent, const int flags, const QString& comp )
: QDS_Datum( id, parent, flags, comp )
}
/*!
- Returns string from QTextEdit widget.
+ Returns string from QTextEdit widget. Reimplemented from QDS_Datum.
*/
QString QDS_TextEdit::getString() const
{
}
/*!
- Sets the string into QTextEdit widget.
+ Sets the string into QTextEdit widget. Reimplemented from QDS_Datum.
*/
void QDS_TextEdit::setString( const QString& txt )
{
}
/*!
- Notify about text changing in line edit.
+ Notify about text changing in text edit.
*/
void QDS_TextEdit::onTextChanged()
{
#include "QDS_Validator.h"
/*!
- Class: QDS_IntegerValidator
+ \class QDS_IntegerValidator
+
+ This class to provide validation of user inputted string for datum with 'Integer'
+ value type according to datum properties: minimum value, maximum value, filter.
+
+ Inherits from QIntValidator.
*/
+/*!
+ Constructor. Create empty validator object.
+*/
QDS_IntegerValidator::QDS_IntegerValidator( QObject* p )
: QIntValidator( p )
{
}
+/*!
+ Constructor. Create validator object with filter string \af.
+*/
QDS_IntegerValidator::QDS_IntegerValidator( const QString& f, QObject* p )
: QIntValidator( p ),
myFilter( f )
{
}
+/*!
+ Destructor.
+*/
QDS_IntegerValidator::~QDS_IntegerValidator()
{
}
+/*!
+ Validate the inputed string \ainput. Reimplemented from QIntValidator. Perform
+ standard check by QIntValidator::validate(). If returned state is not Invalid and
+ filter specified then perform validation with filter by QRegExpValidator.
+
+ Returns Invalid if input is invalid according to this validator's rules,
+ Intermediate if it is likely that a little more editing will make the input acceptable
+ and Acceptable if the input is valid.
+*/
QValidator::State QDS_IntegerValidator::validate( QString& input, int& pos ) const
{
State rgState = Acceptable;
}
/*!
- Class: QDS_DoubleValidator
+ \class QDS_DoubleValidator
+
+ This class to provide validation of user inputted string for datum with 'Float'
+ value type according to datum properties: minimum value, maximum value, precision, filter.
+
+ Inherits from QDoubleValidator.
*/
+/*!
+ Constructor. Create empty validator object.
+*/
QDS_DoubleValidator::QDS_DoubleValidator( QObject* p )
: QDoubleValidator( p )
{
}
+/*!
+ Constructor. Create validator object with filter string \af.
+*/
QDS_DoubleValidator::QDS_DoubleValidator( const QString& f, QObject* p )
: QDoubleValidator( p ),
myFilter( f )
{
}
+/*!
+ Destructor.
+*/
QDS_DoubleValidator::~QDS_DoubleValidator()
{
}
+/*!
+ Validate the inputed string \ainput. Reimplemented from QDoubleValidator. Perform
+ standard check by QDoubleValidator::validate(). If returned state is not Invalid and
+ filter specified then perform validation with filter by QRegExpValidator.
+
+ Returns Invalid if input is invalid according to this validator's rules,
+ Intermediate if it is likely that a little more editing will make the input acceptable
+ and Acceptable if the input is valid.
+*/
QValidator::State QDS_DoubleValidator::validate( QString& input, int& pos ) const
{
State rgState = Acceptable;
}
/*!
- Class: QDS_StringValidator
+ \class QDS_StringValidator
+
+ This class to provide validation of user inputted string for datum with 'String'
+ value type according to datum properties: format, filter.
+
+ Inherits from QDoubleValidator.
*/
+/*!
+ Constructor. Create empty validator object.
+*/
QDS_StringValidator::QDS_StringValidator( QObject* p )
: QValidator( p ),
myLen( -1 )
{
}
+/*!
+ Constructor. Create validator object with filter string \af.
+*/
QDS_StringValidator::QDS_StringValidator( const QString& f, QObject* p )
: QValidator( p ),
myFlags( f ),
{
}
+/*!
+ Constructor. Create validator object with filter string \aft and format flags \afg.
+*/
QDS_StringValidator::QDS_StringValidator( const QString& ft, const QString& fg, QObject* p )
: QValidator( p ),
myLen( -1 ),
{
}
+/*!
+ Destructor.
+*/
QDS_StringValidator::~QDS_StringValidator()
{
}
+/*!
+ Returns valid string length. If length not specified -1 returned.
+*/
int QDS_StringValidator::length() const
{
return myLen;
}
-void QDS_StringValidator::setLength( const int l )
-{
- myLen = l;
+/*!
+ Sets the valid string length \al. If value less than zero valid string
+ length not specified.
+*/
+void QDS_StringValidator::setLength( const int l )
+{
+ myLen = l;
}
+/*!
+ Validate the inputed string \ainput. Reimplemented from QValidator. Convert specified
+ string to upper/lower case if the format flags contains specificator 'u'/'l'.
+ If valid string lenght is specified then check given string length. If
+ filter specified then perform validation with filter by QRegExpValidator.
+
+ Returns Invalid if input is invalid according to this validator's rules,
+ Intermediate if it is likely that a little more editing will make the input acceptable
+ and Acceptable if the input is valid.
+*/
QValidator::State QDS_StringValidator::validate( QString& input, int& pos ) const
{
if ( input.isEmpty() )
#include <qvalidator.h>
/*!
- Class: QDS_IntegerValidator
+ class QDS_IntegerValidator
*/
-
class QDS_EXPORT QDS_IntegerValidator : public QIntValidator
{
public:
};
/*!
- Class: QDS_DoubleValidator
+ class QDS_DoubleValidator
*/
-
class QDS_DoubleValidator : public QDoubleValidator
{
public:
};
/*!
- Class: QDS_StringValidator
+ class QDS_StringValidator
*/
-
class QDS_EXPORT QDS_StringValidator : public QValidator
{
public:
-
QDS_StringValidator( QObject* p = 0 );
QDS_StringValidator( const QString& f, QObject* p = 0 );
QDS_StringValidator( const QString& ft, const QString& fg, QObject* p = 0 );
#include "Qtx.h"
#include <qdir.h>
+#include <qbitmap.h>
#include <qstring.h>
#include <qwidget.h>
#include <qlayout.h>
+#include <qpainter.h>
#include <qtoolbar.h>
#include <qgroupbox.h>
#include <qfileinfo.h>
for ( int i = 0; i < num; i++ )
lst.append( scaleColor( i, 0, num - 1 ) );
}
+
+/*!
+ Name: grayscale [static public]
+ Desc: Convert color image to grayscale image.
+*/
+QImage Qtx::grayscale( const QImage& img )
+{
+ QImage res = img;
+
+ int colNum = res.numColors();
+ if ( colNum )
+ {
+ for ( int i = 0; i < colNum; i++ )
+ res.setColor( i, qGray( res.color( i ) ) );
+ }
+ else
+ {
+ for ( int y = 0; y < res.height(); y++ )
+ {
+ for ( int x = 0; x < res.width(); x++ )
+ {
+ QRgb pix = res.pixel( x, y );
+ res.setPixel( x, y, qRgba( qGray( pix ), qGray( pix ), qGray( pix ), qAlpha( pix ) ) );
+ }
+ }
+ }
+
+ return res;
+}
+
+/*!
+ Name: grayscale [static public]
+ Desc: Convert color pixmap to grayscale pixmap.
+*/
+QPixmap Qtx::grayscale( const QPixmap& pix )
+{
+ QPixmap res;
+ res.convertFromImage( grayscale( pix.convertToImage() ) );
+ return res;
+}
+
+/*!
+ Name: transparentImage [static public]
+ Desc: Create transparent image with specified width \aw, height \ah and color depth \ad.
+*/
+QImage Qtx::transparentImage( const int w, const int h, const int d )
+{
+ QImage img;
+ if ( img.create( w, h, d < 0 ? QPixmap::defaultDepth() : d ) )
+ {
+ img.setAlphaBuffer( true );
+ for ( int i = 0; i < img.height(); i++ )
+ for ( int j = 0; j < img.width(); j++ )
+ img.setPixel( j, i, qRgba( 0, 0, 0, 0 ) );
+ }
+ return img;
+}
+
+/*!
+ Name: transparentPixmap [static public]
+ Desc: Create transparent pixmap with specified width \aw, height \ah and color depth \ad.
+*/
+QPixmap Qtx::transparentPixmap( const int w, const int h, const int d )
+{
+ QPixmap pix;
+ QImage img = transparentImage( w, h, d );
+ if ( !img.isNull() )
+ pix.convertFromImage( img );
+ return pix;
+}
+
+/*!
+ Name: composite [static public]
+ Desc: Create composite pixmap. Pixmap 'pix' draws over pixmap 'dest' with coordinates
+ specified relative upper left corner of 'dest'. If 'dest' not given then new empty
+ pixmap with appropriate size created.
+*/
+QPixmap Qtx::composite( const QPixmap& pix, const int x, const int y, const QPixmap& dest )
+{
+ if ( pix.isNull() )
+ return dest;
+
+ int width = QMAX( pix.width() + x, dest.width() );
+ int height = QMAX( pix.height() + y, dest.height() );
+
+ QPixmap res( width, height );
+ QImage img = transparentImage( width, height, 32 );
+
+ QPainter p;
+ p.begin( &res );
+ p.fillRect( 0, 0, width, height, QBrush( white ) );
+
+ if ( !dest.isNull() )
+ {
+ p.drawPixmap( 0, 0, dest );
+ QImage temp = dest.convertToImage();
+ for ( int i = 0; i < temp.width() && i < img.width(); i++ )
+ {
+ for ( int j = 0; j < temp.height() && j < img.height(); j++ )
+ {
+ if ( temp.hasAlphaBuffer() )
+ img.setPixel( i, j, temp.pixel( i, j ) );
+ else
+ {
+ QRgb p = temp.pixel( i, j );
+ img.setPixel( i, j, qRgba( qRed( p ), qGreen( p ), qBlue( p ), 255 ) );
+ }
+ }
+ }
+ }
+
+ p.drawPixmap( x, y, pix );
+ QImage temp = pix.convertToImage();
+ for ( int c = x; c < temp.width() + x && c < img.width(); c++ )
+ {
+ for ( int r = y; r < temp.height() + y && r < img.height(); r++ )
+ {
+ if ( qAlpha( temp.pixel( c - x, r - y ) ) > 0 )
+ img.setPixel( c, r, temp.pixel( c - x, r - y ) );
+ }
+ }
+
+ p.end();
+
+ for ( int ai = 0; ai < img.width(); ai++ )
+ {
+ for ( int aj = 0; aj < img.height(); aj++ )
+ {
+ if ( qAlpha( img.pixel( ai, aj ) ) < 1 )
+ img.setPixel( ai, aj, qRgba( 255, 255, 255, 255 ) );
+ else
+ img.setPixel( ai, aj, qRgba( 0, 0, 0, 0 ) );
+ }
+ }
+
+ QBitmap bmp( width, height );
+ bmp.convertFromImage( img, Qt::ColorMode_Mask | Qt::ThresholdDither );
+ res.setMask( bmp );
+
+ return res;
+}
#endif
#endif
+#include <qimage.h>
+#include <qpixmap.h>
+
class QObject;
class QString;
class QWidget;
static QColor scaleColor( const int, const int, const int );
static void scaleColors( const int, QValueList<QColor>& );
+
+ static QImage grayscale( const QImage& );
+ static QPixmap grayscale( const QPixmap& );
+ static QImage transparentImage( const int, const int, const int = -1 );
+ static QPixmap transparentPixmap( const int, const int, const int = -1 );
+ static QPixmap composite( const QPixmap&, const int, const int, const QPixmap& = QPixmap() );
};
#endif
successfully and false otherwise.
*/
-bool QtxAction::addTo( QWidget* w, int index )
+bool QtxAction::addTo( QWidget* w, const int index )
{
if ( !addTo( w ) )
return false;
if ( !w )
return;
- if ( !w->inherits( "QPopupMenu" ) && !w->inherits( "QMenuBar" ) )
- return; // unsupported widget type
+ QMenuData* pmd = 0;
+
+ if ( w->inherits( "QPopupMenu" ) )
+ pmd = ::qt_cast<QPopupMenu*>( w );
+ else if ( w->inherits( "QMenuBar" ) )
+ pmd = ::qt_cast<QMenuBar*>( w );
- QMenuData* md = 0;
- QMenuData* pmd = dynamic_cast<QMenuData*>( w );
if ( !pmd )
return; // bad widget
-
+
+ QMenuData* md = 0;
QMenuItem* item = pmd->findItem( id, &md );
if ( !item || md != pmd )
return; // item is not found
#include <qaction.h>
#include <qmap.h>
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
class QTX_EXPORT QtxAction : public QAction
{
Q_OBJECT
virtual ~QtxAction();
virtual bool addTo( QWidget* );
- virtual bool addTo( QWidget*, int );
+ virtual bool addTo( QWidget*, const int );
virtual bool removeFrom( QWidget* );
protected:
QMap<QWidget*,int> myMenuIds;
};
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
#endif
QValueList<int> l;
const QMenuData* md = 0;
if ( w->inherits( "QMenuBar" ) )
- md = dynamic_cast<const QMenuData*>( w );
+ md = ::qt_cast<QMenuBar*>( w );
else if ( w->inherits( "QPopupMenu" ) )
- md = dynamic_cast<const QMenuData*>( w );
+ md = ::qt_cast<QPopupMenu*>( w );
if ( md ) {
- for ( int i=0; i < md->count(); i++ )
- l.append( md->idAt( i ) );
+ for ( uint i = 0; i < md->count(); i++ )
+ l.append( md->idAt( i ) );
}
return l;
}
{
const QMenuData* md = 0;
if ( w->inherits( "QMenuBar" ) )
- md = dynamic_cast<const QMenuData*>( w );
+ md = ::qt_cast<QMenuBar*>( w );
else if ( w->inherits( "QPopupMenu" ) )
- md = dynamic_cast<const QMenuData*>( w );
- if ( md ) {
- for ( int i=0, j=0; i < md->count() && j < l.count(); i++, j++ )
- if ( md->idAt( i ) != l[ j ] ) return retId ? md->idAt( i ) : i;
- if ( md->count() > l.count() ) return retId ? md->idAt( md->count()-1 ) : md->count()-1;
+ md = ::qt_cast<QPopupMenu*>( w );
+ if ( md )
+ {
+ for ( uint i = 0, j = 0; i < md->count() && j < l.count(); i++, j++ )
+ if ( md->idAt( i ) != l[ j ] )
+ return retId ? md->idAt( i ) : i;
+ if ( md->count() > l.count() )
+ return retId ? md->idAt( md->count()-1 ) : md->count() - 1;
}
return -1;
}
void dumpMenu( QWidget* w, bool before )
{
- QMenuData* md = dynamic_cast<QMenuData*>( w );
- if ( !w ) return;
- printf(">>> start dump menu (%s) >>>\n", before ? "before" : "after" );
- for( int i = 0; i < md->count(); i++ )
- printf("%d: %d: %s\n",i,md->idAt(i),md->text(md->idAt(i)).latin1() );
- printf("<<< end dump menu (%s) <<<\n", before ? "before" : "after" );
+ if ( !w )
+ return;
+
+ QMenuData* md = 0;
+ if ( w->inherits( "QMenuBar" ) )
+ md = ::qt_cast<QMenuBar*>( w );
+ else if ( w->inherits( "QPopupMenu" ) )
+ md = ::qt_cast<QPopupMenu*>( w );
+
+ if ( !md )
+ return;
+
+ printf( ">>> start dump menu (%s) >>>\n", before ? "before" : "after" );
+ for ( uint i = 0; i < md->count(); i++ )
+ printf( "%d: %d: %s\n", i, md->idAt( i ), md->text( md->idAt( i ) ).latin1() );
+ printf( "<<< end dump menu (%s) <<<\n", before ? "before" : "after" );
}
};
{
NodeList& lst = idMap[it2.current()->group];
int idx = it2.current()->idx;
- if ( idx < 0 || idx >= lst.count() )
+ if ( idx < 0 || idx >= (int)lst.count() )
lst.append( it2.current() );
else
lst.insert( idx, it2.current() );
#ifndef QTX_DOUBLE_VALIDATOR
#define QTX_DOUBLE_VALIDATOR
+#include "Qtx.h"
+
#include <qvalidator.h>
-class QtxDblValidator : public QDoubleValidator
+class QTX_EXPORT QtxDblValidator : public QDoubleValidator
{
Q_OBJECT
QtxDialog::QtxDialog( QWidget* parent, const char* name,
bool modal, bool allowResize, const int f, WFlags wf )
: QDialog( parent, name, modal,
-#ifdef WIN32
wf | WStyle_Customize | WStyle_Title | WStyle_SysMenu |
- ( allowResize ? WStyle_NormalBorder : WStyle_NoBorderEx ) ),
+#ifdef WIN32
+ ( allowResize ? WStyle_NormalBorder : WStyle_NoBorderEx ) |
#else
- wf | WStyle_NormalBorder | WStyle_Customize | WStyle_Title | WStyle_SysMenu ),
+ WStyle_NormalBorder |
#endif
+ ( allowResize ? WStyle_Maximize : 0 ) ),
mySender( 0 ),
myAlignment( 0 ),
myInited( false ),
void QtxDockWindow::setWidget( QWidget* wid )
{
if ( wid )
- wid->reparent( this, QPoint( 0, 0 ), wid->isVisibleTo( wid->parentWidget() ) );
+ {
+ if ( wid->parentWidget() != this )
+ wid->reparent( this, QPoint( 0, 0 ), wid->isVisibleTo( wid->parentWidget() ) );
+ if ( myWatcher )
+ {
+ setCaption( wid->caption() );
+ if ( wid->icon() )
+ setIcon( *wid->icon() );
+ }
+ }
QDockWindow::setWidget( wid );
}
QtxListAction::~QtxListAction()
{
- if ( myFrame )
+ if ( myFrame ) {
myFrame->myAction = 0;
+ delete myFrame;
+ myFrame = 0;
+ }
}
/*!
void QtxListResourceEdit::SelectItem::store()
{
int idx = myList->currentItem();
- if ( myIndex.contains( idx ) )
- setInteger( myIndex[idx] );
+ if ( idx >= 0 )
+ setInteger( myIndex.contains( idx ) ? myIndex[idx] : idx );
}
/*!
{
int id = getInteger( -1 );
- int idx = -1;
- for ( QMap<int, int>::ConstIterator it = myIndex.begin(); it != myIndex.end() && idx == -1; ++it )
+ for ( QMap<int, int>::ConstIterator it = myIndex.begin(); it != myIndex.end(); ++it )
{
- if ( it.data() == id )
- idx = it.key();
+ if ( it.data() == id ) {
+ myList->setCurrentItem( it.key() );
+ return;
+ }
}
-
- myList->setCurrentItem( idx );
+ if ( id >= 0 )
+ myList->setCurrentItem( id );
}
/*!
if( myFileDlg->exec()==QDialog::Accepted )
{
- myFile->setText( myFileDlg->selectedFile() );
+ QString selFile = QDir::convertSeparators( myFileDlg->selectedFile() );
+ myFile->setText( selFile );
}
}
virtual void update();
- QVariant property( const QString& ) const;
+ virtual QVariant property( const QString& ) const;
virtual void setProperty( const QString&, const QVariant& );
virtual void store() = 0;
QString dirs;
if ( ::getenv( envVar ) )
dirs = ::getenv( envVar );
-#ifdef WNT
+#ifdef WIN32
QString dirsep = ";"; // for Windows: ";" is used as directories separator
#else
QString dirsep = "[:|;]"; // for Linux: both ":" and ";" can be used
QStringList prefList = myTranslator.keys();
for ( QStringList::const_iterator it = prefList.begin(); it != prefList.end(); ++it )
removeTranslators( *it );
+ for ( ResListIterator resIt( myResources ); resIt.current(); ++resIt )
+ delete resIt.current();
+ myResources.clear();
+ for ( FormatListIterator formIt( myFormats ); formIt.current(); ++formIt )
+ delete formIt.current();
}
/*!
bool myIsPixmapCached;
bool myIsIgnoreUserValues;
+
+ friend class QtxResourceMgr::Format;
};
/*!
{
public:
Format( const QString& );
- ~Format();
+ virtual ~Format();
QString format() const;
*/
void QtxWorkstack::onContextMenuRequested( QWidget* w, QPoint p )
{
- QtxWorkstackArea* anArea = dynamic_cast<QtxWorkstackArea*>( (QObject*)sender() );
+ QtxWorkstackArea* anArea = ::qt_cast<QtxWorkstackArea*>( (QObject*)sender() );
if ( !anArea )
anArea = activeArea();
myActionsMap[Rename]->addTo( pm );
}
+ Qtx::simplifySeparators( pm );
+
if ( pm->count() )
pm->exec( p );
//Cuts starting '(' symbol and ending '(' symbol
void cutBrackets( QString& parameters )
{
- if ( !parameters.isEmpty() && parameters[0] == '(' && parameters[parameters.length()-1] == ')' )
+ QChar c1 = parameters[0];
+ QChar c2 = parameters[int(parameters.length()-1)];
+ if ( !parameters.isEmpty() && c1 == '(' && c2 == ')' )
parameters = parameters.mid( 1, parameters.length()-2 );
}
{
QString params( parameters );
// 1. begins and ends with brackets
- bool ok = ( params[0] == '(' && params[params.length()-1] == ')' );
+ QChar c1 = params[0];
+ QChar c2 = params[int(params.length()-1)];
+ bool ok = ( c1 == '(' && c2 == ')' );
if ( !ok ) return ok;
::cutBrackets( params );
// 2. has splitter word
int i = 1,
nOpen = 1, // count brackets: '(' increments nOpen, ')' decrements
start = 0;
- while ( i < str.length() ) {
- if ( str[i] == '(' ) {
+ while ( i < (int)str.length() )
+ {
+ if ( str[i] == '(' )
+ {
nOpen++;
if ( nOpen == 1 )
start = i;
}
- else if ( str[i] == ')' ) {
+ else if ( str[i] == ')' )
+ {
nOpen--;
if ( nOpen == 0 )
lst.append( str.mid( start, i-start+1 ) );
QWidget* view = 0;
QObjectList *l = parent->topLevelWidget()->queryList( "QWidget", aName, false, true );
if ( !l->isEmpty() )
- view = dynamic_cast<QWidget*>( l->first() );
+ view = ::qt_cast<QWidget*>( l->first() );
delete l;
return view;
}
// get splitter sizes and store it in the map for future setting
QValueList<int> sizes;
QStringList sizesLst = QStringList::split( ':', ::getValue( params, "sizes" ) );
- for ( QStringList::Iterator it = sizesLst.begin(); it != sizesLst.end(); ++it )
+ QStringList::Iterator it;
+ for ( it = sizesLst.begin(); it != sizesLst.end(); ++it )
sizes.append( (*it).toInt() );
sMap[ splitter ] = sizes;
qApp->processEvents();
// restore splitters' sizes (map of sizes is filled in setSplitters)
- for ( QMap< QSplitter*, QValueList<int> >::Iterator it = sMap.begin(); it != sMap.end(); ++it )
- it.key()->setSizes( it.data() );
+ for ( QMap< QSplitter*, QValueList<int> >::Iterator itm = sMap.begin(); itm != sMap.end(); ++itm )
+ itm.key()->setSizes( itm.data() );
return (*this);
}
{
QFont aFont = font();
aFont.setUnderline( on );
- QColorGroup* aColGrp = new QColorGroup();
+ QColorGroup aColGrp;
QPalette aPal = palette();
if ( !on ) {
- aPal.setColor( QColorGroup::HighlightedText, aColGrp->foreground() );
+ aPal.setColor( QColorGroup::HighlightedText, aColGrp.foreground() );
aPal.setColor( QColorGroup::Highlight, colorGroup().dark().light( DARK_COLOR_LIGHT ) );
setPalette( aPal );
}
else {
- aPal.setColor( QColorGroup::HighlightedText, aColGrp->highlightedText() );
- aPal.setColor( QColorGroup::Highlight, aColGrp->highlight() );
+ aPal.setColor( QColorGroup::HighlightedText, aColGrp.highlightedText() );
+ aPal.setColor( QColorGroup::Highlight, aColGrp.highlight() );
unsetPalette();
}
setFont( aFont );
// Module : SALOME
// $Header$
-# ifndef __HELPWINDOW_H__
-# define __HELPWINDOW_H__
+#ifndef __HELPWINDOW_H__
+#define __HELPWINDOW_H__
-# include <qapplication.h>
-# include <qmainwindow.h>
+#include <qapplication.h>
+#include <qmainwindow.h>
class QTextView;
class HelpWindow : public QMainWindow
{
+ Q_OBJECT
+
public:
HelpWindow( QWidget* parent = 0, const char* name = 0);
~HelpWindow();
private:
QTextView* myTextView;
};
-# endif /* __HELPWINDOW_H__ */
-
+#endif
class IntervalWindow : public QDialog
{
+ Q_OBJECT
+
public:
IntervalWindow( QWidget* parent = 0 );
~IntervalWindow();
class RegWidget : public QMainWindow
{
-
Q_OBJECT
public:
- RegWidget( CORBA::ORB_var &orb , QWidget *parent = 0, const char *name = 0 );
+ RegWidget( CORBA::ORB_var &orb , QWidget *parent = 0, const char *name = 0 );
~RegWidget();
void SetListe();
void SetListeHistory();
};
-# endif /* # ifndef __REGWIDGET_H__ */
-
-
-
-
-
-
-
-
-
+#endif
QString value = resMgr->stringValue( section, param );
QStringList valsOld = QStringList::split( separ, value );
QStringList valsNew = QStringList::split( separ, newValue );
- for ( int i = 0; i < valsNew.count(); i++ )
+ for ( int i = 0; i < (int)valsNew.count(); i++ )
if ( !valsOld.contains( valsNew[i] ) )
valsOld.append( valsNew[i] );
resMgr->setValue( section, param, valsOld.join( separ ) );
using namespace std;
+#define PUBLISH_ENUM(i) \
+{ \
+ PyObject *w; \
+ int rc; \
+ if ( ( w = PyInt_FromLong( i ) ) == NULL ) return; \
+ rc = PyDict_SetItemString( aModuleDict, #i, w ); \
+ Py_DECREF( w ); \
+ if ( rc < 0 ) return; \
+}
+
+// enumeration : view type
+enum {
+ ViewFront, // fron view
+ ViewBack, // back view
+ ViewTop, // top view
+ ViewBottom, // bottom view
+ ViewRight, // right view
+ ViewLeft // left view
+};
+
+
/*!
VSR : 19.04.05 : Reimplemented for new SALOME GUI (SUIT-based)
All methods are implemented using Event mechanism:
- getRenderer()
- getRenderWindow()
- getRenderWindowInteractor()
- These methods open new VTK viewer if there is no one opened.
- In case of error methods return None object in Python.
+ - showTrihedron()
+ These methods (except showTrihedron() ) open new VTK viewer
+ if there is no one opened.
+ In case of error all methods return None object in Python.
*/
static PyObject* GetPyClass(const char* theClassName){
return aPyClass;
}
-static SVTK_ViewWindow* GetVTKViewWindow() {
+// internal enum: find or create VTK window
+enum { __Find, // try to find only
+ __FindOrCreate, // try to find: if not found - create new
+ __Create }; // try to find: if not found - create new
+
+static SVTK_ViewWindow* GetVTKViewWindow( int toCreate = __FindOrCreate ) {
SVTK_ViewWindow* aVW = NULL;
if ( SUIT_Session::session() ) {
// get application
SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
if ( aStudy ) {
// find or create VTK view manager
- SVTK_ViewManager* aVM = dynamic_cast<SVTK_ViewManager*>( anApp->getViewManager( "VTKViewer", true ) );
- if ( aVM ) {
- aVW = dynamic_cast<SVTK_ViewWindow*>( aVM->getActiveView() );
- // VSR : When new view window is created it can be not active yet at this moment,
- // so the following is a some workaround
- if ( !aVW && !aVM->getViews().isEmpty() )
- aVW = dynamic_cast<SVTK_ViewWindow*>( aVM->getViews()[ 0 ] );
+ if ( toCreate == __Create ) {
+ SVTK_ViewManager* aVM = dynamic_cast<SVTK_ViewManager*>( anApp->createViewManager( "VTKViewer" ) );
+ if ( aVM ) {
+ aVW = dynamic_cast<SVTK_ViewWindow*>( aVM->getActiveView() );
+ if ( !aVW )
+ aVW = dynamic_cast<SVTK_ViewWindow*>( aVM->createViewWindow() );
+ // VSR : When new view window is created it can be not active yet at this moment,
+ // so the following is a some workaround
+ if ( !aVW && !aVM->getViews().isEmpty() )
+ aVW = dynamic_cast<SVTK_ViewWindow*>( aVM->getViews()[ 0 ] );
+ }
+ }
+ else {
+ SVTK_ViewManager* aVM = dynamic_cast<SVTK_ViewManager*>( anApp->getViewManager( "VTKViewer", toCreate == __FindOrCreate ) );
+ if ( aVM ) {
+ aVW = dynamic_cast<SVTK_ViewWindow*>( aVM->getActiveView() );
+ // VSR : When new view window is created it can be not active yet at this moment,
+ // so the following is a some workaround
+ if ( !aVW && !aVM->getViews().isEmpty() )
+ aVW = dynamic_cast<SVTK_ViewWindow*>( aVM->getViews()[ 0 ] );
+ }
}
}
}
}
/*!
- Get VTK renderer (opens new VTK window if there is no one opened)
+ Get VTK renderer.
+ Always opens new VTK window if <toCreate> parameter is non zero.
+ Otherwise opens new VTK window only if there is no one opened.
*/
class TGetRendererEvent: public SALOME_Event {
public:
typedef PyObject* TResult;
TResult myResult;
- TGetRendererEvent() : myResult( Py_None ) {}
+ int myCreate;
+ TGetRendererEvent( bool toCreate )
+ : myResult( Py_None ), myCreate( toCreate ) {}
virtual void Execute() {
- if( SVTK_ViewWindow* aVTKViewWindow = GetVTKViewWindow() ) {
+ if( SVTK_ViewWindow* aVTKViewWindow = GetVTKViewWindow( myCreate ? __Create : __FindOrCreate ) ) {
PyObject* aPyClass = GetPyClass("vtkRenderer");
vtkRenderer* aVTKObject = aVTKViewWindow->getRenderer();
myResult = PyVTKObject_New(aPyClass,aVTKObject);
};
extern "C" PyObject *libSalomePy_getRenderer(PyObject *self, PyObject *args)
{
- //return ProcessEvent( new TGetRendererEvent() );
- PyObject * aResult;
- Py_BEGIN_ALLOW_THREADS // PAL12755
- aResult = ProcessEvent( new TGetRendererEvent() );
- Py_END_ALLOW_THREADS // PAL12755
+ PyObject* aResult = Py_None;
+ int toCreate = 0;
+ if ( !PyArg_ParseTuple(args, "|i:getRenderer", &toCreate) )
+ PyErr_Print();
+ else
+ aResult = ProcessEvent( new TGetRendererEvent( toCreate ) );
return aResult;
}
/*!
- Get VTK render window (opens new VTK window if there is no one opened)
+ Get VTK render window.
+ Always opens new VTK window if <toCreate> parameter is non zero.
+ Otherwise opens new VTK window only if there is no one opened.
*/
class TGetRenderWindowEvent: public SALOME_Event {
public:
typedef PyObject* TResult;
TResult myResult;
- TGetRenderWindowEvent() : myResult( Py_None ) {}
+ int myCreate;
+ TGetRenderWindowEvent( bool toCreate )
+ : myResult( Py_None ), myCreate( toCreate ) {}
virtual void Execute() {
- if( SVTK_ViewWindow* aVTKViewWindow = GetVTKViewWindow() ) {
+ if( SVTK_ViewWindow* aVTKViewWindow = GetVTKViewWindow( myCreate ? __Create : __FindOrCreate ) ) {
PyObject* aPyClass = GetPyClass("vtkRenderWindow");
vtkRenderWindow* aVTKObject = aVTKViewWindow->getRenderWindow();
myResult = PyVTKObject_New(aPyClass,aVTKObject);
};
extern "C" PyObject *libSalomePy_getRenderWindow(PyObject *self, PyObject *args)
{
- //return ProcessEvent( new TGetRenderWindowEvent() );
- PyObject * aResult;
- Py_BEGIN_ALLOW_THREADS // PAL12755
- aResult = ProcessEvent( new TGetRenderWindowEvent() );
- Py_END_ALLOW_THREADS // PAL12755
+ PyObject* aResult = Py_None;
+ int toCreate = 0;
+ if ( !PyArg_ParseTuple(args, "|i:getRenderWindow", &toCreate) )
+ PyErr_Print();
+ else
+ aResult = ProcessEvent( new TGetRenderWindowEvent( toCreate ) );
return aResult;
}
/*!
- Get VTK render window interactor (opens new VTK window if there is no one opened)
+ Get VTK render window interactor.
+ Always opens new VTK window if <toCreate> parameter is non zero.
+ Otherwise opens new VTK window only if there is no one opened.
*/
class TGetRenderWindowInteractorEvent: public SALOME_Event {
public:
typedef PyObject* TResult;
TResult myResult;
- TGetRenderWindowInteractorEvent() : myResult( Py_None ) {}
+ int myCreate;
+ TGetRenderWindowInteractorEvent( bool toCreate )
+ : myResult( Py_None ), myCreate( toCreate ) {}
virtual void Execute() {
- if( SVTK_ViewWindow* aVTKViewWindow = GetVTKViewWindow() ) {
+ if( SVTK_ViewWindow* aVTKViewWindow = GetVTKViewWindow( myCreate ? __Create : __FindOrCreate ) ) {
PyObject* aPyClass = GetPyClass("vtkRenderWindowInteractor");
vtkRenderWindowInteractor* aVTKObject = aVTKViewWindow->getInteractor();
myResult = PyVTKObject_New(aPyClass,aVTKObject);
};
extern "C" PyObject *libSalomePy_getRenderWindowInteractor(PyObject *self, PyObject *args)
{
- //return ProcessEvent( new TGetRenderWindowInteractorEvent() );
- PyObject * aResult;
- Py_BEGIN_ALLOW_THREADS // PAL12755
- aResult = ProcessEvent( new TGetRenderWindowInteractorEvent() );
- Py_END_ALLOW_THREADS // PAL12755
+ PyObject* aResult = Py_None;
+ int toCreate = 0;
+ if ( !PyArg_ParseTuple(args, "|i:getRenderWindowInteractor", &toCreate) )
+ PyErr_Print();
+ else
+ aResult = ProcessEvent( new TGetRenderWindowInteractorEvent( toCreate ) );
return aResult;
}
+/*!
+ Show/hide trihedron in the current VTK viewer (if there is one)
+*/
+extern "C" PyObject *libSalomePy_showTrihedron(PyObject *self, PyObject *args)
+{
+ class TEvent: public SALOME_Event {
+ public:
+ int myShow;
+ TEvent( int bShow )
+ : myShow( bShow ) {}
+ virtual void Execute() {
+ if( SVTK_ViewWindow* aVTKViewWindow = GetVTKViewWindow( __Find ) ) {
+ if ( aVTKViewWindow->isTrihedronDisplayed() != myShow )
+ aVTKViewWindow->onViewTrihedron();
+ }
+ }
+ };
+
+ PyObject* aResult = Py_None;
+ int bShow = 0;
+ if ( !PyArg_ParseTuple(args, "i:showTrihedron", &bShow) )
+ PyErr_Print();
+ else
+ ProcessVoidEvent( new TEvent( bShow ) );
+ return aResult;
+}
+
+/*!
+ Fit all the contents in the current VTK viewer (if there is one)
+*/
+extern "C" PyObject *libSalomePy_fitAll(PyObject *self, PyObject *args)
+{
+ class TEvent: public SALOME_Event {
+ public:
+ TEvent() {}
+ virtual void Execute() {
+ if( SVTK_ViewWindow* aVTKViewWindow = GetVTKViewWindow( __Find ) ) {
+ aVTKViewWindow->onFitAll();
+ }
+ }
+ };
+
+ ProcessVoidEvent( new TEvent() );
+ return Py_None;
+}
+
+/*!
+ Set view type fot the current VTK viewer (if there is one)
+*/
+extern "C" PyObject *libSalomePy_setView(PyObject *self, PyObject *args)
+{
+ class TEvent: public SALOME_Event {
+ public:
+ long myType;
+ TEvent( long type ) : myType( type) {}
+ virtual void Execute() {
+ if( SVTK_ViewWindow* aVTKViewWindow = GetVTKViewWindow( __Find ) ) {
+ switch( myType ) {
+ case ViewFront:
+ aVTKViewWindow->onFrontView(); break;
+ case ViewBack:
+ aVTKViewWindow->onBackView(); break;
+ case ViewTop:
+ aVTKViewWindow->onTopView(); break;
+ case ViewBottom:
+ aVTKViewWindow->onBottomView(); break;
+ case ViewRight:
+ aVTKViewWindow->onRightView(); break;
+ case ViewLeft:
+ aVTKViewWindow->onLeftView(); break;
+ default:
+ PyErr_Format(PyExc_ValueError,"setView%: wrong parameter value; must be between %d and %d", ViewFront, ViewLeft );
+ break;
+ }
+ }
+ }
+ };
+
+ long type = -1;
+ if ( !PyArg_ParseTuple(args, "l:setView", &type) )
+ PyErr_Print();
+ else {
+ ProcessVoidEvent( new TEvent( type ) );
+ if( PyErr_Occurred() )
+ PyErr_Print();
+ }
+ return Py_None;
+}
+
+/*!
+ Reset contents of the current VTK viewer (if there is one)
+ to the default state
+*/
+extern "C" PyObject *libSalomePy_resetView(PyObject *self, PyObject *args)
+{
+ class TEvent: public SALOME_Event {
+ public:
+ TEvent() {}
+ virtual void Execute() {
+ if( SVTK_ViewWindow* aVTKViewWindow = GetVTKViewWindow( __Find ) ) {
+ aVTKViewWindow->onResetView();
+ }
+ }
+ };
+
+ ProcessVoidEvent( new TEvent() );
+ return Py_None;
+}
+
/*!
Library initialization
*/
static PyMethodDef Module_Methods[] =
{
- { "getRenderer", libSalomePy_getRenderer, METH_NOARGS },
- { "getRenderWindow", libSalomePy_getRenderWindow, METH_NOARGS },
- { "getRenderWindowInteractor", libSalomePy_getRenderWindow, METH_NOARGS },
+ { "getRenderer", libSalomePy_getRenderer, METH_VARARGS },
+ { "getRenderWindow", libSalomePy_getRenderWindow, METH_VARARGS },
+ { "getRenderWindowInteractor", libSalomePy_getRenderWindowInteractor, METH_VARARGS },
+ { "showTrihedron", libSalomePy_showTrihedron, METH_VARARGS },
+ { "fitAll", libSalomePy_fitAll, METH_NOARGS },
+ { "setView", libSalomePy_setView, METH_VARARGS },
+ { "resetView", libSalomePy_resetView, METH_NOARGS },
{ NULL, NULL }
};
extern "C" void initlibSalomePy()
{
static char modulename[] = "libSalomePy";
- /*PyObject* aModule = */Py_InitModule(modulename, Module_Methods);
- if(PyErr_Occurred()){
+ // init module
+ PyObject* aModule = Py_InitModule(modulename, Module_Methods);
+ if( PyErr_Occurred() ) {
PyErr_Print();
return;
}
+ // get module's dictionary
+ PyObject *aModuleDict = PyModule_GetDict( aModule );
+ if ( aModuleDict == NULL )
+ return;
+ // add View type enumeration
+ PUBLISH_ENUM( ViewFront );
+ PUBLISH_ENUM( ViewBack );
+ PUBLISH_ENUM( ViewTop );
+ PUBLISH_ENUM( ViewBottom );
+ PUBLISH_ENUM( ViewRight );
+ PUBLISH_ENUM( ViewLeft );
}
QT_VERS = Qt_3_3_0
endif
+ifeq ($(QT_VERS),Qt_3_3_6)
+QT_VERS = Qt_3_3_0
+endif
+
# Sip flags
SIP_FLAGS = -t WS_X11 -t $(QT_VERS) $(PYQT_SIPFLAGS) -s ".cc" -c . -I $(PYQT_SIPS)
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+#include "PyInterp_Dispatcher.h"
#include "SALOME_PYQT_Module.h"
-#include "PyInterp_Dispatcher.h"
+
#include "SUIT_ResourceMgr.h"
#include "STD_MDIDesktop.h"
#include "STD_TabDesktop.h"
#include "SalomeApp_Application.h"
#include "SalomeApp_Study.h"
+#include "LightApp_Preferences.h"
#include "QtxWorkstack.h"
#include "QtxActionMenuMgr.h"
#include <qmenubar.h>
#include <qpopupmenu.h>
+#ifndef WIN32
#include "SALOME_PYQT_SipDefs.h"
-#if defined(SIP_VERS_v4_old) || defined(SIP_VERS_v4_new)
-#include "sipAPISalomePyQtGUI.h"
-#else
-#include "sipSalomePyQtGUIDeclSalomePyQtGUI.h"
#endif
+#include "sipAPISalomePyQtGUI.h"
-#include <sipqtQWidget.h>
-#include <sipqtQPopupMenu.h>
+#include "sipqtQWidget.h"
+#include "sipqtQPopupMenu.h"
#include <CORBA.h>
if ( menuMgr() )
connect( menuMgr(), SIGNAL( menuHighlighted( int, int ) ),
this, SLOT( onMenuHighlighted( int, int ) ) );
+ connect( getApp(), SIGNAL( preferenceChanged( const QString&, const QString&, const QString& ) ),
+ this, SLOT( preferenceChanged( const QString&, const QString&, const QString& ) ) );
// create menus & toolbars from XML file if required
if ( myXmlHandler )
if ( menuMgr() )
disconnect( menuMgr(), SIGNAL( menuHighlighted( int, int ) ),
this, SLOT( onMenuHighlighted( int, int ) ) );
+ disconnect( getApp(), SIGNAL( preferenceChanged( const QString&, const QString&, const QString& ) ),
+ this, SLOT( preferenceChanged( const QString&, const QString&, const QString& ) ) );
// remove menus & toolbars created from XML file if required
if ( myXmlHandler )
return SalomeApp_Module::deactivateModule( theStudy );
}
+/*!
+ Preferences changing (application) - called when preference is changed
+*/
+void SALOME_PYQT_Module::preferenceChanged( const QString& module,
+ const QString& section,
+ const QString& setting )
+{
+ MESSAGE( "SALOME_PYQT_Module::preferenceChanged");
+
+ // perform synchronous request to Python event dispatcher
+ class Event : public PyInterp_LockRequest
+ {
+ public:
+ Event( PyInterp_base* _py_interp,
+ SALOME_PYQT_Module* _obj,
+ const QString& _section,
+ const QString& _setting )
+ : PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true)
+ myObj ( _obj ),
+ mySection( _section ),
+ mySetting( _setting ) {}
+
+ protected:
+ virtual void execute()
+ {
+ myObj->prefChanged( mySection, mySetting );
+ }
+
+ private:
+ SALOME_PYQT_Module* myObj;
+ QString mySection, mySetting;
+ };
+
+ if ( module != moduleName() ) {
+ // Module's preferences are processed by preferencesChanged() method
+ // ...
+ // Posting the request only if dispatcher is not busy!
+ // Executing the request synchronously
+ if ( !PyInterp_Dispatcher::Get()->IsBusy() )
+ PyInterp_Dispatcher::Get()->Exec( new Event( myInterp, this, section, setting ) );
+ }
+}
+
/*!
* Called when study desktop is activated.
* Used for notifying about changing of the active study.
PyInterp_Dispatcher::Get()->Exec( new PopupMenuEvent( myInterp, this, theContext, thePopupMenu ) );
}
+/*!
+ * Export preferences for the Python module.
+ * Called only once when the first instance of the module is created.
+ */
+void SALOME_PYQT_Module::createPreferences()
+{
+ MESSAGE( "SALOME_PYQT_Module::createPreferences");
+ // perform synchronous request to Python event dispatcher
+ class Event : public PyInterp_LockRequest
+ {
+ public:
+ Event( PyInterp_base* _py_interp,
+ SALOME_PYQT_Module* _obj )
+ : PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true)
+ myObj ( _obj ) {}
+
+ protected:
+ virtual void execute()
+ {
+ myObj->initPreferences();
+ }
+
+ private:
+ SALOME_PYQT_Module* myObj;
+ };
+
+ // Posting the request only if dispatcher is not busy!
+ // Executing the request synchronously
+ if ( !PyInterp_Dispatcher::Get()->IsBusy() )
+ PyInterp_Dispatcher::Get()->Exec( new Event( myInterp, this ) );
+}
+
/*!
* Defines the dockable window associated with the module.
* To fill the list of windows the correspondind Python module's windows()
}
}
+/*!
+ Preferences changing (module) - called when the module's preferences are changed
+*/
+void SALOME_PYQT_Module::preferencesChanged( const QString& section, const QString& setting )
+{
+ MESSAGE( "SALOME_PYQT_Module::preferencesChanged");
+
+ // perform synchronous request to Python event dispatcher
+ class Event : public PyInterp_LockRequest
+ {
+ public:
+ Event( PyInterp_base* _py_interp,
+ SALOME_PYQT_Module* _obj,
+ const QString& _section,
+ const QString& _setting )
+ : PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true)
+ myObj ( _obj ),
+ mySection( _section ),
+ mySetting( _setting ) {}
+
+ protected:
+ virtual void execute()
+ {
+ myObj->prefChanged( mySection, mySetting );
+ }
+
+ private:
+ SALOME_PYQT_Module* myObj;
+ QString mySection, mySetting;
+ };
+
+ // Posting the request only if dispatcher is not busy!
+ // Executing the request synchronously
+ if ( !PyInterp_Dispatcher::Get()->IsBusy() )
+ PyInterp_Dispatcher::Get()->Exec( new Event( myInterp, this, section, setting ) );
+}
+
+
/*!
* Performs internal initialization
* - initializes/gets the Python interpreter (one per study)
// ... first put default values
myWindowsMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
myWindowsMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
- // VSR: LogWindow is not yet implemented
- // myWindowsMap.insert( SalomeApp_Application::WT_LogWindow, Qt::DockBottom );
+ myWindowsMap.insert( SalomeApp_Application::WT_LogWindow, Qt::DockBottom );
if(PyObject_HasAttrString(myModule , "windows")){
PyObjWrapper res1( PyObject_CallMethod( myModule, "windows", "" ) );
*/
QString SALOME_PYQT_Module::engineIOR() const
{
+ QString anIOR = QString::null;
if ( !CORBA::is_nil( getEngine() ) )
return QString( getApp()->orb()->object_to_string( getEngine() ) );
return QString( "" );
}
}
+/*!
+ * Initialises preferences for the module
+ * - calls Python module's createPreferences() method
+ */
+void SALOME_PYQT_Module::initPreferences()
+{
+ // Python interpreter should be initialized and Python module should be
+ // import first
+ if ( !myInterp || !myModule )
+ return;
+
+ // temporary set myInitModule because createPreferences() method
+ // might be called during the module intialization process
+ myInitModule = this;
+
+ if ( PyObject_HasAttrString(myModule , "createPreferences") ) {
+ PyObjWrapper res( PyObject_CallMethod( myModule, "createPreferences", "" ) );
+ if( !res ) {
+ PyErr_Print();
+ }
+ }
+
+ myInitModule = 0;
+}
+
/*!
* Initialises python subinterpreter (one per study)
*/
} //__CALL_OLD_METHODS__
}
+/*!
+ * Preference changing callback function
+ * - calls Python module's preferenceChanged(string,string,string) method
+ */
+void SALOME_PYQT_Module::prefChanged( const QString& section, const QString& setting )
+{
+ // Python interpreter should be initialized and Python module should be
+ // import first
+ if ( !myInterp || !myModule )
+ return;
+
+ if ( PyObject_HasAttrString(myModule , "preferenceChanged") ) {
+ PyObjWrapper res( PyObject_CallMethod( myModule,
+ "preferenceChanged",
+ "ss",
+ section.latin1(),
+ setting.latin1() ) );
+ if( !res ) {
+ PyErr_Print();
+ }
+ }
+}
+
/*!
* Returns default menu group
*/
}
return a;
}
+
/*!
* Load icon from resource file
*/
return false;
}
+/*!
+ * The next methods call the parent implementation.
+ * This is done to open protected methods from LightApp_Module class.
+ */
+
+int SALOME_PYQT_Module::addGlobalPreference( const QString& label )
+{
+ LightApp_Preferences* pref = preferences();
+ if ( !pref )
+ return -1;
+
+ return pref->addPreference( label, -1 );
+}
+
+int SALOME_PYQT_Module::addPreference( const QString& label )
+{
+ return SalomeApp_Module::addPreference( label );
+}
+
+int SALOME_PYQT_Module::addPreference( const QString& label,
+ const int pId, const int type,
+ const QString& section,
+ const QString& param )
+{
+ return SalomeApp_Module::addPreference( label, pId, type, section, param );
+}
+
+QVariant SALOME_PYQT_Module::preferenceProperty( const int id,
+ const QString& prop ) const
+{
+ QVariant v = SalomeApp_Module::preferenceProperty( id, prop );
+ return v;
+}
+
+void SALOME_PYQT_Module::setPreferenceProperty( const int id,
+ const QString& prop,
+ const QVariant& var )
+{
+ SalomeApp_Module::setPreferenceProperty( id, prop, var );
+}
+
// SALOME_PYQT_XmlHandler class implementation
// gets an tag name for the dom element [ static ]
/* context popup menu request */
void contextMenuPopup( const QString&, QPopupMenu*, QString& );
+ /* create preferences */
+ void createPreferences();
+
/* get module engine IOR */
virtual QString engineIOR() const;
/* load icon from resource file */
QIconSet loadIcon( const QString& fileName );
+ /* working with preferences : open protected methods */
+ int addGlobalPreference( const QString& );
+ int addPreference( const QString& );
+ int addPreference( const QString&, const int, const int = -1,
+ const QString& = QString::null,
+ const QString& = QString::null );
+ QVariant preferenceProperty( const int, const QString& ) const;
+ void setPreferenceProperty( const int, const QString&, const QVariant& );
+
/* Show/hide menus/toolbars */
void setMenuShown( const bool );
void setToolShown( const bool );
+ /* Preferences changing (module) */
+ void preferencesChanged( const QString&, const QString& );
+
public slots:
/* activation */
virtual bool activateModule( SUIT_Study* );
/* deactivation */
virtual bool deactivateModule( SUIT_Study* );
+ /* Preferences changing (application) */
+ void preferenceChanged( const QString&, const QString&, const QString& );
+
/******************************
* Internal methods
******************************/
void guiEvent( const int );
/* Menu highlight processing */
void menuHighlight( const int, const int );
+ /* Init preferences */
+ void initPreferences();
/* initialize a Python subinterpreter */
void initInterp ( int );
/* set workspace to Python GUI module */
void setWorkSpace();
+ /* preferences changing */
+ void prefChanged( const QString&, const QString& );
+
friend class SALOME_PYQT_XmlHandler;
};
ifeq ($(QT_VERS),Qt_3_3_4)
QT_VERS = Qt_3_3_0
endif
+ifeq ($(QT_VERS),Qt_3_3_6)
+QT_VERS = Qt_3_3_0
+endif
# Sip flags
SIP_FLAGS = -t WS_X11 -t $(QT_VERS) $(PYQT_SIPFLAGS) -s ".cc" -c . -I $(PYQT_SIPS)
#include "LightApp_SelectionMgr.h"
#include "OB_Browser.h"
#include "QtxAction.h"
+#include "LogWindow.h"
using namespace std;
ProcessVoidEvent( new TEvent( name, value, autoValue ) );
}
+/*!
+ SalomePyQt::addBoolSetting
+ Adds an boolean setting to the application preferences
+ <autoValue> parameter is obsolete parameter and currently not used. To be removed lately.
+ This function is obsolete. Use addSetting() instead.
+*/
+void SalomePyQt::addBoolSetting( const QString& name, const bool value, bool autoValue )
+{
+ class TEvent: public SALOME_Event {
+ QString myName;
+ bool myValue;
+ bool myAutoValue;
+ public:
+ TEvent( const QString& name, const bool value, bool autoValue )
+ : myName( name ), myValue( value ), myAutoValue( autoValue ) {}
+ virtual void Execute() {
+ if ( SUIT_Session::session() ) {
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+ QStringList sl = QStringList::split( ":", myName );
+ QString _sec = sl.count() > 1 ? sl[ 0 ].stripWhiteSpace() : QString( DEFAULT_SECTION );
+ QString _nam = sl.count() > 1 ? sl[ 1 ].stripWhiteSpace() : sl.count() > 0 ? sl[ 0 ].stripWhiteSpace() : QString( "" );
+ if ( !_sec.isEmpty() && !_nam.isEmpty() )
+ resMgr->setValue( _sec, _nam, myValue );
+ }
+ }
+ };
+ ProcessVoidEvent( new TEvent( name, value, autoValue ) );
+}
+
/*!
SalomePyQt::removeSettings
Removes a setting from the application preferences
ProcessVoidEvent( new TEvent( section, name, value ) );
}
+/*!
+ SalomePyQt::addSetting
+ Adds a boolean setting to the application preferences
+ (note: the last "dumb" parameter is used in order to avoid
+ sip compilation error because of conflicting int and bool types)
+*/
+void SalomePyQt::addSetting( const QString& section, const QString& name, const bool value, const int )
+{
+ class TEvent: public SALOME_Event {
+ QString mySection;
+ QString myName;
+ bool myValue;
+ public:
+ TEvent( const QString& section, const QString& name, bool value )
+ : mySection( section ), myName( name ), myValue( value ) {}
+ virtual void Execute() {
+ if ( SUIT_Session::session() ) {
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+ if ( !mySection.isEmpty() && !myName.isEmpty() )
+ resMgr->setValue( mySection, myName, myValue );
+ }
+ }
+ };
+ ProcessVoidEvent( new TEvent( section, name, value ) );
+}
+
/*!
SalomePyQt::addSetting
Adds a string setting to the application preferences
/*!
\return an double setting from the application preferences
*/
-double SalomePyQt::doubleSetting( const QString& section, const QString& name, const int def )
+double SalomePyQt::doubleSetting( const QString& section, const QString& name, const double def )
{
return ProcessEvent( new TGetDblSettingEvent( section, name, def ) );
}
ProcessVoidEvent( new TEvent( section, name ) );
}
+/*!
+ SalomePyQt::hasSetting
+ Returns True if the settings exists
+*/
+class THasColorSettingEvent: public SALOME_Event {
+public:
+ typedef bool TResult;
+ TResult myResult;
+ QString mySection;
+ QString myName;
+ THasColorSettingEvent( const QString& section, const QString& name )
+ : mySection( section ), myName( name ) {}
+ virtual void Execute() {
+ if ( SUIT_Session::session() ) {
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+ myResult = resMgr->hasValue( mySection, myName );
+ }
+ }
+};
+bool SalomePyQt::hasSetting( const QString& section, const QString& name )
+{
+ return ProcessEvent( new THasColorSettingEvent( section, name ) );
+}
+
/*!
SalomePyQt::getFileName
Displays 'Open/Save file' dialog box and returns a user's choice (file name)
return ProcessEvent( new TClearMenuEvent( id, menu, removeActions ) );
}
+/*!
+ SalomePyQt::addGlobalPreference
+ Adds global (not module) preferences group
+ */
+class TAddGlobalPrefEvent: public SALOME_Event {
+public:
+ typedef int TResult;
+ TResult myResult;
+ QString myLabel;
+ TAddGlobalPrefEvent( const QString& label )
+ : myResult( -1 ), myLabel( label ) {}
+ virtual void Execute() {
+ if ( SalomeApp_Application* anApp = getApplication() ) {
+ SALOME_PYQT_Module* module = SALOME_PYQT_Module::getInitModule();
+ if ( !module )
+ module = dynamic_cast<SALOME_PYQT_Module*>( anApp->activeModule() );
+ if ( module )
+ myResult = module->addGlobalPreference( myLabel );
+ }
+ }
+};
+int SalomePyQt::addGlobalPreference( const QString& label )
+{
+ return ProcessEvent( new TAddGlobalPrefEvent( label ) );
+}
+
+/*!
+ SalomePyQt::addPreference
+ Adds preference
+ */
+class TAddPrefEvent: public SALOME_Event {
+public:
+ typedef int TResult;
+ TResult myResult;
+ QString myLabel;
+ TAddPrefEvent( const QString& label )
+ : myResult( -1 ), myLabel( label ) {}
+ virtual void Execute() {
+ if ( SalomeApp_Application* anApp = getApplication() ) {
+ SALOME_PYQT_Module* module = SALOME_PYQT_Module::getInitModule();
+ if ( !module )
+ module = dynamic_cast<SALOME_PYQT_Module*>( anApp->activeModule() );
+ if ( module )
+ myResult = module->addPreference( myLabel );
+ }
+ }
+};
+int SalomePyQt::addPreference( const QString& label )
+{
+ return ProcessEvent( new TAddPrefEvent( label ) );
+}
+
+/*!
+ SalomePyQt::addPreference
+ Adds preference
+ */
+class TAddPrefParamEvent: public SALOME_Event {
+public:
+ typedef int TResult;
+ TResult myResult;
+ QString myLabel;
+ int myPId;
+ int myType;
+ QString mySection;
+ QString myParam;
+ TAddPrefParamEvent( const QString& label,
+ const int pId, const int type,
+ const QString& section,
+ const QString& param )
+ : myResult( -1 ),
+ myLabel( label ), myPId( pId ), myType( type ),
+ mySection( section ), myParam ( param ) {}
+ virtual void Execute() {
+ if ( SalomeApp_Application* anApp = getApplication() ) {
+ SALOME_PYQT_Module* module = SALOME_PYQT_Module::getInitModule();
+ if ( !module )
+ module = dynamic_cast<SALOME_PYQT_Module*>( anApp->activeModule() );
+ if ( module )
+ myResult = module->addPreference( myLabel, myPId, myType, mySection, myParam );
+ }
+ }
+};
+int SalomePyQt::addPreference( const QString& label, const int pId, const int type,
+ const QString& section, const QString& param )
+{
+ return ProcessEvent( new TAddPrefParamEvent( label, pId, type, section, param ) );
+}
+
+/*!
+ SalomePyQt::preferenceProperty
+ Gets the property value for the given (by id) preference
+ */
+class TPrefPropEvent: public SALOME_Event {
+public:
+ typedef QVariant TResult;
+ TResult myResult;
+ int myId;
+ QString myProp;
+ TPrefPropEvent( const int id, const QString& prop )
+ : myId( id ), myProp( prop )
+ {
+ myResult = QVariant();
+ }
+ virtual void Execute() {
+ if ( SalomeApp_Application* anApp = getApplication() ) {
+ SALOME_PYQT_Module* module = SALOME_PYQT_Module::getInitModule();
+ if ( !module )
+ module = dynamic_cast<SALOME_PYQT_Module*>( anApp->activeModule() );
+ if ( module )
+ myResult = module->preferenceProperty( myId, myProp );
+ }
+ }
+};
+QVariant SalomePyQt::preferenceProperty( const int id, const QString& prop )
+{
+ return ProcessEvent( new TPrefPropEvent( id, prop ) );
+}
+
+/*!
+ SalomePyQt::setPreferenceProperty
+ Sets the property value for the given (by id) preference
+ */
+void SalomePyQt::setPreferenceProperty( const int id,
+ const QString& prop,
+ const QVariant& var )
+{
+ class TEvent: public SALOME_Event {
+ int myId;
+ QString myProp;
+ QVariant myVar;
+ public:
+ TEvent( const int id, const QString& prop, const QVariant& var )
+ : myId( id ), myProp( prop ), myVar( var ) {}
+ virtual void Execute() {
+ if ( SalomeApp_Application* anApp = getApplication() ) {
+ SALOME_PYQT_Module* module = SALOME_PYQT_Module::getInitModule();
+ if ( !module )
+ module = dynamic_cast<SALOME_PYQT_Module*>( anApp->activeModule() );
+ if ( module )
+ module->setPreferenceProperty( myId, myProp, myVar );
+ }
+ }
+ };
+ ProcessVoidEvent( new TEvent( id, prop, var) );
+}
+
+/*!
+ SalomePyQt::addPreferenceProperty
+ Adds the property value to the list of values
+ for the given (by id) preference
+
+ This method allows creating properties which are QValueList<QVariant>
+ - there is no way to pass such values directly to QVariant parameter
+ from Python
+ */
+void SalomePyQt::addPreferenceProperty( const int id,
+ const QString& prop,
+ const int idx,
+ const QVariant& var )
+{
+ class TEvent: public SALOME_Event {
+ int myId;
+ QString myProp;
+ int myIdx;
+ QVariant myVar;
+ public:
+ TEvent( const int id, const QString& prop, const int idx, const QVariant& var )
+ : myId( id ), myProp( prop ), myIdx( idx), myVar( var ) {}
+ virtual void Execute() {
+ if ( SalomeApp_Application* anApp = getApplication() ) {
+ SALOME_PYQT_Module* module = SALOME_PYQT_Module::getInitModule();
+ if ( !module )
+ module = dynamic_cast<SALOME_PYQT_Module*>( anApp->activeModule() );
+ if ( module ) {
+ QVariant var = module->preferenceProperty( myId, myProp );
+ if ( var.isValid() ) {
+ if ( var.type() == QVariant::StringList ) {
+ QStringList sl = var.asStringList();
+ if ( myIdx >= 0 && myIdx < sl.count() )
+ sl[myIdx] = myVar.asString();
+ else
+ sl.append( myVar.asString() );
+ module->setPreferenceProperty( myId, myProp, sl );
+ }
+ else if ( var.type() == QVariant::List ) {
+ QValueList<QVariant> vl = var.asList();
+ if ( myIdx >= 0 && myIdx < vl.count() )
+ vl[myIdx] = myVar;
+ else
+ vl.append( myVar );
+ module->setPreferenceProperty( myId, myProp, vl );
+ }
+ }
+ else {
+ QValueList<QVariant> vl;
+ vl.append( myVar );
+ module->setPreferenceProperty( myId, myProp, vl );
+ }
+ }
+ }
+ }
+ };
+ ProcessVoidEvent( new TEvent( id, prop, idx, var) );
+}
+
+/*!
+ SalomePyQt::message
+ Puts the message to the Log output window
+ */
+void SalomePyQt::message( const QString& msg, bool addSeparator )
+{
+ class TEvent: public SALOME_Event {
+ QString myMsg;
+ bool myAddSep;
+ public:
+ TEvent( const QString& msg, bool addSeparator )
+ : myMsg( msg ), myAddSep( addSeparator ) {}
+ virtual void Execute() {
+ if ( SalomeApp_Application* anApp = getApplication() ) {
+ LogWindow* lw = anApp->logWindow();
+ if ( lw )
+ lw->putMessage( myMsg, myAddSep );
+ }
+ }
+ };
+ ProcessVoidEvent( new TEvent( msg, addSeparator ) );
+}
+
+/*!
+ SalomePyQt::clearMessages
+ Removes all the messages from the Log output window
+ */
+void SalomePyQt::clearMessages()
+{
+ class TEvent: public SALOME_Event {
+ public:
+ TEvent() {}
+ virtual void Execute() {
+ if ( SalomeApp_Application* anApp = getApplication() ) {
+ LogWindow* lw = anApp->logWindow();
+ if ( lw )
+ lw->clear();
+ }
+ }
+ };
+ ProcessVoidEvent( new TEvent() );
+}
#include <qcolor.h>
#include <LightApp_Application.h>
+#include <LightApp_Preferences.h>
class LightApp_SelectionMgr;
class SalomeApp_Application;
WT_User = LightApp_Application::WT_User
};
+enum {
+ PT_Space = LightApp_Preferences::Space,
+ PT_Bool = LightApp_Preferences::Bool,
+ PT_Color = LightApp_Preferences::Color,
+ PT_String = LightApp_Preferences::String,
+ PT_Selector = LightApp_Preferences::Selector,
+ PT_DblSpin = LightApp_Preferences::DblSpin,
+ PT_IntSpin = LightApp_Preferences::IntSpin,
+ PT_Double = LightApp_Preferences::Double,
+ PT_Integer = LightApp_Preferences::Integer,
+ PT_GroupBox = LightApp_Preferences::GroupBox,
+ PT_Font = LightApp_Preferences::Font,
+ PT_DirList = LightApp_Preferences::DirList,
+ PT_File = LightApp_Preferences::File,
+ PT_User = LightApp_Preferences::User
+};
+
class SalomePyQt
{
public:
static void addSetting ( const QString&, const QString&, const double );
static void addSetting ( const QString&, const QString&, const int );
+ static void addSetting ( const QString&, const QString&, const bool, const int );
static void addSetting ( const QString&, const QString&, const QString& );
static void addSetting ( const QString&, const QString&, const QColor& );
static int integerSetting( const QString&, const QString&, const int = 0 );
- static double doubleSetting ( const QString&, const QString&, const int = 0 );
+ static double doubleSetting ( const QString&, const QString&, const double = 0 );
static bool boolSetting ( const QString&, const QString&, const bool = 0 );
static QString stringSetting ( const QString&, const QString&, const QString& = QString("") );
static QColor colorSetting ( const QString&, const QString&, const QColor& = QColor() );
static void removeSetting ( const QString&, const QString& );
+ static bool hasSetting ( const QString&, const QString& );
// obsolete
static void addStringSetting( const QString&, const QString&, bool = true );
static void addIntSetting ( const QString&, const int, bool = true );
+ static void addBoolSetting ( const QString&, const bool, bool = true );
static void addDoubleSetting( const QString&, const double, bool = true );
static void removeSettings ( const QString& );
static QString getSetting ( const QString& );
+
+ static int addGlobalPreference( const QString& );
+ static int addPreference( const QString& );
+ static int addPreference( const QString&,
+ const int, const int = -1,
+ const QString& = QString::null,
+ const QString& = QString::null );
+ static QVariant preferenceProperty( const int, const QString& );
+ static void setPreferenceProperty( const int,
+ const QString&,
+ const QVariant& );
+ static void addPreferenceProperty( const int,
+ const QString&,
+ const int,
+ const QVariant& );
+
+ static void message( const QString&, bool = true );
+ static void clearMessages();
};
#endif // SALOME_PYQT_H
WT_User
};
+enum PrefType {
+ PT_Space,
+ PT_Bool,
+ PT_Color,
+ PT_String,
+ PT_Selector,
+ PT_DblSpin,
+ PT_IntSpin,
+ PT_Double,
+ PT_Integer,
+ PT_GroupBox,
+ PT_Font,
+ PT_DirList,
+ PT_File,
+ PT_User
+};
+
class QtxAction : QAction
{
%TypeHeaderCode
static void addSetting ( const QString&, const QString&, const double );
static void addSetting ( const QString&, const QString&, const int /Constrained/ );
+ static void addSetting ( const QString&, const QString&, const bool, const int );
static void addSetting ( const QString&, const QString&, const QString& );
static void addSetting ( const QString&, const QString&, const QColor& );
static int integerSetting( const QString&, const QString&, int = 0 );
- static double doubleSetting ( const QString&, const QString&, int = 0 );
+ static double doubleSetting ( const QString&, const QString&, double = 0 );
static bool boolSetting ( const QString&, const QString&, bool = false );
static QString stringSetting ( const QString&, const QString&, const QString& = QString("") );
static QColor colorSetting ( const QString&, const QString&, const QColor& = QColor() );
static void removeSetting ( const QString&, const QString& );
+ static bool hasSetting ( const QString&, const QString& );
// obsolete
static void addStringSetting( const QString&, const QString&, bool = true );
static void addIntSetting ( const QString&, const int, bool = true );
static void addDoubleSetting( const QString&, const double, bool = true );
+ static void addBoolSetting ( const QString&, const bool, bool = true );
static void removeSettings ( const QString& );
static QString getSetting ( const QString& );
+
+ static int addGlobalPreference( const QString& );
+ static int addPreference( const QString& );
+ static int addPreference( const QString&, const int, int = -1,
+ const QString& = QString::null,
+ const QString& = QString::null );
+ static QVariant preferenceProperty( const int, const QString& );
+ static void setPreferenceProperty( const int,
+ const QString&,
+ const QVariant& );
+ static void addPreferenceProperty( const int,
+ const QString&,
+ const int,
+ const QVariant& );
+
+ static void message( const QString&, bool = true );
+ static void clearMessages();
};
WT_User
};
+enum PrefType {
+ PT_Space,
+ PT_Bool,
+ PT_Color,
+ PT_String,
+ PT_Selector,
+ PT_DblSpin,
+ PT_IntSpin,
+ PT_Double,
+ PT_Integer,
+ PT_GroupBox,
+ PT_Font,
+ PT_DirList,
+ PT_File,
+ PT_User
+};
+
class QtxAction : QAction
{
%TypeHeaderCode
static void addSetting ( const QString&, const QString&, const double ) /ReleaseGIL/ ;
static void addSetting ( const QString&, const QString&, const int /Constrained/ ) /ReleaseGIL/ ;
+ static void addSetting ( const QString&, const QString&, const bool, const int ) /ReleaseGIL/ ;
static void addSetting ( const QString&, const QString&, const QString& ) /ReleaseGIL/ ;
static void addSetting ( const QString&, const QString&, const QColor& ) /ReleaseGIL/ ;
static int integerSetting( const QString&, const QString&, const int = 0 ) /ReleaseGIL/ ;
- static double doubleSetting ( const QString&, const QString&, const int = 0 ) /ReleaseGIL/ ;
+ static double doubleSetting ( const QString&, const QString&, const double = 0 ) /ReleaseGIL/ ;
static bool boolSetting ( const QString&, const QString&, const bool = false ) /ReleaseGIL/ ;
static QString stringSetting ( const QString&, const QString&, const QString& = QString("") ) /ReleaseGIL/ ;
static QColor colorSetting ( const QString&, const QString&, const QColor& = QColor() ) /ReleaseGIL/ ;
static void removeSetting ( const QString&, const QString& ) /ReleaseGIL/ ;
+ static bool hasSetting ( const QString&, const QString& ) /ReleaseGIL/ ;
// obsolete
static void addStringSetting( const QString&, const QString&, bool = true ) /ReleaseGIL/ ;
static void addIntSetting ( const QString&, const int, bool = true ) /ReleaseGIL/ ;
static void addDoubleSetting( const QString&, const double, bool = true ) /ReleaseGIL/ ;
+ static void addBoolSetting ( const QString&, const bool, bool = true ) /ReleaseGIL/ ;
static void removeSettings ( const QString& ) /ReleaseGIL/ ;
static QString getSetting ( const QString& ) /ReleaseGIL/ ;
+
+ static int addGlobalPreference( const QString& ) /ReleaseGIL/ ;
+ static int addPreference( const QString& ) /ReleaseGIL/ ;
+ static int addPreference( const QString&,
+ const int, const int = -1,
+ const QString& = QString::null,
+ const QString& = QString::null ) /ReleaseGIL/ ;
+ static QVariant preferenceProperty( const int, const QString& ) /ReleaseGIL/ ;
+ static void setPreferenceProperty( const int,
+ const QString&,
+ const QVariant& ) /ReleaseGIL/ ;
+ static void addPreferenceProperty( const int,
+ const QString&,
+ const int,
+ const QVariant& ) /ReleaseGIL/ ;
+
+ static void message( const QString&, bool = true ) /ReleaseGIL/ ;
+ static void clearMessages() /ReleaseGIL/ ;
};
--- /dev/null
+# Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : Help.py
+# Author : Paul RASCLE, EDF
+# Module : SALOME
+# $Header$
+
+class SalomeDoc:
+ def __init__(self, aDoc):
+ self.doc = aDoc
+ def __repr__(self):
+ print self.doc
+ return "---"
+ def salome(self):
+ doc_salome = '''
+MODULE : salome
+---------------
+module salome gives access to Salome ressources:
+variables:
+
+ salome:orb : CORBA
+ salome.naming_service : instance of naming Service class
+ methods:
+ Resolve(name) : find a CORBA object (ior) by its pathname
+ Register(name) : register a CORBA object under a pathname
+ salome.lcc : instance of lifeCycleCORBA class
+ methods:
+ FindOrLoadComponent(server,name) :
+ obtain an Engine (CORBA object)
+ or launch the Engine if not found,
+ with a Server name and an Engine name
+ salome.sg
+ methods:
+ updateObjBrowser(bool):
+ getActiveStudyId():
+ getActiveStudyName():
+
+ SelectedCount(): returns number of selected objects
+ getSelected(i): returns entry of selected object number i
+ getAllSelected(): returns list of entry of selected objects
+ AddIObject(Entry): select an existing Interactive object
+ RemoveIObject(Entry): remove object from selection
+ ClearIObjects(): clear selection
+
+ Display(*Entry):
+ DisplayOnly(Entry):
+ Erase(Entry):
+ DisplayAll():
+ EraseAll():
+
+ IDToObject(Entry): returns CORBA reference from entry
+
+ salome.myStudyName : active Study Name
+ salome.myStudyId : active Study Id
+ salome.myStudy : the active Study itself (CORBA ior)
+ methods : defined in SALOMEDS.idl
+
+methods:
+ salome.DumpStudy(study) : Dump a study, given the ior
+---
+'''
+ print doc_salome
+
+ def geompy(self):
+ doc_geompy = '''
+MODULE : geompy
+---------------
+module geompy provides an encapsulation of GEOM Engine methods
+variables:
+ geompy.geom : a Geometry Engine, found or loaded
+ at first import of module geompy.
+ methods : defined in GEOM_Gen.idl
+ geompy.myBuilder : a study builder
+ geompy.father : GEOM root in current study (salome.myStudy)
+
+methods:
+ addToStudy(aShape, aName) : add the shape into the current study
+ --- all methods of GEOM_Gen.idl that returns a shape are encapsulated,
+ with the same interface : shapes are named with their ior
+'''
+ print doc_geompy
+
+ def supervision(self):
+ doc_supervision = '''
+MODULES : SALOME_SuperVisionEditor and SALOME_SuperVisionExecutor
+-----------------------------------------------------------------
+this modules provide access to Editor and Executor Engine methods
+
+See SUPERV.idl
+
+In order to run the example (supervisionexample.py)
+
+ Type : from supervisionexample import *
+ supervisionexample.py contains comments
+
+A new python example avoids references to LifeCycleCORBA
+ avoids references to NamingService
+ avoids references to ModuleCatalog
+ avoids SuperVisionComponent creation
+ allows G.Input(...) instead of AddInput(G,...)
+ replaces Editor/Executor with Graph
+ allows Nodes, Ports and Links CORBA objects
+ shortens methods names
+ ...
+
+ See /SuperVisionTest/resources/GraphExample.py
+ and GraphExample.xml
+---
+'''
+ print doc_supervision
+
+
+
+help = SalomeDoc('''
+Availables modules:
+ salome : gives access to Salome ressources
+ geompy : encapsulation of GEOM Engine methods
+ supervision : gives access to SuperVision Engine
+To obtain specific help on a module "truc", type: help.truc()
+To run an example, type: import example3
+''')
+
--- /dev/null
+# Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : PyInterp.py
+# Author : Paul RASCLE, EDF
+# Module : SALOME
+# $Header$
+
+import sys
+from omniORB import CORBA
+from LifeCycleCORBA import *
+from libSALOME_Swig import *
+import SALOMEDS
+from SALOME_NamingServicePy import *
+
+ #--------------------------------------------------------------------------
+
+def DumpComponent(Study, SO, offset):
+ it = Study.NewChildIterator(SO)
+ Builder = Study.NewBuilder()
+ while it.More():
+ CSO = it.Value()
+ it.Next()
+ anAttr = Builder.FindOrCreateAttribute(CSO, "AttributeName")
+ AtName = anAttr._narrow(SALOMEDS.AttributeName)
+ t_name = AtName.Value()
+ if t_name[0] == 1:
+ ofs = 1
+ a = ""
+ while ofs <= offset:
+ a = a + "--"
+ ofs = ofs +1
+ print a + ">" + CSO.GetID() + " " + t_name[1]
+ t_RefSO = CSO.ReferencedObject()
+ if t_RefSO[0] == 1:
+ RefSO = t_RefSO[1]
+ ofs = 1
+ a = ""
+ while ofs <= offset:
+ a = a + " "
+ ofs = ofs +1
+ print a + ">" + RefSO.GetID()
+ DumpComponent(Study, CSO, offset+2)
+
+ #--------------------------------------------------------------------------
+
+def DumpStudy(Study):
+ itcomp = Study.NewComponentIterator()
+ while itcomp.More():
+ SC = itcomp.Value()
+ itcomp.Next()
+ name = SC.ComponentDataType()
+ print "-> ComponentDataType is " + name
+ DumpComponent(Study, SC, 1)
+
+
+ #--------------------------------------------------------------------------
+
+# initialise the ORB
+orb = CORBA.ORB_init([''], CORBA.ORB_ID)
+
+# create an LifeCycleCORBA instance
+lcc = LifeCycleCORBA(orb)
+
+# create an SALOMEGUI_Swig instance
+sg = SALOMEGUI_Swig()
+
+#create an naming service instance
+naming_service = SALOME_NamingServicePy_i(orb)
+
+# get active study name and id
+myStudyName = sg.getActiveStudyName()
+print myStudyName
+
+myStudyId = sg.getActiveStudyId()
+print myStudyId
+
+# get Study Manager reference
+obj = naming_service.Resolve('myStudyManager')
+myStudyManager = obj._narrow(SALOMEDS.StudyManager)
+
+# get active study
+myStudy = myStudyManager.GetStudyByName(myStudyName)
+
#include "SALOME_Prs.h"
#include "SOCC_ViewModel.h"
#include "SVTK_ViewModel.h"
+#include "SVTK_ViewWindow.h"
+#include "SOCC_ViewWindow.h"
+#include "SPlot2d_ViewWindow.h"
#include "SALOME_Event.hxx"
#include "SALOME_ListIO.hxx"
{
return ProcessEvent( new TIsInViewerEvent( theEntry ) );
}
+
+/*!
+ Updates (repaint) current view
+*/
+void SALOMEGUI_Swig::UpdateView()
+{
+ class TEvent: public SALOME_Event {
+ public:
+ TEvent() {}
+ virtual void Execute() {
+ if ( SalomeApp_Application* anApp = getApplication() ) {
+ SUIT_ViewWindow* window = anApp->desktop()->activeWindow();
+ if ( window ) {
+ SALOME_View* view = dynamic_cast<SALOME_View*>( window->getViewManager()->getViewModel() );
+ if ( view )
+ view->Repaint();
+ }
+ }
+ }
+ };
+ ProcessVoidEvent( new TEvent() );
+}
+
+/*!
+ Fit all the contents of the current view window
+ */
+void SALOMEGUI_Swig::FitAll()
+{
+ class TEvent: public SALOME_Event {
+ public:
+ TEvent() {}
+ virtual void Execute() {
+ if ( SalomeApp_Application* anApp = getApplication() ) {
+ SUIT_ViewWindow* window = anApp->desktop()->activeWindow();
+ if ( window ) {
+ if ( dynamic_cast<SVTK_ViewWindow*>( window ) )
+ (dynamic_cast<SVTK_ViewWindow*>( window ))->onFitAll();
+ else if ( dynamic_cast<SOCC_ViewWindow*>( window ) )
+ (dynamic_cast<SOCC_ViewWindow*>( window ))->onFitAll();
+ else if ( dynamic_cast<SPlot2d_ViewWindow*>( window ) )
+ (dynamic_cast<SPlot2d_ViewWindow*>( window ))->onFitAll();
+ }
+ }
+ }
+ };
+ ProcessVoidEvent( new TEvent() );
+}
+
+/*!
+ Reset current view window to the default state.
+ */
+void SALOMEGUI_Swig::ResetView()
+{
+ class TEvent: public SALOME_Event {
+ public:
+ TEvent() {}
+ virtual void Execute() {
+ if ( SalomeApp_Application* anApp = getApplication() ) {
+ SUIT_ViewWindow* window = anApp->desktop()->activeWindow();
+ if ( window ) {
+ if ( dynamic_cast<SVTK_ViewWindow*>( window ) )
+ (dynamic_cast<SVTK_ViewWindow*>( window ))->onResetView();
+ else if ( dynamic_cast<SOCC_ViewWindow*>( window ) )
+ (dynamic_cast<SOCC_ViewWindow*>( window ))->onResetView();
+ else if ( dynamic_cast<SPlot2d_ViewWindow*>( window ) )
+ (dynamic_cast<SPlot2d_ViewWindow*>( window ))->onFitAll();
+ // VSR: there is no 'ResetView' functionality for Plot2d viewer,
+ // so we use 'FitAll' instead.
+ }
+ }
+ }
+ };
+ ProcessVoidEvent( new TEvent() );
+}
+
+enum {
+ __ViewTop,
+ __ViewBottom,
+ __ViewLeft,
+ __ViewRight,
+ __ViewFront,
+ __ViewBack
+};
+
+void setView( int view )
+{
+ class TEvent: public SALOME_Event {
+ private:
+ int myView;
+ public:
+ TEvent( int view ) : myView( view ) {}
+ virtual void Execute() {
+ if ( SalomeApp_Application* anApp = getApplication() ) {
+ SUIT_ViewWindow* window = anApp->desktop()->activeWindow();
+ if ( window ) {
+ if ( dynamic_cast<SVTK_ViewWindow*>( window ) ) {
+ switch( myView ) {
+ case __ViewTop:
+ (dynamic_cast<SVTK_ViewWindow*>( window ))->onTopView(); break;
+ case __ViewBottom:
+ (dynamic_cast<SVTK_ViewWindow*>( window ))->onBottomView(); break;
+ case __ViewLeft:
+ (dynamic_cast<SVTK_ViewWindow*>( window ))->onLeftView(); break;
+ case __ViewRight:
+ (dynamic_cast<SVTK_ViewWindow*>( window ))->onRightView(); break;
+ case __ViewFront:
+ (dynamic_cast<SVTK_ViewWindow*>( window ))->onFrontView(); break;
+ case __ViewBack:
+ (dynamic_cast<SVTK_ViewWindow*>( window ))->onBackView(); break;
+ default:
+ break;
+ }
+ }
+ else if ( dynamic_cast<SOCC_ViewWindow*>( window ) ) {
+ switch( myView ) {
+ case __ViewTop:
+ (dynamic_cast<SOCC_ViewWindow*>( window ))->onTopView(); break;
+ case __ViewBottom:
+ (dynamic_cast<SOCC_ViewWindow*>( window ))->onBottomView(); break;
+ case __ViewLeft:
+ (dynamic_cast<SOCC_ViewWindow*>( window ))->onLeftView(); break;
+ case __ViewRight:
+ (dynamic_cast<SOCC_ViewWindow*>( window ))->onRightView(); break;
+ case __ViewFront:
+ (dynamic_cast<SOCC_ViewWindow*>( window ))->onFrontView(); break;
+ case __ViewBack:
+ (dynamic_cast<SOCC_ViewWindow*>( window ))->onBackView(); break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+ }
+ };
+ ProcessVoidEvent( new TEvent( view ) );
+}
+
+/*!
+ Switch current view window to show top view
+ */
+void SALOMEGUI_Swig::ViewTop()
+{
+ setView( __ViewTop );
+}
+
+/*!
+ Switch current view window to show bottom view
+ */
+void SALOMEGUI_Swig::ViewBottom()
+{
+ setView( __ViewBottom );
+}
+
+/*!
+ Switch current view window to show left view
+ */
+void SALOMEGUI_Swig::ViewLeft()
+{
+ setView( __ViewLeft );
+}
+
+/*!
+ Switch current view window to show right view
+ */
+void SALOMEGUI_Swig::ViewRight()
+{
+ setView( __ViewRight );
+}
+
+/*!
+ Switch current view window to show front view
+ */
+void SALOMEGUI_Swig::ViewFront()
+{
+ setView( __ViewFront );
+}
+
+/*!
+ Switch current view window to show back view
+ */
+void SALOMEGUI_Swig::ViewBack()
+{
+ setView( __ViewBack );
+}
void DisplayAll();
void EraseAll();
bool IsInCurrentView( const char *Entry );
+ void UpdateView();
+
+ /* view operations */
+ void FitAll();
+ void ResetView();
+ void ViewTop();
+ void ViewBottom();
+ void ViewLeft();
+ void ViewRight();
+ void ViewFront();
+ void ViewBack();
/* get component name/username */
const char* getComponentName( const char* ComponentUserName );
void DisplayAll();
void EraseAll();
bool IsInCurrentView(const char *Entry);
+ void UpdateView();
+
+/* view operations */
+ void FitAll();
+ void ResetView();
+ void ViewTop();
+ void ViewBottom();
+ void ViewLeft();
+ void ViewRight();
+ void ViewFront();
+ void ViewBack();
/* get component name/username */
const char* getComponentName( const char* ComponentUserName );
--- /dev/null
+# Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : salome.py
+# Author : Paul RASCLE, EDF
+# Module : SALOME
+# $Header$
+
+from omniORB import CORBA
+from LifeCycleCORBA import *
+from libSALOME_Swig import *
+import SALOMEDS
+from SALOME_NamingServicePy import *
+
+from SALOME_utilities import *
+
+#--------------------------------------------------------------------------
+
+def DumpComponent(Study, SO, offset):
+ it = Study.NewChildIterator(SO)
+ Builder = Study.NewBuilder()
+ while it.More():
+ CSO = it.Value()
+ it.Next()
+ anAttr = Builder.FindOrCreateAttribute(CSO, "AttributeName")
+ AtName = anAttr._narrow(SALOMEDS.AttributeName)
+ t_name = AtName.Value()
+ if t_name[0] == 1:
+ ofs = 1
+ a = ""
+ while ofs <= offset:
+ a = a + "--"
+ ofs = ofs +1
+ MESSAGE( a + ">" + str(CSO.GetID()) + " " + str(t_name[1]) )
+ t_RefSO = CSO.ReferencedObject()
+ if t_RefSO[0] == 1:
+ RefSO = t_RefSO[1]
+ ofs = 1
+ a = ""
+ while ofs <= offset:
+ a = a + " "
+ ofs = ofs +1
+ MESSAGE( a + ">" + str(RefSO.GetID()) )
+ DumpComponent(Study, CSO, offset+2)
+
+ #--------------------------------------------------------------------------
+
+def DumpStudy(Study):
+ itcomp = Study.NewComponentIterator()
+ while itcomp.More():
+ SC = itcomp.Value()
+ itcomp.Next()
+ name = SC.ComponentDataType()
+ MESSAGE( "-> ComponentDataType is " + name )
+ DumpComponent(Study, SC, 1)
+
+
+ #--------------------------------------------------------------------------
+
+def ImportComponentGUI(ComponentName):
+ libName = "lib" + ComponentName + "_Swig"
+ command = "from " + libName + " import *"
+ exec ( command )
+ constructor = ComponentName + "_Swig()"
+ command = "gui = " + constructor
+ exec ( command )
+ return gui
+
+ #--------------------------------------------------------------------------
+
+def SalomeGUIgetAllSelected(self):
+ selNumber = self.SelectedCount()
+ listSelected = []
+ for i in range(selNumber):
+ listSelected.append(self.getSelected(i))
+ return listSelected
+
+class SalomeGUI(SALOMEGUI_Swig):
+ getAllSelected = SalomeGUIgetAllSelected
+
+ #--------------------------------------------------------------------------
+
+def IDToObject(id):
+ myObj = None
+ mySO = myStudy.FindObjectID(id);
+ if mySO is not None:
+ ok, anAttr = mySO.FindAttribute("AttributeIOR")
+ if ok:
+ AtIOR = anAttr._narrow(SALOMEDS.AttributeIOR)
+ if AtIOR.Value() != "":
+ myObj = orb.string_to_object(AtIOR.Value())
+ return myObj
+
+def ObjectToSObject(obj):
+ mySO = None
+ if obj is not None:
+ ior = orb.object_to_string(obj)
+ if ior != "":
+ mySO = myStudy.FindObjectIOR(ior)
+ return mySO
+
+def ObjectToID(obj):
+ mySO = ObjectToSObject(obj)
+ if mySO:
+ return mySO.GetID()
+ return ""
+
+def IDToSObject(id):
+ mySO = myStudy.FindObjectID(id);
+ return mySO
+
+ #--------------------------------------------------------------------------
+
+# initialise the ORB
+orb = CORBA.ORB_init([''], CORBA.ORB_ID)
+
+# create an LifeCycleCORBA instance
+lcc = LifeCycleCORBA(orb)
+
+# create an SALOMEGUI_Swig instance
+sg = SalomeGUI()
+
+#create an naming service instance
+naming_service = SALOME_NamingServicePy_i(orb)
+
+# get active study name and id
+myStudyName = sg.getActiveStudyName()
+MESSAGE( myStudyName )
+
+myStudyId = sg.getActiveStudyId()
+MESSAGE( str(myStudyId) )
+
+# get Study Manager reference
+obj = naming_service.Resolve('myStudyManager')
+myStudyManager = obj._narrow(SALOMEDS.StudyManager)
+
+# get active study
+myStudy = myStudyManager.GetStudyByName(myStudyName)
+
*/
bool SOCC_Prs::IsNull() const
{
- return myObjects.IsEmpty();
+ return myObjects.IsEmpty() == Standard_True;
}
/*!
// }
//}
}
-
- // display trihedron if necessary
- if ( isTrihedronDisplayed )
- getAISContext()->Display( getTrihedron() );
- else
- Repaint();
+
+ Repaint();
}
/*!
myViewPort->fitAll();
break;
case SUIT_Accel::RotateLeft :
- myViewPort->startRotation( cx, cy );
- myViewPort->rotate( cx - inc, cy );
+ myViewPort->startRotation( cx, cy, myCurrPointType, mySelectedPoint );
+ myViewPort->rotate( cx - inc, cy, myCurrPointType, mySelectedPoint );
myViewPort->endRotation();
break;
case SUIT_Accel::RotateRight :
- myViewPort->startRotation( cx, cy );
- myViewPort->rotate( cx + inc, cy );
+ myViewPort->startRotation( cx, cy, myCurrPointType, mySelectedPoint );
+ myViewPort->rotate( cx + inc, cy, myCurrPointType, mySelectedPoint );
myViewPort->endRotation();
break;
case SUIT_Accel::RotateUp :
- myViewPort->startRotation( cx, cy );
- myViewPort->rotate( cx, cy - inc );
+ myViewPort->startRotation( cx, cy, myCurrPointType, mySelectedPoint );
+ myViewPort->rotate( cx, cy - inc, myCurrPointType, mySelectedPoint );
myViewPort->endRotation();
break;
case SUIT_Accel::RotateDown :
- myViewPort->startRotation( cx, cy );
- myViewPort->rotate( cx, cy + inc );
+ myViewPort->startRotation( cx, cy, myCurrPointType, mySelectedPoint );
+ myViewPort->rotate( cx, cy + inc, myCurrPointType, mySelectedPoint );
myViewPort->endRotation();
break;
}
void SPlot2d_Viewer::renameAll( const Handle(SALOME_InteractiveObject)& IObj, const QString& name )
{
SUIT_ViewManager* vm = getViewManager();
- if( vm )
+ if ( vm )
{
const QPtrVector<SUIT_ViewWindow>& wnds = vm->getViews();
- for( int i=0; i<wnds.size(); i++ )
+ for ( uint i = 0; i < wnds.size(); i++ )
{
Plot2d_ViewWindow* pwnd = dynamic_cast<Plot2d_ViewWindow*>( wnds.at( i ) );
rename( IObj, name, pwnd->getViewFrame() );
/*!Destructor.*/
STD_Application::~STD_Application()
{
+ clearViewManagers();
}
/*! \retval QString "StdApplication"*/
tr( "MEN_DESK_HELP_ABOUT" ), tr( "PRP_DESK_HELP_ABOUT" ),
SHIFT+Key_A, desk, false, this, SLOT( onHelpAbout() ) );
- //SRN: BugID IPAL9021, add an action "Load"
- createAction( FileLoadId, tr( "TOT_DESK_FILE_LOAD" ),
- resMgr->loadPixmap( "STD", tr( "ICON_FILE_OPEN" ) ),
- tr( "MEN_DESK_FILE_LOAD" ), tr( "PRP_DESK_FILE_LOAD" ),
- CTRL+Key_L, desk, false, this, SLOT( onLoadDoc() ) );
- //SRN: BugID IPAL9021: End
-
QtxDockAction* da = new QtxDockAction( tr( "TOT_DOCK_WINDOWS" ), tr( "MEN_DOCK_WINDOWS" ), desk );
registerAction( ViewWindowsId, da );
da->setAutoPlace( false );
createMenu( FileNewId, fileMenu, 0 );
createMenu( FileOpenId, fileMenu, 0 );
- createMenu( FileLoadId, fileMenu, 0 ); //SRN: BugID IPAL9021, add a menu item "Load"
createMenu( FileCloseId, fileMenu, 0 );
createMenu( separator(), fileMenu, -1, 0 );
createMenu( FileSaveId, fileMenu, 0 );
createMenu( EditPasteId, editMenu );
createMenu( separator(), editMenu );
- createMenu( ViewWindowsId, viewMenu );
- createMenu( ViewStatusBarId, viewMenu );
+ createMenu( ViewWindowsId, viewMenu, 0 );
+ createMenu( separator(), viewMenu, -1, 10 );
+ createMenu( ViewStatusBarId, viewMenu, 10 );
createMenu( separator(), viewMenu );
createMenu( HelpAboutId, helpMenu );
return res;
}
-/*! called on loading the existent study */
-void STD_Application::onLoadDoc()
-{
-}
-
/*! \retval true, if document was loaded successful, else false.*/
bool STD_Application::onLoadDoc( const QString& aName )
{
emit viewManagerRemoved( vm );
vm->disconnectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
- vm->disconnect();
+ disconnect( vm, SIGNAL( activated( SUIT_ViewManager* ) ),
+ this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
myViewMgrs.removeRef( vm );
if ( myActiveViewMgr == vm )
ViewManagerList lst;
viewManagers( lst );
- for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current(); ++it )
- removeViewManager( it.current() );
+ for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current(); ++it ) {
+ QGuardedPtr<SUIT_ViewManager> vm = it.current();
+ removeViewManager( vm );
+ delete vm;
+ }
}
/*!\retval TRUE, if view manager \a vm, already in view manager list (\a myViewMgrs).*/
virtual void onOpenDoc();
virtual bool onOpenDoc( const QString& );
- virtual void onLoadDoc();
virtual bool onLoadDoc( const QString& );
virtual void onExit();
MenuHelpId = 7
};
- enum { FileNewId, FileOpenId, FileLoadId, FileCloseId,
+ enum { FileNewId, FileOpenId, FileCloseId,
FileSaveId, FileSaveAsId, FileExitId,
ViewStatusBarId, ViewWindowsId, NewWindowId,
EditCutId, EditCopyId, EditPasteId,
\param msg - text of message
\param msec - time in milliseconds, after that the status label will be cleared
*/
-void SUIT_Application::putInfo ( const QString& msg, const int msec )
+void SUIT_Application::putInfo( const QString& msg, const int msec )
{
if ( !desktop() )
return;
myStatusLabel->show();
}
+ QString prev = myStatusLabel->text();
+
myStatusLabel->setText( msg );
if ( msec != -1 )
- QTimer::singleShot( msec <= 0 ? DEFAULT_MESSAGE_DELAY : msec, myStatusLabel, SLOT( clear() ) );
+ QTimer::singleShot( msec <= 0 ? DEFAULT_MESSAGE_DELAY : msec, this, SLOT( onInfoClear() ) );
+
+ if ( prev != msg )
+ emit infoChanged( msg );
+}
+
+/*!
+ Clear the information label in status bar after delay.
+*/
+void SUIT_Application::onInfoClear()
+{
+ if ( !myStatusLabel )
+ return;
+
+ bool changed = !myStatusLabel->text().isEmpty();
+ myStatusLabel->clear();
+ if ( changed )
+ emit infoChanged( QString::null );
}
/*!
#include <qobject.h>
#include <qwidget.h>
+class QLabel;
+class QString;
class QAction;
+class QIconSet;
class SUIT_Desktop;
class SUIT_Convertor;
class SUIT_ViewModel;
class SUIT_ResourceMgr;
-class QString;
-class QIconSet;
-class QLabel;
+
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
/*! \class QObject
* \brief For more information see <a href="http://doc.trolltech.com">QT documentation</a>.
*/
signals:
void applicationClosed( SUIT_Application* );
void activated( SUIT_Application* );
+ void infoChanged( QString );
+
+private slots:
+ void onInfoClear();
protected:
SUIT_Application* startApplication( int, char** ) const;
#define APP_CREATE_NAME "createApplication"
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
#endif
{
public:
SUIT_DataObjectKey();
- ~SUIT_DataObjectKey();
+ virtual ~SUIT_DataObjectKey();
virtual bool isLess( const SUIT_DataObjectKey* ) const = 0;
virtual bool isEqual( const SUIT_DataObjectKey* ) const = 0;
{
}
-/*! operator== : compares two owners*/
+/*! Operator == compares two owners*/
bool operator==( const SUIT_DataOwnerPtr& p1, const SUIT_DataOwnerPtr& p2 )
{
if ( !p1.isNull() && !p2.isNull() )
return p1.isNull() && p2.isNull();
}
+
+/*! Operator < allows to order suit data owners for map */
+bool operator<( const SUIT_DataOwnerPtr& p1, const SUIT_DataOwnerPtr& p2 )
+{
+ if ( p1.isNull() && p2.isNull() )
+ return false;
+ else if ( p1.isNull() )
+ return true;
+ else if ( p2.isNull() )
+ return false;
+
+ //bug with acrossentry of DataOwner and DataSubOwner
+ const _typeinfo& ti1 = typeid( *(p1.operator->()) );
+ const _typeinfo& ti2 = typeid( *(p2.operator->()) );
+
+ int res = strcmp( ti1.name(), ti2.name() );
+
+ if ( !res )
+ return p1->isLess( *p2 );
+
+ return res;
+}
+
/*!
\class SUIT_DataOwnerPtrList
implements value list with unique items (uniqueness is
*/
SUIT_DataOwnerPtrList::iterator SUIT_DataOwnerPtrList::append( const SUIT_DataOwnerPtr& x )
{
- if( mySkipEqual && myMap.contains( x ) ) //contains uses SUIT_DataOwnerPtr::operator==
+ if ( mySkipEqual && myMap.contains( x ) ) //contains uses SUIT_DataOwnerPtr::operator==
return myMap[ x ];
iterator it = QValueList<SUIT_DataOwnerPtr>::append( x );
- if( mySkipEqual )
+ if ( mySkipEqual )
myMap.insert( x, it );
return it;
myMap.remove(x);
return QValueList<SUIT_DataOwnerPtr>::remove( x );
}
-
-/*!
- Operator < allows to order suit data owners for map
-*/
-bool operator<( const SUIT_DataOwnerPtr& p1, const SUIT_DataOwnerPtr& p2 )
-{
- return p1.get()<p2.get();
-}
virtual ~SUIT_DataOwner();//!< destructor
//! compare function
virtual bool isEqual( const SUIT_DataOwner& ) const = 0;
+ virtual bool isLess( const SUIT_DataOwner& ) const = 0;
};
/*! \typedef SUIT_DataOwnerPtr
{
emit activated();
}
+
+/*!
+ Emits message signal
+*/
+void SUIT_Desktop::emitMessage( const QString& theMessage )
+{
+ emit message( theMessage );
+}
void logoInsert( const QString&, const QPixmap&, const int = -1 );
void emitActivated();
+ void emitMessage( const QString& );
signals:
void activated();
void deactivated();
void windowActivated( SUIT_ViewWindow* );
void closing( SUIT_Desktop*, QCloseEvent* );
+ void message( const QString& );
protected:
virtual bool event( QEvent* );
class Signal;
SUIT_PopupClient();
- ~SUIT_PopupClient();
+ virtual ~SUIT_PopupClient();
bool connectPopupRequest( QObject* reciever, const char* slot );
bool disconnectPopupRequest( QObject* reciever, const char* slot );
#include <qfileinfo.h>
#include <qdir.h>
+#include <stdlib.h>
/*!
Constructor
return path( docSection, prefix, id );
}
+#ifndef WIN32
#include <unistd.h>
+#endif
/*!
Returns the user file name for specified application
*/
{
public:
SUIT_SelectionFilter();
- ~SUIT_SelectionFilter();
+ virtual ~SUIT_SelectionFilter();
virtual bool isOk( const SUIT_DataOwner* ) const = 0;
};
{
myAppList.clear();
+ if (myResMgr) {
+ delete myResMgr;
+ myResMgr = 0;
+ }
mySession = 0;
}
if( td.isEqual( r1, r2 ) )
{
// update items themselves
- td.updateItem( r2 );
+ td.updateItem( r1, r2 );
// iterate 'siblings' (direct children)
QValueList< DiffItem< SrcItem, TrgItem > > d;
else
{
//to update
- td.updateItem( item.myTrg );
+ td.updateItem( item.mySrc, item.myTrg );
synchronize( item.mySrc, item.myTrg, td );
lastItem = item.myTrg;
}
#include "SUIT_Study.h"
#include <qcursor.h>
+#include <qregexp.h>
#include <qmessagebox.h>
#ifdef WNT
#include <windows.h>
#endif
+QMap<QString, int> SUIT_ViewManager::_ViewMgrId;
+
/*!\class SUIT_ViewManager.
* Class provide manipulation with view windows.
*/
SUIT_ViewModel* theViewModel )
: QObject( 0 ),
myDesktop( theDesktop ),
-myTitle( "Default viewer" ),
+myTitle( "Default: %M - viewer %V" ),
myStudy( NULL )
{
myViewModel = 0;
myActiveView = 0;
- setViewModel(theViewModel);
- connect(theDesktop, SIGNAL(windowActivated(SUIT_ViewWindow*)),
- this, SLOT(onWindowActivated(SUIT_ViewWindow*)));
+ setViewModel( theViewModel );
+
+ myId = useNewId( getType() );
+
+ connect( theDesktop, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
+ this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
myStudy = theStudy;
- if( myStudy )
+ if ( myStudy )
connect( myStudy, SIGNAL( destroyed() ), this, SLOT( onDeleteStudy() ) );
}
}
}
+int SUIT_ViewManager::useNewId( const QString& type )
+{
+ if ( !_ViewMgrId.contains( type ) )
+ _ViewMgrId.insert( type, 0 );
+
+ int id = _ViewMgrId[type];
+ _ViewMgrId[type]++;
+ return id;
+}
+
+void SUIT_ViewManager::setTitle( const QString& theTitle )
+{
+ if ( myTitle == theTitle )
+ return;
+
+ myTitle = theTitle;
+ for ( uint i = 0; i < myViews.count(); i++ )
+ setViewName( myViews[i] );
+}
+
/*!Sets view model \a theViewModel to view manager.*/
void SUIT_ViewManager::setViewModel(SUIT_ViewModel* theViewModel)
{
}
/*!Sets view name for view window \a theView.*/
-void SUIT_ViewManager::setViewName(SUIT_ViewWindow* theView)
+void SUIT_ViewManager::setViewName( SUIT_ViewWindow* theView )
{
- int aPos = myViews.find(theView);
- theView->setCaption(myTitle + QString(":%1").arg(aPos+1));
+ QString title = prepareTitle( getTitle(), myId + 1, myViews.find( theView ) + 1 );
+ theView->setCaption( title );
+}
+
+QString SUIT_ViewManager::prepareTitle( const QString& title, const int mId, const int vId )
+{
+ QString res = title;
+ QRegExp re( "%[%MV]" );
+ int i = 0;
+ while ( ( i = re.search( res, i ) ) != -1 )
+ {
+ QString rplc;
+ QString str = res.mid( i, re.matchedLength() );
+ if ( str == QString( "%%" ) )
+ rplc = QString( "%" );
+ else if ( str == QString( "%M" ) )
+ rplc = QString::number( mId );
+ else if ( str == QString( "%V" ) )
+ rplc = QString::number( vId );
+ res.replace( i, re.matchedLength(), rplc );
+ i += rplc.length();
+ }
+ return res;
}
/*! Creates View, adds it into list of views and returns just created view window*/
}
connect(theView, SIGNAL(closing(SUIT_ViewWindow*)),
- this, SLOT(onDeleteView(SUIT_ViewWindow*)));
+ this, SLOT(onClosingView(SUIT_ViewWindow*)));
connect(theView, SIGNAL(mousePressed(SUIT_ViewWindow*, QMouseEvent*)),
this, SLOT(onMousePressed(SUIT_ViewWindow*, QMouseEvent*)));
/*!Emit delete view. Remove view window \a theView from view manager.
*/
-void SUIT_ViewManager::onDeleteView(SUIT_ViewWindow* theView)
+void SUIT_ViewManager::onClosingView( SUIT_ViewWindow* theView )
{
- emit deleteView(theView);
- removeView(theView);
+ closeView( theView );
+}
+
+/*!
+ Remove the view window \a theView from view manager and destroy it.
+*/
+void SUIT_ViewManager::closeView( SUIT_ViewWindow* theView )
+{
+ if ( !theView )
+ return;
+
+ QGuardedPtr<SUIT_ViewWindow> view( theView );
+
+ view->hide();
+
+ if ( !view->testWFlags( WDestructiveClose ) )
+ return;
+
+ emit deleteView( view );
+ removeView( view );
+
+ if ( view )
+ delete view;
}
/*!Remove view window \a theView from view manager.
emit lastViewClosed(this);
}
+/*!
+ Set or clear flag Qt::WDestructiveClose for all views
+*/
+void SUIT_ViewManager::setDestructiveClose( const bool on )
+{
+ for ( uint i = 0; i < myViews.count(); i++ )
+ myViews[i]->setDestructiveClose( on );
+}
+
+/*!
+ Returns 'true' if any of views (view windows) is visible.
+*/
+bool SUIT_ViewManager::isVisible() const
+{
+ bool res = false;
+ for ( uint i = 0; i < myViews.count() && !res; i++ )
+ res = myViews[i]->isVisibleTo( myViews[i]->parentWidget() );
+ return res;
+}
+
/*!
Show or hide all views (view windows)
*/
*/
void SUIT_ViewManager::closeAllViews()
{
- unsigned int aSize = myViews.size();
- for (uint i = 0; i < aSize; i++) {
- if (myViews[i])
- myViews[i]->close();
- }
+ for ( uint i = 0; i < myViews.size(); i++ )
+ delete myViews[i];
+ myViews.clear();
}
/*!
*\retval QString - type of view model.
*/
-QString SUIT_ViewManager::getType() const
+QString SUIT_ViewManager::getType() const
{
return (!myViewModel)? "": myViewModel->getType();
}
int getViewsCount() { return myViews.count(); }
QPtrVector<SUIT_ViewWindow> getViews() { return myViews; }
- QString getTitle() const { return myTitle;}
- void setTitle(QString theTitle) { myTitle = theTitle; }
+ QString getTitle() const { return myTitle; }
+ virtual void setTitle( const QString& );
SUIT_ViewWindow* createViewWindow();
+ bool isVisible() const;
virtual void setShown( const bool );
+ virtual void setDestructiveClose( const bool );
public slots:
void createView();
protected slots:
void onWindowActivated(SUIT_ViewWindow*);
- void onDeleteView(SUIT_ViewWindow* theView);
- void onMousePressed(SUIT_ViewWindow* theView, QMouseEvent* theEvent);
+ void onClosingView( SUIT_ViewWindow* );
+ void onMousePressed(SUIT_ViewWindow*, QMouseEvent* );
void onDeleteStudy();
private slots:
/*! Removes the View from internal Views Vector.*/
virtual void removeView(SUIT_ViewWindow* theView);
+ /*! Close the specified View.*/
+ virtual void closeView(SUIT_ViewWindow* theView);
+
/*! Used to set unique name for the view.*/
virtual void setViewName(SUIT_ViewWindow* theView);
+ QString prepareTitle( const QString&, const int, const int );
+
+ static int useNewId( const QString& );
protected:
SUIT_Desktop* myDesktop;
QPtrVector<SUIT_ViewWindow> myViews;
SUIT_ViewWindow* myActiveView;
+ int myId;
QString myTitle;
SUIT_Study* myStudy;
+
+ static QMap<QString, int> _ViewMgrId;
};
#ifdef WIN32
return dumpViewToFormat( dumpView(), fileName, format );
}
+/*!
+ Set or clear flag Qt::WDestructiveClose
+*/
+void SUIT_ViewWindow::setDestructiveClose( const bool on )
+{
+ if ( on )
+ setWFlags( WDestructiveClose );
+ else
+ clearWFlags( WDestructiveClose );
+}
+
/*! Close event \a theEvent.
*/
void SUIT_ViewWindow::closeEvent(QCloseEvent* theEvent)
{
- QMainWindow::closeEvent( theEvent );
+// QMainWindow::closeEvent( theEvent );
emit closing( this );
}
virtual QString getVisualParameters();
virtual void setVisualParameters( const QString& parameters );
+ void setDestructiveClose( const bool );
+
public slots:
virtual void onDumpView();
LIBS+= -lsuit -lqtx
LIBSFORBIN+= -lsuit -lqtx
+PLUGINDIR = $(top_builddir)/bin/salome/styles
+MYPLUGINDIR = styles
+
+$(MYPLUGINDIR): $(PLUGINDIR)
+ -$(RM) $@
+ ln -sf $< $@
+
+$(PLUGINDIR):
+ mkdir -p $@
+
+bin: $(MYPLUGINDIR)
+
@CONCLUDE@
#include <qaction.h>
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
class SUPERVGRAPH_EXPORT SUPERVGraph_View: public QWidget, public SUIT_PopupClient {
Q_OBJECT;
public:
QToolBar* myToolBar;
SUPERVGraph_View* myView;
-};
+};
+
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
#endif
SVTK_SelectionEvent.h \
SVTK_SpaceMouse.h \
SVTK_Event.h \
- SVTK_ViewModelBase.h
+ SVTK_ViewModelBase.h \
+ SVTK_Extension.h
PO_FILES = \
SVTK_msg_en.po \
SVTK_NonIsometricDlg.cxx \
SVTK_UpdateRateDlg.cxx \
SVTK_CubeAxesDlg.cxx \
+ SVTK_SetRotationPointDlg.cxx \
SVTK_DialogBase.cxx \
SVTK_FontWidget.cxx \
SVTK_Trihedron.cxx \
SVTK_RenderWindowInteractor.cxx \
SVTK_GenericRenderWindowInteractor.cxx \
SVTK_SpaceMouse.cxx \
- SVTK_Selector.cxx
+ SVTK_Selector.cxx \
+ SVTK_Extension.cxx
LIB_MOC = \
SVTK_GenericRenderWindowInteractor.h \
SVTK_NonIsometricDlg.h \
SVTK_UpdateRateDlg.h \
SVTK_CubeAxesDlg.h \
+ SVTK_SetRotationPointDlg.h \
SVTK_FontWidget.h \
SVTK_DialogBase.h \
SVTK_ViewModelBase.h \
extern int SALOME_POINT_SIZE;
extern int SALOME_LINE_WIDTH;
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
//! The class is a basic one for all SALOME VTK presentation.
/*!
It provide highlight and prehighlight capabilites,
vtkSmartPointer<vtkOutlineSource> myOutline;
};
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
#endif // SALOME_ACTOR_H
class SALOME_Actor;
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
//! This class used for internal SVTK package purpose (highlight and prehighlight)
class SVTK_EXPORT SVTK_Actor : public SVTK_DeviceActor
{
~SVTK_Actor();
};
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
#endif
#include "SVTK.h"
#include "VTKViewer.h"
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
#ifndef WNT
class VTK_HYBRID_EXPORT SVTK_CubeAxesActor2D : public vtkCubeAxesActor2D
#else
void operator=(const SVTK_CubeAxesActor2D&); // Not implemented.
};
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
#endif
{
if ( !myIsShrinkable )
return;
+
if ( vtkDataSet* aDataSet = myPassFilter[ 0 ]->GetOutput() )
- {
+ {
+ aDataSet->Update();
+ int numCells=aDataSet->GetNumberOfCells();
+ int numPts = aDataSet->GetNumberOfPoints();
+ //It's impossible to use to apply "shrink" for "empty" dataset
+ if (numCells < 1 || numPts < 1)
+ return;
myShrinkFilter->SetInput( aDataSet );
myPassFilter[ 1 ]->SetInput( myShrinkFilter->GetOutput() );
myIsShrunk = true;
myShrinkFilter->SetShrinkFactor(theValue);
}
-
/*!
Set representation (VTK_SURFACE, VTK_POINTS, VTK_WIREFRAME and so on)
param theMode - new mode
switch(myRepresentation){
case Points :
case Surface :
- myProperty->DeepCopy(GetProperty());
+ myProperty->SetAmbient(GetProperty()->GetAmbient());
+ myProperty->SetDiffuse(GetProperty()->GetDiffuse());
+ myProperty->SetSpecular(GetProperty()->GetSpecular());
}
switch(theMode){
case Points :
case Surface :
- GetProperty()->DeepCopy(myProperty);
+ GetProperty()->SetAmbient(myProperty->GetAmbient());
+ GetProperty()->SetDiffuse(myProperty->GetDiffuse());
+ GetProperty()->SetSpecular(myProperty->GetSpecular());
break;
default:
GetProperty()->SetAmbient(1.0);
factor = myPolygonOffsetFactor;
units = myPolygonOffsetUnits;
}
+
+vtkDataSetMapper* SVTK_DeviceActor::GetDataSetMapper()
+{
+ return myMapper;
+}
}
}
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
class SVTK_EXPORT SVTK_DeviceActor: public vtkLODActor
{
void
Render(vtkRenderer *, vtkMapper *);
+ vtkDataSetMapper* GetDataSetMapper();
+
protected:
SVTK::Representation::Type myRepresentation;
vtkProperty *myProperty;
};
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
#endif //SVTK_DEVICE_ACTOR_H
StartGlobalPan,
StartFitArea,
+ SetRotateGravity,
+ StartPointSelection,
+ SetRotateSelected,
+
+ BBCenterChanged,
+ RotationPointChanged,
+ ChangeRotationPoint,
+
LastEvent
};
}
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// Copyright (C) 2004 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.org
+//
+//
+//
+// File : SVTK_Extension.cxx
+// Author : Sergey ANIKIN
+// Module : SALOME
+
+#include "SVTK_Extension.h"
+
+#ifdef WIN32
+#include <windows.h>
+#else
+#include <dlfcn.h>
+#endif
+
+void* SVTK::getOpenGLExtension( const char* theExtension )
+{
+#ifdef WIN32
+ return wglGetProcAddress( theExtension );
+#else
+ void* OpenGLLibrary = dlopen( "libGL.so", RTLD_LAZY );
+ return dlsym( OpenGLLibrary, theExtension );
+#endif
+}
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// 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/
+//
+#ifndef SVTK_Extension_H
+#define SVTK_Extension_H
+
+/*!
+ \file SVTK_Extension.h
+ Functions of loading OpenGL extensions.
+*/
+
+#include <SVTK.h>
+
+namespace SVTK
+{
+ SVTK_EXPORT void* getOpenGLExtension( const char* theExtension );
+}
+
+
+#endif
#ifndef SVTK_FontWidget_H
#define SVTK_FontWidget_H
+#include "SVTK.h"
+
#include <qhbox.h>
class QToolButton;
* Class : SVTK_FontWidget
* Description : Dialog for specifynig font
*/
-class SVTK_FontWidget : public QHBox
+class SVTK_EXPORT SVTK_FontWidget : public QHBox
{
Q_OBJECT
class SVTK_Selector;
class SVTK_Renderer;
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
/*!
\class QVTK_GenericRenderWindowInteractor
QWidget* myRenderWidget; //!< Keeps a pointer to QWidget, where vtkRenderWindow maps to.
};
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
#endif
#include "SVTK_Event.h"
#include "SVTK_Selector.h"
#include "SVTK_Functor.h"
+#include "SVTK_Actor.h"
#include "VTKViewer_Algorithm.h"
#include "SVTK_Functor.h"
#include <vtkCamera.h>
#include <vtkRenderer.h>
#include <vtkPicker.h>
+#include <vtkPointPicker.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkCallbackCommand.h>
#include <vtkRendererCollection.h>
+#include <vtkDataSet.h>
+#include <vtkPerspectiveTransform.h>
+#include <vtkMatrix4x4.h>
#include <qapplication.h>
#include <qpixmap.h>
//VRV: porting on Qt 3.0.5
#include <algorithm>
+#include <iostream>
+
using namespace std;
namespace
::SVTK_InteractorStyle():
mySelectionEvent(new SVTK_SelectionEvent()),
myPicker(vtkPicker::New()),
+ myPointPicker(vtkPointPicker::New()),
myLastHighlitedActor(NULL),
myLastPreHighlitedActor(NULL),
myControllerIncrement(SVTK_ControllerIncrement::New()),
- myControllerOnKeyDown(SVTK_ControllerOnKeyDown::New())
+ myControllerOnKeyDown(SVTK_ControllerOnKeyDown::New()),
+ myHighlightRotationPointActor(SVTK_Actor::New())
{
myPicker->Delete();
+ myPointPicker->Delete();
+
+ myPointPicker->SetTolerance(0.025);
this->MotionFactor = 10.0;
this->State = VTK_INTERACTOR_STYLE_CAMERA_NONE;
//
myControllerIncrement->Delete();
myControllerOnKeyDown->Delete();
+
+ myCurrRotationPointType = SVTK::SetRotateGravity;
+ myPrevRotationPointType = myCurrRotationPointType;
+
+ myHighlightRotationPointActor->Delete();
+ myHighlightRotationPointActor->Initialize();
+ myHighlightRotationPointActor->PickableOff();
+ myHighlightRotationPointActor->SetVisibility( false );
+
+ myHighlightRotationPointActor->GetProperty()->SetPointSize(SALOME_POINT_SIZE+2);
+ myHighlightRotationPointActor->GetProperty()->SetLineWidth(SALOME_LINE_WIDTH+2);
+ myHighlightRotationPointActor->GetProperty()->SetRepresentationToPoints();
+
+ myBBFirstCheck = true;
}
/*!
SVTK_InteractorStyle
::RotateXY(int dx, int dy)
{
- if(GetCurrentRenderer() == NULL)
+ /* if(GetCurrentRenderer() == NULL)
return;
int *size = GetCurrentRenderer()->GetRenderWindow()->GetSize();
GetCurrentRenderer()->ResetCameraClippingRange();
+ this->Render();*/
+
+ if(GetCurrentRenderer() == NULL)
+ return;
+
+ vtkCamera *cam = GetCurrentRenderer()->GetActiveCamera();
+
+ double viewFP[3], viewPos[3];
+ cam->GetFocalPoint(viewFP);
+ cam->GetPosition(viewPos);
+
+ if ( myCurrRotationPointType == SVTK::SetRotateGravity )
+ {
+ vtkFloatingPointType aCenter[3];
+ if ( ComputeBBCenter(GetCurrentRenderer(),aCenter) )
+ {
+ myRotationPointX = aCenter[0];
+ myRotationPointY = aCenter[1];
+ myRotationPointZ = aCenter[2];
+ }
+ }
+
+ // Calculate corresponding transformation
+ vtkPerspectiveTransform* aTransform = vtkPerspectiveTransform::New();
+ aTransform->Identity();
+ aTransform->Translate(+myRotationPointX, +myRotationPointY, +myRotationPointZ);
+
+ // Azimuth transformation
+ int *size = GetCurrentRenderer()->GetRenderWindow()->GetSize();
+ double aDeltaAzimuth = -20.0 / size[0];
+
+ double rxf = double(dx) * aDeltaAzimuth * this->MotionFactor;
+ aTransform->RotateWXYZ(rxf, cam->GetViewUp());
+
+ // Elevation transformation
+ double aDeltaElevation = -20.0 / size[1];
+
+ double ryf = double(dy) * aDeltaElevation * this->MotionFactor;
+ vtkMatrix4x4* aMatrix = cam->GetViewTransformMatrix();
+ const double anAxis[3] = {-aMatrix->GetElement(0,0), // mkr : 27.11.2006 : PAL14011 - Strange behaviour in rotation in VTK Viewer.
+ -aMatrix->GetElement(0,1),
+ -aMatrix->GetElement(0,2)};
+
+ aTransform->RotateWXYZ(ryf, anAxis);
+
+ aTransform->Translate(-myRotationPointX, -myRotationPointY, -myRotationPointZ);
+
+ // To apply the transformation
+ cam->SetPosition(aTransform->TransformPoint(viewPos));
+ cam->SetFocalPoint(aTransform->TransformPoint(viewFP));
+
+ cam->OrthogonalizeViewUp();
+
+ GetCurrentRenderer()->ResetCameraClippingRange();
+
this->Render();
}
} else {
if (ctrl)
startOperation(VTK_INTERACTOR_STYLE_CAMERA_ZOOM);
+ else if ( myCurrRotationPointType == SVTK::StartPointSelection )
+ {
+ SVTK_SelectionEvent* aSelectionEvent = GetSelectionEventFlipY();
+ myPicker->Pick(aSelectionEvent->myX,
+ aSelectionEvent->myY,
+ 0.0,
+ GetCurrentRenderer());
+ if ( SALOME_Actor* anActor = GetFirstSALOMEActor(myPicker.GetPointer()) )
+ {
+ myPointPicker->Pick( aSelectionEvent->myX,
+ aSelectionEvent->myY,
+ 0.0,
+ GetCurrentRenderer() );
+ int aVtkId = myPointPicker->GetPointId();
+ if ( aVtkId >= 0 )
+ {
+ int anObjId = anActor->GetNodeObjId( aVtkId );
+ vtkFloatingPointType* aCoords = anActor->GetNodeCoord(anObjId);
+
+ myCurrRotationPointType = SVTK::SetRotateSelected;
+
+ // invoke event for update coordinates in SVTK_SetRotationPointDlg
+ InvokeEvent(SVTK::RotationPointChanged,(void*)aCoords);
+ }
+ else
+ {
+ // invoke event with no data (for SVTK_SetRotationPointDlg)
+ InvokeEvent(SVTK::RotationPointChanged,0);
+ myCurrRotationPointType = myPrevRotationPointType;
+ }
+ }
+ else
+ {
+ // invoke event with no data (for SVTK_SetRotationPointDlg)
+ InvokeEvent(SVTK::RotationPointChanged,0);
+ myCurrRotationPointType = myPrevRotationPointType;
+ }
+
+ myHighlightRotationPointActor->SetVisibility( false );
+ if(GetCurrentRenderer() != NULL)
+ GetCurrentRenderer()->RemoveActor( myHighlightRotationPointActor.GetPointer() );
+
+ GetRenderWidget()->setCursor(myDefCursor);
+ }
else
startOperation(VTK_INTERACTOR_STYLE_CAMERA_SELECT);
}
+
return;
}
ForcedState = VTK_INTERACTOR_STYLE_CAMERA_ROTATE;
}
+/*!
+ Set rotation point selected by user
+*/
+void
+SVTK_InteractorStyle
+::startPointSelection()
+{
+ myCurrRotationPointType = SVTK::StartPointSelection;
+
+ if(GetCurrentRenderer() != NULL) {
+ GetCurrentRenderer()->AddActor( myHighlightRotationPointActor.GetPointer() );
+ vtkFloatingPointType aColor[3];
+ GetCurrentRenderer()->GetBackground( aColor );
+ myHighlightRotationPointActor->GetProperty()->SetColor(1. - aColor[0],
+ 1. - aColor[1],
+ 1. - aColor[2]);
+ }
+
+ setCursor(VTK_INTERACTOR_STYLE_CAMERA_NONE);
+}
/*!
Starts Spin operation (e.g. through menu command)
break;
case VTK_INTERACTOR_STYLE_CAMERA_NONE:
default:
- GetRenderWidget()->setCursor(myDefCursor);
+ if ( myCurrRotationPointType == SVTK::StartPointSelection )
+ GetRenderWidget()->setCursor(myHandCursor);
+ else
+ GetRenderWidget()->setCursor(myDefCursor);
myCursorState = false;
break;
}
fitRect(x1, y1, x2, y2);
}
else {
- if (myPoint == myOtherPoint) {
- // process point selection
- this->FindPokedRenderer(aSelectionEvent->myX, aSelectionEvent->myY);
- Interactor->StartPickCallback();
-
- myPicker->Pick(aSelectionEvent->myX,
- aSelectionEvent->myY,
- 0.0,
- GetCurrentRenderer());
- //
- SALOME_Actor* anActor = GetFirstSALOMEActor(myPicker.GetPointer());
- aSelectionEvent->myIsRectangle = false;
-
- if(!myShiftState)
- GetSelector()->ClearIObjects();
-
- if(anActor){
- anActor->Highlight( this, aSelectionEvent, true );
- }else{
- if(myLastHighlitedActor.GetPointer() && myLastHighlitedActor.GetPointer() != anActor)
- myLastHighlitedActor->Highlight( this, aSelectionEvent, false );
- }
- myLastHighlitedActor = anActor;
- }
- else {
- //processing rectangle selection
- Interactor->StartPickCallback();
- GetSelector()->StartPickCallback();
- aSelectionEvent->myIsRectangle = true;
-
- if(!myShiftState)
- GetSelector()->ClearIObjects();
-
- vtkActorCollection* aListActors = GetCurrentRenderer()->GetActors();
- aListActors->InitTraversal();
- while(vtkActor* aActor = aListActors->GetNextActor()){
- if(aActor->GetVisibility()){
- if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)){
- if(aSActor->hasIO()){
- aSActor->Highlight( this, aSelectionEvent, true );
- }
+ if (myPoint == myOtherPoint)
+ {
+ // process point selection
+ this->FindPokedRenderer(aSelectionEvent->myX, aSelectionEvent->myY);
+ Interactor->StartPickCallback();
+
+ myPicker->Pick(aSelectionEvent->myX,
+ aSelectionEvent->myY,
+ 0.0,
+ GetCurrentRenderer());
+ //
+ SALOME_Actor* anActor = GetFirstSALOMEActor(myPicker.GetPointer());
+ aSelectionEvent->myIsRectangle = false;
+
+ if(!myShiftState)
+ GetSelector()->ClearIObjects();
+
+ if(anActor)
+ {
+ anActor->Highlight( this, aSelectionEvent, true );
+ }
+ else
+ {
+ if(myLastHighlitedActor.GetPointer() && myLastHighlitedActor.GetPointer() != anActor)
+ myLastHighlitedActor->Highlight( this, aSelectionEvent, false );
+ myLastHighlitedActor = anActor;
+ }
+ }
+ else
+ {
+ //processing rectangle selection
+ Interactor->StartPickCallback();
+ GetSelector()->StartPickCallback();
+ aSelectionEvent->myIsRectangle = true;
+
+ if(!myShiftState)
+ GetSelector()->ClearIObjects();
+
+ vtkActorCollection* aListActors = GetCurrentRenderer()->GetActors();
+ aListActors->InitTraversal();
+ while(vtkActor* aActor = aListActors->GetNextActor())
+ {
+ if(aActor->GetVisibility())
+ {
+ if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor))
+ {
+ if(aSActor->hasIO())
+ aSActor->Highlight( this, aSelectionEvent, true );
+ }
+ }
}
- }
}
- }
Interactor->EndPickCallback();
GetSelector()->EndPickCallback();
}
GetCurrentRenderer());
SALOME_Actor *anActor = GetFirstSALOMEActor(myPicker.GetPointer());
- if (anActor){
- anIsChanged |= anActor->PreHighlight( this, aSelectionEvent, true );
+
+ if ( myCurrRotationPointType == SVTK::StartPointSelection )
+ {
+ myHighlightRotationPointActor->SetVisibility( false );
+
+ SALOME_Actor *anCurrActor;
+ if ( anActor ) anCurrActor = anActor;
+ else if ( myLastPreHighlitedActor.GetPointer()
+ &&
+ myLastPreHighlitedActor.GetPointer() != anActor )
+ anCurrActor = myLastPreHighlitedActor.GetPointer();
+ if ( anCurrActor )
+ {
+ myPointPicker->Pick( aSelectionEvent->myX, aSelectionEvent->myY, 0.0, GetCurrentRenderer() );
+ int aVtkId = myPointPicker->GetPointId();
+ if ( aVtkId >= 0 ) {
+ int anObjId = anActor->GetNodeObjId( aVtkId );
+
+ TColStd_IndexedMapOfInteger aMapIndex;
+ aMapIndex.Add( anObjId );
+ myHighlightRotationPointActor->MapPoints( anActor, aMapIndex );
+
+ myHighlightRotationPointActor->SetVisibility( true );
+ anIsChanged = true;
+ }
+ }
}
+ else {
+ if (anActor){
+ anIsChanged |= anActor->PreHighlight( this, aSelectionEvent, true );
+ }
- if(myLastPreHighlitedActor.GetPointer() && myLastPreHighlitedActor.GetPointer() != anActor)
- anIsChanged |= myLastPreHighlitedActor->PreHighlight( this, aSelectionEvent, false );
+ if(myLastPreHighlitedActor.GetPointer() && myLastPreHighlitedActor.GetPointer() != anActor)
+ anIsChanged |= myLastPreHighlitedActor->PreHighlight( this, aSelectionEvent, false );
+ }
+
myLastPreHighlitedActor = anActor;
if(anIsChanged)
theInteractor->AddObserver( SVTK::StartRotate, EventCallbackCommand, Priority );
theInteractor->AddObserver( SVTK::StartGlobalPan, EventCallbackCommand, Priority );
theInteractor->AddObserver( SVTK::StartFitArea, EventCallbackCommand, Priority );
+
+ theInteractor->AddObserver( SVTK::SetRotateGravity, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::StartPointSelection, EventCallbackCommand, Priority );
+
+ theInteractor->AddObserver( SVTK::ChangeRotationPoint, EventCallbackCommand, Priority );
}
}
{
//vtkInteractorStyle::OnTimer();
this->Interactor->Render();
+ // check if bounding box was changed
+ if ( GetCurrentRenderer() )
+ {
+ vtkFloatingPointType aCurrBBCenter[3];
+ if ( ComputeBBCenter(GetCurrentRenderer(),aCurrBBCenter) )
+ {
+ if ( !myBBFirstCheck )
+ {
+ if ( fabs(aCurrBBCenter[0]-myBBCenter[0]) > 1e-38 ||
+ fabs(aCurrBBCenter[1]-myBBCenter[1]) > 1e-38 ||
+ fabs(aCurrBBCenter[2]-myBBCenter[2]) > 1e-38 ) {
+ // bounding box was changed => send SVTK::RotationPointChanged event
+ // invoke event for update coordinates in SVTK_SetRotationPointDlg
+ InvokeEvent(SVTK::BBCenterChanged,(void*)aCurrBBCenter);
+ for ( int i =0; i < 3; i++) myBBCenter[i] = aCurrBBCenter[i];
+ }
+ }
+ else
+ {
+ for ( int i =0; i < 3; i++) myBBCenter[i] = aCurrBBCenter[i];
+ myBBFirstCheck = false;
+ }
+ }
+ }
}
/*!
vtkObject* anObject = reinterpret_cast<vtkObject*>( clientData );
SVTK_InteractorStyle* self = dynamic_cast<SVTK_InteractorStyle*>( anObject );
int aSpeedIncrement=self->ControllerIncrement()->Current();
+ vtkFloatingPointType aCenter[3];
+ vtkFloatingPointType* aSelectedPoint;
if ( self ) {
switch ( event ) {
case SVTK::SpaceMouseMoveEvent :
case SVTK::StartFitArea:
self->startFitArea();
return;
+
+ case SVTK::SetRotateGravity:
+ if ( self->myCurrRotationPointType == SVTK::StartPointSelection )
+ {
+ self->myHighlightRotationPointActor->SetVisibility( false );
+ if( self->GetCurrentRenderer() != NULL )
+ self->GetCurrentRenderer()->RemoveActor( self->myHighlightRotationPointActor.GetPointer() );
+ self->GetRenderWidget()->setCursor(self->myDefCursor);
+ }
+ self->myPrevRotationPointType = self->myCurrRotationPointType;
+ self->myCurrRotationPointType = SVTK::SetRotateGravity;
+ if ( ComputeBBCenter(self->GetCurrentRenderer(),aCenter) )
+ // invoke event for update coordinates in SVTK_SetRotationPointDlg
+ self->InvokeEvent(SVTK::BBCenterChanged,(void*)aCenter);
+ return;
+ case SVTK::StartPointSelection:
+ self->startPointSelection();
+ return;
+
+ case SVTK::ChangeRotationPoint:
+ if ( self->myCurrRotationPointType == SVTK::StartPointSelection )
+ {
+ self->myHighlightRotationPointActor->SetVisibility( false );
+ if( self->GetCurrentRenderer() != NULL )
+ self->GetCurrentRenderer()->RemoveActor( self->myHighlightRotationPointActor.GetPointer() );
+ self->GetRenderWidget()->setCursor(self->myDefCursor);
+ }
+ self->myPrevRotationPointType = self->myCurrRotationPointType;
+ self->myCurrRotationPointType = SVTK::SetRotateSelected;
+ aSelectedPoint = (vtkFloatingPointType*)callData;
+ self->myRotationPointX = aSelectedPoint[0];
+ self->myRotationPointY = aSelectedPoint[1];
+ self->myRotationPointZ = aSelectedPoint[2];
+ return;
}
}
}
#include <map>
#include <vtkObject.h>
+
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
//
//! Control the value of increment in SALOME way.
/*!
This class controls of value of increment,
for pan/rotate/zoom operations in SALOME way
*/
-class SVTK_ControllerIncrement : public vtkObject{
+class SVTK_EXPORT SVTK_ControllerIncrement : public vtkObject{
public:
vtkTypeMacro(SVTK_ControllerIncrement, vtkObject);
static SVTK_ControllerIncrement* New();
This class controls the behaviour of KeyDown event
in SALOME way
*/
-class SVTK_ControllerOnKeyDown : public vtkObject{
+class SVTK_EXPORT SVTK_ControllerOnKeyDown : public vtkObject{
public:
vtkTypeMacro(SVTK_ControllerOnKeyDown, vtkObject);
static SVTK_ControllerOnKeyDown* New();
class vtkCell;
class vtkPicker;
+class vtkPointPicker;
class SALOME_Actor;
class SVTK_Selector;
class SVTK_GenericRenderWindowInteractor;
+class SVTK_Actor;
#define VTK_INTERACTOR_STYLE_CAMERA_NONE 0
#define VTK_INTERACTOR_STYLE_CAMERA_ROTATE 1
#define VTK_INTERACTOR_STYLE_CAMERA_FIT 5
#define VTK_INTERACTOR_STYLE_CAMERA_SELECT 6
#define VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN 7
+#define VTK_INTERACTOR_STYLE_CAMERA_SELECT_ROTATION_POINT 8
//! Introduce SALOME way of user interaction
/*!
SVTK_Selector* GetSelector();
- protected:
+ protected:
SVTK_InteractorStyle();
~SVTK_InteractorStyle();
void startFitArea();
void startSpin();
+ void startPointSelection();
+
protected:
void loadCursors();
void startOperation(int operation);
PSelectionEvent mySelectionEvent;
vtkSmartPointer<vtkPicker> myPicker;
+
+ unsigned long myCurrRotationPointType;
+ unsigned long myPrevRotationPointType;
+
+ double myRotationPointX;
+ double myRotationPointY;
+ double myRotationPointZ;
+
+ vtkSmartPointer<SVTK_Actor> myHighlightRotationPointActor;
+ vtkSmartPointer<vtkPointPicker> myPointPicker;
+
+ vtkFloatingPointType myBBCenter[3];
+ bool myBBFirstCheck;
};
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
#endif
#include "SVTK_NonIsometricDlg.h"
#include "SVTK_UpdateRateDlg.h"
#include "SVTK_CubeAxesDlg.h"
+#include "SVTK_SetRotationPointDlg.h"
#include "SVTK_MainWindow.h"
#include "SVTK_Event.h"
#include "SVTK_Renderer.h"
#include "SVTK_RenderWindowInteractor.h"
+#include "SVTK_InteractorStyle.h"
#include "SVTK_Selector.h"
myUpdateRateDlg = new SVTK_UpdateRateDlg(myActionsMap[UpdateRate],this,"SVTK_UpdateRateDlg");
myNonIsometricDlg = new SVTK_NonIsometricDlg(myActionsMap[NonIsometric],this,"SVTK_NonIsometricDlg");
myCubeAxesDlg = new SVTK_CubeAxesDlg(myActionsMap[GraduatedAxes],this,"SVTK_CubeAxesDlg");
+ mySetRotationPointDlg = new SVTK_SetRotationPointDlg(myActionsMap[ChangeRotationPointId],this,"SVTK_SetRotationPointDlg");
}
/*!
GetRenderer()->OnAdjustTrihedron();
GetInteractor()->update();
+
+ if ( (SVTK_InteractorStyle*)GetInteractorStyle() )
+ ((SVTK_InteractorStyle*)GetInteractorStyle())->OnTimer();
}
/*!
connect(anAction, SIGNAL(activated()), this, SLOT(activateGlobalPanning()));
myActionsMap[ GlobalPanId ] = anAction;
+ // Change rotation point
+ anAction = new QtxAction(tr("MNU_CHANGINGROTATIONPOINT_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ROTATION_POINT" ) ),
+ tr( "MNU_CHANGINGROTATIONPOINT_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_CHANGINGROTATIONPOINT_VIEW"));
+ anAction->setToggleAction(true);
+ connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onChangeRotationPoint(bool)));
+ myActionsMap[ ChangeRotationPointId ] = anAction;
+
// Rotation
anAction = new QtxAction(tr("MNU_ROTATE_VIEW"),
theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ROTATE" ) ),
aPanningBtn->AddAction(myActionsMap[PanId]);
aPanningBtn->AddAction(myActionsMap[GlobalPanId]);
+ myActionsMap[ChangeRotationPointId]->addTo(myToolBar);
+
myActionsMap[RotationId]->addTo(myToolBar);
SUIT_ToolButton* aViewsBtn = new SUIT_ToolButton(myToolBar);
myEventDispatcher->InvokeEvent(SVTK::StartRotate,0);
}
+/*!
+ Change rotation point
+*/
+void
+SVTK_MainWindow
+::onChangeRotationPoint(bool theIsActivate)
+{
+ if(theIsActivate){
+ mySetRotationPointDlg->addObserver();
+ if ( mySetRotationPointDlg->IsFirstShown() )
+ activateSetRotationGravity();
+ mySetRotationPointDlg->show();
+ }else
+ mySetRotationPointDlg->hide();
+}
+
+/*!
+ Set the gravity center as a rotation point
+*/
+void
+SVTK_MainWindow
+::activateSetRotationGravity()
+{
+ myEventDispatcher->InvokeEvent(SVTK::SetRotateGravity,0);
+}
+
+/*!
+ Set the selected point as a rotation point
+*/
+void
+SVTK_MainWindow
+::activateSetRotationSelected(void* theData)
+{
+ myEventDispatcher->InvokeEvent(SVTK::ChangeRotationPoint,theData);
+}
+
+/*!
+ Set the point selected by user as a rotation point
+*/
+void
+SVTK_MainWindow
+::activateStartPointSelection()
+{
+ myEventDispatcher->InvokeEvent(SVTK::StartPointSelection,0);
+}
+
/*!
Starts global panning transformation
*/
class SVTK_UpdateRateDlg;
class SVTK_CubeAxesActor2D;
class SVTK_CubeAxesDlg;
+class SVTK_SetRotationPointDlg;
class VTKViewer_Trihedron;
class VTKViewer_Transform;
void activatePanning();
void activateGlobalPanning();
+ void onChangeRotationPoint(bool theIsActivate);
+
+ void activateSetRotationGravity();
+ void activateSetRotationSelected(void* theData);
+ void activateStartPointSelection();
+
void onFrontView();
void onBackView();
void onTopView();
void
SetEventDispatcher(vtkObject* theDispatcher);
- enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId,
+ enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId,
+ ChangeRotationPointId, RotationId,
FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId,
ViewTrihedronId, NonIsometric, GraduatedAxes, UpdateRate};
typedef QMap<int, QtxAction*> TActionsMap;
SVTK_NonIsometricDlg* myNonIsometricDlg;
SVTK_UpdateRateDlg* myUpdateRateDlg;
SVTK_CubeAxesDlg* myCubeAxesDlg;
+ SVTK_SetRotationPointDlg* mySetRotationPointDlg;
vtkSmartPointer<vtkObject> myEventDispatcher;
TActionsMap myActionsMap;
class vtkRenderer;
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
/*! \class vtkAbstractPropPicker
* \brief For more information see <a href="http://www.vtk.org/">VTK documentation
*/
vtkRenderer*);
};
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
#endif
QVTK_RenderWindowInteractor
::Initialize(vtkGenericRenderWindowInteractor* theDevice)
{
- if(GetDevice())
- myDevice->SetRenderWindow(NULL);
+ if ( GetDevice() )
+ myDevice->SetRenderWindow( NULL );
myDevice = theDevice;
- if(theDevice)
- theDevice->SetRenderWindow(getRenderWindow());
+ if ( theDevice )
+ theDevice->SetRenderWindow( getRenderWindow() );
}
/*!
QVTK_RenderWindowInteractor
::~QVTK_RenderWindowInteractor()
{
- if(SVTK_SpaceMouse* aSpaceMouse = SVTK_SpaceMouse::getInstance())
- if(aSpaceMouse->isSpaceMouseOn())
- aSpaceMouse->close(x11Display());
+#ifndef WIN32
+ SVTK_SpaceMouse* aSpaceMouse = SVTK_SpaceMouse::getInstance();
+ if ( aSpaceMouse && aSpaceMouse->isSpaceMouseOn() )
+ aSpaceMouse->close( x11Display() );
+#endif
}
{
// Final initialization just before the widget is displayed
GetDevice()->SetSize(width(),height());
- if(!GetDevice()->GetInitialized()){
+ if(!GetDevice()->GetInitialized() && GetDevice()->GetRenderWindow()){
GetDevice()->Initialize();
GetDevice()->ConfigureEvent();
}
{
QWidget::focusInEvent( event );
+#ifndef WIN32
// register set space mouse events receiver
- if(SVTK_SpaceMouse* aSpaceMouse = SVTK_SpaceMouse::getInstance()){
- if(!aSpaceMouse->isSpaceMouseOn()) {// initialize 3D space mouse driver
- aSpaceMouse->initialize(x11Display(),winId());
- }else{
- aSpaceMouse->setWindow(x11Display(),winId());
- }
+ SVTK_SpaceMouse* aSpaceMouse = SVTK_SpaceMouse::getInstance();
+
+ if ( aSpaceMouse )
+ {
+ if ( !aSpaceMouse->isSpaceMouseOn() )
+ // initialize 3D space mouse driver
+ aSpaceMouse->initialize( x11Display(), winId() );
+ else
+ aSpaceMouse->setWindow( x11Display(), winId() );
}
+#endif
}
/*!
{
QWidget::focusOutEvent( event );
+#ifndef WIN32
// unregister set space mouse events receiver
- if(SVTK_SpaceMouse* aSpaceMouse = SVTK_SpaceMouse::getInstance()){
- if(aSpaceMouse->isSpaceMouseOn())
- aSpaceMouse->setWindow(x11Display(),0);
- }
+ SVTK_SpaceMouse* aSpaceMouse = SVTK_SpaceMouse::getInstance();
+ if ( aSpaceMouse && aSpaceMouse->isSpaceMouseOn() )
+ aSpaceMouse->setWindow( x11Display(), 0 );
+#endif
+}
+
+
+#ifdef WIN32
+
+/*!
+ To handle native Win32 events (from such devices as SpaceMouse)
+*/
+bool QVTK_RenderWindowInteractor::winEvent( MSG* msg )
+{
+ // TODO: Implement event handling for SpaceMouse
+ return QWidget::winEvent( msg );
}
+#else
/*!
To handle native X11 events (from such devices as SpaceMouse)
::x11Event( XEvent *xEvent )
{
// handle 3d space mouse events
- if(SVTK_SpaceMouse* aSpaceMouse = SVTK_SpaceMouse::getInstance()){
- if(aSpaceMouse->isSpaceMouseOn() && xEvent->type == ClientMessage){
+ if ( SVTK_SpaceMouse* aSpaceMouse = SVTK_SpaceMouse::getInstance() )
+ {
+ if ( aSpaceMouse->isSpaceMouseOn() && xEvent->type == ClientMessage )
+ {
SVTK_SpaceMouse::MoveEvent anEvent;
int type = aSpaceMouse->translateEvent( x11Display(), xEvent, &anEvent, 1.0, 1.0 );
- switch( type ){
- case SVTK_SpaceMouse::SpaceMouseMove :
- GetDevice()->InvokeEvent(SVTK::SpaceMouseMoveEvent, anEvent.data );
- break;
- case SVTK_SpaceMouse::SpaceButtonPress :
- GetDevice()->InvokeEvent( SVTK::SpaceMouseButtonEvent, &anEvent.button );
- break;
- case SVTK_SpaceMouse::SpaceButtonRelease :
- break;
+ switch ( type )
+ {
+ case SVTK_SpaceMouse::SpaceMouseMove:
+ GetDevice()->InvokeEvent( SVTK::SpaceMouseMoveEvent, anEvent.data );
+ break;
+ case SVTK_SpaceMouse::SpaceButtonPress:
+ GetDevice()->InvokeEvent( SVTK::SpaceMouseButtonEvent, &anEvent.button );
+ break;
+ case SVTK_SpaceMouse::SpaceButtonRelease:
+ break;
}
return true; // stop handling the event
}
return QWidget::x11Event( xEvent );
}
+#endif
+
/*!
Constructor
*/
class SVTK_Selector;
class SVTK_Renderer;
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
/*!
\class QVTK_RenderWindowInteractor
Implements Qt based vtkRenderWindowInteractor.
virtual void focusInEvent( QFocusEvent* );
virtual void focusOutEvent( QFocusEvent* );
- //! To handle native X11 events (from such devices as SpaceMouse)
+ //! To handle native events (from such devices as SpaceMouse)
+#ifdef WIN32
+ virtual bool winEvent( MSG* );
+#else
virtual bool x11Event( XEvent *e );
+#endif
vtkSmartPointer<vtkRenderWindow> myRenderWindow;
vtkSmartPointer<vtkGenericRenderWindowInteractor> myDevice;
TInteractorStyles myInteractorStyles;
};
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
#endif
class VTKViewer_Actor;
class SVTK_Selector;
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
/*!
\class SVTK_Renderer
vtkFloatingPointType myBndBox[6];
};
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
#endif
TMapIOSubIndex::const_iterator anIter = myMapIOSubIndex.find(theIO);
if(anIter != myMapIOSubIndex.end()){
const TColStd_IndexedMapOfInteger& aMapIndex = anIter->second.myMap;
- return aMapIndex.Contains(theIndex);
+ return aMapIndex.Contains( theIndex ) == Standard_True;
}
return false;
}
-static
-bool
-removeIndex(TColStd_IndexedMapOfInteger& theMapIndex,
- const int theIndex)
+static bool removeIndex(TColStd_IndexedMapOfInteger& theMapIndex, const int theIndex)
{
int anId = theMapIndex.FindIndex(theIndex); // i==0 if Index is not in the MapIndex
if(anId){
theMapIndex = aNewMap;
}
}
- return anId;
+ return anId != 0;
}
/*!
}
TColStd_IndexedMapOfInteger& aMapIndex = anIter->second.myMap;
- bool anIsConatains = aMapIndex.Contains(theIndex);
- if(anIsConatains)
- removeIndex(aMapIndex,theIndex);
+ bool anIsConatains = aMapIndex.Contains( theIndex ) == Standard_True;
+ if ( anIsConatains )
+ removeIndex( aMapIndex, theIndex );
- if(!theIsModeShift)
+ if ( !theIsModeShift )
aMapIndex.Clear();
- if(!anIsConatains)
+ if ( !anIsConatains )
aMapIndex.Add( theIndex );
- if( aMapIndex.IsEmpty())
- myMapIOSubIndex.erase(theIO);
+ if ( aMapIndex.IsEmpty() )
+ myMapIOSubIndex.erase( theIO );
return false;
}
#ifndef SVTK_SELECTOR_H
#define SVTK_SELECTOR_H
+#include "SVTK.h"
#include "SVTK_Selection.h"
#include "SALOME_ListIO.hxx"
#include "VTKViewer_Filter.h"
\note
Also, for each #SALOME_InteractiveObject it tries to keep corresponding refenrence to #SALOME_Actor
*/
-class SVTK_Selector: public vtkObject
+class SVTK_EXPORT SVTK_Selector: public vtkObject
{
public:
static SVTK_Selector* New();
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// Copyright (C) 2003 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 :
+// Author :
+// Module : SALOME
+// $Header$
+
+#include "SVTK_SetRotationPointDlg.h"
+#include "SVTK_MainWindow.h"
+#include "SVTK_RenderWindowInteractor.h"
+#include "SVTK_Event.h"
+#include "SVTK_InteractorStyle.h"
+
+#include "VTKViewer_Utilities.h"
+
+#include "QtxAction.h"
+
+#include <qlineedit.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qlayout.h>
+#include <qvalidator.h>
+#include <qbuttongroup.h>
+#include <qobjectlist.h>
+#include <qcheckbox.h>
+#include <qhbox.h>
+
+#include <vtkCallbackCommand.h>
+
+using namespace std;
+
+/*!
+ Constructor
+*/
+SVTK_SetRotationPointDlg
+::SVTK_SetRotationPointDlg(QtxAction* theAction,
+ SVTK_MainWindow* theParent,
+ const char* theName):
+ SVTK_DialogBase(theAction,
+ theParent,
+ theName),
+ myMainWindow(theParent),
+ myPriority(0.0),
+ myEventCallbackCommand(vtkCallbackCommand::New()),
+ myRWInteractor(theParent->GetInteractor())
+{
+ setCaption(tr("DLG_TITLE"));
+ setSizeGripEnabled(TRUE);
+
+ // Create layout for this dialog
+ QGridLayout* layoutDlg = new QGridLayout (this);
+ layoutDlg->setSpacing(6);
+ layoutDlg->setMargin(11);
+
+ // Create check box "Use Bounding Box Center"
+ QHBox* aCheckBox = new QHBox(this);
+
+ myIsBBCenter = new QCheckBox(tr("USE_BBCENTER"), aCheckBox);
+ myIsBBCenter->setChecked(true);
+ connect(myIsBBCenter, SIGNAL(stateChanged(int)), SLOT(onBBCenterChecked()));
+
+ // Create croup button with radio buttons
+ myGroupSelButton = new QButtonGroup(2,Qt::Vertical,"",this);
+ myGroupSelButton->setMargin(11);
+
+ // Create "Set to Origin" button
+ myToOrigin = new QPushButton(myGroupSelButton);
+ myToOrigin->setText(tr("LBL_TOORIGIN"));
+ connect(myToOrigin, SIGNAL(clicked()), this, SLOT(onToOrigin()));
+
+ // Create "Select Point from View" button
+ mySelectPoint = new QPushButton(myGroupSelButton);
+ mySelectPoint->setText(tr("LBL_SELECTPOINT"));
+ mySelectPoint->setToggleButton(true);
+ connect(mySelectPoint, SIGNAL(clicked()), this, SLOT(onSelectPoint()));
+
+ // Create croup box with grid layout
+ myGroupBoxCoord = new QGroupBox(this, "GroupBox");
+ QHBoxLayout* aHBoxLayout = new QHBoxLayout(myGroupBoxCoord);
+ aHBoxLayout->setMargin(11);
+ aHBoxLayout->setSpacing(6);
+
+ // "X" coordinate
+ QLabel* TextLabelX = new QLabel (tr("LBL_X"), myGroupBoxCoord, "TextLabelX");
+ TextLabelX->setFixedWidth(15);
+ myX = new QLineEdit(myGroupBoxCoord);
+ myX->setValidator(new QDoubleValidator(myX));
+ myX->setText(QString::number(0.0));
+ connect(myX, SIGNAL(textChanged(const QString&)), this, SLOT(onCoordChanged()));
+
+ // "Y" coordinate
+ QLabel* TextLabelY = new QLabel (tr("LBL_Y"), myGroupBoxCoord, "TextLabelY");
+ TextLabelY->setFixedWidth(15);
+ myY = new QLineEdit(myGroupBoxCoord);
+ myY->setValidator(new QDoubleValidator(myY));
+ myY->setText(QString::number(0.0));
+ connect(myY, SIGNAL(textChanged(const QString&)), this, SLOT(onCoordChanged()));
+
+ // "Z" coordinate
+ QLabel* TextLabelZ = new QLabel (tr("LBL_Z"), myGroupBoxCoord, "TextLabelZ");
+ TextLabelZ->setFixedWidth(15);
+ myZ = new QLineEdit(myGroupBoxCoord);
+ myZ->setValidator(new QDoubleValidator(myZ));
+ myZ->setText(QString::number(0.0));
+ connect(myZ, SIGNAL(textChanged(const QString&)), this, SLOT(onCoordChanged()));
+
+ // Layout widgets in the horizontal group box
+ aHBoxLayout->addWidget(TextLabelX);
+ aHBoxLayout->addWidget(myX);
+ aHBoxLayout->addWidget(TextLabelY);
+ aHBoxLayout->addWidget(myY);
+ aHBoxLayout->addWidget(TextLabelZ);
+ aHBoxLayout->addWidget(myZ);
+
+ // "Close" button
+ QGroupBox* aGroupBox = new QGroupBox(this);
+ QHBoxLayout* aHBoxLayout2 = new QHBoxLayout(aGroupBox);
+ aHBoxLayout2->setMargin(11);
+ aHBoxLayout2->setSpacing(6);
+
+ QPushButton* m_bClose = new QPushButton(tr("&Close"), aGroupBox, "m_bClose");
+ m_bClose->setAutoDefault(TRUE);
+ m_bClose->setFixedSize(m_bClose->sizeHint());
+ connect(m_bClose, SIGNAL(clicked()), this, SLOT(onClickClose()));
+
+ // Layout buttons
+ aHBoxLayout2->addWidget(m_bClose);
+
+ // Layout top level widgets
+ layoutDlg->addWidget(aCheckBox,0,0);
+ layoutDlg->addWidget(myGroupSelButton,1,0);
+ layoutDlg->addWidget(myGroupBoxCoord,2,0);
+ layoutDlg->addWidget(aGroupBox,3,0);
+
+ setEnabled(myGroupSelButton,!myIsBBCenter->isChecked());
+ setEnabled(myGroupBoxCoord,!myIsBBCenter->isChecked());
+
+ this->resize(400, this->sizeHint().height());
+
+ myEventCallbackCommand->Delete();
+ myEventCallbackCommand->SetClientData(this);
+ myEventCallbackCommand->SetCallback(SVTK_SetRotationPointDlg::ProcessEvents);
+ myIsObserverAdded = false;
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+SVTK_SetRotationPointDlg
+::~SVTK_SetRotationPointDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+void
+SVTK_SetRotationPointDlg
+::addObserver()
+{
+ if ( !myIsObserverAdded ) {
+ vtkInteractorStyle* aIStyle = myRWInteractor->GetInteractorStyle();
+ aIStyle->AddObserver(SVTK::BBCenterChanged, myEventCallbackCommand.GetPointer(), myPriority);
+ aIStyle->AddObserver(SVTK::RotationPointChanged, myEventCallbackCommand.GetPointer(), myPriority);
+ myIsObserverAdded = true;
+ }
+}
+
+/*!
+ Return true if it is the first show for this dialog
+*/
+bool
+SVTK_SetRotationPointDlg
+::IsFirstShown()
+{
+ return myIsBBCenter->isChecked() && myX->text().toDouble() == 0.
+ && myY->text().toDouble() == 0. && myZ->text().toDouble() == 0.;
+}
+
+/*!
+ Processes events
+*/
+void
+SVTK_SetRotationPointDlg
+::ProcessEvents(vtkObject* vtkNotUsed(theObject),
+ unsigned long theEvent,
+ void* theClientData,
+ void* theCallData)
+{
+ SVTK_SetRotationPointDlg* self = reinterpret_cast<SVTK_SetRotationPointDlg*>(theClientData);
+ vtkFloatingPointType* aCoord = (vtkFloatingPointType*)theCallData;
+
+ switch ( theEvent ) {
+ case SVTK::BBCenterChanged:
+ if ( self->myIsBBCenter->isChecked()
+ ||
+ IsBBEmpty(self->myMainWindow->getRenderer()) )
+ {
+ if ( aCoord )
+ {
+ self->myX->setText( QString::number(aCoord[0]) );
+ self->myY->setText( QString::number(aCoord[1]) );
+ self->myZ->setText( QString::number(aCoord[2]) );
+ }
+ }
+ break;
+ case SVTK::RotationPointChanged:
+ if ( aCoord )
+ {
+ self->myX->setText( QString::number(aCoord[0]) );
+ self->myY->setText( QString::number(aCoord[1]) );
+ self->myZ->setText( QString::number(aCoord[2]) );
+ }
+ if ( !self->myIsBBCenter->isChecked() )
+ self->mySelectPoint->toggle();
+ }
+}
+
+void
+SVTK_SetRotationPointDlg
+::setEnabled(QGroupBox* theGrp, const bool theState)
+{
+ QObjectList aChildren(*theGrp->children());
+ QObject* anObj;
+ for(anObj = aChildren.first(); anObj !=0; anObj = aChildren.next())
+ {
+ if (anObj !=0 && anObj->inherits("QLineEdit"))
+ ((QLineEdit*)anObj)->setReadOnly(!theState);
+ if (anObj !=0 && anObj->inherits("QPushButton"))
+ ((QLineEdit*)anObj)->setEnabled(theState);
+ }
+
+}
+
+void
+SVTK_SetRotationPointDlg
+::onBBCenterChecked()
+{
+ setEnabled(myGroupSelButton,!myIsBBCenter->isChecked());
+ setEnabled(myGroupBoxCoord,!myIsBBCenter->isChecked());
+
+ if ( myIsBBCenter->isChecked() )
+ {
+ if ( mySelectPoint->state() == QButton::On )
+ mySelectPoint->toggle();
+ // activate mode : the rotation point is the center of the bounding box
+ // send the data to the SVTK_InteractorStyle: set the type of the rotation point
+ // calculate coordinates of the rotation point
+ myMainWindow->activateSetRotationGravity();
+ }
+ else
+ {
+ QString aX = myX->text();
+ myX->setText(QString::number(aX.toDouble()+1.));
+ myX->setText(aX);
+ }
+}
+
+void
+SVTK_SetRotationPointDlg
+::onToOrigin()
+{
+ if ( mySelectPoint->state() == QButton::On )
+ mySelectPoint->toggle();
+ myX->setText(QString::number(0.0));
+ myY->setText(QString::number(0.0));
+ myZ->setText(QString::number(0.0));
+}
+
+void
+SVTK_SetRotationPointDlg
+::onSelectPoint()
+{
+ if ( mySelectPoint->state() == QButton::On )
+ myMainWindow->activateStartPointSelection();
+ else
+ mySelectPoint->toggle();
+}
+
+void
+SVTK_SetRotationPointDlg
+::onCoordChanged()
+{
+ if ( !myIsBBCenter->isChecked() ) {
+ if ( mySelectPoint->state() == QButton::On
+ &&
+ ( myX->hasFocus() || myY->hasFocus() || myZ->hasFocus() ) )
+ mySelectPoint->toggle();
+ vtkFloatingPointType aCenter[3] = {myX->text().toDouble(),
+ myY->text().toDouble(),
+ myZ->text().toDouble()};
+ myMainWindow->activateSetRotationSelected((void*)aCenter);
+ }
+ else
+ myMainWindow->activateSetRotationGravity();
+}
+
+void
+SVTK_SetRotationPointDlg
+::onClickClose()
+{
+ reject();
+}
+
+
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// Copyright (C) 2003 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 :
+// Author :
+// Module : SALOME
+// $Header$
+
+#ifndef SVTK_SETROTATIONPOINTDLG_H
+#define SVTK_SETROTATIONPOINTDLG_H
+
+#include "SVTK.h"
+
+#include "SVTK_DialogBase.h"
+
+#include <vtkSmartPointer.h>
+
+class SVTK_MainWindow;
+class SVTK_RenderWindowInteractor;
+
+class QtxAction;
+
+class QLineEdit;
+class QPushButton;
+class QGroupBox;
+class QButtonGroup;
+class QCheckBox;
+
+class vtkCallbackCommand;
+class vtkObject;
+
+class SVTK_EXPORT SVTK_SetRotationPointDlg : public SVTK_DialogBase
+{
+ Q_OBJECT;
+
+public:
+ SVTK_SetRotationPointDlg(QtxAction* theAction,
+ SVTK_MainWindow* theParent,
+ const char* theName);
+
+ ~SVTK_SetRotationPointDlg();
+
+ void addObserver();
+ bool IsFirstShown();
+
+protected:
+ SVTK_MainWindow *myMainWindow;
+ SVTK_RenderWindowInteractor* myRWInteractor;
+ bool myIsObserverAdded;
+
+ QCheckBox* myIsBBCenter;
+
+ QButtonGroup* myGroupSelButton;
+ QPushButton* myToOrigin;
+ QPushButton* mySelectPoint;
+
+ QGroupBox* myGroupBoxCoord;
+ QLineEdit* myX;
+ QLineEdit* myY;
+ QLineEdit* myZ;
+
+ void setEnabled(QGroupBox* theGrp, const bool theState);
+
+ //----------------------------------------------------------------------------
+ // Priority at which events are processed
+ vtkFloatingPointType myPriority;
+
+ // Used to process events
+ vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
+
+ // Description:
+ // Main process event method
+ static void ProcessEvents(vtkObject* object,
+ unsigned long event,
+ void* clientdata,
+ void* calldata);
+
+protected slots:
+ void onBBCenterChecked();
+
+ void onToOrigin();
+ void onSelectPoint();
+
+ void onCoordChanged();
+
+ void onClickClose();
+
+};
+
+#endif // SVTK_SETROTATIONPOINTDLG_H
#include <math.h>
#include <stdio.h>
+#ifndef WIN32
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/keysym.h>
+#endif
#include "SVTK_SpaceMouse.h"
*/
SVTK_SpaceMouse::SVTK_SpaceMouse()
{
+#ifndef WIN32
win = InputFocus;
+#endif
spaceMouseOn = 0;
}
+#ifndef WIN32
+
/*!
Initialization
*/
return (!display);
}
+#endif
#ifndef SVTK_SpaceMouse_h
#define SVTK_SpaceMouse_h
+#ifndef WIN32
extern "C"
{
#include <X11/X.h>
#include <X11/Xlib.h>
}
+#endif
class SVTK_SpaceMouse
{
bool isSpaceMouseOn() const { return spaceMouseOn != 0; }
+#ifndef WIN32
int initialize ( Display*, Window );
int setWindow ( Display*, Window );
int translateEvent ( Display*, XEvent*, MoveEvent*, double, double );
int close ( Display* );
+#endif
private:
SVTK_SpaceMouse();
static SVTK_SpaceMouse* myInstance;
+#ifndef WIN32
Atom XMotionEvent;
Atom XButtonPressEvent;
Atom XButtonReleaseEvent;
Atom XCommandEvent;
Window win;
+#endif
int spaceMouseOn;
};
int aCount = 0;
while(vtkActor* aProp = aCollection->GetNextActor()) {
if(aProp->GetVisibility())
- if(SALOME_Actor* anActor = SALOME_Actor::SafeDownCast(aProp))
+ if(SALOME_Actor* anActor = SALOME_Actor::SafeDownCast(aProp)) {
if(!anActor->IsInfinitive())
- aCount++;
+ aCount++;
+ }
+ else if ( !OwnActor( anActor ) ) {
+ aCount++;
+ }
}
return aCount;
}
#include "SVTK_ViewManager.h"
#include "SVTK_ViewModel.h"
-int SVTK_ViewManager::_SVTKViewMgr_Id = 0;
+#include <VTKViewer_ViewManager.h>
/*!
Constructor
*/
-SVTK_ViewManager::SVTK_ViewManager( SUIT_Study* study,
- SUIT_Desktop* theDesktop )
-: SUIT_ViewManager( study, theDesktop )
+SVTK_ViewManager::SVTK_ViewManager( SUIT_Study* study, SUIT_Desktop* theDesktop )
+: SUIT_ViewManager( study, theDesktop, new SVTK_Viewer() )
{
- myId = ++_SVTKViewMgr_Id;
- setViewModel( new SVTK_Viewer() );
+ setTitle( VTKViewer_ViewManager::tr( "VTK_VIEW_TITLE" ) );
}
/*!
{
return myDesktop;
}
-
-/*!
- Sets default name of view
-*/
-void SVTK_ViewManager::setViewName(SUIT_ViewWindow* theView)
-{
- int aPos = myViews.find(theView);
- theView->setCaption( tr( "VTK_VIEW_TITLE" ).arg( myId ).arg( aPos + 1 ) );
-}
virtual ~SVTK_ViewManager();
SUIT_Desktop* getDesktop();
-
-protected:
- void setViewName( SUIT_ViewWindow* theView );
-
-private:
- int myId;
- static int _SVTKViewMgr_Id;
};
#endif
if (SUIT_ViewManager* aViewManager = getViewManager()) {
QPtrVector<SUIT_ViewWindow> aViews = aViewManager->getViews();
- for (int i = 0; i < aViews.count(); i++) {
- if (TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at(i))) {
- aView->SetTrihedronSize(theSize, theRelative);
- }
+ for ( uint i = 0; i < aViews.count(); i++ )
+ {
+ if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
+ aView->SetTrihedronSize( theSize, theRelative );
}
}
}
#include "VTKViewer_Algorithm.h"
#include "SVTK_Functor.h"
+
+namespace SVTK
+{
+ int convertAction( const int accelAction )
+ {
+ switch ( accelAction ) {
+ case SUIT_Accel::PanLeft : return SVTK::PanLeftEvent;
+ case SUIT_Accel::PanRight : return SVTK::PanRightEvent;
+ case SUIT_Accel::PanUp : return SVTK::PanUpEvent;
+ case SUIT_Accel::PanDown : return SVTK::PanDownEvent;
+ case SUIT_Accel::ZoomIn : return SVTK::ZoomInEvent;
+ case SUIT_Accel::ZoomOut : return SVTK::ZoomOutEvent;
+ case SUIT_Accel::RotateLeft : return SVTK::RotateLeftEvent;
+ case SUIT_Accel::RotateRight : return SVTK::RotateRightEvent;
+ case SUIT_Accel::RotateUp : return SVTK::RotateUpEvent;
+ case SUIT_Accel::RotateDown : return SVTK::RotateDownEvent;
+ }
+ return accelAction;
+ }
+}
+
+
+
+
+
/*!
Constructor
*/
myView->SetSelectionTolerance(theTolNodes,theTolItems);
}
-int convertAction( const int accelAction )
-{
- switch ( accelAction ) {
- case SUIT_Accel::PanLeft : return SVTK::PanLeftEvent;
- case SUIT_Accel::PanRight : return SVTK::PanRightEvent;
- case SUIT_Accel::PanUp : return SVTK::PanUpEvent;
- case SUIT_Accel::PanDown : return SVTK::PanDownEvent;
- case SUIT_Accel::ZoomIn : return SVTK::ZoomInEvent;
- case SUIT_Accel::ZoomOut : return SVTK::ZoomOutEvent;
- case SUIT_Accel::RotateLeft : return SVTK::RotateLeftEvent;
- case SUIT_Accel::RotateRight : return SVTK::RotateRightEvent;
- case SUIT_Accel::RotateUp : return SVTK::RotateUpEvent;
- case SUIT_Accel::RotateDown : return SVTK::RotateDownEvent;
- }
- return accelAction;
-}
-
/*!
Performs action
\param accelAction - action
if ( accelAction == SUIT_Accel::ZoomFit )
onFitAll();
else {
- int anEvent = convertAction( accelAction );
+ int anEvent = SVTK::convertAction( accelAction );
myMainWindow->InvokeEvent( anEvent, 0 );
}
return true;
class vtkRenderWindow;
class vtkRenderWindowInteractor;
+namespace SVTK
+{
+ SVTK_EXPORT
+ int convertAction( const int );
+}
+
//! Define a container for SALOME VTK view window
class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow
{
msgid "MNU_ROTATE_VIEW"
msgstr "Rotation"
+msgid "DSC_CHANGINGROTATIONPOINT_VIEW"
+msgstr "Change the point, around which the rotation is performed"
+
+msgid "MNU_CHANGINGROTATIONPOINT_VIEW"
+msgstr "Change Rotation Point"
+
msgid "DSC_DUMP_VIEW"
msgstr "Saves the active view in the image file"
msgid "SVTK_MainWindow::DSC_SVTK_SCALING"
msgstr "Scaling"
+msgid "SVTK_SetRotationPointDlg::DLG_TITLE"
+msgstr "Set Rotation Point"
+
+msgid "SVTK_SetRotationPointDlg::USE_BBCENTER"
+msgstr "Use Bounding Box Center"
+
+msgid "SVTK_SetRotationPointDlg::LBL_TOORIGIN"
+msgstr "Set to Origin"
+
+msgid "SVTK_SetRotationPointDlg::LBL_SELECTPOINT"
+msgstr "Select Point from View"
+
+msgid "SVTK_SetRotationPointDlg::LBL_CENTER_OF_BOUNDING_BOX"
+msgstr "Center of bounding box"
+
+msgid "SVTK_SetRotationPointDlg::LBL_ORIGIN"
+msgstr "Origin of the coordinate system"
+
+msgid "SVTK_SetRotationPointDlg::LBL_SELECTED_POINT"
+msgstr "Selected point"
+
+msgid "SVTK_SetRotationPointDlg::LBL_X"
+msgstr "X :"
+
+msgid "SVTK_SetRotationPointDlg::LBL_Y"
+msgstr "Y :"
+
+msgid "SVTK_SetRotationPointDlg::LBL_Z"
+msgstr "Z :"
+
+msgid "SVTK_SetRotationPointDlg::RBUTTONGROUP_TITLE"
+msgstr "The rotation point type"
+
msgid "SVTK_FontWidget::ARIAL"
msgstr "Arial"
CPPFLAGS+=$(PYTHON_INCLUDES) $(QT_INCLUDES) $(QWT_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(BOOST_CPPFLAGS) $(KERNEL_CXXFLAGS)
LDFLAGS+=$(PYTHON_LIBS) $(QT_MT_LIBS)
-LIBS+= -lsuit -lstd -lCAM -lObjBrowser -lSalomePrs $(KERNEL_LDFLAGS) -lOpUtil -lSALOMELocalTrace -lSalomeDSClient $(CAS_KERNEL) -lSPlot2d -lGLViewer -lOCCViewer -lVTKViewer -lSalomeObject -lSVTK -lSOCC -lPyInterp -lPythonConsole -lLogWindow -lLightApp -lSalomeContainer -lToolsGUI
+LIBS+= -lsuit -lstd -lCAM -lObjBrowser -lSalomePrs $(KERNEL_LDFLAGS) -lOpUtil -lSALOMELocalTrace -lSalomeDSClient $(CAS_KERNEL) -lSPlot2d -lGLViewer -lOCCViewer -lVTKViewer -lSalomeObject -lSVTK -lSOCC -lPyInterp -lPythonConsole -lLogWindow -lLightApp -lSalomeContainer -lToolsGUI -lTOOLSDS -lSalomeSession
@CONCLUDE@
#include <SALOMEDSClient_ClientFactory.hxx>
#include <vector>
+/*!Internal class that updates object browser item properties */
+class SalomeApp_Updater : public OB_Updater
+{
+public:
+ SalomeApp_Updater() : OB_Updater(){};
+ virtual ~SalomeApp_Updater(){};
+ virtual void update( SUIT_DataObject* theObj, OB_ListItem* theItem );
+};
+
+void SalomeApp_Updater::update( SUIT_DataObject* theObj, OB_ListItem* theItem )
+{
+ if( !theObj || !theItem )
+ return;
+
+ SalomeApp_DataObject* SAObj = dynamic_cast<SalomeApp_DataObject*>( theObj );
+ if( !SAObj )
+ return;
+
+ _PTR(SObject) SObj = SAObj->object();
+ if( !SObj )
+ return;
+ _PTR( GenericAttribute ) anAttr;
+
+ // Selectable
+ if ( SObj->FindAttribute( anAttr, "AttributeSelectable" ) )
+ {
+ _PTR(AttributeSelectable) aAttrSel = anAttr;
+ theItem->setSelectable( aAttrSel->IsSelectable() );
+ }
+ // Expandable
+ if ( SObj->FindAttribute(anAttr, "AttributeExpandable") )
+ {
+ _PTR(AttributeExpandable) aAttrExpand = anAttr;
+ theItem->setExpandable( aAttrExpand->IsExpandable() );
+ }
+ // Opened
+ //this attribute is not supported in the version of SALOME 3.x
+ //if ( SObj->FindAttribute(anAttr, "AttributeOpened") )
+ //{
+ // _PTR(AttributeOpened) aAttrOpen = anAttr;
+ // theItem->setOpen( aAttrOpen->IsOpened() );
+ //}
+}
/*!Create new instance of SalomeApp_Application.*/
extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication()
LightApp_Application::start();
SalomeApp_EventFilter::Init();
+
+ static bool isFirst = true;
+ if ( isFirst ) {
+ isFirst = false;
+ QString hdffile;
+ QStringList pyfiles;
+ for (int i = 1; i < qApp->argc(); i++) {
+ QRegExp rx("--test=(.+)");
+ if ( rx.search( QString(qApp->argv()[i]) ) >= 0 && rx.capturedTexts().count() > 0 ) {
+ QStringList files = QStringList::split(",",rx.capturedTexts()[1],false);
+ for (uint j = 0; j < files.count(); j++ ) {
+ QFileInfo fi( files[j] );
+ QString extension = fi.extension( false ).lower();
+ if ( extension == "hdf" && fi.exists() )
+ hdffile = fi.absFilePath();
+ else if ( extension == "py" || extension == "" )
+ pyfiles.append( fi.baseName( true ) );
+ }
+ }
+ }
+ if ( !hdffile.isEmpty() ) // open hdf file given as parameter
+ onOpenDoc( hdffile );
+ else if ( pyfiles.count() > 0 ) // create new study
+ onNewDoc();
+ // import python scripts
+ if ( pyfiles.count() > 0 && activeStudy() ) {
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
+ if ( appStudy ) {
+ _PTR(Study) aStudy = appStudy->studyDS();
+ if ( !aStudy->GetProperties()->IsLocked() ) {
+ for ( uint i = 0; i < pyfiles.count(); i++ ) {
+ QString command = QString( "import %1" ).arg( pyfiles[i] );
+ PythonConsole* pyConsole = pythonConsole();
+ if ( pyConsole )
+ pyConsole->exec( command );
+ }
+ }
+ }
+ }
+ }
}
/*!Create actions:*/
tr( "MEN_DESK_REGISTRY_DISPLAY" ), tr( "PRP_DESK_REGISTRY_DISPLAY" ),
/*SHIFT+Key_D*/0, desk, false, this, SLOT( onRegDisplay() ) );
+ //SRN: BugID IPAL9021, add an action "Load"
+ createAction( FileLoadId, tr( "TOT_DESK_FILE_LOAD" ),
+ resourceMgr()->loadPixmap( "STD", tr( "ICON_FILE_OPEN" ) ),
+ tr( "MEN_DESK_FILE_LOAD" ), tr( "PRP_DESK_FILE_LOAD" ),
+ CTRL+Key_L, desk, false, this, SLOT( onLoadDoc() ) );
+ //SRN: BugID IPAL9021: End
+
+
int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
// "Save GUI State" command is renamed to "Save VISU State" and
// creation of menu item is moved to VISU
// createMenu( SaveGUIStateId, fileMenu, 10, -1 );
+ createMenu( FileLoadId, fileMenu, 0 ); //SRN: BugID IPAL9021, add a menu item "Load"
+
createMenu( DumpStudyId, fileMenu, 10, -1 );
createMenu( separator(), fileMenu, -1, 15, -1 );
createMenu( LoadScriptId, fileMenu, 10, -1 );
return;
name = studyname;
+#ifndef WNT
+ //this code replace marker of windows drive and path become invalid therefore
+ // defines placed there
name.replace( QRegExp(":"), "/" );
+#endif
if( LightApp_Application::onLoadDoc( name ) )
{
if ( flag == WT_ObjectBrowser )
{
OB_Browser* ob = (OB_Browser*)wid;
+ ob->setUpdater( new SalomeApp_Updater() );
connect( ob->listView(), SIGNAL( doubleClicked( QListViewItem* ) ), this, SLOT( onDblClick( QListViewItem* ) ) );
bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false ),
autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
QString anIOR( "" );
CORBA::Object_ptr anEngine = namingService()->Resolve( "/SalomeAppEngine" );
if ( !CORBA::is_nil( anEngine ) )
- anIOR = orb()->object_to_string( anEngine );
+ {
+ CORBA::String_var objStr = orb()->object_to_string( anEngine );
+ anIOR = QString( objStr.in() );
+ }
return anIOR;
}
CAM_Module* currentModule = activeModule();
if (currentModule && currentModule->moduleName() == aModuleTitle)
return;
- thePopup->insertItem( tr( "MEN_OPENWITH" ), this, SLOT( onOpenWith() ) );
+ if ( !aModuleTitle.isEmpty() )
+ thePopup->insertItem( tr( "MEN_OPENWITH" ).arg( aModuleTitle ), this, SLOT( onOpenWith() ) );
}
/*!Update obect browser:
delete it.data();
}
+/*! Check data object */
+bool SalomeApp_Application::checkDataObject(LightApp_DataObject* theObj)
+{
+ if (theObj)
+ return true;
+
+ return false;
+}
public:
enum { MenuToolsId = 5 };
enum { DumpStudyId = LightApp_Application::UserID, LoadScriptId, PropertiesId,
- CatalogGenId, RegDisplayId, SaveGUIStateId, UserID };
+ CatalogGenId, RegDisplayId, SaveGUIStateId, FileLoadId, UserID };
public:
SalomeApp_Application();
virtual void contextMenuPopup( const QString&, QPopupMenu*, QString& );
+ virtual bool checkDataObject(LightApp_DataObject* theObj);
+
static CORBA::ORB_var orb();
static SALOMEDSClient_StudyManager* studyMgr();
static SALOME_NamingService* namingService();
virtual void createPreferences( LightApp_Preferences* );
virtual void updateDesktopTitle();
-
+
private slots:
void onDeleteInvalidReferences();
void onDblClick( QListViewItem* );
#include <SUIT_TreeSync.h>
#include <SUIT_DataObjectIterator.h>
-#include "SALOMEDS_Tool.hxx"
-
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOME_Exception)
void children( const suitPtr&, QValueList<suitPtr>& ) const;
suitPtr parent( const suitPtr& ) const;
bool isCorrect( const kerPtr& ) const;
- void updateItem( const suitPtr& ) const;
+ void updateItem( const kerPtr&, const suitPtr& ) const;
private:
_PTR( Study ) myStudy;
{
kerPtr refObj;
QString name = so->GetName().c_str();
- bool res = so && ( so->GetName().size() || so->ReferencedObject( refObj ) );
+ _PTR( GenericAttribute ) anAttr;
+ bool isDraw = true;
+ if ( so->FindAttribute(anAttr, "AttributeDrawable") )
+ {
+ _PTR(AttributeDrawable) aAttrDraw = anAttr;
+ isDraw = aAttrDraw->IsDrawable();
+ }
+ bool res = so && ( so->GetName().size() || so->ReferencedObject( refObj ) ) && isDraw;
return res;
}
Updates SUIT object
\param p - SUIT object
*/
-void SalomeApp_DataModelSync::updateItem( const suitPtr& ) const
+void SalomeApp_DataModelSync::updateItem( const kerPtr& obj, const suitPtr& ) const
{
}
{
if( !study || !study->root() || !sobj )
return 0;
-
+
DataObjectList ch; study->root()->children( ch );
DataObjectList::const_iterator anIt = ch.begin(), aLast = ch.end();
SUIT_DataObject* suitObj = 0;
else
clr = QColor( 200, 200, 200 );
}
+ else if ( myObject )
+ {
+ _PTR(GenericAttribute) anAttr;
+ if( myObject->FindAttribute ( anAttr, "AttributeTextHighlightColor") )
+ {
+ _PTR(AttributeTextHighlightColor) aHighColAttr = anAttr;
+ clr = QColor( (int)(aHighColAttr->TextHighlightColor().R),
+ (int)(aHighColAttr->TextHighlightColor().G),
+ (int)(aHighColAttr->TextHighlightColor().B));
+ }
+ }
break;
case HighlightedText:
if ( isReference() )
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "SalomeApp_ExceptionHandler.h"
+#include "CASCatch.hxx"
#include <OSD.hxx>
SalomeApp_ExceptionHandler::SalomeApp_ExceptionHandler( const bool floatSignal )
: SUIT_ExceptionHandler()
{
- OSD::SetSignal( floatSignal );
+ // JFA 2006-09-28: PAL10867: suppress signal catching,
+ // if environment variable DISABLE_SIGNALS_CATCHING is set to 1.
+ // Commonly this is used with "noexcepthandler" option.
+ char* envNoCatchSignals = getenv("NOT_INTERCEPT_SIGNALS");
+ if (!envNoCatchSignals || !atoi(envNoCatchSignals))
+ {
+ OSD::SetSignal( floatSignal );
+ }
}
/*!Try to call SUIT_ExceptionHandler::internalHandle(o, e), catch if failure.*/
#else
raiseFPE = false;
#endif
+
return new SalomeApp_ExceptionHandler( raiseFPE );
}
virtual void storeVisualParameters(int savePoint);
virtual void restoreVisualParameters(int savePoint);
+ virtual LightApp_Selection* createSelection() const;
protected:
virtual CAM_DataModel* createDataModel();
- virtual LightApp_Selection* createSelection() const;
virtual void extractContainers( const SALOME_ListIO&, SALOME_ListIO& ) const;
};
#include <qdict.h>
#include "utilities.h"
-#include <iostream.h>
+#include <iostream>
#include <string>
#include <vector>
*/
bool SalomeApp_Study::saveDocumentAs( const QString& theFileName )
{
- bool store = application()->resourceMgr()->booleanValue( "Study", "store_visual_state", true );
+ bool store = application()->resourceMgr()->booleanValue( "Study", "store_visual_state", false );
if ( store )
SalomeApp_VisualState( (SalomeApp_Application*)application() ).storeState();
<parameter name="CAM" value="${GUI_ROOT_DIR}/share/salome/resources/gui"/>
<parameter name="SUPERVGraph" value="${GUI_ROOT_DIR}/share/salome/resources/gui"/>
<parameter name="ToolsGUI" value="${GUI_ROOT_DIR}/share/salome/resources/gui"/>
+ <!-- NETGENPlugin and GHS3DPlugin -->
+ <!-- Here the environment variables are used in upper case, -->
+ <!-- In SMESH/resources/SalomeApp.xml case-sensitive notation is used. -->
+ <!-- As a result, both variants are acceptable. -->
<parameter name="NETGENPlugin" value="${NETGENPLUGIN_ROOT_DIR}/share/salome/resources/netgenplugin"/>
<parameter name="GHS3DPlugin" value="${GHS3DPLUGIN_ROOT_DIR}/share/salome/resources/ghs3dplugin"/>
</section>
</section>
<section name="ExternalBrowser" >
<!-- External HELP browser settings -->
+ <parameter value="D:\Program Files\Internet Explorer\iexplore.exe" name="winapplication" />
<parameter value="/usr/bin/mozilla" name="application" />
</section>
</document>
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// File: CATHAREGUI_msg_en.po
+// File: SalomeApp_msg_en.po
// Created: 10/25/2004 12:46:36 PM
// Author: Sergey LITONIN
-// Copyright (C) CEA 2004
msgid ""
msgstr ""
msgstr "Object browser"
msgid "SalomeApp_Application::MEN_OPENWITH"
-msgstr "Activate Module"
+msgstr "Activate %1 Module"
msgid "SalomeApp_Application::MEN_DELETE_INVALID_REFERENCE"
msgstr "Delete Invalid Reference"
#include <qvbox.h>
#include <qguardedptr.h>
-#ifdef WNT
-#include <SALOME_WNT.hxx>
-#else
-#define SALOME_WNT_EXPORT
-#endif
+#include <SALOME_Session.hxx>
/*!
\class InquireEvent
Contains QCustomEvents for posting to InquireServersQThread
*/
-class SALOME_WNT_EXPORT InquireEvent : public QCustomEvent
+class SESSION_EXPORT InquireEvent : public QCustomEvent
{
public:
class InquireServersGUI;
-class SALOME_WNT_EXPORT InquireServersQThread : public QThread
+class SESSION_EXPORT InquireServersQThread : public QThread
{
public:
InquireServersQThread( InquireServersGUI* r );
class QLabel;
class QFrame;
class QProgressBar;
-class SALOME_WNT_EXPORT InquireServersGUI : public QVBox
+class SESSION_EXPORT InquireServersGUI : public QVBox
{
Q_OBJECT
Session_ServerLauncher.hxx \
Session_ServerThread.hxx \
Session_ServerCheck.hxx \
- SalomeApp_Engine_i.hxx
+ SalomeApp_Engine_i.hxx \
+ SALOME_Session.hxx
# Libraries targets
LIB = libSalomeSession.la
LDFLAGSFORBIN= $(LDFLAGS) $(OMNIORB_LIBS) $(HDF5_LIBS) -lqtx -lSalomeContainer -lSalomeResourcesManager -lTOOLSDS -lSalomeHDFPersist -lSalomeDSImpl -lSalomeGenericObj -lRegistry -lSalomeNotification -lSALOMEBasics
+PLUGINDIR = $(top_builddir)/bin/salome/styles
+MYPLUGINDIR = styles
+
+$(MYPLUGINDIR): $(PLUGINDIR)
+ -$(RM) $@
+ ln -sf $< $@
+
+$(PLUGINDIR):
+ mkdir -p $@
+
+bin: $(MYPLUGINDIR)
+
@CONCLUDE@
--- /dev/null
+// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SALOME_Session.hxx
+// Author : Alexander A. BORODIN
+// Module : GUI
+
+#ifndef _SALOME_Session_HXX_
+#define _SALOME_Session_HXX_
+
+#ifdef WNT
+ #if defined SESSION_EXPORTS
+ #if defined WIN32
+ #define SESSION_EXPORT __declspec( dllexport )
+ #else
+ #define SESSION_EXPORT
+ #endif
+ #else
+ #if defined WIN32
+ #define SESSION_EXPORT __declspec( dllimport )
+ #else
+ #define SESSION_EXPORT
+ #endif
+ #endif
+#else
+ #define SESSION_EXPORT
+#endif
+
+#endif
\ No newline at end of file
{
if ( myExtAppName.isNull() || myExtAppVersion.isNull() ) {
SALOME_ResourceMgr resMgr( "SalomeApp", QString( "%1Config" ) );
+ resMgr.loadLanguage( "LightApp", "en" );
resMgr.loadLanguage( "SalomeApp", "en" );
myExtAppName = QObject::tr( "APP_NAME" ).stripWhiteSpace();
virtual int userFileId( const QString& _fname ) const
{
- QRegExp exp( "\\.SalomeApprc\\.([a-zA-Z0-9.]+)$" );
- QRegExp vers_exp( "^([0-9]+)([A-Za-z]?)([0-9]*)$" );
-
- QString fname = QFileInfo( _fname ).fileName();
- if( exp.exactMatch( fname ) )
- {
- QStringList vers = QStringList::split( ".", exp.cap( 1 ) );
- int major=0, minor=0;
- major = vers[0].toInt();
- minor = vers[1].toInt();
- if( vers_exp.search( vers[2] )==-1 )
- return -1;
- int release = 0, dev1 = 0, dev2 = 0;
- release = vers_exp.cap( 1 ).toInt();
- dev1 = vers_exp.cap( 2 )[ 0 ].latin1();
- dev2 = vers_exp.cap( 3 ).toInt();
-
- int dev = dev1*100+dev2, id = major;
- id*=100; id+=minor;
- id*=100; id+=release;
- id*=10000;
- if ( dev > 0 ) id+=dev-10000;
- return id;
+ if ( !myExtAppName.isEmpty() ) {
+ QRegExp exp( QString( "\\.%1rc\\.([a-zA-Z0-9.]+)$" ).arg( myExtAppName ) );
+ QRegExp vers_exp( "^([0-9]+)([A-Za-z]?)([0-9]*)$" );
+
+ QString fname = QFileInfo( _fname ).fileName();
+ if( exp.exactMatch( fname ) ) {
+ QStringList vers = QStringList::split( ".", exp.cap( 1 ) );
+ int major=0, minor=0;
+ major = vers[0].toInt();
+ minor = vers[1].toInt();
+ if( vers_exp.search( vers[2] )==-1 )
+ return -1;
+ int release = 0, dev1 = 0, dev2 = 0;
+ release = vers_exp.cap( 1 ).toInt();
+ dev1 = vers_exp.cap( 2 )[ 0 ].latin1();
+ dev2 = vers_exp.cap( 3 ).toInt();
+
+ int dev = dev1*100+dev2, id = major;
+ id*=100; id+=minor;
+ id*=100; id+=release;
+ id*=10000;
+ if ( dev > 0 ) id+=dev-10000;
+ return id;
+ }
}
return -1;
#ifndef _SALOMEAPP_ENGINE_I_HXX_
#define _SALOMEAPP_ENGINE_I_HXX_
+#include <SALOME_Session.hxx>
+
#include "SALOME_Component_i.hxx"
#include <vector>
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SalomeApp_Engine)
-#ifdef WNT
-#include <SALOME_WNT.hxx>
-#else
-#define SALOME_WNT_EXPORT
-#endif
-
-class SALOME_WNT_EXPORT SalomeApp_Engine_i: public POA_SalomeApp::Engine,
+class SESSION_EXPORT SalomeApp_Engine_i: public POA_SalomeApp::Engine,
public Engines_Component_i
{
public:
#if !defined(SESSION_SERVERCHECK_HXX)
#define SESSION_SERVERCHECK_HXX
-#ifdef WNT
-#include <SALOME_WNT.hxx>
-#else
-#define SALOME_WNT_EXPORT
-#endif
+#include <SALOME_Session.hxx>
#include <qthread.h>
#include <qapplication.h>
/*!
Class Session_ServerCheck : check SALOME servers
*/
-class SALOME_WNT_EXPORT Session_ServerCheck : public QThread
+class SESSION_EXPORT Session_ServerCheck : public QThread
{
public:
// constructor
{
for (int i=0; i<argc-1; i++)
//argv[i+1] = _argCopy[(*itServ)._firstArg + i].c_str();
- argv[i+1] = _argv[(*itServ)._firstArg + i];
+ argv[i+1] = _argv[(*itServ)._firstArg + i];
}
std::cout << "*** activating [" << argc << "] : " << argv[0] << std::endl;
_serverThreads.push_front(aServerThread);
aServerThread->Init();
+ free( argv[0] );
+ delete[] argv;
}
// Always launch Session Server
Session_SessionThread* aServerThread
= new Session_SessionThread(argc, argv, _orb,_root_poa,_SessionMutex,_SessionStarted);
_serverThreads.push_front(aServerThread);
-
aServerThread->Init();
+ delete[] argv;
}
/*!
#ifndef _SESSION_SERVERLAUNCHER_HXX_
#define _SESSION_SERVERLAUNCHER_HXX_
+#include <SALOME_Session.hxx>
+
#include "Session_ServerThread.hxx"
#include <CORBA.h>
#include <qthread.h>
#include <qwaitcondition.h>
-
-#ifdef WNT
-#include <SALOME_WNT.hxx>
-#else
-#define SALOME_WNT_EXPORT
-#endif
-
using namespace std;
-class ServArg
+class SESSION_EXPORT ServArg
{
public:
int _servType;
_servType(servType),_firstArg(firstArg),_lastArg(lastArg)
{}
-class SALOME_WNT_EXPORT Session_ServerLauncher: public QThread
+class SESSION_EXPORT Session_ServerLauncher: public QThread
{
public:
Session_ServerLauncher();
{
//MESSAGE("Session_ServerThread Constructor " << argv[0]);
_argc = argc;
- _argv = argv;
+ _argv = new char*[ _argc + 1 ];
+ _argv[_argc] = 0;
+ for (int i = 0; i < _argc; i++ )
+ _argv[i] = strdup( argv[i] );
+
_orb = CORBA::ORB::_duplicate(orb);
_root_poa = PortableServer::POA::_duplicate(poa);
_servType =-1;
Session_ServerThread::~Session_ServerThread()
{
//MESSAGE("~Session_ServerThread "<< _argv[0]);
+ delete _NS;
+ for (int i = 0; i <_argc ; i++ )
+ free( _argv[i] );
+ delete[] _argv;
}
/*!
INFOS("RegistryService servant already existing" );
ASSERT(0);
}
- catch( const ServiceUnreachable &ex )
+ catch( const ServiceUnreachable &/*ex*/ )
{
}
- catch( const CORBA::Exception &exx )
+ catch( const CORBA::Exception &/*exx*/ )
{
}
string absoluteName = string("/") + registryName;
{
INFOS("SalomeApp_Engine thread started");
SalomeApp_Engine_i* anEngine = new SalomeApp_Engine_i();
- /*PortableServer::ObjectId_var id = */_root_poa->activate_object( anEngine );
+ // declare variable and get value for them to avoid compilation warning of unused variable
+ // this variable is necessary to avoid memory leak of memory allocated in corba
+ PortableServer::ObjectId_var id = 0;
+ id = _root_poa->activate_object( anEngine );
+ ///*PortableServer::ObjectId_var id = */_root_poa->activate_object( anEngine );
INFOS("poa->activate_object( SalomeApp_Engine )");
- CORBA::Object_ptr obj = anEngine->_this();
+ CORBA::Object_var obj = anEngine->_this();
_NS->Register( obj ,"/SalomeAppEngine");
}
#ifndef _SESSION_SERVERTHREAD_HXX_
#define _SESSION_SERVERTHREAD_HXX_
+#include <SALOME_Session.hxx>
+
#include <CORBA.h>
#include <string>
void WaitForServerReadiness(string serverName);
-class Session_ServerThread
+class SESSION_EXPORT Session_ServerThread
{
public:
static const int NB_SRV_TYP;
};
-class Session_SessionThread : public Session_ServerThread
+class SESSION_EXPORT Session_SessionThread : public Session_ServerThread
{
public:
Session_SessionThread() {}
#include "SUIT_Session.h"
#include "SUIT_Application.h"
+#include "SUIT_Desktop.h"
#include <qapplication.h>
return false;
}
+
+void SALOME_Session_i::emitMessage(const char* theMessage)
+{
+ class TEvent: public SALOME_Event {
+ public:
+ TEvent(const char * msg) {
+ _msg = msg;
+ }
+ virtual void Execute() {
+ SUIT_Session::session()->activeApplication()->desktop()->emitMessage(_msg);
+ }
+ private:
+ const char* _msg;
+ };
+ if ( SUIT_Session::session() ) {
+ if ( SUIT_Session::session()->activeApplication() ) {
+ if ( SUIT_Session::session()->activeApplication()->desktop() ) {
+ ProcessVoidEvent( new TEvent(theMessage) );
+ }
+ }
+ }
+}
+
+void SALOME_Session_i::emitMessageOneWay(const char* theMessage)
+{
+ emitMessage(theMessage);
+}
#ifndef _SESSION_SESSION_I_HXX_
#define _SESSION_SESSION_I_HXX_
+#include <SALOME_Session.hxx>
+
#include <qthread.h>
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOME_Session)
class SALOME_NamingService;
-class SALOME_Session_i: public virtual POA_SALOME::Session,
+class SESSION_EXPORT SALOME_Session_i: public virtual POA_SALOME::Session,
public virtual PortableServer::RefCountServantBase
{
public:
void NSregister();
CORBA::Long GetActiveStudyId();
-
+
void ping(){};
//! Restors a visual state of the study at theSavePoint
bool restoreVisualState(CORBA::Long theSavePoint);
+ //! Emit a qt signal from the session GUI desktop window.
+ void emitMessage(const char* theMessage);
+ void emitMessageOneWay(const char* theMessage);
+
protected:
//! Naming service interface
LDFLAGS+=$(QT_MT_LIBS)
LIBS+=
-# create $(top_builddir)/src/Session/styles directory and copy libSalomeStyle.so there
-LIB_PLUGINDIR = $(top_builddir)/src/Session/styles
-LIB_PLUGINLIB = $(patsubst %.la, $(LIB_PLUGINDIR)/%.so, $(filter %.la, $(LIB)))
+# create $(top_builddir)/bin/salome/styles directory and
+# make link to the libSalomeStyle.so there
+PLUGINDIR = $(top_builddir)/bin/salome/styles
+PLUGIN_LIB_LA = $(patsubst %.la, $(PLUGINDIR)/%.so, $(filter %.la, $(LIB)))
+PLUGIN_LIB_SO = $(patsubst %.so, $(PLUGINDIR)/%.so, $(filter %.so, $(LIB)))
-lib: $(LIB) $(LIB_PLUGINDIR) $(LIB_PLUGINLIB)
+lib: $(LIB) $(PLUGINDIR) $(PLUGIN_LIB_LA) $(PLUGIN_LIB_SO)
-$(LIB_PLUGINDIR):
+$(PLUGINDIR):
mkdir -p $@
-$(LIB_PLUGINLIB): $(LIB_PLUGINDIR)/%.so: .libs/%.so
+$(PLUGIN_LIB_LA): $(PLUGINDIR)/%.so: %.la
+ -$(RM) $@
+ ln -sf $(patsubst %.la, %.so, $(CURDIR)/.libs/$<) $@ || true
+ ln -sf $(patsubst %.la, %.so, $(CURDIR)/.libs/$<).0 $@.0 || true
+
+$(PLUGIN_LIB_SO): $(PLUGINDIR)/%.so: %.so
-$(RM) $@
ln -sf $(CURDIR)/$< $@ || true
int textW = flags & Style_Horizontal ? rt.height() : rt.width();
int textH = flags & Style_Horizontal ? rt.width() : rt.height();
- QString title = titleText( wnd->caption(), textW, p->fontMetrics() );
-
- if ( wnd )
+ QFont old_font = p->font(), f = old_font;
+
+ QString title = titleText( wnd->caption(), textW, textH, f );
+ p->setFont( f );
+ if ( wnd )
{
- QColorGroup cgroup = wnd->isActiveWindow() ? wnd->palette().active() : wnd->palette().inactive();
- p->setPen( cgroup.highlightedText() );
+ QColorGroup cgroup = wnd->isActiveWindow() ? wnd->palette().active() : wnd->palette().inactive();
+ p->setPen( cgroup.highlightedText() );
- if ( flags & Style_Horizontal )
+ if ( flags & Style_Horizontal )
{
- p->rotate( 270.0 );
- p->translate( -(rt.height()+rt.y()), (rt.width()-rt.x()) );
- p->drawText( 0, 0, title );
- }
+ p->rotate( 270.0 );
+ p->translate( -(rt.height()+rt.y()), (rt.width()-rt.x()) );
+ p->drawText( 0, 0, title );
+ }
else
- p->drawText( 2, 2, textW, textH, AlignLeft, title );
- }
+ p->drawText( 2, 2, textW, textH, AlignLeft, title );
+ }
+ p->setFont( old_font );
}
break;
}
\param w - possible width
\param fm - font metrics
*/
-QString SalomeStyle::titleText( const QString& txt, const int W, const QFontMetrics& fm ) const
+QString SalomeStyle::titleText( const QString& txt, const int W, const int H, QFont& f ) const
{
QString res = txt.stripWhiteSpace();
+ QFontMetrics fm( f );
+ while( fm.height() > H && f.pointSize()>1 )
+ {
+ f.setPointSize( f.pointSize()-1 );
+ fm = QFontMetrics( f );
+ }
+
if ( fm.width( res ) > W )
{
QString end( "..." );
void drawGradient( QPainter*, const QRect&, const QColor&,
const QColor&, const Direction, gradient_func ) const;
- QString titleText( const QString&, const int, const QFontMetrics& ) const;
+ QString titleText( const QString&, const int, const int, QFont& f ) const;
private:
QWidget* myTitleParent;
# header files
EXPORT_HEADERS = ToolsGUI.h \
ToolsGUI_RegWidget.h \
- ToolsGUI_CatalogGeneratorDlg.h
+ ToolsGUI_CatalogGeneratorDlg.h \
+ ToolsGUI_HelpWindow.h \
+ ToolsGUI_IntervalWindow.h
# .po files to transform in .qm
PO_FILES = ToolsGUI_icons.po \
ToolsGUI.cxx
LIB_MOC = ToolsGUI_CatalogGeneratorDlg.h \
- ToolsGUI_RegWidget.h
+ ToolsGUI_RegWidget.h \
+ ToolsGUI_HelpWindow.h \
+ ToolsGUI_IntervalWindow.h
LIB_CLIENT_IDL = SALOME_Registry.idl SALOME_Exception.idl
class ToolsGUI_HelpWindow : public QMainWindow
{
+ Q_OBJECT
+
public:
ToolsGUI_HelpWindow( QWidget* parent = 0, const char* name = 0);
~ToolsGUI_HelpWindow();
class ToolsGUI_IntervalWindow : public QDialog
{
+ Q_OBJECT
+
public:
ToolsGUI_IntervalWindow( QWidget* parent = 0 );
~ToolsGUI_IntervalWindow();
// Recuperation de la reference de l'objet
CORBA::Object_var object = 0 ;
try
- {
- SCRUTE(registryName) ;
- object = naming.Resolve( registryName ) ;
- if(CORBA::is_nil(object)) throw CommException( "unable to find the RegistryService" ) ;
- }
- catch( const ServiceUnreachable &ex )
- {
- MESSAGE( ex.what() )
- exit( EXIT_FAILURE ) ;
- }
- catch( const CORBA::Exception &exx )
- {
- exit( EXIT_FAILURE ) ;
- }
-
+ {
+ SCRUTE(registryName) ;
+ object = naming.Resolve( registryName ) ;
+ if(CORBA::is_nil(object)) throw CommException( "unable to find the RegistryService" ) ;
+ }
+ catch( const ServiceUnreachable& ex )
+ {
+ MESSAGE( ex.what() )
+ exit( EXIT_FAILURE ) ;
+ }
+ catch( const CORBA::Exception& )
+ {
+ exit( EXIT_FAILURE ) ;
+ }
+
// Specialisation de l'objet generique
-
+
return Registry::Components::_narrow( object ) ;
}
QString a = QString( "<hr><h2>" ) + tr( "Code" ) + QString( " : " );
a.append( QString( c_info.name ) );
a.append( "</h1><hr><br>" );
+ a.append( "<code>" ); // ASV: 28.07.06 : added <code> tags to make the text font be
+ // fixed width (looks much better on Windows)
a.append( tr( "Process Id" ) + QString( " : " ) );
a.append( BOLD( QString::number( int( c_info.pid ) ) ) );
a.append( QString( " " ) + tr( "on machine" ) + QString( " " ) );
a.append( BOLD( QString::number( int( c_info.difftime ) ) ) );
a.append( QString( " " ) + tr( "seconds" ) + QString( ")<br>" ) );
}
+ a.append( "</code>" ); // ASV: 28.07.06 : added <code> tags to make the text font be
+ // fixed width (looks much better on Windows)
END_OF("setlongText");
return a;
// Try CSF_SaloameResources env.var directory ( or directory list )
cenv = getenv( "CSF_SalomeResources" );
if ( cenv ) {
- dir.sprintf( "%s", cenv );
- if ( !dir.isEmpty() ) {
- QStringList dirList = QStringList::split( SEPARATOR, dir, false ); // skip empty entries
- for ( int i = 0; i < dirList.count(); i++ ) {
- QFileInfo fileInfo( addSlash( dirList[ i ] ) + filename );
- if ( fileInfo.isFile() && fileInfo.exists() )
- return fileInfo.filePath();
+ dir.sprintf( "%s", cenv );
+ if ( !dir.isEmpty() )
+ {
+ QStringList dirList = QStringList::split( SEPARATOR, dir, false ); // skip empty entries
+ for ( int i = 0; i < (int)dirList.count(); i++ )
+ {
+ QFileInfo fileInfo( addSlash( dirList[ i ] ) + filename );
+ if ( fileInfo.isFile() && fileInfo.exists() )
+ return fileInfo.filePath();
}
}
}
return filename;
}
+
QString addSlash( const QString& path )
{
return Qtx::addSlash( path );
-// if (!path.isNull()) {
-//#ifdef WNT
-// QChar slash ('\\');
-//#else
-// QChar slash ('/');
-//#endif
-// if ( path.at(path.length()-1) != slash )
-// return path + slash;
-// }
-// return path;
}
// Module : SALOME
// $Header$
-# ifndef __REGWIDGET_H__
-# define __REGWIDGET_H__
-# include <qapplication.h>
-# include <qmainwindow.h>
+#ifndef __REGWIDGET_H__
+#define __REGWIDGET_H__
+#include <qapplication.h>
+#include <qmainwindow.h>
#include <SALOMEconfig.h>
#include CORBA_CLIENT_HEADER(SALOME_Registry)
class ToolsGUI_HelpWindow;
class ToolsGUI_IntervalWindow;
-class Standard_EXPORT ToolsGUI_InfoWindow : public QMainWindow {
+class Standard_EXPORT ToolsGUI_InfoWindow : public QMainWindow
+{
+ Q_OBJECT
+
public:
ToolsGUI_InfoWindow( QWidget* parent = 0, const char* name = 0);
QTextView* myTextView;
};
-class Standard_EXPORT ToolsGUI_RegWidget : public QMainWindow
+class Standard_EXPORT ToolsGUI_RegWidget : public QMainWindow
{
-
Q_OBJECT
public:
static ToolsGUI_RegWidget* myRegWidgetPtr;
};
-# endif /* # ifndef __REGWIDGET_H__ */
-
-
-
-
-
-
-
-
-
+#endif
LDFLAGSFORBIN=$(LDFLAGS)
-@CONCLUDE@
\ No newline at end of file
+@CONCLUDE@
extern int VTKViewer_POINT_SIZE;
extern int VTKViewer_LINE_WIDTH;
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
/*! \class vtkLODActor
* \brief For more information see <a href="http://www.vtk.org/">VTK documentation</a>
*/
bool myIsHighlighted;
};
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
#endif // VTKVIEVER_ACTOR_H
class vtkPoints;
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
/*! \brief This class used same as vtkAppendFilter. See documentation on VTK for more information.
*/
class VTKVIEWER_EXPORT VTKViewer_AppendFilter : public vtkAppendFilter
vtkSmartPointer<vtkPoints> myPoints;
};
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
#endif
class vtkCell;
class vtkGenericCell;
class vtkQuad;
+
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
/*!Rectangular cell picker class.*/
class VTK_EXPORT VTKViewer_CellRectPicker : public VTKViewer_RectPicker
{
vtkQuad* Quad2;
};
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
#endif
#include <set>
#include <map>
+#ifdef WNT
+#include <algorithm>
+#endif
+
#include <vtkUnstructuredGrid.h>
#include <vtkGeometryFilter.h>
#include <vtkDelaunay3D.h>
virtual
vtkIdType
GetConnectivity(vtkIdType thePntId);
-
};
this->Modified();
}
-vtkIdType VTKViewer_ExtractUnstructuredGrid::GetInputId(int theOutId) const{
- if(myCellIds.empty() && myCellTypes.empty()) return theOutId;
- if(myOut2InId.empty() || theOutId > myOut2InId.size()) return -1;
+vtkIdType VTKViewer_ExtractUnstructuredGrid::GetInputId(int theOutId) const
+{
+ if ( myCellIds.empty() && myCellTypes.empty() )
+ return theOutId;
+
+ if ( myOut2InId.empty() || theOutId > (int)myOut2InId.size() )
+ return -1;
#if defined __GNUC_2__
return myOut2InId[theOutId];
#else
#include <set>
#include <map>
#include <vector>
+
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
/*! \class vtkUnstructuredGridToUnstructuredGridFilter
* \brief For more information see <a href="http://www.vtk.org/">VTK documentation</a>
*/
void operator=(const VTKViewer_ExtractUnstructuredGrid&);
};
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
#endif
}
-vtkIdType VTKViewer_GeometryFilter::GetElemObjId(int theVtkID){
- if(myVTK2ObjIds.empty() || theVtkID > myVTK2ObjIds.size()) return -1;
+vtkIdType VTKViewer_GeometryFilter::GetElemObjId( int theVtkID )
+{
+ if( myVTK2ObjIds.empty() || theVtkID > (int)myVTK2ObjIds.size() )
+ return -1;
#if defined __GNUC_2__
return myVTK2ObjIds[theVtkID];
#else
#include <vtkGeometryFilter.h>
#include <vector>
+
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
/*! \brief This class used same as vtkGeometryFilter. See documentation on VTK for more information.
*/
class VTKVIEWER_EXPORT VTKViewer_GeometryFilter : public vtkGeometryFilter
int myIsWireframeMode;
};
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
#endif
#define VTK_INTERACTOR_STYLE_CAMERA_SELECT 6
#define VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN 7
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
/*! Description:\n
* This class must be supplied with a vtkRenderWindowInteractor wrapper or\n
* parent. This class should not normally be instantiated by application\n
//@}
};
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
#endif
float c1[3], c2[3];
int picked=0;
int *winSize;
- float x, y, t, p;
+ float x, y, t;
float *viewport;
float cameraPos[4], cameraFP[4];
float *displayCoords, *worldCoords;
float windowLowerLeft[4], windowUpperRight[4];
float bounds[6], tol;
float tF, tB;
- float hitPosition[3];
float cameraDOP[3];
// Initialize picking process
* p2[4][4] is the corner points of bottom face.
* \retval The method returns a non-zero value, if the point is inside.
*/
-char VTKViewer_RectPicker::PointInside (float p[3], float p1[4][4], float p2[4][4], float tol)
+char VTKViewer_RectPicker::PointInside(float p[3], float p1[4][4], float p2[4][4], float tol)
{
- int i, j, k;
+ int j, k;
float t, coord[3];
// Fix one coordinate (x, for example) and
/*!Return node object id by vtk node id.
*\retval -1 - if no object, else return id.
*/
-vtkIdType VTKViewer_ShrinkFilter::GetNodeObjId(int theVtkID){
- if(myVTK2ObjIds.empty() || theVtkID > myVTK2ObjIds.size()) return -1;
+vtkIdType VTKViewer_ShrinkFilter::GetNodeObjId(int theVtkID)
+{
+ if ( myVTK2ObjIds.empty() || theVtkID > (int)myVTK2ObjIds.size() )
+ return -1;
return myVTK2ObjIds.at(theVtkID);
}
#include <vector>
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
/*!Shrink cells composing an arbitrary data set.
*\warning It is possible to turn cells inside out or cause self intersection in special cases.
*/
TVectorId myVTK2ObjIds;
};
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
#endif
myLabelActor->AddPosition(aPosition);
}
+/*! Check if actor belongs to the axis object
+ * \param theActor - vtkActor pointer
+ * \retval Return true if the actor belongs to the axis object
+ */
+bool VTKViewer_Axis::OwnActor(const vtkActor* theActor)
+{
+ return theActor == myLineActor ||
+ theActor == myArrowActor ||
+ theActor == myLabelActor;
+}
+
/*! \class VTKViewer_XAxis
* \brief X Axis actor
*/
int aCount = 0;
while(vtkActor* prop = aCollection->GetNextActor()) {
if( prop->GetVisibility())
- if(VTKViewer_Actor* anActor = VTKViewer_Actor::SafeDownCast(prop))
+ if(VTKViewer_Actor* anActor = VTKViewer_Actor::SafeDownCast(prop)) {
if(!anActor->IsInfinitive())
- aCount++;
+ aCount++;
+ }
+ else if ( !OwnActor( anActor ) ) {
+ aCount++;
+ }
//int aCount = theRenderer->VisibleActorCount();
//SetVisibility(aVis);
}
return aCount;
}
+
+/*! Check if actor belongs to the axis object
+ * \param theActor - vtkActor pointer
+ * \retval Return true if the actor belongs to the axis object
+ */
+bool VTKViewer_Trihedron::OwnActor(const vtkActor* theActor)
+{
+ myPresent->InitTraversal();
+ while(vtkActor* anActor = myPresent->GetNextActor()) {
+ if ( anActor == theActor ) return true;
+ }
+ for(int i = 0; i < 3; i++) {
+ if ( myAxis[i]->OwnActor(theActor) ) return true;
+ }
+ return false;
+}
};
/*!This class provide support trihedron object in vtk viewer.*/
-class VTKVIEWER_EXPORT VTKVIEWER_EXPORT VTKViewer_Trihedron : public vtkObject
+class VTKVIEWER_EXPORT VTKViewer_Trihedron : public vtkObject
{
protected:
/*!Initialize fields by default values.*/
*/
virtual int GetVisibleActorCount(vtkRenderer* theRenderer);
+ /*! Check if actor belongs to the trihedron object
+ * \param theActor - vtkActor pointer
+ * \retval Return true if the actor belongs to the trihedron object
+ */
+ virtual bool OwnActor(const vtkActor* theActor);
+
protected:
/*! Actor collection*/
vtkActorCollection* myPresent;
* \retval Return myArrowActor
*/
virtual VTKViewer_UnScaledActor* GetArrow() { return myArrowActor; }
+
+ /*! Check if actor belongs to the axis object
+ * \param theActor - vtkActor pointer
+ * \retval Return true if the actor belongs to the axis object
+ */
+ virtual bool OwnActor(const vtkActor* theActor);
protected:
/*! Visibility flag.
return fabs( theNewSize - theSize) > theSize * EPS_SIZE ||
fabs( theNewSize-theSize ) > theNewSize * EPS_SIZE;
}
+
+bool IsBBEmpty(vtkRenderer* theRenderer)
+{
+ if(!theRenderer)
+ return false;
+
+ vtkFloatingPointType aNewBndBox[6];
+ aNewBndBox[ 0 ] = aNewBndBox[ 2 ] = aNewBndBox[ 4 ] = VTK_LARGE_FLOAT;
+ aNewBndBox[ 1 ] = aNewBndBox[ 3 ] = aNewBndBox[ 5 ] = -VTK_LARGE_FLOAT;
+
+ // iterate through displayed objects and set size if necessary
+ vtkActorCollection* anActors = theRenderer->GetActors();
+ anActors->InitTraversal();
+ bool isAny = false;
+ while(vtkActor* anAct = anActors->GetNextActor())
+ //if(SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(anAct))
+ if(VTKViewer_Actor* anActor = VTKViewer_Actor::SafeDownCast(anAct))
+ if(anActor->GetVisibility() && !anActor->IsInfinitive())
+ {
+ vtkFloatingPointType *aBounds = anActor->GetBounds();
+ if(aBounds[0] > -VTK_LARGE_FLOAT && aBounds[1] < VTK_LARGE_FLOAT &&
+ aBounds[2] > -VTK_LARGE_FLOAT && aBounds[3] < VTK_LARGE_FLOAT &&
+ aBounds[4] > -VTK_LARGE_FLOAT && aBounds[5] < VTK_LARGE_FLOAT)
+ isAny = true;
+ }
+
+ return !isAny;
+}
+
+bool ComputeBBCenter(vtkRenderer* theRenderer, vtkFloatingPointType theCenter[3])
+{
+ theCenter[0] = theCenter[1] = theCenter[2] = 0.0;
+
+ if(!theRenderer)
+ return false;
+
+ vtkFloatingPointType aNewBndBox[6];
+ aNewBndBox[ 0 ] = aNewBndBox[ 2 ] = aNewBndBox[ 4 ] = VTK_LARGE_FLOAT;
+ aNewBndBox[ 1 ] = aNewBndBox[ 3 ] = aNewBndBox[ 5 ] = -VTK_LARGE_FLOAT;
+
+ // iterate through displayed objects and set size if necessary
+ vtkActorCollection* anActors = theRenderer->GetActors();
+ anActors->InitTraversal();
+ bool isAny = false;
+ while(vtkActor* anAct = anActors->GetNextActor())
+ {
+ //if(SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(anAct))
+ if(VTKViewer_Actor* anActor = VTKViewer_Actor::SafeDownCast(anAct))
+ {
+ if(anActor->GetVisibility() && !anActor->IsInfinitive())
+ {
+ vtkFloatingPointType *aBounds = anActor->GetBounds();
+ if(aBounds[0] > -VTK_LARGE_FLOAT && aBounds[1] < VTK_LARGE_FLOAT &&
+ aBounds[2] > -VTK_LARGE_FLOAT && aBounds[3] < VTK_LARGE_FLOAT &&
+ aBounds[4] > -VTK_LARGE_FLOAT && aBounds[5] < VTK_LARGE_FLOAT)
+ {
+ for(int i = 0; i < 5; i = i + 2){
+ if(aBounds[i] < aNewBndBox[i])
+ aNewBndBox[i] = aBounds[i];
+ if(aBounds[i+1] > aNewBndBox[i+1])
+ aNewBndBox[i+1] = aBounds[i+1];
+ }
+ isAny = true;
+ }
+ }
+ }
+ }
+
+ if ( !isAny )
+ {
+ // null bounding box => the center is (0,0,0)
+ return true;
+ }
+
+ if(aNewBndBox[0] > -VTK_LARGE_FLOAT && aNewBndBox[1] < VTK_LARGE_FLOAT &&
+ aNewBndBox[2] > -VTK_LARGE_FLOAT && aNewBndBox[3] < VTK_LARGE_FLOAT &&
+ aNewBndBox[4] > -VTK_LARGE_FLOAT && aNewBndBox[5] < VTK_LARGE_FLOAT)
+ {
+ static vtkFloatingPointType MIN_DISTANCE = 1.0 / VTK_LARGE_FLOAT;
+
+ vtkFloatingPointType aLength = aNewBndBox[1]-aNewBndBox[0];
+ aLength = max((aNewBndBox[3]-aNewBndBox[2]),aLength);
+ aLength = max((aNewBndBox[5]-aNewBndBox[4]),aLength);
+
+ if(aLength < MIN_DISTANCE)
+ return false;
+
+ vtkFloatingPointType aWidth =
+ sqrt((aNewBndBox[1]-aNewBndBox[0])*(aNewBndBox[1]-aNewBndBox[0]) +
+ (aNewBndBox[3]-aNewBndBox[2])*(aNewBndBox[3]-aNewBndBox[2]) +
+ (aNewBndBox[5]-aNewBndBox[4])*(aNewBndBox[5]-aNewBndBox[4]));
+
+ if(aWidth < MIN_DISTANCE)
+ return false;
+
+ theCenter[0] = (aNewBndBox[0] + aNewBndBox[1])/2.0;
+ theCenter[1] = (aNewBndBox[2] + aNewBndBox[3])/2.0;
+ theCenter[2] = (aNewBndBox[4] + aNewBndBox[5])/2.0;
+ return true;
+ }
+
+ return false;
+
+ /*
+ vtkFloatingPointType aBounds[6];
+ int aCount = ComputeVisiblePropBounds(theRenderer,aBounds);
+ printf("aNewBndBox[0] = %f, aNewBndBox[1] = %f,\naNewBndBox[2] = %f, aNewBndBox[3] = %f,\naNewBndBox[4] = %f, aNewBndBox[5] = %f\n",
+ aBounds[0],aBounds[1],aBounds[2],aBounds[3],aBounds[4],aBounds[5]);
+ printf("aCount = %d\n",aCount);
+
+ if(aCount){
+ static vtkFloatingPointType MIN_DISTANCE = 1.0 / VTK_LARGE_FLOAT;
+
+ vtkFloatingPointType aLength = aBounds[1]-aBounds[0];
+ aLength = max((aBounds[3]-aBounds[2]),aLength);
+ aLength = max((aBounds[5]-aBounds[4]),aLength);
+
+ if(aLength < MIN_DISTANCE)
+ return false;
+
+ vtkFloatingPointType aWidth =
+ sqrt((aBounds[1]-aBounds[0])*(aBounds[1]-aBounds[0]) +
+ (aBounds[3]-aBounds[2])*(aBounds[3]-aBounds[2]) +
+ (aBounds[5]-aBounds[4])*(aBounds[5]-aBounds[4]));
+
+ if(aWidth < MIN_DISTANCE)
+ return false;
+
+ theCenter[0] = (aBounds[0] + aBounds[1])/2.0;
+ theCenter[1] = (aBounds[2] + aBounds[3])/2.0;
+ theCenter[2] = (aBounds[4] + aBounds[5])/2.0;
+ return true;
+ }
+ return false;*/
+}
const vtkFloatingPointType theSize,
const vtkFloatingPointType theSizeInPercents);
+VTKVIEWER_EXPORT
+extern
+bool IsBBEmpty(vtkRenderer* theRenderer);
+VTKVIEWER_EXPORT
+extern
+bool ComputeBBCenter(vtkRenderer* theRenderer,
+ vtkFloatingPointType theCenter[3]);
#endif
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- PURPOSE. See the above copyright notice for more information.
+ PURPOSE. See the above copyright notice for more information.*/
-=========================================================================*/
// VTKViewer_VectorText.cxx is a copy of vtkVectorText.cxx file.
// Purpose of copying: to remove linking to libHybrid.so VTK library
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- PURPOSE. See the above copyright notice for more information.
+ PURPOSE. See the above copyright notice for more information.*/
-=========================================================================*/
// .NAME vtkVectorText - create polygonal text
// .SECTION Description
#include "VTKViewer_ViewManager.h"
#include "VTKViewer_ViewModel.h"
-int VTKViewer_ViewManager::_VTKViewMgr_Id = 0;
-
/*!Constructor.Initialize SIUT_ViewManager by \a study and \a theDesktop.
* Create new instance of VTKViewer_Viewer and set view model by it.
*/
VTKViewer_ViewManager::VTKViewer_ViewManager( SUIT_Study* study, SUIT_Desktop* theDesktop )
-: SUIT_ViewManager( study, theDesktop )
+: SUIT_ViewManager( study, theDesktop, new VTKViewer_Viewer() )
{
- myId = ++_VTKViewMgr_Id;
- setViewModel( new VTKViewer_Viewer() );
+ setTitle( tr( "VTK_VIEW_TITLE" ) );
}
/*!Destructor.*/
{
/*!Do nothing.*/
}
-
-/*!Sets view window name*/
-void VTKViewer_ViewManager::setViewName(SUIT_ViewWindow* theView)
-{
- int aPos = myViews.find(theView);
- theView->setCaption( tr( "VTK_VIEW_TITLE" ).arg( myId ).arg( aPos + 1 ) );
-}
public:
VTKViewer_ViewManager( SUIT_Study* study, SUIT_Desktop* );
virtual ~VTKViewer_ViewManager();
-
-protected:
- void setViewName( SUIT_ViewWindow* theView );
-
-private:
- int myId;
- static int _VTKViewMgr_Id;
};
#endif
#include <qpalette.h>
#include <qpopupmenu.h>
+bool _InitializeVtkWarningsCall()
+{
+ char* isOn = getenv( "VTK_WARNINGS_IS_ON" );
+ if ( !isOn || strcmp( isOn, "1" ) )
+ vtkObject::GlobalWarningDisplayOff();
+
+ delete isOn;
+ return vtkObject::GetGlobalWarningDisplay();
+}
+static bool _InitializeVtkWarnings = _InitializeVtkWarningsCall();
+
/*!Constructor.Sets background color to black.*/
VTKViewer_Viewer::VTKViewer_Viewer()
: SUIT_ViewModel(),
msgid "ICON_VTKVIEWER_VIEW_RIGHT"
msgstr "view_right.png"
+msgid "ICON_VTKVIEWER_VIEW_ROTATION_POINT"
+msgstr "view_rotation_point.png"
+
msgid "ICON_VTKVIEWER_VIEW_ROTATE"
msgstr "view_rotate.png"
msgstr "Change background..."
msgid "VTKViewer_ViewManager::VTK_VIEW_TITLE"
-msgstr "VTK scene:%1 - viewer:%2"
+msgstr "VTK scene:%M - viewer:%V"
msgid "MNU_SHOW_TRIHEDRON"
msgstr "Show/Hide trihedron"