Skip to content

Commit

Permalink
Added support for volumes and LRSplineSurface (OFF by default).
Browse files Browse the repository at this point in the history
  • Loading branch information
sbriseid committed Feb 11, 2013
1 parent 5062372 commit ffe3ccf
Show file tree
Hide file tree
Showing 15 changed files with 955 additions and 25 deletions.
151 changes: 135 additions & 16 deletions viewlib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
PROJECT(viewlib)

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

# Find modules

#FIND_PACKAGE(GoLRspline2D REQUIRED)

FIND_PACKAGE(OpenGL REQUIRED)
FIND_PACKAGE(Qt4 REQUIRED)
SET(Boost_ADDITIONAL_VERSIONS
"1.42" "1.42.0"
"1.43" "1.43.0"
"1.44" "1.44.0"
"1.46" "1.46.0"
"1.47" "1.47.0")
FIND_PACKAGE(Boost REQUIRED)

IF(WIN32)
SET(GLUT_INCLUDE_DIR
"$ENV{PROGRAMW6432}/Microsoft SDKs/Windows/v6.0A/Include"
)
ELSE(WIN32)
FIND_PACKAGE(GLUT REQUIRED)
ENDIF(WIN32)


MACRO (QT4_WRAP_UI_GO outfiles )
Expand All @@ -20,6 +28,10 @@ MACRO (QT4_WRAP_UI_GO outfiles )
GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/include/GoTools/viewlib/ui_${outfile}.h) # Here we set output
# MESSAGE(STATUS infile: ${infile})
# MESSAGE(STATUS outfile: ${outfile})
# MESSAGE(STATUS ui_options: ${ui_options})
# MESSAGE(STATUS QT_UIC_EXECUTABLE: ${QT_UIC_EXECUTABLE})
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_UIC_EXECUTABLE}
ARGS ${ui_options} -o ${outfile} ${infile}
Expand All @@ -28,6 +40,11 @@ MACRO (QT4_WRAP_UI_GO outfiles )
ENDFOREACH (it)
ENDMACRO (QT4_WRAP_UI_GO)


OPTION(ViewlibVolAndLRSupport "Include spline volumes?" OFF)
#OPTION(LRSplinesSupport "Include LRSplines?" OFF)


SET(QT_USE_QTOPENGL 1)
SET(QT_USE_QT3SUPPORT 1)
INCLUDE(${QT_USE_FILE})
Expand All @@ -40,9 +57,13 @@ INCLUDE_DIRECTORIES(
${viewlib_SOURCE_DIR}/include
${GoIgeslib_SOURCE_DIR}/include
${GoToolsCore_SOURCE_DIR}/include
${GoTools_COMMON_INCLUDE_DIRS}
${GoTrivariate_SOURCE_DIR}/include
${GoLRspline2D_SOURCE_DIR}/include
${sisl_SOURCE_DIR}/include
${QT_INCLUDES}
${OPENGL_INCLUDE_DIR}
${GLUT_INCLUDE_DIR}
${Boost_INCLUDE_DIR}
)


