Commit ef962f60 authored by Ruben Undheim's avatar Ruben Undheim

Imported Upstream version 0.0.34

parents
echo off
set PATH=D:\Programme\Qt\2009.01\qt\bin
set PATH=%PATH%;D:\Programme\Qt\2009.01\bin;D:\Programme\Qt\2009.01\mingw\bin
set PATH=%PATH%;%SystemRoot%\System32
set PATH=%PATH%;D:\devel\CSXCAD\release;D:\devel\QCSXCAD\release
set PATH=%PATH%;D:\devel\tinyxml\release
set PATH=%PATH%;D:\devel\fparser\release
set PATH=%PATH%;D:\opt\VTK\bin
echo on
echo %PATH%
.\release\AppCSXCAD.exe
\ No newline at end of file
/*
* Copyright (C) 2012-2015 Thorsten Liebig (Thorsten.Liebig@gmx.de)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QMenu>
#include <QMenuBar>
#include <QMessageBox>
#include "AppCSXCAD.h"
#include "QVTKStructure.h"
#include "QCSXCAD_Global.h"
AppCSXCAD::AppCSXCAD(QWidget *parent) : QCSXCAD(parent)
{
QMenuBar* mb = menuBar();
QMenu *FileMenu = mb->addMenu("&File");
if (QCSX_Settings.GetEdit())
FileMenu->addAction(QIcon(":/images/filenew.png"),tr("New"),this,SLOT(New()),QKeySequence(tr("Ctrl+N")));
FileMenu->addAction(QIcon(":/images/fileopen.png"),tr("Load"),this,SLOT(ImportGeometry()),QKeySequence(tr("Ctrl+L")));
FileMenu->addSeparator();
if (QCSX_Settings.GetEdit())
{
FileMenu->addAction(QIcon(":/images/filesave.png"),tr("Save"),this,SLOT(Save()),QKeySequence(tr("Ctrl+S")));
FileMenu->addAction(QIcon(":/images/filesave.png"),tr("Save As"),this,SLOT(ExportGeometry()));
}
//FileMenu->addAction(QIcon(":/images/filesaveas.png"),tr("Save As.."),this,SLOT(SaveAs()));
QMenu *FileExportMenu = FileMenu->addMenu(tr("E&xport"));
FileExportMenu->addAction(QIcon(":/images/filesave.png"),tr("CSXCAD XML"),this,SLOT(ExportGeometry()));
FileExportMenu->addAction(QIcon(":/images/filesave.png"),tr("Pov&ray"),this,SLOT(ExportGeometry_Povray()),QKeySequence(tr("Ctrl+R")));
FileExportMenu->addAction(QIcon(":/images/filesave.png"),tr("Polydata-&VTK"),this,SLOT(ExportGeometry_PolyDataVTK()));
FileExportMenu->addAction(QIcon(":/images/filesave.png"),tr("STL"),this,SLOT(ExportGeometry_STL()));
FileExportMenu->addAction(QIcon(":/images/filesave.png"),tr("PLY"),this,SLOT(ExportGeometry_PLY()));
FileExportMenu->addAction(QIcon(":/images/filesave.png"),tr("3D view to &PNG"),this,SLOT(ExportView2Image()),QKeySequence(tr("Ctrl+P")));
FileExportMenu->addAction(QIcon(":/images/filesave.png"),tr("&X3D"),this,SLOT(ExportGeometry_X3D()),QKeySequence(tr("Ctrl+3")));
FileMenu->addSeparator();
FileMenu->addAction(QIcon(":/images/exit.png"),tr("Exit"),qApp,SLOT(quit()));
QMenu *InfoMenu = mb->addMenu("Info");
InfoMenu->addAction(tr("About"),this,SLOT(aboutQCSXCAD()));
QStringList argList=qApp->arguments();
if (argList.size()>1)
{
QString file = argList.back();
if (!file.startsWith("-"))
if (ReadFile(file)==false)
QMessageBox::information(this,"File Error!",tr("Can't open file: %1").arg(file));
GUIUpdate();
}
QString title = tr("AppCSXCAD");
if (QCSX_Settings.GetEdit()==false)
title += " - " + tr("View Mode");
setWindowTitle(title);
View3D();
LoadSettings();
parseCommandLineArguments(qApp->arguments());
}
AppCSXCAD::~AppCSXCAD()
{
SaveSettings();
}
void AppCSXCAD::parseCommandLineArguments(const QStringList &argList)
{
for (int n=0;n<argList.size();++n)
{
QString arg = argList.at(n);
if (!arg.startsWith("--"))
continue;
QStringList arg_split = arg.split("=",QString::SkipEmptyParts);
if (arg_split.size()==0)
continue;
//compate with all known args
if (arg_split.at(0).compare("--export-polydata-vtk")==0)
{
std::cout << "AppCSXCAD - exporting 3D view to polydata vtk" << std::endl;
if (arg_split.size()<=1)
continue;
ExportGeometry_PolyDataVTK(arg_split.at(1));
}
if (arg_split.at(0).compare("--export-STL")==0)
{
std::cout << "AppCSXCAD - exporting 3D data to STL" << std::endl;
if (arg_split.size()<=1)
continue;
ExportGeometry_STL(arg_split.at(1));
}
}
}
void AppCSXCAD::SaveSettings()
{
QSettings settings(__APPNAME__,__APPNAME__);
settings.beginGroup("MainWindow");
settings.setValue("Geometry",saveGeometry());
settings.setValue("State",saveState());
settings.endGroup();
}
void AppCSXCAD::LoadSettings()
{
QSettings settings(__APPNAME__, __APPNAME__);
settings.beginGroup("MainWindow");
restoreGeometry(settings.value("Geometry").toByteArray());
restoreState(settings.value("State").toByteArray());
settings.endGroup();
}
bool AppCSXCAD::ReadFile(QString filename)
{
m_filename=filename;
return QCSXCAD::ReadFile(filename);
}
void AppCSXCAD::Save()
{
Write2XML(m_filename);
}
void AppCSXCAD::clear()
{
m_filename=QString();
QCSXCAD::clear();
}
/*
* Copyright (C) 2012-2015 Thorsten Liebig (Thorsten.Liebig@gmx.de)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef APPCSXCAD_H
#define APPCSXCAD_H
#include <QWidget>
#include <QString>
#include <QStringList>
#include "QCSXCAD.h"
#define __APPNAME__ "AppCSXCAD"
class AppCSXCAD : public QCSXCAD
{
Q_OBJECT
public:
AppCSXCAD(QWidget *parent = 0);
virtual ~AppCSXCAD();
virtual bool ReadFile(QString filename);
public slots:
void Save();
virtual void clear();
protected:
void parseCommandLineArguments(const QStringList &argList);
void SaveSettings();
void LoadSettings();
QString m_filename;
};
#endif // APPCSXCAD_H
#!/bin/bash
BIN_PATH=`dirname $0`
# unset the library search path
# Matlab sets it to point to an old libc
export LD_LIBRARY_PATH=
# Important! If you get a vtk error like this:
# ERROR: In /builddir/build/BUILD/VTK/Rendering/vtkXOpenGLRenderWindow.cxx, line 404
# vtkXOpenGLRenderWindow (0xbe2980): Could not find a decent visual
# you need to uncomment the next line:
# export LIBGL_ALWAYS_INDIRECT=y
$BIN_PATH/AppCSXCAD $@
# define build type
IF( DEFINED CMAKE_BUILD_TYPE )
SET( CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Set to either \"Release\" or \"Debug\"" )
ELSE()
SET( CMAKE_BUILD_TYPE Release CACHE STRING "Set to either \"Release\" or \"Debug\"" )
ENDIF()
PROJECT( AppCSXCAD CXX)
cmake_minimum_required(VERSION 2.8)
if(POLICY CMP0020)
cmake_policy(SET CMP0020 OLD)
endif()
IF(EXISTS ${PROJECT_SOURCE_DIR}/localConfig.cmake)
include(${PROJECT_SOURCE_DIR}/localConfig.cmake)
ENDIF()
# default
set(VERSION "v0.2.1")
# add git revision
IF(EXISTS ${PROJECT_SOURCE_DIR}/.git )
FIND_PACKAGE(Git)
# Get the latest abbreviated commit hash of the working branch
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE GITREV
)
set(VERSION ${GITREV})
string(STRIP ${VERSION} VERSION)
message(STATUS "Found Git repository, ${PROJECT_NAME} version tag: ${VERSION}")
ENDIF()
ADD_DEFINITIONS(-DGIT_VERSION=\"${VERSION}\")
#
# Set up RPATH for the project
#
option(ENABLE_RPATH "Enable rpath support on Linux and Mac" ON)
if(NOT CMAKE_INSTALL_RPATH)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
endif()
if(APPLE AND NOT CMAKE_INSTALL_NAME_DIR)
set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
endif()
if(UNIX AND ENABLE_RPATH)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif()
# Set locations of extra CMake modules
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${openEMS_SOURCE_DIR}/cmake/Modules/")
# CSXCAD
# $ cmake -DCSXCAD_ROOT_DIR=~/opt/openEMS .
# SET(CSXCAD_ROOT_DIR ~/opt/openEMS)
find_library(CSXCAD_LIBRARIES
NAMES CSXCAD
HINTS ${CSXCAD_ROOT_DIR}/lib${LIB_SUFFIX}
NO_CMAKE_FIND_ROOT_PATH
)
message(STATUS "CSXCAD_LIBRARIES: ${CSXCAD_LIBRARIES}" )
#TODO test if CSXCADs was found
find_path(CSXCAD_INCLUDE_DIR
NAMES ContinuousStructure.h
HINTS ${CSXCAD_ROOT_DIR}/include
PATH_SUFFIXES "CSXCAD" ${CSXCAD_INCLUDE_DIR}
NO_CMAKE_FIND_ROOT_PATH
)
message(STATUS "CSXCAD_INCLUDE_DIR: ${CSXCAD_INCLUDE_DIR}" )
INCLUDE_DIRECTORIES( ${CSXCAD_INCLUDE_DIR} )
# QCSXCAD
# $ cmake -DQCSXCAD_ROOT_DIR=~/opt/openEMS .
# SET(QCSXCAD_ROOT_DIR ~/opt/openEMS)
find_library(QCSXCAD_LIBRARIES
NAMES QCSXCAD
HINTS ${QCSXCAD_ROOT_DIR}/lib${LIB_SUFFIX}
NO_CMAKE_FIND_ROOT_PATH
)
message(STATUS "QCSXCAD_LIBRARIES: ${QCSXCAD_LIBRARIES}" )
#TODO test if QCSXCADs was found
find_path(QCSXCAD_INCLUDE_DIR
NAMES QCSXCAD.h
HINTS ${QCSXCAD_ROOT_DIR}/include
PATH_SUFFIXES "QCSXCAD" ${QCSXCAD_INCLUDE_DIR}
NO_CMAKE_FIND_ROOT_PATH
)
message(STATUS "QCSXCAD_INCLUDE_DIR: ${QCSXCAD_INCLUDE_DIR}" )
INCLUDE_DIRECTORIES( ${QCSXCAD_INCLUDE_DIR} )
# vtk
if (WIN32)
find_package(VTK 6.1 REQUIRED)
else()
# prefer >=6.1, fallback to >=5.4
find_package(VTK 6.1 COMPONENTS vtkGUISupportQt NO_MODULE)
IF (NOT ${VTK_FOUND})
find_package(VTK REQUIRED)
endif()
endif()
message(STATUS "Found package VTK. Using " ${VTK_VERSION})
include(${VTK_USE_FILE})
INCLUDE_DIRECTORIES(${VTK_INCLUDE_DIR})
if("${VTK_MAJOR_VERSION}" EQUAL 5)
set( vtk_LIBS
QVTK )
elseif("${VTK_MAJOR_VERSION}" EQUAL 6)
set( vtk_LIBS
vtkGUISupportQt)
endif()
message(STATUS "vtk libraries " ${vtk_LIBS})
# Qt
set(CMAKE_AUTOMOC ON)
if(${VTK_VERSION} VERSION_GREATER "6" AND VTK_QT_VERSION VERSION_GREATER "4")
find_package(Qt5Widgets REQUIRED)
include_directories(${Qt5Widgets_INCLUDE_DIRS})
find_package(Qt5Xml REQUIRED)
include_directories(${Qt5Xml_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${Qt5_INCLUDE_DIRS})
set(CMAKE_CXX_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
else()
FIND_PACKAGE(Qt4 REQUIRED QtCore QtGui QtXml)
INCLUDE( ${QT_USE_FILE} )
endif()
message(STATUS "Found package VTK. Using version " ${VTK_VERSION})
SET(SOURCES
main.cpp
AppCSXCAD.cpp
)
ADD_EXECUTABLE( AppCSXCAD ${SOURCES} )
if(Qt5Widgets_FOUND)
qt5_use_modules(AppCSXCAD Widgets Xml)
endif()
TARGET_LINK_LIBRARIES( AppCSXCAD
${CSXCAD_LIBRARIES}
${QCSXCAD_LIBRARIES}
${QT_LIBRARIES}
${vtk_LIBS}
)
#
# Install the application.
# On Mac the bundle is also installed into bin.
#
INSTALL(TARGETS AppCSXCAD
BUNDLE DESTINATION bin COMPONENT Runtime
RUNTIME DESTINATION bin COMPONENT Runtime
)
if (UNIX)
INSTALL(FILES AppCSXCAD.sh
DESTINATION bin
PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)
endif ()
# TODO tarball
This diff is collapsed.
Install instructions for AppCSXCAD:
---------------------------------------------
1) Prerequirements:
AppCSXCAD relies on the QCSXCAD & CSXCAD libraries and its dependencies:
- CSXCAD, QCSXCAD (http://openEMS.de)
2) Build:
- change directory to QCSXCAD
- build:
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=<path/to/install/> -DCSXCAD_ROOT_DIR=<path/to/CSXCAD> -DQCSXCAD_ROOT_DIR=<path/to/QCSXCAD>