0024665: A sample for advanced function mechanism
authorbugmaster <bugmaster@opencascade.com>
Thu, 25 Feb 2016 14:08:20 +0000 (17:08 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 25 Feb 2016 14:08:20 +0000 (17:08 +0300)
Update for Linux platform

samples/qt/FuncDemo/FuncDemo.pro
samples/qt/FuncDemo/custom.bat
samples/qt/FuncDemo/custom.sh [new file with mode: 0644]
samples/qt/FuncDemo/env.sh [new file with mode: 0644]
samples/qt/FuncDemo/run.sh [new file with mode: 0644]
samples/qt/FuncDemo/src/FThread.cpp
samples/qt/FuncDemo/src/mainwindow.cpp

index c6bb1dc..64fa96d 100644 (file)
@@ -1,40 +1,12 @@
-######################################################################
-# Automatically generated by qmake (2.01a) ?? 11. ??? 12:03:38 2016
-######################################################################
-
 TEMPLATE = app
-TARGET = 
-DEPENDPATH += . src
-INCLUDEPATH += .
+CONFIG += debug_and_release qt
+
+TARGET = FuncDemo
+
+SAMPLESROOT = $$quote($$(CASROOT)/samples/qt)
 
-# Input
-HEADERS += src/BaseDriver.h \
-           src/CircleDriver.h \
-           src/ConeDriver.h \
-           src/CylinderDriver.h \
-           src/edge.h \
-           src/FThread.h \
-           src/graphwidget.h \
-           src/mainwindow.h \
-           src/node.h \
-           src/PointDriver.h \
-           src/PrismDriver.h \
-           src/ShapeSaverDriver.h \
-           src/SimpleDriver.h
-SOURCES += src/BaseDriver.cpp \
-           src/CircleDriver.cpp \
-           src/ConeDriver.cpp \
-           src/CylinderDriver.cpp \
-           src/edge.cpp \
-           src/FThread.cpp \
-           src/graphwidget.cpp \
-           src/main.cpp \
-           src/mainwindow.cpp \
-           src/node.cpp \
-           src/PointDriver.cpp \
-           src/PrismDriver.cpp \
-           src/ShapeSaverDriver.cpp \
-           src/SimpleDriver.cpp
+HEADERS = src/*.h
+SOURCES = src/*.cpp
 
 INCLUDEPATH += $$quote($$(CASROOT)/inc)
 
@@ -86,6 +58,24 @@ win32 {
 LIBS += -lTKernel -lTKMath -lTKBRep -lTKGeomBase -lTKGeomAlgo -lTKG3d -lTKG2d \
         -lTKTopAlgo -lTKMesh -lTKPrim -lTKCDF -lTKLCAF -lTKCAF -lTKBO
 
+lrelease.name = LRELEASE ${QMAKE_FILE_IN}
+lrelease.commands = lrelease ${QMAKE_FILE_IN} -qm $${RES_DIR}/${QMAKE_FILE_BASE}.qm
+lrelease.output = ${QMAKE_FILE_BASE}.qm
+lrelease.input = TS_FILES
+lrelease.clean = $${RES_DIR}/${QMAKE_FILE_BASE}.qm
+lrelease.CONFIG += no_link target_predeps
+QMAKE_EXTRA_COMPILERS += lrelease
+
+copy_res.name = Copy resource ${QMAKE_FILE_IN}
+copy_res.output = ${QMAKE_FILE_BASE}${QMAKE_FILE_EXT}
+copy_res.clean = $${RES_DIR}/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT}
+copy_res.input = RES_FILES
+copy_res.CONFIG += no_link target_predeps
+win32: copy_res.commands = type ${QMAKE_FILE_IN} > $${RES_DIR}/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT}
+unix:  copy_res.commands = cp -f ${QMAKE_FILE_IN} $${RES_DIR}
+QMAKE_EXTRA_COMPILERS += copy_res
+#QMAKE_CXXFLAGS += /wd4996
+
 greaterThan(QT_MAJOR_VERSION, 4) {
     QT += widgets
 }
index 895b72e..115ac2c 100644 (file)
@@ -1,3 +1,3 @@
 @echo off
 rem Define QTDIR variable
-set QTDIR=D:\Qt\4.8.2
+set QTDIR=
diff --git a/samples/qt/FuncDemo/custom.sh b/samples/qt/FuncDemo/custom.sh
new file mode 100644 (file)
index 0000000..708bb7f
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/bash
+#Define QTDIR variables in order to generate Makefile files by qmake
+export QTDIR=
diff --git a/samples/qt/FuncDemo/env.sh b/samples/qt/FuncDemo/env.sh
new file mode 100644 (file)
index 0000000..f081139
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+export aSamplePath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+if [ -e "custom.sh" ]; then
+   source "custom.sh";
+fi
+
+if [ -e "${aSamplePath}/../../../env.sh" ]; then
+   source "${aSamplePath}/../../../env.sh";
+fi
+
+if test "${QTDIR}" == ""; then
+   echo "Environment variable \"QTDIR\" not defined. Define it in \"custom.sh\" script."
+   exit 1
+fi
+
+host=`uname -s`
+export STATION=$host
+
+export PATH=${QTDIR}/bin:${PATH}
diff --git a/samples/qt/FuncDemo/run.sh b/samples/qt/FuncDemo/run.sh
new file mode 100644 (file)
index 0000000..8129d8f
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+export aSamplePath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+if [ -e "${aSamplePath}/env.sh" ]; then source "${aSamplePath}/env.sh"; fi
+cd $aSamplePath
+
+aSystem=`uname -s`
+if [ "$aSystem" == "Darwin" ] && [ "$MACOSX_USE_GLX" != "true" ]; then
+  if [ "${CASDEB}" == "d" ]; then
+    BIN_DIR="${aSamplePath}/build/Debug/FuncDemo.app/Contents/MacOS"
+  else
+    BIN_DIR="${aSamplePath}/build/Release/FuncDemo.app/Contents/MacOS"
+  fi
+else
+  BIN_DIR="${aSamplePath}/${STATION}/bin${CASDEB}"
+fi
+
+PATH="${BIN_DIR}:${PATH}"
+export PATH
+
+if test ! -r "${BIN_DIR}/FuncDemo"; then
+  echo "Executable \"${BIN_DIR}/FuncDemo\" not found."
+  if [ "$aSystem" == "Darwin" ] && [ "$MACOSX_USE_GLX" != "true" ]; then
+    echo "Probably you don't compile the application. Build it with Xcode."
+  else
+    echo "Probably you don't compile the application. Execute \"make\"."
+  fi
+  exit 1
+fi
+
+${BIN_DIR}/FuncDemo
index 06bbc0f..48221dc 100644 (file)
@@ -1,5 +1,5 @@
 #include "FThread.h"
-#include "GraphWidget.h"
+#include "graphwidget.h"
 
 #include <TFunction_Function.hxx>
 #include <TFunction_IFunction.hxx>
@@ -67,7 +67,11 @@ void FThread::run()
         {
             L = getFreeFunction();
             if (L.IsNull())
-                ::Sleep(100);
+            #ifdef __GNUC__
+               sleep(0.001);
+            #else
+               ::Sleep(100);
+            #endif
             else
                 break;
         }
@@ -123,4 +127,4 @@ void FThread::run()
     }// while (More())
 
     graph->setFinished();
-}
\ No newline at end of file
+}
index 2122279..cb1f490 100644 (file)
@@ -54,6 +54,9 @@
 #include <TDataStd_Name.hxx>
 #include <TDataStd_Real.hxx>
 #include <TDataStd_RealArray.hxx>
+#ifdef __GNUC__
+#include <unistd.h>
+#endif
 
 MainWindow::MainWindow()
 {
@@ -171,7 +174,11 @@ void MainWindow::compute()
 
             // Process user-events.
             qApp->processEvents();
-            ::Sleep(100);
+            #ifdef __GNUC__
+               sleep(0.001);
+            #else
+               ::Sleep(100);
+            #endif
         }
     }
 
@@ -660,4 +667,4 @@ void MainWindow::createDefaultModel2()
     graph->createModel(doc);
 
     //app->SaveAs(doc, "W:\\TestFM\\model2.cbf");
-}
\ No newline at end of file
+}