Expand All @@ -51,33 +72,135 @@ INCLUDE_DIRECTORIES(
SET(DEPLIBS
GoIgeslib
GoToolsCore
GoTrivariate
GoLRspline2D
sisl
${QT_LIBRARIES}
${OPENGL_LIBRARIES}
)


# # We also support LRSplines.
# IF (LRSplinesSupport)
# INCLUDE_DIRECTORIES(
# ${CUDA_TOOLKIT_INCLUDE}
# ${CUSPARSE_INCLUDE})
# CUDA_INCLUDE_DIRECTORIES(
# ${LinSolver_SOURCE_DIR}/src
# ${LinSolver_SOURCE_DIR}/include)
# ENDIF (LRSplinesSupport)


# Qt uic
FILE(GLOB_RECURSE viewlib_UIS include/*.ui)
# We not use GLOB_RECURSE to avoid including volume directory.
# For the file to be generated we need to pass it through the QT4_WRAP_CPP macro.
FILE(GLOB viewlib_UIS include/GoTools/viewlib/*.ui)
QT4_WRAP_UI_GO(viewlib_UIS_H ${viewlib_UIS})

# MESSAGE(STATUS "viewlib_UIS: "${viewlib_UIS}) # The source ui-files.
# MESSAGE(STATUS "viewlib_UIS_H: "${viewlib_UIS_H}) # The generated h-files.

# Qt moc. The option '-nw' is "not recommended" according to the Qt
# documentation, but it gets rid of warnings...
FILE(GLOB_RECURSE viewlib_MOC_HDRS_TMP include/*.h)
FILE(GLOB viewlib_MOC_HDRS_TMP ${viewlib_SOURCE_DIR}/include/GoTools/viewlib/*.h)
SET(viewlib_MOC_HDRS ${viewlib_MOC_HDRS_TMP} ${viewlib_UIS_H})
QT4_WRAP_CPP(viewlib_MOC_SRCS ${viewlib_MOC_HDRS}
OPTIONS "-nw")

# MESSAGE(STATUS "viewlib_MOC_HDRS:"${viewlib_MOC_HDRS})
# MESSAGE(STATUS "viewlib_MOC_SRCS:"${viewlib_MOC_SRCS})

# Make the viewlib library

FILE(GLOB_RECURSE viewlib_SRCS src/*.C include/*.h)
FILE(GLOB viewlib_SRCS src/*.C include/GoTools/viewlib/*.h)
ADD_LIBRARY(viewlib ${viewlib_SRCS} ${viewlib_MOC_SRCS})
SET_PROPERTY(TARGET viewlib
PROPERTY FOLDER "viewlib/Libs")


# For volume models, a few more includes and libs are needed.
IF (ViewlibVolAndLRSupport)
INCLUDE_DIRECTORIES(
include/GoTools/viewlib/vol_and_lr/gvRectangularVolumePaintable.h
include/GoTools/viewlib/vol_and_lr/RectangularVolumePropertySheet.h
)

MACRO (QT4_WRAP_UI_GO_VOLANDLR outfiles )
QT4_EXTRACT_OPTIONS(ui_files ui_options ${ARGN})
# MESSAGE("I am here")
FOREACH (it ${ui_files})
GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
SET(outfile ${viewlib_BINARY_DIR}/include/GoTools/viewlib/vol_and_lr/ui_${outfile}.h) # Here we set output
#SET(outfile ${viewlib_BINARY_DIR}/include/GoTools/viewlib/ui_${outfile}.h) # Here we set output
# MESSAGE(STATUS infile: ${infile})
# MESSAGE(STATUS outfile: ${outfile})
# MESSAGE(STATUS ui_options: ${ui_options})
# MESSAGE(STATUS QT_UIC_EXECUTABLE: ${QT_UIC_EXECUTABLE})
# ADD_CUSTOM_COMMAND(
# OUTPUT ${outfile}
# COMMAND ${QT_UIC_EXECUTABLE}
# ARGS ${ui_options} -o ${outfile} ${infile}
# MAIN_DEPENDENCY ${infile}
# )
ADD_CUSTOM_COMMAND(
OUTPUT ${outfile}
COMMAND uic
ARGS -o ${outfile} ${infile}
DEPENDS ${infile}
# MAIN_DEPENDENCY ${infile}
)
SET(${outfiles} ${${outfiles}} ${outfile})
ENDFOREACH (it)
# MESSAGE("I am not here")
ENDMACRO (QT4_WRAP_UI_GO_VOLANDLR)

# Qt uic
FILE(GLOB viewlib_volandlr_UIS ${viewlib_SOURCE_DIR}/include/GoTools/viewlib/vol_and_lr/*.ui)
# QT4_WRAP_UI_GO_VOLUME(viewlib_volandlr_UIS_H ${viewlib_volandlr_UIS})
# MESSAGE(STATUS "Wrapping volume!")
QT4_WRAP_UI_GO_VOLANDLR(viewlib_volandlr_UIS_H ${viewlib_volandlr_UIS})
# MESSAGE(STATUS "Done wrapping volume!")
# MESSAGE(STATUS "viewlib_volandlr_UIS: "${viewlib_volandlr_UIS}) # The source ui-files.
# MESSAGE(STATUS "viewlib_volandlr_UIS_H: "${viewlib_volandlr_UIS_H}) # The generated h-files.

# Qt moc. The option '-nw' is "not recommended" according to the Qt
# documentation, but it gets rid of warnings...
# MESSAGE(STATUS "Starting with moc stuff!")
FILE(GLOB viewlib_volandlr_MOC_HDRS_TMP ${viewlib_SOURCE_DIR}/include/GoTools/viewlib/vol_and_lr/*.h)
# MESSAGE(STATUS "viewlib_volandlr_MOC_HDRS_TMP:"${viewlib_volandlr_MOC_HDRS_TMP})
SET(viewlib_volandlr_MOC_HDRS ${viewlib_volandlr_MOC_HDRS_TMP} ${viewlib_volandlr_UIS_H})
QT4_WRAP_CPP(viewlib_volandlr_MOC_SRCS ${viewlib_volandlr_MOC_HDRS}
OPTIONS "-nw")
# MESSAGE(STATUS ${viewlib_volandlr_MOC_HDRS})
# MESSAGE(STATUS ${viewlib_volandlr_MOC_SRCS})
# MESSAGE(STATUS "Done with moc stuff!")

# Make the viewlibVolume library
FILE(GLOB_RECURSE viewlib_SRCS src/*.C include/*.h)
ADD_LIBRARY(viewlibVolAndLR ${viewlib_SRCS} ${viewlib_MOC_SRCS} ${viewlib_volandlr_SRCS} ${viewlib_volandlr_MOC_SRCS})
SET_PROPERTY(TARGET viewlibVolAndLR
PROPERTY FOLDER "viewlib/Libs")

# # Make the viewlibVolume library.
# FILE(GLOB viewlibVolume_src ${viewlib_SOURCE_DIR}/src/volume/*.C)
# ADD_LIBRARY(viewlibVolume STATIC ${viewlibVolume_src})
# MESSAGE(STATUS viewlibVolume_src: ${viewlibVolume_src})
# # TARGET_LINK_LIBRARIES(app_BenchSolvers
# # LinSolverCBlasDep ${CBLAS_LIBRARY} ${ATLAS_LIBRARY})

FILE(GLOB viewlibVolAndLR_APPS app/vol_and_lr/*.C)
FOREACH(app ${viewlibVolAndLR_APPS})
GET_FILENAME_COMPONENT(appname ${app} NAME_WE)
ADD_EXECUTABLE(${appname} ${app})
TARGET_LINK_LIBRARIES(${appname} viewlibVolAndLR ${DEPLIBS})
SET_TARGET_PROPERTIES(${appname}
PROPERTIES RUNTIME_OUTPUT_DIRECTORY app)
SET_PROPERTY(TARGET ${appname}
PROPERTY FOLDER "viewlib/Apps")
ENDFOREACH(app)

ENDIF (ViewlibVolAndLRSupport)


# Set various compiler flags

IF(NOT WIN32)
Expand Down Expand Up @@ -107,6 +230,7 @@ ADD_CUSTOM_COMMAND(
${viewlib_BINARY_DIR}/data
)

#ADD_SUBDIRECTORY(src)

# 'install' target
IF(WIN32)
Expand Down Expand Up @@ -138,30 +262,25 @@ IF(WIN32)
ELSE(WIN32)
# Linux
# lib
INSTALL(TARGETS viewlib DESTINATION lib COMPONENT viewlib)
INSTALL(TARGETS viewlib DESTINATION lib/GoTools)
# include
INSTALL(DIRECTORY include/GoTools/viewlib
DESTINATION include/GoTools
COMPONENT viewlib-dev
FILES_MATCHING PATTERN "*.h"
PATTERN ".svn" EXCLUDE
)
# include ui files
INSTALL(DIRECTORY ${viewlib_BINARY_DIR}/include/GoTools/viewlib/
DESTINATION include/GoTools/viewlib
COMPONENT viewlib-dev
FILES_MATCHING PATTERN "ui_*_form.h"
PATTERN ".svn" EXCLUDE
)
# data
INSTALL(DIRECTORY data/
DESTINATION share/GoTools/viewlib
COMPONENT viewlib
FILES_MATCHING PATTERN "*.g2" PATTERN "*.igs"
PATTERN ".svn" EXCLUDE
)
# bin
INSTALL(TARGETS goview DESTINATION bin COMPONENT viewlib)
INSTALL(TARGETS goview DESTINATION bin)
ENDIF(WIN32)

SET(CPACK_STRIP_FILES ${CPACK_STRIP_FILES} libviewlib.so)
49 changes: 49 additions & 0 deletions viewlib/app/vol_and_lr/goview_vol_and_lr.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//===========================================================================
//
// File: goview_vol_and_lr.C
//
// Created: Fri Feb 8 11:27:13 2013
//
// Author: Sverre Briseid <[email protected]>
//
// Revision: $Id$
//
// Description:
//
//===========================================================================

#include <utility>
#include <QApplication>

#include "GoTools/viewlib/vol_and_lr/DataHandlerVolAndLR.h"
#include "GoTools/viewlib/gvApplication.h"


/** An application for viewing spline surfaces and other geometrical objects.
*
* The program is based on the QT toolkit, OpenGL and Sintef's Go toolkit.
*
* This version adds support for volumes and LRSplines.
*
*/

//int less_largest_x_cntr=0, less_largest_y_cntr=0, less_smallest_y_cntr=0;

int main(int argc, char** argv)
{
// // Use the generic app object
QApplication theapp(argc, argv);

// Create our main widget
std::auto_ptr<DataHandler> dh(new DataHandlerVolAndLR);
gvApplication* appwidget = new gvApplication(dh, NULL, argv[0]);

appwidget->resize(500, 530);
// appwidget->resize(1300, 1100);
appwidget->show();
// theapp.setMainWidget(appwidget);
theapp.setActiveWindow(appwidget);

int return_value=theapp.exec();
return return_value;
}
2 changes: 2 additions & 0 deletions viewlib/include/GoTools/viewlib/gvApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ public slots:
// trimmed we plot the net of the underlying sf.
void show_control_nets();

void set_random_color();

protected:
void buildGUI();
Q3ButtonGroup* createObjectToggleBox();
Expand Down
11 changes: 5 additions & 6 deletions viewlib/include/GoTools/viewlib/gvColor.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
#define _GVCOLOR_H


//#include <boost/type_traits.hpp>
#include <boost/type_traits.hpp>
#include <cmath>
#include "GoTools/utils/config.h"

/// Represents a color by four floats, like in OpenGL.
struct gvColor
Expand All @@ -32,14 +31,14 @@ struct gvColor
template <typename NumericType>
gvColor(NumericType r, NumericType g, NumericType b)
{
setVal(Int2Type< is_floating_point<NumericType>::value >(),
setVal(Int2Type< boost::is_floating_point<NumericType>::value >(),
r, g, b);
}
template <typename NumericType>
gvColor(NumericType r, NumericType g, NumericType b,
NumericType alpha)
{
setVal(Int2Type< is_floating_point<NumericType>::value >(),
setVal(Int2Type< boost::is_floating_point<NumericType>::value >(),
r, g, b, alpha);
}

Expand All @@ -48,7 +47,7 @@ struct gvColor
NumericType alpha)
{
gvColor ret;
ret.setHsva(Int2Type< is_floating_point<NumericType>::value >(),
ret.setHsva(Int2Type< boost::is_floating_point<NumericType>::value >(),
h, s, v, alpha);
return ret;
}
Expand Down Expand Up @@ -135,7 +134,7 @@ struct gvColor
float fs=s/100.0f;
float fv=v/100.0f;
float fa=alpha/100.0f;
setHsva(Int2Type< is_floating_point<float>::value >(),
setHsva(Int2Type< boost::is_floating_point<float>::value >(),
fh,fs,fv,fa);
}

Expand Down
32 changes: 32 additions & 0 deletions viewlib/include/GoTools/viewlib/vol_and_lr/DataHandlerVolAndLR.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//===========================================================================
//
// File: DataHandlerVolAndLR.h
//
// Created: Fri Feb 8 16:21:46 2013
//
// Author: Sverre Briseid <[email protected]>
//
// Revision: $Id$
//
// Description:
//
//===========================================================================

#ifndef _DATAHANDLERVOLANDLR_H
#define _DATAHANDLERVOLANDLR_H

#include "GoTools/viewlib/DefaultDataHandler.h"

class DataHandlerVolAndLR : public DefaultDataHandler
{
public:
/// Default constructor. Initializes factory (by registering classes).
DataHandlerVolAndLR();
virtual ~DataHandlerVolAndLR();

virtual void create(shared_ptr<Go::GeomObject> obj,
const gvColor& col, int id);
};

#endif // _DATAHANDLERVOLANDLR_H

Loading

0 comments on commit ffe3ccf

Please sign in to comment.