IDLDIR =
endif
-SUBDIRS = $(IDLDIR) adm_local resources src doc bin
+SUBDIRS = $(IDLDIR) adm_local resources src doc bin tools
-DIST_SUBDIRS = idl adm_local resources src doc bin
+DIST_SUBDIRS = idl adm_local resources src doc bin tools
DISTCLEANFILES = a.out aclocal.m4 configure local-install.sh hack_libtool adm_local/unix/config_files/config.guess adm_local/unix/config_files/config.sub adm_local/unix/config_files/depcomp adm_local/unix/config_files/install-sh adm_local/unix/config_files/libtool.m4 adm_local/unix/config_files/ltmain.sh adm_local/unix/config_files/ltoptions.m4 adm_local/unix/config_files/ltsugar.m4 adm_local/unix/config_files/ltversion.m4 adm_local/unix/config_files/lt~obsolete.m4 adm_local/unix/config_files/missing adm_local/unix/config_files/py-compile
ENDFOREACH(D ${QT_INCLUDES})
SET(QT_INCLUDES ${DIRS})
SET(QT_INCLUDES ${QT_INCLUDES} -DQT_THREAD_SUPPORT)
-SET(QT_MT_LIBS ${QT_LIBRARIES} ${QT_QTXML_LIBRARY} ${QT_QTOPENGL_LIBRARY})
+SET(QT_MT_LIBS ${QT_LIBRARIES} ${QT_QTXML_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${QT_QTWEBKIT_LIBRARY})
SET(QT_LIBS ${QT_MT_LIBS})
SET(qt4_ldflags ${QT_MT_LIBS})
ENDIF(SIP_ROOT)
SET(SIP_INCLUDES -I${SIP_ROOT}/include/python${PYTHON_VERSION})
+IF(WINDOWS)
+ SET(SIP_INCLUDES ${SIP_INCLUDES} -I${SIP_ROOT}/include)
+ENDIF(WINDOWS)
IF(WINDOWS)
FIND_PROGRAM(PYUIC_EXECUTABLE NAMES pyuic4 pyuic4.bat)
AC_REQUIRE([AC_PROG_CXXCPP])dnl
AC_REQUIRE([CHECK_OPENGL])dnl
AC_REQUIRE([AC_LINKER_OPTIONS])dnl
+AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
AC_REQUIRE([OPTIONS_QT])dnl
QTDIR=/usr/lib/qt4
fi
elif test -z $QTDIR ; then
+ AC_MSG_WARN(undefined QTDIR variable which specify where Qt product was installed, trying to guess using pkg-config)
+ PKG_PROG_PKG_CONFIG()
+ AS_IF([test "x$PKG_CONFIG" != "x"],
+ [
+ QT_REQUIRED_VERSION=4.0.0
+ if $PKG_CONFIG --exists "QtCore >= $QT_REQUIRED_VERSION"
+ then
+ QT_USING_PKGCONFIG=yes
+ QT_VERSION=`$PKG_CONFIG --modversion QtCore --atleast-version=$QT_REQUIRED_VERSION`
+ QT_VERSION_ID=`echo $QT_VERSION | awk -F. '{v=$[1]*10000+$[2]*100+$[3];print v}'`
+
+ MOC=`$PKG_CONFIG --variable=moc_location "QtCore >= $QT_REQUIRED_VERSION"`
+ UIC=`$PKG_CONFIG --variable=uic_location "QtCore >= $QT_REQUIRED_VERSION"`
+ QRCC=`$PKG_CONFIG --variable=rcc_location "QtCore >= $QT_REQUIRED_VERSION"`
+ LRELEASE=`$PKG_CONFIG --variable=lrelease_location "QtCore >= $QT_REQUIRED_VERSION"`
+
+ QTCORE_CPPFLAGS=`$PKG_CONFIG --cflags "QtCore >= $QT_REQUIRED_VERSION"`
+ QTGUI_CPPFLAGS=`$PKG_CONFIG --cflags "QtGui >= $QT_REQUIRED_VERSION"`
+ QTOPENGL_CPPFLAGS=`$PKG_CONFIG --cflags "QtOpenGL >= $QT_REQUIRED_VERSION"`
+ QTXML_CPPFLAGS=`$PKG_CONFIG --cflags "QtXml >= $QT_REQUIRED_VERSION"`
+ QTASSISTANT_CPPFLAGS=`$PKG_CONFIG --cflags "QtAssistant >= $QT_REQUIRED_VERSION"`
+ QTNETWORK_CPPFLAGS=`$PKG_CONFIG --cflags "QtNetwork >= $QT_REQUIRED_VERSION"`
+ QTWEBKIT_CPPFLAGS=`$PKG_CONFIG --cflags "QtWebKit >= $QT_REQUIRED_VERSION"`
+
+ QTCORE_LDFLAGS=`$PKG_CONFIG --libs "QtCore >= $QT_REQUIRED_VERSION"`
+ QTGUI_LDFLAGS=`$PKG_CONFIG --libs "QtGui >= $QT_REQUIRED_VERSION"`
+ QTOPENGL_LDFLAGS=`$PKG_CONFIG --libs "QtOpenGL >= $QT_REQUIRED_VERSION"`
+ QTXML_LDFLAGS=`$PKG_CONFIG --libs "QtXml >= $QT_REQUIRED_VERSION"`
+ QTASSISTANT_LDFLAGS=`$PKG_CONFIG --libs "QtAssistant >= $QT_REQUIRED_VERSION"`
+ QTNETWORK_LDFLAGS=`$PKG_CONFIG --libs "QtNetwork >= $QT_REQUIRED_VERSION"`
+ QTWEBKIT_LDFLAGS=`$PKG_CONFIG --libs "QtWebKit >= $QT_REQUIRED_VERSION"`
+ else
+ AC_MSG_WARN(Qt not found)
+ fi
+ ],
+ [
+ AC_MSG_WARN([pkg-config not found])
+ ]
+ )
+fi
+if test -z $QTDIR ; then
AC_MSG_WARN(undefined QTDIR variable which specify where Qt product was installed)
for d in /usr/local/lib/qt4 /usr/lib/qt4 /usr ; do
if test -f ${d}/lib/libQtCore.so ; then
fi
done
fi
-
#
# check QTDIR environment variable
#
-if test "x$QTDIR" = "x"
+if test "x$QTDIR" = "x" -a "x$QT_USING_PKGCONFIG" != "xyes"
then
AC_MSG_RESULT(Please define correct path in "--with-qt" option or use correct $QTDIR variable)
qt_ok=no
#
if test "x$qt_ok" = "xyes"
then
- qt_inc_ok=no
- QTINC=""
- AC_CHECK_FILE(${QTDIR}/include/qt4/QtCore/qglobal.h,QTINC="/qt4",QTINC="")
- if test "x$QTINC" = "x"
+ AC_MSG_CHECKING(whether Qt version >= 4.0)
+ if test "x$QT_USING_PKGCONFIG" != "xyes"
then
- AC_CHECK_FILE(${QTDIR}/include${QTINC}/QtCore/qglobal.h,qt_inc_ok=yes,qt_inc_ok=no)
- else
- qt_inc_ok=yes
+ qt_inc_ok=no
+ QTINC=""
+ AC_CHECK_FILE(${QTDIR}/include/qt4/QtCore/qglobal.h,QTINC="/qt4",QTINC="")
+ if test "x$QTINC" = "x"
+ then
+ AC_CHECK_FILE(${QTDIR}/include${QTINC}/QtCore/qglobal.h,qt_inc_ok=yes,qt_inc_ok=no)
+ else
+ qt_inc_ok=yes
+ fi
+
+ if test "x$qt_inc_ok" = "xyes"
+ then
+ QT_VERSION=`grep "QT_VERSION_STR" ${QTDIR}/include${QTINC}/QtCore/qglobal.h | sed -e 's%^#define QT_VERSION_STR[[:space:]]*\"\([[:digit:]\.]*\)\"%\1%g'`
+ fi
fi
- if test "x$qt_inc_ok" = "xyes"
- then
- AC_MSG_CHECKING(whether Qt version >= 4.0)
- QT_VERSION=`grep "QT_VERSION_STR" ${QTDIR}/include${QTINC}/QtCore/qglobal.h | sed -e 's%^#define QT_VERSION_STR[[:space:]]*\"\([[:digit:]\.]*\)\"%\1%g'`
+
+
+ if test "x$qt_inc_ok" = "xyes" -o "x$QT_USING_PKGCONFIG" = "xyes"
+ then
QT_VERSION_ID=`echo $QT_VERSION | awk -F. '{v=$[1]*10000+$[2]*100+$[3];print v}'`
if test $QT_VERSION_ID -ge 40000
then
if test "x$qt_ok" = "xyes"
then
- if test -f ${QTDIR}/bin/moc
+ if test "x$QT_USING_PKGCONFIG" != "xyes"
then
- MOC=${QTDIR}/bin/moc
- else
- AC_PATH_PROG(MOC, moc)
+ if test -f ${QTDIR}/bin/moc
+ then
+ MOC=${QTDIR}/bin/moc
+ else
+ AC_PATH_PROG(MOC, moc)
+ fi
fi
+
if test "x$MOC" = "x"
then
qt_ok=no
#
if test "x$qt_ok" = "xyes"
then
- if test "x$qt_add" = "xno"
+ if test "x$QT_USING_PKGCONFIG" != "xyes"
then
- AC_MSG_CHECKING(uic)
- if test -f ${QTDIR}/bin/uic
- then
- UIC=${QTDIR}/bin/uic
- else
- AC_PATH_PROG(UIC, uic)
- fi
- AC_MSG_RESULT(yes)
- else
- AC_MSG_CHECKING(uic-qt$qt_add)
- if test -f ${QTDIR}/bin/uic-qt$qt_add
- then
- UIC=${QTDIR}/bin/uic-qt$qt_add
- else
- AC_PATH_PROG(UIC, uic)
- fi
- AC_MSG_RESULT(yes)
+ if test "x$qt_add" = "xno"
+ then
+ AC_MSG_CHECKING(uic)
+ if test -f ${QTDIR}/bin/uic
+ then
+ UIC=${QTDIR}/bin/uic
+ else
+ AC_PATH_PROG(UIC, uic)
+ fi
+ AC_MSG_RESULT(yes)
+ else
+ AC_MSG_CHECKING(uic-qt$qt_add)
+ if test -f ${QTDIR}/bin/uic-qt$qt_add
+ then
+ UIC=${QTDIR}/bin/uic-qt$qt_add
+ else
+ AC_PATH_PROG(UIC, uic)
+ fi
+ AC_MSG_RESULT(yes)
+ fi
fi
if test "x$UIC" = "x"
#
if test "x$qt_ok" = "xyes"
then
- if test "x$qt_add" = "xno"
+ if test "x$QT_USING_PKGONFIG" != "xyes"
then
- if test -f ${QTDIR}/bin/rcc
- then
- QRCC=${QTDIR}/bin/rcc
- else
- AC_PATH_PROG(QRCC, rcc)
- fi
- else
- if test -f ${QTDIR}/bin/rcc-qt$qt_add
- then
- QRCC=${QTDIR}/bin/rcc-qt$qt_add
- else
- AC_PATH_PROG(QRCC, rcc)
- fi
+ if test "x$qt_add" = "xno"
+ then
+ if test -f ${QTDIR}/bin/rcc
+ then
+ QRCC=${QTDIR}/bin/rcc
+ else
+ AC_PATH_PROG(QRCC, rcc)
+ fi
+ else
+ if test -f ${QTDIR}/bin/rcc-qt$qt_add
+ then
+ QRCC=${QTDIR}/bin/rcc-qt$qt_add
+ else
+ AC_PATH_PROG(QRCC, rcc)
+ fi
+ fi
fi
+
if test "x$QRCC" = "x"
then
qt_ok=no
#
if test "x$qt_ok" = "xyes"
then
- if test "x$qt_add" = "xno"
+ if test "x$QT_USING_PKGCONFIG" != "xyes"
then
- if test -f ${QTDIR}/bin/lrelease
- then
- LRELEASE=${QTDIR}/bin/lrelease
- else
- AC_PATH_PROG(LRELEASE, lrelease)
- fi
- else
- if test -f ${QTDIR}/bin/lrelease-qt$qt_add
- then
- LRELEASE=${QTDIR}/bin/lrelease-qt$qt_add
- else
- AC_PATH_PROG(LRELEASE, lrelease)
- fi
+ if test "x$qt_add" = "xno"
+ then
+ if test -f ${QTDIR}/bin/lrelease
+ then
+ LRELEASE=${QTDIR}/bin/lrelease
+ else
+ AC_PATH_PROG(LRELEASE, lrelease)
+ fi
+ else
+ if test -f ${QTDIR}/bin/lrelease-qt$qt_add
+ then
+ LRELEASE=${QTDIR}/bin/lrelease-qt$qt_add
+ else
+ AC_PATH_PROG(LRELEASE, lrelease)
+ fi
+ fi
fi
+
if test "x$LRELEASE" = "x"
then
qt_ok=no
AC_CHECKING(include Qt header files)
CPPFLAGS_old=$CPPFLAGS
- CPPFLAGS="$CPPFLAGS -I${QTDIR}/include${QTINC} -I${QTDIR}/include${QTINC}/QtCore"
+ if test "x$QT_USING_PKGCONFIG" != "xyes"
+ then
+ CPPFLAGS="$CPPFLAGS -I${QTDIR}/include${QTINC} -I${QTDIR}/include${QTINC}/QtCore"
+ else
+ CPPFLAGS="$CPPFLAGS $QTCORE_CPPFLAGS"
+ fi
AC_CHECK_HEADER(QObject,qt_ok=yes,qt_ok=no)
CPPFLAGS=$CPPFLAGS_old
AC_MSG_RESULT(QTDIR environment variable may be wrong (probably too old Qt version))
else
AC_MSG_RESULT(qt header files seem to be OK)
- QT_INCLUDES="-I${QTDIR}/include${QTINC}"
- # user header files
- QT_INCLUDES="${QT_INCLUDES} -I${QTDIR}/include${QTINC}/QtCore"
- QT_INCLUDES="${QT_INCLUDES} -I${QTDIR}/include${QTINC}/QtGui"
- QT_INCLUDES="${QT_INCLUDES} -I${QTDIR}/include${QTINC}/QtOpenGL"
- QT_INCLUDES="${QT_INCLUDES} -I${QTDIR}/include${QTINC}/QtXml"
- # not used currently header files (uncomment if required)
- #QT_INCLUDES="${QT_INCLUDES} -I$(QTDIR)/include${QTINC}/QtAssistant"
- #QT_INCLUDES="${QT_INCLUDES} -I$(QTDIR)/include${QTINC}/QtDBus"
- #QT_INCLUDES="${QT_INCLUDES} -I$(QTDIR)/include${QTINC}/QtDesigner"
- #QT_INCLUDES="${QT_INCLUDES} -I$(QTDIR)/include${QTINC}/QtNetwork"
- #QT_INCLUDES="${QT_INCLUDES} -I$(QTDIR)/include${QTINC}/QtSql"
- #QT_INCLUDES="${QT_INCLUDES} -I$(QTDIR)/include${QTINC}/QtSvg"
- #QT_INCLUDES="${QT_INCLUDES} -I$(QTDIR)/include${QTINC}/QtTest"
- #QT_INCLUDES="${QT_INCLUDES} -I$(QTDIR)/include${QTINC}/QtUiTools"
-
- QT_ASSISTANT_INCLUDES="${QT_ASSISTANT_INCLUDES} -I${QTDIR}/include${QTINC}/QtAssistant"
- QT_ASSISTANT_INCLUDES="${QT_ASSISTANT_INCLUDES} -I${QTDIR}/include${QTINC}/QtNetwork"
+ if test "x$QT_USING_PKGCONFIG" != "xyes"
+ then
+ QT_BASE="-I${QTDIR}/include${QTINC}"
+ # user header files
+ QTCORE_CPPFLAGS="${QT_BASE}/QtCore"
+ QTGUI_CPPFLAGS="${QT_BASE}/QtGui"
+ QTOPENGL_CPPFLAGS="${QT_BASE}/QtOpenGL"
+ QTWEBKIT_CPPFLAGS="${QT_BASE}/QtWebKit"
+ QTXML_CPPFLAGS="${QT_BASE}/QtXml"
+
+ QTASSISTANT_CPPFLAGS="${QT_BASE}/QtAssistant"
+ QTNETWORK_CPPFLAGS="${QT_BASE}/QtNetwork"
+ fi
- # this flag is obsolete with Qt 4
- QT_MT_INCLUDES="$QT_INCLUDES"
+ QT_INCLUDES="$QT_BASE $QTCORE_CPPFLAGS $QTGUI_CPPFLAGS $QTOPENGL_CPPFLAGS $QTXML_CPPFLAGS $QTWEBKIT_CPPFLAGS"
+
+ QT_ASSISANT_INCLUDES="$QTASSISTANT_CPPFLAGS $QTNETWORK_CPPFLAGS"
+ QT_MT_INCLUDES="${QT_INCLUDES}"
fi
fi
CXXFLAGS="$CXXFLAGS $QT_INCLUDES"
LIBS_old=$LIBS
- if test "x$QTDIR" = "x/usr" ; then
- QT_LIB_DIR=""
- elif test -d ${QTDIR}/lib; then
- QT_LIB_DIR="-L$QTDIR/lib"
- elif test -d ${QTDIR}/lib64; then
- QT_LIB_DIR="-L$QTDIR/lib64"
- elif test "x$QTDIR" = "x/usr/lib/qt4" ; then
- QT_LIB_DIR=""
+ if test "x$QT_USING_PKGCONFIG" = "xyes"
+ then
+ LIBS="$LIBS $QTCORE_LDFLAGS"
else
- AC_MSG_ERROR(Can't detect of Qt library directory )
- qt_ok=no
+ if test "x$QTDIR" = "x/usr" ; then
+ QT_LIB_DIR=""
+ elif test -d ${QTDIR}/lib; then
+ QT_LIB_DIR="-L$QTDIR/lib"
+ elif test -d ${QTDIR}/lib64; then
+ QT_LIB_DIR="-L$QTDIR/lib64"
+ elif test "x$QTDIR" = "x/usr/lib/qt4" ; then
+ QT_LIB_DIR=""
+ else
+ AC_MSG_ERROR(Can't detect Qt library directory ) #'
+ qt_ok=no
+ fi
+ LIBS="$LIBS $QT_LIB_DIR -lQtCore"
fi
- LIBS="$LIBS $QT_LIB_DIR -lQtCore"
AC_CACHE_VAL(salome_cv_lib_qt,[
AC_TRY_LINK(
else
AC_MSG_RESULT(yes)
# core libs
- QT_CORE_LIBS="$QT_LIB_DIR -lQtCore -lQtXml"
- # gui libs
- QT_GUI_LIBS="$QT_LIB_DIR -lQtGui -lQtOpenGL"
- # other libs (currently not used)
- QT_OTHER_LIBS="$QT_LIB_DIR"
- # other libs (can be used if necessary)
- #QT_OTHER_LIBS="$QT_LIB_DIR -lQt3Support -lQtAssistantClient -lQtDesigner -lQtNetwork -lQtSql -lQtSvg -lQtTest -ltQtUiTools"
- QT_ASSISTANT_LIBS="$QT_LIB_DIR -lQtAssistantClient -lQtNetwork"
+ if test "x$QT_USING_PKGCONFIG" = "xyes"
+ then
+ QT_CORE_LIBS="$QTCORE_LDFLAGS $QTXML_LDFLAGS"
+ QT_GUI_LIBS="$QTGUI_LDFLAGS $QTOPENGL_LDFLAGS $QTWEBKIT_LDFLAGS"
+ QT_ASSISTANT_LIBS="$QTASSISTANT_LDFLAGS $QTNETWORK_LDFLAGS"
+ else
+ QT_CORE_LIBS="$QT_LIB_DIR -lQtCore -lQtXml"
+ # gui libs
+ QT_GUI_LIBS="$QT_LIB_DIR -lQtGui -lQtOpenGL -lQtWebKit"
+ # other libs (currently not used)
+ QT_OTHER_LIBS="$QT_LIB_DIR"
+ # other libs (can be used if necessary)
+ #QT_OTHER_LIBS="$QT_LIB_DIR -lQt3Support -lQtAssistantClient -lQtDesigner -lQtNetwork -lQtSql -lQtSvg -lQtTest -ltQtUiTools"
+ QT_ASSISTANT_LIBS="$QT_LIB_DIR -lQtAssistantClient -lQtNetwork"
+ fi
# all libs
QT_LIBS="$QT_CORE_LIBS $QT_GUI_LIBS $QT_OTHER_LIBS"
# this flag is obsolete with Qt 4
# redefinition compilation warnings
# ============================================================
#
-AM_CXXFLAGS = @KERNEL_CXXFLAGS@ -include SALOMEconfig.h
-AM_CPPFLAGS = @KERNEL_CXXFLAGS@ -include SALOMEconfig.h
+AM_CXXFLAGS = @KERNEL_CXXFLAGS@ -include SALOMEconfig.h -I$(top_builddir)
+AM_CPPFLAGS = @KERNEL_CXXFLAGS@ -include SALOMEconfig.h -I$(top_builddir)
# ============================================================
# This file defines the common definitions used in several
src/GUI_PY/Makefile \
resources/Makefile \
idl/Makefile \
+ tools/Makefile \
+ tools/dlgfactory/Makefile \
Makefile
])
<ul>
<li><b>Simple</b> - as a plain text</li>
<li><b>Tree</b> - in a tree-like form</li>
-</ul></ul>
+</ul>
+<li><b>Automatic nodes compute limit</b></li> - Size limit for the
+mesh groups for which the number of underlying nodes is calculated
+automatically. If the group size exceeds the value set in preferences,
+the user will have to press \em Compute button explicitly. Zero value
+means "no limit". Default value is set to 100 000 mesh elements.
+</li></ul>
<li><b>Automatic Parameters</b></li>
<ul>
<li><b>Ratio Bounding Box Diagonal / Max Size</b> - this parameter is
</ul>
<li><b>Elements</b></li>
<ul>
-<li><b>Fill</b> - allows to select the color of surface of elements
+<li><b>Surface color</b> - allows to select the color of surface of elements
(seen in Shading mode). Click on the colored line to access to the
\ref select_color_and_font_page "Select Color" dialog box.</li>
-<li><b>Outline</b> - allows to select the color of borders of
+<li><b>Back surface color</b> - allows to select the color of interior surface
+of elements. Use slider to select this color. This color generated on base
+of the <b>Surface color</b> by changing it's brightness and saturation.</li>
+<li><b>Outline color</b> - allows to select the color of borders of
elements. Click on the colored line to access to the
\ref select_color_and_font_page "Select Color" dialog box.</li>
-<li><b>Back Face</b> - allows to select the color of interior surface
-of elements. Click on the colored line to access to the
+<li><b>Wireframe color</b> - allows to select the color of borders of
+elements in the wireframe mode. Click on the colored line to access to the
\ref select_color_and_font_page "Select Color" dialog box.</li>
<li><b>Width</b> - allows to define the width of lines (edges and borders of elements).</li>
<li><b>Shrink coef.</b> - allows to define relative space of elements
the current view area to the minimized / maximized state.</center>
<hr>
+\image html occ_view_sync.png
+<br><center><b>Synchronize view</b> - synchronize 3d view parameters.</center>
+This button has two states - checked and unchecked. Clicking on this
+button opens a drop-down menu listing the compatible 3d views. As soon
+as user selects any view from the list, the parameters (view point,
+position, zoom coefficient etc) of the current view are synchronized
+to the selected view (static synchronization).
+
+In addition, when this button is in the "checked" state, the dynamic
+synchronization of the views is performed, i.e. any zoom, pan, rotate
+or other view operation done in one view is automatically applied
+to the second view.
+<hr>
+
\note OCC Viewer features a special <b>Polyline Selection</b>
mechanism, which allows selecting an arbitraty part of the graphic
area using a polygon frame, instead of the usual selection with a
- <b>Main title</b> the title of the XY plot. By default, it will
consist of the names of the tables, on the basis of which the curve
lines have been constructed.
-- <b>Curve type</b> you can select from \b Points, \b Lines and \b Spline.
- <b>Show legend</b> here you can define the position of the
+- <b>Curve type</b> you can select from \b Points, \b Lines and \b Spline.
description table on the XY plot (to the \b Left, to the \b Right, on
\b Top or on \b Bottom).
+- <b>Legend font</b> here you can set type, face and color for the font of Legend item.
- <b>Marker size</b> - size of the points (markers) forming curve lines.
- <b>Background color</b> of the XY plot.
- <b>Scale mode</b> here you can select the type of scaling (\b
(separately for each component) for dumping of a study to a python script.
If the option is disabled, the study is dumped to a single python script.</li>
</ul>
-<li><b>External browser</b></li>
+<li><b>External browser</b></li> - allow to define which browser will
+be used to show SALOME reference manuals: internal (built-in SALOME browser) or external (IE, Netscape, Mozilla, ...).
<ul>
<li>\b Application - this option allows you to set an external browser (IE,
Netscape) which will be used for viewing SALOME reference manuals. By
- <b>OCC Viewer 3d</b>
- <b>Trihedron size</b> - this submenu allows to set the size of
coordinate axes displayed in the viewer.
+ - <b>Relative size</b> - if checked in, trihedron axes scale to fit the
+ size of the area displayed in 3D Viewer.
- <b>Navigation</b> - this option allows to choose one of the
modes of work with mouse in OCC and VTK 3D viewers.
- <b>Salome Standard Controls</b> - allows to manipulate objects in the
relatively to its center.
- <b>Relative to the cursor</b> - allows to zoom the view
relatively to the current cursor position.
+ - <b>Show static trihedron</b> - allows to show/hide the static trihedron
+ located in the bottom-left corner of the viewer.
- <b>VTK Viewer 3d</b>
- <b>Projection mode</b> - allows choosing between \b Orthogonal and
\b Perspective projection mode.
and \b Geometrical progression used for zooming.
- <b>Show static trihedron</b> - allows to show/hide the static trihedron
located in the bottom-left corner of the viewer.
+ - <b>Dynamic pre-selection</b> - switches dynamic pre-selection on/off.
- <b>Spacemouse</b> - a mouse-like manipulator device specially designed
for working with 3D presentations, objects, etc. You can reassign the
actions listed below to any of its buttons.
- <b>Legend Position</b> - this submenu allows to set the default position
of the legend, it can be located to the left, to the right, on top or
on bottom of the graph.
+ - <b>Legend font</b> - this allows to set type and face for the font of Legend item.
- <b>Curve Type</b> - this allows to set the representation of graphs in
your presentations. You can see only <b>Points</b>, points connected with
<b>Lines</b> or points connected with smooth <b>Splines</b>.
of all points displayed in the viewer is greater than zero.
If this condition is not met, the scale is switched to <b>Linear</b>
automatically, even if it is set to <b>Logarithmic</b>.
- - <b>Background Color</b> - this submenu allows to select the background
+ - <b>Background color</b> - this submenu allows to select the background
color. Click on the colored line to access to the
\ref select_color_and_font_page "Select Color" dialog box.
+ - <b>Legend font color</b> - this allows to select the color of the font of the legend item.
+ - <b>Highlighted legend font color</b> - this submenu allows to select the color of the font of the selected legend item.
+ - <b>Selection color</b> - this submenu allows to select the color of selected object in the viewer.
<br><h2>Directories Preferences</h2>
(non-perspective) view's mode.</center>
<hr>
+\image html vtk_view_highlight.png
+<br><center><b>Dynamic pre-selection switch</b> - allows to switch
+on/off dynamic pre-selection of the objects. When the dynamic
+pre-selection is switched on, the objects can be selected by clicking
+of the point/cell belonging to this object, with some performance
+loss. Switch dynamic pre-selection off to have good performance on the
+big objects (like huge meshes).</center>
+<hr>
+
\image html vtk_view_triedre.png
<br><center><b>Show/Hide Trihedron</b> - shows or hides coordinate axes.</center>
<hr>
mode</b> only)
<hr>
+\image html vtk_view_sync.png
+<br><center><b>Synchronize view</b> - synchronize 3d view parameters.</center>
+This button has two states - checked and unchecked. Clicking on this
+button opens a drop-down menu listing the compatible 3d views. As soon
+as user selects any view from the list, the parameters (view point,
+position, zoom coefficient etc) of the current view are synchronized
+to the selected view (static synchronization).
+
+In addition, when this button is in the "checked" state, the dynamic
+synchronization of the views is performed, i.e. any zoom, pan, rotate
+or other view operation done in one view is automatically applied
+to the second view.
+<hr>
+
\image html vtk_view_parallel.png
<br><center><b>Orthogonal mode</b> - Switches the view to the orthogonal mode.</center>
<hr>
#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
#endif
+
+#if OCC_VERSION_LARGE > 0x06050100 // for OCC-6.5.2 and higher version
+ status = app->Open( CAF_Tools::toExtString( fname ), myStdDoc ) == PCDM_RS_OK;
+#else
status = app->Open( CAF_Tools::toExtString( fname ), myStdDoc ) == CDF_RS_OK;
+#endif
}
catch ( Standard_Failure ) {
status = false;
OCC_CATCH_SIGNALS;
#endif
if ( save )
+#if OCC_VERSION_LARGE > 0x06050100 // for OCC-6.5.2 and higher version
+ status = app->Save( stdDoc() ) == PCDM_SS_OK;
+#else
status = app->Save( stdDoc() ) == CDF_SS_OK;
+#endif
else
{
TCollection_ExtendedString format, path( CAF_Tools::toExtString( fname ) );
if ( format.Length() )
stdDoc()->ChangeStorageFormat( format );
+#if OCC_VERSION_LARGE > 0x06050100 // for OCC-6.5.2 and higher version
+ status = app->SaveAs( stdDoc(), path ) == PCDM_SS_OK;
+#else
status = app->SaveAs( stdDoc(), path ) == CDF_SS_OK;
+#endif
}
}
catch ( Standard_Failure ) {
#include <cstdio>
+class BusyLocker
+{
+public:
+ BusyLocker( bool& busy ) : myPrev( busy ), myBusy( busy ) { myBusy = true; }
+ ~BusyLocker() { myBusy = myPrev; }
+private:
+ bool myPrev;
+ bool& myBusy;
+};
+
/*!
\brief Create new instance of CAM_Application.
\return new instance of CAM_Application class
CAM_Application::CAM_Application( const bool autoLoad )
: STD_Application(),
myModule( 0 ),
- myAutoLoad( autoLoad )
+ myAutoLoad( autoLoad ),
+ myBlocked( false )
{
readModuleList();
}
*/
bool CAM_Application::activateModule( const QString& modName )
{
- if ( !modName.isEmpty() && !activeStudy() )
+ if ( !modName.isEmpty() && !activeStudy() || myBlocked )
return false;
+ // VSR 25/10/2011: prevent nested activation/deactivation
+ // See issues 0021307, 0021373
+ BusyLocker lock( myBlocked );
+
bool res = false;
if ( !modName.isEmpty() )
{
if ( myModule )
{
- // VSR: 26/06/2011 bug 0021307: temporarily disable desktop's signals to prevent false module activation
- bool signalsBlocked = desktop() && desktop()->signalsBlocked();
- if ( desktop() ) desktop()->blockSignals( true );
if ( !myModule->deactivateModule( activeStudy() ) )
{
// ....
}
- // VSR: 26/06/2011 bug 0021307: enable desktop's signals back
- if ( desktop() ) desktop()->blockSignals( signalsBlocked );
}
myModule = mod;
bool aIsSingleton = resMgr->booleanValue(*it, "singleton", false);
- QString ver = resMgr->stringValue(*it, modName + "_VERSION", QString());
+ QString ver = resMgr->stringValue(*it, "version", QString());
ModuleInfo inf;
inf.name = modName;
ModuleShortInfo kernel;
kernel.name = "KERNEL";
- kernel.version = GUI_VERSION_STR;
+ kernel.version = KERNEL_VERSION_STR;
info.append(kernel);
ModuleShortInfo gui;
ModuleList myModules; //!< loaded modules list
ModuleInfoList myInfoList; //!< modules info list
bool myAutoLoad; //!< auto loading flag
+ bool myBlocked; //!< "blocked" flag, internal usage
};
#ifdef WIN32
nodist_salomeres_DATA = CAM_msg_en.qm CAM_msg_fr.qm
-libCAM_la_CPPFLAGS = $(QT_INCLUDES) -I$(srcdir)/../SUIT -I$(srcdir)/../STD -I$(srcdir)/../Qtx -I$(top_builddir)
+libCAM_la_CPPFLAGS = $(QT_INCLUDES) -I$(srcdir)/../SUIT -I$(srcdir)/../STD -I$(srcdir)/../Qtx
libCAM_la_LDFLAGS = $(QT_MT_LIBS)
libCAM_la_LIBADD = ../Qtx/libqtx.la ../SUIT/libsuit.la ../STD/libstd.la
return false;
GLfloat xa, xb, ya, yb, l;
GLfloat rsin, rcos, r, ra, rb;
- GLboolean update;
+ // GLboolean update;
GLboolean selected = myIsSel;
myIsSel = GL_FALSE;
else
myHighFlag = GL_TRUE;
- update = ( GLboolean )( myIsSel != selected );
+ // update = ( GLboolean )( myIsSel != selected );
// cout << "GLViewer_Polyline::select complete with " << (int)myIsSel << endl;
if( !aList.isEmpty() )
{
- int index = 0;
int str_size = aList.first().length();
for( int i = 1, size = aList.count(); i < size; i++ )
{
if ( str_size < (int)aList[i].length() )
{
- index = i;
str_size = aList[i].length();
}
}
mypkgpythondir = $(salomepythondir)/salome/gui
# Python modules to be installed
-mypkgpython_PYTHON = __init__.py \
- selectvars.py
+mypkgpython_PYTHON = \
+ __init__.py \
+ SelectVarsDialog_ui.py \
+ selectvars.py \
+ genericdialog_ui.py \
+ genericdialog.py \
+ mytestdialog_ui.py \
+ mytestdialog.py \
+ helper.py
-nodist_mypkgpython_PYTHON = SelectVarsDialog.py
-CLEANFILES = $(nodist_mypkgpython_PYTHON)
-EXTRA_DIST += SelectVarsDialog.ui
+PYUIC_FILES = \
+ SelectVarsDialog_ui.py \
+ genericdialog_ui.py \
+ mytestdialog_ui.py
-%.py:%.ui
- $(PYUIC) $< -o $@
+nodist_mypkgpython_PYTHON = $(PYUIC_FILES)
+CLEANFILES = $(PYUIC_FILES)
+
+EXTRA_DIST += \
+ SelectVarsDialog.ui \
+ genericdialog.ui \
+ mytestdialog.ui
+
+# This rule indicates that some python files are generated from ui
+# files using the PYUIC utility. The convention is to create a file
+# name <basename>_ui.py when the ui file name is <basename>.ui. When
+# implementing the dialog, you generally create a third file named
+# <basename>.py that uses the UI_<basename> classe defined in the
+# generated file <basename>_ui.py.
+%_ui.py:%.ui
+ $(PYUIC) -x $< -o $@
--- /dev/null
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2010 EDF 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
+#
+# -* Makefile *-
+#
+
+__author__="gboulant"
+__date__ ="$31 mars 2010 17:09:53$"
+
+from PyQt4.QtGui import QDialog, QMessageBox
+
+from genericdialog_ui import Ui_GenericDialog
+
+class GenericDialog(QDialog):
+ """
+ This is an abstract generic dialog box for implementing default and
+ generic behaviour of dialog windows.
+ Note that this class can be instantiated but can't be used because the
+ OK behaviour is a default one indicating that the checkData function should
+ be implemented in a derived class. The general interface that should be
+ implemented in derived class is the MVC pattern:
+
+ - setData(<a_data_model_object>):
+ to initiate the values of the dialog windows from a given data model.
+
+ - boolean checkData():
+ to verify that the data are valid and notify user if not.
+
+ - <a_data_model_object> getData():
+ to get the valid data model from values read in the dialog window.
+ """
+
+ __wasOk = False
+ checkDataMessage = ""
+
+ def __init__(self,parent = None,name = None,modal = 0,fl = 0):
+ QDialog.__init__(self,parent)
+ # Set up the user interface from Designer.
+ self.__ui = Ui_GenericDialog()
+ self.__ui.setupUi(self)
+
+ def getPanel(self):
+ '''
+ This returns the central panel where to draw the custom dialog
+ widgets.
+ '''
+ return self.__ui.myCenterPanel
+
+ def getButtonBox(self):
+ return self.__ui.buttonBox
+
+ def accept(self):
+ """
+ Slot function connected to the button OK
+ """
+ if not self.checkData():
+ QMessageBox.warning( self, "Alerte", self.checkDataMessage)
+ return
+ self.__wasOk = True
+ self.hide()
+
+ def displayAndWait(self):
+ """
+ This function can be used to display the dialog in the case
+ where the dialog is modal and does not need interactivity with
+ parent windows and other part of the application. When called,
+ the dialog is raised visible and keep waiting until the button
+ OK or the button CANCEL is pressed. Then the flow can go on
+ (see an example of implementation in the tests functions at
+ the end of this file).
+ In the general case, in particular if you need interaction
+ with the graphical framework (clic on widgets embedded in
+ other dialogs), you should used instead the show() command
+ (for a non modal dialog) or the open() command (for a window
+ modal dialog, i.e. a dialog that can not interact with its
+ direct parent but can interact with the other parts).
+ """
+ self.__wasOk = False
+ self.exec_()
+
+ def wasOk(self):
+ """
+ Return True if the button OK was pressed to close the dialog windows.
+ """
+ return self.__wasOk
+
+ def checkData(self):
+ """
+ This function should be implemented in a derived class. It should return
+ True in the case where the data are estimated to be valid data.
+ """
+ self.checkDataMessage = "The checkData() function is not implemented yet"
+ return True
+
+#
+# ==============================================================================
+# Basic use cases and unit test functions
+# ==============================================================================
+#
+def TEST_GenericDialog():
+ import sys
+ from PyQt4.QtGui import QApplication
+ from PyQt4.QtCore import QObject, SIGNAL, SLOT
+ app = QApplication(sys.argv)
+ QObject.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
+
+ dlg=GenericDialog()
+ dlg.displayAndWait()
+ if dlg.wasOk():
+ print "OK has been pressed"
+ else:
+ print "Cancel has been pressed"
+
+if __name__ == "__main__":
+ TEST_GenericDialog()
--- /dev/null
+<ui version="4.0" >
+ <class>GenericDialog</class>
+ <widget class="QDialog" name="GenericDialog" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>498</width>
+ <height>352</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Dialog</string>
+ </property>
+ <layout class="QHBoxLayout" >
+ <property name="margin" >
+ <number>9</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <layout class="QVBoxLayout" >
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QFrame" name="myCenterPanel" >
+ <property name="frameShape" >
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Raised</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons" >
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>GenericDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>GenericDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
--- /dev/null
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# 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
+#
+
+# Author: Guillaume Boulant (EDF/R&D)
+
+# ==================================================================
+# This file provides helper functions to drive some gui features of a
+# SALOME Application (the selection in the object browser for now,
+# further development coming soon). Note that some of these helper
+# functions are specialized for a GEOM or SMESH context (see the
+# guihelper.py modules comming with the packages salome.geom and
+# salome.smesh.
+# ==================================================================
+
+#
+# ==================================================================
+# Definition of usefull objects and functions to deal with the SALOME
+# technical context.
+# ==================================================================
+#
+
+from salome.kernel import services
+
+#
+# Get SALOME PyQt interface to manipulate the GUI context
+# (Get the active study for example. Note that the active study is a
+# GUI concept only: it is the study that is currently active in the
+# desktop)
+#
+import SalomePyQt
+sgPyQt=SalomePyQt.SalomePyQt()
+
+#
+# Get SALOME Swig interface to manipulate the GUI widget
+#
+import libSALOME_Swig
+SalomeGUI = libSALOME_Swig.SALOMEGUI_Swig()
+
+#
+# ==================================================================
+# General helper function for GUI programming actions
+# ==================================================================
+#
+# Get the active study
+#
+def getActiveStudy():
+ """
+ This returns a study object that corresponds to the active
+ study. The active study is a GUI concept: it's the study currently
+ active on the desktop.
+ """
+ studyId = sgPyQt.getStudyId()
+ study = services.getStudyManager().GetStudyByID( studyId )
+ return study
+
+#
+# ==================================================================
+# Functions to manipulate the objects in the browser (generic)
+# ==================================================================
+#
+def getSObjectSelected():
+ '''
+ Returns the sobject and the entry of the item currently selected
+ in the objects browser. Returns "None, None" if no item is
+ selected. If several objects are selected, it returns the first
+ one of the list.
+ '''
+ sobj = None
+ entry = None
+ study = getActiveStudy()
+ if SalomeGUI.SelectedCount() == 1:
+ # We only considere the first element of the list. If you need
+ # something else, create another function in your own context.
+ entry = SalomeGUI.getSelected( 0 )
+ if entry != '':
+ sobj = study.FindObjectID( entry )
+ return sobj, entry
+
+def showSObjectSelected():
+ '''
+ This function print the attributes of the selected object.
+ (this function is only for test purpose)
+ '''
+ sobj, entry = getSObjectSelected()
+ if ( sobj ):
+ test, attr = sobj.FindAttribute( "AttributeName" )
+ if test:
+ message = "My name is '%s'" % attr.Value()
+ print message
+ pass
+
+def deleteSObjectSelected():
+ '''
+ This function deletes the selected object.
+ '''
+ sobj, entry = getSObjectSelected()
+ if ( sobj ):
+ study = getActiveStudy()
+ builder = study.NewBuilder()
+ builder.RemoveObject( sobj )
+ SalomeGUI.updateObjBrowser(True)
+ pass
+
+#
+# ==================================================================
+# Use cases and demo functions
+# ==================================================================
+#
+
+# CAUTION: Before running this test functions, you first have to
+# create (or import) an object and select this object in the objects
+# browser.
+
+#
+# Definitions:
+# - the SObject is an item in the active study (Study Object).
+# - the entry is the identifier of an item.
+# - the object (geom object or smesh object) is a CORBA servant
+# embedded in the SALOME component container and with a reference in
+# the SALOME study, so that it can be retrieved.
+#
+
+def TEST_getSObjectSelected():
+ mySObject, myEntry = getSObjectSelected()
+ myName = mySObject.GetName()
+ print "The name of the selected object is %s"%myName
+
+def TEST_showSObjectSelected():
+ showSObjectSelected()
+
+if __name__ == "__main__":
+ TEST_getSObjectSelected()
+ TEST_showSObjectSelected()
--- /dev/null
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2010 EDF 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
+#
+# -* Makefile *-
+#
+
+__author__="gboulant"
+__date__ ="$31 mars 2010 17:09:53$"
+
+from mytestdialog_ui import Ui_MyTestDialog
+from genericdialog import GenericDialog
+
+class MyTestDialog(GenericDialog):
+ """
+ This class is to illustrate the usage of the GenericDialog to implement
+ the dialog windows of the application with a common design template provided
+ by the generic class GenericDialog.
+ """
+ def __init__(self, parent=None, name="MyTestDialog"):
+ GenericDialog.__init__(self, parent, name)
+ # Set up the user interface from Designer.
+ self.ui = Ui_MyTestDialog()
+ # BE CAREFULL HERE, the ui form is NOT put in the global dialog (already
+ # containing some generic widgets) but in the center panel created in the
+ # GenericDialog as a void container for the form. The MyTestDialog form
+ # is supposed here to create only the widgets to be placed in the center
+ # panel
+ self.ui.setupUi(self.getPanel())
+
+ #
+ # We implement here the interface of the MVC pattern
+ #
+ def setData(self, name):
+ """
+ This function implements the mapping from the data model to the widgets
+ """
+ self.ui.txtName.setText(name)
+
+ def checkData(self):
+ """
+ This function implements the control to be done on the values contained
+ in the widgets when trying to validate the dialog window (click OK first
+ trigs this function).
+ """
+ if ( self.ui.txtName.text().trimmed() == "" ):
+ self.checkDataMessage = "The name can't be void"
+ return False
+ return True
+
+ def getData(self):
+ """
+ This function implements the mapping from the widgets to the data model
+ """
+ name = str(self.ui.txtName.text().trimmed().toUtf8())
+ # _MEM_: note here that (i) the utf8 format is used and (ii) we must not
+ # forget to convert to a standard python string (instead of a QString).
+ return name
+
+
+from PyQt4.QtCore import SIGNAL
+class MyTestDialogWithSignals(MyTestDialog):
+ """
+ This class is to illustrate the usage of the GenericDialog in the
+ case where the dialog windows is not modal. In such a case, the
+ controller must be warn of close events using Qt signals.
+ """
+ def __init__(self, parent=None, name="MyTestDialogWithSignals"):
+ MyTestDialog.__init__(self, parent, name)
+
+ def accept(self):
+ """
+ This function is the slot connected to the the OK button
+ (click event of the OK button).
+ """
+ # The dialog is raised in a non modal mode (for example, to
+ # get interactivity with the parents windows. Then we have to
+ # emit a signal to warn the parent observer that the dialog
+ # has been validated so that it can process the event
+ MyTestDialog.accept(self)
+ if self.wasOk():
+ self.emit(SIGNAL('inputValidated()'))
+
+
+
+#
+# ==============================================================================
+# Basic use case
+# ==============================================================================
+#
+
+def TEST_MyTestDialog_modal():
+ import sys
+ from PyQt4.QtCore import QObject, SIGNAL, SLOT
+ from PyQt4.QtGui import QApplication
+ app = QApplication(sys.argv)
+ QObject.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
+
+ dlg=MyTestDialog()
+ dlg.setData("A default name")
+ dlg.displayAndWait()
+ if dlg.wasOk():
+ name = dlg.getData()
+ print "The name has been modified to",name
+
+
+class DialogListener:
+ def onProcessEvent(self):
+ print "onProcessEvent(): OK has been pressed"
+ import sys
+ sys.exit(0)
+
+
+def TEST_MyTestDialog_non_modal():
+ import sys
+ from PyQt4.QtCore import QObject, SIGNAL, SLOT
+ from PyQt4.QtGui import QApplication
+ app = QApplication(sys.argv)
+ QObject.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
+
+ dlg=MyTestDialogWithSignals()
+ # This dialog window will emit a inputValidated() signal when the
+ # OK button is pressed and the data are validated. Then, we
+ # connect this signal to a local slot so that the event can be
+ # processed.
+ dlgListener = DialogListener()
+ app.connect(dlg, SIGNAL('inputValidated()'), dlgListener.onProcessEvent)
+ # This connect instruction means that the signal inputValidated()
+ # emited by the dlg Qt object will raise a call to the slot
+ # dlgListener.onProcessEvent
+
+ dlg.setData("A default name")
+ dlg.show()
+
+ app.exec_()
+
+if __name__ == "__main__":
+ #TEST_MyTestDialog_modal()
+ TEST_MyTestDialog_non_modal()
--- /dev/null
+<ui version="4.0" >
+ <class>MyTestDialog</class>
+ <widget class="QDialog" name="MyTestDialog" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Dialog</string>
+ </property>
+ <layout class="QHBoxLayout" >
+ <property name="margin" >
+ <number>9</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <layout class="QVBoxLayout" >
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout" >
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="lblName" >
+ <property name="text" >
+ <string>TextLabel</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="txtName" />
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
# Dialog box for variables selection #
# ---------------------------------- #
-from SelectVarsDialog import Ui_SelectVarsDialog
+from SelectVarsDialog_ui import Ui_SelectVarsDialog
class MySelectVarsDialog(Ui_SelectVarsDialog, QtGui.QDialog):
#include "LightApp_SelectionMgr.h"
#include "LightApp_DataObject.h"
#include "LightApp_WgViewModel.h"
+#include "LightApp_FullScreenHelper.h"
#include <Basics_OCCTVersion.hxx>
#include <QtxSearchTool.h>
#include <QtxWorkstack.h>
#include <QtxMap.h>
+#include <QtxWebBrowser.h>
#include <LogWindow.h>
#include <QTimer>
#include <QHeaderView>
#include <QTreeView>
+#include <QMimeData>
+#include <QShortcut>
#include <utilities.h>
/*! \var global preferences of LightApp */
LightApp_Preferences* LightApp_Application::_prefs_ = 0;
+
+static inline QString getFile(){
+#ifdef WIN32
+ return QString( "file://" );
+#else
+ return QString( "file:" );
+#endif
+}
+
+
/*!
\class LightApp_Application
Application containing LightApp module
/*!Constructor.*/
LightApp_Application::LightApp_Application()
: CAM_Application( false ),
- myPrefs( 0 )
+ myPrefs( 0 ),
+ myScreenHelper(new LightApp_FullScreenHelper())
{
Q_INIT_RESOURCE( LightApp );
STD_TabDesktop* desk = new STD_TabDesktop();
+ desk->setFullScreenAllowed(false);
setDesktop( desk );
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
+ QtxWebBrowser::setData("browser:icon", aResMgr->loadPixmap( "LightApp", tr( "BROWSER_ICON" ) ) );
+ QtxWebBrowser::setData("browser:title", tr( "BROWSER_TITLE" ) );
+ QtxWebBrowser::setData("toolbar:title", tr( "BROWSER_TOOLBAR_TITLE" ) );
+ QtxWebBrowser::setData("menu:file:title", tr( "BROWSER_FILEMENU" ) );
+ QtxWebBrowser::setData("action:close:title", tr( "BROWSER_CLOSE" ) );
+ QtxWebBrowser::setData("action:close:icon", aResMgr->loadPixmap( "LightApp", tr( "BROWSER_CLOSE_ICON" ) ) );
+ QtxWebBrowser::setData("action:back:title", tr( "BROWSER_BACK" ) );
+ QtxWebBrowser::setData("action:forward:title", tr( "BROWSER_FORWARD" ) );
+ QtxWebBrowser::setData("action:find:title", tr( "BROWSER_FIND" ) );
+ QtxWebBrowser::setData("action:findnext:title", tr( "BROWSER_FINDNEXT" ) );
+ QtxWebBrowser::setData("action:findprev:title", tr( "BROWSER_FINDPREV" ) );
+
desktop()->setWindowIcon( aLogo );
desktop()->setDockableMenuBar( false );
desktop()->setDockableStatusBar( false );
LightApp_Application::~LightApp_Application()
{
delete mySelMgr;
+ delete myScreenHelper;
}
/*!Start application.*/
if ( QFile::exists( indexFile ) )
helpData.insert( tr( "%1 module Users's Guide" ).arg( aModule ), indexFile );
}
-
+
IMapConstIterator<QString, QString > fileIt;
for ( fileIt = helpData.begin(); fileIt != helpData.end(); fileIt++ ) {
QString helpFileName = fileIt.key();
a->setData( fileIt.value() );
if ( !helpSubMenu.isEmpty() ){
int helpSubMenuId = createMenu( helpSubMenu, helpMenu, -1, 0 );
- createMenu( a, helpSubMenuId, -1 );
+ createMenu( a, helpSubMenuId, -1 );
}
else
createMenu( a, helpMenu, -1, 0 );
static QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), 0 );
connect( mru, SIGNAL( activated( const QString& ) ), this, SLOT( onMRUActivated( const QString& ) ) );
registerAction( MRUId, mru );
-
+
// default icon for neutral point ('SALOME' module)
QPixmap defIcon = resMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
if ( defIcon.isNull() )
defIcon = QPixmap( imageEmptyIcon );
-
+
//! default icon for any module
QPixmap modIcon = resMgr->loadPixmap( "LightApp", tr( "APP_MODULE_ICO" ), false );
if ( modIcon.isNull() )
modIcon = QPixmap( imageEmptyIcon );
-
+
QStringList modList;
modules( modList, false );
{
if ( !isLibExists( *it ) )
continue;
-
+
QString modName = moduleName( *it );
if ( !isModuleAccessible( *it ) )
{
icon = modIcon;
INFOS ( "****************************************************************" << std::endl
- << "* Icon for " << (*it).toLatin1().constData()
+ << "* Icon for " << (*it).toLatin1().constData()
<< " not found. Using the default one." << std::endl
<< "****************************************************************" << std::endl );
}
moduleAction->insertModule( *it, icon );
}
- connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ),
+ connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ),
this, SLOT( onModuleActivation( const QString& ) ) );
registerAction( ModulesListId, moduleAction );
}
createAction( StyleId, tr( "TOT_THEME" ), QIcon(), tr( "MEN_DESK_THEME" ), tr( "PRP_THEME" ),
0, desk, false, this, SLOT( onStylePreferences() ) );
+ createAction( FullScreenId, tr( "TOT_FULLSCREEN" ), QIcon(), tr( "MEN_DESK_FULLSCREEN" ), tr( "PRP_FULLSCREEN" ),
+ Qt::Key_F11, desk, false, this, SLOT( onFullScreen() ) );
+
+
int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1 );
createMenu( separator(), viewMenu, -1, 20, -1 );
createMenu( StyleId, viewMenu, 20, -1 );
+ createMenu( FullScreenId, viewMenu, 20, -1 );
int modTBar = createTool( tr( "INF_TOOLBAR_MODULES" ) );
createTool( ModulesListId, modTBar );
const QString& theContext = QString() )
: myApp( theApp ),
myParams( theParams ),
-#ifdef WIN32
- myHelpFile( "file://" + theHelpFile ),
-#else
- myHelpFile( "file:" + theHelpFile ),
-#endif
myContext( theContext ),
myStatus(0),
myLApp( app )
{
+ myHelpFile = QString("%1%2").arg( getFile() ).arg( QFileInfo( theHelpFile ).canonicalFilePath() );
}
virtual void run()
anApp.append( quote );
#endif
QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
+ bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
- if ( !anApp.isEmpty() )
- {
- RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
- rs->start();
- }
- else
- {
- if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
- SUIT_MessageBox::Yes | SUIT_MessageBox::No,
- SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
+ if( useExtBrowser ) {
+ if ( !anApp.isEmpty() ) {
+ RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
+ rs->start();
+ }
+ else {
+ if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
+ SUIT_MessageBox::Yes | SUIT_MessageBox::No,
+ SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
- showPreferences( tr( "PREF_APP" ) );
+ showPreferences( tr( "PREF_APP" ) );
+ }
+ }
+ else {
+ QtxWebBrowser::loadUrl(getFile() + helpFile);
}
}
anApp.prepend( quote );
anApp.append( quote );
#endif
- QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
- if ( !anApp.isEmpty() )
- {
- RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile, theContext );
- rs->start();
+ bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
+
+ if(useExtBrowser) {
+ QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
+
+ if ( !anApp.isEmpty() ) {
+ RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile, theContext );
+ rs->start();
+ }
+ else {
+ if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
+ SUIT_MessageBox::Yes | SUIT_MessageBox::No,
+ SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
+ showPreferences( tr( "PREF_APP" ) );
+ }
}
- else
- {
- if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
- SUIT_MessageBox::Yes | SUIT_MessageBox::No,
- SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
- showPreferences( tr( "PREF_APP" ) );
+ else {
+ QtxWebBrowser::loadUrl(getFile() + helpFile, theContext );
}
}
#ifndef DISABLE_SALOMEOBJECT
vm = new SOCC_Viewer();
#else
- vm = new OCCViewer_Viewer( true, resMgr->booleanValue( "OCCViewer", "static_trihedron", true ) );
+ vm = new OCCViewer_Viewer( true );
#endif
- vm->setBackgroundColor( OCCViewer_ViewFrame::TOP_LEFT,
+ vm->setBackgroundColor( OCCViewer_ViewFrame::TOP_LEFT,
resMgr->colorValue( "OCCViewer", "xz_background", vm->backgroundColor() ) );
- vm->setBackgroundColor( OCCViewer_ViewFrame::TOP_RIGHT,
- resMgr->colorValue( "OCCViewer", "yz_background", vm->backgroundColor() ) );
-
+ vm->setBackgroundColor( OCCViewer_ViewFrame::TOP_RIGHT,
+ resMgr->colorValue( "OCCViewer", "yz_background", vm->backgroundColor() ) );
+
vm->setBackgroundColor( OCCViewer_ViewFrame::BOTTOM_LEFT,
resMgr->colorValue( "OCCViewer", "xy_background", vm->backgroundColor() ) );
- vm->setBackgroundColor( OCCViewer_ViewFrame::BOTTOM_RIGHT,
- resMgr->colorValue( "OCCViewer", "background", vm->backgroundColor() ) );
-
- vm->setTrihedronSize( resMgr->doubleValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ) );
+ vm->setBackgroundColor( OCCViewer_ViewFrame::BOTTOM_RIGHT,
+ resMgr->colorValue( "OCCViewer", "background", vm->backgroundColor() ) );
+
+ vm->setTrihedronSize( resMgr->doubleValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ),
+ resMgr->booleanValue( "OCCViewer", "relative_size", vm->trihedronRelative() ));
int u( 1 ), v( 1 );
vm->isos( u, v );
u = resMgr->integerValue( "OCCViewer", "iso_number_u", u );
vm->setStaticTrihedronVisible( resMgr->booleanValue( "VTKViewer", "show_static_trihedron", vm->isStaticTrihedronVisible() ) );
vm->setInteractionStyle( resMgr->integerValue( "VTKViewer", "navigation_mode", vm->interactionStyle() ) );
vm->setZoomingStyle( resMgr->integerValue( "VTKViewer", "zooming_mode", vm->zoomingStyle() ) );
+ vm->setDynamicPreSelection( resMgr->booleanValue( "VTKViewer", "dynamic_preselection", vm->dynamicPreSelection() ) );
vm->setIncrementalSpeed( resMgr->integerValue( "VTKViewer", "speed_value", vm->incrementalSpeed() ),
resMgr->integerValue( "VTKViewer", "speed_mode", vm->incrementalSpeedMode() ) );
vm->setSpacemouseButtons( resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", vm->spacemouseBtn(1) ),
{
SUIT_ResourceMgr* resMgr = resourceMgr();
- SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
- desktop(),
- new LightApp_WgViewModel( vmType, w ) );
+ SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
+ desktop(),
+ new LightApp_WgViewModel( vmType, w ) );
vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
-
+
addViewManager( vm );
SUIT_ViewWindow* vw = vm->createViewWindow();
if ( vw && desktop() ) {
updateObjectBrowser( true );
}
+/*!Private SLOT. Support drag-and-drop operation.*/
+void LightApp_Application::onDropped (const QMimeData *data, Qt::DropAction action,
+ int row, int column, const QModelIndex& parent)
+{
+ if (action == Qt::IgnoreAction)
+ return;
+
+ if (!data->hasFormat("application/vnd.text.list"))
+ return;
+
+ if (column > 0)
+ return;
+
+ if (!parent.isValid())
+ // dropping into the top level of the model is not allowed
+ return;
+
+ SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>(objectBrowser()->model());
+
+ SUIT_DataObject* obj = treeModel->object(parent);
+ if (!obj)
+ return;
+
+ LightApp_DataObject* parentObj = dynamic_cast<LightApp_DataObject*>(obj);
+ if (!parentObj)
+ return;
+
+ // decode mime data
+ QByteArray encodedData = data->data("application/vnd.text.list");
+ QDataStream stream (&encodedData, QIODevice::ReadOnly);
+ QStringList newItems;
+
+ while (!stream.atEnd()) {
+ QString text;
+ stream >> text;
+ if (!text.isEmpty())
+ newItems << text;
+ }
+
+ DataObjectList listObjs;
+ foreach (QString text, newItems) {
+ SUIT_DataObject* anObji = findObject(text);
+ if (anObji)
+ listObjs.append(anObji);
+ }
+
+ // tmp: clear selection to avoid problem with persistent data model indexes
+ //mySelMgr->clearSelected();
+
+ LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(parentObj->module());
+ if (aModule)
+ aModule->dropObjects(listObjs, action, parentObj, row);
+}
+
/*!Private SLOT. On preferences.*/
void LightApp_Application::onPreferences()
{
treeModel->registerColumn( 0, EntryCol, LightApp_DataObject::EntryId );
treeModel->setAppropriate( EntryCol, Qtx::Toggled );
+ // Mantis issue 0020136: Drag&Drop in OB
+ SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
+ connect( proxyModel, SIGNAL(dropped(const QMimeData*, Qt::DropAction, int, int, const QModelIndex&)),
+ this, SLOT(onDropped(const QMimeData*, Qt::DropAction, int, int, const QModelIndex&)) );
+
// temporary commented
/*
OB_ListView* ob_list = dynamic_cast<OB_ListView*>( const_cast<QListView*>( ob->listView() ) );
pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" );
- int autoSaveInterval = pref->addPreference( tr( "PREF_AUTO_SAVE" ), studyGroup,
+ int autoSaveInterval = pref->addPreference( tr( "PREF_AUTO_SAVE" ), studyGroup,
LightApp_Preferences::IntSpin, "Study", "auto_save_interval" );
pref->setItemProperty( "min", 0, autoSaveInterval );
pref->setItemProperty( "max", 1440, autoSaveInterval );
pref->setItemProperty( "special", tr( "PREF_AUTO_SAVE_DISABLED" ), autoSaveInterval );
- int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab );
+ int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab, LightApp_Preferences::Auto, "ExternalBrowser", "use_external_browser");
QString platform;
#ifdef WIN32
platform = "winapplication";
int genGroup = pref->addPreference( tr( "PREF_GROUP_COMMON" ), viewTab );
pref->addPreference( tr( "PREF_DROP_DOWN_BUTTONS" ), genGroup,
- LightApp_Preferences::Bool, "viewers", "drop_down_buttons" );
-
+ LightApp_Preferences::Bool, "viewers", "drop_down_buttons" );
+
int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), viewTab );
int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), viewTab );
pref->setItemProperty( "min", 1.0E-06, occTS );
pref->setItemProperty( "max", 1000, occTS );
+ pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), occGroup, LightApp_Preferences::Bool, "OCCViewer", "relative_size" );
+
int occStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), occGroup,
LightApp_Preferences::Selector, "OCCViewer", "navigation_mode" );
pref->setItemProperty( "indexes", aModeIndexesList, occZoomingStyleMode );
#endif
+ pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), occGroup, LightApp_Preferences::Bool, "OCCViewer", "show_static_trihedron" );
+
// VTK Viewer
int vtkGen = pref->addPreference( "", vtkGroup, LightApp_Preferences::Frame );
pref->setItemProperty( "columns", 2, vtkGen );
pref->setItemProperty( "indexes", aModeIndexesList, vtkSpeedMode );
pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), vtkGen, LightApp_Preferences::Bool, "VTKViewer", "show_static_trihedron" );
+ pref->addPreference( tr( "PREF_DYNAMIC_PRESELECTION" ), vtkGen, LightApp_Preferences::Bool, "VTKViewer", "dynamic_preselection" );
int vtkSM = pref->addPreference( tr( "PREF_FRAME_SPACEMOUSE" ), vtkGroup, LightApp_Preferences::GroupBox );
pref->setItemProperty( "columns", 2, vtkSM );
pref->setItemProperty( "strings", aValuesList, legendPosition );
pref->setItemProperty( "indexes", anIndicesList, legendPosition );
+ pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
+
int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dGroup,
LightApp_Preferences::Selector, "Plot2d", "CurveType" );
aValuesList.clear();
pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), plot2dGroup,
LightApp_Preferences::Color, "Plot2d", "Background" );
+ pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
+
+ pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
+
+ pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
+ LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
+
+
int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
pref->addPreference( tr( "" ), dirGroup,
if ( !resMgr )
return;
- if ( sec == "viewers" && param == "drop_down_buttons" )
+ if ( sec == "viewers" && param == "drop_down_buttons" )
{
ViewManagerList vmlist = viewManagers();
foreach( SUIT_ViewManager* vm, vmlist )
{
QVector<SUIT_ViewWindow*> vwlist = vm->getViews();
foreach( SUIT_ViewWindow* vw, vwlist )
- if ( vw ) vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
+ if ( vw ) vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
}
}
#ifndef DISABLE_OCCVIEWER
- if ( sec == QString( "OCCViewer" ) && param == QString( "trihedron_size" ) )
+ if ( sec == QString( "OCCViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )))
{
- double sz = resMgr->doubleValue( sec, param, -1 );
+ double sz = resMgr->doubleValue( sec, "trihedron_size", -1 );
+ bool relative = resMgr->booleanValue( sec, "relative_size", true );
QList<SUIT_ViewManager*> lst;
viewManagers( OCCViewer_Viewer::Type(), lst );
QListIterator<SUIT_ViewManager*> it( lst );
continue;
OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
- occVM->setTrihedronSize( sz );
+ occVM->setTrihedronSize( sz, relative );
occVM->getAISContext()->UpdateCurrentViewer();
}
}
#endif
+#ifndef DISABLE_OCCVIEWER
+ if ( sec == QString( "OCCViewer" ) && param == QString( "show_static_trihedron" ) )
+ {
+ bool isVisible = resMgr->booleanValue( "OCCViewer", "show_static_trihedron", true );
+ QList<SUIT_ViewManager*> lst;
+ viewManagers( OCCViewer_Viewer::Type(), lst );
+ QListIterator<SUIT_ViewManager*> it( lst );
+ while ( it.hasNext() )
+ {
+ SUIT_ViewModel* vm = it.next()->getViewModel();
+ if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
+ continue;
+
+ OCCViewer_Viewer* occVM = dynamic_cast<OCCViewer_Viewer*>( vm );
+ if( occVM )
+ {
+ occVM->setStaticTrihedronDisplayed( isVisible );
+ }
+ }
+ }
+#endif
+
#ifndef DISABLE_OCCVIEWER
if ( sec == QString( "OCCViewer" ) && param == QString( "navigation_mode" ) )
{
}
#endif
+#ifndef DISABLE_VTKVIEWER
+ if ( sec == QString( "VTKViewer" ) && param == QString( "dynamic_preselection" ) )
+ {
+ bool mode = resMgr->booleanValue( "VTKViewer", "dynamic_preselection", true );
+ QList<SUIT_ViewManager*> lst;
+#ifndef DISABLE_SALOMEOBJECT
+ viewManagers( SVTK_Viewer::Type(), lst );
+ QListIterator<SUIT_ViewManager*> it( lst );
+ while ( it.hasNext() )
+ {
+ SUIT_ViewModel* vm = it.next()->getViewModel();
+ if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
+ continue;
+
+ SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
+ if( vtkVM ) vtkVM->setDynamicPreSelection( mode );
+ }
+#endif
+ }
+#endif
+
#ifndef DISABLE_VTKVIEWER
if ( sec == QString( "VTKViewer" ) && param == QString( "show_static_trihedron" ) )
{
if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
}
+
+ if ( sec == "ExternalBrowser" && param == "use_external_browser" ) {
+ if ( resMgr->booleanValue("ExternalBrowser", "use_external_browser", false ) )
+ {
+ if(QtxWebBrowser::webBrowser())
+ QtxWebBrowser::webBrowser()->close();
+ }
+ }
+
+#ifndef DISABLE_PLOT2DVIEWER
+ if ( sec == "Plot2d" ) {
+ if( param == "SelectionColor" ) {
+ QColor c = resMgr->colorValue( sec, param );
+ Plot2d_Object::setSelectionColor(c);
+ }
+ else if (param == "SelectedLegendFontColor") {
+ QColor c = resMgr->colorValue( sec, param );
+ Plot2d_Object::setHighlightedLegendTextColor(c);
+ }
+ }
+#endif
}
/*!
*/
void LightApp_Application::contextMenuPopup( const QString& type, QMenu* thePopup, QString& title )
{
- //Add "Rename" item
+ //Add "Rename" item
LightApp_SelectionMgr* selMgr = LightApp_Application::selectionMgr();
bool cacheIsOn = selMgr->isSelectionCacheEnabled();
selMgr->setSelectionCacheEnabled( true );
if ( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) )
a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) );
}
-
+
if ( selMgr && ob ) {
SALOME_ListIO selected;
selMgr->selectedObjects( selected );
Handle(SALOME_InteractiveObject) anIObject = selected.First();
SUIT_DataObject* obj = findObject(anIObject->getEntry());
if(obj && obj->renameAllowed()) {
- QAction* a = new QAction(tr("MEN_RENAME_OBJ"), thePopup);
- connect( a, SIGNAL( triggered(bool) ), ob, SLOT( onStartEditing() ) );
- if ( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) )
- a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) );
-
- QList<QAction*> acts = thePopup->actions();
- QAction* firstAction = acts.count() > 0 ? acts.first() : 0;
- thePopup->insertAction(firstAction,a);
+ QAction* a = new QAction(tr("MEN_RENAME_OBJ"), thePopup);
+ connect( a, SIGNAL( triggered(bool) ), ob, SLOT( onStartEditing() ) );
+ if ( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) )
+ a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) );
+
+ QList<QAction*> acts = thePopup->actions();
+ QAction* firstAction = acts.count() > 0 ? acts.first() : 0;
+ thePopup->insertAction(firstAction,a);
}
}
}
if ( objectBrowser() )
objectBrowser()->updateTree();
-
+
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
if ( aResMgr && activeStudy() ) {
int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
resourceMgr()->setValue( "Style", "use_salome_style", Style_Salome::isActive() );
}
+void LightApp_Application::onFullScreen(){
+ if(myScreenHelper) {
+ if(desktop()->isFullScreen())
+ myScreenHelper->switchToNormalScreen();
+ else
+ myScreenHelper->switchToFullScreen();
+ }
+}
+
/*!
Connects just added view manager
*/
LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
if (aStudy )
aStudy->removeViewMgr(vm->getGlobalId());
-
+
STD_Application::removeViewManager( vm );
delete vm;
}
}
/*!
- Copy of current selection
+ Copy of current selection
*/
void LightApp_Application::onCopy()
{
// 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: LightApp_Application.h
// Created: 6/20/2005 18:39:25 PM
// Author: OCC team
-//
+
#ifndef LIGHTAPP_APPLICATION_H
#define LIGHTAPP_APPLICATION_H
class LightApp_WidgetContainer;
class LightApp_Preferences;
class LightApp_SelectionMgr;
+class LightApp_FullScreenHelper;
class LightApp_DataObject;
class SUIT_DataBrowser;
class SUIT_Study;
CloseId, CloseAllId, GroupAllId,
PreferencesId, MRUId, ModulesListId,
NewGLViewId, NewPlot2dId, NewOCCViewId, NewVTKViewId, NewQxGraphViewId,
- NewQxSceneViewId = NewQxGraphViewId, StyleId,
+ NewQxSceneViewId = NewQxGraphViewId, StyleId, FullScreenId,
UserID };
protected:
void onMRUActivated( const QString& );
void onStylePreferences();
+ void onFullScreen();
private slots:
void onSelection();
void onRefresh();
+ void onDropped( const QMimeData*, Qt::DropAction,
+ int, int, const QModelIndex& );
void onPreferences();
void onPreferenceChanged( QString&, QString&, QString& );
void onRenameWindow();
LightApp_Preferences* myPrefs;
LightApp_SelectionMgr* mySelMgr;
+ LightApp_FullScreenHelper* myScreenHelper;
+
WinMap myWin;
WinVis myWinVis;
WinGeom myWinGeom;
// 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 : LightApp_DataObject.cxx
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
-//
+
#include "LightApp_DataObject.h"
#include "LightApp_Study.h"
#include "LightApp_DataModel.h"
#include "LightApp_Application.h"
#include <CAM_Module.h>
-#include <SUIT_DataObjectKey.h>
+#include <SUIT_DataObjectKey.h>
#include <QVariant>
+#include <iostream>
+
/*!
\class LightApp_DataObject::Key
\brief Represents unique data object key for the LightApp_DataObject
*/
/*!
- \brief Constructor.
+ \brief Constructor.
\param parent parent data object
*/
LightApp_DataObject::LightApp_DataObject( SUIT_DataObject* parent )
-: CAM_DataObject( parent ),
- myCompObject( 0 ),
+: CAM_DataObject( parent ),
+ myCompObject( 0 ),
myCompDataType( "" )
{
}
*/
QVariant LightApp_DataObject::customData(Qtx::CustomDataType type) {
switch(type) {
- case Qtx::IdType:
+ case Qtx::IdType:
return EntryId;
break;
default:
return r && r->study() && componentDataType() != r->study()->getVisualComponentName();
}
+/*!
+ \brief Check if the object is dragable.
+
+ This method can be re-implemented in the subclasses.
+
+ \return \c true if it is possible to drag this object
+*/
+bool LightApp_DataObject::isDragable() const
+{
+ LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(module());
+ if (aModule) {
+ return aModule->isDragable(this);
+ }
+ return false;
+}
+
+/*!
+ \brief Check if the drop operation fo this object is possible.
+
+ This method can be re-implemented in the subclasses.
+
+ \param obj object being dropped
+ \return \c true if it is possible to drop an object \c obj
+ to this object
+*/
+bool LightApp_DataObject::isDropAccepted()
+{
+ LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(module());
+ if (aModule) {
+ return aModule->isDropAccepted(this);
+ }
+ return false;
+}
/*!
\brief Check if this object is can't be renamed in place
LightApp_RootObject* r = dynamic_cast<LightApp_RootObject*>( root() );
if(r && r->study())
app = dynamic_cast<LightApp_Application*>(r->study()->application());
-
+
return ( m && m->renameAllowed( entry() ) ) ||
( app && app->renameAllowed( entry() ) );
}
{
LightApp_Module* m = dynamic_cast<LightApp_Module*>( module() );
LightApp_RootObject* r = dynamic_cast<LightApp_RootObject*>( root() );
- LightApp_Application* app = (r && r->study()) ? dynamic_cast<LightApp_Application*>(r->study()->application()) : 0;
+ LightApp_Application* app =
+ (r && r->study()) ? dynamic_cast<LightApp_Application*>(r->study()->application()) : 0;
return ( m && m->renameObject( entry(), name ) ) ||
( app && app->renameObject( entry(), name ) );
}
else {
// both not integer ID
- int r = QString::localeAwareCompare( idsLeft[i], idsRight[i] );
+ int r = QString::localeAwareCompare( idsLeft[i], idsRight[i] );
if ( !calculated && r != 0 ) {
result = r < 0;
calculated = true;
}
}
// we should reach this if the entries are exactly equal
- return result;
+ return result;
}
return QString::localeAwareCompare( leftStr, rightStr ) < 0;
}
/*!
\brief Insert new child object to the children list at specified position.
-
+
Adds component in the study for this module object if it is not done yet.
-
+
\param obj object to be inserted
\param pos position at which data object should be inserted
*/
*/
LightApp_RootObject::LightApp_RootObject( LightApp_Study* study )
: CAM_DataObject( 0 ),
- LightApp_DataObject( 0 ),
- myStudy( study )
+ LightApp_DataObject( 0 ),
+ myStudy( study )
{
}
\param study pointer to the study
*/
void LightApp_RootObject::setStudy( LightApp_Study* study )
-{
- myStudy = study;
+{
+ myStudy = study;
}
/*
\return pointer to the study
*/
LightApp_Study* LightApp_RootObject::study() const
-{
- return myStudy;
-}
+{
+ return myStudy;
+}
// 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 : LightApp_DataObject.h
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
-//
+
#ifndef LIGHTAPP_DATAOBJECT_H
#define LIGHTAPP_DATAOBJECT_H
public:
//! Column id
- enum {
+ enum {
EntryId = VisibilityId + 1 //!< entry column
};
virtual QVariant customData(Qtx::CustomDataType type);
virtual bool isVisible() const;
+ virtual bool isDragable() const;
+ virtual bool isDropAccepted();
virtual bool renameAllowed( const int = NameId ) const;
virtual bool setName( const QString& );
LightApp_RootObject( LightApp_Study* );
virtual ~LightApp_RootObject();
-
+
void setStudy( LightApp_Study* );
LightApp_Study* study() const;
-
+
private:
LightApp_Study* myStudy;
};
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 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: LightApp_FullScreenHelper.h
+// Created: 04/10/2011 18:44:25 PM
+// Author: OCC team
+//
+#include <QAction>
+#include <QMenuBar>
+#include <QStatusBar>
+
+#include <PyConsole_Console.h>
+
+#include <STD_Application.h>
+
+#include <SUIT_Session.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_DataBrowser.h>
+
+#include "LightApp_FullScreenHelper.h"
+#include "LightApp_Application.h"
+
+
+/*!
+ * Constructor
+ */
+LightApp_FullScreenHelper::LightApp_FullScreenHelper()
+{
+ myStatusBarVisibility = false;
+}
+
+/*!
+ * Destructor
+ */
+LightApp_FullScreenHelper::~LightApp_FullScreenHelper()
+{
+
+}
+
+
+/*!
+ * Switch application to the full screen mode.
+ */
+void LightApp_FullScreenHelper::switchToFullScreen() {
+
+ SUIT_Session* session = SUIT_Session::session();
+ if(!session)
+ return;
+
+ LightApp_Application* app = dynamic_cast<LightApp_Application*>( session->activeApplication() );
+
+ if(!app)
+ return;
+
+ SUIT_Desktop* desktop = app->desktop();
+
+ if(!desktop)
+ return;
+
+ desktop->setWindowState(desktop->windowState() ^ Qt::WindowFullScreen);
+
+ if(desktop->menuBar())
+ desktop->menuBar()->hide();
+
+ if(desktop->statusBar()) {
+ myStatusBarVisibility = desktop->statusBar()->isVisible();
+ desktop->statusBar()->hide();
+ QAction *act = app->action(STD_Application::ViewStatusBarId);
+ if(act)
+ act->setEnabled(false);
+ }
+
+
+ QList<QDockWidget*> aDocWidgets = desktop->findChildren<QDockWidget*>();
+ myDocWidgetMap.clear();
+
+ QWidget* ob = app->objectBrowser();
+ QObject* obParent = ob ? ob->parent() : 0;
+
+ foreach(QDockWidget* aWidget, aDocWidgets) {
+ if(aWidget && aWidget->parent() == desktop) {
+ if( aWidget->isVisible() && aWidget != obParent ) {
+ aWidget->hide();
+ QAction* act = aWidget->toggleViewAction();
+ bool isActionEnabled = false;
+ if(act) {
+ isActionEnabled = act->isEnabled();
+ if( isActionEnabled ) {
+ act->setEnabled(false);
+ }
+ }
+
+ myDocWidgetMap.insert(aWidget, isActionEnabled);
+ }
+ }
+ }
+
+ QList<QToolBar*> aToolBars = desktop->findChildren<QToolBar*>();
+ myToolBarMap.clear();
+ foreach(QToolBar* aWidget, aToolBars ) {
+ if( aWidget && aWidget->parent() == desktop ) {
+ if( aWidget->isVisible()) {
+ aWidget->hide();
+ QAction* act = aWidget->toggleViewAction();
+ bool isActionEnabled = false;
+ if(act) {
+ isActionEnabled = act->isEnabled();
+ if( isActionEnabled ) {
+ act->setEnabled(false);
+ }
+ }
+ myToolBarMap.insert(aWidget, isActionEnabled);
+ }
+ }
+ }
+}
+
+/*!
+ * Switch application to the normal screen mode.
+ */
+void LightApp_FullScreenHelper::switchToNormalScreen() {
+
+ SUIT_Session* session = SUIT_Session::session();
+ if(!session)
+ return;
+
+ LightApp_Application* app = dynamic_cast<LightApp_Application*>( session->activeApplication() );
+
+ if(!app)
+ return;
+
+ SUIT_Desktop* desktop = app->desktop();
+
+ if(!desktop)
+ return;
+
+ desktop->setWindowState(desktop->windowState() ^ Qt::WindowFullScreen);
+
+
+ DocWidgetMap::iterator it = myDocWidgetMap.begin();
+ for( ;it != myDocWidgetMap.end() ; it++ ) {
+ QDockWidget* aWidget = it.key();
+ bool state = it.value();
+ aWidget->show();
+ QAction* act = aWidget->toggleViewAction();
+ if(act && state)
+ act->setEnabled(true);
+ }
+
+ ToolBarMap::iterator it1 = myToolBarMap.begin();
+ for( ;it1 != myToolBarMap.end() ; it1++ ) {
+ QToolBar* aWidget = it1.key();
+ bool state = it1.value();
+ aWidget->show();
+ QAction* act = aWidget->toggleViewAction();
+ if(act && state)
+ act->setEnabled(true);
+ }
+
+ if(desktop->menuBar())
+ desktop->menuBar()->show();
+
+ if(desktop->statusBar() && myStatusBarVisibility) {
+ desktop->statusBar()->show();
+ QAction *act = app->action(STD_Application::ViewStatusBarId);
+ if(act)
+ act->setEnabled(true);
+ }
+
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 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: LightApp_FullScreenHelper.h
+// Created: 04/10/2011 18:39:25 PM
+// Author: OCC team
+//
+#ifndef LIGHTAPP_FULLSCREEN_H
+#define LIGHTAPP_FULLSCREEN_H
+
+#include "LightApp.h"
+
+#include <QMap>
+#include <QDockWidget>
+#include <QToolBar>
+
+
+class LIGHTAPP_EXPORT LightApp_FullScreenHelper {
+ public:
+
+ LightApp_FullScreenHelper();
+ ~LightApp_FullScreenHelper();
+
+ void switchToFullScreen();
+ void switchToNormalScreen();
+
+ private:
+ typedef QMap<QDockWidget*,bool> DocWidgetMap;
+ DocWidgetMap myDocWidgetMap;
+
+ typedef QMap<QToolBar*, bool> ToolBarMap;
+ ToolBarMap myToolBarMap;
+
+
+ bool myStatusBarVisibility;
+
+};
+
+
+#endif //LIGHTAPP_FULLSCREEN_H
// 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: LightApp_Module.cxx
// Created: 6/20/2005 16:30:56 AM
// Author: OCC team
-//
+
#include "LightApp_Module.h"
#include "CAM_Application.h"
#include <QString>
#include <QStringList>
+#include <iostream>
/*!Constructor.*/
LightApp_Module::LightApp_Module( const QString& name )
if( theIsUpdateDataModel ){
if( CAM_DataModel* aDataModel = dataModel() ){
if ( LightApp_DataModel* aModel = dynamic_cast<LightApp_DataModel*>( aDataModel ) ) {
- SUIT_DataObject* aParent = NULL;
- if(theDataObject && theDataObject != aDataModel->root())
- aParent = theDataObject->parent();
+ //SUIT_DataObject* aParent = NULL;
+ //if(theDataObject && theDataObject != aDataModel->root())
+ // aParent = theDataObject->parent();
LightApp_DataObject* anObject = dynamic_cast<LightApp_DataObject*>(theDataObject);
LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(getApp()->activeStudy());
{
}
+/*!
+ virtual method
+ \return true if module allows dragging the given object
+*/
+bool LightApp_Module::isDragable(const SUIT_DataObject* /*what*/) const
+{
+ return false;
+}
+
+/*!
+ virtual method
+ \return true if module allows dropping one or more objects (currently selected) on the object \c where
+*/
+bool LightApp_Module::isDropAccepted(const SUIT_DataObject* /*where*/) const
+{
+ return false;
+}
+
+/*!
+ virtual method
+*/
+void LightApp_Module::dropObjects(const DataObjectList& what, Qt::DropAction action,
+ const SUIT_DataObject* parent, const int row)
+{
+}
+
/*!
\brief Return \c true if object can be renamed
*/
// 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: LightApp_Module.h
// Created: 6/20/2005 16:25:06 AM
// Author: OCC team
-//
+
#ifndef LIGHTAPP_MODULE_H
#define LIGHTAPP_MODULE_H
#include "LightApp_Preferences.h"
#include <CAM_Module.h>
+#include <SUIT_DataObject.h>
+
class LightApp_Application;
class LightApp_Selection;
class LightApp_Operation;
class LightApp_SelectionMgr;
class SUIT_Study;
-class SUIT_DataObject;
+//class SUIT_DataObject;
class SUIT_Operation;
class SUIT_ViewManager;
class CAM_Application;
virtual void update( const int );
// Update viewer or/and object browser etc. in accordance with update flags
- // ( see SalomeApp_UpdateFlags enumeration ). Derived modules can redefine this method
+ // (see SalomeApp_UpdateFlags enumeration). Derived modules can redefine this method
// for their own purposes
virtual void updateObjBrowser( bool = true, SUIT_DataObject* = 0 );
- // Update object bropwser ( for updating model or whole object browser use update() method
- // can be used )
+ // Update object browser (for updating model or whole object browser use update() method)
virtual void selectionChanged();
virtual void preferencesChanged( const QString&, const QString& );
virtual bool canCopy() const;
virtual bool canPaste() const;
+ virtual bool isDragable(const SUIT_DataObject* what) const;
+ virtual bool isDropAccepted(const SUIT_DataObject* where) const;
+ virtual void dropObjects(const DataObjectList& what, Qt::DropAction action,
+ const SUIT_DataObject* parent, const int row);
virtual void copy();
virtual void paste();
virtual bool renameAllowed( const QString& ) const;
virtual bool reusableOperation( const int id );
int addPreference( const QString& label );
- int addPreference( const QString& label, const int pId, const int = LightApp_Preferences::Auto,
+ int addPreference( const QString& label, const int pId,
+ const int type = LightApp_Preferences::Auto,
const QString& section = QString(),
const QString& param = QString() );
QVariant preferenceProperty( const int, const QString& ) const;
#include "LightApp_DataObject.h"
#include "LightApp_Application.h"
+#include <SPlot2d_ViewModel.h>
+
+#include <SALOME_ListIO.hxx>
+
/*!
Constructor
*/
LightApp_Plot2dSelector::LightApp_Plot2dSelector( Plot2d_Viewer* v, SUIT_SelectionMgr* mgr )
-: SUIT_Selector( mgr, v )
+ : SUIT_Selector( mgr, v ),
+ myViewer(v)
{
if ( v )
connect( v, SIGNAL( legendSelected( const QString& ) ), this, SLOT( onSelectionChanged( const QString& ) ) );
void LightApp_Plot2dSelector::getSelection( SUIT_DataOwnerPtrList& theList ) const
{
if( !myCurEntry.isNull() )
- theList.append( new LightApp_DataOwner( myCurEntry ) );
+ theList.append( new LightApp_DataOwner( new SALOME_InteractiveObject(qPrintable(myCurEntry),"","") ) );
}
/*!Sets selection.*/
void LightApp_Plot2dSelector::setSelection( const SUIT_DataOwnerPtrList& theList )
{
- /* if( theList.count()>0 )
- myCurEntry = theList.first()->getEntry();
- else*/
- myCurEntry = QString::null;
+ SALOME_ListIO anIOList;
+ for ( SUIT_DataOwnerPtrList::const_iterator it = theList.begin(); it != theList.end(); ++it ) {
+ const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*it).operator->() );
+ if ( owner ) {
+ if( !owner->IO().IsNull() ) {
+ anIOList.Append(owner->IO());
+ } else if ( !owner->entry().isEmpty() ) {
+ anIOList.Append( new SALOME_InteractiveObject(qPrintable(owner->entry()),"","") );
+ }
+ }
+ }
+ SPlot2d_Viewer* v = dynamic_cast<SPlot2d_Viewer*>(myViewer);
+
+ if(v)
+ v->setObjectsSelected(anIOList);
}
/*!On selection changed.*/
{
myCurEntry = entry;
selectionChanged();
+ myCurEntry = QString();
}
virtual void setSelection( const SUIT_DataOwnerPtrList& );
private:
- QString myCurEntry;
+ QString myCurEntry;
+ Plot2d_Viewer* myViewer;
};
#endif
vw = new SUIT_ViewWindow( d );
vw->setCentralWidget( myWidget );
myCreated = true;
- vw->setClosable( false );///////////////////
}
return vw;
}
LightApp_Preferences.h \
LightApp_PreferencesDlg.h \
LightApp_UpdateFlags.h \
- LightApp_WgViewModel.h
+ LightApp_WgViewModel.h \
+ LightApp_FullScreenHelper.h
if ENABLE_PYCONSOLE
salomeinclude_HEADERS += LightApp_PyInterp.h
LightApp_SwitchOp.cxx \
LightApp_Preferences.cxx \
LightApp_PreferencesDlg.cxx \
- LightApp_WgViewModel.cxx
+ LightApp_WgViewModel.cxx \
+ LightApp_FullScreenHelper.cxx
if ENABLE_PYCONSOLE
dist_libLightApp_la_SOURCES += LightApp_PyInterp.cxx
<parameter name="trihedron_size" value="100" />
<parameter name="navigation_mode" value="0" />
<parameter name="zooming_mode" value="0" />
+ <parameter name="show_static_trihedron" value="true"/>
+ <parameter name="relative_size" value="true"/>
</section>
<section name="VTKViewer" >
<!-- VTK viewer preferences -->
<parameter name="projection_mode" value="0"/>
<parameter name="trihedron_size" value="105"/>
<parameter name="relative_size" value="true"/>
- <parameter name="use_advanced_selection_algorithm" value="true"/>
+ <parameter name="dynamic_preselection" value="true"/>
<parameter name="navigation_mode" value="0"/>
<parameter name="zooming_mode" value="0"/>
<parameter name="speed_value" value="10"/>
<section name="Plot2d" >
<!-- Plot2d viewer preferences -->
<parameter name="Background" value="255, 255, 255" />
+ <parameter name="SelectionColor" value="80, 80, 80" />
<parameter name="CurveType" value="1" />
<parameter name="HorScaleMode" value="0" />
<parameter name="LegendPos" value="1" />
+ <parameter name="LegendFont" value="Helvetic,12" />
+ <parameter name="LegendFontColor" value="0, 0, 0" />
+ <parameter name="SelectedLegendFontColor" value="255, 255, 255" />
<parameter name="MarkerSize" value="9" />
<parameter name="ShowLegend" value="true" />
<parameter name="VerScaleMode" value="0" />
<section name="ExternalBrowser" >
<!-- External HELP browser settings -->
<parameter value="C:\Program Files\Internet Explorer\iexplore.exe" name="winapplication" />
+ <parameter value="false" name="use_external_browser" />
<parameter value="/usr/bin/mozilla" name="application" />
</section>
</document>
<source>APP_MODULE_ICO</source>
<translation>icon_module.png</translation>
</message>
+ <message>
+ <source>BROWSER_ICON</source>
+ <translation>icon_default.png</translation>
+ </message>
+ <message>
+ <source>BROWSER_CLOSE_ICON</source>
+ <translation>close.png</translation>
+ </message>
</context>
</TS>
<source>ENTRY_COLUMN</source>
<translation>Entry</translation>
</message>
+ <message>
+ <source>BROWSER_TITLE</source>
+ <translation>SALOME Help Browser</translation>
+ </message>
+ <message>
+ <source>BROWSER_TOOLBAR_TITLE</source>
+ <translation>Navigation</translation>
+ </message>
+ <message>
+ <source>BROWSER_FILEMENU</source>
+ <translation>&File</translation>
+ </message>
+ <message>
+ <source>BROWSER_CLOSE</source>
+ <translation>&Close</translation>
+ </message>
+ <message>
+ <source>BROWSER_BACK</source>
+ <translation>Go Back</translation>
+ </message>
+ <message>
+ <source>BROWSER_FORWARD</source>
+ <translation>Go Forward</translation>
+ </message>
+ <message>
+ <source>BROWSER_FIND</source>
+ <translation>&Find...</translation>
+ </message>
+ <message>
+ <source>BROWSER_FINDNEXT</source>
+ <translation>Find &next</translation>
+ </message>
+ <message>
+ <source>BROWSER_FINDPREV</source>
+ <translation>Find &previous</translation>
+ </message>
</context>
<context>
<name>LightApp_Application</name>
<source>PRP_THEME</source>
<translation>Change style properties</translation>
</message>
+ <message>
+ <source>TOT_FULLSCREEN</source>
+ <translation>Full screen</translation>
+ </message>
+ <message>
+ <source>MEN_DESK_FULLSCREEN</source>
+ <translation>Full screen</translation>
+ </message>
+ <message>
+ <source>PRP_FULLSCREEN</source>
+ <translation>Switch to full screen mode</translation>
+ </message>
<message>
<source>INF_TOOLBAR_MODULES</source>
<translation>Modules</translation>
</message>
<message>
<source>PREF_AUTO_SIZE_FIRST</source>
- <translation>Auto size for first column</translation>
+ <translation>Auto size for "Name" column</translation>
</message>
<message>
<source>PREF_RESIZE_ON_EXPAND_ITEM</source>
<source>PREF_VIEWER_BACKGROUND</source>
<translation>Background color</translation>
</message>
+ <message>
+ <source>PREF_VIEWER_SELECTION</source>
+ <translation>Selection color</translation>
+ </message>
<message>
<source>PREF_XYVIEWER_BACKGROUND</source>
<translation>XY View background color</translation>
<source>PREF_FONT</source>
<translation>Font</translation>
</message>
+ <message>
+ <source>PREF_LEGEND_FONT</source>
+ <translation>Legend font</translation>
+ </message>
+ <message>
+ <source>PREF_FONT_COLOR</source>
+ <translation>Legend font color</translation>
+ </message>
+ <message>
+ <source>PREF_SELECTED_FONT_COLOR</source>
+ <translation>Highlighted legend font color</translation>
+ </message>
<message>
<source>PREF_LEFT</source>
<translation>Left</translation>
<translation>Python Console</translation>
</message>
<message>
- <source>PREF_USE_ADVANCED_SELECTION_ALGORITHM</source>
- <translation>Use Advanced Selection Algorithm</translation>
+ <source>PREF_DYNAMIC_PRESELECTION</source>
+ <translation>Dynamic pre-selection</translation>
</message>
<message>
<source>TOT_CLOSE</source>
<source>ABOUT_CAPTION</source>
<translation>A propos de %1</translation>
</message>
+ <message>
+ <source>ABOUT_BASE</source>
+ <translation>Informations générales</translation>
+ </message>
+ <message>
+ <source>ABOUT_MODULE_INFOS</source>
+ <translation>Modules</translation>
+ </message>
+ <message>
+ <source>ABOUT_UNKNOWN_VERSION</source>
+ <translation>Inconnue</translation>
+ </message>
+ <message>
+ <source>ABOUT_CLOSE</source>
+ <translation>&Fermer</translation>
+ </message>
<message>
<source>APP_NAME</source>
<translation>SALOME</translation>
<source>ENTRY_COLUMN</source>
<translation>Entrée</translation>
</message>
+ <message>
+ <source>BROWSER_TITLE</source>
+ <translation>Aide de SALOME</translation>
+ </message>
+ <message>
+ <source>BROWSER_TOOLBAR_TITLE</source>
+ <translation>Navigation</translation>
+ </message>
+ <message>
+ <source>BROWSER_FILEMENU</source>
+ <translation>&Fichier</translation>
+ </message>
+ <message>
+ <source>BROWSER_CLOSE</source>
+ <translation>&Fermer</translation>
+ </message>
+ <message>
+ <source>BROWSER_BACK</source>
+ <translation>Reculer</translation>
+ </message>
+ <message>
+ <source>BROWSER_FORWARD</source>
+ <translation>Avancer</translation>
+ </message>
+ <message>
+ <source>BROWSER_FIND</source>
+ <translation>&Chercher...</translation>
+ </message>
+ <message>
+ <source>BROWSER_FINDNEXT</source>
+ <translation>Chercher &suivant</translation>
+ </message>
+ <message>
+ <source>BROWSER_FINDPREV</source>
+ <translation>Chercher &précédent</translation>
+ </message>
</context>
<context>
<name>LightApp_Application</name>
<source>PRP_THEME</source>
<translation>Changer les propriétés du style </translation>
</message>
+ <message>
+ <source>TOT_FULLSCREEN</source>
+ <translation>Plein écran</translation>
+ </message>
+ <message>
+ <source>MEN_DESK_FULLSCREEN</source>
+ <translation>Plein écran</translation>
+ </message>
+ <message>
+ <source>PRP_FULLSCREEN</source>
+ <translation>Basculer en mode plein écran</translation>
+ </message>
<message>
<source>INF_TOOLBAR_MODULES</source>
<translation>Modules</translation>
</message>
<message>
<source>PREF_AUTO_SIZE_FIRST</source>
- <translation>Taille automatique pour la première colonne</translation>
+ <translation>Taille automatique pour la colonne "Nom"</translation>
</message>
<message>
<source>PREF_RESIZE_ON_EXPAND_ITEM</source>
<translation>Console Python</translation>
</message>
<message>
- <source>PREF_USE_ADVANCED_SELECTION_ALGORITHM</source>
+ <source>PREF_DYNAMIC_PRESELECTION</source>
<translation>Utiliser l'algorithme de sélection avancée</translation>
</message>
<message>
resources/occ_view_style_switch.png \
resources/occ_view_zooming_style_switch.png \
resources/occ_view_maximized.png \
- resources/occ_view_minimized.png
+ resources/occ_view_minimized.png \
+ resources/occ_view_sync.png
nodist_salomeres_DATA = \
OCCViewer_images.qm \
{
// Get values from the OCC view
double aScaleFactor[3];
- myView->getViewPort()->getView()->AxialScale( aScaleFactor[0], aScaleFactor[1], aScaleFactor[2] );
+ myView->getViewPort()->getAxialScale( aScaleFactor[0], aScaleFactor[1], aScaleFactor[2] );
m_sbXcoeff->setValue( aScaleFactor[0] );
m_sbYcoeff->setValue( aScaleFactor[1] );
m_sbZcoeff->setValue( aScaleFactor[2] );
bool OCCViewer_AxialScaleDlg::apply()
{
double aScaleFactor[3] = { m_sbXcoeff->value(), m_sbYcoeff->value(), m_sbZcoeff->value() };
- myView->getViewPort()->getView()->SetAxialScale( aScaleFactor[0], aScaleFactor[1], aScaleFactor[2] );
+ myView->getViewPort()->setAxialScale( aScaleFactor[0], aScaleFactor[1], aScaleFactor[2] );
return true;
}
Constructor
*/
OCCViewer_ViewManager::OCCViewer_ViewManager( SUIT_Study* study, SUIT_Desktop* theDesktop, bool DisplayTrihedron )
-: SUIT_ViewManager( study, theDesktop, new OCCViewer_Viewer( DisplayTrihedron, false ) )
-{
+: SUIT_ViewManager( study, theDesktop, new OCCViewer_Viewer( DisplayTrihedron ) )
+{
setTitle( tr( "OCC_VIEW_TITLE" ) );
}
#include "SUIT_ViewManager.h"
#include "SUIT_Desktop.h"
#include "SUIT_Session.h"
+#include "SUIT_ResourceMgr.h"
#include "QtxActionToolMgr.h"
#include <Prs3d_AngleAspect.hxx>
#include <Prs3d_TextAspect.hxx>
-#include "utilities.h"
+#include <Visual3d_View.hxx>
/*!
Constructor
\param DisplayTrihedron - is trihedron displayed
*/
-OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron, bool DisplayStaticTrihedron )
+OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron)
: SUIT_ViewModel(),
- myShowStaticTrihedron( DisplayStaticTrihedron ),
- myColors(4, Qt::black)
+ myColors(4, Qt::black),
+ myIsRelative(true),
+ myTrihedronSize(100)
{
// init CasCade viewers
myV3dViewer = OCCViewer_VService::Viewer3d( "", (short*) "Viewer3d", "", 1000.,
// selection
mySelectionEnabled = true;
myMultiSelectionEnabled = true;
+
+
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+ if(resMgr)
+ myShowStaticTrihedron = resMgr->booleanValue( "OCCViewer", "show_static_trihedron", true );
}
/*!
Changes trihedron size
\param sz - new size
*/
-void OCCViewer_Viewer::setTrihedronSize( const double sz )
+void OCCViewer_Viewer::setTrihedronSize( const double sz, bool isRelative )
{
- if ( !myTrihedron.IsNull() )
- myTrihedron->SetSize( sz );
+ if ( myTrihedronSize != sz || isRelative != myIsRelative) {
+ myTrihedronSize = sz;
+ myIsRelative = isRelative;
+ updateTrihedron();
+ }
}
/*!
if ( theColor.isValid() && theViewId >= 0 && theViewId < myColors.count() )
myColors[theViewId] = theColor;
}
+
+
+/*!
+ Set the show static trihedron flag
+*/
+void OCCViewer_Viewer::setStaticTrihedronDisplayed(const bool on) {
+ if(myShowStaticTrihedron != on) {
+ OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
+ if(!aView)
+ return;
+
+ OCCViewer_ViewPort3d* vp3d = aView->getViewPort();
+ if(vp3d) {
+ myShowStaticTrihedron = on;
+ vp3d->updateStaticTriedronVisibility();
+ }
+ }
+}
+
+/*!
+ Get new and current trihedron size corresponding to the current model size
+*/
+bool OCCViewer_Viewer::computeTrihedronSize( double& theNewSize, double& theSize )
+{
+ theNewSize = 100;
+ theSize = 100;
+
+ //SRN: BUG IPAL8996, a usage of method ActiveView without an initialization
+ Handle(V3d_Viewer) viewer = getViewer3d();
+ viewer->InitActiveViews();
+ if(!viewer->MoreActiveViews()) return false;
+
+ Handle(V3d_View) view3d = viewer->ActiveView();
+ //SRN: END of fix
+
+ if ( view3d.IsNull() )
+ return false;
+
+ double Xmin = 0, Ymin = 0, Zmin = 0, Xmax = 0, Ymax = 0, Zmax = 0;
+ double aMaxSide;
+
+ view3d->View()->MinMaxValues( Xmin, Ymin, Zmin, Xmax, Ymax, Zmax );
+
+ if ( Xmin == RealFirst() || Ymin == RealFirst() || Zmin == RealFirst() ||
+ Xmax == RealLast() || Ymax == RealLast() || Zmax == RealLast() )
+ return false;
+
+ aMaxSide = Xmax - Xmin;
+ if ( aMaxSide < Ymax -Ymin ) aMaxSide = Ymax -Ymin;
+ if ( aMaxSide < Zmax -Zmin ) aMaxSide = Zmax -Zmin;
+
+ // IPAL21687
+ // The boundary box of the view may be initialized but nullified
+ // (case of infinite objects)
+ if ( aMaxSide < Precision::Confusion() )
+ return false;
+
+ float aSizeInPercents = SUIT_Session::session()->resourceMgr()->doubleValue("OCCViewer","trihedron_size", 100.);
+
+ static float EPS = 5.0E-3;
+ theSize = getTrihedron()->Size();
+ theNewSize = aMaxSide*aSizeInPercents / 100.0;
+
+ return fabs( theNewSize - theSize ) > theSize * EPS ||
+ fabs( theNewSize - theSize) > theNewSize * EPS;
+}
+
+/*!
+ * Update the size of the trihedron
+ */
+void OCCViewer_Viewer::updateTrihedron() {
+ if(myIsRelative){
+ double newSz, oldSz;
+
+ if(computeTrihedronSize(newSz, oldSz))
+ myTrihedron->SetSize(newSz);
+
+ } else if(myTrihedron->Size() != myTrihedronSize) {
+ myTrihedron->SetSize(myTrihedronSize);
+ }
+}
public:
static QString Type() { return "OCCViewer"; }
- OCCViewer_Viewer( bool DisplayTrihedron = true, bool DisplayStaticTrihedron = true );
+ OCCViewer_Viewer( bool DisplayTrihedron = true);
virtual ~OCCViewer_Viewer();
void update();
virtual void setTrihedronShown( const bool );
double trihedronSize() const;
- virtual void setTrihedronSize( const double );
+ virtual void setTrihedronSize( const double , bool isRelative = true);
+
+ bool trihedronRelative() const {return myIsRelative; }
+
+ // a utility function, used by SALOME_View_s methods
+ bool computeTrihedronSize( double& theNewSize, double& theSize );
+
+ void updateTrihedron();
+
virtual OCCViewer_ViewWindow* createSubWindow();
bool isMultiSelectionEnabled() const { return myMultiSelectionEnabled; }
int getSelectionCount() const { return (!myAISContext.IsNull())? myAISContext->NbSelected():0; }
+
bool isStaticTrihedronDisplayed() { return myShowStaticTrihedron; }
+ void setStaticTrihedronDisplayed(const bool on);
/* Selection management */
bool highlight( const Handle(AIS_InteractiveObject)&, bool, bool=true );
bool mySelectionEnabled;
bool myMultiSelectionEnabled;
+ bool myIsRelative;
//QColor myBgColor;
QPoint myStartPnt, myEndPnt;
bool myShowStaticTrihedron;
+ double myTrihedronSize;
+
QVector<QColor> myColors;
};
}
}*/
+/*!
+ Performs synchronization of view parameters with the specified view.
+ Returns \c true if synchronization is done successfully or \c false otherwise.
+ Default implementation does nothing (return \c false)
+*/
+bool OCCViewer_ViewPort::synchronize( OCCViewer_ViewPort* )
+{
+ return false;
+}
+
/*!
Sets the background color with color selection dialog. [ virtual protected slot ]
*/
// void onCreatePopup( QPopupMenu* );
// void onDestroyPopup( QPopupMenu* );
+public slots:
+ virtual bool synchronize( OCCViewer_ViewPort* );
+
protected slots:
virtual void onChangeBgColor();
void vpMouseEvent( QMouseEvent* );
void vpDrawExternal( QPainter* );
void vpChangeBGColor( QColor );
+ void vpTransformed( OCCViewer_ViewPort* );
private:
void initialize();
return true;
}
+
+
/*!
Sets new CASCADE view on viewport. Returns the previous active view. [ public ]
*/
myPerspView->SetZSize( zsize );*/
}
+/*!
+ Get axial scale to the view
+*/
+void OCCViewer_ViewPort3d::getAxialScale( double& xScale, double& yScale, double& zScale )
+{
+ xScale = yScale = zScale = 1.;
+
+ if ( !activeView().IsNull() )
+ activeView()->AxialScale( xScale, yScale, zScale );
+}
+
/*!
Returns the background color [ virtual public ]
*/
*/
void OCCViewer_ViewPort3d::fitRect( const QRect& rect )
{
- if ( !activeView().IsNull() )
+ if ( !activeView().IsNull() ) {
activeView()->WindowFit( rect.left(), rect.top(), rect.right(), rect.bottom() );
+ emit vpTransformed( this );
+ }
}
/*!
else
#endif
activeView()->Zoom( x0 + y0, 0, x + y, 0 );
+ emit vpTransformed( this );
}
}
*/
void OCCViewer_ViewPort3d::setCenter( int x, int y )
{
- if ( !activeView().IsNull() )
+ if ( !activeView().IsNull() ) {
activeView()->Place( x, y, myScale );
+ emit vpTransformed( this );
+ }
}
/*!
*/
void OCCViewer_ViewPort3d::pan( int dx, int dy )
{
- if ( !activeView().IsNull() )
+ if ( !activeView().IsNull() ) {
activeView()->Pan( dx, dy, 1.0 );
+ emit vpTransformed( this );
+ }
}
/*!
default:
break;
}
+ emit vpTransformed( this );
}
// setZSize( getZSize() );
}
activeView()->ZFitAll(1.);
activeView()->SetZSize(0.);
activeView()->Update();
+ emit vpTransformed( this );
}
}
Standard_Real margin = 0.01;
activeView()->FitAll( margin, withZ, upd );
activeView()->SetZSize(0.);
+ emit vpTransformed( this );
}
/*!
void OCCViewer_ViewPort3d::reset()
{
// double zsize = getZSize();
- if ( !activeView().IsNull() )
+ if ( !activeView().IsNull() ) {
activeView()->Reset();
+ emit vpTransformed( this );
// setZSize( zsize );
+ }
}
/*!
double X, Y, Z;
activeView()->Convert( x, y, X, Y, Z );
activeView()->Rotate( 0, 0, degrees * Standard_PI180, X, Y, Z );
+ emit vpTransformed( this );
}
+/*!
+ Set axial scale to the view
+*/
+void OCCViewer_ViewPort3d::setAxialScale( double xScale, double yScale, double zScale )
+{
+ if ( activeView().IsNull() )
+ return;
+
+ activeView()->SetAxialScale( xScale, yScale, zScale );
+ emit vpTransformed( this );
+}
+
/*!
Passed the handle of native window of the component to CASCADE view. [ private ]
*/
{
return ( !view.IsNull() && view->View()->IsDefined() );
}
+
+/*!
+ Performs synchronization of view parameters with the specified view.
+ Returns \c true if synchronization is done successfully or \c false otherwise.
+ Default implementation does nothing (return \c false)
+*/
+bool OCCViewer_ViewPort3d::synchronize( OCCViewer_ViewPort* view )
+{
+ bool ok = false;
+ OCCViewer_ViewPort3d* vp3d = qobject_cast<OCCViewer_ViewPort3d*>( view );
+ if ( vp3d ) {
+ bool blocked = blockSignals( false );
+ Handle(V3d_View) aView3d = getView();
+ Handle(V3d_View) aRefView3d = vp3d->getView();
+ aView3d->SetImmediateUpdate( Standard_False );
+ aView3d->SetViewMapping( aRefView3d->ViewMapping() );
+ aView3d->SetViewOrientation( aRefView3d->ViewOrientation() );
+ aView3d->ZFitAll();
+ aView3d->SetImmediateUpdate( Standard_True );
+ aView3d->Update();
+ blockSignals( blocked );
+ ok = true;
+ }
+ return ok;
+}
+
+/*
+ * Show/Hide static triedron
+ */
+void OCCViewer_ViewPort3d::updateStaticTriedronVisibility() {
+ OCCViewer_ViewWindow* aVW = dynamic_cast<OCCViewer_ViewWindow*>( parentWidget()->parentWidget()->parentWidget() );
+ if ( aVW ) {
+ OCCViewer_Viewer* aViewModel = dynamic_cast<OCCViewer_Viewer*>( aVW->getViewManager()->getViewModel() );
+ Handle(V3d_View) aView = activeView();
+ if ( aViewModel ){
+ if(aViewModel->isStaticTrihedronDisplayed()) {
+ aView->TriedronDisplay( Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.05, V3d_ZBUFFER );
+ } else {
+ aView->TriedronErase();
+ }
+ aView->Update();
+ }
+ }
+}
virtual ~OCCViewer_ViewPort3d();
public:
- Handle(V3d_View) getView() const;
- Handle(V3d_View) setView( const Handle(V3d_View)& );
- Handle(V3d_Viewer) getViewer() const;
+ Handle(V3d_View) getView() const;
+ Handle(V3d_View) setView( const Handle(V3d_View)& );
+ Handle(V3d_Viewer) getViewer() const;
- void setAnimationMode(bool theDegenerated);
+ void setAnimationMode(bool theDegenerated);
virtual void setBackgroundColor( const QColor& color);
virtual QColor backgroundColor() const;
virtual int getBgImgHeight(){return myBgImgHeight; };
virtual int getBgImgWidth() {return myBgImgWidth; };
+ virtual void updateStaticTriedronVisibility();
+
// void setActive( V3d_TypeOfView );
- virtual bool syncronize( const OCCViewer_ViewPort3d* );
+ virtual bool syncronize( const OCCViewer_ViewPort3d* );
+
+ double getZSize() const;
+ void setZSize( double );
- double getZSize() const;
- void setZSize( double );
+ void getAxialScale( double&, double&, double& );
- virtual void onUpdate();
+ virtual void onUpdate();
// TRANSFORMATIONS
virtual void reset();
virtual void zoom( int, int, int, int );
virtual void fitAll( bool keepScale = false, bool withZ = true, bool upd = true );
virtual void rotateXY( double );
+ virtual void setAxialScale( double, double, double );
virtual void startRotation( int, int, int, const gp_Pnt& );
virtual void rotate( int, int, int, const gp_Pnt& );
void setAdvancedZoomingEnabled( const bool theState ) { myIsAdvancedZoomingEnabled = theState; }
bool isAdvancedZoomingEnabled() const { return myIsAdvancedZoomingEnabled; }
+public slots:
+ virtual bool synchronize( OCCViewer_ViewPort* );
+
protected:
// EVENTS
virtual void paintEvent( QPaintEvent* );
virtual void attachWindow( const Handle(V3d_View)&, const Handle(Aspect_Window)& );
private:
- Handle(V3d_View) activeView() const;
- Handle(V3d_View) inactiveView() const;
- bool mapView( const Handle(V3d_View)& );
- bool setWindow( const Handle(V3d_View)& );
- bool mapped( const Handle(V3d_View)& ) const;
+ Handle(V3d_View) activeView() const;
+ Handle(V3d_View) inactiveView() const;
+ bool mapView( const Handle(V3d_View)& );
+ bool setWindow( const Handle(V3d_View)& );
+ bool mapped( const Handle(V3d_View)& ) const;
private:
Handle(V3d_View) myOrthoView;
#include <SUIT_Tools.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_MessageBox.h>
+#include <SUIT_Application.h>
#include <QtxActionToolMgr.h>
#include <QtxMultiAction.h>
#include <QKeyEvent>
#include <QMouseEvent>
#include <QApplication>
+#include <QMenu>
#include <AIS_ListOfInteractive.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
myCubeAxesDlg->initialize();
}
+OCCViewer_ViewWindow* OCCViewer_ViewWindow::getView( const int mode ) const
+{
+ return mode == get2dMode() ? const_cast<OCCViewer_ViewWindow*>( this ) : 0;
+}
+
/*!
\brief Detect viewer operation according the the mouse button pressed
and key modifiers used.
aAction->setStatusTip(tr("DSC_MINIMIZE_VIEW"));
connect(aAction, SIGNAL(triggered()), this, SLOT(onMaximizedView()));
toolMgr()->registerAction( aAction, MaximizedId );
+
+ // Synchronize view
+ aAction = new QtxAction(tr("MNU_SYNCHRONIZE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SYNC" ) ),
+ tr( "MNU_SYNCHRONIZE_VIEW" ), 0, this );
+ aAction->setStatusTip(tr("DSC_SYNCHRONIZE_VIEW"));
+ aAction->setMenu( new QMenu( this ) );
+ aAction->setCheckable(true);
+ connect(aAction->menu(), SIGNAL(aboutToShow()), this, SLOT(updateSyncViews()));
+ connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onSynchronizeView(bool)));
+ toolMgr()->registerAction( aAction, SynchronizeId );
}
/*!
#endif
toolMgr()->append( AmbientId, tid );
- toolMgr()->append( MaximizedId, tid);
+ toolMgr()->append( MaximizedId, tid );
+ toolMgr()->append( SynchronizeId, tid );
}
/*!
\brief Restore view parameters.
\param anItem view parameters
*/
-void OCCViewer_ViewWindow::performRestoring( const viewAspect& anItem )
+void OCCViewer_ViewWindow::performRestoring( const viewAspect& anItem, bool baseParamsOnly )
{
Handle(V3d_View) aView3d = myViewPort->getView();
aView3d->SetEye( anItem.eyeX, anItem.eyeY, anItem.eyeZ );
aView3d->SetProj( anItem.projX, anItem.projY, anItem.projZ );
aView3d->SetAxialScale( anItem.scaleX, anItem.scaleY, anItem.scaleZ );
- myModel->setTrihedronShown( anItem.isVisible );
- myModel->setTrihedronSize( anItem.size );
+
+ if ( !baseParamsOnly ) {
+
+ myModel->setTrihedronShown( anItem.isVisible );
+ myModel->setTrihedronSize( anItem.size );
#if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 and higher version
- // graduated trihedron
- bool anIsVisible = anItem.gtIsVisible;
- OCCViewer_AxisWidget::AxisData anAxisData[3];
- anAxisData[0].DrawName = anItem.gtDrawNameX;
- anAxisData[1].DrawName = anItem.gtDrawNameZ;
- anAxisData[2].DrawName = anItem.gtDrawNameZ;
- anAxisData[0].Name = anItem.gtNameX;
- anAxisData[1].Name = anItem.gtNameZ;
- anAxisData[2].Name = anItem.gtNameZ;
- anAxisData[0].NameColor = QColor( anItem.gtNameColorRX,
- anItem.gtNameColorGX,
- anItem.gtNameColorBX );
- anAxisData[1].NameColor = QColor( anItem.gtNameColorRY,
- anItem.gtNameColorGY,
- anItem.gtNameColorBY );
- anAxisData[2].NameColor = QColor( anItem.gtNameColorRZ,
- anItem.gtNameColorGZ,
- anItem.gtNameColorBZ );
- anAxisData[0].DrawValues = anItem.gtDrawValuesX;
- anAxisData[1].DrawValues = anItem.gtDrawValuesY;
- anAxisData[2].DrawValues = anItem.gtDrawValuesZ;
- anAxisData[0].NbValues = anItem.gtNbValuesX;
- anAxisData[1].NbValues = anItem.gtNbValuesY;
- anAxisData[2].NbValues = anItem.gtNbValuesZ;
- anAxisData[0].Offset = anItem.gtOffsetX;
- anAxisData[1].Offset = anItem.gtOffsetY;
- anAxisData[2].Offset = anItem.gtOffsetZ;
- anAxisData[0].Color = QColor( anItem.gtColorRX,
- anItem.gtColorGX,
- anItem.gtColorBX );
- anAxisData[1].Color = QColor( anItem.gtColorRY,
- anItem.gtColorGY,
- anItem.gtColorBY );
- anAxisData[2].Color = QColor( anItem.gtColorRZ,
- anItem.gtColorGZ,
- anItem.gtColorBZ );
- anAxisData[0].DrawTickmarks = anItem.gtDrawTickmarksX;
- anAxisData[1].DrawTickmarks = anItem.gtDrawTickmarksY;
- anAxisData[2].DrawTickmarks = anItem.gtDrawTickmarksZ;
- anAxisData[0].TickmarkLength = anItem.gtTickmarkLengthX;
- anAxisData[1].TickmarkLength = anItem.gtTickmarkLengthY;
- anAxisData[2].TickmarkLength = anItem.gtTickmarkLengthZ;
-
- myCubeAxesDlg->SetData( anIsVisible, anAxisData );
- myCubeAxesDlg->ApplyData( aView3d );
+ // graduated trihedron
+ bool anIsVisible = anItem.gtIsVisible;
+ OCCViewer_AxisWidget::AxisData anAxisData[3];
+ anAxisData[0].DrawName = anItem.gtDrawNameX;
+ anAxisData[1].DrawName = anItem.gtDrawNameZ;
+ anAxisData[2].DrawName = anItem.gtDrawNameZ;
+ anAxisData[0].Name = anItem.gtNameX;
+ anAxisData[1].Name = anItem.gtNameZ;
+ anAxisData[2].Name = anItem.gtNameZ;
+ anAxisData[0].NameColor = QColor( anItem.gtNameColorRX,
+ anItem.gtNameColorGX,
+ anItem.gtNameColorBX );
+ anAxisData[1].NameColor = QColor( anItem.gtNameColorRY,
+ anItem.gtNameColorGY,
+ anItem.gtNameColorBY );
+ anAxisData[2].NameColor = QColor( anItem.gtNameColorRZ,
+ anItem.gtNameColorGZ,
+ anItem.gtNameColorBZ );
+ anAxisData[0].DrawValues = anItem.gtDrawValuesX;
+ anAxisData[1].DrawValues = anItem.gtDrawValuesY;
+ anAxisData[2].DrawValues = anItem.gtDrawValuesZ;
+ anAxisData[0].NbValues = anItem.gtNbValuesX;
+ anAxisData[1].NbValues = anItem.gtNbValuesY;
+ anAxisData[2].NbValues = anItem.gtNbValuesZ;
+ anAxisData[0].Offset = anItem.gtOffsetX;
+ anAxisData[1].Offset = anItem.gtOffsetY;
+ anAxisData[2].Offset = anItem.gtOffsetZ;
+ anAxisData[0].Color = QColor( anItem.gtColorRX,
+ anItem.gtColorGX,
+ anItem.gtColorBX );
+ anAxisData[1].Color = QColor( anItem.gtColorRY,
+ anItem.gtColorGY,
+ anItem.gtColorBY );
+ anAxisData[2].Color = QColor( anItem.gtColorRZ,
+ anItem.gtColorGZ,
+ anItem.gtColorBZ );
+ anAxisData[0].DrawTickmarks = anItem.gtDrawTickmarksX;
+ anAxisData[1].DrawTickmarks = anItem.gtDrawTickmarksY;
+ anAxisData[2].DrawTickmarks = anItem.gtDrawTickmarksZ;
+ anAxisData[0].TickmarkLength = anItem.gtTickmarkLengthX;
+ anAxisData[1].TickmarkLength = anItem.gtTickmarkLengthY;
+ anAxisData[2].TickmarkLength = anItem.gtTickmarkLengthZ;
+
+ myCubeAxesDlg->SetData( anIsVisible, anAxisData );
+ myCubeAxesDlg->ApplyData( aView3d );
#endif
+ } // if ( !baseParamsOnly )
+
myRestoreFlag = 0;
}
{
myViewAspects = aViewList;
}
+
+void OCCViewer_ViewWindow::synchronizeView( OCCViewer_ViewWindow* viewWindow, int id )
+{
+ OCCViewer_ViewWindow* otherViewWindow = 0;
+ QList<OCCViewer_ViewWindow*> compatibleViews;
+
+ bool isSync = viewWindow->toolMgr()->action( SynchronizeId )->isChecked();
+
+ int vwid = viewWindow->getId();
+
+ SUIT_Application* app = SUIT_Session::session()->activeApplication();
+ if ( !app ) return;
+
+ QList<SUIT_ViewManager*> wmlist;
+ app->viewManagers( viewWindow->getViewManager()->getType(), wmlist );
+
+ foreach( SUIT_ViewManager* wm, wmlist ) {
+ QVector<SUIT_ViewWindow*> vwlist = wm->getViews();
+
+ foreach( SUIT_ViewWindow* vw, vwlist ) {
+ OCCViewer_ViewWindow* occVW = dynamic_cast<OCCViewer_ViewWindow*>( vw );
+ if ( !occVW ) continue;
+
+ // check only compatible types
+ occVW = occVW->getView( viewWindow->get2dMode() );
+ if ( occVW ) {
+ if ( occVW->getId() == id )
+ otherViewWindow = occVW;
+ else if ( occVW != viewWindow )
+ compatibleViews.append( occVW );
+ }
+ }
+ }
+
+ if ( isSync && id ) {
+ // remove all possible disconnections
+ foreach( OCCViewer_ViewWindow* vw, compatibleViews ) {
+ // disconnect target view
+ vw->getViewPort()->disconnect( SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), viewWindow->getViewPort(), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
+ viewWindow->getViewPort()->disconnect( SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), vw->getViewPort(), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
+ if ( otherViewWindow ) {
+ // disconnect source view
+ vw->getViewPort()->disconnect( SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), otherViewWindow->getViewPort(), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
+ otherViewWindow->getViewPort()->disconnect( SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), vw->getViewPort(), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
+ }
+ QAction* a = vw->toolMgr()->action( SynchronizeId );
+ if ( a ) {
+ int anid = a->data().toInt();
+ if ( a->isChecked() && ( anid == id || anid == vwid ) ) {
+ bool blocked = a->blockSignals( true );
+ a->setChecked( false );
+ a->blockSignals( blocked );
+ }
+ }
+ }
+ if ( otherViewWindow ) {
+ // reconnect source and target view
+ otherViewWindow->getViewPort()->disconnect( SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), viewWindow->getViewPort(), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
+ viewWindow->getViewPort()->disconnect( SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), otherViewWindow->getViewPort(), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
+ otherViewWindow->getViewPort()->connect( viewWindow->getViewPort(), SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
+ viewWindow->getViewPort()->connect( otherViewWindow->getViewPort(), SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
+ // synchronize target view with source view
+ viewWindow->getViewPort()->synchronize( otherViewWindow->getViewPort() );
+ viewWindow->toolMgr()->action( SynchronizeId )->setData( otherViewWindow->getId() );
+ otherViewWindow->toolMgr()->action( SynchronizeId )->setData( viewWindow->getId() );
+ if ( !otherViewWindow->toolMgr()->action( SynchronizeId )->isChecked() ) {
+ bool blocked = otherViewWindow->toolMgr()->action( SynchronizeId )->blockSignals( true );
+ otherViewWindow->toolMgr()->action( SynchronizeId )->setChecked( true );
+ otherViewWindow->toolMgr()->action( SynchronizeId )->blockSignals( blocked );
+ }
+ }
+ }
+ else if ( otherViewWindow ) {
+ // reconnect source and target view
+ otherViewWindow->getViewPort()->disconnect( SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), viewWindow->getViewPort(), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
+ viewWindow->getViewPort()->disconnect( SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), otherViewWindow->getViewPort(), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
+ viewWindow->getViewPort()->synchronize( otherViewWindow->getViewPort() );
+ viewWindow->toolMgr()->action( SynchronizeId )->setData( otherViewWindow->getId() );
+ if ( otherViewWindow->toolMgr()->action( SynchronizeId )->data().toInt() == viewWindow->getId() && otherViewWindow->toolMgr()->action( SynchronizeId )->isChecked() ) {
+ bool blocked = otherViewWindow->toolMgr()->action( SynchronizeId )->blockSignals( true );
+ otherViewWindow->toolMgr()->action( SynchronizeId )->setChecked( false );
+ otherViewWindow->toolMgr()->action( SynchronizeId )->blockSignals( blocked );
+ }
+ }
+}
+
+/*!
+ "Synchronize View" action slot.
+*/
+void OCCViewer_ViewWindow::onSynchronizeView(bool checked)
+{
+ QAction* a = qobject_cast<QAction*>( sender() );
+ if ( a ) {
+ synchronizeView( this, a->data().toInt() );
+ }
+}
+
+/*!
+ Update list of available view for the "Synchronize View" action
+*/
+void OCCViewer_ViewWindow::updateSyncViews()
+{
+ QAction* anAction = toolMgr()->action( SynchronizeId );
+ if ( anAction && anAction->menu() ) {
+ int currentId = anAction->data().toInt();
+ anAction->menu()->clear();
+ SUIT_Application* app = SUIT_Session::session()->activeApplication();
+ if ( app ) {
+ QList<SUIT_ViewManager*> wmlist;
+ app->viewManagers( getViewManager()->getType(), wmlist );
+ foreach( SUIT_ViewManager* wm, wmlist ) {
+ QVector<SUIT_ViewWindow*> vwlist = wm->getViews();
+ foreach ( SUIT_ViewWindow* vw, vwlist ) {
+ OCCViewer_ViewWindow* occVW = dynamic_cast<OCCViewer_ViewWindow*>( vw );
+ if ( !occVW || occVW == this ) continue;
+ // list only compatible types
+ OCCViewer_ViewWindow* subWindow = occVW->getView( get2dMode() );
+ if ( subWindow && subWindow != this ) {
+ QAction* a = anAction->menu()->addAction( occVW->windowTitle() );
+ if ( subWindow->getId() == currentId ) {
+ QFont f = a->font();
+ f.setBold( true );
+ a->setFont( f );
+ }
+ a->setData( subWindow->getId() );
+ connect( a, SIGNAL( triggered(bool) ), this, SLOT( onSynchronizeView(bool) ) );
+ }
+ }
+ }
+ }
+ if ( anAction->menu()->actions().isEmpty() ) {
+ anAction->setData( 0 );
+ anAction->menu()->addAction( tr( "MNU_SYNC_NO_VIEW" ) );
+ }
+ }
+}
FrontId, BackId, TopId, BottomId, LeftId, RightId, ClockWiseId, AntiClockWiseId,
ResetId, CloneId, ClippingId, MemId, RestoreId,
TrihedronShowId, AxialScaleId, GraduatedAxesId, AmbientId,
- SwitchInteractionStyleId, SwitchZoomingStyleId, MaximizedId, UserId };
+ SwitchInteractionStyleId, SwitchZoomingStyleId, MaximizedId, SynchronizeId, UserId };
enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE,
PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW,
OCCViewer_ViewWindow(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel);
virtual ~OCCViewer_ViewWindow();
+ virtual OCCViewer_ViewWindow* getView( const int ) const;
+
virtual OCCViewer_ViewPort3d* getViewPort();
virtual bool eventFilter(QObject* watched, QEvent* e);
- virtual void performRestoring( const viewAspect& );
+ virtual void performRestoring( const viewAspect&, bool = false );
virtual void initLayout();
virtual QString backgroundImageFilename() const;
virtual void setBackgroundImage( const QString& ,const Aspect_FillMethod& theFillMethod);
- virtual const viewAspectList& getViewAspects();
+ virtual const viewAspectList& getViewAspects();
virtual void appendViewAspect( const viewAspect& );
virtual void updateViewAspects( const viewAspectList& );
virtual void clearViewAspects();
double myCurScale;
+private slots:
+ void onSynchronizeView(bool);
+ void updateSyncViews();
+
+private:
+ static void synchronizeView( OCCViewer_ViewWindow*, int );
+
private:
OCCViewer_ClippingDlg* myClippingDlg;
QtxAction* myClippingAction;
<source>ICON_OCCVIEWER_MINIMIZE</source>
<translation>occ_view_minimized.png</translation>
</message>
+ <message>
+ <source>ICON_OCCVIEWER_SYNC</source>
+ <translation>occ_view_sync.png</translation>
+ </message>
</context>
</TS>
</message>
<message>
<source>OCC_IMAGE_FILES</source>
- <translation>Images Files (*.bmp *.png *.jpg *.jpeg)</translation>
+ <translation>Images Files (*.bmp *.png *.jpg *.jpeg *.eps *.ps)</translation>
</message>
<message>
<source>OCC_BG_IMAGE_FILES</source>
<source>DSC_MINIMIZE_VIEW</source>
<translation>Minimize view</translation>
</message>
+ <message>
+ <source>DSC_SYNCHRONIZE_VIEW</source>
+ <translation>Synchronize view</translation>
+ </message>
<message>
<source>MNU_MAXIMIZE_VIEW</source>
<translation>Maximize</translation>
<source>MNU_MINIMIZE_VIEW</source>
<translation>Minimize</translation>
</message>
+ <message>
+ <source>MNU_SYNCHRONIZE_VIEW</source>
+ <translation>Synchronize</translation>
+ </message>
+ <message>
+ <source>MNU_SYNC_NO_VIEW</source>
+ <translation>[ No appropriate view ]</translation>
+ </message>
</context>
<context>
<name>OCCViewer_CreateRestoreViewDlg</name>
</message>
<message>
<source>OCC_IMAGE_FILES</source>
- <translation>Fichiers images (*.bmp *.png *.jpg *.jpeg)</translation>
+ <translation>Fichiers images (*.bmp *.png *.jpg *.jpeg *.eps *.ps)</translation>
</message>
<message>
<source>DSC_MAXIMIZE_VIEW</source>
// 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 : OB_Browser.cxx
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
-//
+
#include "OB_Browser.h"
//#include "OB_Filter.h"
myView->setSelectionMode( QAbstractItemView::ExtendedSelection );
myView->setAllColumnsShowFocus( true );
+ // Mantis issue 0020136: Drag&Drop in OB
+ myView->setDragEnabled(TRUE);
+ myView->setAcceptDrops(TRUE);
+ myView->setDropIndicatorShown(TRUE);
+ myView->setDragDropMode(QAbstractItemView::DragDrop);
+ //myView->setDragDropMode(QAbstractItemView::InternalMove);
+
mySearchTool = new QtxSearchTool( this, myView );
mySearchTool->setFrameStyle( QFrame::NoFrame | QFrame::Plain );
mySearchTool->setActivators( QtxSearchTool::StandardKey | QtxSearchTool::SlashKey );
connect( myView, SIGNAL( selectionChanged() ),
this, SIGNAL( selectionChanged() ) );
-
}
/*!
// 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 : OB_Browser.h
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
-//
+
#ifndef OB_BROWSER_H
#define OB_BROWSER_H
QtxSearchTool* searchTool() const;
bool isSearchToolEnabled() const;
void setSearchToolEnabled( const bool );
-
+
int autoOpenLevel() const;
void setAutoOpenLevel( const int );
void openLevels( const int = -1 );
unsigned long getModifiedTime() const;
void setModified();
-
+
// san - moved to SUIT_TreeModel
//OB_Updater* getUpdater() const;
//virtual void setUpdater( OB_Updater* theUpdate = 0 );
private slots:
void onExpandAll();
void onCollapseAll();
- //void onDestroyed( SUIT_DataObject* );
- //void onDoubleClicked ( QListViewItem* );
- //void onDropped( QPtrList<QListViewItem>, QListViewItem*, int );
-
+ //void onDestroyed( SUIT_DataObject* );
+ //void onDoubleClicked ( QListViewItem* );
+ //void onDropped( QPtrList<QListViewItem>, QListViewItem*, int );
+
protected:
//void adjustWidth( QListViewItem* );
//virtual void updateText();
Plot2d_ViewModel.h \
Plot2d_ViewWindow.h \
Plot2d_SetupCurveDlg.h \
+ Plot2d_SetupCurveScaleDlg.h \
Plot2d_ToolTip.h
dist_libPlot2d_la_SOURCES = \
Plot2d_ViewModel.cxx \
Plot2d_ViewWindow.cxx \
Plot2d_SetupCurveDlg.cxx \
+ Plot2d_SetupCurveScaleDlg.cxx \
Plot2d_ToolTip.cxx
MOC_FILES = \
Plot2d_ViewModel_moc.cxx \
Plot2d_ViewWindow_moc.cxx \
Plot2d_SetupCurveDlg_moc.cxx \
+ Plot2d_SetupCurveScaleDlg_moc.cxx \
Plot2d_ToolTip_moc.cxx
nodist_libPlot2d_la_SOURCES = $(MOC_FILES)
if ( theItem->rtti() != rtti() )
return;
- QwtPlotCurve* aCurve = dynamic_cast<QwtPlotCurve*>( theItem );
+ Plot2d_QwtPlotCurve* aCurve = dynamic_cast<Plot2d_QwtPlotCurve*>( theItem );
if ( !aCurve )
return;
Qt::PenStyle ps = Plot2d::plot2qwtLine( getLine() );
QwtSymbol::Style ms = Plot2d::plot2qwtMarker( getMarker() );
+
+ QColor aColor = isSelected() ? Plot2d_Object::selectionColor() : getColor();
+ int lineW = getLineWidth();
+ if ( isSelected() ) lineW += (lineW == 0 ? 3 : 2);
- aCurve->setPen( QPen( getColor(), getLineWidth(), ps ) );
- aCurve->setSymbol( QwtSymbol( ms, QBrush( getColor() ),
- QPen( getColor() ),
- QSize( getMarkerSize(), getMarkerSize() ) ) );
+ int markerS = isSelected() ? getMarkerSize() + 2 : getMarkerSize();
+
+ aCurve->setSelected(isSelected());
+
+ aCurve->setPen( QPen(aColor , lineW, ps ) );
+ aCurve->setSymbol( QwtSymbol( ms, QBrush( aColor ),
+ QPen( aColor ),
+ QSize( markerS , markerS ) ) );
+
+ aCurve->setLegendPen(QPen(getColor(), getLineWidth(), ps ));
+ aCurve->setLegendSymbol( QwtSymbol( ms, QBrush( getColor() ),
+ QPen( getColor() ),
+ QSize( getMarkerSize() , getMarkerSize() )));
+
double *x, *y;
long nb = getData( &x, &y );
aCurve->setData( x, y, nb );
Plot2d_Object::updatePlotItem( theItem );
anItem->setData( getData() );
- anItem->setColor( getColor() );
+ anItem->setLegendPen(getColor());
+ anItem->setSelected(isSelected());
+ anItem->setColor( isSelected() ? Plot2d_Object::selectionColor() : getColor() );
}
/*!
#include "Plot2d_Object.h"
+
+#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
+
// color tolerance (used to compare color values)
const long COLOR_DISTANCE = 100;
+
+// Static members
+QColor Plot2d_Object::mySelectionColor;
+QColor Plot2d_Object::myHighlightedLegendTextColor;
+
+/*
+ * Read colors from the resource manager.
+*/
+void Plot2d_Object::initColors() {
+ SUIT_Session* session = SUIT_Session::session();
+ if(!session)
+ return;
+
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+ if(resMgr) {
+ mySelectionColor = resMgr->colorValue( "Plot2d", "SelectionColor", QColor(80,80,80) );
+ myHighlightedLegendTextColor = resMgr->colorValue( "Plot2d", "SelectedLegendFontColor", QColor(255,255,255) );
+ }
+}
+
/*!
Constructor
*/
myHorUnits( "" ), myVerUnits( "" ),
myName( "" ),
myXAxis( QwtPlot::xBottom ),
- myYAxis( QwtPlot::yLeft )
+ myYAxis( QwtPlot::yLeft ),
+ myIsSelected(false),
+ myScale ( 1.0 )
{
}
myXAxis = object.getXAxis();
myYAxis = object.getYAxis();
myPoints = object.getPointList();
+ myScale = object.getScale();
}
/*!
myXAxis = object.getXAxis();
myYAxis = object.getYAxis();
myPoints = object.getPointList();
+ myScale = object.getScale();
return *this;
}
theItem->attach( aPlot );
}
}
- theItem->setTitle( !getName().isEmpty() ? getName() : getVerTitle() );
+ QString name = !getName().isEmpty() ? getName() : getVerTitle();
+ if( myScale != 1.0 )
+ name = name + QString("( *%1 )").arg(myScale);
+ theItem->setTitle( name );
}
/*!
return myName;
}
+/*!
+ Sets object's scale factor
+ */
+void Plot2d_Object::setScale( double theScale )
+{
+ myScale = theScale;
+}
+/*!
+ Gets object's scale factor
+ */
+double Plot2d_Object::getScale() const
+{
+ return myScale;
+}
+
/*!
Adds one point for object.
*/
int aNPoints = nbPoints();
double* aY = new double[aNPoints];
for (int i = 0; i < aNPoints; i++) {
- aY[i] = myPoints[i].y;
+ aY[i] = myScale * myPoints[i].y;
}
return aY;
}
*theY = new double[aNPoints];
for (int i = 0; i < aNPoints; i++) {
(*theX)[i] = myPoints[i].x;
- (*theY)[i] = myPoints[i].y;
+ (*theY)[i] = myScale * myPoints[i].y;
}
return aNPoints;
}
double aMinY = 1e150;
pointList::const_iterator aIt;
for (aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt)
- aMinY = qMin( aMinY, (*aIt).y );
+ aMinY = qMin( aMinY, myScale * (*aIt).y );
return aMinY;
}
double aMaxY = -1e150;
pointList::const_iterator aIt;
for (aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt)
- aMaxY = qMax( aMaxY, (*aIt).y );
+ aMaxY = qMax( aMaxY, myScale * (*aIt).y );
return aMaxY;
}
return tol <= 0;
}
+/*!
+ Sets object's selected property
+*/
+void Plot2d_Object::setSelected(const bool on) {
+ myIsSelected = on;
+}
+
+/*!
+ Gets object's selected property
+*/
+bool Plot2d_Object::isSelected() const {
+ return myIsSelected;
+}
+
+/*!
+ * Sets selection color of the object.
+*/
+void Plot2d_Object::setSelectionColor(const QColor& c) {
+ mySelectionColor = c;
+}
+
+/*!
+ * Return selection color of the object.
+*/
+QColor Plot2d_Object::selectionColor() {
+ return mySelectionColor;
+}
+
+/*!
+ * Sets font color of the selected legend item.
+*/
+void Plot2d_Object::setHighlightedLegendTextColor(const QColor& c) {
+ myHighlightedLegendTextColor = c;
+}
+
+/*!
+ * Sets font color of the selected legend item.
+*/
+QColor Plot2d_Object::highlightedLegendTextColor() {
+ return myHighlightedLegendTextColor;
+}
void setName( const QString& );
QString getName() const;
+ void setScale( double );
+ double getScale() const;
+
void addPoint( double, double, const QString& = QString() );
void addPoint( const Plot2d_Point& );
void insertPoint( int, double, double, const QString& = QString() );
double getMaxX() const;
double getMinY() const;
double getMaxY() const;
+
+ void setSelected(const bool);
+ bool isSelected() const;
static bool closeColors( const QColor&, const QColor&, int distance = -1 );
+
+ static void initColors();
+
+ static void setSelectionColor(const QColor& c);
+ static QColor selectionColor();
+
+ static void setHighlightedLegendTextColor(const QColor& c);
+ static QColor highlightedLegendTextColor();
protected:
bool myAutoAssign;
QwtPlot::Axis myXAxis;
QwtPlot::Axis myYAxis;
+ double myScale;
+
pointList myPoints;
+ bool myIsSelected;
+
+ private:
+ static QColor mySelectionColor; //!< Color of the selected curve or histogram
+ static QColor myHighlightedLegendTextColor; //!< Color of the selected legend item font
};
typedef QList<Plot2d_Object*> objectList;
// Author : Natalia ERMOLAEVA, Open CASCADE S.A.S. (natalia.donis@opencascade.com)
#include "Plot2d_PlotItems.h"
+#include "Plot2d_Object.h"
#include <QPainter>
+#include <QPalette>
+#include <QLayout>
#include <qwt_plot.h>
#include <qwt_painter.h>
#include <qwt_scale_map.h>
*/
Plot2d_QwtLegendItem::Plot2d_QwtLegendItem( QWidget* parent ) :
QwtLegendItem( parent ),
- myYAxisIdentifierMode( IM_None )
+ myYAxisIdentifierMode( IM_None ),
+ myIsSelected(false)
{
myYAxisLeftIcon = yAxisLeft;
myYAxisRightIcon = yAxisRight;
}
}
+/*!
+ Update highliting on the item.
+*/
+void Plot2d_QwtLegendItem::updateHighlit() {
+ QwtText txt = text();
+ if(isSelected()) {
+ QColor highlightColor = Plot2d_Object::selectionColor();
+ if(highlightColor != txt.backgroundBrush().color()) {
+ txt.setBackgroundBrush(highlightColor);
+ setText(txt);
+ }
+ } else if( QWidget* parent = qobject_cast<QWidget*>(this->parent()->parent()) ) {
+ QPalette aPal = parent->palette();
+ if(aPal.color(QPalette::Background) != txt.backgroundBrush().color()) {
+ txt.setBackgroundBrush(aPal.color(QPalette::Background));
+ setText(txt);
+ }
+ }
+}
+
+/*!
+ Sets selected property.
+*/
+void Plot2d_QwtLegendItem::setSelected(const bool on) {
+ myIsSelected = on;
+}
+
+/*!
+ Gets selected property.
+*/
+bool Plot2d_QwtLegendItem::isSelected() const {
+ return myIsSelected;
+}
+
+
+/*
+ Draw text of the item.
+*/
+void Plot2d_QwtLegendItem::drawText(QPainter * painter, const QRect &rect) {
+ painter->setPen( isSelected() ? Plot2d_Object::highlightedLegendTextColor() :
+ getColorFromPalette( QPalette::Text) );
+
+ QwtLegendItem::drawText( painter, rect );
+}
+
+/*
+ Get color from the legend pallete by 'role' flag.
+*/
+QColor Plot2d_QwtLegendItem::getColorFromPalette(QPalette::ColorRole role) {
+ QWidget* pw = parentWidget();
+ QColor col = palette().color( role );
+ while( pw ) {
+ if ( qobject_cast<QwtLegend*>( pw ) ) {
+ col = pw->palette().color(role );
+ break;
+ }
+ pw = pw->parentWidget();
+ }
+ return col;
+}
+
/*!
Constructor of Plot2d_QwtPlotCurve
*/
Plot2d_QwtPlotCurve::Plot2d_QwtPlotCurve( const QString& title,
QwtPlot::Axis yAxis /*const int index*/ ) :
+ Plot2d_SelectableItem(),
QwtPlotCurve( title ),
myYAxis( yAxis ),
- myYAxisIdentifierEnabled( false )
+ myYAxisIdentifierEnabled( false )
{
}
*/
void Plot2d_QwtPlotCurve::updateLegend( QwtLegend* legend ) const
{
- QwtPlotCurve::updateLegend( legend );
-
- if ( legend ) {
- QWidget* widget = legend->find( this );
+ if ( !legend )
+ return;
+
+ QWidget* widget = legend->find( this );
+
+ if ( testItemAttribute(QwtPlotItem::Legend)) {
+
+ if ( widget == NULL ) {
+ widget = legendItem();
+ if ( widget ) {
+ if ( widget->inherits("QwtLegendItem") ) {
+ QwtLegendItem *label = (QwtLegendItem *)widget;
+ label->setItemMode(legend->itemMode());
+
+ if ( plot() ) {
+ QObject::connect(label, SIGNAL(clicked()),
+ plot(), SLOT(legendItemClicked()));
+ QObject::connect(label, SIGNAL(checked(bool)),
+ plot(), SLOT(legendItemChecked(bool)));
+ }
+ }
+ legend->contentsWidget()->layout()->addWidget(widget);
+ legend->insert(this, widget);
+ }
+ }
+
+ QwtPlotCurve::updateLegend( legend );
+
+
if( Plot2d_QwtLegendItem* anItem = dynamic_cast<Plot2d_QwtLegendItem*>( widget ) ) {
int aMode = Plot2d_QwtLegendItem::IM_None;
if( myYAxisIdentifierEnabled )
Plot2d_QwtLegendItem::IM_Right :
Plot2d_QwtLegendItem::IM_Left;
anItem->setYAxisIdentifierMode( aMode );
+ if(isSelected()) {
+ anItem->setCurvePen(legendPen());
+ anItem->setSymbol(legendSymbol());
+ }
+ anItem->setSelected(isSelected());
+ anItem->updateHighlit();
}
}
}
{
return new Plot2d_QwtLegendItem;
}
+/*!
+ Constructor.
+*/
+Plot2d_SelectableItem::Plot2d_SelectableItem():
+ myIsSelected(false)
+{
+}
+
+/*!
+ Destructor.
+*/
+Plot2d_SelectableItem::~Plot2d_SelectableItem()
+{
+}
+
+/*!
+ Sets selected property.
+*/
+void Plot2d_SelectableItem::setSelected( const bool on) {
+ myIsSelected = on;
+}
+
+/*!
+ Return selected property.
+*/
+bool Plot2d_SelectableItem::isSelected() const {
+ return myIsSelected;
+}
+
+/*!
+ Sets legend pen property.
+*/
+void Plot2d_SelectableItem::setLegendPen( const QPen & p) {
+ myLegendPen = p;
+}
+
+/*!
+ Return legend pen property.
+*/
+QPen Plot2d_SelectableItem::legendPen() const {
+ return myLegendPen;
+}
+
+/*!
+ Sets legend symbol property.
+*/
+void Plot2d_SelectableItem::setLegendSymbol(const QwtSymbol& s) {
+ myLegendSymbol = s;
+}
+
+/*!
+ Sets legend symbol property.
+*/
+QwtSymbol Plot2d_SelectableItem::legendSymbol() const {
+ return myLegendSymbol;
+}
/*!
Constructor
Constructor
*/
Plot2d_HistogramItem::Plot2d_HistogramItem( const QwtText& theTitle )
-: Plot2d_HistogramQwtItem( theTitle ),
+: Plot2d_HistogramQwtItem( theTitle ),
+ Plot2d_SelectableItem(),
myCrossed( true )
{
}
if ( !theWidget || !theWidget->inherits( "QwtLegendItem" ) )
return;
- QwtLegendItem* anItem = ( QwtLegendItem* )theWidget;
+ Plot2d_QwtLegendItem* anItem = ( Plot2d_QwtLegendItem* )theWidget;
QFontMetrics aFMetrics( anItem->font() );
int aSize = aFMetrics.height();
- QwtSymbol aSymbol( QwtSymbol::Rect, QBrush( color() ),
- QPen( color() ), QSize( aSize, aSize ) );
+ QwtSymbol aSymbol( QwtSymbol::Rect, QBrush( legendPen().color() ),
+ QPen( legendPen().color() ), QSize( aSize, aSize ) );
anItem->setSymbol( aSymbol );
anItem->setIdentifierMode( theLegend->identifierMode()
| QwtLegendItem::ShowSymbol );
+ anItem->setSelected(isSelected());
+ anItem->updateHighlit();
anItem->update();
}
return myCrossed;
}
+/*!
+ Redefined method, which creates and returns legend item of the curve
+*/
+QWidget* Plot2d_HistogramItem::legendItem() const
+{
+ return new Plot2d_QwtLegendItem;
+}
+
+
/*!
Draws bar of histogram and on it bars of histograms with lower height.
*/
public:
void setYAxisIdentifierMode( const int );
+ void updateHighlit();
+ void setSelected(const bool on);
+ bool isSelected() const;
+ QColor getColorFromPalette(QPalette::ColorRole role);
protected:
virtual void drawIdentifier( QPainter*, const QRect& ) const;
+ virtual void drawText(QPainter *, const QRect &);
+
+private:
private:
int myYAxisIdentifierMode;
QPixmap myYAxisRightIcon;
int mySpacingCollapsed;
int mySpacingExpanded;
+ bool myIsSelected;
};
-class PLOT2D_EXPORT Plot2d_QwtPlotCurve : public QwtPlotCurve
+class PLOT2D_EXPORT Plot2d_SelectableItem {
+public:
+ Plot2d_SelectableItem();
+ ~Plot2d_SelectableItem();
+
+ void setSelected( const bool );
+ bool isSelected() const;
+
+ void setLegendPen( const QPen & );
+ QPen legendPen() const;
+
+ void setLegendSymbol( const QwtSymbol& );
+ QwtSymbol legendSymbol() const;
+
+private:
+ bool myIsSelected;
+ QPen myLegendPen;
+ QwtSymbol myLegendSymbol;
+};
+
+class PLOT2D_EXPORT Plot2d_QwtPlotCurve : public QwtPlotCurve, public Plot2d_SelectableItem
{
public:
Plot2d_QwtPlotCurve( const QString&, QwtPlot::Axis = QwtPlot::yLeft );
double myReference;
};
-class PLOT2D_EXPORT Plot2d_HistogramItem : public Plot2d_HistogramQwtItem
+class PLOT2D_EXPORT Plot2d_HistogramItem : public Plot2d_HistogramQwtItem, public Plot2d_SelectableItem
{
public:
explicit Plot2d_HistogramItem( const QString& = QString() );
const QRect& ) const;
int getCrossedTop( const QRect& ) const;
+ virtual QWidget* legendItem() const;
+
protected:
QList<QRect> myBarItems;
bool myCrossed;
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 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 : Plot2d_SetupCurveScaleDlg.cxx
+//
+#include "Plot2d_SetupCurveScaleDlg.h"
+
+#include <SUIT_Tools.h>
+
+#include <QGroupBox>
+#include <QHBoxLayout>
+#include <QVBoxLayout>
+#include <QLabel>
+#include <QPushButton>
+
+#include <QtxDoubleSpinBox.h>
+
+const int MARGIN_SIZE = 11;
+const int SPACING_SIZE = 6;
+const int MIN_COMBO_WIDTH = 100;
+const int MIN_SPIN_WIDTH = 50;
+
+/*!
+ \class Plot2d_SetupCurveScaleDlg
+ \brief Dialog box for modifying 2d curve scale factor.
+*/
+
+/*!
+ \brief Constructor.
+ \param parent parent widget
+*/
+Plot2d_SetupCurveScaleDlg::Plot2d_SetupCurveScaleDlg( /*curveList lst, */QWidget* parent )
+: QDialog( parent )
+{
+ setModal( true );
+ setWindowTitle( tr("TLT_SETUP_CURVE_SCALE") );
+ setSizeGripEnabled( true );
+
+ /************************************************************************/
+ QGroupBox* GroupC1 = new QGroupBox( this );
+ QHBoxLayout* GroupC1Layout = new QHBoxLayout( GroupC1 );
+ GroupC1Layout->setSpacing( SPACING_SIZE );
+ GroupC1Layout->setMargin( MARGIN_SIZE );
+
+ QLabel* aScaleLab = new QLabel( tr( "CURVE_SCALE_FACTOR" ), GroupC1 );
+ myValueSpin = new QtxDoubleSpinBox( GroupC1 );
+ myValueSpin->setMinimum( 0.01 );
+ myValueSpin->setSingleStep( 0.1 );
+ myValueSpin->setMinimumWidth( MIN_SPIN_WIDTH );
+
+ GroupC1Layout->addWidget( aScaleLab );
+ GroupC1Layout->addWidget( myValueSpin );
+
+ /************************************************************************/
+ QGroupBox* GroupButtons = new QGroupBox( this );
+ QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons );
+ GroupButtonsLayout->setSpacing( SPACING_SIZE );
+ GroupButtonsLayout->setMargin( MARGIN_SIZE );
+
+ myOkBtn = new QPushButton( tr( "BUT_OK" ), this );
+ myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), this );
+
+ GroupButtonsLayout->addWidget( myOkBtn );
+ GroupButtonsLayout->addSpacing( 10 );
+ GroupButtonsLayout->addWidget( myCancelBtn );
+
+ /************************************************************************/
+ QVBoxLayout* topLayout = new QVBoxLayout( this );
+ topLayout->setSpacing( SPACING_SIZE );
+ topLayout->setMargin( MARGIN_SIZE );
+ topLayout->addWidget( GroupC1 );
+ topLayout->addWidget( GroupButtons );
+
+ // default settings
+ setScale( 1.0 ); // no scale
+
+ // connections
+ connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) );
+ connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
+
+ SUIT_Tools::centerWidget( this, parent );
+}
+
+/*!
+ \brief Destructor.
+*/
+Plot2d_SetupCurveScaleDlg::~Plot2d_SetupCurveScaleDlg()
+{
+}
+
+/*!
+ \brief Set scale factor.
+ \param coef scale factor
+ \sa getScale()
+*/
+void Plot2d_SetupCurveScaleDlg::setScale( const double coef )
+{
+ if ( coef > myValueSpin->maximum() ){
+ myValueSpin->setMaximum( coef );
+ }
+ myValueSpin->setValue( coef );
+}
+
+/*!
+ \brief Get scale factor.
+ \return chosen scale factor
+ \sa setScale()
+*/
+double Plot2d_SetupCurveScaleDlg::getScale() const
+{
+ return myValueSpin->value();
+}
+/*!
+ \brief Clear value in the "Scale factor" spinbox.
+*/
+void Plot2d_SetupCurveScaleDlg::setUndefinedValue() {
+ myValueSpin->setCleared(true);
+ myValueSpin->setSpecialValueText("");
+}
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 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 : Plot2d_SetupCurveScaleDlg.h
+//
+#ifndef PLOT2D_SETUPCURVESCALEDLG_H
+#define PLOT2D_SETUPCURVESCALEDLG_H
+
+#include "Plot2d.h"
+
+#include <QDialog>
+
+class QPushButton;
+class QLabel;
+
+class QtxDoubleSpinBox;
+
+class PLOT2D_EXPORT Plot2d_SetupCurveScaleDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ Plot2d_SetupCurveScaleDlg( /*curveList,*/ QWidget* = 0 );
+ ~Plot2d_SetupCurveScaleDlg();
+
+public:
+ void setScale( const double );
+ double getScale() const;
+
+ void setUndefinedValue();
+
+private:
+ QPushButton* myOkBtn;
+ QPushButton* myCancelBtn;
+ QtxDoubleSpinBox* myValueSpin;
+};
+
+#endif // PLOT2D_SETUPCURVESCALEDLG_H
+
#include <SUIT_Session.h>
#include <SUIT_Application.h>
#include <QtxColorButton.h>
+#include <QtxFontEdit.h>
#include <QCheckBox>
#include <QLineEdit>
// legend
myLegendCheck = new QCheckBox( tr( "PLOT2D_ENABLE_LEGEND" ), this );
myLegendCombo = new QComboBox( this );
+ myLegendFont = new QtxFontEdit( this );
+ myLegendColor = new QtxColorButton( this );
+ QLabel* aLegendFontLab = new QLabel( tr( "PLOT2D_LEGEND_FONT" ), this );
myLegendCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
myLegendCombo->setMinimumWidth( MIN_COMBO_WIDTH );
myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_LEFT" ) );
// layout widgets
topLayout->addWidget( myTitleCheck, 0, 0 );
topLayout->addWidget( myTitleEdit, 0, 1, 1, 3 );
- topLayout->addWidget( aCurveLab, 1, 0 );
- topLayout->addWidget( myCurveCombo, 1, 1 );
- topLayout->addWidget( myLegendCheck, 1, 2 );
- topLayout->addWidget( myLegendCombo, 1, 3 );
- topLayout->addWidget( aMarkerLab, 2, 0 );
- topLayout->addWidget( myMarkerSpin, 2, 1 );
+ topLayout->addWidget( myLegendCheck, 1, 0 );
+ topLayout->addWidget( myLegendCombo, 1, 1 );
+ topLayout->addWidget( aCurveLab, 1, 2 );
+ topLayout->addWidget( myCurveCombo, 1, 3 );
+ topLayout->addWidget( aLegendFontLab,2, 0 );
+ topLayout->addWidget( myLegendFont, 2, 1 );
+ topLayout->addWidget( myLegendColor, 2, 2 );
+
+ topLayout->addWidget( aMarkerLab, 3, 0 );
+ topLayout->addWidget( myMarkerSpin, 3, 1 );
QHBoxLayout* bgLayout = new QHBoxLayout;
bgLayout->addWidget( myBackgroundBtn ); bgLayout->addStretch();
- topLayout->addWidget( aBGLab, 2, 2 );
- topLayout->addLayout( bgLayout, 2, 3 );
- topLayout->addWidget( aScaleGrp, 3, 0, 1, 4 );
- topLayout->addWidget( aTabWidget, 4, 0, 1, 4 );
- topLayout->addWidget( myDefCheck, 5, 0, 1, 4 );
- topLayout->setRowStretch( 5, 5 );
-
- topLayout->addLayout( btnLayout, 6, 0, 1, 4 );
+ topLayout->addWidget( aBGLab, 3, 2 );
+ topLayout->addLayout( bgLayout, 3, 3 );
+ topLayout->addWidget( aScaleGrp, 4, 0, 1, 4 );
+ topLayout->addWidget( aTabWidget, 5, 0, 1, 4 );
+ topLayout->addWidget( myDefCheck, 6, 0, 1, 4 );
+ topLayout->setRowStretch( 6, 5 );
+
+ topLayout->addLayout( btnLayout, 7, 0, 1, 4 );
if ( !showDefCheck )
myDefCheck->hide();
\brief Set legend attribute.
\param if \c true legend is shown
\param pos legend position: 0 (left), 1 (right), 2 (top), 3 (bottom)
- \sa isLegendEnabled(), getLegendPos()
+ \param fnt legend font
+ \param col legend font color
+ \sa isLegendEnabled(), getLegendPos(), getLegendFont()
*/
-void Plot2d_SetupViewDlg::setLegend( bool enable, int pos )
+void Plot2d_SetupViewDlg::setLegend( bool enable, int pos, const QFont& fnt, const QColor& col )
{
myLegendCheck->setChecked( enable );
myLegendCombo->setCurrentIndex( pos );
+ myLegendFont->setCurrentFont( fnt );
+ myLegendColor->setColor( col );
onLegendChecked();
}
return myLegendCombo->currentIndex();
}
+/*!
+ \brief Get legend font.
+ \return legend font
+ \sa setLegend()
+*/
+QFont Plot2d_SetupViewDlg::getLegendFont()
+{
+ return myLegendFont->currentFont();
+}
+
+/*!
+ \brief Get legend font color.
+ \return legend font color
+ \sa setLegend()
+*/
+QColor Plot2d_SetupViewDlg::getLegendColor()
+{
+ return myLegendColor->color();
+}
+
/*!
\brief Set marker size.
\param size marker size
class QComboBox;
class QPushButton;
class QtxColorButton;
+class QtxFontEdit;
class PLOT2D_EXPORT Plot2d_SetupViewDlg : public QDialog
{
void setCurveType( const int );
int getCurveType();
- void setLegend( bool, int );
+ void setLegend( bool, int, const QFont&, const QColor& );
bool isLegendEnabled();
int getLegendPos();
+ QFont getLegendFont();
+ QColor getLegendColor();
void setMarkerSize( const int );
int getMarkerSize();
QLineEdit* myTitleYEdit;
QLineEdit* myTitleY2Edit;
QtxColorButton* myBackgroundBtn;
+ QtxColorButton* myLegendColor;
+ QtxFontEdit* myLegendFont;
QCheckBox* myXGridCheck;
QSpinBox* myXGridSpin;
QCheckBox* myYGridCheck;
: QWidget (parent, 0),
myOperation( NoOpId ),
myCurveType( 1 ),
- myShowLegend( true ), myLegendPos( 1 ),
+ myShowLegend( true ), myLegendPos( 1 ), myLegendFont("Helvetic",12),
+ myLegendColor(Qt::black),
myMarkerSize( DEFAULT_MARKER_SIZE ),
myBackground( Qt::white ),
myTitle( "" ), myXTitle( "" ), myYTitle( "" ), myY2Title( "" ),
setVerScaleMode( myYMode, false );
setBackgroundColor( myBackground );
setLegendPos( myLegendPos );
+ setLegendFont( myLegendFont );
+ setLegendFontColor( myLegendColor );
showLegend( myShowLegend, false );
myPlot->replot();
myShowLegend = resMgr->booleanValue( "Plot2d", "ShowLegend", myShowLegend );
myLegendPos = resMgr->integerValue( "Plot2d", "LegendPos", myLegendPos );
+ myLegendFont = resMgr->fontValue( "Plot2d", "LegendFont", myLegendFont );
+ myLegendColor = resMgr->colorValue( "Plot2d", "LegendFontColor", myLegendColor );
myMarkerSize = resMgr->integerValue( "Plot2d", "MarkerSize", myMarkerSize );
myBackground = resMgr->colorValue( "Plot2d", "Background", myBackground );
resMgr->setValue( "Plot2d", "CurveType", myCurveType );
resMgr->setValue( "Plot2d", "ShowLegend", myShowLegend );
resMgr->setValue( "Plot2d", "LegendPos", myLegendPos );
+ resMgr->setValue( "Plot2d", "LegendFont", myLegendFont );
+ resMgr->setValue( "Plot2d", "LegendFontColor", myLegendColor );
resMgr->setValue( "Plot2d", "MarkerSize", myMarkerSize );
resMgr->setValue( "Plot2d", "Background", myBackground );
resMgr->setValue( "Plot2d", "ShowTitle", myTitleEnabled );
{
if ( !object )
return;
-
+
if ( object->getYAxis() == QwtPlot::yRight )
mySecondY = true;
}
}
+/*!
+ update legend
+*/
+void Plot2d_ViewFrame::updateLegend() {
+ if ( myPlot->getLegend() ) {
+ ObjectDict::iterator it = myObjects.begin();
+ for( ; it != myObjects.end(); ++it )
+ it.key()->updateLegend(myPlot->getLegend());
+ }
+}
+
+
/*!
Fits the view to see all data
*/
if (mySecondY)
dlg->setY2Title( myY2TitleEnabled, myY2Title );
dlg->setCurveType( myCurveType );
- dlg->setLegend( myShowLegend, myLegendPos );
+ dlg->setLegend( myShowLegend, myLegendPos, myLegendFont, myLegendColor );
dlg->setMarkerSize( myMarkerSize );
dlg->setBackgroundColor( myBackground );
dlg->setScaleMode(myXMode, myYMode);
if ( myLegendPos != dlg->getLegendPos() ) {
setLegendPos( dlg->getLegendPos() );
}
+ if ( myLegendFont != dlg->getLegendFont() ) {
+ setLegendFont( dlg->getLegendFont() );
+ }
+ if ( myLegendColor != dlg->getLegendColor() ) {
+ setLegendFontColor( dlg->getLegendColor() );
+ }
+
// marker size
if ( myMarkerSize != dlg->getMarkerSize() ) {
setMarkerSize( dlg->getMarkerSize(), false );
QwtLegend* legend = myPlot->legend();
if ( !legend ) {
legend = new QwtLegend( myPlot );
- legend->setFrameStyle( QFrame::Box | QFrame::Sunken );
+ legend->setFrameStyle( QFrame::Box | QFrame::Sunken );
}
legend->setItemMode( QwtLegend::ClickableItem );
myPlot->insertLegend( legend );
setLegendPos( myLegendPos );
+ setLegendFont( myLegendFont );
+ setLegendFontColor( myLegendColor );
}
else
myPlot->insertLegend( 0 );
return myLegendPos;
}
+/*!
+ Sets legend font
+*/
+void Plot2d_ViewFrame::setLegendFont( const QFont& fnt )
+{
+ myLegendFont = fnt;
+ QwtLegend* legend = myPlot->legend();
+ if ( legend ) {
+ legend->setFont(fnt);
+ }
+}
+
+/*!
+ Gets legend font
+*/
+QFont Plot2d_ViewFrame::getLegendFont() const
+{
+ return myLegendFont;
+}
+
+/*!
+ Gets legend font color
+*/
+QColor Plot2d_ViewFrame::getLegendFontColor() const
+{
+ return myLegendColor;
+}
+
+/*!
+ Sets legend font color
+*/
+void Plot2d_ViewFrame::setLegendFontColor( const QColor& col )
+{
+ myLegendColor = col;
+ QwtLegend* legend = myPlot->legend();
+ if ( legend ) {
+ QPalette pal = legend->palette();
+ pal.setColor( QPalette::Text, col );
+ legend->setPalette( pal );
+ }
+}
+
/*!
Sets new marker size
*/
QwtSymbol aSymbol = crv->symbol();
aSymbol.setSize( myMarkerSize, myMarkerSize );
crv->setSymbol( aSymbol );
+ if(it.value())
+ it.value()->setMarkerSize( myMarkerSize );
}
}
if ( update )
aPal.setColor( QPalette::Background, myBackground );
}
myPlot->getLegend()->setPalette( aPal );
+ updateLegend();
}
Repaint();
}
void updateObject( Plot2d_Object*, bool = false );
void updateLegend( const Plot2d_Prs* );
+ void updateLegend();
void fitAll();
void fitArea( const QRect& );
void fitData( const int, const double, const double,
void showLegend( bool, bool = true );
void setLegendPos( int );
int getLegendPos() const;
+ void setLegendFont( const QFont& );
+ QFont getLegendFont() const;
+ void setLegendFontColor( const QColor& );
+ QColor getLegendFontColor() const;
void setMarkerSize( const int, bool = true );
int getMarkerSize() const;
void setBackgroundColor( const QColor& );
int myCurveType;
bool myShowLegend;
int myLegendPos;
+ QFont myLegendFont;
+ QColor myLegendColor;
int myMarkerSize;
QColor myBackground;
QString myTitle, myXTitle, myYTitle, myY2Title;
{
myPrs = 0;
myAutoDel = theAutoDel;
+ Plot2d_Object::initColors();
}
/*!
public:
static QString Type() { return "Plot2d"; }
-
+
Plot2d_Viewer(bool theAutoDel = false);
~Plot2d_Viewer();
<source>PLOT2D_ENABLE_LEGEND</source>
<translation>Show legend</translation>
</message>
+ <message>
+ <source>PLOT2D_LEGEND_FONT</source>
+ <translation>Legend font</translation>
+ </message>
<message>
<source>DSC_ZOOM_VIEW</source>
<translation>Zoom the view</translation>
<translation>Background color</translation>
</message>
</context>
+<context>
+ <name>Plot2d_SetupCurveScaleDlg</name>
+ <message>
+ <source>TLT_SETUP_CURVE_SCALE</source>
+ <translation>Curve(s) scale</translation>
+ </message>
+ <message>
+ <source>CURVE_SCALE_FACTOR</source>
+ <translation>Scale factor</translation>
+ </message>
+</context>
</TS>
#include <QMenu>
#include <QVBoxLayout>
+#include <utilities.h>
+
/*!
\brief Constructor.
QVBoxLayout* lay = new QVBoxLayout( this );
lay->setMargin( 0 );
myEditor = new PyConsole_Editor( myInterp, this );
+ char* synchronous = getenv("PYTHON_CONSOLE_SYNC");
+ if (synchronous && atoi(synchronous))
+ {
+ MESSAGE("Python console is synchronous");
+ myEditor->setIsSync(true);
+ }
myEditor->viewport()->installEventFilter( this );
lay->addWidget( myEditor );
QtxActionMgr.h \
QtxActionSet.h \
QtxActionToolMgr.h \
+ QtxBiColorTool.h \
QtxColorButton.h \
QtxColorScale.h \
QtxComboBox.h \
QtxWorkspace.h \
QtxWorkspaceAction.h \
QtxWorkstack.h \
- QtxWorkstackAction.h
+ QtxWorkstackAction.h \
+ QtxWebBrowser.h
#VSR: not yet migrated to Qt4 files
# \
QtxActionMgr.cxx \
QtxActionSet.cxx \
QtxActionToolMgr.cxx \
+ QtxBiColorTool.cxx \
QtxColorButton.cxx \
QtxColorScale.cxx \
QtxComboBox.cxx \
QtxWorkspace.cxx \
QtxWorkspaceAction.cxx \
QtxWorkstack.cxx \
- QtxWorkstackAction.cxx
+ QtxWorkstackAction.cxx \
+ QtxWebBrowser.cxx
#VSR: not yet migrated to Qt4 files
# \
QtxActionMgr_moc.cxx \
QtxActionSet_moc.cxx \
QtxActionToolMgr_moc.cxx \
+ QtxBiColorTool_moc.cxx \
QtxColorButton_moc.cxx \
QtxColorScale_moc.cxx \
QtxComboBox_moc.cxx \
QtxWorkspace_moc.cxx \
QtxWorkspaceAction_moc.cxx \
QtxWorkstack_moc.cxx \
- QtxWorkstackAction_moc.cxx
+ QtxWorkstackAction_moc.cxx \
+ QtxWebBrowser_moc.cxx
#VSR: not yet migrated to Qt4 files
# \
nodist_libqtx_la_SOURCES = $(MOC_FILES)
libqtx_la_CPPFLAGS = $(QT_INCLUDES)
-libqtx_la_LDFLAGS = $(QT_MT_LIBS)
+libqtx_la_LDFLAGS = $(QT_MT_LIBS) $(OGL_LIBS)
nodist_salomeres_DATA = \
Qtx_msg_fr.qm
#include <stdarg.h>
#include <clocale>
+#define BICOLOR_CHANGE_HUE
+
/*!
\class Qtx
\brief A set of helpful utility functions.
return res;
}
+/*!
+ \brief Convert bi-color value to the string representation.
+
+ Bi-color value is specified as main color and integer delta
+ value that is used to calculate secondary color by changing
+ paremeters of the main color ("saturation" and "value"
+ components in HSV notation).
+
+ The resulting string consists of two sub-strings separated by
+ '|' symbol. The first part represents main color
+ (see colorToString() for more details), the second part is a
+ delta value.
+
+ Backward conversion can be done with stringToBiColor() method.
+
+ \param color color to be converted
+ \param delta delta value
+ \return string representation of the bi-color value
+
+ \sa stringToBiColor(), stringToColor()
+*/
+QString Qtx::biColorToString( const QColor& color, const int delta )
+{
+ return QString("%1|%2").arg( Qtx::colorToString( color ) ).arg( delta );
+}
+
+/*!
+ \brief Restore bi-color value from the string representation.
+
+ Bi-color value is specified as main color and integer delta
+ value that is used to calculate secondary color by changing
+ paremeters of the main color ("saturation" and "value"
+ components in HSV notation).
+
+ The parameter \a str should consist of two sub-strings separated
+ by '|' symbol. The first part represents main color
+ (see stringToColor() for more details), the second part is a
+ delta value.
+
+ Backward conversion can be done with biColorToString() method.
+
+ \param str string representation of the bi-color value
+ \param color resulting color value
+ \param delta resulting delta value
+ \return \c true if the conversion is successful and \c false otherwise
+
+ \sa biColorToString(), stringToColor(), rgbSet()
+*/
+bool Qtx::stringToBiColor( const QString& str, QColor& color, int& delta )
+{
+ QStringList data = str.split( "|", QString::KeepEmptyParts );
+ QColor c;
+ int d = 0;
+ bool ok = data.count() > 0 && Qtx::stringToColor( data[0], c );
+ bool dok = false;
+ if ( data.count() > 1 ) d = data[1].toInt( &dok );
+ ok = ok && dok;
+ color = ok ? c : QColor();
+ delta = ok ? d : 0;
+ return ok;
+}
+
+/*!
+ \brief Compute secondary color value from specified main color
+ and delta.
+
+ Secondary color is calculated by changing paremeters of the main
+ color ("saturation" and "value" components in HSV notation) using
+ specified delta.
+
+ If main color is invalid, result of the function is also invalid color.
+
+ \param color source main color
+ \param delta delta value
+ \return resulting secondary color
+
+ \sa biColorToString(), stringToBiColor()
+*/
+QColor Qtx::mainColorToSecondary( const QColor& color, int delta )
+{
+ QColor cs = color;
+ if ( cs.isValid() ) {
+ int val = qMin( 255, qMax( cs.value() + delta, 0 ) );
+ int sat = qMin( 255, qMax( cs.saturation() + delta-(val-cs.value()), 0 ) );
+#ifdef BICOLOR_CHANGE_HUE
+ const int BICOLOR_HUE_MAXDELTA = 40;
+ int dh = delta-(val-cs.value())-(sat-cs.saturation());
+ dh = qMin( BICOLOR_HUE_MAXDELTA, qAbs( dh ) ) * ( dh > 0 ? 1 : -1 );
+ //int hue = qMin( 359, qMax( cs.hue() + delta-(val-cs.value())-(sat-cs.saturation()), 0 ) );
+ //int hue = qMin( 359, qMax( cs.hue() + delta-(val-cs.value())-ds, 0 ) );
+ int hue = cs.hue() + dh;
+ if ( hue < 0 ) hue = 360 - hue;
+#else
+ int hue = cs.hue();
+#endif
+ cs.setHsv( hue, sat, val );
+ }
+ return cs;
+}
+
/*!
\brief Dump linear gradient to the string description.
\param gradient linear gradient to be converted
static QString colorToString( const QColor& );
static bool stringToColor( const QString&, QColor& );
+ static QString biColorToString( const QColor&, const int );
+ static bool stringToBiColor( const QString&, QColor&, int& );
+ static QColor mainColorToSecondary( const QColor&, int );
static QString gradientToString( const QLinearGradient& );
static QString gradientToString( const QRadialGradient& );
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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: QtxBiColorTool.cxx
+// Author: Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
+
+#include "QtxBiColorTool.h"
+#include "QtxColorButton.h"
+
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QPainter>
+#include <QSlider>
+#include <QStyle>
+
+const int BICOLOR_MAX_DELTA = 100;
+
+/*!
+ \class QtxBiColorTool::ColorLabel
+ \brief Draw colored label (for secondary color)
+ \internal
+*/
+class QtxBiColorTool::ColorLabel: public QFrame
+{
+public:
+ ColorLabel( QWidget* parent) : QFrame( parent )
+ {
+ setFrameStyle( QFrame::Box | QFrame::Plain );
+ setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
+ }
+ ~ColorLabel() {}
+ QSize sizeHint() const
+ {
+ return minimumSizeHint();
+ }
+ QSize minimumSizeHint() const
+ {
+ int pm = style()->pixelMetric(QStyle::PM_ButtonMargin);
+ QFontMetrics fm ( font() );
+ return QSize( fm.height() + pm, fm.height() + pm );
+ }
+ void paintEvent( QPaintEvent* e )
+ {
+ QPainter p( this );
+ drawFrame( &p );
+ QRect r = contentsRect();
+ if ( myColor.isValid() ) {
+ p.fillRect( r, QBrush( myColor ) );
+ }
+ else {
+ p.fillRect( r, QBrush( palette().color( foregroundRole() ), Qt::BDiagPattern ) );
+ }
+ p.end();
+ }
+ void setColor( const QColor& c )
+ {
+ myColor = c;
+ update();
+ }
+
+private:
+ QColor myColor;
+};
+
+/*!
+ \class QtxBiColorTool
+ \brief Implementation of the widget managing a couple of colors.
+
+ The main color is specified explicitly. The secondary color is calculated
+ by changing "value" of the main color in HSV notation to the specified delta.
+*/
+
+/*!
+ \brief Constructor.
+ \param parent parent widget
+*/
+QtxBiColorTool::QtxBiColorTool( QWidget* parent )
+ : QWidget( parent )
+{
+ QHBoxLayout* l = new QHBoxLayout( this );
+ l->setMargin( 0 );
+ l->setSpacing( 5 );
+
+ myMainColor = new QtxColorButton( this );
+ myMainColor->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
+ myExtraText = new QLabel( this );
+ myRuler = new QSlider( Qt::Horizontal, this );
+ myRuler->setMinimum( -BICOLOR_MAX_DELTA );
+ myRuler->setMaximum( +BICOLOR_MAX_DELTA );
+ myRuler->setSingleStep( 1 );
+ myRuler->setPageStep( 10 );
+ myRuler->setValue( 0 );
+ myRuler->setTickPosition( QSlider::NoTicks );
+ myDelta = new ColorLabel( this );
+
+ l->addWidget( myMainColor );
+ l->addWidget( myExtraText );
+ l->addWidget( myRuler );
+ l->addWidget( myDelta );
+
+ connect( myMainColor, SIGNAL( changed( QColor ) ), this, SLOT( updateState() ) );
+ connect( myRuler, SIGNAL( valueChanged( int ) ), this, SLOT( updateState() ) );
+
+ updateState();
+}
+
+/*!
+ \brief Destructor.
+*/
+QtxBiColorTool::~QtxBiColorTool()
+{
+}
+
+/*!
+ \brief Get currently selected main color
+
+ Returns invalid QColor if no color is selected.
+
+ \return selected main color
+ \sa setMainColor()
+*/
+QColor QtxBiColorTool::mainColor() const
+{
+ return myMainColor->color();
+}
+
+/*!
+ \brief Set main color.
+ \param c color to be set as current main color
+ \sa mainColor()
+*/
+void QtxBiColorTool::setMainColor( const QColor& c )
+{
+ myMainColor->setColor( c );
+ updateState();
+}
+
+/*!
+ \brief Get current value delta for the secondary color
+ \return curent color value delta
+ \sa setDelta(), secondaryColor()
+*/
+int QtxBiColorTool::delta() const
+{
+ return myRuler->value();
+}
+
+/*!
+ \brief Set value delta for the secondary color
+ \param d new color value delta
+ \sa delta(), secondaryColor()
+*/
+void QtxBiColorTool::setDelta( int d )
+{
+ myRuler->setValue( d );
+ updateState();
+}
+
+/*!
+ \brief Get secondary color.
+
+ Returns invalid QColor if no main color is selected.
+ Secondary color is calculated by changing "value" of the main color
+ in HSV notation to the specified delta.
+
+ \return secondary color
+ \sa mainColor(), setMainColor(), delta(), setDelta()
+*/
+QColor QtxBiColorTool::secondaryColor() const
+{
+ return Qtx::mainColorToSecondary( mainColor(), delta() );
+}
+
+/*!
+ \brief Returns auxiliary text assigned to the widget
+ \return current widget text
+ \sa setText()
+*/
+QString QtxBiColorTool::text() const
+{
+ return myExtraText->text();
+}
+
+/*!
+ \brief Assign auxiliary text to the widet
+ \param txt new widget text
+ \sa text()
+*/
+void QtxBiColorTool::setText( const QString& txt )
+{
+ myExtraText->setText( txt );
+}
+
+/*!
+ \brief Update widget state
+*/
+void QtxBiColorTool::updateState()
+{
+ myDelta->setColor( secondaryColor() );
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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: QtxBiColorTool.h
+// Author: Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
+
+#ifndef QTXBICOLORTOOL_H
+#define QTXBICOLORTOOL_H
+
+#include "Qtx.h"
+
+#include <QColor>
+#include <QWidget>
+
+class QLabel;
+class QSlider;
+class QtxColorButton;
+
+class QTX_EXPORT QtxBiColorTool : public QWidget
+{
+ class ColorLabel;
+
+ Q_OBJECT
+
+public:
+ QtxBiColorTool( QWidget* = 0 );
+ virtual ~QtxBiColorTool();
+
+ QColor mainColor() const;
+ void setMainColor( const QColor& );
+
+ int delta() const;
+ void setDelta( int );
+
+ QColor secondaryColor() const;
+
+ QString text() const;
+ void setText( const QString& );
+
+ static QColor mainColorToSecondary( const QColor&, int );
+
+private slots:
+ void updateState();
+
+private:
+ QtxColorButton* myMainColor;
+ QLabel* myExtraText;
+ QSlider* myRuler;
+ ColorLabel* myDelta;
+};
+
+#endif // QTXBICOLORTOOL_H
myStatusBar( 0 ),
myOpaque( true ),
myResizer( 0 ),
- myMouseMove( 0 )
+ myMouseMove( 0 ),
+ myFullScreenAllowed(true)
{
//rnv: Enables tooltips for inactive windows.
//rnv: For details see http://bugtracker.opencascade.com/show_bug.cgi?id=20893
state = QString( "min" );
break;
case Qt::WindowFullScreen:
- state = QString( "full" );
+ state = isFullScreenAllowed() ? QString( "full" ) : QString( "max" );
break;
}
return ok;
}
+
+/*!
+ \brief FullScreenAllowed flag allowed dump in the main window geometry
+ Qt::WindowFullScreen parameter.
+ \return \c fullScreenAllowed flag.
+*/
+bool QtxMainWindow::isFullScreenAllowed() const {
+ return myFullScreenAllowed;
+}
+
+
+/*!
+ \brief Set FullScreenAllowed flag.
+ The default value is true.
+ \param f value of the fullScreenAllowed flag.
+*/
+void QtxMainWindow::setFullScreenAllowed( const bool f ) {
+ myFullScreenAllowed = f;
+}
QString storeGeometry() const;
void retrieveGeometry( const QString& );
+ bool isFullScreenAllowed() const;
+ void setFullScreenAllowed( const bool );
+
protected:
virtual bool event( QEvent* );
QToolBar* myMenuBar; //!< dockable menu bar
QToolBar* myStatusBar; //!< dockable status bar
+ bool myFullScreenAllowed;
+
bool myOpaque;
Resizer* myResizer;
QMouseEvent* myMouseMove;
#include "QtxComboBox.h"
#include "QtxIntSpinBox.h"
#include "QtxColorButton.h"
+#include "QtxBiColorTool.h"
#include "QtxDoubleSpinBox.h"
#include "QtxShortcutEdit.h"
#include "QtxResourceMgr.h"
myColor->setColor( getColor() );
}
+/*!
+ \class QtxPagePrefBiColorItem
+ \brief GUI implementation of the resources item to store a bi-color value.
+
+ The main color is specified explicitly. The secondary color is calculated
+ by changing "value" and "saturation" parameters of the main color in the
+ HSV notation using specified delta.
+*/
+
+/*!
+ \brief Constructor.
+ \param title preference item title
+ \param parent parent preference item
+ \param sect resource file section associated with the preference item
+ \param param resource file parameter associated with the preference item
+*/
+QtxPagePrefBiColorItem::QtxPagePrefBiColorItem( const QString& title, QtxPreferenceItem* parent,
+ const QString& sect, const QString& param )
+: QtxPageNamedPrefItem( title, parent, sect, param )
+{
+ setControl( myColors = new QtxBiColorTool( 0 ) );
+}
+
+/*!
+ \brief Destructor.
+*/
+QtxPagePrefBiColorItem::~QtxPagePrefBiColorItem()
+{
+}
+
+/*!
+ \bried Get auxiliary text
+ \return text assigned to the item
+ \sa setText()
+*/
+QString QtxPagePrefBiColorItem::text() const
+{
+ return myColors->text();
+}
+
+/*!
+ \bried Set auxiliary text
+ \param t text being assigned to the item
+ \sa text()
+*/
+void QtxPagePrefBiColorItem::setText( const QString& t )
+{
+ myColors->setText( t );
+}
+
+/*!
+ \brief Store preference item to the resource manager.
+ \sa retrieve()
+*/
+void QtxPagePrefBiColorItem::store()
+{
+ setString( Qtx::biColorToString( myColors->mainColor(), myColors->delta() ) );
+}
+
+/*!
+ \brief Retrieve preference item from the resource manager.
+ \sa store()
+*/
+void QtxPagePrefBiColorItem::retrieve()
+{
+ QColor c;
+ int d;
+ Qtx::stringToBiColor( getString(), c, d );
+ myColors->setMainColor( c );
+ myColors->setDelta( d );
+}
+
+/*!
+ \brief Get preference item option value.
+ \param name option name
+ \return property value or null QVariant if option is not set
+ \sa setOptionValue()
+*/
+QVariant QtxPagePrefBiColorItem::optionValue( const QString& name ) const
+{
+ if ( name == "text" )
+ return text();
+ else
+ return QtxPageNamedPrefItem::optionValue( name );
+}
+
+/*!
+ \brief Set preference item option value.
+ \param name option name
+ \param val new property value
+ \sa optionValue()
+*/
+void QtxPagePrefBiColorItem::setOptionValue( const QString& name, const QVariant& val )
+{
+ if ( name == "text" )
+ {
+ if ( val.canConvert( QVariant::String ) )
+ setText( val.toString() );
+ }
+ else
+ QtxPageNamedPrefItem::setOptionValue( name, val );
+}
+
/*!
\class QtxPagePrefFontItem
\brief GUI implementation of the resources font item.
class QtxGroupBox;
class QtxComboBox;
class QtxColorButton;
+class QtxBiColorTool;
class QtxShortcutEdit;
class QtxShortcutTree;
virtual void setOptionValue( const QString&, const QVariant& );
private slots:
- void setIcon( int );
+ void setIcon( int );
private:
void updateSlider();
QtxColorButton* myColor;
};
+class QTX_EXPORT QtxPagePrefBiColorItem : public QtxPageNamedPrefItem
+{
+public:
+ QtxPagePrefBiColorItem( const QString&, QtxPreferenceItem* = 0,
+ const QString& = QString(), const QString& = QString() );
+ virtual ~QtxPagePrefBiColorItem();
+
+ virtual QString text() const;
+ virtual void setText( const QString& );
+
+ virtual void store();
+ virtual void retrieve();
+
+protected:
+ virtual QVariant optionValue( const QString& ) const;
+ virtual void setOptionValue( const QString&, const QVariant& );
+
+private:
+ QtxBiColorTool* myColors;
+};
+
class QTX_EXPORT QtxPagePrefFontItem : public QObject, public QtxPageNamedPrefItem
{
Q_OBJECT
*/
bool QtxResourceMgr::IniFormat::save( const QString& fname, const QMap<QString, Section>& secMap )
{
+ if ( !Qtx::mkDir( QFileInfo( fname ).absolutePath() ) )
+ return false;
+
QFile file( fname );
if ( !file.open( QFile::WriteOnly ) )
return false;
#ifndef QT_NO_DOM
+ if ( !Qtx::mkDir( QFileInfo( fname ).absolutePath() ) )
+ return false;
+
QFile file( fname );
if ( !file.open( QFile::WriteOnly ) )
return false;
the configuration file from the previous versions of the application).
\param appName application name
- \param for_load boolean flag indicating that file is opened for loading or saving (not used)
+ \param for_load boolean flag indicating that file is opened for loading or saving (not used in default implementation)
\return user configuration file name
\sa globalFileName()
*/
QString fileName;
QString pathName = QDir::homePath();
+ QString cfgAppName = QApplication::applicationName();
+ if ( !cfgAppName.isEmpty() )
+ pathName = Qtx::addSlash( Qtx::addSlash( pathName ) + QString( ".config" ) ) + cfgAppName;
+
#ifdef WIN32
fileName = QString( "%1.%2" ).arg( appName ).arg( currentFormat() );
#else
\param controls ORed controls flags (QtxSearchTool::Controls)
\sa setWatchedWidget(), setControls()
*/
-QtxSearchTool::QtxSearchTool( QWidget* parent, QWidget* watched, int controls )
+QtxSearchTool::QtxSearchTool( QWidget* parent, QWidget* watched, int controls, Qt::Orientation orientation )
: QFrame( parent ),
myWatched( watched ? watched : parent ),
mySearcher( 0 ),
myAutoHideTimer( 0 ),
myAutoHideEnabled( true )
{
- init();
+ init( orientation );
}
/*!
\param controls ORed controls flags (QtxSearchTool::Controls)
\sa setWatchedWidget(), setControls()
*/
-QtxSearchTool::QtxSearchTool( QWidget* parent, int controls )
+QtxSearchTool::QtxSearchTool( QWidget* parent, int controls, Qt::Orientation orientation )
: QFrame( parent ),
myWatched( parent ),
mySearcher( 0 ),
myAutoHideTimer( 0 ),
myAutoHideEnabled( true )
{
- init();
+ init( orientation );
}
/*!
wid = id < 0 ? --_wid : id;
- QVBoxLayout* vbox = qobject_cast<QVBoxLayout*>( layout() );
+ QBoxLayout* vbox = qobject_cast<QBoxLayout*>( layout() );
w->setParent( this );
vbox->addWidget( w );
myWidgets.insert( wid, w );
\brief Initialize the search tool widget.
\internal
*/
-void QtxSearchTool::init()
+void QtxSearchTool::init( Qt::Orientation orientation )
{
setFrameStyle( QFrame::StyledPanel | QFrame::Plain );
- QVBoxLayout* vbox = new QVBoxLayout();
- vbox->setSpacing( 0 );
- vbox->setMargin( 5 );
- setLayout( vbox );
myBtnWidget = new QWidget( this );
QHBoxLayout* myBtnWidget_layout = new QHBoxLayout( myBtnWidget );
myBtnWidget_layout->setSpacing( 0 );
myBtnWidget_layout->setMargin( 0 );
- vbox->addWidget( myBtnWidget );
myModWidget = new QWidget( this );
QHBoxLayout* myModWidget_layout = new QHBoxLayout( myModWidget );
myModWidget_layout->setSpacing( 0 );
myModWidget_layout->setMargin( 0 );
- vbox->addWidget( myModWidget );
myClose = new QToolButton( myBtnWidget );
myClose->setIcon( QIcon( close_xpm ) );
setShortcuts( QKeySequence( "Ctrl+S" ) );
setActivators( Any );
+
+ QBoxLayout* box = orientation == Qt::Vertical ? (QBoxLayout*)( new QVBoxLayout ) : (QBoxLayout*)( new QHBoxLayout );
+ box->setSpacing( 0 );
+ box->setMargin( 5 );
+ box->addWidget( myBtnWidget );
+ box->addWidget( myModWidget );
+ setLayout( box );
+
updateControls();
}
Any = HotKey | SlashKey | StandardKey | PrintKey //!< search tool is activated by any of above mentioned ways
} Activator;
- QtxSearchTool( QWidget*, QWidget* = 0, int = All );
- QtxSearchTool( QWidget*, int = All );
+ QtxSearchTool( QWidget*, QWidget* = 0, int = All, Qt::Orientation = Qt::Vertical );
+ QtxSearchTool( QWidget*, int = All, Qt::Orientation = Qt::Vertical );
virtual ~QtxSearchTool();
QWidget* watchedWidget() const;
void modifierSwitched();
private:
- void init();
+ void init( Qt::Orientation );
bool focused() const;
void clearShortcuts();
void initShortcuts( const QList<QKeySequence>& );
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 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: QtxWebBrowser.cxx
+// Author: Roman NIKOLAEV
+//
+#include "QtxWebBrowser.h"
+#include "QtxSearchTool.h"
+
+#include <QApplication>
+#include <QFileInfo>
+#include <QWebView>
+#include <QMenuBar>
+#include <QToolBar>
+#include <QMenu>
+#include <QStatusBar>
+#include <QVBoxLayout>
+
+/*!
+ \class WebViewSearcher
+ \brief A class is used with QtxSearchTool in order to search text within the web page
+ \internal
+*/
+class WebViewSearcher : public QtxSearchTool::Searcher
+{
+public:
+ WebViewSearcher( QWebView* );
+ ~WebViewSearcher();
+
+ bool find( const QString&, QtxSearchTool* );
+ bool findNext( const QString&, QtxSearchTool* );
+ bool findPrevious( const QString&, QtxSearchTool* );
+ bool findFirst( const QString&, QtxSearchTool* );
+ bool findLast( const QString&, QtxSearchTool* );
+
+private:
+ QWebView* myView;
+};
+
+WebViewSearcher::WebViewSearcher( QWebView* view ) : myView( view )
+{
+}
+
+WebViewSearcher::~WebViewSearcher()
+{
+}
+
+bool WebViewSearcher::find( const QString& text, QtxSearchTool* st )
+{
+ QWebPage::FindFlags fl = 0;
+ if ( st->isCaseSensitive() ) fl = fl | QWebPage::FindCaseSensitively;
+ if ( st->isSearchWrapped() ) fl = fl | QWebPage::FindWrapsAroundDocument;
+ return myView->findText( text, fl );
+}
+
+bool WebViewSearcher::findNext( const QString& text, QtxSearchTool* st )
+{
+ return find( text, st );
+}
+
+bool WebViewSearcher::findPrevious( const QString& text, QtxSearchTool* st )
+{
+ QWebPage::FindFlags fl = QWebPage::FindBackward;
+ if ( st->isCaseSensitive() ) fl = fl | QWebPage::FindCaseSensitively;
+ if ( st->isSearchWrapped() ) fl = fl | QWebPage::FindWrapsAroundDocument;
+ return myView->findText( text, fl );
+}
+
+bool WebViewSearcher::findFirst( const QString&, QtxSearchTool* )
+{
+ return false;
+}
+
+bool WebViewSearcher::findLast( const QString&, QtxSearchTool* )
+{
+ return false;
+}
+
+/*!
+ \class QtxWebBrowser
+
+ \brief The QtxWebBrowser provides a window that can display html pages.
+
+ Only one instance of the QtxWebBrowser class can be created. To access the browser
+ window, use static method QtxWebBrowser::webBrowser(), which creates an
+ instance of the QtxWebBrowser widget (if it is not yet created) and returns a
+ pointer to it.
+
+ You should not destroy this instance - it is done automatically after
+ closing of the browser window. To close window programmatically use
+ method close().
+
+ To set visual properties of the browser use static method setData().
+
+ The following sample demonstrates how to use web browser.
+ In this code the browser window is created, /data/index.html file is opened
+ and scrolled to the "anchor1" anchor on this page.
+
+ \code
+ int main(int argc, char *argv[])
+ {
+ QApplication app(argc, argv);
+
+ // set icon, title and menu items.
+ QtxWebBrowser::setData("browser:title", tr("Web Browser"));
+ QtxWebBrowser::setData("browser:icon", QPixmap(":/icon.png"));
+ QtxWebBrowser::setData("menu:file:title", tr("&File"));
+ QtxWebBrowser::setData("action:close:title", tr("&Close"));
+
+ // show HTML page
+ QtxWebBrowser::loadUrl("file:///data/index.html", "anchor1");
+
+ return app.exec();
+ }
+ \endcode
+
+*/
+
+//! The only one instance of web browser
+QtxWebBrowser* QtxWebBrowser::myBrowser = 0;
+
+//! Internal data map to store resources of the browser.
+QMap<QString, QVariant> QtxWebBrowser::myData;
+
+/*!
+ \brief Constructor.
+
+ Construct the web browser.
+*/
+QtxWebBrowser::QtxWebBrowser() : QMainWindow( 0 )
+{
+ setAttribute( Qt::WA_DeleteOnClose );
+ statusBar();
+
+ QWidget* frame = new QWidget( this );
+
+ myWebView = new QWebView( frame );
+ myWebView->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
+ myFindPanel = new QtxSearchTool( frame, myWebView,
+ QtxSearchTool::Basic | QtxSearchTool::Case | QtxSearchTool::Wrap,
+ Qt::Horizontal );
+ myFindPanel->setFrameStyle( QFrame::NoFrame | QFrame::Plain );
+ myFindPanel->setActivators( QtxSearchTool::SlashKey );
+ myFindPanel->setSearcher( new WebViewSearcher( myWebView ) );
+ myFindPanel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
+
+ myToolbar = addToolBar( tr( "Navigation" ) );
+ myToolbar->addAction( myWebView->pageAction( QWebPage::Back ) );
+ myToolbar->addAction( myWebView->pageAction( QWebPage::Forward ) );
+
+ myMenus[ File ] = menuBar()->addMenu( tr( "&File" ) );
+ myActions[ Find ] = myMenus[ File ]->addAction( tr( "&Find in text..." ), myFindPanel, SLOT( find() ), QKeySequence( QKeySequence::Find ) );
+ myActions[ FindNext ] = myMenus[ File ]->addAction( tr( "&Find next" ), myFindPanel, SLOT( findNext() ), QKeySequence( QKeySequence::FindNext ) );
+ myActions[ FindPrev ] = myMenus[ File ]->addAction( tr( "&Find previous" ), myFindPanel, SLOT( findPrevious() ), QKeySequence( QKeySequence::FindPrevious ) );
+ myMenus[ File ]->addSeparator();
+ myActions[ Close ] = myMenus[ File ]->addAction( tr( "&Close" ), this, SLOT( close() ) );
+
+ QVBoxLayout* main = new QVBoxLayout( frame );
+ main->addWidget( myWebView );
+ main->addWidget( myFindPanel );
+ main->setMargin( 0 );
+ main->setSpacing( 3 );
+
+ connect( myWebView, SIGNAL( titleChanged( QString ) ), SLOT( adjustTitle() ) );
+ connect( myWebView, SIGNAL( linkClicked( QUrl ) ), SLOT( linkClicked( QUrl ) ) );
+ connect( myWebView->page(), SIGNAL( linkHovered( QString, QString, QString ) ), SLOT( linkHovered( QString, QString, QString ) ) );
+
+ setCentralWidget( frame );
+ setFocusProxy( myWebView );
+ updateData();
+ qAddPostRoutine( QtxWebBrowser::clearData );
+}
+
+/*!
+ \brief Destructor.
+*/
+QtxWebBrowser::~QtxWebBrowser()
+{
+ myBrowser = 0;
+}
+
+/*!
+ \brief Return the only instance of the QtxWebBrowser
+ \return instance of the QtxWebBrowser
+*/
+QtxWebBrowser* QtxWebBrowser::webBrowser()
+{
+ if ( !myBrowser )
+ myBrowser = new QtxWebBrowser();
+ return myBrowser;
+}
+
+/*!
+ \brief Load given url address and optional scroll to the specified anchor
+ \param url an url address to load
+ \param anchor an anchor to scroll page to
+*/
+void QtxWebBrowser::loadUrl( const QString& url, const QString& anchor )
+{
+ QString anUrl = url;
+ if( !anchor.isEmpty() ) anUrl += "#" + anchor;
+
+ Qtx::alignWidget( webBrowser(), (QWidget*)QApplication::desktop(), Qtx::AlignCenter );
+
+ webBrowser()->show();
+ webBrowser()->myWebView->load( QUrl( anUrl ) );
+ webBrowser()->setFocus();
+ webBrowser()->activateWindow();
+ webBrowser()->raise();
+}
+
+/*!
+ \brief Set browser settings from.
+
+ This method can be used to setup the browser properties.
+ - \c "browser:title" : title of the browser window
+ - \c "browser:icon" : icon of the browser window
+ - \c "toolbar:title" : title of the toolbar
+ - \c "menu:file:title" : File menu of the browser
+ - \c "action:close:title" : File/Close menu item title
+ - \c "action:close:icon" : File/Close menu item icon
+ - \c "action:back:title" : Navigation/Back menu item title
+ - \c "action:back:icon" : Navigation/Back menu item icon
+ - \c "action:forward:title" : Navigation/Forward menu item title
+ - \c "action:forward:icon" : Navigation/Forward menu item icon
+ - \c "action:find:title" : File/Find menu item title
+ - \c "action:find:icon" : File/Find menu item icon
+ - \c "action:findnext:title" : File/Find Next menu item title
+ - \c "action:findnext:icon" : File/Find Next menu item icon
+ - \c "action:findprev:title" : File/Find Previous menu item title
+ - \c "action:findprev:icon" : File/Find Previous menu item icon
+
+ \param key name of the property
+ \param val value of the property
+
+*/
+void QtxWebBrowser::setData( const QString& key, const QVariant& val )
+{
+ myData.insert( key, val );
+ if ( myBrowser ) myBrowser->updateData();
+}
+
+/*!
+ \brief Get string value by key from the internal data map
+ \param key data key identifier
+ \return string value assigned to the key (null string if data is not assigned to the key)
+ \internal
+*/
+QString QtxWebBrowser::getStringValue( const QString& key )
+{
+ QString val;
+ if ( myData.contains( key ) && myData[key].canConvert( QVariant::String ) )
+ val = myData[key].toString();
+ return val;
+}
+
+/*!
+ \brief Get icon value by key from the internal data map
+ \param key data key identifier
+ \return icon assigned to the key (null icon if data is not assigned to the key)
+ \internal
+*/
+QIcon QtxWebBrowser::getIconValue(const QString& key)
+{
+ QIcon val;
+ if ( myData.contains( key ) ) {
+ if ( myData[key].canConvert( QVariant::Pixmap ) )
+ val = myData[key].value<QPixmap>();
+ else if ( myData[key].canConvert( QVariant::Icon ) )
+ val = myData[key].value<QIcon>();
+ }
+ return val;
+}
+
+/*!
+ \brief Update web browser properties from internal data map
+*/
+void QtxWebBrowser::updateData()
+{
+ // main title
+ adjustTitle();
+
+ // window icon
+ QIcon icon = getIconValue( "browser:icon" );
+ if ( !icon.isNull() )
+ setWindowIcon( icon );
+
+ // toolbar title
+ QString tbTitle = getStringValue( "toolbar:title" );
+ if ( myToolbar && !tbTitle.isEmpty() )
+ myToolbar->setWindowTitle( tbTitle );
+
+ // File menu
+ QString fmenu = getStringValue( "menu:file:title" );
+ if ( myMenus.contains( File ) && !fmenu.isEmpty() )
+ myMenus[ File ]->setTitle( fmenu );
+
+ // File/Close menu
+ QString closeTlt = getStringValue( "action:close:title" );
+ QIcon closeIco = getIconValue( "action:close:icon" );
+ if ( myActions.contains( Close ) ) {
+ if ( !closeTlt.isEmpty() )
+ myActions[ Close ]->setText( closeTlt );
+ if ( !closeIco.isNull() )
+ myActions[ Close ]->setIcon( closeIco );
+ }
+
+ // Navigation/Go Back menu
+ QString backTlt = getStringValue( "action:back:title" );
+ QIcon backIco = getIconValue( "action:back:icon" );
+ if ( !backTlt.isEmpty() )
+ myWebView->pageAction( QWebPage::Back )->setText( backTlt );
+ if ( !backIco.isNull() )
+ myWebView->pageAction( QWebPage::Back )->setIcon( backIco );
+
+ // Navigation/Go Forward menu
+ QString fwdTlt = getStringValue( "action:forward:title" );
+ QIcon fwdIco = getIconValue( "action:forward:icon" );
+ if ( !fwdTlt.isEmpty() )
+ myWebView->pageAction( QWebPage::Forward )->setText( fwdTlt );
+ if ( !fwdIco.isNull() )
+ myWebView->pageAction( QWebPage::Forward )->setIcon( fwdIco );
+
+ // File/Find menu
+ QString findTlt = getStringValue( "action:find:title" );
+ QIcon findIco = getIconValue( "action:find:icon" );
+ if ( myActions.contains( Find ) ) {
+ if ( !findTlt.isEmpty() )
+ myActions[ Find ]->setText( findTlt );
+ if ( !findIco.isNull() )
+ myActions[ Find ]->setIcon( findIco );
+ }
+
+ // File/Find Next menu
+ QString findNextTlt = getStringValue( "action:findnext:title" );
+ QIcon findNextIco = getIconValue( "action:findnext:icon" );
+ if ( myActions.contains( FindNext ) ) {
+ if ( !findNextTlt.isEmpty() )
+ myActions[ FindNext ]->setText( findNextTlt );
+ if ( !findNextIco.isNull() )
+ myActions[ FindNext ]->setIcon( findNextIco );
+ }
+
+ // File/Find Previous menu
+ QString findPrevTlt = getStringValue( "action:findprev:title" );
+ QIcon findPrevIco = getIconValue( "action:findprev:icon" );
+ if ( myActions.contains( FindPrev ) ) {
+ if ( !findPrevTlt.isEmpty() )
+ myActions[ FindPrev ]->setText( findPrevTlt );
+ if ( !findPrevIco.isNull() )
+ myActions[ FindPrev ]->setIcon( findPrevIco );
+ }
+}
+
+/*!
+ \brief Clear internal data map
+ \internal
+*/
+void QtxWebBrowser::clearData()
+{
+ myData.clear();
+}
+
+/*!
+ \brief Called when users activated any link at the page
+ \param url URL being clicked
+ \internal
+*/
+void QtxWebBrowser::linkClicked( const QUrl& url )
+{
+ myWebView->page()->setLinkDelegationPolicy( QWebPage::DontDelegateLinks );
+ myWebView->load( url );
+ if ( url.scheme() == "file" ) {
+ QString filename = url.toLocalFile();
+ if ( QFileInfo( filename ).suffix().toLower() == "pdf" ) {
+#ifdef WIN32
+ ::system( QString( "start %2" ).arg( filename ).toLatin1().constData() );
+#else
+ // special processing of PDF files
+ QStringList readers;
+ readers << "xdg-open" << "acroread" << "kpdf" << "kghostview" << "xpdf";
+ foreach ( QString r, readers ) {
+ QString reader = QString( "/usr/bin/%1" ).arg( r );
+ if ( QFileInfo( reader ).exists() ) {
+ ::system( QString( "unset LD_LIBRARY_PATH; %1 %2 &" ).arg( reader ).arg( url.toLocalFile() ).toLatin1().constData() );
+ break;
+ }
+ }
+#endif // WIN32
+ }
+ }
+ myWebView->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
+}
+
+/*!
+ \brief Called when link is hovered
+ \param link link being hovered
+ \param title link title (if it is specified in the markup)
+ \param content provides text within the link element, e.g., text inside an HTML anchor tag
+ \internal
+*/
+void QtxWebBrowser::linkHovered( const QString& link, const QString& /*title*/, const QString& /*context*/ )
+{
+ statusBar()->showMessage( link );
+}
+
+/*!
+ \brief Update title of the window
+ \internal
+*/
+void QtxWebBrowser::adjustTitle()
+{
+ QString title = getStringValue( "browser:title" );
+ setWindowTitle( title.isEmpty() ? myWebView->title() : title + QString( " [%1]" ).arg( myWebView->title() ) );
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 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: QtxWebBrowser.h
+// Author: Roman NIKOLAEV
+//
+
+#ifndef QTXWEBBROWSER_H
+#define QTXWEBBROWSER_H
+
+#include "Qtx.h"
+
+#include <QMainWindow>
+#include <QMap>
+
+class QAction;
+class QMenu;
+class QToolBar;
+class QWebView;
+class QUrl;
+class QtxSearchTool;
+
+class QTX_EXPORT QtxWebBrowser : public QMainWindow
+{
+ Q_OBJECT
+
+ enum { File };
+ enum { Find, FindNext, FindPrev, Close };
+
+private:
+ QtxWebBrowser();
+
+public:
+ virtual ~QtxWebBrowser();
+
+ static QtxWebBrowser* webBrowser();
+ static void loadUrl( const QString&, const QString& = QString() );
+ static void setData( const QString&, const QVariant& );
+
+private:
+ static QString getStringValue( const QString& );
+ static QIcon getIconValue( const QString& );
+ void updateData();
+ static void clearData();
+
+protected slots:
+ virtual void linkClicked( const QUrl& );
+ virtual void linkHovered( const QString&, const QString&, const QString& );
+
+private slots:
+ void adjustTitle();
+
+private:
+ static QMap<QString, QVariant> myData;
+ static QtxWebBrowser* myBrowser;
+ QWebView* myWebView;
+ QToolBar* myToolbar;
+ QMap<int, QMenu*> myMenus;
+ QMap<int, QAction*> myActions;
+ QtxSearchTool* myFindPanel;
+};
+
+#endif // QTXWEBBROWSER_H
</message>
<message>
<source>Wrap search</source>
- <translation>Terminer la recherche</translation>
+ <translation>Continuer la recherche</translation>
</message>
</context>
<context>
<name>QxScene_ViewManager</name>
<message>
<source>QXSCENE_VIEW_TITLE</source>
- <translation>QGraphics scène:%M - visualisateur:%V</translation>
+ <translation>Scène QGraphics:%M - visualisateur:%V</translation>
</message>
</context>
</TS>
The number of parameters is limeted only by maximum possible length of the command line.
*/
+#include "GUI_version.h"
#include "SUIT_ResourceMgr.h"
#include <QFile>
#include <QDir>
*/
static QString salomeVersion()
{
- QString path( ::getenv( "GUI_ROOT_DIR" ) );
- if ( !path.isEmpty() )
- path += QDir::separator();
- path += QString( "bin/salome/VERSION" );
-
- QFile vf( path );
- if ( !vf.open( QIODevice::ReadOnly ) )
- return QString();
-
- QString line( vf.readLine( 1024 ) );
- vf.close();
-
- if ( line.isEmpty() )
- return QString();
-
- while ( !line.isEmpty() && line.at( line.length() - 1 ) == QChar( '\n' ) )
- line.remove( line.length() - 1, 1 );
-
- QString ver;
- int idx = line.lastIndexOf( ":" );
- if ( idx != -1 )
- ver = line.mid( idx + 1 ).trimmed();
-
- return ver;
+ return GUI_VERSION_STR;
}
/*!
{
SUIT_ViewWindow* resWnd = 0;
- LightApp_Application* app = getApplication();
+ LightApp_Application* app = getApplication();
if ( app )
{
- STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>( app->desktop() );
- if ( tabDesk )
+ ViewManagerList vmlist = app->viewManagers();
+ foreach( SUIT_ViewManager* vm, vmlist )
{
- QList<SUIT_ViewWindow*> wndlist = tabDesk->windows();
- SUIT_ViewWindow* wnd;
- foreach ( wnd, wndlist )
+ QVector<SUIT_ViewWindow*> vwlist = vm->getViews();
+ foreach ( SUIT_ViewWindow* vw, vwlist )
{
- if ( id == wnd->getId() )
+ if ( id == vw->getId() )
{
- resWnd = wnd;
+ resWnd = vw;
break;
}
}
{
Handle(AIS_Trihedron) aTrh = Handle(AIS_Trihedron)::DownCast( anAIS );
double aNewSize = 100, aSize = 100;
- getTrihedronSize( aNewSize, aSize );
+ computeTrihedronSize( aNewSize, aSize );
aTrh->SetSize( aTrh == getTrihedron() ? aNewSize : 0.5 * aNewSize );
}
ic->Deactivate( anAIS );
}
}
+ updateTrihedron();
}
//}
}
}
+ updateTrihedron();
}
// }
//}
}
-
+
Repaint();
+ updateTrihedron();
}
/*!
}
}
-/*!
- Get new and current trihedron size corresponding to the current model size
-*/
-bool SOCC_Viewer::getTrihedronSize( double& theNewSize, double& theSize )
-{
- theNewSize = 100;
- theSize = 100;
-
- //SRN: BUG IPAL8996, a usage of method ActiveView without an initialization
- Handle(V3d_Viewer) viewer = getViewer3d();
- viewer->InitActiveViews();
- if(!viewer->MoreActiveViews()) return false;
-
- Handle(V3d_View) view3d = viewer->ActiveView();
- //SRN: END of fix
-
- if ( view3d.IsNull() )
- return false;
-
- double Xmin = 0, Ymin = 0, Zmin = 0, Xmax = 0, Ymax = 0, Zmax = 0;
- double aMaxSide;
-
- view3d->View()->MinMaxValues( Xmin, Ymin, Zmin, Xmax, Ymax, Zmax );
-
- if ( Xmin == RealFirst() || Ymin == RealFirst() || Zmin == RealFirst() ||
- Xmax == RealLast() || Ymax == RealLast() || Zmax == RealLast() )
- return false;
-
- aMaxSide = Xmax - Xmin;
- if ( aMaxSide < Ymax -Ymin ) aMaxSide = Ymax -Ymin;
- if ( aMaxSide < Zmax -Zmin ) aMaxSide = Zmax -Zmin;
-
- // IPAL21687
- // The boundary box of the view may be initialized but nullified
- // (case of infinite objects)
- if ( aMaxSide < Precision::Confusion() )
- return false;
-
- float aSizeInPercents = SUIT_Session::session()->resourceMgr()->doubleValue("Viewer","TrihedronSize", 105.);
-
- static float EPS = 5.0E-3;
- theSize = getTrihedron()->Size();
- theNewSize = aMaxSide*aSizeInPercents / 100.0;
-
- return fabs( theNewSize - theSize ) > theSize * EPS ||
- fabs( theNewSize - theSize) > theNewSize * EPS;
-}
/*!
\Collect objects visible in viewer
virtual void GetVisible( SALOME_ListIO& );
virtual void Repaint();
- // a utility function, used by SALOME_View_s methods
- bool getTrihedronSize( double& theNewSize, double& theSize );
-
//a map to store AIS objects associated to a SALOME entry
std::map< std::string , std::vector<Handle(AIS_InteractiveObject)> > entry2aisobjects;
};
#include "SUIT_ViewManager.h"
#include "SALOME_ListIO.hxx"
+#include "SALOME_ListIteratorOfListIO.hxx"
#include <QApplication>
#include <QToolBar>
emit legendSelected( anEntry );
}
}
+
+/*!
+
+*/
+void SPlot2d_Viewer::setObjectsSelected( SALOME_ListIO& theList ) {
+ Plot2d_ViewFrame* aViewFrame = getActiveViewFrame();
+ if(aViewFrame) {
+
+ objectList allObjects;
+ aViewFrame->getObjects( allObjects );
+
+ bool isSelected = false;
+ SPlot2d_Histogram* h = 0;
+ SPlot2d_Curve* c =0;
+
+ foreach ( Plot2d_Object* o, allObjects ) {
+ isSelected = false;
+
+ Handle(SALOME_InteractiveObject) io;
+ if( (h = dynamic_cast<SPlot2d_Histogram*>(o)) && h->hasIO() ) {
+ io = h->getIO();
+ } else if((c = dynamic_cast<SPlot2d_Curve*>(o)) && c->hasIO()) {
+ io = c->getIO();
+ } else {
+ continue;
+ }
+
+ SALOME_ListIteratorOfListIO anIter( theList );
+
+ for( ; anIter.More(); anIter.Next() ) {
+ if ( anIter.Value()->hasEntry() ) {
+ if( io->isSame(anIter.Value()) ) {
+ isSelected = o->isSelected();
+ if( !isSelected ) {
+ o->setSelected(true);
+ aViewFrame->updateObject(o);
+ theList.Remove(anIter);
+ isSelected = true;
+ break;
+ } else
+ break;
+ }
+ }
+ }
+ if( !isSelected && o->isSelected() != false ) {
+ o->setSelected(false);
+ aViewFrame->updateObject(o);
+ }
+ }
+ aViewFrame->Repaint();
+ }
+}
virtual bool isVisible( const Handle(SALOME_InteractiveObject)& IObject );
virtual void GetVisible( SALOME_ListIO& theList );
+ virtual void setObjectsSelected( SALOME_ListIO& theList );
+
/* operations */
SPlot2d_Curve* getCurveByIO( const Handle(SALOME_InteractiveObject)&, Plot2d_ViewFrame* = 0 );
SUIT_ShortcutMgr* shortcutMgr() const;
//! Puts the message to the status bar
- void putInfo ( const QString&, const int = 0 );
+ void putInfo ( const QString&, const int = 0 );
//! Invokes application-specific "Open/Save File" dialog and returns the selected file name.
- virtual QString getFileName( bool open, const QString& initial, const QString& filters,
- const QString& caption, QWidget* parent ) = 0;
+ virtual QString getFileName( bool open, const QString& initial, const QString& filters,
+ const QString& caption, QWidget* parent ) = 0;
//! Invokes application-specific "Select Directory" dialog and returns the selected directory name.
- virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent ) = 0;
+ virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent ) = 0;
- virtual int viewManagerId ( const SUIT_ViewManager* ) const = 0;
+ virtual int viewManagerId ( const SUIT_ViewManager* ) const = 0;
+ virtual void viewManagers( const QString&, QList<SUIT_ViewManager*>& ) const = 0;
+ QAction* action( const int ) const;
signals:
void applicationClosed( SUIT_Application* );
void setActionShown( const int, const bool );
static QAction* separator();
- QAction* action( const int ) const;
int actionId( const QAction* ) const;
QList<QAction*> actions() const;
// 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 : SUIT_DataObject.cxx
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
-//
#include <QVariant>
}
/*!
- \brief Check if the drop operation fo this object is possible.
+ \brief Check if the drop operation for this object is possible.
This method can be re-implemented in the subclasses.
Default implementation returns \c false (drop operation is not allowed).
- \param obj object being dropped
- \return \c true if it is possible to drop an object \c obj
- to this object
+ \return \c true if it is possible to drop one or more objects (currently selected) to this object
*/
-
-bool SUIT_DataObject::isDropAccepted( SUIT_DataObject* /*obj*/ )
+bool SUIT_DataObject::isDropAccepted()
{
return false;
}
// 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 : SUIT_DataObject.h
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
-//
+
#ifndef SUIT_DATAOBJECT_H
#define SUIT_DATAOBJECT_H
#pragma warning( disable:4251 )
#endif
-class SUIT_EXPORT SUIT_DataObject
+class SUIT_EXPORT SUIT_DataObject
{
public:
class Signal;
//! Color role
- typedef enum {
+ typedef enum {
Text, //!< editor foreground (text) color
Base, //!< editor background color
Foreground, //!< foreground (text) color
//! Column id
enum
- {
+ {
NameId, //!< name column
VisibilityId //!< visibility state column
};
virtual void children( DataObjectList&, const bool = false ) const;
virtual DataObjectList children( const bool = false );
-
+
void appendChild( SUIT_DataObject* );
virtual void insertChild( SUIT_DataObject*, int );
virtual void removeChild( SUIT_DataObject*, const bool = false );
virtual bool expandable() const;
virtual bool isVisible() const;
virtual bool isDragable() const;
- virtual bool isDropAccepted( SUIT_DataObject* obj );
+ virtual bool isDropAccepted();
virtual bool isEnabled() const;
virtual bool isSelectable() const;
virtual bool compare( const QVariant&, const QVariant&, const int = NameId ) const;
virtual SUIT_DataObjectKey* key() const;
- virtual int groupId() const;
+ virtual int groupId() const;
virtual QVariant customData(Qtx::CustomDataType /*type*/);
static Signal* signal();
case ShortcutTree:
item = new QtxPagePrefShortcutTreeItem( title, parent, sect, param );
break;
+ case BiColor:
+ item = new QtxPagePrefBiColorItem( title, parent, sect, param );
+ break;
case UserDefined:
item = new QtxUserDefinedItem(parent);
break;
public:
typedef enum { Auto, Space, Bool, Color, String, Selector,
DblSpin, IntSpin, Double, Integer,
- GroupBox, Tab, Frame, Font, DirList, File, Slider, Shortcut, ShortcutTree,
+ GroupBox, Tab, Frame, Font, DirList, File, Slider, Shortcut, ShortcutTree, BiColor,
UserDefined = 1000 } PrefItemType;
public:
*/
QString SUIT_ResourceMgr::findAppropriateUserFile( const QString& fname ) const
{
- QDir d( QFileInfo( fname ).dir() );
- d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
- QStringList l = d.entryList();
QString appr_file;
- int id0 = userFileId( fname ), id, appr=-1;
- if( id0<0 )
+
+ // calculate default file id from user file name
+ long id0 = userFileId( fname );
+ if ( id0 < 0 ) // can't calculate file id from user file name, no further processing
return appr_file;
- for( QStringList::const_iterator anIt = l.begin(), aLast = l.end(); anIt!=aLast; anIt++ )
- {
- id = userFileId( *anIt );
- if( id<0 )
- continue;
+ long id, appr = -1;
+
+ // get all files from the same dir where use file is (should be) situated
+ QDir d( QFileInfo( fname ).dir() );
+ if ( d.exists() ) {
+ d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
+ QStringList l = d.entryList();
+ for( QStringList::const_iterator anIt = l.begin(), aLast = l.end(); anIt!=aLast; anIt++ )
+ {
+ id = userFileId( *anIt );
+ if ( id < 0 )
+ continue;
+ if( appr < 0 || qAbs( id-id0 ) < qAbs( appr-id0 ) )
+ {
+ appr = id;
+ appr_file = d.absoluteFilePath( *anIt );
+ }
+ }
+ }
+
+ // backward compatibility: check also user's home directory (if it differs from above one)
+ QDir home = QDir::home();
+ if ( home.exists() && d.canonicalPath() != home.canonicalPath() ) {
+ home.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
+ QStringList l = home.entryList();
- if( appr < 0 || abs( id-id0 ) < abs( appr-id0 ) )
+ for( QStringList::const_iterator anIt = l.begin(), aLast = l.end(); anIt!=aLast; anIt++ )
{
- appr = id;
- appr_file = d.absoluteFilePath( *anIt );
+ id = userFileId( *anIt );
+ if ( id < 0 )
+ continue;
+ if( appr < 0 || qAbs( id-id0 ) < qAbs( appr-id0 ) )
+ {
+ appr = id;
+ appr_file = home.absoluteFilePath( *anIt );
+ }
}
}
+
return appr_file;
}
/*!
Calculates integer extended version number by user file name for comparing
*/
-int SUIT_ResourceMgr::userFileId( const QString& ) const
+long SUIT_ResourceMgr::userFileId( const QString& ) const
{
return -1;
}
protected:
virtual QString userFileName( const QString&, const bool = true ) const;
virtual QString findAppropriateUserFile( const QString& ) const;
- virtual int userFileId( const QString& ) const;
+ virtual long userFileId( const QString& ) const;
private:
QString myVersion;
// 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: SUIT_TreeModel.cxx
// Author: Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
-//
+
#include "SUIT_Session.h"
#include "SUIT_TreeModel.h"
#include "SUIT_TreeSync.h"
#include "SUIT_DataObject.h"
#include "SUIT_ResourceMgr.h"
-
#include <QApplication>
#include <QHash>
+#include <QMimeData>
SUIT_AbstractModel::SUIT_AbstractModel() : mySearcher( 0 )
{
return QVariant();
SUIT_DataObject* obj = object( index );
+ if ( !obj )
+ return QVariant();
QColor c;
QVariant val;
*/
Qt::ItemFlags SUIT_TreeModel::flags( const QModelIndex& index ) const
{
+ /*
if ( !index.isValid() )
return 0;
if ( obj->renameAllowed( index.column() ) )
f = f | Qt::ItemIsEditable;
}
+
return f;
+ */
+
+ Qt::ItemFlags f = 0;
+
+ if (!index.isValid())
+ //return Qt::ItemIsDropEnabled; // items can be dropped into the top level of the model
+ return f;
+
+ SUIT_DataObject* obj = object(index);
+
+ if (obj) {
+ // data object is enabled
+ if (obj->isEnabled())
+ f = f | Qt::ItemIsEnabled;
+
+ // data object is selectable
+ if (obj->isSelectable())
+ f = f | Qt::ItemIsSelectable;
+
+ // data object is checkable
+ if (obj->isCheckable(index.column()))
+ f = f | Qt::ItemIsUserCheckable;
+
+ // data object can be renamed
+ if (obj->renameAllowed(index.column()))
+ f = f | Qt::ItemIsEditable;
+
+ // data object can be dragged
+ if (obj->isDragable())
+ f = f | Qt::ItemIsDragEnabled;
+
+ // another data object(s) can be dropped on this one
+ if (obj->isDropAccepted())
+ f = f | Qt::ItemIsDropEnabled;
+ }
+
+ return f;
+}
+
+Qt::DropActions SUIT_TreeModel::supportedDropActions() const
+{
+ return Qt::CopyAction | Qt::MoveAction;
+}
+
+//This function is never called
+bool SUIT_TreeModel::removeRows(int row, int count, const QModelIndex &parent)
+{
+ qDebug("Remove");
+ if (parent.isValid())
+ return FALSE;
+
+ beginRemoveRows(parent, row, row + count - 1);
+
+ for (int i = 0; i < count; ++i){
+ //delete m_pAllData->takeAt(row);
+ }
+
+ endRemoveRows();
+ return TRUE;
}
/*!
updateTree( parent );
}
+/*!
+ \brief Drag and Drop support.
+*/
+QStringList SUIT_TreeModel::mimeTypes() const
+{
+ QStringList types;
+ types << "application/vnd.text.list";
+ return types;
+}
+
+/*!
+ \brief Called when the data objects are exported(dragged) from the tree.
+ \param indexes the list of exported objects
+*/
+QMimeData* SUIT_TreeModel::mimeData (const QModelIndexList &indexes) const
+{
+ QMimeData *mimeData = new QMimeData();
+ QByteArray encodedData;
+
+ QDataStream stream (&encodedData, QIODevice::WriteOnly);
+
+ foreach (QModelIndex index, indexes) {
+ if (index.isValid()) {
+ if (index.column() == 0) {
+ SUIT_DataObject* aDObj = object(index);
+ QString anEntry = aDObj->text(SUIT_DataObject::VisibilityId + 1);
+ stream << anEntry;
+ }
+ }
+ }
+
+ mimeData->setData("application/vnd.text.list", encodedData);
+ return mimeData;
+}
+
+bool SUIT_TreeModel::dropMimeData (const QMimeData* data, Qt::DropAction action,
+ int row, int column, const QModelIndex& parent)
+{
+ emit dropped(data, action, row, column, parent);
+
+ return true;
+}
+
/*!
\class SUIT_ProxyModel
- \brief Proxy model which can be used above the SUIT_TreeMovel class
+ \brief Proxy model which can be used above the SUIT_TreeModel class
to enable custom sorting/filtering of the data.
The SUIT_TreeModel class does not support custom sorting/filtering of the data.
SUIT_TreeModel* model = new SUIT_TreeModel( this );
connect( model, SIGNAL( modelUpdated() ), this, SIGNAL( modelUpdated() ) );
connect( model, SIGNAL( clicked(SUIT_DataObject*, int) ), this, SIGNAL(clicked(SUIT_DataObject*, int) ) );
+ connect( model, SIGNAL( dropped(const QMimeData*, Qt::DropAction, int, int, const QModelIndex&) ),
+ //this, SIGNAL( dropped(const QMimeData*, Qt::DropAction, int, int, const QModelIndex&) ));
+ this, SLOT( onDropped(const QMimeData*, Qt::DropAction, int, int, const QModelIndex&) ));
setSourceModel( model );
setDynamicSortFilter( true );
}
SUIT_TreeModel* model = new SUIT_TreeModel( root, this );
connect( model, SIGNAL( modelUpdated() ), this, SIGNAL( modelUpdated() ) );
connect( model, SIGNAL( clicked(SUIT_DataObject*, int) ), this, SIGNAL(clicked(SUIT_DataObject*, int) ) );
+ connect( model, SIGNAL( dropped(const QMimeData*, Qt::DropAction, int, int, const QModelIndex&) ),
+ //this, SIGNAL( dropped(const QMimeData*, Qt::DropAction, int, int, const QModelIndex&) ));
+ this, SLOT( onDropped(const QMimeData*, Qt::DropAction, int, int, const QModelIndex&) ));
setSourceModel( model );
setDynamicSortFilter( true );
}
{
connect( *model, SIGNAL( modelUpdated() ), this, SIGNAL( modelUpdated() ) );
connect( *model, SIGNAL( clicked(SUIT_DataObject*, int) ), this, SIGNAL(clicked(SUIT_DataObject*, int) ) );
+ connect( *model, SIGNAL( dropped(const QMimeData*, Qt::DropAction, int, int, const QModelIndex&) ),
+ //this, SIGNAL( dropped(const QMimeData*, Qt::DropAction, int, int, const QModelIndex&) ));
+ this, SLOT( onDropped(const QMimeData*, Qt::DropAction, int, int, const QModelIndex&) ));
setSourceModel( *model );
setDynamicSortFilter( true );
}
treeModel()->emitClicked(obj,index);
}
+void SUIT_ProxyModel::onDropped (const QMimeData* data, Qt::DropAction action,
+ int row, int column, const QModelIndex& parent)
+{
+ emit dropped(data, action, row, column, mapFromSource(parent));
+}
+
/*!
\class SUIT_ItemDelegate
\brief An SUIT_DataObject-based item delegate class.
// 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: SUIT_TreeModel.h
// Author: Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
-//
+
#ifndef SUIT_TREEMODEL_H
#define SUIT_TREEMODEL_H
class SUIT_DataObject;
class SUIT_TreeModel;
+class QMimeData;
class SUIT_EXPORT SUIT_DataSearcher
{
virtual Qt::ItemFlags flags( const QModelIndex& ) const;
virtual QVariant headerData( int, Qt::Orientation, int = Qt::DisplayRole ) const;
+ virtual Qt::DropActions supportedDropActions() const;
+ virtual bool removeRows(int row, int count, const QModelIndex &parent);
+
virtual QModelIndex index( int, int, const QModelIndex& = QModelIndex() ) const;
virtual QModelIndex parent( const QModelIndex& ) const;
virtual void updateTreeModel(SUIT_DataObject*,TreeItem*);
+ virtual QStringList mimeTypes() const;
+ virtual QMimeData* mimeData (const QModelIndexList& indexes) const;
+ virtual bool dropMimeData (const QMimeData *data, Qt::DropAction action,
+ int row, int column, const QModelIndex &parent);
+
public slots:
virtual void updateTree( const QModelIndex& );
virtual void updateTree( SUIT_DataObject* = 0 );
signals:
void modelUpdated();
void clicked( SUIT_DataObject*, int );
+ void dropped( const QMimeData*, Qt::DropAction, int, int, const QModelIndex& );
private:
void initialize();
virtual void updateTree( const QModelIndex& );
virtual void updateTree( SUIT_DataObject* = 0 );
void setSortingEnabled( bool );
+ void onDropped( const QMimeData*, Qt::DropAction, int, int, const QModelIndex& );
signals:
void modelUpdated();
void clicked( SUIT_DataObject*, int );
+ void dropped( const QMimeData*, Qt::DropAction, int, int, const QModelIndex& );
protected:
SUIT_AbstractModel* treeModel() const;
//#endif //#if defined WIN32
+#include "GUI_version.h"
#include "SUITApp_Application.h"
-
-#include <SUIT_Session.h>
-#include <SUIT_Desktop.h>
-#include <SUIT_ResourceMgr.h>
-#include <Style_Salome.h>
-#include <QtxSplash.h>
-
-#include <SUIT_LicenseDlg.h>
+#include "SUIT_Desktop.h"
+#include "SUIT_LicenseDlg.h"
+#include "SUIT_ResourceMgr.h"
+#include "SUIT_Session.h"
+#include "Style_Salome.h"
+#include "QtxSplash.h"
#include <QDir>
#include <QFile>
static QString salomeVersion()
{
- QString path( ::getenv( "GUI_ROOT_DIR" ) );
- if ( !path.isEmpty() )
- path += QDir::separator();
-
- path += QString( "bin/salome/VERSION" );
-
- QFile vf( path );
- if ( !vf.open( QFile::ReadOnly ) )
- return QString();
-
- QString line = vf.readLine( 1024 );
- vf.close();
-
- if ( line.isEmpty() )
- return QString();
-
- while ( !line.isEmpty() && line.at( line.length() - 1 ) == QChar( '\n' ) )
- line.remove( line.length() - 1, 1 );
-
- QString ver;
- int idx = line.lastIndexOf( ":" );
- if ( idx != -1 )
- ver = line.mid( idx + 1 ).trimmed();
+ return GUI_VERSION_STR;
+}
- return ver;
+static QString getAppName( const QString& libName )
+{
+ QString appName = QFileInfo( libName ).baseName();
+ if ( appName.startsWith( "lib" ) ) appName = appName.mid( 3 );
+ return appName;
}
// static void MessageOutput( QtMsgType type, const char* msg )
bool iniFormat = false;
bool noSplash = false;
bool useLicense = false;
- for ( int i = 1; i < argc /*&& !noExceptHandling*/; i++ )
+ for ( int i = 1; i < argc; i++ )
{
if ( !strcmp( argv[i], "--noexcepthandling" ) )
noExceptHandling = true;
iniFormat = true;
else if ( !strcmp( argv[i], "--nosplash") )
noSplash = true;
- else if ( !strcmp( argv[i], "--uselicense" ) )
+ else if ( !strcmp( argv[i], "--uselicense" ) )
useLicense = true;
- else
+ else
argList.append( QString( argv[i] ) );
}
QApplication::addLibraryPath( QDir( qtdir ).absoluteFilePath( "plugins" ) );
SUITApp_Application app( argc, argv );
+ QString cfgAppName = getAppName( argList.isEmpty() ? QString() : argList.first() );
+ // hard-coding for LightApp :( no other way to this for the moment
+ if ( cfgAppName == "LightApp" ) {
+ app.setOrganizationName( "salome" );
+ app.setApplicationName( "salome" );
+ app.setApplicationVersion( salomeVersion() );
+ }
int result = -1;
resources/vtk_view_recording_start.png \
resources/vtk_view_recording_play.png \
resources/vtk_view_recording_pause.png \
- resources/vtk_view_recording_stop.png
+ resources/vtk_view_recording_stop.png \
+ resources/vtk_view_sync.png \
+ resources/vtk_view_highlight.png
nodist_salomeres_DATA = \
SVTK_msg_en.qm \
SetFocalPointSelected,
StartFocalPointSelection,
FocalPointChanged,
+
+ OperationFinished, // rnv: invoked then SpinXY, RotateXY, DollyXY or PanXY operation is finished.
LastEvent
};
GetCurrentRenderer()->ResetCameraClippingRange();
this->Render();
+ this->InvokeEvent(SVTK::OperationFinished,NULL);
}
void SVTK_InteractorStyle::PanXY(int x, int y, int oldX, int oldY)
{
TranslateView(x, y, oldX, oldY);
this->Render();
+ this->InvokeEvent(SVTK::OperationFinished,NULL);
}
void SVTK_InteractorStyle::DollyXY(int dx, int dy)
}
this->Render();
+ this->InvokeEvent(SVTK::OperationFinished,NULL);
}
void SVTK_InteractorStyle::SpinXY(int x, int y, int oldX, int oldY)
cam->OrthogonalizeViewUp();
this->Render();
+ this->InvokeEvent(SVTK::OperationFinished,NULL);
}
myCellPicker(vtkCellPicker::New())
{
mySelectionMode = ActorSelection;
+ myDynamicPreselection = true;
myPicker->Delete();
myCellPicker->Delete();
SVTK_SelectorDef
::Pick(const SVTK_SelectionEvent* theEvent, vtkRenderer* theRenderer) const
{
- bool anAdvancedSelectionAlgorithm = true;
- SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
- if ( aResourceMgr )
- anAdvancedSelectionAlgorithm = aResourceMgr->booleanValue( "VTKViewer", "use_advanced_selection_algorithm", true );
-
vtkActorCollection* aListActors = NULL;
- if ( anAdvancedSelectionAlgorithm ) {
+
+ if ( GetDynamicPreSelection() ) {
myCellPicker->Pick(theEvent->myX,
theEvent->myY,
0.0,
myPicker->SetTolerance(theTolerance);
myCellPicker->SetTolerance(theTolerance);
}
+
+void
+SVTK_SelectorDef
+::SetDynamicPreSelection( bool theIsDynPreselect )
+{
+ myDynamicPreselection = theIsDynPreselect;
+}
+
+bool
+SVTK_SelectorDef
+::GetDynamicPreSelection() const
+{
+ return myDynamicPreselection;
+}
virtual
void
SetTolerance(const double& theTolerance) = 0;
+
+ virtual
+ void
+ SetDynamicPreSelection( bool theIsDynPreselect ) = 0;
+
+ virtual
+ bool
+ GetDynamicPreSelection() const = 0;
};
void
SetTolerance(const double& theTolerance);
+ virtual
+ void
+ SetDynamicPreSelection( bool theIsDynPreselect );
+
+ virtual
+ bool
+ GetDynamicPreSelection() const;
+
private:
int mySelectionMode;
+ bool myDynamicPreselection;
+
struct TIOLessThan
{
bool
myProjMode = 0;
myStyle = 0;
myZoomingStyle = 0;
+ myDynamicPreSelection = false;
mySpaceBtn[0] = 1;
mySpaceBtn[1] = 2;
mySpaceBtn[2] = 9;
aViewWindow->SetProjectionMode( projectionMode() );
aViewWindow->SetInteractionStyle( interactionStyle() );
aViewWindow->SetZoomingStyle( zoomingStyle() );
+ aViewWindow->SetDynamicPreSelection( dynamicPreSelection() );
aViewWindow->SetIncrementalSpeed( incrementalSpeed(), incrementalSpeedMode() );
aViewWindow->SetSpacemouseButtons( spacemouseBtn(1), spacemouseBtn(2), spacemouseBtn(3) );
}
}
+/*!
+ \return dynamic preselection
+*/
+bool SVTK_Viewer::dynamicPreSelection() const
+{
+ return myDynamicPreSelection;
+}
+
+/*!
+ Sets dynamic preselection
+ \param theMode - new dynamic preselection mode
+*/
+void SVTK_Viewer::setDynamicPreSelection( const bool theMode )
+{
+ myDynamicPreSelection = theMode;
+
+ if (SUIT_ViewManager* aViewManager = getViewManager()) {
+ QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
+ for ( uint i = 0; i < aViews.count(); i++ )
+ {
+ if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
+ aView->SetDynamicPreSelection( theMode );
+ }
+ }
+}
+
/*!
\return incremental speed value
*/
//! Sets zooming style
void setZoomingStyle( const int );
+ //! Gets dynamic preselection
+ bool dynamicPreSelection() const;
+
+ //! Sets dynamic preselection
+ void setDynamicPreSelection( const bool );
+
//! Get incremental speed (see #SVTK_InteractorStyle::ControllerIncrement)
int incrementalSpeed() const;
int myProjMode;
int myStyle;
int myZoomingStyle;
+ bool myDynamicPreSelection;
int mySpaceBtn[3];
};
#include "SALOME_Actor.h"
+#include <QMenu>
#include <QToolBar>
#include <QEvent>
#include <QXmlStreamWriter>
#include <vtkGL2PSExporter.h>
#include <vtkInteractorStyle.h>
#include <vtkProperty.h>
+#include <vtkCallbackCommand.h>
#include "QtxAction.h"
#include "SUIT_ResourceMgr.h"
#include "SUIT_Accel.h"
#include "SUIT_OverrideCursor.h"
+#include "SUIT_ViewManager.h"
#include "QtxActionToolMgr.h"
#include "QtxMultiAction.h"
SUIT_ViewWindow(theDesktop),
myView(NULL),
myDumpImage(QImage()),
- myKeyFreeInteractorStyle(SVTK_KeyFreeInteractorStyle::New())
+ myKeyFreeInteractorStyle(SVTK_KeyFreeInteractorStyle::New()),
+ myEventCallbackCommand(vtkCallbackCommand::New())
{
setWindowFlags( windowFlags() & ~Qt::Window );
// specific of vtkSmartPointer
{
myInteractor = new SVTK_RenderWindowInteractor(this,"SVTK_RenderWindowInteractor");
- SVTK_Selector* aSelector = SVTK_Selector::New();
+ SVTK_Selector* aSelector = SVTK_Selector::New();
+ aSelector->SetDynamicPreSelection( SUIT_Session::session()->resourceMgr()->
+ booleanValue( "VTKViewer", "dynamic_preselection", true ) );
SVTK_GenericRenderWindowInteractor* aDevice = SVTK_GenericRenderWindowInteractor::New();
aDevice->SetRenderWidget(myInteractor);
myToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_LABEL"), false, Qt::AllToolBarAreas, -1, this );
myRecordingToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_RECORD_LABEL"), false, Qt::AllToolBarAreas, -1, this );
- createActions( SUIT_Session::session()->activeApplication()->resourceMgr() );
+ createActions( SUIT_Session::session()->resourceMgr() );
createToolBar();
SetEventDispatcher(myInteractor->GetDevice());
myView = new SVTK_View(this);
Initialize(myView,theModel);
+
+
+ myEventCallbackCommand->SetClientData(this);
+ myEventCallbackCommand->SetCallback(SVTK_ViewWindow::ProcessEvents);
+ myEventCallbackCommand->Delete();
+
+ GetInteractor()->GetInteractorStyle()->AddObserver(SVTK::OperationFinished,
+ myEventCallbackCommand.GetPointer(), 0.0);
+
+
myInteractor->getRenderWindow()->Render();
onResetView();
{
GetRenderer()->OnFrontView();
Repaint();
+ emit transformed( this );
}
/*!
{
GetRenderer()->OnBackView();
Repaint();
+ emit transformed( this );
}
/*!
{
GetRenderer()->OnTopView();
Repaint();
+ emit transformed( this );
}
/*!
{
GetRenderer()->OnBottomView();
Repaint();
+ emit transformed( this );
}
/*!
{
GetRenderer()->OnLeftView();
Repaint();
+ emit transformed( this );
}
/*!
{
GetRenderer()->OnRightView();
Repaint();
+ emit transformed( this );
}
/*!
{
GetRenderer()->onClockWiseView();
Repaint();
+ emit transformed( this );
}
/*!
{
GetRenderer()->onAntiClockWiseView();
Repaint();
+ emit transformed( this );
}
/*!
{
GetRenderer()->OnResetView();
Repaint();
+ emit transformed( this );
}
/*!
{
GetRenderer()->OnFitAll();
Repaint();
+ emit transformed( this );
}
/*!
{
GetRenderer()->SetScale( theScale );
Repaint();
+ emit transformed( this );
}
/*!
onSwitchZoomingStyle( theStyle==1 );
}
+/*!
+ Switch dynamic preselection on / off
+ \param theDynPreselection - dynamic pre-selection mode
+*/
+void SVTK_ViewWindow::SetDynamicPreSelection( bool theDynPreselection )
+{
+ onSwitchDynamicPreSelection( theDynPreselection );
+}
+
/*!
Switches "keyboard free" interaction style on/off
*/
a->setChecked( theOn );
}
+/*!
+ Toogles dynamic preselection on/off
+*/
+void SVTK_ViewWindow::onSwitchDynamicPreSelection( bool theOn )
+{
+ GetSelector()->SetDynamicPreSelection( theOn );
+
+ // update action state if method is called outside
+ QtxAction* a = getAction( SwitchDynamicPreselectionId );
+ if ( a->isChecked() != theOn )
+ a->setChecked( theOn );
+}
+
/*!
Sets incremental speed
\param theValue - new incremental speed
GetRenderer()->OnAdjustCubeAxes();
}
+void SVTK_ViewWindow::synchronize(SVTK_ViewWindow* otherViewWindow )
+{
+ if ( otherViewWindow ) {
+ bool blocked = blockSignals( true );
+ doSetVisualParameters( otherViewWindow->getVisualParameters(), true );
+ blockSignals( blocked );
+ }
+}
+
/*!
Emits key pressed
*/
/*!
The method restores visual parameters of this view from a formated string
*/
-void SVTK_ViewWindow::doSetVisualParameters( const QString& parameters )
+void SVTK_ViewWindow::doSetVisualParameters( const QString& parameters, bool baseParamsOnly )
{
+
double pos[3], focalPnt[3], viewUp[3], parScale, scale[3];
QXmlStreamReader aReader(parameters);
scale[1] = aAttr.value("Y").toString().toDouble();
scale[2] = aAttr.value("Z").toString().toDouble();
//printf("#### ViewScale %f; %f; %f\n", scale[0], scale[1], scale[2]);
- } else if (aReader.name() == "DisplayCubeAxis") {
- if (aAttr.value("Show") == "0")
- gradAxesActor->VisibilityOff();
- else
- gradAxesActor->VisibilityOn();
- } else if (aReader.name() == "GraduatedAxis") {
- if(aAttr.value("Axis") == "X")
- setGradAxisVisualParams(aReader, gradAxesActor->GetXAxisActor2D());
- else if(aAttr.value("Axis") == "Y")
- setGradAxisVisualParams(aReader, gradAxesActor->GetYAxisActor2D());
- else if(aAttr.value("Axis") == "Z")
- setGradAxisVisualParams(aReader, gradAxesActor->GetZAxisActor2D());
- } else if (aReader.name() == "Trihedron") {
- if (aAttr.value("isShown") == "0")
- GetTrihedron()->VisibilityOff();
- else
- GetTrihedron()->VisibilityOn();
- SetTrihedronSize(aAttr.value("Size").toString().toDouble());
+ }
+ else if (aReader.name() == "DisplayCubeAxis") {
+ if ( !baseParamsOnly ) {
+ if (aAttr.value("Show") == "0")
+ gradAxesActor->VisibilityOff();
+ else
+ gradAxesActor->VisibilityOn();
+ }
+ }
+ else if (aReader.name() == "GraduatedAxis") {
+ if ( !baseParamsOnly ) {
+ if(aAttr.value("Axis") == "X")
+ setGradAxisVisualParams(aReader, gradAxesActor->GetXAxisActor2D());
+ else if(aAttr.value("Axis") == "Y")
+ setGradAxisVisualParams(aReader, gradAxesActor->GetYAxisActor2D());
+ else if(aAttr.value("Axis") == "Z")
+ setGradAxisVisualParams(aReader, gradAxesActor->GetZAxisActor2D());
+ }
+ }
+ else if (aReader.name() == "Trihedron") {
+ if ( !baseParamsOnly ) {
+ if (aAttr.value("isShown") == "0")
+ GetTrihedron()->VisibilityOff();
+ else
+ GetTrihedron()->VisibilityOn();
+ SetTrihedronSize(aAttr.value("Size").toString().toDouble());
+ }
}
}
}
camera->SetFocalPoint( focalPnt );
camera->SetViewUp( viewUp );
camera->SetParallelScale( parScale );
- SetScale( scale );
- } else {
+ GetRenderer()->SetScale( scale );
+ //SetScale( scale );
+ }
+ else {
QStringList paramsLst = parameters.split( '*' );
if ( paramsLst.size() >= nNormalParams ) {
// 'reading' list of parameters
camera->SetFocalPoint( focalPnt );
camera->SetViewUp( viewUp );
camera->SetParallelScale( parScale );
- SetScale( scale );
+ GetRenderer()->SetScale( scale );
+ //SetScale( scale );
// apply graduated axes parameters
- SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
- if ( gradAxesActor && paramsLst.size() == nAllParams ) {
- int i = nNormalParams+1, j = i + nGradAxisParams - 1;
- ::setGradAxisVisualParams( gradAxesActor->GetXAxisActor2D(), parameters.section( '*', i, j ) );
- i = j + 1; j += nGradAxisParams;
- ::setGradAxisVisualParams( gradAxesActor->GetYAxisActor2D(), parameters.section( '*', i, j ) );
- i = j + 1; j += nGradAxisParams;
- ::setGradAxisVisualParams( gradAxesActor->GetZAxisActor2D(), parameters.section( '*', i, j ) );
+ if ( !baseParamsOnly ) {
+ SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
+ if ( gradAxesActor && paramsLst.size() == nAllParams ) {
+ int i = nNormalParams+1, j = i + nGradAxisParams - 1;
+ ::setGradAxisVisualParams( gradAxesActor->GetXAxisActor2D(), parameters.section( '*', i, j ) );
+ i = j + 1; j += nGradAxisParams;
+ ::setGradAxisVisualParams( gradAxesActor->GetYAxisActor2D(), parameters.section( '*', i, j ) );
+ i = j + 1; j += nGradAxisParams;
+ ::setGradAxisVisualParams( gradAxesActor->GetZAxisActor2D(), parameters.section( '*', i, j ) );
- if ( paramsLst[13].toUShort() )
- gradAxesActor->VisibilityOn();
- else
- gradAxesActor->VisibilityOff();
- } else if ( paramsLst.size() == nAllParams ) {
- if ( paramsLst[90].toUShort() )
- GetTrihedron()->VisibilityOn();
- else
- GetTrihedron()->VisibilityOff();
+ if ( paramsLst[13].toUShort() )
+ gradAxesActor->VisibilityOn();
+ else
+ gradAxesActor->VisibilityOff();
+ }
+ else if ( paramsLst.size() == nAllParams ) {
+ if ( paramsLst[90].toUShort() )
+ GetTrihedron()->VisibilityOn();
+ else
+ GetTrihedron()->VisibilityOff();
- SetTrihedronSize(paramsLst[91].toDouble());
+ SetTrihedronSize(paramsLst[91].toDouble());
+ }
}
}
}
+ Repaint();
}
connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onViewParameters(bool)));
mgr->registerAction( anAction, ViewParametersId );
+ // Synchronize View
+ anAction = new QtxAction(tr("MNU_SYNCHRONIZE_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_SYNCHRONIZE" ) ),
+ tr( "MNU_SYNCHRONIZE_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_SYNCHRONIZE_VIEW"));
+ anAction->setMenu( new QMenu( this ) );
+ anAction->setCheckable(true);
+ connect(anAction->menu(), SIGNAL(aboutToShow()), this, SLOT(updateSyncViews()));
+ connect(anAction, SIGNAL(triggered(bool)), this, SLOT(onSynchronizeView(bool)));
+ mgr->registerAction( anAction, SynchronizeId );
+
// Switch between interaction styles
anAction = new QtxAction(tr("MNU_SVTK_STYLE_SWITCH"),
theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_STYLE_SWITCH" ) ),
connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchInteractionStyle(bool)));
mgr->registerAction( anAction, SwitchInteractionStyleId );
- // Switch between zomming styles
+ // Switch between zooming styles
anAction = new QtxAction(tr("MNU_SVTK_ZOOMING_STYLE_SWITCH"),
theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_ZOOMING_STYLE_SWITCH" ) ),
tr( "MNU_SVTK_ZOOMING_STYLE_SWITCH" ), 0, this);
connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchZoomingStyle(bool)));
mgr->registerAction( anAction, SwitchZoomingStyleId );
+ // Turn on/off dynamic pre-selection
+ anAction = new QtxAction(tr("MNU_SVTK_DYNAMIC_PRESLECTION_SWITCH"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_DYNAMIC_PRESLECTION_SWITCH" ) ),
+ tr( "MNU_SVTK_DYNAMIC_PRESLECTION_SWITCH" ), 0, this);
+ anAction->setStatusTip(tr("DSC_SVTK_DYNAMIC_PRESLECTION_SWITCH"));
+ anAction->setCheckable(true);
+ connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchDynamicPreSelection(bool)));
+ mgr->registerAction( anAction, SwitchDynamicPreselectionId );
+
// Start recording
myStartAction = new QtxAction(tr("MNU_SVTK_RECORDING_START"),
theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_START" ) ),
mgr->append( DumpId, myToolBar );
mgr->append( SwitchInteractionStyleId, myToolBar );
mgr->append( SwitchZoomingStyleId, myToolBar );
+ mgr->append( SwitchDynamicPreselectionId, myToolBar );
mgr->append( ViewTrihedronId, myToolBar );
QtxMultiAction* aScaleAction = new QtxMultiAction( this );
mgr->append( GraduatedAxes, myToolBar );
mgr->append( ViewParametersId, myToolBar );
+ mgr->append( SynchronizeId, myToolBar );
+
mgr->append( toolMgr()->separator(), myToolBar );
+
mgr->append( ParallelModeId, myToolBar );
mgr->append( ProjectionModeId, myToolBar );
emit Hide( theEvent );
}
+void SVTK_ViewWindow::synchronizeView( SVTK_ViewWindow* viewWindow, int id )
+{
+ SVTK_ViewWindow* otherViewWindow = 0;
+ QList<SVTK_ViewWindow*> compatibleViews;
+
+ bool isSync = viewWindow->toolMgr()->action( SynchronizeId )->isChecked();
+
+ int vwid = viewWindow->getId();
+
+ SUIT_Application* app = SUIT_Session::session()->activeApplication();
+ if ( !app ) return;
+
+ QList<SUIT_ViewManager*> wmlist;
+ app->viewManagers( viewWindow->getViewManager()->getType(), wmlist );
+
+ foreach( SUIT_ViewManager* wm, wmlist ) {
+ QVector<SUIT_ViewWindow*> vwlist = wm->getViews();
+
+ foreach( SUIT_ViewWindow* vw, vwlist ) {
+ SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( vw );
+ if ( !vtkVW ) continue;
+ if ( vtkVW->getId() == id )
+ otherViewWindow = vtkVW;
+ else if ( vtkVW != viewWindow )
+ compatibleViews.append( vtkVW );
+ }
+ }
+
+ if ( isSync && id ) {
+ // remove all possible disconnections
+ foreach( SVTK_ViewWindow* vw, compatibleViews ) {
+ // disconnect target view
+ vw->disconnect( SIGNAL( transformed( SVTK_ViewPort* ) ), viewWindow, SLOT( synchronize( SVTK_ViewPort* ) ) );
+ viewWindow->disconnect( SIGNAL( transformed( SVTK_ViewPort* ) ), vw, SLOT( synchronize( SVTK_ViewPort* ) ) );
+ if ( otherViewWindow ) {
+ // disconnect source view
+ vw->disconnect( SIGNAL( transformed( SVTK_ViewPort* ) ), otherViewWindow, SLOT( synchronize( SVTK_ViewPort* ) ) );
+ otherViewWindow->disconnect( SIGNAL( transformed( SVTK_ViewPort* ) ), vw, SLOT( synchronize( SVTK_ViewPort* ) ) );
+ }
+ QAction* a = vw->toolMgr()->action( SynchronizeId );
+ if ( a ) {
+ int anid = a->data().toInt();
+ if ( a->isChecked() && ( anid == id || anid == vwid ) ) {
+ bool blocked = a->blockSignals( true );
+ a->setChecked( false );
+ a->blockSignals( blocked );
+ }
+ }
+ }
+ if ( otherViewWindow ) {
+ // reconnect source and target view
+ otherViewWindow->disconnect( SIGNAL( transformed( SVTK_ViewWindow* ) ), viewWindow, SLOT( synchronize( SVTK_ViewWindow* ) ) );
+ viewWindow->disconnect( SIGNAL( transformed( SVTK_ViewWindow* ) ), otherViewWindow, SLOT( synchronize( SVTK_ViewWindow* ) ) );
+ otherViewWindow->connect( viewWindow, SIGNAL( transformed( SVTK_ViewWindow* ) ), SLOT( synchronize( SVTK_ViewWindow* ) ) );
+ viewWindow->connect( otherViewWindow, SIGNAL( transformed( SVTK_ViewWindow* ) ), SLOT( synchronize( SVTK_ViewWindow* ) ) );
+ // synchronize target view with source view
+ viewWindow->doSetVisualParameters( otherViewWindow->getVisualParameters(), true );
+ viewWindow->toolMgr()->action( SynchronizeId )->setData( otherViewWindow->getId() );
+ otherViewWindow->toolMgr()->action( SynchronizeId )->setData( viewWindow->getId() );
+ if ( !otherViewWindow->toolMgr()->action( SynchronizeId )->isChecked() ) {
+ bool blocked = otherViewWindow->toolMgr()->action( SynchronizeId )->blockSignals( true );
+ otherViewWindow->toolMgr()->action( SynchronizeId )->setChecked( true );
+ otherViewWindow->toolMgr()->action( SynchronizeId )->blockSignals( blocked );
+ }
+ }
+ }
+ else if ( otherViewWindow ) {
+ // reconnect source and target view
+ otherViewWindow->disconnect( SIGNAL( transformed( SVTK_ViewWindow* ) ), viewWindow, SLOT( synchronize( SVTK_ViewWindow* ) ) );
+ viewWindow->disconnect( SIGNAL( transformed( SVTK_ViewWindow* ) ), otherViewWindow, SLOT( synchronize( SVTK_ViewWindow* ) ) );
+ viewWindow->doSetVisualParameters( otherViewWindow->getVisualParameters(), true );
+ viewWindow->toolMgr()->action( SynchronizeId )->setData( otherViewWindow->getId() );
+ if ( otherViewWindow->toolMgr()->action( SynchronizeId )->data().toInt() == viewWindow->getId() && otherViewWindow->toolMgr()->action( SynchronizeId )->isChecked() ) {
+ bool blocked = otherViewWindow->toolMgr()->action( SynchronizeId )->blockSignals( true );
+ otherViewWindow->toolMgr()->action( SynchronizeId )->setChecked( false );
+ otherViewWindow->toolMgr()->action( SynchronizeId )->blockSignals( blocked );
+ }
+ }
+}
+
+/*!
+ "Synchronize View" action slot.
+*/
+void SVTK_ViewWindow::onSynchronizeView(bool checked)
+{
+ QAction* a = qobject_cast<QAction*>( sender() );
+ if ( a ) {
+ synchronizeView( this, a->data().toInt() );
+ }
+}
+
+/*!
+ Update list of available view for the "Synchronize View" action
+*/
+void SVTK_ViewWindow::updateSyncViews()
+{
+ QAction* anAction = toolMgr()->action( SynchronizeId );
+ if ( anAction && anAction->menu() ) {
+ int currentId = anAction->data().toInt();
+ anAction->menu()->clear();
+ SUIT_Application* app = SUIT_Session::session()->activeApplication();
+ if ( app ) {
+ QList<SUIT_ViewManager*> wmlist;
+ app->viewManagers( getViewManager()->getType(), wmlist );
+ foreach( SUIT_ViewManager* wm, wmlist ) {
+ QVector<SUIT_ViewWindow*> vwlist = wm->getViews();
+ foreach ( SUIT_ViewWindow* vw, vwlist ) {
+ SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( vw );
+ if ( !vtkVW || vtkVW == this ) continue;
+ QAction* a = anAction->menu()->addAction( vtkVW->windowTitle() );
+ if ( vtkVW->getId() == currentId ) {
+ QFont f = a->font();
+ f.setBold( true );
+ a->setFont( f );
+ }
+ a->setData( vtkVW->getId() );
+ connect( a, SIGNAL( triggered(bool) ), this, SLOT( onSynchronizeView(bool) ) );
+ }
+ }
+ }
+ if ( anAction->menu()->actions().isEmpty() ) {
+ anAction->setData( 0 );
+ anAction->menu()->addAction( tr( "MNU_SYNC_NO_VIEW" ) );
+ }
+ }
+}
+
+
+/*!
+ Emit transformed signal.
+*/
+void SVTK_ViewWindow::emitTransformed() {
+ transformed(this);
+}
+
+/*!
+ Processes events
+*/
+void SVTK_ViewWindow::ProcessEvents(vtkObject* vtkNotUsed(theObject),
+ unsigned long theEvent,
+ void* theClientData,
+ void* theCallData)
+{
+ SVTK_ViewWindow* self = reinterpret_cast<SVTK_ViewWindow*>(theClientData);
+ if(self)
+ self->emitTransformed();
+}
class vtkRenderWindow;
class vtkRenderWindowInteractor;
class vtkInteractorStyle;
+class vtkCallbackCommand;
+
class SVTK_RenderWindowInteractor;
class SVTK_Renderer;
class SVTK_NonIsometricDlg;
//! Redirect the request to #SVTK_MainWindow::SetZoomingStyle
virtual void SetZoomingStyle( const int );
+ virtual void SetDynamicPreSelection( bool );
+
//! Redirect the request to #SVTK_MainWindow::SetSpacemouseButtons
virtual void SetSpacemouseButtons( const int, const int, const int );
virtual void RefreshDumpImage();
+ void emitTransformed();
+
//! To invoke a VTK event on #SVTK_RenderWindowInteractor instance
void InvokeEvent(unsigned long theEvent, void* theCallData);
void onSwitchInteractionStyle(bool theOn);
void onSwitchZoomingStyle(bool theOn);
+ void onSwitchDynamicPreSelection(bool theOn);
void onStartRecording();
void onPlayRecording();
void selectionChanged();
void actorAdded(VTKViewer_Actor*);
void actorRemoved(VTKViewer_Actor*);
+ void transformed(SVTK_ViewWindow*);
public slots:
//! Redirect the request to #SVTK_Renderer::OnFrontView
//! Redirect the request to #SVTK_Renderer::OnAdjustCubeAxes
virtual void onAdjustCubeAxes();
-
+
+ virtual void synchronize(SVTK_ViewWindow*);
+
protected slots:
void onKeyPressed(QKeyEvent* event);
void onKeyReleased(QKeyEvent* event);
virtual void Initialize(SVTK_View* theView,
SVTK_ViewModelBase* theModel);
- void doSetVisualParameters( const QString& );
+ // Main process event method
+ static void ProcessEvents(vtkObject* object,
+ unsigned long event,
+ void* clientdata,
+ void* calldata);
+
+ void doSetVisualParameters( const QString&, bool = false );
void SetEventDispatcher(vtkObject* theDispatcher);
QImage dumpViewContent();
ChangeRotationPointId, RotationId,
FrontId, BackId, TopId, BottomId, LeftId, RightId, ClockWiseId, AntiClockWiseId, ResetId,
ViewTrihedronId, NonIsometric, GraduatedAxes, UpdateRate,
- ParallelModeId, ProjectionModeId, ViewParametersId, SwitchInteractionStyleId,
- SwitchZoomingStyleId,
+ ParallelModeId, ProjectionModeId, ViewParametersId, SynchronizeId, SwitchInteractionStyleId,
+ SwitchZoomingStyleId,SwitchDynamicPreselectionId,
StartRecordingId, PlayRecordingId, PauseRecordingId, StopRecordingId };
-
SVTK_View* myView;
//SVTK_MainWindow* myMainWindow;
SVTK_ViewModelBase* myModel;
vtkSmartPointer<vtkObject> myEventDispatcher;
+ // Used to process events
+ vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
+
SVTK_NonIsometricDlg* myNonIsometricDlg;
SVTK_UpdateRateDlg* myUpdateRateDlg;
SVTK_CubeAxesDlg* myCubeAxesDlg;
vtkPVAxesWidget* myAxesWidget;
+private slots:
+ void onSynchronizeView(bool);
+ void updateSyncViews();
+
+private:
+ static void synchronizeView( SVTK_ViewWindow*, int );
+
private:
QImage myDumpImage;
};
<source>ICON_SVTK_RECORDING_STOP</source>
<translation>vtk_view_recording_stop.png</translation>
</message>
+ <message>
+ <source>ICON_SVTK_SYNCHRONIZE</source>
+ <translation>vtk_view_sync.png</translation>
+ </message>
+ <message>
+ <source>ICON_SVTK_DYNAMIC_PRESLECTION_SWITCH</source>
+ <translation>vtk_view_highlight.png</translation>
+ </message>
</context>
</TS>
<source>DSC_VIEWPARAMETERS_VIEW</source>
<translation>Change the parameters of the view</translation>
</message>
+ <message>
+ <source>MNU_SYNCHRONIZE_VIEW</source>
+ <translation>Synchronize</translation>
+ </message>
+ <message>
+ <source>DSC_SYNCHRONIZE_VIEW</source>
+ <translation>Synchronize view</translation>
+ </message>
+ <message>
+ <source>MNU_SYNC_NO_VIEW</source>
+ <translation>[ No appropriate view ]</translation>
+ </message>
<message>
<source>MNU_SVTK_PARALLEL_MODE</source>
<translation>Orthogonal Mode</translation>
<source>MNU_SVTK_ZOOMING_STYLE_SWITCH</source>
<translation>Zomming style switch</translation>
</message>
+ <message>
+ <source>DSC_SVTK_DYNAMIC_PRESLECTION_SWITCH</source>
+ <translation>Dynamic preselection switch</translation>
+ </message>
+ <message>
+ <source>MNU_SVTK_DYNAMIC_PRESLECTION_SWITCH</source>
+ <translation>Dynamic preselection switch</translation>
+ </message>
</context>
<context>
<name>SVTK_FontWidget</name>
<source>DSC_VIEWPARAMETERS_VIEW</source>
<translation>Changer les paramètres de la vue</translation>
</message>
+ <message>
+ <source>MNU_SYNCHRONIZE_VIEW</source>
+ <translation>Synchroniser</translation>
+ </message>
+ <message>
+ <source>DSC_SYNCHRONIZE_VIEW</source>
+ <translation>Synchroniser la vue</translation>
+ </message>
+ <message>
+ <source>MNU_SYNC_NO_VIEW</source>
+ <translation>[ Pas de vue appropriée ]</translation>
+ </message>
<message>
<source>MNU_SVTK_PARALLEL_MODE</source>
<translation>Mode orthogonal</translation>
<source>MNU_SVTK_ZOOMING_STYLE_SWITCH</source>
<translation>Changer le style de zoom</translation>
</message>
+ <message>
+ <source>DSC_SVTK_DYNAMIC_PRESLECTION_SWITCH</source>
+ <translation>Pré-sélection dynamique</translation>
+ </message>
+ <message>
+ <source>MNU_SVTK_DYNAMIC_PRESLECTION_SWITCH</source>
+ <translation>Pré-sélection dynamique</translation>
+ </message>
</context>
<context>
<name>SVTK_FontWidget</name>
// 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: SalomeApp_DataModel.cxx
// Created: 10/25/2004 10:36:06 AM
// Author: Sergey LITONIN
-//
+
#include "SalomeApp_DataModel.h"
#include "SalomeApp_Study.h"
#include "SalomeApp_DataObject.h"
_PTR(AttributeExpandable) aAttrExp = anAttr;
expandable = aAttrExp->IsExpandable();
}
-
+
if ( expandable ) {
- _PTR(ChildIterator) it ( myStudy->NewChildIterator( obj ) );
- for ( ; it->More(); it->Next() )
- ch.append( it->Value() );
+ // tmp??
+ _PTR(UseCaseBuilder) aUseCaseBuilder = myStudy->GetUseCaseBuilder();
+ if (aUseCaseBuilder->HasChildren(obj)) {
+ _PTR(UseCaseIterator) it ( aUseCaseBuilder->GetUseCaseIterator( obj ) );
+ for ( ; it->More(); it->Next() )
+ ch.append( it->Value() );
+ }
+ else {
+ _PTR(ChildIterator) it ( myStudy->NewChildIterator( obj ) );
+ for ( ; it->More(); it->Next() )
+ ch.append( it->Value() );
+ }
}
return ch;
bool SalomeApp_DataObject::hasChildren() const
{
bool ok = false;
- _PTR(ChildIterator) it ( myObject->GetStudy()->NewChildIterator( myObject ) );
- for ( ; it->More() && !ok; it->Next() ) {
- _PTR(SObject) obj = it->Value();
- if ( obj ) {
- _PTR(SObject) refObj;
- //if ( obj->ReferencedObject( refObj ) ) continue; // omit references
- if ( obj->GetName() != "" ) ok = true;
+
+ // tmp??
+ _PTR(UseCaseBuilder) aUseCaseBuilder = myObject->GetStudy()->GetUseCaseBuilder();
+ if (aUseCaseBuilder->IsUseCaseNode(myObject)) {
+ ok = aUseCaseBuilder->HasChildren(myObject);
+ // TODO: check name as below?
+ }
+ else {
+ _PTR(ChildIterator) it ( myObject->GetStudy()->NewChildIterator( myObject ) );
+ for ( ; it->More() && !ok; it->Next() ) {
+ _PTR(SObject) obj = it->Value();
+ if ( obj ) {
+ _PTR(SObject) refObj;
+ //if ( obj->ReferencedObject( refObj ) ) continue; // omit references
+ if ( obj->GetName() != "" ) ok = true;
+ }
}
}
return ok;
// 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 : SalomeApp_DataObject.h
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
-//
+
#ifndef SALOMEAPP_DATAOBJECT_H
#define SALOMEAPP_DATAOBJECT_H
// 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: SalomeApp_Module.cxx
// Created: 10/25/2004 11:39:56 AM
// Author: Sergey LITONIN
-//
+
#include "SalomeApp_Module.h"
#include "SalomeApp_DataModel.h"
#include "SalomeApp_Application.h"
if ( SUIT_ViewManager* vman = app->activeViewManager() )
vmod = vman->getViewModel();
app->updateVisibilityState( listObj, vmod );
-}
\ No newline at end of file
+}
// 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: SalomeApp_Module.h
// Created: 10/25/2004 11:33:06 AM
// Author: Sergey LITONIN
-//
+
#ifndef SALOMEAPP_MODULE_H
#define SALOMEAPP_MODULE_H
// 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 "SalomeApp_Study.h"
myStudy=aStudy;
fillEntryMap();
}
-
+
SUIT_DataObject* findObject( const char* theID ) const
{
EntryMap::const_iterator it = entry2SuitObject.find( theID );
virtual bool event(QEvent *event)
{
- if (event->type() == QEvent::User )
+ if (event->type() == QEvent::User )
{
//START_TIMING(notify);
notifyObserverID_real(static_cast<ObserverEvent *>(event)->_anID.c_str(),static_cast<ObserverEvent *>(event)->_event);
void notifyObserverID_real(const std::string& theID, long event)
{
SalomeApp_DataObject* suit_obj = 0;
-
- switch(event) {
- case 1:
+
+ switch(event) {
+ case 1:
{ //Add sobject
- EntryMapIter it = entry2SuitObject.find( theID );
- if ( it != entry2SuitObject.end() )
- {
- MESSAGE("Entry " << theID << " is already added. Problem ??");
+ _PTR(SObject) aSObj = myStudyDS->FindObjectID(theID);
+ _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
+
+ if (!aSComp || aSComp->IsNull()) {
+ MESSAGE("Entry " << theID << " has not father component. Problem ??");
return;
}
- _PTR(SObject) obj = myStudyDS->FindObjectID( theID );
- int last2Pnt_pos = theID.rfind( ":" );
- std::string parent_id = theID.substr( 0, last2Pnt_pos );
- int tag = atoi( theID.substr( last2Pnt_pos+1 ).c_str() );
-
- if ( parent_id.length() == 3 ) // "0:1" - root item?
- {
- // It's probably a SComponent
- _PTR(SComponent) aSComp = obj->GetFatherComponent();
- if ( aSComp && !aSComp->IsNull() && aSComp->GetID() == theID )
- suit_obj = new SalomeApp_ModuleObject( aSComp );
- else
- suit_obj = new SalomeApp_DataObject( obj );
- }
- else
- {
- suit_obj = new SalomeApp_DataObject( obj );
- }
-
- it = entry2SuitObject.find( parent_id );
- if ( it != entry2SuitObject.end() )
- {
- SalomeApp_DataObject* father = it->second;
- father->insertChildAtTag( suit_obj, tag );
- }
- else
- {
+
+ // Mantis issue 0020136: Drag&Drop in OB
+ _PTR(UseCaseBuilder) aUseCaseBuilder = myStudyDS->GetUseCaseBuilder();
+ if (aUseCaseBuilder->IsUseCaseNode(aSComp)) { // BEGIN: work with tree nodes structure
+ if (!aUseCaseBuilder->IsUseCaseNode(aSObj)) {
+ // tree node is not yet set, it is a normal situation
+ return;
+ }
+
+ _PTR(SObject) aFatherSO = aUseCaseBuilder->GetFather(aSObj);
+ if (!aFatherSO || aFatherSO->IsNull()) {
+ MESSAGE("Father SObject is not found. Problem ??");
+ return;
+ }
+
+ std::string parent_id = aFatherSO->GetID();
+ EntryMapIter it = entry2SuitObject.find(parent_id.c_str());
+
+ if (it == entry2SuitObject.end()) {
+ MESSAGE("Father data object is not found. Problem ??");
+ return;
+ }
+
+ SalomeApp_DataObject* aFatherDO = it->second;
+
+ it = entry2SuitObject.find(theID);
+ if (it != entry2SuitObject.end()) { // this SOobject is already added somethere
+ // tmp??
+ suit_obj = it->second;
+ SUIT_DataObject* oldFather = suit_obj->parent();
+ if (oldFather) {
+ oldFather->removeChild(suit_obj, false);
+
+ suit_obj->updateItem(); // tmp??
+ if (SalomeApp_DataObject* oldFatherSA = dynamic_cast<SalomeApp_DataObject*>(oldFather)) {
+ oldFatherSA->updateItem(); // tmp??
+ }
+
+ //entry2SuitObject.erase(it);
+ ////delete suit_obj;
+ //suit_obj = new SalomeApp_DataObject(aSObj);
+ //entry2SuitObject[theID] = suit_obj;
+ }
+ }
+ else {
+ suit_obj = new SalomeApp_DataObject(aSObj);
+ entry2SuitObject[theID] = suit_obj;
+ }
+
+ // define position in the data tree (in aFatherDO) to insert the aSObj
+ int pos = -1;
+ //int childDataObjCount = aFatherDO->childCount();
+ _PTR(UseCaseIterator) aUseCaseIter = aUseCaseBuilder->GetUseCaseIterator(aFatherSO);
+ for (int cur = 0; aUseCaseIter->More() && pos < 0; cur++, aUseCaseIter->Next()) {
+ if (aUseCaseIter->Value()->GetID() == theID) {
+ pos = cur;
+ break;
+ }
+ }
+
+ //aFatherDO->insertChildAtPos(suit_obj, pos);
+ aFatherDO->insertChild(suit_obj, pos);
+ aFatherDO->updateItem(); // tmp??
+
+ } // END: work with tree nodes structure
+ else { // BEGIN: work with study structure
+ EntryMapIter it = entry2SuitObject.find( theID );
+ if ( it != entry2SuitObject.end() ) {
+ MESSAGE("Entry " << theID << " is already added. Problem ??");
+ return;
+ }
+
+ int last2Pnt_pos = theID.rfind( ":" );
+ std::string parent_id = theID.substr( 0, last2Pnt_pos );
+ int tag = atoi( theID.substr( last2Pnt_pos+1 ).c_str() );
+
if ( parent_id.length() == 3 ) // "0:1" - root item?
{
- // This should be for a module
- SUIT_DataObject* father=myStudy->root();
- father->appendChild(suit_obj);
+ // It's probably a SComponent
+ if ( theID == aSComp->GetID() )
+ suit_obj = new SalomeApp_ModuleObject( aSComp );
+ else
+ suit_obj = new SalomeApp_DataObject( aSObj );
}
else
{
- MESSAGE("SHOULD NEGER GET HERE!!!");
-
- //Try to find the SalomeApp_DataObject object parent
- std::string root_id = parent_id.substr( 0, 4 );
- std::string obj_id = parent_id.substr( 4 );
-
- std::string anID;
- std::string::size_type debut = 0;
- std::string::size_type fin;
- SalomeApp_DataObject* anObj = dynamic_cast<SalomeApp_DataObject*>( myStudy->root() );
- while ( 1 )
+ suit_obj = new SalomeApp_DataObject( aSObj );
+ }
+
+ it = entry2SuitObject.find( parent_id );
+ if ( it != entry2SuitObject.end() ) {
+ SalomeApp_DataObject* father = it->second;
+ father->insertChildAtTag( suit_obj, tag );
+ }
+ else {
+ if ( parent_id.length() == 3 ) // "0:1" - root item?
{
- fin = obj_id.find_first_of( ':', debut );
- if ( fin == std::string::npos )
- {
- //last id
- anObj = dynamic_cast<SalomeApp_DataObject*>( anObj->childObject( atoi( obj_id.substr( debut ).c_str() )-1 ) );
- entry2SuitObject[parent_id] = anObj;
- break;
- }
- anID = root_id + obj_id.substr( 0, fin );
- EntryMapIter it2 = entry2SuitObject.find( anID );
- if ( it2 == entry2SuitObject.end() )
- {
- //the ID is not known in entry2SuitObject
- anObj = dynamic_cast<SalomeApp_DataObject*>( anObj->childObject( atoi( obj_id.substr( debut, fin-debut ).c_str() )-1 ) );
- entry2SuitObject[anID] = anObj;
+ // This should be for a module
+ SUIT_DataObject* father=myStudy->root();
+ father->appendChild(suit_obj);
+ }
+ else
+ {
+ MESSAGE("SHOULD NEVER GET HERE!!!");
+
+ //Try to find the SalomeApp_DataObject object parent
+ std::string root_id = parent_id.substr( 0, 4 );
+ std::string obj_id = parent_id.substr( 4 );
+
+ std::string anID;
+ std::string::size_type debut = 0;
+ std::string::size_type fin;
+ SalomeApp_DataObject* anObj = dynamic_cast<SalomeApp_DataObject*>( myStudy->root() );
+ while ( 1 ) {
+ fin = obj_id.find_first_of( ':', debut );
+ if ( fin == std::string::npos ) {
+ //last id
+ anObj = dynamic_cast<SalomeApp_DataObject*>(anObj->childObject(atoi(obj_id.substr(debut).c_str())-1));
+ entry2SuitObject[parent_id] = anObj;
+ break;
+ }
+ anID = root_id + obj_id.substr( 0, fin );
+ EntryMapIter it2 = entry2SuitObject.find( anID );
+ if ( it2 == entry2SuitObject.end() ) {
+ //the ID is not known in entry2SuitObject
+ anObj = dynamic_cast<SalomeApp_DataObject*>(anObj->childObject(atoi(obj_id.substr(debut, fin-debut).c_str())-1));
+ entry2SuitObject[anID] = anObj;
+ }
+ else
+ anObj = it2->second;
+ debut = fin+1;
}
- else
- anObj = it2->second;
- debut = fin+1;
+ anObj->insertChildAtTag( suit_obj, tag );
}
- anObj->insertChildAtTag( suit_obj, tag );
}
- }
- entry2SuitObject[theID] = suit_obj;
+ entry2SuitObject[theID] = suit_obj;
+ } // END: work with study structure
break;
- }
- case 2:
+ }
+ case 2:
{ // Remove sobject
EntryMapIter it = entry2SuitObject.find( theID );
if ( it != entry2SuitObject.end() )
{
suit_obj = it->second;
- // VSR: object is not removed, since SALOMEDS::SObject is not actually removed, only its attributes are cleared;
+ // VSR: object is not removed, since SALOMEDS::SObject is not actually removed,
+ // only its attributes are cleared;
// thus, the object can be later reused
suit_obj->updateItem();
//SUIT_DataObject* father=suit_obj->parent();
}
break;
}
- case 0:
+ case 0:
{ //modify sobject
//MESSAGE("Want to modify an object " << theID);
EntryMapIter it = entry2SuitObject.find( theID );
case 5: //IOR of the object modified
{
EntryMapIter it = entry2SuitObject.find( theID );
- if ( it != entry2SuitObject.end() )
+ if ( it != entry2SuitObject.end() )
suit_obj = it->second;
-
+
/* Define visibility state */
- bool isComponent = dynamic_cast<SalomeApp_ModuleObject*>( suit_obj ) != 0;
+ bool isComponent = dynamic_cast<SalomeApp_ModuleObject*>( suit_obj ) != 0;
if ( suit_obj && !isComponent ) {
QString moduleTitle = ((CAM_Application*)myStudy->application())->moduleTitle(suit_obj->componentDataType());
if (!moduleTitle.isEmpty()) {
LightApp_Displayer* aDisplayer = LightApp_Displayer::FindDisplayer(moduleTitle,false);
- if(aDisplayer) {
+ if (aDisplayer) {
if(aDisplayer->canBeDisplayed(theID.c_str())) {
myStudy->setVisibilityState( theID.c_str(), Qtx::HiddenState );
//MESSAGE("Object with entry : "<< theID <<" CAN be displayed !!!");
- } else
+ }
+ else
MESSAGE("Object with entry : "<< theID <<" CAN'T be displayed !!!");
}
}
}
default:MESSAGE("Unknown event: " << event);break;
} //switch
- } //notifyObserverID
+ } //notifyObserverID_real
-private:
+private:
void fillEntryMap()
{
entry2SuitObject.clear();
}
}
}
-
+
private:
_PTR(Study) myStudyDS;
SalomeApp_Study* myStudy;
SalomeApp_Study::SalomeApp_Study( SUIT_Application* app )
: LightApp_Study( app ), myObserver( 0 )
{
-}
+}
/*!
Destructor.
#ifdef WITH_SALOMEDS_OBSERVER
myObserver = new Observer_i(myStudyDS,this);
- //attach an observer to the study with notification of modifications
+ //attach an observer to the study with notification of modifications
myStudyDS->attach(myObserver->_this(),true);
#endif
-
+
return aRet;
}
ModelList dm_s;
dataModels( dm_s );
QListIterator<CAM_DataModel*> it( dm_s );
- while ( it.hasNext() )
+ while ( it.hasNext() )
openDataModel( studyName(), it.next() );
-
+
// this will build a SUIT_DataObject-s tree under myRoot member field
// passing "false" in order NOT to rebuild existing data models' trees - it was done in previous step
- // but tree that corresponds to not-loaded data models will be updated any way.
- ((SalomeApp_Application*)application())->updateObjectBrowser( false );
+ // but tree that corresponds to not-loaded data models will be updated any way.
+ ((SalomeApp_Application*)application())->updateObjectBrowser( false );
#ifdef WITH_SALOMEDS_OBSERVER
dynamic_cast<SalomeApp_RootObject*>( root() )->setToSynchronize(false);
myObserver = new Observer_i(myStudyDS,this);
- //attach an observer to the study with notification of modifications
+ //attach an observer to the study with notification of modifications
myStudyDS->attach(myObserver->_this(),true);
#endif
bool res = CAM_Study::openDocument( theFileName );
-
+
emit opened( this );
study->IsSaved(true);
SalomeApp_VisualState( (SalomeApp_Application*)application() ).restoreState( savePoints[savePoints.size()-1] );
}
- ((SalomeApp_Application*)application())->updateObjectBrowser( true );
+ ((SalomeApp_Application*)application())->updateObjectBrowser( true );
return res;
}
// this will build a SUIT_DataObject-s tree under myRoot member field
// passing "false" in order NOT to rebuild existing data models' trees - it was done in previous step
- // but tree that corresponds to not-loaded data models will be updated any way.
- ((SalomeApp_Application*)application())->updateObjectBrowser( false );
+ // but tree that corresponds to not-loaded data models will be updated any way.
+ ((SalomeApp_Application*)application())->updateObjectBrowser( false );
#ifdef WITH_SALOMEDS_OBSERVER
dynamic_cast<SalomeApp_RootObject*>( root() )->setToSynchronize(false);
myObserver = new Observer_i(myStudyDS,this);
- //attach an observer to the study with notification of modifications
+ //attach an observer to the study with notification of modifications
myStudyDS->attach(myObserver->_this(),true);
#endif
bool store = application()->resourceMgr()->booleanValue( "Study", "store_visual_state", false );
if ( store )
SalomeApp_VisualState( (SalomeApp_Application*)application() ).storeState();
-
+
ModelList list; dataModels( list );
QListIterator<CAM_DataModel*> it( list );
bool isMultiFile = resMgr->booleanValue( "Study", "multi_file", false );
bool isAscii = resMgr->booleanValue( "Study", "ascii_file", false );
- bool res = (isAscii ?
+ bool res = (isAscii ?
SalomeApp_Application::studyMgr()->SaveAsASCII( theFileName.toStdString(), studyDS(), isMultiFile ) :
SalomeApp_Application::studyMgr()->SaveAs ( theFileName.toStdString(), studyDS(), isMultiFile ))
&& CAM_Study::saveDocumentAs( theFileName );
-
+
res = res && saveStudyData(theFileName);
if ( res )
if ( SalomeApp_DataModel* aModel = (SalomeApp_DataModel*)it.next() ) {
listOfFiles.clear();
aModel->save(listOfFiles);
- if ( !listOfFiles.isEmpty() )
+ if ( !listOfFiles.isEmpty() )
saveModuleData(aModel->module()->name(), listOfFiles);
}
}
bool isMultiFile = resMgr->booleanValue( "Study", "multi_file", false );
bool isAscii = resMgr->booleanValue( "Study", "ascii_file", false );
- bool res = (isAscii ?
+ bool res = (isAscii ?
SalomeApp_Application::studyMgr()->SaveASCII( studyDS(), isMultiFile ) :
SalomeApp_Application::studyMgr()->Save ( studyDS(), isMultiFile )) && CAM_Study::saveDocument();
res = res && saveStudyData(studyName());
if ( res )
- emit saved( this );
+ emit saved( this );
return res;
}
if (!isAnyChanged)
isAnyChanged = LightApp_Study::isModified();
- return isAnyChanged;
+ return isAnyChanged;
}
/*!
if (!isAllSaved)
isAllSaved = LightApp_Study::isSaved();
- return isAllSaved;
+ return isAllSaved;
}
/*!
if (!aModule) {
// Check SComponent existance
_PTR(Study) aStudy = studyDS();
- if (!aStudy)
+ if (!aStudy)
return;
_PTR(SComponent) aComp = aStudy->FindComponent(dm->module()->name().toStdString());
if (!aComp) {
*/
void SalomeApp_Study::components( QStringList& comps ) const
{
- for( _PTR(SComponentIterator) it ( studyDS()->NewComponentIterator() ); it->More(); it->Next() )
+ for( _PTR(SComponentIterator) it ( studyDS()->NewComponentIterator() ); it->More(); it->Next() )
{
_PTR(SComponent) aComponent ( it->Value() );
// skip the magic "Interface Applicative" component
QString SalomeApp_Study::centry( const QString& comp ) const
{
QString e;
- for( _PTR(SComponentIterator) it ( studyDS()->NewComponentIterator() ); it->More() && e.isEmpty(); it->Next() )
+ for( _PTR(SComponentIterator) it ( studyDS()->NewComponentIterator() ); it->More() && e.isEmpty(); it->Next() )
{
_PTR(SComponent) aComponent ( it->Value() );
if ( aComponent && comp == aComponent->ComponentDataType().c_str() )
</section>
<section name="SMESH">
<!-- Default SMESH module plugins -->
- <parameter name="plugins" value="NETGENPlugin,GHS3DPlugin,GHS3DPRLPlugin,HexoticPLUGIN,BLSURFPlugin"/>
+ <parameter name="plugins" value="GHS3DPlugin,GHS3DPRLPlugin,BLSURFPlugin,NETGENPlugin,HexoticPLUGIN"/>
</section>
<section name="ObjectBrowser" >
<!-- Object Browser preferences -->
</message>
<message>
<source>APPCLOSE_DESCRIPTION</source>
- <translation>Voulez-vous fermer ou décharger l'étude avant de la fermer?</translation>
+ <translation>Voulez-vous fermer ou décharger l'étude avant de la fermer ?</translation>
</message>
<message>
<source>PRP_DESK_PROPERTIES</source>
</message>
<message>
<source>CLOSE_DESCRIPTION</source>
- <translation>Voulez-vous sauvegarder les changements faits au Registre?</translation>
+ <translation>Voulez-vous sauvegarder les changements faits au Registre ?</translation>
</message>
<message>
<source>INCORRECT_DATA</source>
</message>
<message>
<source>ERR_UPDATE_STUDY_FAILED</source>
- <translation>Impossible de mettre l'étude à jour!</translation>
+ <translation>Impossible de mettre l'étude à jour !</translation>
</message>
</context>
<context>
The plugins manager creates a submenu <menuname> in the <basemenuname> menu.
-The plugins manager searches in $HOME/.salome/Plugins, $HOME/$APPLI/Plugins, $SALOME_PLUGINS_PATH directories
+The plugins manager searches in $HOME/.config/salome/Plugins, $HOME/$APPLI/Plugins, $SALOME_PLUGINS_PATH directories
files named <name>_plugins.py and executes them.
These files should contain python code that register functions into the plugins manager.
self.plugins_files=[]
# USER plugins directory
- user_dir = os.path.expanduser("~/.salome/Plugins")
+ user_dir = os.path.expanduser("~/.config/salome/Plugins")
self.plugindirs.append(user_dir)
+ # obsolete: USER plugins directory
+ # (for compatibility reasons only; new plugins should be stored in ~/.config/salome/Plugins)
+ user_obsolete_dir = os.path.expanduser("~/.salome/Plugins")
+ self.plugindirs.append(user_obsolete_dir)
# APPLI plugins directory
appli=os.getenv("APPLI")
#include <Style_Salome.h>
+#include "GUI_version.h"
#include <SUIT_Tools.h>
#include <SUIT_Session.h>
#include <SUIT_Application.h>
QString salomeVersion()
{
- QString path( ::getenv( "GUI_ROOT_DIR" ) );
- if ( !path.isEmpty() )
- path += QDir::separator();
- path += QString( "bin/salome/VERSION" );
-
- QFile vf( path );
- if ( !vf.open( QIODevice::ReadOnly ) )
- return QString();
-
- QString line( vf.readLine( 1024 ) );
-
- vf.close();
-
- if ( line.isEmpty() )
- return QString();
-
- while ( !line.isEmpty() && line.at( line.length() - 1 ) == QChar( '\n' ) )
- line.remove( line.length() - 1, 1 );
-
- QString ver;
- int idx = line.lastIndexOf( ":" );
- if ( idx != -1 )
- ver = line.mid( idx + 1 ).trimmed();
-
- return ver;
+ return GUI_VERSION_STR;
}
class SALOME_ResourceMgr : public SUIT_ResourceMgr
return SUIT_ResourceMgr::userFileName( myExtAppName, for_load );
}
- virtual int userFileId( const QString& _fname ) const
+ virtual long userFileId( const QString& _fname ) const
{
+ long id = -1;
if ( !myExtAppName.isEmpty() ) {
QRegExp exp( QString( "\\.%1rc\\.([a-zA-Z0-9.]+)$" ).arg( myExtAppName ) );
QRegExp vers_exp( "^([0-9]+)([A-Za-z]?)([0-9]*)$" );
if( exp.exactMatch( fname ) ) {
QStringList vers = exp.cap( 1 ).split( ".", QString::SkipEmptyParts );
int major=0, minor=0;
- major = vers[0].toInt();
- minor = vers[1].toInt();
- if( vers_exp.indexIn( vers[2] )==-1 )
- return -1;
int release = 0, dev1 = 0, dev2 = 0;
- release = vers_exp.cap( 1 ).toInt();
- dev1 = vers_exp.cap( 2 )[ 0 ].toLatin1();
- dev2 = vers_exp.cap( 3 ).toInt();
+ if ( vers.count() > 0 ) major = vers[0].toInt();
+ if ( vers.count() > 1 ) minor = vers[1].toInt();
+ if ( vers.count() > 2 ) {
+ if( vers_exp.indexIn( vers[2] ) != -1 ) {
+ release = vers_exp.cap( 1 ).toInt();
+ dev1 = vers_exp.cap( 2 )[ 0 ].toLatin1();
+ dev2 = vers_exp.cap( 3 ).toInt();
+ }
+ }
- int dev = dev1*100+dev2, id = major;
+ 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;
+ return id;
}
public:
catch (std::exception& e) {
std::cerr << e.what() << std::endl;
}
+ catch (CORBA::Exception& e) {
+ std::cerr << "Caught CORBA::Exception" << std::endl;
+ CORBA::Any tmp;
+ tmp<<= e;
+ CORBA::TypeCode_var tc = tmp.type();
+ const char *p = tc->name();
+ std::cerr << "notify(): CORBA exception of the kind : " << p << " is caught" << std::endl;
+ }
catch (...) {
std::cerr << "Unknown exception caught in Qt handler: it's probably a bug in SALOME platform" << std::endl;
}
vtkInformationVector *outputVector)
{
int idx;
- vtkIdType numPts, numCells, newCellId, cellId;
- vtkCellData *cd;
+ vtkIdType numPts, numCells, cellId;
+ // vtkCellData *cd;
vtkIdList *ptIds;
vtkDataSet *ds;
int numInputs = this->GetNumberOfInputConnections(0);
if (ds != NULL) {
numCells = ds->GetNumberOfCells();
- cd = ds->GetCellData();
+ // cd = ds->GetCellData();
// copy cell and cell data
for (cellId=0; cellId<numCells; cellId++) {
ds->GetCellPoints(cellId, ptIds);
- newCellId = output->InsertNextCell(ds->GetCellType(cellId), ptIds);
+ output->InsertNextCell(ds->GetCellType(cellId), ptIds);
}
}
}
vtkPoints *inPts;
vtkPoints *newPts;
- int numPts, numCells;
+ int numPts/*, numCells*/;
vtkPointData *pd=input->GetPointData(), *outPD=output->GetPointData();
vtkCellData *cd=input->GetCellData(), *outCD=output->GetCellData();
output->CopyStructure( input );
inPts = input->GetPoints();
if(!anIsIdentity && inPts){
numPts = inPts->GetNumberOfPoints();
- numCells = input->GetNumberOfCells();
+ // numCells = input->GetNumberOfCells();
newPts = vtkPoints::New();
newPts->Allocate(numPts);
this->UpdateProgress(.2);
<name>VTKViewer_ViewManager</name>
<message>
<source>VTK_VIEW_TITLE</source>
- <translation>VTK scène:%M - visualiseur:%V</translation>
+ <translation>Scène VTK:%M - visualiseur:%V</translation>
</message>
</context>
<context>
--- /dev/null
+# Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# Copyright (C) 2003-2007 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
+#
+
+SUBDIRS = dlgfactory
--- /dev/null
+#include "GenericDialog.hxx"
+
+GenericDialog::GenericDialog(QDialog *parent) : QDialog(parent)
+{
+ ui.setupUi(this); // A faire en premier
+
+ /*
+ Personnalisez vos widgets ici si nécessaire
+ Réalisez des connexions supplémentaires entre signaux et slots
+ */
+
+ // The slots accept() and reject() are already connected to the
+ // buttonbox (inherited features)
+}
+
+QFrame * GenericDialog::getPanel() {
+ return ui.centralPanel;
+}
+
+QDialogButtonBox * GenericDialog::getButtonBox() {
+ return ui.buttonBox;
+}
+
+
+#include <QDebug>
+void GenericDialog::accept() {
+ qDebug() << "accept() is not implemented yet";
+ QDialog::accept();
+}
--- /dev/null
+#ifndef _GenericDialog_HXX
+#define _GenericDialog_HXX
+
+#include <QtGui>
+#include "ui_GenericDialog.hxx"
+
+class GenericDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GenericDialog(QDialog *parent = 0);
+
+ protected:
+ QFrame * getPanel();
+ QDialogButtonBox * getButtonBox();
+
+ protected slots:
+ void accept();
+ //void reject();
+
+ private:
+ Ui_GenericDialog ui; // instance of the class defined in ui_GenericDialog.h
+};
+
+
+#endif // _GenericDialog_HXX
--- /dev/null
+<ui version="4.0" >
+ <class>GenericDialog</class>
+ <widget class="QDialog" name="GenericDialog" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Dialog</string>
+ </property>
+ <layout class="QHBoxLayout" >
+ <property name="margin" >
+ <number>9</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <layout class="QVBoxLayout" >
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QFrame" name="centralPanel" >
+ <property name="frameShape" >
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Raised</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons" >
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>GenericDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>GenericDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
--- /dev/null
+# Copyright (C) 2010 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# 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
+#
+# -* Makefile *-
+#
+# Author : Guillaume Boulant (EDF/R&D)
+
+include $(top_srcdir)/adm_local/unix/make_common_starter.am
+
+# moc-files generation (using MOC)
+%_moc.cxx: %.hxx
+ $(MOC) $< -o $@
+
+# Qt form files generation (using UIC)
+ui_%.hxx: %.ui
+ $(UIC) -o $@ $<
+
+# Program targets
+bin_PROGRAMS = qtester gtester
+
+# QDialog uic files
+UIC_FILES_QDIALOG = \
+ ui_QDialogTest.hxx
+
+# QDialog moc files
+MOC_FILES_QDIALOG = \
+ QDialogTest_moc.cxx
+
+# GDialog uic files
+UIC_FILES_GDIALOG= \
+ ui_GenericDialog.hxx \
+ ui_GDialogTest.hxx
+
+# GDialog moc files
+MOC_FILES_GDIALOG= \
+ GenericDialog_moc.cxx \
+ GDialogTest_moc.cxx
+
+QDIALOG_TEMPLATES = __QDIALOG__.ui __QDIALOG__.hxx __QDIALOG__.cxx
+GDIALOG_TEMPLATES = __GDIALOG__.ui __GDIALOG__.hxx __GDIALOG__.cxx
+
+# generated sources
+BUILT_SOURCES = $(UIC_FILES_QDIALOG) $(UIC_FILES_GDIALOG)
+
+# extra distributed files
+EXTRA_DIST += $(QDIALOG_TEMPLATES) $(GDIALOG_TEMPLATES) GenericDialog.ui README.txt dlgfactory.sh
+
+mostlyclean-local:
+ rm @builddir@/QDialogTest*
+ rm @builddir@/GDialogTest*
+ rm -f @builddir@/*_moc.cxx @builddir@/ui_*.hxx
+
+QDialogTest.hxx QDialogTest.cxx QDialogTest.ui: $(QDIALOG_TEMPLATES) dlgfactory.sh
+ $(srcdir)/dlgfactory.sh -n QDialogTest -t qdialog
+
+GDialogTest.hxx GDialogTest.cxx GDialogTest.ui : $(GDIALOG_TEMPLATES) dlgfactory.sh
+ $(srcdir)/dlgfactory.sh -n GDialogTest -t gdialog
+
+QT_CXXFLAGS=@QT_INCLUDES@ @QT_MT_INCLUDES@
+QT_LIBS=@QT_LIBS@
+
+# QDialog tester
+qtester_SOURCES = \
+ qtester.cxx
+nodist_qtester_SOURCES = \
+ QDialogTest.cxx \
+ $(MOC_FILES_QDIALOG) \
+ $(UIC_FILES_QDIALOG)
+
+qtester_CPPFLAGS = \
+ $(QT_CXXFLAGS)
+
+qtester_LDFLAGS = \
+ $(QT_LIBS)
+
+gtester_SOURCES = \
+ gtester.cxx \
+ GenericDialog.hxx \
+ GenericDialog.cxx
+nodist_gtester_SOURCES = \
+ GDialogTest.cxx \
+ $(MOC_FILES_GDIALOG) \
+ $(UIC_FILES_GDIALOG)
+
+gtester_CPPFLAGS = \
+ $(QT_CXXFLAGS)
+
+gtester_LDFLAGS = \
+ $(QT_LIBS)
--- /dev/null
+This package provides a simple tool to generates the bootstrap files
+of a standard Qt dialog. Nothing original neither very smart, but just
+help to initiate all this stuff the good way.
+
+See the header of the script dlgfactory.sh for details.
+
+Some use cases (basic unit test) are given in the files qtester.cxx
+and gtester.cxx. The build procedure (when you type make) create test
+classes called QDialogTest and GDialogTest and used respectively in
+qtester and gtester.
+
+(gboulant - 26 oct. 2011)
--- /dev/null
+#include "__CLASSNAME__.hxx"
+
+__CLASSNAME__::__CLASSNAME__(QDialog *parent) : GenericDialog(parent)
+{
+ ui.setupUi(this->getPanel());
+}
--- /dev/null
+#ifndef ___CLASSNAME___HXX
+#define ___CLASSNAME___HXX
+
+#include <QtGui>
+#include "ui___CLASSNAME__.hxx"
+#include "GenericDialog.hxx"
+
+class __CLASSNAME__ : public GenericDialog
+{
+ Q_OBJECT
+
+ public:
+ __CLASSNAME__(QDialog *parent = 0);
+
+ private:
+ Ui___CLASSNAME__ ui; // instance of the class defined in ui___CLASSNAME__.hxx
+};
+
+
+#endif // ___CLASSNAME___HXX
--- /dev/null
+<ui version="4.0" >
+ <class>__CLASSNAME__</class>
+ <widget class="QWidget" name="__CLASSNAME__" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>340</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Form</string>
+ </property>
+ <layout class="QHBoxLayout" >
+ <property name="margin" >
+ <number>9</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <layout class="QVBoxLayout" >
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout" >
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <layout class="QVBoxLayout" >
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label" >
+ <property name="text" >
+ <string>Pression :</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_2" >
+ <property name="text" >
+ <string>Température :</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" >
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QLineEdit" name="lineEdit" />
+ </item>
+ <item>
+ <widget class="QLineEdit" name="lineEdit_2" />
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>20</width>
+ <height>121</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
--- /dev/null
+#include "__CLASSNAME__.hxx"
+
+__CLASSNAME__::__CLASSNAME__(QDialog *parent) : QDialog(parent)
+{
+ ui.setupUi(this); // A faire en premier
+
+ /*
+ Personnalisez vos widgets ici si nécessaire
+ Réalisez des connexions supplémentaires entre signaux et slots
+ */
+
+ // The slots accept() and reject() are already connected to the
+ // buttonbox (inherited features)
+}
+
+#include <QDebug>
+void __CLASSNAME__::accept() {
+ qDebug() << "accept() is not implemented yet";
+ QDialog::accept();
+}
--- /dev/null
+#ifndef ___CLASSNAME___HXX
+#define ___CLASSNAME___HXX
+
+#include <QtGui>
+#include "ui___CLASSNAME__.hxx"
+
+class __CLASSNAME__ : public QDialog
+{
+ Q_OBJECT
+
+ public:
+ __CLASSNAME__(QDialog *parent = 0);
+
+ protected slots:
+ void accept();
+ //void reject();
+
+ private:
+ Ui___CLASSNAME__ ui; // instance of the class defined in ui___CLASSNAME__.hxx
+};
+
+
+#endif // ___CLASSNAME___HXX
--- /dev/null
+<ui version="4.0" >
+ <class>__CLASSNAME__</class>
+ <widget class="QDialog" name="__CLASSNAME__" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Dialog</string>
+ </property>
+ <widget class="QDialogButtonBox" name="buttonBox" >
+ <property name="geometry" >
+ <rect>
+ <x>30</x>
+ <y>240</y>
+ <width>341</width>
+ <height>32</height>
+ </rect>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons" >
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>__CLASSNAME__</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>__CLASSNAME__</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
--- /dev/null
+#!/bin/sh
+#
+# ==================================================================
+#_debut_usage
+#
+# USAGE:
+#
+# dlgfactory.sh -n className [-t classType]
+#
+#
+# DESCRIPTION:
+#
+# This script generates a set of files to initiate a dialog qt window
+# (i.e. MyDialog.ui, MyDialog.hxx and MyDialog.cxx files).
+#
+# The dialog window can be a self-consistent class (i.e. depends only
+# on Qt classes) or a classe that inherits from the class
+# GenericDialog whose implementation is provided in this package and
+# whose design is defined by the GenericDialog.ui file (editable using
+# the qt designer).
+#
+# The -t option let you choose between the two possibilities (specify
+# "-t qdialog" for the first case, "-t gdialog" otherwise).
+#
+# OPTION:
+# -n : specify the name of the class (default is TestDialog)
+#
+# -t : specify the type of the class (default is qdialog)
+#
+#_fin_usage
+# ==================================================================
+#
+
+thisScript=$(which $0)
+TOOLDIRNAME=$(dirname $0)
+
+displayUsage()
+{
+ cat $thisScript | sed -e '/^#_debut_usage/,/^#_fin_usage/!d' \
+ -e '/^#_debut_usage/d' \
+ -e '/^#_fin_usage/d' \
+ -e 's/^#//g'
+}
+
+#
+# Read the options on the command line
+#
+className=TestDialog
+classType=dialog
+if [ $# -eq 0 ]; then
+ displayUsage
+ exit 1
+else
+ while [ $# -ne 0 ]; do
+ case $1 in
+ -n)
+ shift; className=$1; shift ;;
+ -t)
+ shift; classType=$1; shift ;;
+ *)
+ displayUsage;;
+ esac
+ done
+fi
+
+if [ "$classType" = "qdialog" ]; then
+ sed s/__CLASSNAME__/$className/g $TOOLDIRNAME/__QDIALOG__.ui > $className.ui
+ sed s/__CLASSNAME__/$className/g $TOOLDIRNAME/__QDIALOG__.hxx > $className.hxx
+ sed s/__CLASSNAME__/$className/g $TOOLDIRNAME/__QDIALOG__.cxx > $className.cxx
+else
+ sed s/__CLASSNAME__/$className/g $TOOLDIRNAME/__GDIALOG__.ui > $className.ui
+ sed s/__CLASSNAME__/$className/g $TOOLDIRNAME/__GDIALOG__.hxx > $className.hxx
+ sed s/__CLASSNAME__/$className/g $TOOLDIRNAME/__GDIALOG__.cxx > $className.cxx
+fi
+
+displayMessage()
+{
+ cat $thisScript | sed -e '/^#_debut_message/,/^#_fin_message/!d' \
+ -e '/^#_debut_message/d' \
+ -e '/^#_fin_message/d' \
+ -e 's/^#//g' \
+ -e "s/__CLASSNAME__/$className/g"
+}
+
+#_debut_message
+##
+## ---------------------------------------------------------
+## Generation rules to create moc files from QObject headers
+## and form source files from ui files
+## ---------------------------------------------------------
+##
+#%_moc.cxx: %.hxx
+# $(MOC) $< -o $@
+#
+#ui_%.hxx: %.ui
+# $(UIC) -o $@ $<
+#
+##
+## ---------------------------------------------------------
+## Declaration of form files generated by UIC and MOC files
+## as BUILT_SOURCES to be used in the building process.
+## ---------------------------------------------------------
+##
+#UIC_FILES = \
+# ui___CLASSNAME__.hxx
+##
+#MOC_FILES = \
+# __CLASSNAME___moc.cxx
+#
+#BUILT_SOURCES = $(UIC_FILES)
+#
+##
+## ---------------------------------------------------------
+## Declaration of sources files to the building process
+## ---------------------------------------------------------
+## MOC files and UIC files should be added to the list of undistributed
+## source files with something like (where <MyLibrary> should be
+## replaced by the name of the product declared by the directive
+## lib_LTLIBRARIES):
+##
+#nodist_<MyLibrary>_la_SOURCES += $(MOC_FILES) $(UIC_FILES)
+#
+#dist_<MyLibrary>_la_SOURCES += __CLASSNAME__.cxx
+#salomeinclude_HEADERS += __CLASSNAME__.hxx
+#
+#<MyLibrary>_la_CPPFLAGS = \
+# $(QT_CXXFLAGS)
+#
+#<MyLibrary>_la_LDFLAGS = \
+# $(QT_LIBS)
+
+#_fin_message
+
+echo "Note that the following directives should be present in your Makefile.am (or something like that):"
+echo ""
+displayMessage
+
--- /dev/null
+//
+// This program can be used for unit test of dialog box.
+// You just have to include the interface file (*.h) and
+// use the dialog class as illustrated in the functions TEST_*.
+// (gboulant - 12/10/2010)
+//
+#include <QApplication>
+#include <QtGui>
+#include "GDialogTest.hxx"
+
+void TEST_show() {
+ GDialogTest * dialog = new GDialogTest();
+ dialog->show();
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ TEST_show();
+ return app.exec();
+}
--- /dev/null
+//
+// This program can be used for unit test of dialog box.
+// You just have to include the interface file (*.h) and
+// use the dialog class as illustrated in the functions TEST_*.
+// (gboulant - 12/10/2010)
+//
+#include <QApplication>
+#include <QtGui>
+#include "QDialogTest.hxx"
+
+void TEST_show() {
+ QDialogTest * dialog = new QDialogTest();
+ dialog->show();
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ TEST_show();
+ return app.exec();
+}