@ -0,0 +1,25 @@
|
||||
|
||||
GL2PS LICENSE
|
||||
Version 2, November 2003
|
||||
|
||||
Copyright (C) 2003, Christophe Geuzaine
|
||||
|
||||
Permission to use, copy, and distribute this software and its
|
||||
documentation for any purpose with or without fee is hereby granted,
|
||||
provided that the copyright notice appear in all copies and that both
|
||||
that copyright notice and this permission notice appear in supporting
|
||||
documentation.
|
||||
|
||||
Permission to modify and distribute modified versions of this software
|
||||
is granted, provided that:
|
||||
|
||||
1) the modifications are licensed under the same terms as this
|
||||
software;
|
||||
|
||||
2) you make available the source code of any modifications that you
|
||||
distribute, either on the same media as you distribute any executable
|
||||
or other form of this software, or via a mechanism generally accepted
|
||||
in the software development community for the electronic transfer of
|
||||
data.
|
||||
|
||||
This software is provided "as is" without express or implied warranty.
|
@ -0,0 +1,199 @@
|
||||
/* $Id: gl2ps.h 173 2007-05-20 15:51:51Z krischnamurti $ */
|
||||
/*
|
||||
* GL2PS, an OpenGL to PostScript Printing Library
|
||||
* Copyright (C) 1999-2006 Christophe Geuzaine <geuz@geuz.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of either:
|
||||
*
|
||||
* a) the GNU Library General Public License as published by the Free
|
||||
* Software Foundation, either version 2 of the License, or (at your
|
||||
* option) any later version; or
|
||||
*
|
||||
* b) the GL2PS License as published by Christophe Geuzaine, either
|
||||
* version 2 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 either
|
||||
* the GNU Library General Public License or the GL2PS License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library in the file named "COPYING.LGPL";
|
||||
* if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||
* Cambridge, MA 02139, USA.
|
||||
*
|
||||
* You should have received a copy of the GL2PS License with this
|
||||
* library in the file named "COPYING.GL2PS"; if not, I will be glad
|
||||
* to provide one.
|
||||
*
|
||||
* For the latest info about gl2ps, see http://www.geuz.org/gl2ps/.
|
||||
* Please report all bugs and problems to <gl2ps@geuz.org>.
|
||||
*/
|
||||
|
||||
#ifndef __GL2PS_H__
|
||||
#define __GL2PS_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Define GL2PSDLL at compile time to build a Windows DLL */
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
|
||||
# if defined(_MSC_VER)
|
||||
# pragma warning(disable:4115)
|
||||
# if (_MSC_VER >= 1400) /* VS8 - not sure about VC7 */
|
||||
# pragma warning(disable: 4996) /* MS security enhancements */
|
||||
# endif
|
||||
# endif
|
||||
# include <windows.h>
|
||||
# if defined(GL2PSDLL)
|
||||
# if defined(GL2PSDLL_EXPORTS)
|
||||
# define GL2PSDLL_API __declspec(dllexport)
|
||||
# else
|
||||
# define GL2PSDLL_API __declspec(dllimport)
|
||||
# endif
|
||||
# else
|
||||
# define GL2PSDLL_API
|
||||
# endif
|
||||
#else
|
||||
# define GL2PSDLL_API
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) || defined(HAVE_OPENGL_GL_H)
|
||||
# include <OpenGL/gl.h>
|
||||
#else
|
||||
# include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
/* Support for compressed PostScript/PDF/SVG and for embedded PNG
|
||||
images in SVG */
|
||||
|
||||
#if defined(HAVE_ZLIB) || defined(HAVE_LIBZ)
|
||||
# define GL2PS_HAVE_ZLIB
|
||||
# if defined(HAVE_LIBPNG) || defined(HAVE_PNG)
|
||||
# define GL2PS_HAVE_LIBPNG
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Version number */
|
||||
|
||||
#define GL2PS_MAJOR_VERSION 1
|
||||
#define GL2PS_MINOR_VERSION 3
|
||||
#define GL2PS_PATCH_VERSION 2
|
||||
#define GL2PS_EXTRA_VERSION ""
|
||||
|
||||
#define GL2PS_VERSION (GL2PS_MAJOR_VERSION + \
|
||||
0.01 * GL2PS_MINOR_VERSION + \
|
||||
0.0001 * GL2PS_PATCH_VERSION)
|
||||
|
||||
#define GL2PS_COPYRIGHT "(C) 1999-2006 Christophe Geuzaine (geuz@geuz.org)"
|
||||
|
||||
/* Output file formats (the values and the ordering are important!) */
|
||||
|
||||
#define GL2PS_PS 0
|
||||
#define GL2PS_EPS 1
|
||||
#define GL2PS_TEX 2
|
||||
#define GL2PS_PDF 3
|
||||
#define GL2PS_SVG 4
|
||||
#define GL2PS_PGF 5
|
||||
|
||||
/* Sorting algorithms */
|
||||
|
||||
#define GL2PS_NO_SORT 1
|
||||
#define GL2PS_SIMPLE_SORT 2
|
||||
#define GL2PS_BSP_SORT 3
|
||||
|
||||
/* Message levels and error codes */
|
||||
|
||||
#define GL2PS_SUCCESS 0
|
||||
#define GL2PS_INFO 1
|
||||
#define GL2PS_WARNING 2
|
||||
#define GL2PS_ERROR 3
|
||||
#define GL2PS_NO_FEEDBACK 4
|
||||
#define GL2PS_OVERFLOW 5
|
||||
#define GL2PS_UNINITIALIZED 6
|
||||
|
||||
/* Options for gl2psBeginPage */
|
||||
|
||||
#define GL2PS_NONE 0
|
||||
#define GL2PS_DRAW_BACKGROUND (1<<0)
|
||||
#define GL2PS_SIMPLE_LINE_OFFSET (1<<1)
|
||||
#define GL2PS_SILENT (1<<2)
|
||||
#define GL2PS_BEST_ROOT (1<<3)
|
||||
#define GL2PS_OCCLUSION_CULL (1<<4)
|
||||
#define GL2PS_NO_TEXT (1<<5)
|
||||
#define GL2PS_LANDSCAPE (1<<6)
|
||||
#define GL2PS_NO_PS3_SHADING (1<<7)
|
||||
#define GL2PS_NO_PIXMAP (1<<8)
|
||||
#define GL2PS_USE_CURRENT_VIEWPORT (1<<9)
|
||||
#define GL2PS_COMPRESS (1<<10)
|
||||
#define GL2PS_NO_BLENDING (1<<11)
|
||||
#define GL2PS_TIGHT_BOUNDING_BOX (1<<12)
|
||||
|
||||
/* Arguments for gl2psEnable/gl2psDisable */
|
||||
|
||||
#define GL2PS_POLYGON_OFFSET_FILL 1
|
||||
#define GL2PS_POLYGON_BOUNDARY 2
|
||||
#define GL2PS_LINE_STIPPLE 3
|
||||
#define GL2PS_BLEND 4
|
||||
|
||||
/* Text alignment (o=raster position; default mode is BL):
|
||||
+---+ +---+ +---+ +---+ +---+ +---+ +-o-+ o---+ +---o
|
||||
| o | o | | o | | | | | | | | | | | |
|
||||
+---+ +---+ +---+ +-o-+ o---+ +---o +---+ +---+ +---+
|
||||
C CL CR B BL BR T TL TR */
|
||||
|
||||
#define GL2PS_TEXT_C 1
|
||||
#define GL2PS_TEXT_CL 2
|
||||
#define GL2PS_TEXT_CR 3
|
||||
#define GL2PS_TEXT_B 4
|
||||
#define GL2PS_TEXT_BL 5
|
||||
#define GL2PS_TEXT_BR 6
|
||||
#define GL2PS_TEXT_T 7
|
||||
#define GL2PS_TEXT_TL 8
|
||||
#define GL2PS_TEXT_TR 9
|
||||
|
||||
typedef GLfloat GL2PSrgba[4];
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
GL2PSDLL_API GLint gl2psBeginPage(const char *title, const char *producer,
|
||||
GLint viewport[4], GLint format, GLint sort,
|
||||
GLint options, GLint colormode,
|
||||
GLint colorsize, GL2PSrgba *colormap,
|
||||
GLint nr, GLint ng, GLint nb, GLint buffersize,
|
||||
FILE *stream, const char *filename);
|
||||
GL2PSDLL_API GLint gl2psEndPage(void);
|
||||
GL2PSDLL_API GLint gl2psSetOptions(GLint options);
|
||||
GL2PSDLL_API GLint gl2psBeginViewport(GLint viewport[4]);
|
||||
GL2PSDLL_API GLint gl2psEndViewport(void);
|
||||
GL2PSDLL_API GLint gl2psText(const char *str, const char *fontname,
|
||||
GLshort fontsize);
|
||||
GL2PSDLL_API GLint gl2psTextOpt(const char *str, const char *fontname,
|
||||
GLshort fontsize, GLint align, GLfloat angle);
|
||||
GL2PSDLL_API GLint gl2psSpecial(GLint format, const char *str);
|
||||
GL2PSDLL_API GLint gl2psDrawPixels(GLsizei width, GLsizei height,
|
||||
GLint xorig, GLint yorig,
|
||||
GLenum format, GLenum type, const void *pixels);
|
||||
GL2PSDLL_API GLint gl2psEnable(GLint mode);
|
||||
GL2PSDLL_API GLint gl2psDisable(GLint mode);
|
||||
GL2PSDLL_API GLint gl2psPointSize(GLfloat value);
|
||||
GL2PSDLL_API GLint gl2psLineWidth(GLfloat value);
|
||||
GL2PSDLL_API GLint gl2psBlendFunc(GLenum sfactor, GLenum dfactor);
|
||||
|
||||
/* undocumented */
|
||||
GL2PSDLL_API GLint gl2psDrawImageMap(GLsizei width, GLsizei height,
|
||||
const GLfloat position[3],
|
||||
const unsigned char *imagemap);
|
||||
GL2PSDLL_API const char *gl2psGetFileExtension(GLint format);
|
||||
GL2PSDLL_API const char *gl2psGetFormatDescription(GLint format);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __GL2PS_H__ */
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
|
||||
QwtPlot3D license -- January 5th, 2005
|
||||
|
||||
Copyright (C) 2003-2005 Michael Bieber
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the author be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
*/
|
@ -0,0 +1,227 @@
|
||||
# Doxyfile 1.4.3
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
PROJECT_NAME = "QwtPlot3D API"
|
||||
PROJECT_NUMBER = 0.2.7
|
||||
OUTPUT_DIRECTORY =
|
||||
CREATE_SUBDIRS = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
USE_WINDOWS_ENCODING = YES
|
||||
BRIEF_MEMBER_DESC = NO
|
||||
REPEAT_BRIEF = NO
|
||||
ABBREVIATE_BRIEF =
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
INLINE_INHERITED_MEMB = NO
|
||||
FULL_PATH_NAMES = NO
|
||||
STRIP_FROM_PATH =
|
||||
STRIP_FROM_INC_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
DETAILS_AT_TOP = NO
|
||||
INHERIT_DOCS = NO
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
SEPARATE_MEMBER_PAGES = NO
|
||||
TAB_SIZE = 2
|
||||
ALIASES =
|
||||
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
SUBGROUPING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
EXTRACT_ALL = NO
|
||||
EXTRACT_PRIVATE = NO
|
||||
EXTRACT_STATIC = YES
|
||||
EXTRACT_LOCAL_CLASSES = NO
|
||||
EXTRACT_LOCAL_METHODS = NO
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
HIDE_FRIEND_COMPOUNDS = YES
|
||||
HIDE_IN_BODY_DOCS = NO
|
||||
INTERNAL_DOCS = NO
|
||||
CASE_SENSE_NAMES = YES
|
||||
HIDE_SCOPE_NAMES = YES
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
INLINE_INFO = YES
|
||||
SORT_MEMBER_DOCS = NO
|
||||
SORT_BRIEF_DOCS = NO
|
||||
SORT_BY_SCOPE_NAME = NO
|
||||
GENERATE_TODOLIST = NO
|
||||
GENERATE_TESTLIST = NO
|
||||
GENERATE_BUGLIST = NO
|
||||
GENERATE_DEPRECATEDLIST= YES
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = YES
|
||||
SHOW_DIRECTORIES = YES
|
||||
FILE_VERSION_FILTER =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to warning and progress messages
|
||||
#---------------------------------------------------------------------------
|
||||
QUIET = YES
|
||||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = NO
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_NO_PARAMDOC = NO
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LOGFILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT = ../src \
|
||||
. \
|
||||
../include
|
||||
FILE_PATTERNS = *.cpp \
|
||||
*.h \
|
||||
*.dox
|
||||
RECURSIVE = YES
|
||||
EXCLUDE =
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS = moc_*
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS =
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
IMAGE_PATH = doxygenimages
|
||||
INPUT_FILTER =
|
||||
FILTER_PATTERNS =
|
||||
FILTER_SOURCE_FILES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to source browsing
|
||||
#---------------------------------------------------------------------------
|
||||
SOURCE_BROWSER = NO
|
||||
INLINE_SOURCES = NO
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
REFERENCED_BY_RELATION = YES
|
||||
REFERENCES_RELATION = YES
|
||||
USE_HTAGS = NO
|
||||
VERBATIM_HEADERS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
ALPHABETICAL_INDEX = YES
|
||||
COLS_IN_ALPHA_INDEX = 4
|
||||
IGNORE_PREFIX = Qwt3D
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the HTML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_HTML = YES
|
||||
HTML_OUTPUT = web/doxygen
|
||||
HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER =
|
||||
HTML_STYLESHEET = web/navigation/doxygen.css
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
GENERATE_HTMLHELP = NO
|
||||
CHM_FILE = qwtplot3d.chm
|
||||
HHC_LOCATION = "c:\Programme\HTML Help Workshop\hhc.exe"
|
||||
GENERATE_CHI = NO
|
||||
BINARY_TOC = YES
|
||||
TOC_EXPAND = YES
|
||||
DISABLE_INDEX = NO
|
||||
ENUM_VALUES_PER_LINE = 4
|
||||
GENERATE_TREEVIEW = NO
|
||||
TREEVIEW_WIDTH = 250
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the LaTeX output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_LATEX = NO
|
||||
LATEX_OUTPUT = latex
|
||||
LATEX_CMD_NAME = latex
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
COMPACT_LATEX = YES
|
||||
PAPER_TYPE = a4
|
||||
EXTRA_PACKAGES =
|
||||
LATEX_HEADER =
|
||||
PDF_HYPERLINKS = YES
|
||||
USE_PDFLATEX = YES
|
||||
LATEX_BATCHMODE = NO
|
||||
LATEX_HIDE_INDICES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_RTF = NO
|
||||
RTF_OUTPUT = rtf
|
||||
COMPACT_RTF = NO
|
||||
RTF_HYPERLINKS = NO
|
||||
RTF_STYLESHEET_FILE =
|
||||
RTF_EXTENSIONS_FILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_MAN = NO
|
||||
MAN_OUTPUT = man
|
||||
MAN_EXTENSION = .3
|
||||
MAN_LINKS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the XML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_XML = NO
|
||||
XML_OUTPUT = xml
|
||||
XML_SCHEMA =
|
||||
XML_DTD =
|
||||
XML_PROGRAMLISTING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options for the AutoGen Definitions output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the Perl module output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_PERLMOD = NO
|
||||
PERLMOD_LATEX = NO
|
||||
PERLMOD_PRETTY = YES
|
||||
PERLMOD_MAKEVAR_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the preprocessor
|
||||
#---------------------------------------------------------------------------
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = NO
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
SEARCH_INCLUDES = YES
|
||||
INCLUDE_PATH = V:/cvs/qwtplot3d/include/
|
||||
INCLUDE_FILE_PATTERNS = *.h
|
||||
PREDEFINED = QWT3D_NOT_FOR_DOXYGEN \
|
||||
QT_VERSION=0x040000
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
TAGFILES =
|
||||
GENERATE_TAGFILE =
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = NO
|
||||
PERL_PATH = /usr/bin/perl
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
CLASS_DIAGRAMS = YES
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HAVE_DOT = NO
|
||||
CLASS_GRAPH = YES
|
||||
COLLABORATION_GRAPH = YES
|
||||
GROUP_GRAPHS = YES
|
||||
UML_LOOK = NO
|
||||
TEMPLATE_RELATIONS = YES
|
||||
INCLUDE_GRAPH = YES
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
CALL_GRAPH = NO
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
DIRECTORY_GRAPH = YES
|
||||
DOT_IMAGE_FORMAT = png
|
||||
DOT_PATH = V:/graphviz/Graphviz/bin/
|
||||
DOTFILE_DIRS =
|
||||
MAX_DOT_GRAPH_WIDTH = 974
|
||||
MAX_DOT_GRAPH_HEIGHT = 10000
|
||||
MAX_DOT_GRAPH_DEPTH = 0
|
||||
DOT_TRANSPARENT = NO
|
||||
DOT_MULTI_TARGETS = NO
|
||||
GENERATE_LEGEND = YES
|
||||
DOT_CLEANUP = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to the search engine
|
||||
#---------------------------------------------------------------------------
|
||||
SEARCHENGINE = NO
|
@ -0,0 +1,7 @@
|
||||
<hr><address style="align: right;"><small>
|
||||
The documentation for the QwtPlot3D API has been created by <a href="http://www.doxygen.org/index.html">
|
||||
<img src="doxygen.png" alt="doxygen" align="middle" border=0 width=110 height=53>
|
||||
</a> $doxygenversion and is hosted at </small> <a href="http://sourceforge.net">
|
||||
<img src="http://sourceforge.net/sflogo.php?group_id=78209&type=1" width="88" height="31" border="0" alt="SourceForge.net Logo" /></a></address>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,176 @@
|
||||
BODY {
|
||||
background-color: #FAF8E8;
|
||||
background: white;
|
||||
font-family:sans-serif;
|
||||
color:black;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4 {
|
||||
font-family:sans-serif;
|
||||
color: #005A9C;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
H1 {
|
||||
text-align: center;
|
||||
font-size: 18px;
|
||||
}
|
||||
H2 {
|
||||
font-size: 16px;
|
||||
}
|
||||
CAPTION { font-weight: bold }
|
||||
DIV.qindex { width: 100%;
|
||||
background-color: #eeeeff;
|
||||
border: 4px solid #eeeeff;
|
||||
text-align: center;
|
||||
margin-bottom: 2px
|
||||
}
|
||||
|
||||
a:link { font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 13px; color: #3366ff}
|
||||
a:visited { font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 13px; color: #3366ff}
|
||||
a:hover { font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 13px; color: #3366ff}
|
||||
|
||||
|
||||
A.qindex:hover { background-color: #ddddff }
|
||||
A.qindexHL { background-color: #6666cc;
|
||||
color: #ffffff
|
||||
}
|
||||
A.qindexHL:hover { background-color: #6666cc }
|
||||
A.qindexRef:hover { background-color: #ddddff }
|
||||
A.qindexRefHL { background-color: #6666cc;
|
||||
color: #ffffff
|
||||
}
|
||||
A.qindexRefHL:hover { background-color: #6666cc }
|
||||
|
||||
A.el { text-decoration: none }
|
||||
A.code { text-decoration: none; font-weight: normal; color: #4444ee }
|
||||
A.codeRef { font-weight: normal; color: #4444ee }
|
||||
A:hover { text-decoration: none; background-color: #f2f2ff }
|
||||
|
||||
DL.el { margin-left: -1cm }
|
||||
DIV.fragment {
|
||||
width: 98%;
|
||||
border: 1px solid #CCCCCC;
|
||||
background-color: #f5f5f5;
|
||||
padding-left: 4px;
|
||||
margin: 4px;
|
||||
}
|
||||
DIV.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px }
|
||||
TD{ font-size: 13px;}
|
||||
TD.md { background-color: #f2f2ff; font-weight: bold}
|
||||
TD.mdname1 { background-color: #f2f2ff; font-weight: bold; color: #602020}
|
||||
TD.mdname { background-color: #f2f2ff; font-weight: bold; color: #602020; width: 600px}
|
||||
DIV.groupHeader { margin-left: 16px; margin-top: 12px; margin-bottom: 6px; font-weight: bold }
|
||||
DIV.groupText { margin-left: 16px; font-style: italic; font-size: smaller }
|
||||
BODY {
|
||||
background: white;
|
||||
color: black;
|
||||
margin-right: 20px;
|
||||
margin-left: 20px;
|
||||
}
|
||||
TD.indexkey {
|
||||
background-color: #eeeeff;
|
||||
padding-right : 10px;
|
||||
padding-top : 2px;
|
||||
padding-left : 10px;
|
||||
padding-bottom : 2px;
|
||||
margin-left : 0px;
|
||||
margin-right : 0px;
|
||||
margin-top : 2px;
|
||||
margin-bottom : 2px
|
||||
}
|
||||
TD.indexvalue {
|
||||
background-color: #eeeeff;
|
||||
padding-right : 10px;
|
||||
padding-top : 2px;
|
||||
padding-left : 10px;
|
||||
padding-bottom : 2px;
|
||||
margin-left : 0px;
|
||||
margin-right : 0px;
|
||||
margin-top : 2px;
|
||||
margin-bottom : 2px
|
||||
}
|
||||
TR.memlist {
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
P.formulaDsp { text-align: center; }
|
||||
IMG.formulaDsp { }
|
||||
IMG.formulaInl { vertical-align: middle; }
|
||||
SPAN.keyword { color: #008000 }
|
||||
SPAN.keywordtype { color: #604020 }
|
||||
SPAN.keywordflow { color: #e08000 }
|
||||
SPAN.comment { color: #800000 }
|
||||
SPAN.preprocessor { color: #806020 }
|
||||
SPAN.stringliteral { color: #002080 }
|
||||
SPAN.charliteral { color: #008080 }
|
||||
.mdTable {
|
||||
border: 1px solid #868686;
|
||||
background-color: #f2f2ff;
|
||||
}
|
||||
.mdRow {
|
||||
padding: 8px 20px;
|
||||
}
|
||||
.mdescLeft {
|
||||
font-size: smaller;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
background-color: #FAFAFA;
|
||||
padding-left: 8px;
|
||||
border-top: 1px none #E0E0E0;
|
||||
border-right: 1px none #E0E0E0;
|
||||
border-bottom: 1px none #E0E0E0;
|
||||
border-left: 1px none #E0E0E0;
|
||||
margin: 0px;
|
||||
}
|
||||
.mdescRight {
|
||||
font-size: smaller;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-style: italic;
|
||||
background-color: #FAFAFA;
|
||||
padding-left: 4px;
|
||||
border-top: 1px none #E0E0E0;
|
||||
border-right: 1px none #E0E0E0;
|
||||
border-bottom: 1px none #E0E0E0;
|
||||
border-left: 1px none #E0E0E0;
|
||||
margin: 0px;
|
||||
padding-bottom: 0px;
|
||||
padding-right: 8px;
|
||||
}
|
||||
.memItemLeft {
|
||||
padding: 1px 0px 0px 8px;
|
||||
margin: 4px;
|
||||
border-top-width: 1px;
|
||||
border-right-width: 1px;
|
||||
border-bottom-width: 1px;
|
||||
border-left-width: 1px;
|
||||
border-top-style: solid;
|
||||
border-top-color: #E0E0E0;
|
||||
border-right-color: #E0E0E0;
|
||||
border-bottom-color: #E0E0E0;
|
||||
border-left-color: #E0E0E0;
|
||||
border-right-style: none;
|
||||
border-bottom-style: none;
|
||||
border-left-style: none;
|
||||
background-color: #FAFAFA;
|
||||
font-family: Geneva, Arial, Helvetica, sans-serif;
|
||||
font-size: 13px;
|
||||
}
|
||||
.memItemRight {
|
||||
padding: 1px 0px 0px 8px;
|
||||
margin: 4px;
|
||||
border-top-width: 1px;
|
||||
border-right-width: 1px;
|
||||
border-bottom-width: 1px;
|
||||
border-left-width: 1px;
|
||||
border-top-style: solid;
|
||||
border-top-color: #E0E0E0;
|
||||
border-right-color: #E0E0E0;
|
||||
border-bottom-color: #E0E0E0;
|
||||
border-left-color: #E0E0E0;
|
||||
border-right-style: none;
|
||||
border-bottom-style: none;
|
||||
border-left-style: none;
|
||||
background-color: #FAFAFA;
|
||||
font-family: Geneva, Arial, Helvetica, sans-serif;
|
||||
font-size: 13px;
|
||||
}
|
After Width: | Height: | Size: 2.3 KiB |
@ -0,0 +1,12 @@
|
||||
BODY{ background: url(bg1.gif) }
|
||||
|
||||
A:link {text-decoration:none; color: #004080}
|
||||
A:visited {text-decoration:none; color: #003060}
|
||||
A:active {text-decoration:none; color:#6F6F00}
|
||||
|
||||
|
||||
TD { font-family:Arial,sans-serif }
|
||||
TD.outside{background-color: #D0A000}
|
||||
TD.inside{background-color: #FAF8D0; text-align: center; font-size:14px;}
|
||||
TD.selected_outside{background-color: #0000E0}
|
||||
TD.alt_outside{background-color:#88BBAA}
|
After Width: | Height: | Size: 2.1 KiB |
@ -0,0 +1,2 @@
|
||||
REM set QMAKESPEC=win32-msvc.net
|
||||
qmake qwtplot3d.pro
|
@ -0,0 +1,102 @@
|
||||
#include <qapplication.h>
|
||||
#include <qsplitter.h>
|
||||
#include <qtimer.h>
|
||||
|
||||
#include "autoswitch.h"
|
||||
|
||||
using namespace Qwt3D;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// autoswitch.cpp
|
||||
//
|
||||
// Demonstrates autoswitching axes with a cutted saddle as data
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
Plot::Plot(QWidget* pw, int updateinterval)
|
||||
:SurfacePlot(pw)
|
||||
{
|
||||
setRotation(30,0,15);
|
||||
setShift(0.1,0,0);
|
||||
setZoom(0.8);
|
||||
coordinates()->setNumberFont("Courier",8);
|
||||
|
||||
for (unsigned i=0; i!=coordinates()->axes.size(); ++i)
|
||||
{
|
||||
coordinates()->axes[i].setMajors(7);
|
||||
coordinates()->axes[i].setMinors(4);
|
||||
}
|
||||
|
||||
|
||||
coordinates()->axes[Qwt3D::X1].setLabelString("x");
|
||||
coordinates()->axes[Y1].setLabelString("y");
|
||||
coordinates()->axes[Z1].setLabelString("z");
|
||||
coordinates()->axes[X2].setLabelString("x");
|
||||
coordinates()->axes[Y2].setLabelString("y");
|
||||
coordinates()->axes[Z2].setLabelString("z");
|
||||
coordinates()->axes[X3].setLabelString("x");
|
||||
coordinates()->axes[Y3].setLabelString("y");
|
||||
coordinates()->axes[Z3].setLabelString("z");
|
||||
coordinates()->axes[X4].setLabelString("x");
|
||||
coordinates()->axes[Y4].setLabelString("y");
|
||||
coordinates()->axes[Z4].setLabelString("z");
|
||||
|
||||
|
||||
QTimer* timer = new QTimer( this );
|
||||
connect( timer, SIGNAL(timeout()), this, SLOT(rotate()) );
|
||||
|
||||
timer->start(updateinterval);
|
||||
|
||||
}
|
||||
|
||||
void Plot::rotate()
|
||||
{
|
||||
int prec = 3;
|
||||
|
||||
setRotation(
|
||||
(int(prec*xRotation() + 2) % (360*prec))/double(prec),
|
||||
(int(prec*yRotation() + 2) % (360*prec))/double(prec),
|
||||
(int(prec*zRotation() + 2) % (360*prec))/double(prec)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
#if QT_VERSION < 0x040000
|
||||
QSplitter* spl = new QSplitter(QSplitter::Horizontal);
|
||||
#else
|
||||
QSplitter* spl = new QSplitter(Qt::Horizontal);
|
||||
#endif
|
||||
Plot* plot1 = new Plot(spl,30);
|
||||
plot1->setFloorStyle(FLOORISO);
|
||||
plot1->setCoordinateStyle(BOX);
|
||||
Saddle saddle(*plot1);
|
||||
saddle.create();
|
||||
plot1->setTitle("Autoswitching axes");
|
||||
plot1->setBackgroundColor(RGBA(1,1, 157./255));
|
||||
plot1->makeCurrent();
|
||||
plot1->updateData();
|
||||
plot1->updateGL();
|
||||
|
||||
|
||||
Plot* plot2 = new Plot(spl,80);
|
||||
plot2->setZoom(0.8);
|
||||
Hat hat(*plot2);
|
||||
hat.create();
|
||||
plot2->setPlotStyle(HIDDENLINE);
|
||||
plot2->setFloorStyle(FLOORDATA);
|
||||
plot2->setCoordinateStyle(FRAME);
|
||||
plot2->setBackgroundColor(RGBA(1,1, 157./255));
|
||||
plot2->makeCurrent();
|
||||
plot2->updateData();
|
||||
plot2->updateGL();
|
||||
|
||||
|
||||
#if QT_VERSION < 0x040000
|
||||
a.setMainWidget(spl);
|
||||
#endif
|
||||
spl->resize(800,400);
|
||||
spl->show();
|
||||
return a.exec();
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
#ifndef AUTOSWITCH_H__
|
||||
#define AUTOSWITCH_H__
|
||||
|
||||
#include <qtimer.h>
|
||||
#include "qwt3d_surfaceplot.h"
|
||||
#include "qwt3d_function.h"
|
||||
|
||||
typedef Qwt3D::SurfacePlot SurfacePlot; // VC6/moc issue
|
||||
typedef Qwt3D::Function Function; // VC6/moc issue
|
||||
|
||||
class Saddle : public Function
|
||||
{
|
||||
public:
|
||||
Saddle(SurfacePlot& pw)
|
||||
:Function(pw)
|
||||
{
|
||||
setDomain(-2.5,2.5,-2.5,2.5);
|
||||
setMaxZ(1.5);
|
||||
setMinZ(-1.5);
|
||||
setMesh(31,31);
|
||||
}
|
||||
|
||||
double operator()(double x, double y)
|
||||
{
|
||||
return x*y;
|
||||
}
|
||||
};
|
||||
|
||||
class Hat : public Function
|
||||
{
|
||||
public:
|
||||
|
||||
Hat(SurfacePlot& pw)
|
||||
:Function(pw)
|
||||
{
|
||||
setDomain(-1.5,1.5,-1.5,1.5);
|
||||
setMesh(41,41);
|
||||
}
|
||||
|
||||
double operator()(double x, double y)
|
||||
{
|
||||
return 1.0 / (x*x+y*y+0.3);
|
||||
}
|
||||
};
|
||||
|
||||
class Plot : public SurfacePlot
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Plot(QWidget* pw, int updateinterval);
|
||||
|
||||
public slots:
|
||||
void rotate();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,4 @@
|
||||
include( ../common.pro )
|
||||
|
||||
SOURCES = autoswitch.cpp
|
||||
HEADERS = autoswitch.h
|
@ -0,0 +1,15 @@
|
||||
include( ../common.pro )
|
||||
|
||||
SOURCES = src/main.cpp \
|
||||
src/axesmainwindow.cpp
|
||||
|
||||
HEADERS = src/axesmainwindow.h \
|
||||
src/axes.h
|
||||
|
||||
!isEmpty( ISQT4 ) {
|
||||
FORMS = src/axesmainwindowbase4.ui
|
||||
}
|
||||
isEmpty( ISQT4 ) {
|
||||
FORMS = src/axesmainwindowbase.ui
|
||||
}
|
||||
|
@ -0,0 +1,75 @@
|
||||
#ifndef axes_h__2004_06_07_10_38_begin_guarded_code
|
||||
#define axes_h__2004_06_07_10_38_begin_guarded_code
|
||||
|
||||
#include "qwt3d_plot.h"
|
||||
using namespace Qwt3D;
|
||||
|
||||
/*****************************
|
||||
*
|
||||
* Examples for user defined
|
||||
* tic labels
|
||||
*
|
||||
******************************/
|
||||
|
||||
class Letter : public LinearScale
|
||||
{
|
||||
public:
|
||||
explicit Letter(bool uppercase = true) : uc_(uppercase) {}
|
||||
Scale* clone() const {return new Letter(*this);}
|
||||
QString ticLabel(unsigned int idx) const
|
||||
{
|
||||
if (idx<majors_p.size() && idx < 26)
|
||||
return (uc_) ? QString(QChar('A'+idx)) : QString(QChar('a'+idx));
|
||||
return QString("-");
|
||||
}
|
||||
private:
|
||||
bool uc_;
|
||||
};
|
||||
|
||||
class Imaginary : public LinearScale
|
||||
{
|
||||
public:
|
||||
Scale* clone() const {return new Imaginary;}
|
||||
QString ticLabel(unsigned int idx) const
|
||||
{
|
||||
if (idx<majors_p.size())
|
||||
{
|
||||
double val = majors_p[idx];
|
||||
if (val)
|
||||
return QString::number(val) + "*i";
|
||||
return QString::number(val);
|
||||
}
|
||||
return QString("");
|
||||
}
|
||||
};
|
||||
|
||||
class TimeItems : public LinearScale
|
||||
{
|
||||
public:
|
||||
Scale* clone() const {return new TimeItems;}
|
||||
QString ticLabel(unsigned int idx) const
|
||||
{
|
||||
if (idx<majors_p.size())
|
||||
{
|
||||
QTime t = QTime::currentTime();
|
||||
int h = t.hour();
|
||||
int m = t.minute();
|
||||
if (m+idx > 59)
|
||||
{
|
||||
if (h==23)
|
||||
h=0;
|
||||
else
|
||||
h+=1;
|
||||
m = (m+idx) % 60;
|
||||
}
|
||||
else
|
||||
m += idx;
|
||||
|
||||
return QTime(h,m).toString("hh:mm")+"h";
|
||||
}
|
||||
return QString("");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif /* include guarded */
|
@ -0,0 +1,245 @@
|
||||
#include <qsplitter.h>
|
||||
#include <qlayout.h>
|
||||
#include <qcombobox.h>
|
||||
#include <qaction.h>
|
||||
#include <qslider.h>
|
||||
#include <qcheckbox.h>
|
||||
#include <qmenubar.h>
|
||||
#include <qdatetime.h>
|
||||
|
||||
#include "axes.h"
|
||||
#include "axesmainwindow.h"
|
||||
#include "../../../include/qwt3d_function.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace Qwt3D;
|
||||
|
||||
|
||||
// Example function
|
||||
class Rosenbrock : public Function
|
||||
{
|
||||
public:
|
||||
|
||||
Rosenbrock(SurfacePlot& pw)
|
||||
:Function(pw)
|
||||
{
|
||||
}
|
||||
|
||||
double operator()(double x, double y)
|
||||
{
|
||||
return log10((1-x)*(1-x) + 1 * (y - x*x)*(y - x*x));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Main widget
|
||||
|
||||
AxesMainWindow::AxesMainWindow( QWidget* parent)
|
||||
: DummyBase(parent)
|
||||
{
|
||||
#if QT_VERSION < 0x040000
|
||||
setCaption("axes");
|
||||
QGridLayout *grid = new QGridLayout( frame, 0, 0 );
|
||||
#else
|
||||
setupUi(this);
|
||||
QGridLayout *grid = new QGridLayout( frame);
|
||||
#endif
|
||||
|
||||
plot = new SurfacePlot(frame);
|
||||
grid->addWidget( plot, 0, 0 );
|
||||
|
||||
plot->setZoom(0.8);
|
||||
plot->setRotation(30,0,15);
|
||||
|
||||
plot->coordinates()->setGridLines(true,true);
|
||||
plot->setCoordinateStyle(BOX);
|
||||
//plot->setCoordinateStyle(NOCOORD);
|
||||
//plot->setPlotStyle(FILLED);
|
||||
|
||||
|
||||
rosenbrock = new Rosenbrock(*plot);
|
||||
|
||||
rosenbrock->setMesh(31,33);
|
||||
rosenbrock->setDomain(-1.73,1.8,-1.9,1.8);
|
||||
rosenbrock->setMinZ(-100);
|
||||
|
||||
rosenbrock->create();
|
||||
|
||||
for (unsigned i=0; i!=plot->coordinates()->axes.size(); ++i)
|
||||
{
|
||||
plot->coordinates()->axes[i].setMajors(5);
|
||||
plot->coordinates()->axes[i].setMinors(4);
|
||||
plot->coordinates()->axes[i].setLabelColor(RGBA(0,0,0.4));
|
||||
}
|
||||
|
||||
//plot->setTitle("Rosenbrock");
|
||||
plot->setMeshLineWidth(1);
|
||||
plot->coordinates()->setGridLinesColor(RGBA(0,0,0.5));
|
||||
plot->coordinates()->setLineWidth(1);
|
||||
plot->coordinates()->setNumberColor(RGBA(0,0.5,0));
|
||||
plot->coordinates()->setNumberFont("Courier",10);
|
||||
plot->setTitleFont("Courier",11);
|
||||
plot->coordinates()->setLabelFont("Courier",12, QFont::Bold);
|
||||
plot->coordinates()->axes[X1].setLabelString("X1");
|
||||
plot->coordinates()->axes[Y1].setLabelString("Y1");
|
||||
plot->coordinates()->axes[Z1].setLabelString("Z1");
|
||||
plot->coordinates()->axes[X2].setLabelString("X2");
|
||||
plot->coordinates()->axes[Y2].setLabelString("Y2");
|
||||
plot->coordinates()->axes[Z2].setLabelString("Z2");
|
||||
plot->coordinates()->axes[X3].setLabelString("X3");
|
||||
plot->coordinates()->axes[Y3].setLabelString("Y3");
|
||||
plot->coordinates()->axes[Z3].setLabelString("Z3");
|
||||
plot->coordinates()->axes[X4].setLabelString("X4");
|
||||
plot->coordinates()->axes[Y4].setLabelString("Y4");
|
||||
plot->coordinates()->axes[Z4].setLabelString("Z4");
|
||||
|
||||
|
||||
plot->coordinates()->setLineSmooth(true);
|
||||
smoothBox->setDown(true);
|
||||
|
||||
#if QT_VERSION < 0x040000
|
||||
Items->insertItem( "&Standard", this, SLOT(standardItems()), ALT+Key_S );
|
||||
Items->insertItem( "&Imaginary", this, SLOT(complexItems()), ALT+Key_I );
|
||||
Items->insertItem( "&Letter", this, SLOT(letterItems()), ALT+Key_L );
|
||||
Items->insertItem( "&Time", this, SLOT(timeItems()), ALT+Key_T );
|
||||
Items->insertItem( "&Log", this, SLOT(customScale()), ALT+Key_C );
|
||||
#else
|
||||
QMenu* Items = menuBar()->addMenu("Item");
|
||||
Items->addAction( "&Standard", this, SLOT(standardItems()), QKeySequence("ALT+S") );
|
||||
Items->addAction( "&Imaginary", this, SLOT(complexItems()), QKeySequence("ALT+I") );
|
||||
Items->addAction( "&Letter", this, SLOT(letterItems()), QKeySequence("ALT+L") );
|
||||
Items->addAction( "&Time", this, SLOT(timeItems()), QKeySequence("ALT+T") );
|
||||
Items->addAction( "&Log", this, SLOT(customScale()), QKeySequence("ALT+C") );
|
||||
#endif
|
||||
|
||||
plot->makeCurrent();
|
||||
plot->updateData();
|
||||
plot->updateGL();
|
||||
|
||||
connect(smoothBox, SIGNAL(toggled(bool)), this, SLOT(setSmoothLines(bool)) );
|
||||
connect(numbergapslider, SIGNAL(valueChanged(int)), this, SLOT(setNumberGap(int)) );
|
||||
connect(labelgapslider, SIGNAL(valueChanged(int)), this, SLOT(setLabelGap(int)) );
|
||||
connect(ticLengthSlider, SIGNAL(valueChanged(int)), this, SLOT(setTicLength(int)) );
|
||||
connect(ticNumberSlider, SIGNAL(valueChanged(int)), this, SLOT(setTicNumber(int)) );
|
||||
|
||||
tics = plot->coordinates()->axes[X1].majors();
|
||||
|
||||
//resetTics();
|
||||
|
||||
customScale();
|
||||
|
||||
plot->setPolygonOffset(10);
|
||||
}
|
||||
|
||||
AxesMainWindow::~AxesMainWindow()
|
||||
{
|
||||
delete rosenbrock;
|
||||
}
|
||||
|
||||
void AxesMainWindow::setNumberGap(int gap)
|
||||
{
|
||||
plot->coordinates()->adjustNumbers(gap);
|
||||
plot->makeCurrent();
|
||||
plot->updateGL();
|
||||
}
|
||||
|
||||
void AxesMainWindow::setLabelGap(int gap)
|
||||
{
|
||||
plot->coordinates()->adjustLabels(gap);
|
||||
plot->makeCurrent();
|
||||
plot->updateGL();
|
||||
}
|
||||
|
||||
void AxesMainWindow::setSmoothLines(bool val)
|
||||
{
|
||||
plot->coordinates()->setLineSmooth(val);
|
||||
plot->updateGL();
|
||||
}
|
||||
|
||||
void AxesMainWindow::setTicLength(int val)
|
||||
{
|
||||
double majl = (plot->coordinates()->second()-plot->coordinates()->first()).length() / 1000.;
|
||||
majl = majl * val;
|
||||
plot->coordinates()->setTicLength(majl,0.6*majl);
|
||||
plot->updateGL();
|
||||
}
|
||||
|
||||
void AxesMainWindow::setTicNumber(int degree)
|
||||
{
|
||||
plot->coordinates()->axes[X1].setMajors(tics + degree);
|
||||
plot->updateGL();
|
||||
}
|
||||
|
||||
void AxesMainWindow::resetTics()
|
||||
{
|
||||
ticNumberSlider->setEnabled(false);
|
||||
plot->setTitle("");
|
||||
plot->coordinates()->axes[X1].setMajors(5);
|
||||
plot->coordinates()->setAutoScale(true);
|
||||
plot->coordinates()->setStandardScale();
|
||||
plot->coordinates()->axes[Z2].setLabelString("Z4");
|
||||
plot->coordinates()->setGridLines(false,false,Qwt3D::BACK);
|
||||
}
|
||||
|
||||
void AxesMainWindow::standardItems()
|
||||
{
|
||||
resetTics();
|
||||
plot->updateGL();
|
||||
}
|
||||
|
||||
void AxesMainWindow::letterItems()
|
||||
{
|
||||
resetTics();
|
||||
ticNumberSlider->setEnabled(true);
|
||||
plot->coordinates()->axes[X1].setAutoScale(false);
|
||||
plot->coordinates()->setStandardScale();
|
||||
plot->coordinates()->axes[X1].setScale(new Letter);
|
||||
plot->coordinates()->axes[X2].setScale(new Letter);
|
||||
plot->coordinates()->axes[X3].setScale(new Letter);
|
||||
plot->coordinates()->axes[X4].setScale(new Letter);
|
||||
plot->coordinates()->axes[Y1].setScale(new Letter(false));
|
||||
plot->coordinates()->axes[Y2].setScale(new Letter(false));
|
||||
plot->coordinates()->axes[Y3].setScale(new Letter(false));
|
||||
plot->coordinates()->axes[Y4].setScale(new Letter(false));
|
||||
plot->setTitle("Use the tics slider for this example!");
|
||||
plot->updateGL();
|
||||
}
|
||||
|
||||
void AxesMainWindow::complexItems()
|
||||
{
|
||||
resetTics();
|
||||
plot->coordinates()->axes[Y1].setScale(new Imaginary);
|
||||
plot->coordinates()->axes[Y2].setScale(new Imaginary);
|
||||
plot->coordinates()->axes[Y3].setScale(new Imaginary);
|
||||
plot->coordinates()->axes[Y4].setScale(new Imaginary);
|
||||
plot->updateGL();
|
||||
}
|
||||
|
||||
void AxesMainWindow::timeItems()
|
||||
{
|
||||
resetTics();
|
||||
plot->coordinates()->axes[Z1].setScale(new TimeItems);
|
||||
plot->coordinates()->axes[Z2].setScale(new TimeItems);
|
||||
plot->coordinates()->axes[Z3].setScale(new TimeItems);
|
||||
plot->coordinates()->axes[Z4].setScale(new TimeItems);
|
||||
plot->updateGL();
|
||||
}
|
||||
|
||||
void AxesMainWindow::customScale()
|
||||
{
|
||||
resetTics();
|
||||
plot->coordinates()->axes[Z1].setScale(LOG10SCALE);
|
||||
plot->coordinates()->axes[Z3].setScale(LOG10SCALE);
|
||||
plot->coordinates()->axes[Z4].setScale(LOG10SCALE);
|
||||
plot->coordinates()->axes[Z2].setLabelString("log10(z)");
|
||||
// plot->coordinates()->axes[Z4].setScale(new LogScale);
|
||||
// plot->coordinates()->axes[Z1].setAutoScale(false);
|
||||
// plot->coordinates()->axes[Z2].setAutoScale(false);
|
||||
// plot->coordinates()->axes[Z3].setAutoScale(false);
|
||||
// plot->coordinates()->axes[Z4].setAutoScale(false);
|
||||
|
||||
plot->coordinates()->setGridLines(true,true,Qwt3D::BACK);
|
||||
|
||||
plot->updateGL();
|
||||
}
|
||||
|
@ -0,0 +1,64 @@
|
||||
#include <qmainwindow.h>
|
||||
|
||||
#include "qwt3d_surfaceplot.h"
|
||||
#include "qwt3d_function.h"
|
||||
#include "qwt3d_plot.h"
|
||||
|
||||
#if QT_VERSION < 0x040000
|
||||
#include "axesmainwindowbase.h"
|
||||
#else
|
||||
#include "ui_axesmainwindowbase4.h"
|
||||
#endif
|
||||
|
||||
//MOC_SKIP_BEGIN
|
||||
#if QT_VERSION < 0x040000
|
||||
class DummyBase : public AxesMainWindowBase
|
||||
{
|
||||
public:
|
||||
DummyBase(QWidget* parent = 0)
|
||||
: AxesMainWindowBase(parent)
|
||||
{
|
||||
}
|
||||
};
|
||||
#else
|
||||
class DummyBase : public QMainWindow, protected Ui::MainWindow
|
||||
{
|
||||
public:
|
||||
DummyBase(QWidget* parent = 0)
|
||||
: QMainWindow(parent)
|
||||
{
|
||||
}
|
||||
};
|
||||
#endif
|
||||
//MOC_SKIP_END
|
||||
|
||||
|
||||
class AxesMainWindow : public DummyBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AxesMainWindow( QWidget* parent = 0);
|
||||
~AxesMainWindow();
|
||||
Qwt3D::SurfacePlot* plot;
|
||||
Qwt3D::Function *rosenbrock;
|
||||
void resetTics();
|
||||
|
||||
public slots:
|
||||
void setNumberGap(int gap);
|
||||
void setLabelGap(int gap);
|
||||
|
||||
void setSmoothLines(bool);
|
||||
void setTicLength(int val);
|
||||
void setTicNumber(int degree);
|
||||
|
||||
void standardItems();
|
||||
void complexItems();
|
||||
void letterItems();
|
||||
void timeItems();
|
||||
void customScale();
|
||||
|
||||
private:
|
||||
|
||||
int tics;
|
||||
};
|
@ -0,0 +1,243 @@
|
||||
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||
<class>AxesMainWindowBase</class>
|
||||
<widget class="QMainWindow">
|
||||
<property name="name">
|
||||
<cstring>AxesMainWindowBase</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>826</width>
|
||||
<height>608</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="caption">
|
||||
<string>print</string>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<widget class="QFrame" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>frame</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>Sunken</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLayoutWidget" row="1" column="0">
|
||||
<property name="name">
|
||||
<cstring>layout11</cstring>
|
||||
</property>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>layout9</cstring>
|
||||
</property>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>TextLabel1_2</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Number gap</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSlider">
|
||||
<property name="name">
|
||||
<cstring>numbergapslider</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maxValue">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickmarks">
|
||||
<enum>Above</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>layout10</cstring>
|
||||
</property>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>TextLabel1_2_2</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Label gap</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSlider">
|
||||
<property name="name">
|
||||
<cstring>labelgapslider</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maxValue">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickmarks">
|
||||
<enum>Above</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
<widget class="QCheckBox" row="1" column="1" rowspan="1" colspan="2">
|
||||
<property name="name">
|
||||
<cstring>smoothBox</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Smooth Lines</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLayoutWidget" row="0" column="1">
|
||||
<property name="name">
|
||||
<cstring>layout11</cstring>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLayoutWidget" row="0" column="2" rowspan="2" colspan="1">
|
||||
<property name="name">
|
||||
<cstring>layout9</cstring>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLabel" row="0" column="0" rowspan="1" colspan="3">
|
||||
<property name="name">
|
||||
<cstring>ticNumeberLabel</cstring>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Tics</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSlider" row="1" column="0">
|
||||
<property name="name">
|
||||
<cstring>ticLengthSlider</cstring>
|
||||
</property>
|
||||
<property name="maxValue">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Vertical</enum>
|
||||
</property>
|
||||
<property name="tickmarks">
|
||||
<enum>Below</enum>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Tic Length (rel.)</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSlider" row="1" column="1">
|
||||
<property name="name">
|
||||
<cstring>ticNumberSlider</cstring>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maxValue">
|
||||
<number>25</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Vertical</enum>
|
||||
</property>
|
||||
<property name="tickmarks">
|
||||
<enum>Below</enum>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Change Tic Number (available only for letter example)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<menubar>
|
||||
<property name="name">
|
||||
<cstring>menubar</cstring>
|
||||
</property>
|
||||
<item text="Items" name="Items">
|
||||
</item>
|
||||
</menubar>
|
||||
<toolbars>
|
||||
</toolbars>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
</UI>
|
@ -0,0 +1,295 @@
|
||||
<ui version="4.0" >
|
||||
<author></author>
|
||||
<comment></comment>
|
||||
<exportmacro></exportmacro>
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>694</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget" >
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>8</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="QFrame" name="frame" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape" >
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow" >
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<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="label_4" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>0</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Tics</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QSlider" name="ticLengthSlider" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>0</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximum" >
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value" >
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="invertedAppearance" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="tickPosition" >
|
||||
<enum>QSlider::TicksBelow</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="ticNumberSlider" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>0</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximum" >
|
||||
<number>25</number>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="invertedAppearance" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="tickPosition" >
|
||||
<enum>QSlider::TicksBelow</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_2" >
|
||||
<layout class="QVBoxLayout" >
|
||||
<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_2" >
|
||||
<property name="text" >
|
||||
<string><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Number gap</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="numbergapslider" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>5</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximum" >
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickPosition" >
|
||||
<enum>QSlider::TicksAbove</enum>
|
||||
</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="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<string><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Label gap</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="labelgapslider" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>5</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximum" >
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickPosition" >
|
||||
<enum>QSlider::TicksAbove</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="smoothBox" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>1</hsizetype>
|
||||
<vsizetype>5</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Smooth Lines</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QWidget" name="widget" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>590</x>
|
||||
<y>10</y>
|
||||
<width>61</width>
|
||||
<height>421</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<pixmapfunction></pixmapfunction>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -0,0 +1,31 @@
|
||||
/********************************************************************
|
||||
created: 2003/09/10
|
||||
filename: main.cpp
|
||||
|
||||
author: Micha Bieber
|
||||
*********************************************************************/
|
||||
|
||||
#include <qapplication.h>
|
||||
#include "axesmainwindow.h"
|
||||
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
QApplication app( argc, argv );
|
||||
|
||||
if ( !QGLFormat::hasOpenGL() )
|
||||
{
|
||||
qWarning( "This system has no OpenGL support. Exiting." );
|
||||
return -1;
|
||||
}
|
||||
|
||||
AxesMainWindow mainwindow;
|
||||
|
||||
#if QT_VERSION < 0x040000
|
||||
app.setMainWidget(&mainwindow);
|
||||
#endif
|
||||
|
||||
mainwindow.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
After Width: | Height: | Size: 533 B |
@ -0,0 +1,34 @@
|
||||
TEMPLATE = app
|
||||
CONFIG += qt warn_on thread debug
|
||||
UI_DIR = tmp
|
||||
MOC_DIR = tmp
|
||||
OBJECTS_DIR = tmp
|
||||
INCLUDEPATH += ../../include
|
||||
DEPENDPATH = $$INCLUDEPATH
|
||||
DESTDIR = ../bin
|
||||
|
||||
unix:LIBS += -lqwtplot3d -L../../lib
|
||||
linux-g++:QMAKE_CXXFLAGS += -fno-exceptions
|
||||
|
||||
win32{
|
||||
LIBS += ../../lib/qwtplot3d.lib
|
||||
TEMPLATE = vcapp
|
||||
DEFINES += QT_DLL QWT3D_DLL
|
||||
RC_FILE = ../icon.rc
|
||||
contains (CONFIG, debug) {
|
||||
QMAKE_LFLAGS += /NODEFAULTLIB:msvcrt
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MYVERSION = $$[QMAKE_VERSION]
|
||||
ISQT4 = $$find(MYVERSION, ^[2-9])
|
||||
|
||||
!isEmpty( ISQT4 ) {
|
||||
RESOURCES = ../images.qrc
|
||||
QT += opengl
|
||||
}
|
||||
|
||||
isEmpty( ISQT4 ) {
|
||||
CONFIG += opengl
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
REM set QMAKESPEC=win32-msvc.net
|
||||
cd mesh2
|
||||
qmake mesh2.pro
|
||||
cd ../simpleplot
|
||||
qmake simpleplot.pro
|
||||
cd ../autoswitch
|
||||
qmake autoswitch.pro
|
||||
cd ../enrichments
|
||||
qmake enrichments.pro
|
||||
cd ../axes
|
||||
qmake axes.pro
|
||||
cd ..
|
@ -0,0 +1,16 @@
|
||||
include( ../common.pro )
|
||||
|
||||
SOURCES = src/main.cpp \
|
||||
src/enrichmentmainwindow.cpp \
|
||||
src/enrichments.cpp
|
||||
|
||||
HEADERS = src/enrichmentmainwindow.h \
|
||||
src/enrichments.h
|
||||
|
||||
!isEmpty( ISQT4 ) {
|
||||
FORMS = src/enrichmentmainwindowbase4.ui
|
||||
}
|
||||
isEmpty( ISQT4 ) {
|
||||
FORMS = src/enrichmentmainwindowbase.ui
|
||||
}
|
||||
|
@ -0,0 +1,147 @@
|
||||
#include <qlayout.h>
|
||||
#include <qslider.h>
|
||||
#include <qcheckbox.h>
|
||||
#include <qradiobutton.h>
|
||||
|
||||
|
||||
#include "enrichmentmainwindow.h"
|
||||
#include "enrichments.h"
|
||||
#include "../../../include/qwt3d_function.h"
|
||||
|
||||
using namespace Qwt3D;
|
||||
|
||||
|
||||
class Hat : public Function
|
||||
{
|
||||
public:
|
||||
|
||||
Hat(SurfacePlot& pw)
|
||||
:Function(pw)
|
||||
{
|
||||
}
|
||||
|
||||
double operator()(double x, double y)
|
||||
{
|
||||
double ret = 1.0 / (x*x+y*y+0.5);
|
||||
return ret;
|
||||
}
|
||||
QString name() const {return "$\\frac{1}{x^2+y^2+\\frac{1}{2}}$";}
|
||||
};
|
||||
|
||||
Hat* hat;
|
||||
|
||||
EnrichmentMainWindow::EnrichmentMainWindow( QWidget* parent )
|
||||
: DummyBase( parent )
|
||||
{
|
||||
#if QT_VERSION < 0x040000
|
||||
setCaption("enrichment");
|
||||
QGridLayout *grid = new QGridLayout( frame, 0, 0 );
|
||||
#else
|
||||
setupUi(this);
|
||||
QGridLayout *grid = new QGridLayout( frame);
|
||||
#endif
|
||||
|
||||
plot = new SurfacePlot(frame);
|
||||
grid->addWidget( plot, 0, 0 );
|
||||
|
||||
plot->setTitle("Bar Style (Vertex Enrichment)");
|
||||
plot->setTitleFont("Arial",12);
|
||||
|
||||
plot->setZoom(0.8);
|
||||
plot->setRotation(30,0,15);
|
||||
|
||||
plot->setCoordinateStyle(BOX);
|
||||
bar = (Bar*)plot->setPlotStyle(Bar(0.007,0.5));
|
||||
|
||||
hat = new Hat(*plot);
|
||||
|
||||
hat->setMesh(23,21);
|
||||
hat->setDomain(-1.8,1.7,-1.6,1.7);
|
||||
|
||||
hat->create();
|
||||
|
||||
for (unsigned i=0; i!=plot->coordinates()->axes.size(); ++i)
|
||||
{
|
||||
plot->coordinates()->axes[i].setMajors(5);
|
||||
plot->coordinates()->axes[i].setMinors(4);
|
||||
}
|
||||
|
||||
|
||||
//plot->setMeshLineWidth(1);
|
||||
plot->coordinates()->setGridLinesColor(RGBA(0,0,0.5));
|
||||
plot->coordinates()->setLineWidth(1);
|
||||
plot->coordinates()->setNumberFont("Courier",8);
|
||||
plot->coordinates()->adjustNumbers(5);
|
||||
|
||||
setColor();
|
||||
plot->updateData();
|
||||
plot->updateGL();
|
||||
|
||||
|
||||
levelSlider->setValue(50);
|
||||
level_ = 0.5;
|
||||
width_ = 0.007;
|
||||
connect( levelSlider, SIGNAL(valueChanged(int)), this, SLOT(setLevel(int)) );
|
||||
|
||||
//connect( barBtn, SIGNAL(clicked()), this, SLOT(barSlot()) );
|
||||
//connect( sliceBtn, SIGNAL(clicked()), this, SLOT(sliceSlot()) );
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
}
|
||||
|
||||
EnrichmentMainWindow::~EnrichmentMainWindow()
|
||||
{
|
||||
delete hat;
|
||||
}
|
||||
|
||||
|
||||
void EnrichmentMainWindow::setColor()
|
||||
{
|
||||
Qwt3D::ColorVector cv;
|
||||
|
||||
RGBA rgb;
|
||||
int i = 252;
|
||||
int step = 4;
|
||||
|
||||
while (i>=0)
|
||||
{
|
||||
rgb.r = i/255.; rgb.g=(i-60>0) ? (i-60)/255.:0;rgb.b=0;
|
||||
// rgb.a = 0.2;
|
||||
cv.push_back(rgb);
|
||||
if (!--step)
|
||||
{
|
||||
i-=4;
|
||||
step=4;
|
||||
}
|
||||
}
|
||||
StandardColor* col = new StandardColor(plot);
|
||||
col->setColorVector(cv);
|
||||
|
||||
plot->setDataColor(col);
|
||||
}
|
||||
|
||||
|
||||
void EnrichmentMainWindow::setLevel(int i)
|
||||
{
|
||||
level_ = 1 - i / 100.;
|
||||
bar->configure(width_,level_);
|
||||
plot->updateData();
|
||||
plot->updateGL();
|
||||
}
|
||||
|
||||
void EnrichmentMainWindow::setWidth(int i)
|
||||
{
|
||||
width_ = i / 20000.;
|
||||
bar->configure(width_,level_);
|
||||
plot->updateData();
|
||||
plot->updateGL();
|
||||
}
|
||||
|
||||
void EnrichmentMainWindow::barSlot()
|
||||
{
|
||||
Bar b(width_,level_);
|
||||
bar = (Bar*)plot->setPlotStyle(b);
|
||||
plot->updateData();
|
||||
plot->updateGL();
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
#include "qwt3d_surfaceplot.h"
|
||||
#include "qwt3d_function.h"
|
||||
#include "qwt3d_plot.h"
|
||||
#include "enrichments.h"
|
||||
|
||||
|
||||
#if QT_VERSION < 0x040000
|
||||
#include "enrichmentmainwindowbase.h"
|
||||
#else
|
||||
#include "ui_enrichmentmainwindowbase4.h"
|
||||
#endif
|
||||
|
||||
//MOC_SKIP_BEGIN
|
||||
#if QT_VERSION < 0x040000
|
||||
class DummyBase : public EnrichmentMainWindowBase
|
||||
{
|
||||
public:
|
||||
DummyBase(QWidget* parent = 0)
|
||||
: EnrichmentMainWindowBase(parent)
|
||||
{
|
||||
}
|
||||
};
|
||||
#else
|
||||
class DummyBase : public QMainWindow, protected Ui::MainWindow
|
||||
{
|
||||
public:
|
||||
DummyBase(QWidget* parent = 0)
|
||||
: QMainWindow(parent)
|
||||
{
|
||||
}
|
||||
};
|
||||
#endif
|
||||
//MOC_SKIP_END
|
||||
|
||||
|
||||
class EnrichmentMainWindow : public DummyBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
EnrichmentMainWindow( QWidget* parent = 0 );
|
||||
~EnrichmentMainWindow();
|
||||
void setColor();
|
||||
Bar *bar;
|
||||
Qwt3D::SurfacePlot* plot;
|
||||
|
||||
public slots:
|
||||
void setLevel(int);
|
||||
void setWidth(int);
|
||||
void barSlot();
|
||||
|
||||
private:
|
||||
double level_, width_;
|
||||
|
||||
};
|
||||
|
||||
|
@ -0,0 +1,215 @@
|
||||
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||
<class>EnrichmentMainWindowBase</class>
|
||||
<widget class="QMainWindow">
|
||||
<property name="name">
|
||||
<cstring>EnrichmentMainWindowBase</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>843</width>
|
||||
<height>702</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="caption">
|
||||
<string>print</string>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<widget class="QLayoutWidget" row="1" column="0">
|
||||
<property name="name">
|
||||
<cstring>Layout11</cstring>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<widget class="QLayoutWidget" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>Layout10</cstring>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<widget class="QLabel" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>TextLabel1_2</cstring>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Width</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSlider" row="0" column="1">
|
||||
<property name="name">
|
||||
<cstring>widthSlider</cstring>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="minValue">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="maxValue">
|
||||
<number>200</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickmarks">
|
||||
<enum>Below</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Relative psition of slicing plane</string>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<widget class="QLayoutWidget" row="0" column="1">
|
||||
<property name="name">
|
||||
<cstring>Layout9</cstring>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
</grid>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<widget class="QLayoutWidget" row="0" column="1" rowspan="2" colspan="1">
|
||||
<property name="name">
|
||||
<cstring>Layout8</cstring>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<widget class="QSlider" row="1" column="0">
|
||||
<property name="name">
|
||||
<cstring>levelSlider</cstring>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maxValue">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Vertical</enum>
|
||||
</property>
|
||||
<property name="tickmarks">
|
||||
<enum>Below</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Changes the level, where marker are shown</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>TextLabel1</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Level</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<widget class="QFrame" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>frame</cstring>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>Sunken</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<menubar>
|
||||
<property name="name">
|
||||
<cstring>menubar</cstring>
|
||||
</property>
|
||||
</menubar>
|
||||
<toolbars>
|
||||
</toolbars>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
</UI>
|
@ -0,0 +1,167 @@
|
||||
<ui version="4.0" >
|
||||
<author></author>
|
||||
<comment></comment>
|
||||
<exportmacro></exportmacro>
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget" >
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0" >
|
||||
<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="QFrame" name="frame" >
|
||||
<property name="frameShape" >
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow" >
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<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="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Level</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="levelSlider" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>0</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximum" >
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value" >
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="invertedAppearance" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="tickPosition" >
|
||||
<enum>QSlider::TicksBelow</enum>
|
||||
</property>
|
||||
<property name="tickInterval" >
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>0</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Width</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="widthSlider" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimum" >
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="maximum" >
|
||||
<number>200</number>
|
||||
</property>
|
||||
<property name="value" >
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickPosition" >
|
||||
<enum>QSlider::TicksBelow</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<pixmapfunction></pixmapfunction>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -0,0 +1,150 @@
|
||||
#include "qbitmap.h"
|
||||
|
||||
#include "qwt3d_color.h"
|
||||
#include "qwt3d_plot.h"
|
||||
#include "enrichments.h"
|
||||
|
||||
using namespace Qwt3D;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bar
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
Bar::Bar()
|
||||
{
|
||||
configure(0, 1);
|
||||
}
|
||||
|
||||
Bar::Bar(double rad, double level)
|
||||
{
|
||||
configure(rad, level);
|
||||
}
|
||||
|
||||
void Bar::configure(double rad, double level)
|
||||
{
|
||||
plot = 0;
|
||||
radius_ = rad;
|
||||
level_ = level;
|
||||
}
|
||||
|
||||
void Bar::drawBegin()
|
||||
{
|
||||
diag_ = (plot->hull().maxVertex-plot->hull().minVertex).length() * radius_;
|
||||
glLineWidth( 0 );
|
||||
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||
glPolygonOffset(1,1);
|
||||
}
|
||||
|
||||
void Bar::drawEnd()
|
||||
{
|
||||
}
|
||||
|
||||
void Bar::draw(Qwt3D::Triple const& pos)
|
||||
{
|
||||
|
||||
// GLStateBewarer sb(GL_LINE_SMOOTH, true);
|
||||
// sb.turnOn();
|
||||
|
||||
double interval = plot->hull().maxVertex.z-plot->hull().minVertex.z;
|
||||
double numlevel = plot->hull().minVertex.z + level_ * interval;
|
||||
interval /=100;
|
||||
if (pos.z > numlevel - interval && pos.z < numlevel + interval )
|
||||
{
|
||||
Label3D lb;
|
||||
lb.draw(pos, diag_, diag_ * 2);
|
||||
}
|
||||
|
||||
GLdouble minz = plot->hull().minVertex.z;
|
||||
|
||||
RGBA rgbat = (*plot->dataColor())(pos);
|
||||
RGBA rgbab = (*plot->dataColor())(pos.x, pos.y, minz);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glColor4d(rgbab.r,rgbab.g,rgbab.b,rgbab.a);
|
||||
glVertex3d(pos.x-diag_,pos.y-diag_,minz);
|
||||
glVertex3d(pos.x+diag_,pos.y-diag_,minz);
|
||||
glVertex3d(pos.x+diag_,pos.y+diag_,minz);
|
||||
glVertex3d(pos.x-diag_,pos.y+diag_,minz);
|
||||
|
||||
if (pos.z > numlevel - interval && pos.z < numlevel + interval )
|
||||
glColor3d(0.7,0,0);
|
||||
else
|
||||
glColor4d(rgbat.r,rgbat.g,rgbat.b,rgbat.a);
|
||||
glVertex3d(pos.x-diag_,pos.y-diag_,pos.z);
|
||||
glVertex3d(pos.x+diag_,pos.y-diag_,pos.z);
|
||||
glVertex3d(pos.x+diag_,pos.y+diag_,pos.z);
|
||||
glVertex3d(pos.x-diag_,pos.y+diag_,pos.z);
|
||||
|
||||
glColor4d(rgbab.r,rgbab.g,rgbat.b,rgbab.a);
|
||||
glVertex3d(pos.x-diag_,pos.y-diag_,minz);
|
||||
glVertex3d(pos.x+diag_,pos.y-diag_,minz);
|
||||
glColor4d(rgbat.r,rgbat.g,rgbat.b,rgbat.a);
|
||||
glVertex3d(pos.x+diag_,pos.y-diag_,pos.z);
|
||||
glVertex3d(pos.x-diag_,pos.y-diag_,pos.z);
|
||||
|
||||
glColor4d(rgbab.r,rgbab.g,rgbat.b,rgbab.a);
|
||||
glVertex3d(pos.x-diag_,pos.y+diag_,minz);
|
||||
glVertex3d(pos.x+diag_,pos.y+diag_,minz);
|
||||
glColor4d(rgbat.r,rgbat.g,rgbat.b,rgbat.a);
|
||||
glVertex3d(pos.x+diag_,pos.y+diag_,pos.z);
|
||||
glVertex3d(pos.x-diag_,pos.y+diag_,pos.z);
|
||||
|
||||
glColor4d(rgbab.r,rgbab.g,rgbat.b,rgbab.a);
|
||||
glVertex3d(pos.x-diag_,pos.y-diag_,minz);
|
||||
glVertex3d(pos.x-diag_,pos.y+diag_,minz);
|
||||
glColor4d(rgbat.r,rgbat.g,rgbat.b,rgbat.a);
|
||||
glVertex3d(pos.x-diag_,pos.y+diag_,pos.z);
|
||||
glVertex3d(pos.x-diag_,pos.y-diag_,pos.z);
|
||||
|
||||
glColor4d(rgbab.r,rgbab.g,rgbat.b,rgbab.a);
|
||||
glVertex3d(pos.x+diag_,pos.y-diag_,minz);
|
||||
glVertex3d(pos.x+diag_,pos.y+diag_,minz);
|
||||
glColor4d(rgbat.r,rgbat.g,rgbat.b,rgbat.a);
|
||||
glVertex3d(pos.x+diag_,pos.y+diag_,pos.z);
|
||||
glVertex3d(pos.x+diag_,pos.y-diag_,pos.z);
|
||||
glEnd();
|
||||
|
||||
glColor3d(0,0,0);
|
||||
glBegin(GL_LINES);
|
||||
glVertex3d(pos.x-diag_,pos.y-diag_,minz); glVertex3d(pos.x+diag_,pos.y-diag_,minz);
|
||||
glVertex3d(pos.x-diag_,pos.y-diag_,pos.z); glVertex3d(pos.x+diag_,pos.y-diag_,pos.z);
|
||||
glVertex3d(pos.x-diag_,pos.y+diag_,pos.z); glVertex3d(pos.x+diag_,pos.y+diag_,pos.z);
|
||||
glVertex3d(pos.x-diag_,pos.y+diag_,minz); glVertex3d(pos.x+diag_,pos.y+diag_,minz);
|
||||
|
||||
glVertex3d(pos.x-diag_,pos.y-diag_,minz); glVertex3d(pos.x-diag_,pos.y+diag_,minz);
|
||||
glVertex3d(pos.x+diag_,pos.y-diag_,minz); glVertex3d(pos.x+diag_,pos.y+diag_,minz);
|
||||
glVertex3d(pos.x+diag_,pos.y-diag_,pos.z); glVertex3d(pos.x+diag_,pos.y+diag_,pos.z);
|
||||
glVertex3d(pos.x-diag_,pos.y-diag_,pos.z); glVertex3d(pos.x-diag_,pos.y+diag_,pos.z);
|
||||
|
||||
glVertex3d(pos.x-diag_,pos.y-diag_,minz); glVertex3d(pos.x-diag_,pos.y-diag_,pos.z);
|
||||
glVertex3d(pos.x+diag_,pos.y-diag_,minz); glVertex3d(pos.x+diag_,pos.y-diag_,pos.z);
|
||||
glVertex3d(pos.x+diag_,pos.y+diag_,minz); glVertex3d(pos.x+diag_,pos.y+diag_,pos.z);
|
||||
glVertex3d(pos.x-diag_,pos.y+diag_,minz); glVertex3d(pos.x-diag_,pos.y+diag_,pos.z);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void Label3D::draw(Qwt3D::Triple const& pos, double w, double h)
|
||||
{
|
||||
double gap = 0.3;
|
||||
glColor3d(1,1,1);
|
||||
glBegin(GL_QUADS);
|
||||
glVertex3d(pos.x-w,pos.y,pos.z + gap);
|
||||
glVertex3d(pos.x+w,pos.y,pos.z + gap);
|
||||
glVertex3d(pos.x+w,pos.y,pos.z + gap + h);
|
||||
glVertex3d(pos.x-w,pos.y,pos.z + gap + h);
|
||||
glEnd();
|
||||
glColor3d(0.4,0,0);
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glVertex3d(pos.x-w,pos.y,pos.z + gap);
|
||||
glVertex3d(pos.x+w,pos.y,pos.z + gap);
|
||||
glVertex3d(pos.x+w,pos.y,pos.z + gap + h);
|
||||
glVertex3d(pos.x-w,pos.y,pos.z + gap + h);
|
||||
glEnd();
|
||||
glBegin(GL_LINES);
|
||||
glVertex3d(pos.x,pos.y,pos.z);
|
||||
glVertex3d(pos.x,pos.y,pos.z + gap);
|
||||
glEnd();
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
#ifndef enrichments_h__2004_02_25_13_58_begin_guarded_code
|
||||
#define enrichments_h__2004_02_25_13_58_begin_guarded_code
|
||||
|
||||
#include "qwt3d_plot.h"
|
||||
|
||||
|
||||
class Bar : public Qwt3D::VertexEnrichment
|
||||
{
|
||||
public:
|
||||
Bar();
|
||||
Bar(double rad, double level);
|
||||
|
||||
Qwt3D::Enrichment* clone() const {return new Bar(*this);}
|
||||
|
||||
void configure(double rad, double level);
|
||||
void drawBegin();
|
||||
void drawEnd();
|
||||
void draw(Qwt3D::Triple const&);
|
||||
|
||||
private:
|
||||
double level_, radius_;
|
||||
double diag_;
|
||||
};
|
||||
|
||||
class Label3D
|
||||
{
|
||||
public:
|
||||
void draw(Qwt3D::Triple const&, double w, double h);
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,30 @@
|
||||
/********************************************************************
|
||||
created: 2003/09/10
|
||||
filename: main.cpp
|
||||
|
||||
author: Micha Bieber
|
||||
*********************************************************************/
|
||||
|
||||
#include <qapplication.h>
|
||||
#include "enrichmentmainwindow.h"
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
QApplication app( argc, argv );
|
||||
|
||||
if ( !QGLFormat::hasOpenGL() )
|
||||
{
|
||||
qWarning( "This system has no OpenGL support. Exiting." );
|
||||
return -1;
|
||||
}
|
||||
|
||||
EnrichmentMainWindow mainwindow;
|
||||
|
||||
#if QT_VERSION < 0x040000
|
||||
app.setMainWidget(&mainwindow);
|
||||
#endif
|
||||
|
||||
mainwindow.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
TEMPLATE = subdirs
|
||||
SUBDIRS = \
|
||||
simpleplot \
|
||||
autoswitch \
|
||||
enrichments \
|
||||
axes \
|
||||
mesh2
|
||||
|
||||
|
||||
|
@ -0,0 +1,43 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual Studio 2005
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "autoswitch", "autoswitch\autoswitch.vcproj", "{C925FD16-FB8D-3C0C-A955-78E37532F05B}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "axes", "axes\axes.vcproj", "{9DBB316E-B662-37E5-81FA-F07D1AD5DBF3}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "enrichments", "enrichments\enrichments.vcproj", "{DE9FA224-88EA-3A55-B709-A679DE8B943D}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mesh2", "mesh2\mesh2.vcproj", "{8001AE3F-B159-3472-A7B5-E866065C22AE}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "qwtplot3d", "..\qwtplot3d.vcproj", "{FCF9D3F3-79A6-3A08-92BE-6DAE29ADC6A5}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simpleplot", "simpleplot\simpleplot.vcproj", "{A81FCC17-CCAB-3CEC-9A30-C8F9EDD6F0D3}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{C925FD16-FB8D-3C0C-A955-78E37532F05B}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{C925FD16-FB8D-3C0C-A955-78E37532F05B}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{C925FD16-FB8D-3C0C-A955-78E37532F05B}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{9DBB316E-B662-37E5-81FA-F07D1AD5DBF3}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{9DBB316E-B662-37E5-81FA-F07D1AD5DBF3}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{9DBB316E-B662-37E5-81FA-F07D1AD5DBF3}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{DE9FA224-88EA-3A55-B709-A679DE8B943D}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{DE9FA224-88EA-3A55-B709-A679DE8B943D}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{DE9FA224-88EA-3A55-B709-A679DE8B943D}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{8001AE3F-B159-3472-A7B5-E866065C22AE}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{8001AE3F-B159-3472-A7B5-E866065C22AE}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{8001AE3F-B159-3472-A7B5-E866065C22AE}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{FCF9D3F3-79A6-3A08-92BE-6DAE29ADC6A5}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{FCF9D3F3-79A6-3A08-92BE-6DAE29ADC6A5}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{FCF9D3F3-79A6-3A08-92BE-6DAE29ADC6A5}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{A81FCC17-CCAB-3CEC-9A30-C8F9EDD6F0D3}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{A81FCC17-CCAB-3CEC-9A30-C8F9EDD6F0D3}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{A81FCC17-CCAB-3CEC-9A30-C8F9EDD6F0D3}.Release|Win32.ActiveCfg = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
After Width: | Height: | Size: 975 B |
After Width: | Height: | Size: 178 B |
After Width: | Height: | Size: 918 B |
After Width: | Height: | Size: 292 B |
After Width: | Height: | Size: 213 B |
After Width: | Height: | Size: 297 B |
After Width: | Height: | Size: 248 B |
After Width: | Height: | Size: 290 B |
After Width: | Height: | Size: 527 B |
After Width: | Height: | Size: 1001 B |
After Width: | Height: | Size: 820 B |
After Width: | Height: | Size: 890 B |
After Width: | Height: | Size: 969 B |
After Width: | Height: | Size: 877 B |
After Width: | Height: | Size: 799 B |
After Width: | Height: | Size: 1014 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 1.3 KiB |
@ -0,0 +1 @@
|
||||
IDI_ICON1 ICON DISCARDABLE "icon.ico"
|
@ -0,0 +1,31 @@
|
||||
<RCC>
|
||||
<qresource prefix="/images" >
|
||||
<file>box.png</file>
|
||||
<file>filecell.png</file>
|
||||
<file>fileopen.png</file>
|
||||
<file>filledmesh.png</file>
|
||||
<file>floordata.png</file>
|
||||
<file>floorempty.png</file>
|
||||
<file>flooriso.png</file>
|
||||
<file>floormesh.png</file>
|
||||
<file>frame.png</file>
|
||||
<file>grid.png</file>
|
||||
<file>gridb.png</file>
|
||||
<file>gridc.png</file>
|
||||
<file>gridf.png</file>
|
||||
<file>gridfr.png</file>
|
||||
<file>gridl.png</file>
|
||||
<file>gridr.png</file>
|
||||
<file>hiddenline.png</file>
|
||||
<file>icon.png</file>
|
||||
<file>movie.png</file>
|
||||
<file>nodata.png</file>
|
||||
<file>none.png</file>
|
||||
<file>normals.png</file>
|
||||
<file>polygon.png</file>
|
||||
<file>qwtplot.png</file>
|
||||
<file>savecontent.png</file>
|
||||
<file>scattered.png</file>
|
||||
<file>wireframe.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -0,0 +1,25 @@
|
||||
include( ../common.pro )
|
||||
|
||||
SOURCES = src/main.cpp \
|
||||
src/mesh2mainwindow.cpp \
|
||||
src/colormapreader.cpp \
|
||||
src/lightingdlg.cpp \
|
||||
src/mesh.cpp
|
||||
|
||||
HEADERS = src/mesh2mainwindow.h \
|
||||
src/functions.h \
|
||||
src/colormapreader.h \
|
||||
src/lightingdlg.h \
|
||||
src/femreader.h
|
||||
|
||||
!isEmpty( ISQT4 ) {
|
||||
SOURCES += src/designerworkaround.cpp
|
||||
HEADERS += src/designerworkaround.h
|
||||
FORMS = src/mesh2mainwindowbase4.ui \
|
||||
src/lightingdlgbase4.ui
|
||||
}
|
||||
isEmpty( ISQT4 ) {
|
||||
FORMS = src/mesh2mainwindowbase.ui \
|
||||
src/lightingdlgbase.ui
|
||||
}
|
||||
|
@ -0,0 +1,81 @@
|
||||
#include <fstream>
|
||||
|
||||
#include <qfileinfo.h>
|
||||
#include <qfiledialog.h>
|
||||
#include <qlayout.h>
|
||||
#include <qpainter.h>
|
||||
|
||||
#include "colormapreader.h"
|
||||
|
||||
using namespace Qwt3D;
|
||||
using namespace std;
|
||||
|
||||
#if QT_VERSION < 0x040000
|
||||
|
||||
ColorMapPreview::ColorMapPreview( QWidget *parent )
|
||||
: QFrame( parent )
|
||||
{
|
||||
label_ = new QLabel(this);
|
||||
setFrameShape( QFrame::StyledPanel );
|
||||
setFrameShadow( QFrame::Sunken );
|
||||
QGridLayout* layout = new QGridLayout( this, 1, 1, 10);
|
||||
|
||||
layout->addWidget( label_, 0, 0, Qt::AlignJustify );
|
||||
}
|
||||
|
||||
void ColorMapPreview::previewUrl( const QUrl &u )
|
||||
{
|
||||
QString path = u.path();
|
||||
QFileInfo fi( path );
|
||||
if (fi.extension() != "map" && fi.extension() != "MAP")
|
||||
label_->setText( "No color map" );
|
||||
else
|
||||
{
|
||||
if ( open(path) )
|
||||
label_->setPixmap( pix_ );
|
||||
}
|
||||
}
|
||||
|
||||
bool ColorMapPreview::open(QString fname)
|
||||
{
|
||||
if (fname.isEmpty())
|
||||
return false;
|
||||
|
||||
ifstream file(QWT3DLOCAL8BIT(fname));
|
||||
|
||||
RGBA rgb;
|
||||
cv.clear();
|
||||
|
||||
while ( file )
|
||||
{
|
||||
file >> rgb.r >> rgb.g >> rgb.b;
|
||||
file.ignore(10000,'\n');
|
||||
if (!file.good())
|
||||
break;
|
||||
else
|
||||
{
|
||||
rgb.a = 1;
|
||||
rgb.r /= 255;
|
||||
rgb.g /= 255;
|
||||
rgb.b /= 255;
|
||||
cv.push_back(rgb);
|
||||
}
|
||||
}
|
||||
|
||||
pix_.resize(80, cv.size());
|
||||
QPainter p( &pix_ );
|
||||
p.translate( 0, cv.size()-1 );
|
||||
for (unsigned i=0; i!=cv.size(); ++i)
|
||||
{
|
||||
rgb = cv[i];
|
||||
p.setPen(GL2Qt(rgb.r,rgb.g,rgb.b));
|
||||
p.drawLine(QPoint(0,0),QPoint(pix_.width(),0));
|
||||
p.translate( 0, -1 );
|
||||
}
|
||||
p.end();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#else
|
||||
#endif
|
@ -0,0 +1,28 @@
|
||||
#ifndef __colormapreader_2003_06_08_13_23__
|
||||
#define __colormapreader_2003_06_08_13_23__
|
||||
|
||||
#include <qlabel.h>
|
||||
#include <qframe.h>
|
||||
#include <qpixmap.h>
|
||||
|
||||
#include "../../../include/qwt3d_types.h"
|
||||
|
||||
#if QT_VERSION < 0x040000
|
||||
|
||||
class ColorMapPreview : public QFrame, public QFilePreview
|
||||
{
|
||||
public:
|
||||
ColorMapPreview( QWidget *parent=0 );
|
||||
void previewUrl( const QUrl &u );
|
||||
|
||||
private:
|
||||
Qwt3D::ColorVector cv;
|
||||
QLabel* label_;
|
||||
QPixmap pix_;
|
||||
bool open(QString);
|
||||
};
|
||||
|
||||
#else // if present in Qt4
|
||||
#endif
|
||||
|
||||
#endif
|
@ -0,0 +1,146 @@
|
||||
#include "designerworkaround.h"
|
||||
|
||||
namespace{
|
||||
QString tr(const char* val)
|
||||
{
|
||||
return QObject::tr(val);
|
||||
}
|
||||
|
||||
void setCheckable(QActionGroup* ag)
|
||||
{
|
||||
QList<QAction*> tmplist = ag->actions();
|
||||
for (QList<QAction*>::iterator it=tmplist.begin(); it!=tmplist.end(); ++it)
|
||||
(*it)->setCheckable(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void DesignerWorkaround::setupWorkaround(QMainWindow* mw)
|
||||
{
|
||||
// actions
|
||||
|
||||
openFile = new QAction(QIcon(":/images/fileopen.png"), tr("&Open File"), mw);
|
||||
openFile->setShortcut( QKeySequence(tr("CTRL+O")));
|
||||
openMeshFile = new QAction(QIcon(":/images/filecell.png"), tr("Open FEM File"), mw);
|
||||
|
||||
Exit = new QAction(tr("&Exit"), mw);
|
||||
Exit->setShortcut( QKeySequence(tr("CTRL+Q")));
|
||||
|
||||
animation = new QAction(QIcon(":/images/movie.png"), tr("Animation"), mw);
|
||||
animation->setCheckable(true);
|
||||
dump = new QAction(QIcon(":/images/savecontent.png"), "", mw);
|
||||
|
||||
coord = new QActionGroup(mw);
|
||||
Box = new QAction(QIcon(":/images/box.png"), "", coord);
|
||||
Frame = new QAction(QIcon(":/images/frame.png"), "", coord);
|
||||
None = new QAction(QIcon(":/images/grid.png"), "", coord);
|
||||
setCheckable(coord);
|
||||
|
||||
grids = new QActionGroup(mw);
|
||||
front = new QAction(QIcon(":/images/gridfr.png"), "", grids);
|
||||
back = new QAction(QIcon(":/images/gridb.png"), "", grids);
|
||||
right = new QAction(QIcon(":/images/gridr.png"), "", grids);
|
||||
left = new QAction(QIcon(":/images/gridl.png"), "", grids);
|
||||
ceil = new QAction(QIcon(":/images/gridc.png"), "", grids);
|
||||
floor = new QAction(QIcon(":/images/gridf.png"), "", grids);
|
||||
grids->setExclusive(false);
|
||||
setCheckable(grids);
|
||||
|
||||
plotstyle = new QActionGroup(mw);
|
||||
pointstyle = new QAction(QIcon(":/images/scattered.png"), "", plotstyle);
|
||||
wireframe = new QAction(QIcon(":/images/wireframe.png"), "", plotstyle);
|
||||
hiddenline = new QAction(QIcon(":/images/hiddenline.png"), "", plotstyle);
|
||||
polygon = new QAction(QIcon(":/images/polygon.png"), "", plotstyle);
|
||||
filledmesh = new QAction(QIcon(":/images/filledmesh.png"), "", plotstyle);
|
||||
nodata = new QAction(QIcon(":/images/nodata.png"), "", plotstyle);
|
||||
setCheckable(plotstyle);
|
||||
|
||||
floorstyle = new QActionGroup(mw);
|
||||
floordata = new QAction(QIcon(":/images/floordata.png"), "", floorstyle);
|
||||
flooriso = new QAction(QIcon(":/images/flooriso.png"), "", floorstyle);
|
||||
floornone = new QAction(QIcon(":/images/floorempty.png"), "", floorstyle);
|
||||
setCheckable(floorstyle);
|
||||
|
||||
normals = new QAction(QIcon(":/images/normals.png"), "", mw);
|
||||
normals->setCheckable(true);
|
||||
|
||||
color = new QActionGroup(mw);
|
||||
axescolor = new QAction(tr("&Axes"), color);
|
||||
backgroundcolor = new QAction(tr("&Background"), color);
|
||||
meshcolor = new QAction(tr("&Mesh"), color);
|
||||
numbercolor = new QAction(tr("&Numbers"), color);
|
||||
labelcolor = new QAction(tr("&Label"), color);
|
||||
titlecolor = new QAction(tr("Caption"), color);
|
||||
datacolor = new QAction(tr("Data color"), color);
|
||||
resetcolor = new QAction(tr("&Reset"), color);
|
||||
|
||||
font = new QActionGroup(mw);
|
||||
numberfont = new QAction(tr("&Scale numbering"), font);
|
||||
labelfont = new QAction(tr("&Axes label"), font);
|
||||
titlefont = new QAction(tr("&Caption"), font);
|
||||
resetfont = new QAction(tr("&Reset"), font);
|
||||
|
||||
|
||||
// toolbars
|
||||
mainToolbar = new QToolBar( QString(""), mw );
|
||||
mainToolbar->setMovable( false );
|
||||
|
||||
mainToolbar->addAction(openFile);
|
||||
mainToolbar->addAction(openMeshFile);
|
||||
mainToolbar->addAction(dump);
|
||||
|
||||
filetypeCB = new QComboBox;
|
||||
functionCB = new QComboBox;
|
||||
psurfaceCB = new QComboBox;
|
||||
|
||||
mainToolbar->addWidget(filetypeCB);
|
||||
mainToolbar->addWidget(functionCB);
|
||||
mainToolbar->addWidget(psurfaceCB);
|
||||
|
||||
mainToolbar->addAction(animation);
|
||||
|
||||
csToolbar = new QToolBar( QString(""), mw );
|
||||
csToolbar->setMovable( false );
|
||||
|
||||
csToolbar->addActions(coord->actions());
|
||||
csToolbar->addActions(grids->actions());
|
||||
csToolbar->addActions(plotstyle->actions());
|
||||
csToolbar->addActions(floorstyle->actions());
|
||||
csToolbar->addAction(normals);
|
||||
|
||||
// menubar
|
||||
menubar = mw->menuBar();//new QMenuBar();
|
||||
filemenu = menubar->addMenu("&File");
|
||||
filemenu->addAction(openFile);
|
||||
filemenu->addAction(openMeshFile);
|
||||
filemenu->addAction(animation);
|
||||
filemenu->addAction(Exit);
|
||||
colormenu = menubar->addMenu(tr("&Color"));
|
||||
colormenu->addActions(color->actions());
|
||||
fontmenu = menubar->addMenu(tr("&Fonts"));
|
||||
fontmenu->addActions(font->actions());
|
||||
|
||||
mw->addToolBar(mainToolbar);
|
||||
mw->addToolBar(csToolbar);
|
||||
|
||||
|
||||
functionCB->clear();
|
||||
functionCB->addItem( tr( "---" ) );
|
||||
functionCB->addItem( tr( "Hat" ) );
|
||||
functionCB->addItem( tr( "Rosenbrock" ) );
|
||||
functionCB->addItem( tr( "Saddle" ) );
|
||||
functionCB->addItem( tr( "Sombrero" ) );
|
||||
functionCB->addItem( tr( "Ripple" ) );
|
||||
functionCB->setToolTip(tr( "Display function" ) );
|
||||
psurfaceCB->clear();
|
||||
psurfaceCB->addItem( tr( "---" ) );
|
||||
psurfaceCB->addItem( tr( "Torus" ) );
|
||||
psurfaceCB->addItem( tr( "Seashell" ) );
|
||||
psurfaceCB->addItem( tr( "Boy" ) );
|
||||
psurfaceCB->addItem( tr( "Dini" ) );
|
||||
psurfaceCB->addItem( tr( "Cone" ) );
|
||||
psurfaceCB->setToolTip(tr( "Display parametric surface. Turn Lighting on for better quality."));
|
||||
|
||||
QObject::connect(Exit, SIGNAL(triggered()), mw, SLOT(close()));
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
#ifndef designerworkaround_h__2005_07_10_10_46_begin_guarded_code
|
||||
#define designerworkaround_h__2005_07_10_10_46_begin_guarded_code
|
||||
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtGui/QToolBar>
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QActionGroup>
|
||||
#include <QtGui/QMainWindow>
|
||||
#include <QtGui/QComboBox>
|
||||
#include <QtGui/QMenuBar>
|
||||
|
||||
|
||||
class DesignerWorkaround
|
||||
{
|
||||
public:
|
||||
QMenuBar *menubar;
|
||||
QMenu *filemenu;
|
||||
QMenu *colormenu;
|
||||
QMenu *fontmenu;
|
||||
QToolBar *mainToolbar;
|
||||
QToolBar *csToolbar;
|
||||
QAction* openFile;
|
||||
QAction* openMeshFile;
|
||||
QAction* animation;
|
||||
QAction* dump;
|
||||
QAction* normals;
|
||||
QAction* Exit;
|
||||
|
||||
QActionGroup* coord;
|
||||
QAction* Box;
|
||||
QAction* Frame;
|
||||
QAction* None;
|
||||
|
||||
QActionGroup* plotstyle;
|
||||
QAction* wireframe;
|
||||
QAction* hiddenline;
|
||||
QAction* polygon;
|
||||
QAction* filledmesh;
|
||||
QAction* nodata;
|
||||
QAction* pointstyle;
|
||||
|
||||
QActionGroup* color;
|
||||
QAction* axescolor;
|
||||
QAction* backgroundcolor;
|
||||
QAction* meshcolor;
|
||||
QAction* numbercolor;
|
||||
QAction* labelcolor;
|
||||
QAction* titlecolor;
|
||||
QAction* datacolor;
|
||||
QAction* resetcolor;
|
||||
|
||||
QActionGroup* font;
|
||||
QAction* numberfont;
|
||||
QAction* labelfont;
|
||||
QAction* titlefont;
|
||||
QAction* resetfont;
|
||||
|
||||
QActionGroup* floorstyle;
|
||||
QAction* floordata;
|
||||
QAction* flooriso;
|
||||
QAction* floornone;
|
||||
|
||||
QActionGroup* grids;
|
||||
QAction* front;
|
||||
QAction* back;
|
||||
QAction* right;
|
||||
QAction* left;
|
||||
QAction* ceil;
|
||||
QAction* floor;
|
||||
|
||||
QComboBox* filetypeCB, *functionCB, *psurfaceCB;
|
||||
|
||||
void setupWorkaround(QMainWindow* mw);
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,83 @@
|
||||
#ifndef femreader_h__2004_03_07_14_03_begin_guarded_code
|
||||
#define femreader_h__2004_03_07_14_03_begin_guarded_code
|
||||
|
||||
#include <math.h>
|
||||
#include <fstream>
|
||||
#include "qwt3d_global.h"
|
||||
#include "qwt3d_types.h"
|
||||
|
||||
class NodeFilter
|
||||
{
|
||||
public:
|
||||
explicit NodeFilter()
|
||||
{
|
||||
values = std::vector<double>(6);
|
||||
}
|
||||
|
||||
Qwt3D::Triple readLine(std::ifstream& str)
|
||||
{
|
||||
for (unsigned i = 0; i!=values.size(); ++i)
|
||||
str >> values[i];
|
||||
|
||||
return Qwt3D::Triple(values[1], values[2], values[5] / 1000);
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<double> values;
|
||||
};
|
||||
|
||||
class CellFilter
|
||||
{
|
||||
public:
|
||||
|
||||
Qwt3D::Cell readLine(std::ifstream& str)
|
||||
{
|
||||
Qwt3D::Cell cell(4);
|
||||
str >> cell[0]; // dummy (cell number) - overridden in next step
|
||||
for (unsigned i = 0; i<cell.size(); ++i)
|
||||
{
|
||||
str >> cell[i];
|
||||
cell[i] = cell[i] - 1;
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename FILTER>
|
||||
bool readNodes(Qwt3D::TripleField& v, const char* fname, FILTER fil)
|
||||
{
|
||||
std::ifstream file(fname);
|
||||
|
||||
v.clear();
|
||||
|
||||
Qwt3D::Triple t;
|
||||
while ( file )
|
||||
{
|
||||
t = fil.readLine( file );
|
||||
if (!file.good())
|
||||
break;
|
||||
v.push_back( t );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename FILTER>
|
||||
bool readConnections(Qwt3D::CellField& v, const char* fname, FILTER fil)
|
||||
{
|
||||
std::ifstream file(fname);
|
||||
|
||||
v.clear();
|
||||
|
||||
Qwt3D::Cell cell;
|
||||
while ( file )
|
||||
{
|
||||
cell = fil.readLine( file );
|
||||
if (!file.good())
|
||||
break;
|
||||
v.push_back(cell);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif /* include guarded */
|
@ -0,0 +1,214 @@
|
||||
#ifndef __EXAMPLE_H__
|
||||
#define __EXAMPLE_H__
|
||||
|
||||
#include <math.h>
|
||||
#include "../../../include/qwt3d_parametricsurface.h"
|
||||
#include "../../../include/qwt3d_function.h"
|
||||
|
||||
using namespace Qwt3D;
|
||||
|
||||
|
||||
class Rosenbrock : public Function
|
||||
{
|
||||
public:
|
||||
|
||||
Rosenbrock(SurfacePlot& pw)
|
||||
:Function(pw)
|
||||
{
|
||||
}
|
||||
|
||||
double operator()(double x, double y)
|
||||
{
|
||||
return 0.7 * log10((1-x)*(1-x) + 10 * (y - x*x)*(y - x*x));
|
||||
}
|
||||
// QString name() const {return "Almost {\\it Rosenbrock}\\,:\\quad$\\frac{\\ln((1-x)^2 + 100(y-x^2)^2)}{8}$";}
|
||||
};
|
||||
|
||||
class Hat : public Function
|
||||
{
|
||||
public:
|
||||
|
||||
Hat(SurfacePlot& pw)
|
||||
:Function(pw)
|
||||
{
|
||||
//setMinZ(0.3);
|
||||
setDomain(0,10,0,10);
|
||||
}
|
||||
|
||||
double operator()(double x, double y)
|
||||
{
|
||||
return 1.0 / (x*x+y*y+0.5);
|
||||
//return x*x*y/(x*x*x*x+y*y);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class Ripple : public Function
|
||||
{
|
||||
public:
|
||||
|
||||
Ripple(SurfacePlot& pw)
|
||||
:Function(pw)
|
||||
{
|
||||
double l = 12;
|
||||
setDomain(-l,l,-l,l);
|
||||
}
|
||||
|
||||
double operator()(double x, double y)
|
||||
{
|
||||
return (cos(sqrt(x*x+y*y) + cos(sqrt(((x+.913*2*Qwt3D::PI)*(x+.913*2*Qwt3D::PI))+y*y))
|
||||
+ cos(sqrt(((x-.913*2*Qwt3D::PI)*(x-.913*2*Qwt3D::PI))+(y*y))))*4);
|
||||
}
|
||||
};
|
||||
|
||||
class Saddle : public Function
|
||||
{
|
||||
public:
|
||||
|
||||
Saddle()
|
||||
:Function()
|
||||
{
|
||||
// setMaxZ(0.8);
|
||||
}
|
||||
|
||||
double operator()(double x, double y)
|
||||
{
|
||||
return x*x - y*y;
|
||||
}
|
||||
// QString name() const {return "$x^2-y^2$";}
|
||||
};
|
||||
|
||||
class Mex : public Function
|
||||
{
|
||||
public:
|
||||
|
||||
Mex()
|
||||
:Function()
|
||||
{
|
||||
// setMaxZ(0.8);
|
||||
}
|
||||
|
||||
double operator()(double x, double y)
|
||||
{
|
||||
double n = sqrt(x*x+y*y);
|
||||
|
||||
if (n < DBL_MIN)
|
||||
return 20;
|
||||
|
||||
return 20 * sin(sqrt(x*x+y*y)) / n;
|
||||
}
|
||||
// QString name() const {return "$\\frac{20\\sin\\sqrt{x^2+y^2}}{\\sqrt{x^2+y^2}}$";}
|
||||
};
|
||||
|
||||
class Torus : public ParametricSurface
|
||||
{
|
||||
public:
|
||||
|
||||
Torus(SurfacePlot& pw)
|
||||
:ParametricSurface(pw)
|
||||
{
|
||||
setMesh(41,31);
|
||||
setDomain(-2*Qwt3D::PI, 0,-2*Qwt3D::PI,0);
|
||||
setPeriodic(true,true);
|
||||
}
|
||||
|
||||
|
||||
Triple operator()(double u, double v)
|
||||
{
|
||||
double x,y,z;
|
||||
double c = 1.9;
|
||||
x = (c + cos(v)) * cos(u);
|
||||
y = (c + cos(v)) * sin(u);
|
||||
z = sin(v) + cos(v);
|
||||
return Triple(x,y,z);
|
||||
}
|
||||
};
|
||||
|
||||
class Seashell : public ParametricSurface
|
||||
{
|
||||
public:
|
||||
|
||||
Seashell(SurfacePlot& pw)
|
||||
:ParametricSurface(pw)
|
||||
{
|
||||
setMesh(41,131);
|
||||
setDomain(0,2*Qwt3D::PI,0,2*Qwt3D::PI);
|
||||
setPeriodic(true,true);
|
||||
}
|
||||
|
||||
|
||||
Triple operator()(double u, double v)
|
||||
{
|
||||
double x,y,z;
|
||||
double a = 1;
|
||||
double b = 6;
|
||||
double c = 0.5;
|
||||
int n = 3;
|
||||
|
||||
double f = v/(2*Qwt3D::PI);
|
||||
|
||||
x = a*(1-f)*cos(n*v)*(1+cos(u)) + c*cos(n*v) ;
|
||||
y = a*(1-f)*sin(n*v)*(1+cos(u)) + c*sin(n*v) ;
|
||||
z = b*f + a*(1-f)*sin(u);
|
||||
return Triple(x,y,z);
|
||||
}
|
||||
};
|
||||
|
||||
class Boy : public ParametricSurface
|
||||
{
|
||||
public:
|
||||
|
||||
Boy(SurfacePlot& pw)
|
||||
:ParametricSurface(pw)
|
||||
{
|
||||
setMesh(141,131);
|
||||
setDomain(0,Qwt3D::PI,0,Qwt3D::PI);
|
||||
setPeriodic(true,true);
|
||||
}
|
||||
|
||||
|
||||
Triple operator()(double u, double v)
|
||||
{
|
||||
double x,y,z;
|
||||
double a = 2/3.;
|
||||
double b = sqrt(2.);
|
||||
|
||||
x = a*(cos(u)*cos(2*v)+b*sin(u)*cos(v))*cos(u) / (b-sin(2*u)*sin(3*v));
|
||||
y = a*(cos(u)*sin(2*v)-b*sin(u)*sin(v))*cos(u) / (b-sin(2*u)*sin(3*v));
|
||||
z = b*cos(u)*cos(u) / (b-sin(2*u)*sin(2*v));
|
||||
|
||||
return Triple(x,y,z);
|
||||
}
|
||||
};
|
||||
|
||||
class Dini : public ParametricSurface
|
||||
{
|
||||
public:
|
||||
|
||||
Dini(SurfacePlot& pw)
|
||||
:ParametricSurface(pw)
|
||||
{
|
||||
setMesh(141,35);
|
||||
setDomain(0,5*Qwt3D::PI,0.001, 2);
|
||||
setPeriodic(true,true);
|
||||
}
|
||||
|
||||
|
||||
Triple operator()(double u, double v)
|
||||
{
|
||||
double x,y,z;
|
||||
double a = 5;
|
||||
double b = 1;
|
||||
|
||||
|
||||
x=a*cos(u)*sin(v);
|
||||
y=a*sin(u)*sin(v);
|
||||
z=a*(cos(v)+log(tan(v/2)))+b*u;
|
||||
|
||||
return Triple(x,y,z);
|
||||
}
|
||||
};
|
||||
|
||||
void createCone(Qwt3D::TripleField& conepos, Qwt3D::CellField& conecell);
|
||||
|
||||
#endif
|
@ -0,0 +1,220 @@
|
||||
#include <qlayout.h>
|
||||
#include <qframe.h>
|
||||
#include <qslider.h>
|
||||
#include <qcheckbox.h>
|
||||
#include <qpushbutton.h>
|
||||
|
||||
#include "lightingdlg.h"
|
||||
|
||||
using namespace Qwt3D;
|
||||
|
||||
class Sphere : public ParametricSurface
|
||||
{
|
||||
public:
|
||||
|
||||
Sphere(SurfacePlot& pw)
|
||||
:ParametricSurface(pw)
|
||||
{
|
||||
setMesh(41,31);
|
||||
setDomain(0,2*Qwt3D::PI,0,Qwt3D::PI);
|
||||
setPeriodic(false,false);
|
||||
}
|
||||
|
||||
|
||||
Triple operator()(double u, double v)
|
||||
{
|
||||
double x,y,z;
|
||||
double r = 1;
|
||||
x = r*cos(u)*sin(v);
|
||||
y = r*sin(u)*sin(v);
|
||||
z = r*cos(v);
|
||||
return Triple(x,y,z);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Plot
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
Plot::Plot(QWidget *parent)
|
||||
: SurfacePlot(parent)
|
||||
{
|
||||
setTitle("A Simple SurfacePlot Demonstration");
|
||||
|
||||
Sphere sphere(*this);
|
||||
sphere.create();
|
||||
|
||||
reset();
|
||||
assignMouse(Qt::LeftButton,
|
||||
Qt::RightButton,
|
||||
Qt::LeftButton,
|
||||
Qt::NoButton,
|
||||
Qt::NoButton,
|
||||
Qt::NoButton,
|
||||
Qt::NoButton,
|
||||
Qt::NoButton,
|
||||
Qt::NoButton
|
||||
);
|
||||
|
||||
stick = (Pointer*)addEnrichment(Pointer(0.05));
|
||||
stick->setPos(0,0,1);
|
||||
}
|
||||
|
||||
void Plot::reset()
|
||||
{
|
||||
makeCurrent();
|
||||
setRotation(0,0,0);
|
||||
setTitle("Use your mouse buttons and keyboard");
|
||||
setTitleFont("Arial", 8, QFont::Bold);
|
||||
setTitleColor(RGBA(0.9,0.9,0.9));
|
||||
setSmoothMesh(true);
|
||||
setZoom(0.9);
|
||||
setCoordinateStyle(NOCOORD);
|
||||
setMeshColor(RGBA(0.6,0.6,0.6,0.3));
|
||||
setPlotStyle(FILLEDMESH);
|
||||
setBackgroundColor(RGBA(0,0,0));
|
||||
|
||||
updateData();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Pointer
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
Pointer::Pointer(double rad)
|
||||
{
|
||||
configure(rad);
|
||||
}
|
||||
|
||||
Pointer::~Pointer()
|
||||
{
|
||||
}
|
||||
|
||||
void Pointer::configure(double rad)
|
||||
{
|
||||
plot = 0;
|
||||
|
||||
radius_ = rad;
|
||||
}
|
||||
|
||||
void Pointer::drawBegin()
|
||||
{
|
||||
GLint mode;
|
||||
glGetIntegerv(GL_MATRIX_MODE, &mode);
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glPushMatrix();
|
||||
|
||||
glColor3d(1,0,0);
|
||||
glBegin(GL_LINES);
|
||||
glVertex3d(pos_.x, pos_.y, pos_.z);
|
||||
glVertex3d(0, 0, 0);
|
||||
glEnd();
|
||||
|
||||
glPopMatrix();
|
||||
glMatrixMode(mode);
|
||||
}
|
||||
|
||||
|
||||
LightingDlg::LightingDlg(QWidget *parent)
|
||||
:LightingBase(parent)
|
||||
{
|
||||
#if QT_VERSION < 0x040000
|
||||
QGridLayout *grid = new QGridLayout( frame, 0, 0 );
|
||||
#else
|
||||
setupUi(this);
|
||||
QGridLayout *grid = new QGridLayout( frame);
|
||||
#endif
|
||||
|
||||
dataPlot = 0;
|
||||
|
||||
plot = new Plot(frame);
|
||||
plot->updateData();
|
||||
|
||||
grid->addWidget( plot, 0, 0 );
|
||||
|
||||
connect( stdlight, SIGNAL( clicked() ), this, SLOT( reset() ) );
|
||||
connect( distSL, SIGNAL(valueChanged(int)), this, SLOT(setDistance(int)) );
|
||||
connect( emissSL, SIGNAL(valueChanged(int)), this, SLOT(setEmission(int)) );
|
||||
connect( ambdiffSL, SIGNAL(valueChanged(int)), this, SLOT(setDiff(int)) );
|
||||
connect( specSL, SIGNAL(valueChanged(int)), this, SLOT(setSpec(int)) );
|
||||
connect( shinSL, SIGNAL(valueChanged(int)), this, SLOT(setShin(int)) );
|
||||
connect( plot, SIGNAL(rotationChanged(double, double, double)), this, SLOT(setRotation(double, double, double)) );
|
||||
}
|
||||
|
||||
LightingDlg::~LightingDlg()
|
||||
{
|
||||
delete plot;
|
||||
}
|
||||
|
||||
void LightingDlg::setEmission(int val)
|
||||
{
|
||||
if (!dataPlot)
|
||||
return;
|
||||
dataPlot->setMaterialComponent(GL_EMISSION, val / 100.);
|
||||
dataPlot->updateGL();
|
||||
}
|
||||
void LightingDlg::setDiff(int val)
|
||||
{
|
||||
if (!dataPlot)
|
||||
return;
|
||||
dataPlot->setLightComponent(GL_DIFFUSE, val / 100.);
|
||||
dataPlot->updateGL();
|
||||
}
|
||||
void LightingDlg::setSpec(int val)
|
||||
{
|
||||
if (!dataPlot)
|
||||
return;
|
||||
dataPlot->setMaterialComponent(GL_SPECULAR, val / 100.);
|
||||
dataPlot->updateGL();
|
||||
}
|
||||
void LightingDlg::setShin(int val)
|
||||
{
|
||||
if (!dataPlot)
|
||||
return;
|
||||
dataPlot->setShininess( val / 100.);
|
||||
dataPlot->updateGL();
|
||||
}
|
||||
|
||||
void LightingDlg::reset()
|
||||
{
|
||||
plot->reset();
|
||||
if (dataPlot)
|
||||
dataPlot->updateGL();
|
||||
}
|
||||
|
||||
void LightingDlg::setDistance(int val)
|
||||
{
|
||||
|
||||
plot->stick->setPos(0,0,val/100.);
|
||||
plot->updateData();
|
||||
plot->updateGL();
|
||||
|
||||
double drad = (dataPlot->hull().maxVertex-dataPlot->hull().minVertex).length();
|
||||
drad *= val/20.;
|
||||
|
||||
dataPlot->setLightShift(drad,drad,drad);
|
||||
dataPlot->updateGL();
|
||||
}
|
||||
|
||||
void LightingDlg::assign(Qwt3D::Plot3D* pl)
|
||||
{
|
||||
if (!pl)
|
||||
return;
|
||||
dataPlot = pl;
|
||||
}
|
||||
|
||||
void LightingDlg::setRotation(double x, double y, double z)
|
||||
{
|
||||
if (!dataPlot)
|
||||
return;
|
||||
|
||||
setDistance(distSL->value());
|
||||
dataPlot->setLightRotation(x,y,z);
|
||||
dataPlot->updateGL();
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
#ifndef lightingdlg_h__2004_03_07_13_35_begin_guarded_code
|
||||
#define lightingdlg_h__2004_03_07_13_35_begin_guarded_code
|
||||
|
||||
#include <math.h>
|
||||
#include <qapplication.h>
|
||||
#include "../../../include/qwt3d_parametricsurface.h"
|
||||
#include "../../../include/qwt3d_surfaceplot.h"
|
||||
#include "../../../include/qwt3d_enrichment.h"
|
||||
#include "../../../include/qwt3d_color.h"
|
||||
|
||||
#if QT_VERSION < 0x040000
|
||||
#include "lightingdlgbase.h"
|
||||
#else
|
||||
#include "ui_lightingdlgbase4.h"
|
||||
#endif
|
||||
|
||||
class Pointer : public Qwt3D::VertexEnrichment
|
||||
{
|
||||
public:
|
||||
Pointer(double rad);
|
||||
~Pointer();
|
||||
|
||||
Qwt3D::Enrichment* clone() const {return new Pointer(*this);}
|
||||
|
||||
void configure(double rad);
|
||||
void drawBegin();
|
||||
void draw(Qwt3D::Triple const&){}
|
||||
void setPos(double x, double y, double z) {pos_ = Qwt3D::Triple(x,y,z);}
|
||||
|
||||
private:
|
||||
double radius_;
|
||||
Qwt3D::Triple pos_;
|
||||
};
|
||||
|
||||
struct SColor : public Qwt3D::Color
|
||||
{
|
||||
Qwt3D::RGBA operator()(double, double, double) const {return Qwt3D::RGBA(0.8,0,0,0.5);}
|
||||
};
|
||||
|
||||
typedef Qwt3D::SurfacePlot SPlot; // moc/VC6 issue in Qt 4.0.0
|
||||
|
||||
class Plot : public SPlot
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Plot(QWidget* parent);
|
||||
Pointer* stick;
|
||||
void reset();
|
||||
};
|
||||
|
||||
//MOC_SKIP_BEGIN
|
||||
#if QT_VERSION < 0x040000
|
||||
class LightingBase : public LightingDlgBase
|
||||
{
|
||||
public:
|
||||
LightingBase(QWidget* parent = 0)
|
||||
: LightingDlgBase(parent)
|
||||
{
|
||||
}
|
||||
};
|
||||
#else
|
||||
class LightingBase : public QDialog, protected Ui::Dialog
|
||||
{
|
||||
public:
|
||||
LightingBase(QWidget* parent = 0)
|
||||
: QDialog(parent)
|
||||
{
|
||||
}
|
||||
};
|
||||
#endif
|
||||
//MOC_SKIP_END
|
||||
|
||||
|
||||
|
||||
class LightingDlg : public LightingBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LightingDlg(QWidget *parent=0);
|
||||
~LightingDlg();
|
||||
|
||||
void assign(Qwt3D::Plot3D* pl);
|
||||
|
||||
Plot* plot;
|
||||
Qwt3D::Plot3D* dataPlot;
|
||||
|
||||
public slots:
|
||||
void setDistance(int);
|
||||
void setEmission(int);
|
||||
void setDiff(int);
|
||||
void setSpec(int);
|
||||
void setShin(int);
|
||||
void reset();
|
||||
void setRotation(double x, double y, double z);
|
||||
};
|
||||
|
||||
|
||||
#endif /* include guarded */
|
@ -0,0 +1,361 @@
|
||||
<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
|
||||
<class>LightingDlgBase</class>
|
||||
<widget class="QDialog">
|
||||
<property name="name">
|
||||
<cstring>LightingDlgBase</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>450</width>
|
||||
<height>345</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>5</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>450</width>
|
||||
<height>345</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>450</width>
|
||||
<height>345</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="caption">
|
||||
<string>Lighting Configuration</string>
|
||||
</property>
|
||||
<property name="sizeGripEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<widget class="QFrame" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>frame</cstring>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>290</width>
|
||||
<height>290</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>290</width>
|
||||
<height>290</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>Sunken</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLayoutWidget" row="1" column="0">
|
||||
<property name="name">
|
||||
<cstring>Layout11</cstring>
|
||||
</property>
|
||||
<hbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>stdlight</cstring>
|
||||
</property>
|
||||
<property name="caption">
|
||||
<string></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Std</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<spacer>
|
||||
<property name="name">
|
||||
<cstring>Horizontal Spacing2</cstring>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>buttonOk</cstring>
|
||||
</property>
|
||||
<property name="caption">
|
||||
<string></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&OK</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</hbox>
|
||||
</widget>
|
||||
<widget class="QLayoutWidget" row="0" column="1">
|
||||
<property name="name">
|
||||
<cstring>Layout8</cstring>
|
||||
</property>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>Layout2</cstring>
|
||||
</property>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>ambdiff</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Ambient & Diffuse Part</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSlider">
|
||||
<property name="name">
|
||||
<cstring>ambdiffSL</cstring>
|
||||
</property>
|
||||
<property name="maxValue">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>80</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>Layout2_2</cstring>
|
||||
</property>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>spec</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Specular Part</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSlider">
|
||||
<property name="name">
|
||||
<cstring>specSL</cstring>
|
||||
</property>
|
||||
<property name="maxValue">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>30</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>Layout2_3</cstring>
|
||||
</property>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>shin</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Shininess</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSlider">
|
||||
<property name="name">
|
||||
<cstring>shinSL</cstring>
|
||||
</property>
|
||||
<property name="maxValue">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>500</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>Layout2_4</cstring>
|
||||
</property>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>emiss</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Emission</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSlider">
|
||||
<property name="name">
|
||||
<cstring>emissSL</cstring>
|
||||
</property>
|
||||
<property name="maxValue">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>Layout2_4_2</cstring>
|
||||
</property>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>dist</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Distance</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSlider">
|
||||
<property name="name">
|
||||
<cstring>distSL</cstring>
|
||||
</property>
|
||||
<property name="maxValue">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonOk</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>LightingDlgBase</receiver>
|
||||
<slot>accept()</slot>
|
||||
</connection>
|
||||
</connections>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
</UI>
|
@ -0,0 +1,293 @@
|
||||
<ui version="4.0" >
|
||||
<author></author>
|
||||
<comment></comment>
|
||||
<exportmacro></exportmacro>
|
||||
<class>Dialog</class>
|
||||
<widget class="QDialog" name="Dialog" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>428</width>
|
||||
<height>330</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0" >
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QFrame" name="frame" >
|
||||
<property name="frameShape" >
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow" >
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="stdlight" >
|
||||
<property name="text" >
|
||||
<string>Std</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>91</width>
|
||||
<height>31</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonOk" >
|
||||
<property name="text" >
|
||||
<string>&Ok</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<layout class="QVBoxLayout" >
|
||||
<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><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Ambient &amp; Diffuse Part</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="ambdiffSL" >
|
||||
<property name="maximum" >
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value" >
|
||||
<number>80</number>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</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="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<string><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Specular Part</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="specSL" >
|
||||
<property name="maximum" >
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value" >
|
||||
<number>30</number>
|
||||
</property>
|
||||
<property name="sliderPosition" >
|
||||
<number>30</number>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</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="QLabel" name="label_3" >
|
||||
<property name="text" >
|
||||
<string><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Shininess</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="shinSL" >
|
||||
<property name="maximum" >
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="value" >
|
||||
<number>500</number>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</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="QLabel" name="label_3_2" >
|
||||
<property name="text" >
|
||||
<string><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Emission</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="emissSL" >
|
||||
<property name="maximum" >
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</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="QLabel" name="label_3_2_2" >
|
||||
<property name="text" >
|
||||
<string><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Distance</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="distSL" >
|
||||
<property name="maximum" >
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="value" >
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QWidget" name="layoutWidget" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>280</y>
|
||||
<width>351</width>
|
||||
<height>33</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<pixmapfunction></pixmapfunction>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>stdlight</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>Dialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>278</x>
|
||||
<y>253</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>96</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonOk</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>Dialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>369</x>
|
||||
<y>253</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>179</x>
|
||||
<y>282</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -0,0 +1,22 @@
|
||||
#include "lightingdlgbaseimpl.h"
|
||||
|
||||
/*
|
||||
* Constructs a lightingdlgbase which is a child of 'parent', with the
|
||||
* name 'name' and widget flags set to 'f'
|
||||
*
|
||||
* The dialog will by default be modeless, unless you set 'modal' to
|
||||
* TRUE to construct a modal dialog.
|
||||
*/
|
||||
lightingdlgbase::lightingdlgbase( QWidget* parent, const char* name, bool modal, WFlags fl )
|
||||
: lightingdlgbaseBase( parent, name, modal, fl )
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Destroys the object and frees any allocated resources
|
||||
*/
|
||||
lightingdlgbase::~lightingdlgbase()
|
||||
{
|
||||
// no need to delete child widgets, Qt does it all for us
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
#ifndef LIGHTINGDLGBASE_H
|
||||
#define LIGHTINGDLGBASE_H
|
||||
#include "lightingdlgbase.h"
|
||||
|
||||
class lightingdlgbase : public lightingdlgbaseBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
lightingdlgbase( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
|
||||
~lightingdlgbase();
|
||||
|
||||
};
|
||||
|
||||
#endif // LIGHTINGDLGBASE_H
|
@ -0,0 +1,32 @@
|
||||
/********************************************************************
|
||||
created: 2003/09/09
|
||||
filename: main.cpp
|
||||
|
||||
author: Micha Bieber
|
||||
*********************************************************************/
|
||||
|
||||
#include <qapplication.h>
|
||||
#include "mesh2mainwindow.h"
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
QApplication::setColorSpec( QApplication::CustomColor );
|
||||
QApplication app(argc,argv);
|
||||
|
||||
if ( !QGLFormat::hasOpenGL() )
|
||||
{
|
||||
qWarning( "This system has no OpenGL support. Exiting." );
|
||||
return -1;
|
||||
}
|
||||
|
||||
Mesh2MainWindow mainwindow;
|
||||
|
||||
#if QT_VERSION < 0x040000
|
||||
app.setMainWidget(&mainwindow);
|
||||
#endif
|
||||
|
||||
mainwindow.resize(1024,768);
|
||||
mainwindow.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
#include "functions.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace Qwt3D;
|
||||
|
||||
|
||||
void createCone(Qwt3D::TripleField& conepos, Qwt3D::CellField& conecell)
|
||||
{
|
||||
conepos.clear(); conecell.clear();
|
||||
Cell cell;
|
||||
|
||||
conepos.push_back(Triple(0,0,0));
|
||||
|
||||
const unsigned int count = 17;
|
||||
double r1 = 0.7;
|
||||
double r2 = 0.9 * r1;
|
||||
|
||||
double h1 = 2;
|
||||
double h2 = 1.03 * h1;
|
||||
|
||||
unsigned i;
|
||||
|
||||
Cell c1;
|
||||
// outer top border
|
||||
for (i=0; i<count; ++i)
|
||||
{
|
||||
conepos.push_back(Triple(r1*cos(2*i*Qwt3D::PI/count), r1*sin(2*i*Qwt3D::PI/count),h1));
|
||||
}
|
||||
// inner top border
|
||||
for (i=0; i<count; ++i)
|
||||
{
|
||||
conepos.push_back(Triple(r2*cos(2*i*Qwt3D::PI/count), r2*sin(2*i*Qwt3D::PI/count),h2));
|
||||
c1.push_back(count+i+1);
|
||||
}
|
||||
// top polygon
|
||||
conecell.push_back(c1);
|
||||
|
||||
// triangles
|
||||
Cell c2(3);
|
||||
for (i=1; i<count+1; ++i)
|
||||
{
|
||||
c2[0] = 0;
|
||||
c2[1] = i%count +1;
|
||||
c2[2] = i;
|
||||
conecell.push_back(c2);
|
||||
}
|
||||
// quadrangles
|
||||
c2 = Cell(4);
|
||||
for (i=1; i<count+1; ++i)
|
||||
{
|
||||
c2[0] = i;
|
||||
c2[1] = i%count +1;
|
||||
c2[2] = count+i%count +1;
|
||||
c2[3] = count+i;
|
||||
conecell.push_back(c2);
|
||||
}
|
||||
}
|
@ -0,0 +1,956 @@
|
||||
#include <qmetaobject.h>
|
||||
|
||||
#include <qframe.h>
|
||||
#include <qlabel.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qlayout.h>
|
||||
#include <qtooltip.h>
|
||||
#include <qwhatsthis.h>
|
||||
#include <qaction.h>
|
||||
#include <qmenubar.h>
|
||||
|
||||
#if QT_VERSION < 0x040000
|
||||
#include <qpopupmenu.h>
|
||||
#endif
|
||||
|
||||
#include <qtoolbar.h>
|
||||
#include <qimage.h>
|
||||
#include <qpixmap.h>
|
||||
#include <qfiledialog.h>
|
||||
#include <qstatusbar.h>
|
||||
#include <qfileinfo.h>
|
||||
#include <qslider.h>
|
||||
#include <qtimer.h>
|
||||
#include <qcombobox.h>
|
||||
#include <qstring.h>
|
||||
#include <qcheckbox.h>
|
||||
#include <qcolordialog.h>
|
||||
#include <qfontdialog.h>
|
||||
|
||||
#include "mesh2mainwindow.h"
|
||||
|
||||
#include "functions.h"
|
||||
#include "colormapreader.h"
|
||||
#include "lightingdlg.h"
|
||||
#include "femreader.h"
|
||||
#include "../../../include/qwt3d_io.h"
|
||||
#include "../../../include/qwt3d_io_gl2ps.h"
|
||||
#include "../../../include/qwt3d_io_reader.h"
|
||||
|
||||
using namespace Qwt3D;
|
||||
using namespace std;
|
||||
|
||||
|
||||
bool Mesh2MainWindow::connectA (const QObject* sender, const char * slot)
|
||||
{
|
||||
#if QT_VERSION < 0x040000
|
||||
return connect( sender, SIGNAL( activated() ), this, slot );
|
||||
#else
|
||||
return connect( sender, SIGNAL( triggered() ), this, slot );
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Mesh2MainWindow::connectAG (const QObject* sender, const char * slot)
|
||||
{
|
||||
#if QT_VERSION < 0x040000
|
||||
return connect( sender, SIGNAL( selected( QAction* ) ), this, slot ) ;
|
||||
#else
|
||||
return connect( sender, SIGNAL( triggered( QAction* ) ), this, slot ) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
Mesh2MainWindow::~Mesh2MainWindow()
|
||||
{
|
||||
delete dataWidget;
|
||||
}
|
||||
|
||||
Mesh2MainWindow::Mesh2MainWindow( QWidget* parent )
|
||||
: DummyBase( parent )
|
||||
{
|
||||
#if QT_VERSION < 0x040000
|
||||
setCaption("Mesh2");
|
||||
QGridLayout *grid = new QGridLayout( frame, 0, 0 );
|
||||
#else
|
||||
setupWorkaround(this);
|
||||
setupUi(this);
|
||||
QGridLayout *grid = new QGridLayout( frame );
|
||||
#endif
|
||||
|
||||
col_ = 0;
|
||||
legend_ = false;
|
||||
redrawWait = 50;
|
||||
activeCoordSystem = None;
|
||||
|
||||
dataWidget = new SurfacePlot(frame);
|
||||
grid->addWidget( dataWidget, 0, 0 );
|
||||
|
||||
connectAG( coord, SLOT( pickCoordSystem( QAction* ) ) );
|
||||
connectAG( plotstyle, SLOT( pickPlotStyle( QAction* ) ) );
|
||||
connectA( axescolor, SLOT( pickAxesColor() ) );
|
||||
connectA( backgroundcolor, SLOT( pickBgColor() ) );
|
||||
connectAG( floorstyle, SLOT( pickFloorStyle( QAction* ) ) );
|
||||
connectA( meshcolor, SLOT( pickMeshColor() ) );
|
||||
connectA( numbercolor, SLOT( pickNumberColor() ) );
|
||||
connectA( labelcolor, SLOT( pickLabelColor() ) );
|
||||
connectA( titlecolor, SLOT( pickTitleColor() ) );
|
||||
connectA( datacolor, SLOT( pickDataColor() ) );
|
||||
connect( lighting, SIGNAL( clicked() ), this, SLOT( pickLighting() ) );
|
||||
connectA( resetcolor, SLOT( resetColors() ) );
|
||||
connectA( numberfont, SLOT( pickNumberFont() ) );
|
||||
connectA( labelfont, SLOT( pickLabelFont() ) );
|
||||
connectA( titlefont, SLOT( pickTitleFont() ) );
|
||||
connectA( resetfont, SLOT( resetFonts() ) );
|
||||
connect( animation, SIGNAL( toggled(bool) ) , this, SLOT( toggleAnimation(bool) ) );
|
||||
connectA( dump, SLOT( dumpImage() ) );
|
||||
connectA( openFile, SLOT( open() ) );
|
||||
//connect(openFile, SIGNAL(triggered()), this, SLOT(open()));
|
||||
connectA( openMeshFile, SLOT( openMesh() ) );
|
||||
|
||||
// only EXCLUSIVE groups emit selected :-/
|
||||
connect( left, SIGNAL( toggled( bool ) ), this, SLOT( setLeftGrid( bool ) ) );
|
||||
connect( right, SIGNAL( toggled( bool ) ), this, SLOT( setRightGrid( bool ) ) );
|
||||
connect( ceil, SIGNAL( toggled( bool ) ), this, SLOT( setCeilGrid( bool ) ) );
|
||||
connect( floor, SIGNAL( toggled( bool ) ), this, SLOT( setFloorGrid( bool ) ) );
|
||||
connect( back, SIGNAL( toggled( bool ) ), this, SLOT( setBackGrid( bool ) ) );
|
||||
connect( front, SIGNAL( toggled( bool ) ), this, SLOT( setFrontGrid( bool ) ) );
|
||||
|
||||
timer = new QTimer( this );
|
||||
connect( timer, SIGNAL(timeout()), this, SLOT(rotate()) );
|
||||
|
||||
resSlider->setRange(1,70);
|
||||
connect( resSlider, SIGNAL(valueChanged(int)), dataWidget, SLOT(setResolution(int)) );
|
||||
connect( dataWidget, SIGNAL(resolutionChanged(int)), resSlider, SLOT(setValue(int)) );
|
||||
resSlider->setValue(1);
|
||||
|
||||
connect( offsSlider, SIGNAL(valueChanged(int)), this, SLOT(setPolygonOffset(int)) );
|
||||
|
||||
connect(normButton, SIGNAL(clicked()), this, SLOT(setStandardView()));
|
||||
|
||||
QString qwtstr(" qwtplot3d ");
|
||||
qwtstr += QString::number(QWT3D_MAJOR_VERSION) + ".";
|
||||
qwtstr += QString::number(QWT3D_MINOR_VERSION) + ".";
|
||||
qwtstr += QString::number(QWT3D_PATCH_VERSION) + " ";
|
||||
|
||||
QLabel* info = new QLabel(qwtstr, statusBar());
|
||||
statusBar()->addWidget(info, 0);
|
||||
filenameWidget = new QLabel(" ", statusBar());
|
||||
statusBar()->addWidget(filenameWidget,0);
|
||||
dimWidget = new QLabel("", statusBar());
|
||||
statusBar()->addWidget(dimWidget,0);
|
||||
rotateLabel = new QLabel("", statusBar());
|
||||
statusBar()->addWidget(rotateLabel,0);
|
||||
shiftLabel = new QLabel("", statusBar());
|
||||
statusBar()->addWidget(shiftLabel,0);
|
||||
scaleLabel = new QLabel("", statusBar());
|
||||
statusBar()->addWidget(scaleLabel,0);
|
||||
zoomLabel = new QLabel("", statusBar());
|
||||
statusBar()->addWidget(zoomLabel,0);
|
||||
|
||||
connect(dataWidget, SIGNAL(rotationChanged(double,double,double)),this,SLOT(showRotate(double,double,double)));
|
||||
connect(dataWidget, SIGNAL(vieportShiftChanged(double,double)),this,SLOT(showShift(double,double)));
|
||||
connect(dataWidget, SIGNAL(scaleChanged(double,double,double)),this,SLOT(showScale(double,double,double)));
|
||||
connect(dataWidget, SIGNAL(zoomChanged(double)),this,SLOT(showZoom(double)));
|
||||
|
||||
connect(functionCB, SIGNAL(activated(const QString&)), this, SLOT(createFunction(const QString&)));
|
||||
connect(psurfaceCB, SIGNAL(activated(const QString&)), this, SLOT(createPSurface(const QString&)));
|
||||
connect(projection, SIGNAL( toggled(bool) ), this, SLOT( toggleProjectionMode(bool)));
|
||||
connect(colorlegend, SIGNAL( toggled(bool) ), this, SLOT( toggleColorLegend(bool)));
|
||||
connect(autoscale, SIGNAL( toggled(bool) ), this, SLOT( toggleAutoScale(bool)));
|
||||
connect(shader, SIGNAL( toggled(bool) ), this, SLOT( toggleShader(bool)));
|
||||
connect(mouseinput, SIGNAL( toggled(bool) ), dataWidget, SLOT( enableMouse(bool)));
|
||||
connect(lightingswitch, SIGNAL( toggled(bool) ), this, SLOT( enableLighting(bool)));
|
||||
connect(normals, SIGNAL( toggled(bool) ), this, SLOT( showNormals(bool)));
|
||||
connect(normalsquality, SIGNAL(valueChanged(int)), this, SLOT(setNormalQuality(int)) );
|
||||
connect(normalslength, SIGNAL(valueChanged(int)), this, SLOT(setNormalLength(int)) );
|
||||
|
||||
setStandardView();
|
||||
|
||||
dataWidget->coordinates()->setLineSmooth(true);
|
||||
dataWidget->coordinates()->setGridLinesColor(RGBA(0.35,0.35,0.35,1));
|
||||
dataWidget->enableMouse(true);
|
||||
dataWidget->setKeySpeed(15,20,20);
|
||||
|
||||
lightingdlg_ = new LightingDlg( this );
|
||||
lightingdlg_->assign( dataWidget);
|
||||
|
||||
#if QT_VERSION < 0x040000 //todo - restore, when Qt4 re-implements preview functionality
|
||||
datacolordlg_ = new QFileDialog( this );
|
||||
QDir dir("./../../data/colormaps");
|
||||
if (dir.exists("./../../data/colormaps"))
|
||||
datacolordlg_->setDir("./../../data/colormaps");
|
||||
datacolordlg_->setFilter("Colormap files (*.map *.MAP)");
|
||||
colormappv_ = new ColorMapPreview;
|
||||
datacolordlg_->setContentsPreviewEnabled( TRUE );
|
||||
datacolordlg_->setContentsPreview( colormappv_, colormappv_ );
|
||||
datacolordlg_->setPreviewMode( QFileDialog::Contents );
|
||||
connect(datacolordlg_, SIGNAL(fileHighlighted(const QString&)), this, SLOT(adaptDataColors(const QString&)));
|
||||
#else
|
||||
//connect(datacolordlg_, SIGNAL(filesSelected(const QStringList&)), this, SLOT(adaptDataColors4(const QStringList&)));
|
||||
#endif
|
||||
connect(filetypeCB, SIGNAL(activated(const QString&)), this, SLOT(setFileType(const QString&)));
|
||||
|
||||
filetypeCB->clear();
|
||||
|
||||
QStringList list = IO::outputFormatList();
|
||||
#if QT_VERSION < 0x040000
|
||||
filetypeCB->insertStringList(list);
|
||||
#else
|
||||
filetypeCB->insertItems(0,list);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
filetype_ = filetypeCB->currentText();
|
||||
dataWidget->setTitleFont( "Arial", 14, QFont::Normal );
|
||||
|
||||
grids->setEnabled(false);
|
||||
|
||||
PixmapWriter* pmhandler = (PixmapWriter*)IO::outputHandler("JPEG");
|
||||
if (!pmhandler)
|
||||
pmhandler = (PixmapWriter*)IO::outputHandler("jpeg"); //Qt4 naming scheme change
|
||||
if (pmhandler)
|
||||
pmhandler->setQuality(70);
|
||||
|
||||
VectorWriter* handler = (VectorWriter*)IO::outputHandler("PDF");
|
||||
handler->setTextMode(VectorWriter::TEX);
|
||||
handler = (VectorWriter*)IO::outputHandler("EPS");
|
||||
handler->setTextMode(VectorWriter::TEX);
|
||||
handler = (VectorWriter*)IO::outputHandler("EPS_GZ");
|
||||
if (handler) // with zlib support only
|
||||
handler->setTextMode(VectorWriter::TEX);
|
||||
}
|
||||
|
||||
void Mesh2MainWindow::open()
|
||||
{
|
||||
#if QT_VERSION < 0x040000
|
||||
QString s = QFileDialog::getOpenFileName( "../../data", "GridData Files (*.mes *.MES)", this );
|
||||
#else
|
||||
QString s = QFileDialog::getOpenFileName( this, "", "../../data", "GridData Files (*.mes *.MES)");
|
||||
#endif
|
||||
|
||||
if ( s.isEmpty() || !dataWidget)
|
||||
return;
|
||||
|
||||
QFileInfo fi( s );
|
||||
|
||||
#if QT_VERSION < 0x040000
|
||||
QString ext = fi.extension(); // ext = "gz"
|
||||
QToolTip::add(filenameWidget, s);
|
||||
#else
|
||||
filenameWidget->setToolTip(s);
|
||||
QString ext = fi.suffix();
|
||||
#endif
|
||||
filenameWidget->setText(fi.fileName());
|
||||
qApp->processEvents(); // enforces repaint;
|
||||
|
||||
if (IO::load(dataWidget, s, ext))
|
||||
{
|
||||
double a = dataWidget->facets().first;
|
||||
double b = dataWidget->facets().second;
|
||||
|
||||
dimWidget->setText(QString("Cells ") + QString::number(a*b)
|
||||
+ " (" + QString::number(a) + "x" + QString::number(b) +")" );
|
||||
|
||||
dataWidget->setResolution(3);
|
||||
}
|
||||
|
||||
for (unsigned i=0; i!=dataWidget->coordinates()->axes.size(); ++i)
|
||||
{
|
||||
dataWidget->coordinates()->axes[i].setMajors(4);
|
||||
dataWidget->coordinates()->axes[i].setMinors(5);
|
||||
dataWidget->coordinates()->axes[i].setLabelString("");
|
||||
}
|
||||
|
||||
updateColorLegend(4,5);
|
||||
pickCoordSystem(activeCoordSystem);
|
||||
dataWidget->showColorLegend(legend_);
|
||||
}
|
||||
|
||||
void Mesh2MainWindow::createFunction(QString const& name)
|
||||
{
|
||||
dataWidget->makeCurrent();
|
||||
|
||||
dataWidget->legend()->setScale(LINEARSCALE);
|
||||
for (unsigned i=0; i!=dataWidget->coordinates()->axes.size(); ++i)
|
||||
{
|
||||
dataWidget->coordinates()->axes[i].setMajors(7);
|
||||
dataWidget->coordinates()->axes[i].setMinors(5);
|
||||
}
|
||||
|
||||
if (name == QString("Rosenbrock"))
|
||||
{
|
||||
Rosenbrock rosenbrock(*dataWidget);
|
||||
|
||||
rosenbrock.setMesh(50,51);
|
||||
rosenbrock.setDomain(-1.73,1.55,-1.5,1.95);
|
||||
rosenbrock.setMinZ(-100);
|
||||
|
||||
rosenbrock.create();
|
||||
|
||||
dataWidget->coordinates()->axes[Z1].setScale(LOG10SCALE);
|
||||
dataWidget->coordinates()->axes[Z2].setScale(LOG10SCALE);
|
||||
dataWidget->coordinates()->axes[Z3].setScale(LOG10SCALE);
|
||||
dataWidget->coordinates()->axes[Z4].setScale(LOG10SCALE);
|
||||
dataWidget->legend()->setScale(LOG10SCALE);
|
||||
}
|
||||
else if (name == QString("Hat"))
|
||||
{
|
||||
Hat hat(*dataWidget);
|
||||
|
||||
hat.setMesh(51,72);
|
||||
hat.setDomain(-1.5,1.5,-1.5,1.5);
|
||||
hat.create();
|
||||
}
|
||||
else if (name == QString("Ripple"))
|
||||
{
|
||||
Ripple ripple(*dataWidget);
|
||||
ripple.setMesh(120,120);
|
||||
ripple.create();
|
||||
}
|
||||
else if (name == QString("Saddle"))
|
||||
{
|
||||
Saddle saddle;
|
||||
|
||||
saddle.setMesh(71,71);
|
||||
double dom = 2.5;
|
||||
saddle.setDomain(-dom, dom, -dom, dom);
|
||||
saddle.assign(*dataWidget);
|
||||
saddle.create();
|
||||
}
|
||||
else if (name == QString("Sombrero"))
|
||||
{
|
||||
Mex mex;
|
||||
|
||||
mex.setMesh(91,91);
|
||||
double dom = 15;
|
||||
mex.setDomain(-dom, dom, -dom, dom);
|
||||
mex.create(*dataWidget);
|
||||
}
|
||||
|
||||
double a = dataWidget->facets().first;
|
||||
double b = dataWidget->facets().second;
|
||||
|
||||
dimWidget->setText(QString("Cells ") + QString::number(a*b)
|
||||
+ " (" + QString::number(a) + "x" + QString::number(b) +")" );
|
||||
|
||||
updateColorLegend(7,5);
|
||||
|
||||
dataWidget->coordinates()->axes[X1].setLabelString(QString("X1"));
|
||||
dataWidget->coordinates()->axes[X2].setLabelString(QString("X2"));
|
||||
dataWidget->coordinates()->axes[X3].setLabelString(QString("X3"));
|
||||
dataWidget->coordinates()->axes[X4].setLabelString(QString("X4"));
|
||||
|
||||
dataWidget->coordinates()->axes[Y1].setLabelString(QString("Y1"));
|
||||
dataWidget->coordinates()->axes[Y2].setLabelString(QString("Y2"));
|
||||
dataWidget->coordinates()->axes[Y3].setLabelString(QString("Y3"));
|
||||
dataWidget->coordinates()->axes[Y4].setLabelString(QString("Y4"));
|
||||
|
||||
dataWidget->coordinates()->axes[Z1].setLabelString(QString("Z1"));
|
||||
dataWidget->coordinates()->axes[Z2].setLabelString(QString("Z2"));
|
||||
dataWidget->coordinates()->axes[Z3].setLabelString(QString("Z3"));
|
||||
dataWidget->coordinates()->axes[Z4].setLabelString(QString("Z4"));
|
||||
|
||||
pickCoordSystem(activeCoordSystem);
|
||||
}
|
||||
|
||||
void Mesh2MainWindow::createPSurface(QString const& name)
|
||||
{
|
||||
dataWidget->makeCurrent();
|
||||
if (name == QString("Torus"))
|
||||
{
|
||||
Torus sf(*dataWidget);
|
||||
sf.create();
|
||||
}
|
||||
else if (name == QString("Seashell"))
|
||||
{
|
||||
Seashell ss(*dataWidget);
|
||||
ss.create();
|
||||
}
|
||||
else if (name == QString("Boy"))
|
||||
{
|
||||
Boy boy(*dataWidget);
|
||||
boy.create();
|
||||
}
|
||||
else if (name == QString("Dini"))
|
||||
{
|
||||
Dini dini(*dataWidget);
|
||||
dini.create();
|
||||
}
|
||||
else if (name == QString("Cone"))
|
||||
{
|
||||
TripleField conepos;
|
||||
CellField conecell;
|
||||
createCone(conepos,conecell);
|
||||
dataWidget->loadFromData(conepos, conecell);
|
||||
}
|
||||
for (unsigned i=0; i!=dataWidget->coordinates()->axes.size(); ++i)
|
||||
{
|
||||
dataWidget->coordinates()->axes[i].setMajors(7);
|
||||
dataWidget->coordinates()->axes[i].setMinors(5);
|
||||
}
|
||||
|
||||
double a = dataWidget->facets().first;
|
||||
double b = dataWidget->facets().second;
|
||||
|
||||
dimWidget->setText(QString("Cells ") + QString::number(a*b)
|
||||
+ " (" + QString::number(a) + "x" + QString::number(b) +")" );
|
||||
|
||||
updateColorLegend(7,5);
|
||||
|
||||
dataWidget->coordinates()->axes[X1].setLabelString(QString("X1"));
|
||||
dataWidget->coordinates()->axes[X2].setLabelString(QString("X2"));
|
||||
dataWidget->coordinates()->axes[X3].setLabelString(QString("X3"));
|
||||
dataWidget->coordinates()->axes[X4].setLabelString(QString("X4"));
|
||||
|
||||
dataWidget->coordinates()->axes[Y1].setLabelString(QString("Y1"));
|
||||
dataWidget->coordinates()->axes[Y2].setLabelString(QString("Y2"));
|
||||
dataWidget->coordinates()->axes[Y3].setLabelString(QString("Y3"));
|
||||
dataWidget->coordinates()->axes[Y4].setLabelString(QString("Y4"));
|
||||
|
||||
dataWidget->coordinates()->axes[Z1].setLabelString(QString("Z1"));
|
||||
dataWidget->coordinates()->axes[Z2].setLabelString(QString("Z2"));
|
||||
dataWidget->coordinates()->axes[Z3].setLabelString(QString("Z3"));
|
||||
dataWidget->coordinates()->axes[Z4].setLabelString(QString("Z4"));
|
||||
|
||||
pickCoordSystem(activeCoordSystem);
|
||||
}
|
||||
|
||||
|
||||
void Mesh2MainWindow::pickCoordSystem( QAction* action)
|
||||
{
|
||||
if (!action || !dataWidget)
|
||||
return;
|
||||
|
||||
activeCoordSystem = action;
|
||||
|
||||
dataWidget->setTitle("QwtPlot3D (Use Ctrl-Alt-Shift-LeftBtn-Wheel or keyboard)");
|
||||
|
||||
if (!dataWidget->hasData())
|
||||
{
|
||||
double l = 0.6;
|
||||
dataWidget->createCoordinateSystem(Triple(-l,-l,-l), Triple(l,l,l));
|
||||
for (unsigned i=0; i!=dataWidget->coordinates()->axes.size(); ++i)
|
||||
{
|
||||
dataWidget->coordinates()->axes[i].setMajors(4);
|
||||
dataWidget->coordinates()->axes[i].setMinors(5);
|
||||
}
|
||||
}
|
||||
|
||||
if (action == Box || action == Frame)
|
||||
{
|
||||
if (action == Box)
|
||||
dataWidget->setCoordinateStyle(BOX);
|
||||
if (action == Frame)
|
||||
dataWidget->setCoordinateStyle(FRAME);
|
||||
grids->setEnabled(true);
|
||||
}
|
||||
else if (action == None)
|
||||
{
|
||||
dataWidget->setTitle("QwtPlot3D (Use Ctrl-Alt-Shift-LeftBtn-Wheel or keyboard)");
|
||||
dataWidget->setCoordinateStyle(NOCOORD);
|
||||
grids->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void Mesh2MainWindow::pickPlotStyle( QAction* action )
|
||||
{
|
||||
if (!action || !dataWidget)
|
||||
return;
|
||||
|
||||
if (action == polygon)
|
||||
{
|
||||
dataWidget->setPlotStyle(FILLED);
|
||||
}
|
||||
else if (action == filledmesh)
|
||||
{
|
||||
dataWidget->setPlotStyle(FILLEDMESH);
|
||||
}
|
||||
else if (action == wireframe)
|
||||
{
|
||||
dataWidget->setPlotStyle(WIREFRAME);
|
||||
}
|
||||
else if (action == hiddenline)
|
||||
{
|
||||
dataWidget->setPlotStyle(HIDDENLINE);
|
||||
}
|
||||
else if (action == pointstyle)
|
||||
{
|
||||
|
||||
dataWidget->setPlotStyle(Qwt3D::POINTS);
|
||||
// Cone d(len,32);
|
||||
// CrossHair d(0.003,0,true,false);
|
||||
// dataWidget->setPlotStyle(d);
|
||||
}
|
||||
else
|
||||
{
|
||||
dataWidget->setPlotStyle(NOPLOT);
|
||||
}
|
||||
dataWidget->updateData();
|
||||
dataWidget->updateGL();
|
||||
}
|
||||
|
||||
void
|
||||
Mesh2MainWindow::pickFloorStyle( QAction* action )
|
||||
{
|
||||
if (!action || !dataWidget)
|
||||
return;
|
||||
|
||||
if (action == floordata)
|
||||
{
|
||||
dataWidget->setFloorStyle(FLOORDATA);
|
||||
}
|
||||
else if (action == flooriso)
|
||||
{
|
||||
dataWidget->setFloorStyle(FLOORISO);
|
||||
}
|
||||
else
|
||||
{
|
||||
dataWidget->setFloorStyle(NOFLOOR);
|
||||
}
|
||||
|
||||
dataWidget->updateData();
|
||||
dataWidget->updateGL();
|
||||
}
|
||||
|
||||
void Mesh2MainWindow::setLeftGrid(bool b)
|
||||
{
|
||||
setGrid(Qwt3D::LEFT,b);
|
||||
}
|
||||
void Mesh2MainWindow::setRightGrid(bool b)
|
||||
{
|
||||
setGrid(Qwt3D::RIGHT,b);
|
||||
}
|
||||
void Mesh2MainWindow::setCeilGrid(bool b)
|
||||
{
|
||||
setGrid(Qwt3D::CEIL,b);
|
||||
}
|
||||
void Mesh2MainWindow::setFloorGrid(bool b)
|
||||
{
|
||||
setGrid(Qwt3D::FLOOR,b);
|
||||
}
|
||||
void Mesh2MainWindow::setFrontGrid(bool b)
|
||||
{
|
||||
setGrid(Qwt3D::FRONT,b);
|
||||
}
|
||||
void Mesh2MainWindow::setBackGrid(bool b)
|
||||
{
|
||||
setGrid(Qwt3D::BACK,b);
|
||||
}
|
||||
|
||||
void Mesh2MainWindow::setGrid(Qwt3D::SIDE s, bool b)
|
||||
{
|
||||
if (!dataWidget)
|
||||
return;
|
||||
|
||||
int sum = dataWidget->coordinates()->grids();
|
||||
|
||||
if (b)
|
||||
sum |= s;
|
||||
else
|
||||
sum &= ~s;
|
||||
|
||||
dataWidget->coordinates()->setGridLines(sum!=Qwt3D::NOSIDEGRID, sum!=Qwt3D::NOSIDEGRID, sum);
|
||||
dataWidget->updateGL();
|
||||
}
|
||||
|
||||
void Mesh2MainWindow::resetColors()
|
||||
{
|
||||
if (!dataWidget)
|
||||
return;
|
||||
|
||||
const RGBA axc = RGBA(0,0,0,1);
|
||||
const RGBA bgc = RGBA(1.0,1.0,1.0,1.0);
|
||||
const RGBA msc = RGBA(0,0,0,1);
|
||||
const RGBA nuc = RGBA(0,0,0,1);
|
||||
const RGBA lbc = RGBA(0,0,0,1);
|
||||
const RGBA tc = RGBA(0,0,0,1);
|
||||
|
||||
dataWidget->coordinates()->setAxesColor(axc);
|
||||
dataWidget->setBackgroundColor(bgc);
|
||||
dataWidget->setMeshColor(msc);
|
||||
dataWidget->updateData();
|
||||
dataWidget->coordinates()->setNumberColor(nuc);
|
||||
dataWidget->coordinates()->setLabelColor(lbc);
|
||||
dataWidget->setTitleColor(tc);
|
||||
|
||||
col_ = new StandardColor(dataWidget);
|
||||
dataWidget->setDataColor(col_);
|
||||
dataWidget->updateData();
|
||||
dataWidget->updateNormals();
|
||||
dataWidget->updateGL();
|
||||
}
|
||||
|
||||
|
||||
void Mesh2MainWindow::pickAxesColor()
|
||||
{
|
||||
QColor c = QColorDialog::getColor( Qt::white, this );
|
||||
if ( !c.isValid() )
|
||||
return;
|
||||
RGBA rgb = Qt2GL(c);
|
||||
dataWidget->coordinates()->setAxesColor(rgb);
|
||||
dataWidget->updateGL();
|
||||
}
|
||||
|
||||
void Mesh2MainWindow::pickBgColor()
|
||||
{
|
||||
|
||||
QColor c = QColorDialog::getColor( Qt::white, this );
|
||||
if ( !c.isValid() )
|
||||
return;
|
||||
RGBA rgb = Qt2GL(c);
|
||||
dataWidget->setBackgroundColor(rgb);
|
||||
dataWidget->updateGL();
|
||||
}
|
||||
|
||||
void Mesh2MainWindow::pickMeshColor()
|
||||
{
|
||||
|
||||
QColor c = QColorDialog::getColor( Qt::white, this );
|
||||
if ( !c.isValid() )
|
||||
return;
|
||||
RGBA rgb = Qt2GL(c);
|
||||
dataWidget->setMeshColor(rgb);
|
||||
dataWidget->updateData();
|
||||
dataWidget->updateGL();
|
||||
}
|
||||
|
||||
void Mesh2MainWindow::pickNumberColor()
|
||||
{
|
||||
|
||||
QColor c = QColorDialog::getColor( Qt::white, this );
|
||||
if ( !c.isValid() )
|
||||
return;
|
||||
RGBA rgb = Qt2GL(c);
|
||||
dataWidget->coordinates()->setNumberColor(rgb);
|
||||
dataWidget->updateGL();
|
||||
}
|
||||
|
||||
void Mesh2MainWindow::pickLabelColor()
|
||||
{
|
||||
QColor c = QColorDialog::getColor( Qt::white, this );
|
||||
if ( !c.isValid() )
|
||||
return;
|
||||
RGBA rgb = Qt2GL(c);
|
||||
dataWidget->coordinates()->setLabelColor(rgb);
|
||||
dataWidget->updateGL();
|
||||
}
|
||||
void Mesh2MainWindow::pickTitleColor()
|
||||
{
|
||||
QColor c = QColorDialog::getColor( Qt::white, this );
|
||||
if ( !c.isValid() )
|
||||
return;
|
||||
RGBA rgb = Qt2GL(c);
|
||||
dataWidget->setTitleColor(rgb);
|
||||
dataWidget->updateGL();
|
||||
}
|
||||
|
||||
void Mesh2MainWindow::pickLighting()
|
||||
{
|
||||
lightingdlg_->show();
|
||||
}
|
||||
|
||||
void Mesh2MainWindow::pickDataColor()
|
||||
{
|
||||
#if QT_VERSION < 0x040000
|
||||
datacolordlg_->show();
|
||||
#else
|
||||
QString s = QFileDialog::getOpenFileName( this, "", "./../../data/colormaps", "Colormap files (*.map *.MAP)");
|
||||
adaptDataColors(s);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Mesh2MainWindow::adaptDataColors(const QString& fileName)
|
||||
{
|
||||
ColorVector cv;
|
||||
|
||||
if (!openColorMap(cv, fileName))
|
||||
return;
|
||||
|
||||
col_ = new StandardColor(dataWidget);
|
||||
col_->setColorVector(cv);
|
||||
|
||||
dataWidget->setDataColor(col_);
|
||||
dataWidget->updateData();
|
||||
dataWidget->updateNormals();
|
||||
dataWidget->showColorLegend(legend_);
|
||||
dataWidget->updateGL();
|
||||
}
|
||||
|
||||
void Mesh2MainWindow::pickNumberFont()
|
||||
{
|
||||
bool ok;
|
||||
QFont font = QFontDialog::getFont(&ok, this );
|
||||
if ( !ok )
|
||||
{
|
||||
return;
|
||||
}
|
||||
dataWidget->coordinates()->setNumberFont(font);
|
||||
dataWidget->updateGL();
|
||||
}
|
||||
void Mesh2MainWindow::pickLabelFont()
|
||||
{
|
||||
bool ok;
|
||||
QFont font = QFontDialog::getFont(&ok, this );
|
||||
if ( !ok )
|
||||
{
|
||||
return;
|
||||
}
|
||||
dataWidget->coordinates()->setLabelFont(font);
|
||||
dataWidget->updateGL();
|
||||
}
|
||||
void Mesh2MainWindow::pickTitleFont()
|
||||
{
|
||||
bool ok;
|
||||
QFont font = QFontDialog::getFont(&ok, this );
|
||||
if ( !ok )
|
||||
{
|
||||
return;
|
||||
}
|
||||
dataWidget->setTitleFont(font.family(), font.pointSize(), font.weight(), font.italic());
|
||||
}
|
||||
|
||||
void Mesh2MainWindow::resetFonts()
|
||||
{
|
||||
dataWidget->coordinates()->setNumberFont(QFont("Courier", 12));
|
||||
dataWidget->coordinates()->setLabelFont(QFont("Courier", 14, QFont::Bold));
|
||||
dataWidget->setTitleFont( "Arial", 14, QFont::Normal );
|
||||
dataWidget->updateGL();
|
||||
}
|
||||
|
||||
void Mesh2MainWindow::setStandardView()
|
||||
{
|
||||
dataWidget->setRotation(30,0,15);
|
||||
dataWidget->setViewportShift(0.05,0);
|
||||
dataWidget->setScale(1,1,1);
|
||||
dataWidget->setZoom(0.95);
|
||||
}
|
||||
|
||||
void Mesh2MainWindow::dumpImage()
|
||||
{
|
||||
static int counter = 0;
|
||||
if (!dataWidget)
|
||||
return;
|
||||
QString name;
|
||||
|
||||
name = QString("dump_") + QString::number(counter++) + ".";
|
||||
|
||||
if (filetype_ == "PS_GZ")
|
||||
name += "ps.gz";
|
||||
else if (filetype_ == "EPS_GZ")
|
||||
name += "eps.gz";
|
||||
else
|
||||
name += filetype_;
|
||||
|
||||
#if QT_VERSION < 0x040000
|
||||
IO::save(dataWidget, name.lower(), filetype_);
|
||||
#else
|
||||
VectorWriter* vw = (VectorWriter*)IO::outputHandler("PDF");
|
||||
if (vw)
|
||||
vw->setSortMode(VectorWriter::BSPSORT);
|
||||
IO::save(dataWidget, name.toLower(), filetype_);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
Turns animation on or off
|
||||
*/
|
||||
void Mesh2MainWindow::toggleAnimation(bool val)
|
||||
{
|
||||
if ( val )
|
||||
{
|
||||
timer->start( redrawWait ); // Wait this many msecs before redraw
|
||||
}
|
||||
else
|
||||
{
|
||||
timer->stop();
|
||||
}
|
||||
}
|
||||
|
||||
void Mesh2MainWindow::rotate()
|
||||
{
|
||||
if (!dataWidget)
|
||||
return;
|
||||
|
||||
dataWidget->setRotation(
|
||||
int(dataWidget->xRotation() + 1) % 360,
|
||||
int(dataWidget->yRotation() + 1) % 360,
|
||||
int(dataWidget->zRotation() + 1) % 360
|
||||
);
|
||||
}
|
||||
|
||||
void
|
||||
Mesh2MainWindow::toggleProjectionMode(bool val)
|
||||
{
|
||||
dataWidget->setOrtho(val);
|
||||
}
|
||||
|
||||
void
|
||||
Mesh2MainWindow::toggleColorLegend(bool val)
|
||||
{
|
||||
legend_ = val;
|
||||
dataWidget->showColorLegend(val);
|
||||
}
|
||||
|
||||
void
|
||||
Mesh2MainWindow::toggleAutoScale(bool val)
|
||||
{
|
||||
dataWidget->coordinates()->setAutoScale(val);
|
||||
dataWidget->updateGL();
|
||||
}
|
||||
|
||||
void
|
||||
Mesh2MainWindow::toggleShader(bool val)
|
||||
{
|
||||
if (val)
|
||||
dataWidget->setShading(GOURAUD);
|
||||
else
|
||||
dataWidget->setShading(FLAT);
|
||||
}
|
||||
|
||||
void
|
||||
Mesh2MainWindow::setPolygonOffset(int val)
|
||||
{
|
||||
dataWidget->setPolygonOffset(val / 10.0);
|
||||
dataWidget->updateData();
|
||||
dataWidget->updateGL();
|
||||
}
|
||||
|
||||
void
|
||||
Mesh2MainWindow::showRotate(double x, double y, double z)
|
||||
{
|
||||
rotateLabel->setText(" Angles (" + QString::number(x,'g',3) + " ,"
|
||||
+ QString::number(y,'g',3) + " ,"
|
||||
+ QString::number(z,'g',3) + ")");
|
||||
}
|
||||
void
|
||||
Mesh2MainWindow::showShift(double x, double y)
|
||||
{
|
||||
shiftLabel->setText(" Shifts (" + QString::number(x,'g',3) + " ,"
|
||||
+ QString::number(y,'g',3) + " )"
|
||||
);
|
||||
}
|
||||
void
|
||||
Mesh2MainWindow::showScale(double x, double y, double z)
|
||||
{
|
||||
scaleLabel->setText(" Scales (" + QString::number(x,'g',3) + " ,"
|
||||
+ QString::number(y,'g',3) + " ,"
|
||||
+ QString::number(z,'g',3) + ")");
|
||||
}
|
||||
void
|
||||
Mesh2MainWindow::showZoom(double z)
|
||||
{
|
||||
zoomLabel->setText(" Zoom " + QString::number(z,'g',3));
|
||||
}
|
||||
|
||||
void Mesh2MainWindow::openMesh()
|
||||
{
|
||||
#if QT_VERSION < 0x040000
|
||||
QString data(QFileDialog::getOpenFileName( "../../data", "nodes (*.nod)", this ) );
|
||||
QString edges( QFileDialog::getOpenFileName( "../../data", "connectivities (*.cel)", this ) );
|
||||
#else
|
||||
QString data( QFileDialog::getOpenFileName( this, "", "../../data", "nodes (*.nod)") );
|
||||
QString edges( QFileDialog::getOpenFileName( this, "", "../../data", "connectivities (*.cel)") );
|
||||
#endif
|
||||
|
||||
if ( data.isEmpty() || edges.isEmpty() || !dataWidget)
|
||||
return;
|
||||
|
||||
|
||||
TripleField vdata;
|
||||
CellField vpoly;
|
||||
|
||||
readNodes(vdata, QWT3DLOCAL8BIT(data), NodeFilter());
|
||||
readConnections(vpoly, QWT3DLOCAL8BIT(edges), CellFilter());
|
||||
|
||||
dataWidget->loadFromData(vdata, vpoly);
|
||||
dimWidget->setText(QString("Cells ") + QString::number(dataWidget->facets().first));
|
||||
|
||||
for (unsigned i=0; i!=dataWidget->coordinates()->axes.size(); ++i)
|
||||
{
|
||||
dataWidget->coordinates()->axes[i].setMajors(4);
|
||||
dataWidget->coordinates()->axes[i].setMinors(5);
|
||||
dataWidget->coordinates()->axes[i].setLabelString(QString(""));
|
||||
}
|
||||
|
||||
updateColorLegend(4,5);
|
||||
pickCoordSystem(activeCoordSystem);
|
||||
}
|
||||
|
||||
void
|
||||
Mesh2MainWindow::showNormals(bool val)
|
||||
{
|
||||
dataWidget->showNormals(val);
|
||||
dataWidget->updateNormals();
|
||||
dataWidget->updateGL();
|
||||
}
|
||||
|
||||
void
|
||||
Mesh2MainWindow::setNormalLength(int val)
|
||||
{
|
||||
dataWidget->setNormalLength(val / 400.);
|
||||
dataWidget->updateNormals();
|
||||
dataWidget->updateGL();
|
||||
}
|
||||
|
||||
void
|
||||
Mesh2MainWindow::setNormalQuality(int val)
|
||||
{
|
||||
dataWidget->setNormalQuality(val);
|
||||
dataWidget->updateNormals();
|
||||
dataWidget->updateGL();
|
||||
}
|
||||
|
||||
bool
|
||||
Mesh2MainWindow::openColorMap(ColorVector& cv, QString fname)
|
||||
{
|
||||
if (fname.isEmpty())
|
||||
return false;
|
||||
|
||||
ifstream file(QWT3DLOCAL8BIT(fname));
|
||||
|
||||
if (!file)
|
||||
return false;
|
||||
|
||||
RGBA rgb;
|
||||
cv.clear();
|
||||
|
||||
while ( file )
|
||||
{
|
||||
file >> rgb.r >> rgb.g >> rgb.b;
|
||||
file.ignore(1000,'\n');
|
||||
if (!file.good())
|
||||
break;
|
||||
else
|
||||
{
|
||||
rgb.a = 1;
|
||||
rgb.r /= 255;
|
||||
rgb.g /= 255;
|
||||
rgb.b /= 255;
|
||||
cv.push_back(rgb);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
Mesh2MainWindow::updateColorLegend(int majors, int minors)
|
||||
{
|
||||
dataWidget->legend()->setMajors(majors);
|
||||
dataWidget->legend()->setMinors(minors);
|
||||
double start, stop;
|
||||
dataWidget->coordinates()->axes[Z1].limits(start,stop);
|
||||
dataWidget->legend()->setLimits(start, stop);
|
||||
}
|
||||
|
||||
void Mesh2MainWindow::setFileType(QString const& name)
|
||||
{
|
||||
filetype_ = name;
|
||||
}
|
||||
|
||||
void Mesh2MainWindow::enableLighting(bool val)
|
||||
{
|
||||
dataWidget->enableLighting(val);
|
||||
dataWidget->illuminate(0);
|
||||
dataWidget->updateGL();
|
||||
}
|
@ -0,0 +1,134 @@
|
||||
#ifndef mesh2mainwindow_h__2004_03_07_13_38_begin_guarded_code
|
||||
#define mesh2mainwindow_h__2004_03_07_13_38_begin_guarded_code
|
||||
|
||||
#include "../../../include/qwt3d_surfaceplot.h"
|
||||
|
||||
|
||||
#if QT_VERSION < 0x040000
|
||||
#include "mesh2mainwindowbase.h"
|
||||
#else
|
||||
#include "ui_mesh2mainwindowbase4.h"
|
||||
#include "designerworkaround.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//MOC_SKIP_BEGIN
|
||||
#if QT_VERSION < 0x040000
|
||||
class DummyBase : public Mesh2MainWindowBase
|
||||
{
|
||||
public:
|
||||
DummyBase(QWidget* parent = 0)
|
||||
: Mesh2MainWindowBase(parent)
|
||||
{
|
||||
}
|
||||
};
|
||||
#else
|
||||
class DummyBase : public QMainWindow, protected Ui::MainWindow, protected DesignerWorkaround
|
||||
{
|
||||
public:
|
||||
DummyBase(QWidget* parent = 0)
|
||||
: QMainWindow(parent)
|
||||
{
|
||||
}
|
||||
};
|
||||
#endif
|
||||
//MOC_SKIP_END
|
||||
|
||||
class QLabel;
|
||||
class QTimer;
|
||||
class QAction;
|
||||
class QFileDialog;
|
||||
class LightingDlg;
|
||||
class ColorMapPreview;
|
||||
|
||||
class Mesh2MainWindow : public DummyBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Mesh2MainWindow( QWidget* parent = 0 );
|
||||
~Mesh2MainWindow();
|
||||
|
||||
Qwt3D::SurfacePlot* dataWidget;
|
||||
|
||||
public slots:
|
||||
void open();
|
||||
void openMesh();
|
||||
|
||||
void createFunction(QString const& name);
|
||||
void createPSurface(QString const& name);
|
||||
void setFileType(QString const& name);
|
||||
|
||||
void pickCoordSystem( QAction* );
|
||||
void pickPlotStyle( QAction* );
|
||||
void pickFloorStyle( QAction* );
|
||||
void pickAxesColor();
|
||||
void pickBgColor();
|
||||
void pickMeshColor();
|
||||
void pickNumberColor();
|
||||
void pickLabelColor();
|
||||
void pickTitleColor();
|
||||
void pickDataColor();
|
||||
void pickLighting();
|
||||
void resetColors();
|
||||
void pickNumberFont();
|
||||
void pickLabelFont();
|
||||
void pickTitleFont();
|
||||
void resetFonts();
|
||||
void setStandardView();
|
||||
void dumpImage();
|
||||
void toggleAnimation(bool);
|
||||
void toggleProjectionMode(bool);
|
||||
void toggleColorLegend(bool);
|
||||
void toggleAutoScale(bool val);
|
||||
void toggleShader(bool val);
|
||||
void rotate();
|
||||
void setPolygonOffset(int);
|
||||
|
||||
void showRotate(double x, double y, double z);
|
||||
void showShift(double x, double y);
|
||||
void showScale(double x, double y, double z);
|
||||
void showZoom(double z);
|
||||
void showNormals(bool val);
|
||||
void setNormalQuality(int);
|
||||
void setNormalLength(int);
|
||||
bool openColorMap(Qwt3D::ColorVector& cv, QString fname);
|
||||
void adaptDataColors(const QString&);
|
||||
void updateColorLegend(int majors, int minors);
|
||||
|
||||
void setLeftGrid( bool b );
|
||||
void setRightGrid( bool b );
|
||||
void setCeilGrid( bool b );
|
||||
void setFloorGrid( bool b );
|
||||
void setFrontGrid( bool b );
|
||||
void setBackGrid( bool b );
|
||||
void setGrid( Qwt3D::SIDE, bool );
|
||||
|
||||
void enableLighting(bool val);
|
||||
|
||||
private:
|
||||
QLabel *filenameWidget, *dimWidget,
|
||||
*rotateLabel, *shiftLabel, *scaleLabel, *zoomLabel;
|
||||
|
||||
QTimer* timer;
|
||||
int redrawWait;
|
||||
|
||||
QAction* activeCoordSystem;
|
||||
|
||||
bool legend_;
|
||||
Qwt3D::StandardColor* col_;
|
||||
|
||||
QFileDialog* datacolordlg_;
|
||||
LightingDlg* lightingdlg_;
|
||||
QString filetype_;
|
||||
|
||||
// convenience compatib. code
|
||||
bool connectA (const QObject* sender, const char * slot);
|
||||
bool connectAG (const QObject* sender, const char * slot);
|
||||
|
||||
#if QT_VERSION < 0x040000
|
||||
ColorMapPreview* colormappv_;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* include guarded */
|
@ -0,0 +1,479 @@
|
||||
<ui version="4.0" >
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>Mesh2</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget" >
|
||||
<layout class="QGridLayout" >
|
||||
<property name="leftMargin" >
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="horizontalSpacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="verticalSpacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="1" column="0" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="normButton" >
|
||||
<property name="text" >
|
||||
<string>Std</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="lighting" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Lighting</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="lightingswitch" >
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<string><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Polygon Offset</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="offsSlider" >
|
||||
<property name="maximum" >
|
||||
<number>30</number>
|
||||
</property>
|
||||
<property name="pageStep" >
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="value" >
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickPosition" >
|
||||
<enum>QSlider::TicksAbove</enum>
|
||||
</property>
|
||||
<property name="tickInterval" >
|
||||
<number>2</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3" >
|
||||
<property name="text" >
|
||||
<string><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Resolution</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="resSlider" >
|
||||
<property name="minimum" >
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum" >
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickPosition" >
|
||||
<enum>QSlider::TicksAbove</enum>
|
||||
</property>
|
||||
<property name="tickInterval" >
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="MinimumExpanding" hsizetype="MinimumExpanding" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape" >
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow" >
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="projection" >
|
||||
<property name="text" >
|
||||
<string>Ortho</string>
|
||||
</property>
|
||||
<property name="checked" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="colorlegend" >
|
||||
<property name="text" >
|
||||
<string>Legend</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="autoscale" >
|
||||
<property name="text" >
|
||||
<string>Autoscale</string>
|
||||
</property>
|
||||
<property name="checked" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="mouseinput" >
|
||||
<property name="text" >
|
||||
<string>Mouse</string>
|
||||
</property>
|
||||
<property name="checked" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="shader" >
|
||||
<property name="text" >
|
||||
<string>Shading</string>
|
||||
</property>
|
||||
<property name="checked" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Normals</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QSlider" name="normalsquality" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimum" >
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="maximum" >
|
||||
<number>32</number>
|
||||
</property>
|
||||
<property name="pageStep" >
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="value" >
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="invertedAppearance" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="tickPosition" >
|
||||
<enum>QSlider::TicksAbove</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="normalslength" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimum" >
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum" >
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="pageStep" >
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="value" >
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="invertedAppearance" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="tickPosition" >
|
||||
<enum>QSlider::TicksAbove</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../images.qrc" />
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>lightingswitch</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>lighting</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>181</x>
|
||||
<y>568</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>144</x>
|
||||
<y>568</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -0,0 +1,9 @@
|
||||
\documentclass{slides}
|
||||
\usepackage[dvips]{color}
|
||||
\usepackage{times}
|
||||
\usepackage{graphicx}
|
||||
|
||||
\begin{document}
|
||||
\include{dump_0.pdf}
|
||||
%\include{dump3b}
|
||||
\end{document}
|
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 824 B |
After Width: | Height: | Size: 487 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 733 B |
After Width: | Height: | Size: 543 B |
After Width: | Height: | Size: 550 B |
After Width: | Height: | Size: 479 B |
@ -0,0 +1,83 @@
|
||||
//-----------------------------------------------------------------
|
||||
// simpleplot.cpp
|
||||
//
|
||||
// A simple example which shows how to use SurfacePlot
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
#include <math.h>
|
||||
#include <qapplication.h>
|
||||
#include <qwt3d_surfaceplot.h>
|
||||
#include <qwt3d_function.h>
|
||||
|
||||
|
||||
using namespace Qwt3D;
|
||||
|
||||
class Rosenbrock : public Function
|
||||
{
|
||||
public:
|
||||
|
||||
Rosenbrock(SurfacePlot& pw)
|
||||
:Function(pw)
|
||||
{
|
||||
}
|
||||
|
||||
double operator()(double x, double y)
|
||||
{
|
||||
return log((1-x)*(1-x) + 100 * (y - x*x)*(y - x*x)) / 8;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class Plot : public SurfacePlot
|
||||
{
|
||||
public:
|
||||
Plot();
|
||||
};
|
||||
|
||||
|
||||
Plot::Plot()
|
||||
{
|
||||
setTitle("A Simple SurfacePlot Demonstration");
|
||||
|
||||
Rosenbrock rosenbrock(*this);
|
||||
|
||||
rosenbrock.setMesh(41,31);
|
||||
rosenbrock.setDomain(-1.73,1.5,-1.5,1.5);
|
||||
rosenbrock.setMinZ(-10);
|
||||
|
||||
rosenbrock.create();
|
||||
|
||||
setRotation(30,0,15);
|
||||
setScale(1,1,1);
|
||||
setShift(0.15,0,0);
|
||||
setZoom(0.9);
|
||||
|
||||
for (unsigned i=0; i!=coordinates()->axes.size(); ++i)
|
||||
{
|
||||
coordinates()->axes[i].setMajors(7);
|
||||
coordinates()->axes[i].setMinors(4);
|
||||
}
|
||||
|
||||
|
||||
coordinates()->axes[X1].setLabelString("x-axis");
|
||||
coordinates()->axes[Y1].setLabelString("y-axis");
|
||||
//coordinates()->axes[Z1].setLabelString(QChar(0x38f)); // Omega - see http://www.unicode.org/charts/
|
||||
|
||||
|
||||
setCoordinateStyle(BOX);
|
||||
|
||||
updateData();
|
||||
updateGL();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
Plot plot;
|
||||
#if QT_VERSION < 0x040000
|
||||
a.setMainWidget(&plot);
|
||||
#endif
|
||||
plot.resize(800,600);
|
||||
plot.show();
|
||||
return a.exec();
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
include( ../common.pro )
|
||||
|
||||
SOURCES = simpleplot.cpp
|
After Width: | Height: | Size: 1.1 KiB |
@ -0,0 +1,75 @@
|
||||
#ifndef qwt3d_autoptr_h__2004_05_14_18_57_begin_guarded_code
|
||||
#define qwt3d_autoptr_h__2004_05_14_18_57_begin_guarded_code
|
||||
|
||||
namespace Qwt3D
|
||||
{
|
||||
|
||||
//! Simple Auto pointer providing deep copies for raw pointer
|
||||
/*!
|
||||
Requirements: \n
|
||||
virtual T* T::clone() const;\n
|
||||
T::destroy() const;
|
||||
virtual ~T() private/protected\n\n
|
||||
clone() is necessary for the pointer to preserve polymorphic behaviour.
|
||||
The pointer requires also heap based objects with regard to the template
|
||||
argument in order to be able to get ownership and control over destruction.
|
||||
*/
|
||||
template <typename T>
|
||||
class qwt3d_ptr
|
||||
{
|
||||
public:
|
||||
//! Standard ctor
|
||||
explicit qwt3d_ptr(T* ptr = 0)
|
||||
:rawptr_(ptr)
|
||||
{
|
||||
}
|
||||
//! Dtor (calls T::destroy)
|
||||
~qwt3d_ptr()
|
||||
{
|
||||
destroyRawPtr();
|
||||
}
|
||||
|
||||
//! Copy ctor (calls (virtual) clone())
|
||||
qwt3d_ptr(qwt3d_ptr const& val)
|
||||
{
|
||||
rawptr_ = val.rawptr_->clone();
|
||||
}
|
||||
|
||||
//! Assignment in the same spirit as copy ctor
|
||||
qwt3d_ptr<T>& operator=(qwt3d_ptr const& val)
|
||||
{
|
||||
if (this == &val)
|
||||
return *this;
|
||||
|
||||
destroyRawPtr();
|
||||
rawptr_ = val.rawptr_->clone();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! It's a pointerlike object, isn't it ?
|
||||
T* operator->() const
|
||||
{
|
||||
return rawptr_;
|
||||
}
|
||||
|
||||
//! Dereferencing
|
||||
T& operator*() const
|
||||
{
|
||||
return *rawptr_;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
T* rawptr_;
|
||||
void destroyRawPtr()
|
||||
{
|
||||
if (rawptr_)
|
||||
rawptr_->destroy();
|
||||
rawptr_ = 0;
|
||||
}
|
||||
};
|
||||
|
||||
} // ns
|
||||
|
||||
#endif /* include guarded */
|
@ -0,0 +1,51 @@
|
||||
#ifndef __qwt3d_autoscaler_2003_08_18_12_05__
|
||||
#define __qwt3d_autoscaler_2003_08_18_12_05__
|
||||
|
||||
#include <vector>
|
||||
#include "qwt3d_global.h"
|
||||
#include "qwt3d_autoptr.h"
|
||||
|
||||
namespace Qwt3D
|
||||
{
|
||||
|
||||
//! ABC for autoscaler
|
||||
class QWT3D_EXPORT AutoScaler
|
||||
{
|
||||
friend class qwt3d_ptr<AutoScaler>;
|
||||
protected:
|
||||
//! Returns a new heap based object of the derived class.
|
||||
virtual AutoScaler* clone() const = 0;
|
||||
//! To implement from subclasses
|
||||
virtual int execute(double& a, double& b, double start, double stop, int ivals) = 0;
|
||||
virtual ~AutoScaler(){}
|
||||
|
||||
private:
|
||||
void destroy() const {delete this;} //!< Used by qwt3d_ptr
|
||||
};
|
||||
|
||||
//! Automatic beautifying of linear scales
|
||||
class QWT3D_EXPORT LinearAutoScaler : public AutoScaler
|
||||
{
|
||||
friend class LinearScale;
|
||||
protected:
|
||||
LinearAutoScaler();
|
||||
explicit LinearAutoScaler(std::vector<double>& mantisses);
|
||||
//! Returns a new heap based object utilized from qwt3d_ptr
|
||||
AutoScaler* clone() const {return new LinearAutoScaler(*this);}
|
||||
int execute(double& a, double& b, double start, double stop, int ivals);
|
||||
|
||||
private:
|
||||
|
||||
double start_, stop_;
|
||||
int intervals_;
|
||||
|
||||
void init(double start, double stop, int ivals);
|
||||
double anchorvalue(double start, double mantisse, int exponent);
|
||||
int segments(int& l_intervals, int& r_intervals, double start, double stop, double anchor, double mantissa, int exponent);
|
||||
std::vector<double> mantissi_;
|
||||
};
|
||||
|
||||
} // ns
|
||||
|
||||
|
||||
#endif
|
@ -0,0 +1,131 @@
|
||||
#ifndef __AXIS_H__
|
||||
#define __AXIS_H__
|
||||
|
||||
#include "qwt3d_autoptr.h"
|
||||
#include "qwt3d_label.h"
|
||||
#include "qwt3d_scale.h"
|
||||
#include "qwt3d_autoscaler.h"
|
||||
|
||||
namespace Qwt3D
|
||||
{
|
||||
|
||||
//! Autoscalable axis with caption.
|
||||
/*!
|
||||
Axes are highly customizable especially in terms
|
||||
of labeling and scaling.
|
||||
*/
|
||||
class QWT3D_EXPORT Axis : public Drawable
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
Axis(); //!< Constructs standard axis
|
||||
Axis(Qwt3D::Triple beg, Qwt3D::Triple end); //!< Constructs a new axis with specified limits
|
||||
virtual ~Axis(); // dtor
|
||||
|
||||
virtual void draw(); //!< Draws axis
|
||||
|
||||
void setPosition(const Qwt3D::Triple& beg, const Qwt3D::Triple& end); //!< Positionate axis
|
||||
void position(Qwt3D::Triple& beg, Qwt3D::Triple& end) const {beg = beg_; end = end_;} //!< Returns axis' position
|
||||
Qwt3D::Triple begin() const { return beg_; } //!< Returns axis' beginning position
|
||||
Qwt3D::Triple end() const { return end_; } //!< Returns axis' ending position
|
||||
double length() const { return (end_-beg_).length(); } //!< Returns axis' length
|
||||
|
||||
void setTicLength(double majorl, double minorl); //!< Sets tics lengths in world coordinates
|
||||
//! Returns tics lengths
|
||||
void ticLength(double& majorl, double& minorl) const {majorl = lmaj_; minorl = lmin_;}
|
||||
void setTicOrientation(double tx, double ty, double tz); //!< Sets tic orientation
|
||||
void setTicOrientation(const Qwt3D::Triple& val); //!< Same function as above
|
||||
Qwt3D::Triple ticOrientation() const { return orientation_;} //!< Returns tic orientation
|
||||
void setSymmetricTics( bool b) { symtics_ = b;} //!< Sets two-sided tics (default is false)
|
||||
|
||||
//! Sets font for axis label
|
||||
void setLabelFont(QString const& family, int pointSize, int weight = QFont::Normal, bool italic = false);
|
||||
void setLabelFont(QFont const& font); //!< Sets font for axis label
|
||||
QFont const& labelFont() const {return labelfont_;} //!< Returns current label font
|
||||
|
||||
void setLabelString(QString const& name); //!< Sets label content
|
||||
void setLabelPosition(const Qwt3D::Triple& pos, Qwt3D::ANCHOR);
|
||||
void setLabelColor(Qwt3D::RGBA col);
|
||||
void setLabel(bool d) {drawLabel_ = d;} //!< Turns label drawing on or off
|
||||
void adjustLabel(int val) {labelgap_ = val;} //!< Shifts label in device coordinates dependent on anchor;
|
||||
|
||||
void setScaling(bool d) {drawTics_ = d;} //!< Turns scale drawing on or off
|
||||
bool scaling() const {return drawTics_;} //!< Returns, if scale drawing is on or off
|
||||
void setScale(Qwt3D::SCALETYPE);
|
||||
void setScale(Scale* item);
|
||||
void setNumbers(bool d) {drawNumbers_ = d;} //!< Turns number drawing on or off
|
||||
bool numbers() const {return drawNumbers_;} //!< Returns, if number drawing is on or off
|
||||
void setNumberColor(Qwt3D::RGBA col); //!< Sets the color for axes numbers
|
||||
Qwt3D::RGBA numberColor() const {return numbercolor_;} //!< Returns the color for axes numbers
|
||||
//! Sets font for numbering
|
||||
void setNumberFont(QString const& family, int pointSize, int weight = QFont::Normal, bool italic = false);
|
||||
void setNumberFont(QFont const&); //!< Overloaded member, works like the above function
|
||||
QFont const& numberFont() const {return numberfont_;} //!< Returns current numbering font
|
||||
void setNumberAnchor(Qwt3D::ANCHOR a) { scaleNumberAnchor_ = a;} //!< Sets anchor position for numbers
|
||||
void adjustNumbers(int val) {numbergap_ = val;} //!< Shifts axis numbers in device coordinates dependent on anchor;
|
||||
|
||||
void setAutoScale(bool val = true) {autoscale_ = val;} //!< Turns Autoscaling on or off
|
||||
bool autoScale() const { return autoscale_;} //!< actual Autoscaling mode
|
||||
|
||||
void setMajors(int val); //!< Requests major intervals (maybe changed, if autoscaling is present)
|
||||
void setMinors(int val); //!< Requests minor intervals
|
||||
int majors() const { return majorintervals_; } //!< Returns number of major intervals
|
||||
int minors() const { return minorintervals_; } //!< Returns number of minor intervals
|
||||
Qwt3D::TripleField const& majorPositions() const {return majorpos_;} //!< Returns positions for actual major tics (also if invisible)
|
||||
Qwt3D::TripleField const& minorPositions() const {return minorpos_;} //!< Returns positions for actual minor tics (also if invisible)
|
||||
|
||||
//! Sets line width for axis components
|
||||
void setLineWidth(double val, double majfac = 0.9, double minfac = 0.5);
|
||||
double lineWidth() const { return lineWidth_;} //!< Returns line width for axis body
|
||||
double majLineWidth() const { return majLineWidth_;} //!< Returns Line width for major tics
|
||||
double minLineWidth() const { return minLineWidth_;} //!< Returns Line width for minor tics
|
||||
|
||||
void setLimits(double start, double stop) {start_=start; stop_=stop;} //!< Sets interval
|
||||
void limits(double& start, double& stop) const {start = start_; stop = stop_;} //!< Returns axis interval
|
||||
void recalculateTics(); //!< Enforces recalculation of ticmark positions
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void init();
|
||||
void drawBase();
|
||||
void drawTics();
|
||||
void drawTicLabel(Qwt3D::Triple Pos, int mtic);
|
||||
Qwt3D::Triple drawTic(Qwt3D::Triple nadir, double length);
|
||||
void drawLabel();
|
||||
bool prepTicCalculation(Triple& startpoint);
|
||||
|
||||
Qwt3D::Triple biggestNumberString();
|
||||
|
||||
|
||||
Qwt3D::ANCHOR scaleNumberAnchor_;
|
||||
Qwt3D::Label label_;
|
||||
std::vector<Qwt3D::Label> markerLabel_;
|
||||
|
||||
Qwt3D::Triple beg_, end_;
|
||||
Qwt3D::TripleField majorpos_, minorpos_; //! vectors, holding major resp. minor tic positions;
|
||||
|
||||
Qwt3D::Triple ncube_beg_, ncube_end_; //!< enclosing parallelepiped for axis numbering
|
||||
|
||||
double start_, stop_, autostart_, autostop_;
|
||||
double lmaj_, lmin_;
|
||||
Qwt3D::Triple orientation_;
|
||||
|
||||
int majorintervals_, minorintervals_;
|
||||
|
||||
double lineWidth_, majLineWidth_, minLineWidth_;
|
||||
bool symtics_;
|
||||
bool drawNumbers_, drawTics_, drawLabel_;
|
||||
bool autoscale_;
|
||||
QFont numberfont_, labelfont_;
|
||||
Qwt3D::RGBA numbercolor_;
|
||||
|
||||
int numbergap_, labelgap_;
|
||||
|
||||
Qwt3D::qwt3d_ptr<Qwt3D::Scale> scale_;
|
||||
};
|
||||
|
||||
} // ns
|
||||
|
||||
#endif
|
@ -0,0 +1,63 @@
|
||||
#ifndef __COLORGENERATOR_H__
|
||||
#define __COLORGENERATOR_H__
|
||||
|
||||
#include <qstring.h>
|
||||
#include "qwt3d_global.h"
|
||||
#include "qwt3d_types.h"
|
||||
|
||||
namespace Qwt3D
|
||||
{
|
||||
|
||||
//! Abstract base class for color functors
|
||||
/*!
|
||||
Use your own color model by providing an implementation of operator()(double x, double y, double z).
|
||||
Colors destructor has been declared \c protected, in order to use only heap based objects. Plot3D
|
||||
will handle the objects destruction.
|
||||
See StandardColor for an example
|
||||
*/
|
||||
class QWT3D_EXPORT Color
|
||||
{
|
||||
public:
|
||||
virtual Qwt3D::RGBA operator()(double x, double y, double z) const = 0; //!< Implement your color model here
|
||||
virtual Qwt3D::RGBA operator()(Qwt3D::Triple const& t) const {return this->operator()(t.x,t.y,t.z);}
|
||||
//! Should create a color vector usable by ColorLegend. The default implementation returns his argument
|
||||
virtual Qwt3D::ColorVector& createVector(Qwt3D::ColorVector& vec) { return vec; }
|
||||
|
||||
void destroy() const { delete this;}
|
||||
|
||||
protected:
|
||||
virtual ~Color(){} //!< Allow heap based objects only
|
||||
};
|
||||
|
||||
|
||||
|
||||
class Plot3D;
|
||||
//! Standard color model for Plot3D - implements the data driven operator()(double x, double y, double z)
|
||||
/*!
|
||||
The class has a ColorVector representing z values, which will be used by operator()(double x, double y, double z)
|
||||
*/
|
||||
class QWT3D_EXPORT StandardColor : public Color
|
||||
{
|
||||
public:
|
||||
//! Initializes with data and set up a ColorVector with a size of 100 z values (default);
|
||||
explicit StandardColor(Qwt3D::Plot3D* data, unsigned size = 100);
|
||||
Qwt3D::RGBA operator()(double x, double y, double z) const; //!< Receives z-dependend color from ColorVector
|
||||
void setColorVector(Qwt3D::ColorVector const& cv);
|
||||
void reset(unsigned size=100); //!< Resets the standard colors;
|
||||
void setAlpha(double a); //!< Sets unitary alpha value for all colors
|
||||
/**
|
||||
\brief Creates color vector
|
||||
|
||||
Creates a color vector used by ColorLegend. This is essentially a copy from the internal used vector.
|
||||
\return The vector created
|
||||
*/
|
||||
Qwt3D::ColorVector& createVector(Qwt3D::ColorVector& vec) {vec = colors_; return vec;}
|
||||
|
||||
protected:
|
||||
Qwt3D::ColorVector colors_;
|
||||
Qwt3D::Plot3D* data_;
|
||||
};
|
||||
|
||||
} // ns
|
||||
|
||||
#endif
|
@ -0,0 +1,77 @@
|
||||
#ifndef __PLANE_H__
|
||||
#define __PLANE_H__
|
||||
|
||||
#include "qwt3d_global.h"
|
||||
#include "qwt3d_drawable.h"
|
||||
#include "qwt3d_axis.h"
|
||||
#include "qwt3d_color.h"
|
||||
|
||||
namespace Qwt3D
|
||||
{
|
||||
|
||||
//! A flat color legend
|
||||
/**
|
||||
The class visualizes a ColorVector together with a scale (axis) and a caption. ColorLegends are vertical
|
||||
or horizontal
|
||||
*/
|
||||
class QWT3D_EXPORT ColorLegend : public Drawable
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Possible anchor points for caption and axis
|
||||
enum SCALEPOSITION
|
||||
{
|
||||
Top, //!< scale on top
|
||||
Bottom, //!< scale on bottom
|
||||
Left, //!< scale left
|
||||
Right //!< scale right
|
||||
};
|
||||
|
||||
//! Orientation of the legend
|
||||
enum ORIENTATION
|
||||
{
|
||||
BottomTop, //!< Positionate the legend vertically, the lowest color index is on the bottom
|
||||
LeftRight //!< Positionate the legend horizontally, the lowest color index is on left side
|
||||
};
|
||||
|
||||
ColorLegend(); //!< Standard constructor
|
||||
|
||||
void draw(); //!< Draws the object. You should not use this explicitely - the function is called by updateGL().
|
||||
|
||||
void setRelPosition(Qwt3D::Tuple relMin, Qwt3D::Tuple relMax); //!< Sets the relative position of the legend inside widget
|
||||
void setOrientation(ORIENTATION, SCALEPOSITION); //!< Sets legend orientation and scale position
|
||||
void setLimits(double start, double stop); //!< Sets the limit of the scale.
|
||||
void setMajors(int); //!< Sets scale major tics.
|
||||
void setMinors(int); //!< Sets scale minor tics.
|
||||
void drawScale(bool val) { showaxis_ = val; } //!< Sets whether a scale will be drawn.
|
||||
void drawNumbers(bool val) { axis_.setNumbers(val); } //!< Sets whether the scale will have scale numbers.
|
||||
void setAutoScale(bool val); //!< Sets, whether the axis is autoscaled or not.
|
||||
void setScale(Qwt3D::Scale *scale); //!< Sets another scale
|
||||
void setScale(Qwt3D::SCALETYPE); //!< Sets one of the predefined scale types
|
||||
|
||||
void setTitleString(QString const& s); //!< Sets the legends caption string.
|
||||
|
||||
//! Sets the legends caption font.
|
||||
void setTitleFont(QString const& family, int pointSize, int weight = QFont::Normal, bool italic = false);
|
||||
|
||||
Qwt3D::ColorVector colors; //!< The color vector
|
||||
|
||||
private:
|
||||
|
||||
Qwt3D::Label caption_;
|
||||
Qwt3D::ParallelEpiped geometry() const { return pe_;}
|
||||
void setGeometryInternal();
|
||||
|
||||
Qwt3D::ParallelEpiped pe_;
|
||||
Qwt3D::Tuple relMin_, relMax_;
|
||||
Qwt3D::Axis axis_;
|
||||
SCALEPOSITION axisposition_;
|
||||
ORIENTATION orientation_;
|
||||
|
||||
bool showaxis_;
|
||||
};
|
||||
|
||||
} // ns
|
||||
|
||||
#endif
|
@ -0,0 +1,100 @@
|
||||
#ifndef __COORDSYS_H__
|
||||
#define __COORDSYS_H__
|
||||
|
||||
#include "qwt3d_axis.h"
|
||||
#include "qwt3d_colorlegend.h"
|
||||
|
||||
namespace Qwt3D
|
||||
{
|
||||
|
||||
//! A coordinate system with different styles (BOX, FRAME)
|
||||
class QWT3D_EXPORT CoordinateSystem : public Drawable
|
||||
{
|
||||
|
||||
public:
|
||||
explicit CoordinateSystem(Qwt3D::Triple blb = Qwt3D::Triple(0,0,0), Qwt3D::Triple ftr = Qwt3D::Triple(0,0,0), Qwt3D::COORDSTYLE = Qwt3D::BOX);
|
||||
~CoordinateSystem();
|
||||
|
||||
void init(Qwt3D::Triple beg = Qwt3D::Triple(0,0,0), Qwt3D::Triple end = Qwt3D::Triple(0,0,0));
|
||||
//! Set style for the coordinate system (NOCOORD, FRAME or BOX)
|
||||
void setStyle(Qwt3D::COORDSTYLE s, Qwt3D::AXIS frame_1 = Qwt3D::X1,
|
||||
Qwt3D::AXIS frame_2 = Qwt3D::Y1,
|
||||
Qwt3D::AXIS frame_3 = Qwt3D::Z1);
|
||||
Qwt3D::COORDSTYLE style() const { return style_;} //!< Return style oft the coordinate system
|
||||
void setPosition(Qwt3D::Triple first, Qwt3D::Triple second); //!< first == front_left_bottom, second == back_right_top
|
||||
|
||||
void setAxesColor(Qwt3D::RGBA val); //!< Set common color for all axes
|
||||
//! Set common font for all axis numberings
|
||||
void setNumberFont(QString const& family, int pointSize, int weight = QFont::Normal, bool italic = false);
|
||||
//! Set common font for all axis numberings
|
||||
void setNumberFont(QFont const& font);
|
||||
//! Set common color for all axis numberings
|
||||
void setNumberColor(Qwt3D::RGBA val);
|
||||
void setStandardScale(); //!< Sets an linear axis with real number items
|
||||
|
||||
void adjustNumbers(int val); //!< Fine tunes distance between axis numbering and axis body
|
||||
void adjustLabels(int val); //!< Fine tunes distance between axis label and axis body
|
||||
|
||||
//! Sets color for the grid lines
|
||||
void setGridLinesColor(Qwt3D::RGBA val) {gridlinecolor_ = val;}
|
||||
|
||||
//! Set common font for all axis labels
|
||||
void setLabelFont(QString const& family, int pointSize, int weight = QFont::Normal, bool italic = false);
|
||||
//! Set common font for all axis labels
|
||||
void setLabelFont(QFont const& font);
|
||||
//! Set common color for all axis labels
|
||||
void setLabelColor(Qwt3D::RGBA val);
|
||||
|
||||
//! Set line width for tic marks and axes
|
||||
void setLineWidth(double val, double majfac = 0.9, double minfac = 0.5);
|
||||
//! Set length for tic marks
|
||||
void setTicLength(double major, double minor);
|
||||
|
||||
//! Switch autoscaling of axes
|
||||
void setAutoScale(bool val = true);
|
||||
|
||||
Qwt3D::Triple first() const { return first_;}
|
||||
Qwt3D::Triple second() const { return second_;}
|
||||
|
||||
void setAutoDecoration(bool val = true) {autodecoration_ = val;}
|
||||
bool autoDecoration() const { return autodecoration_;}
|
||||
|
||||
void setLineSmooth(bool val = true) {smooth_ = val;} //!< draw smooth axes
|
||||
bool lineSmooth() const {return smooth_;} //!< smooth axes ?
|
||||
|
||||
void draw();
|
||||
|
||||
//! Defines whether a grid between the major and/or minor tics should be drawn
|
||||
void setGridLines(bool majors, bool minors, int sides = Qwt3D::NOSIDEGRID);
|
||||
int grids() const {return sides_;} //!< Returns grids switched on
|
||||
|
||||
//! The vector of all12 axes - use them to set axis properties individually.
|
||||
std::vector<Axis> axes;
|
||||
|
||||
|
||||
private:
|
||||
void destroy();
|
||||
|
||||
Qwt3D::Triple first_, second_;
|
||||
Qwt3D::COORDSTYLE style_;
|
||||
|
||||
Qwt3D::RGBA gridlinecolor_;
|
||||
|
||||
bool smooth_;
|
||||
|
||||
void chooseAxes();
|
||||
void autoDecorateExposedAxis(Axis& ax, bool left);
|
||||
void drawMajorGridLines(); //!< Draws a grid between the major tics on the site
|
||||
void drawMinorGridLines(); //!< Draws a grid between the minor tics on the site
|
||||
void drawMajorGridLines(Qwt3D::Axis&, Qwt3D::Axis&); //! Helper
|
||||
void drawMinorGridLines(Qwt3D::Axis&, Qwt3D::Axis&); //! Helper
|
||||
void recalculateAxesTics();
|
||||
|
||||
bool autodecoration_;
|
||||
bool majorgridlines_, minorgridlines_;
|
||||
int sides_;
|
||||
};
|
||||
|
||||
} // ns
|
||||
|
||||
#endif
|
@ -0,0 +1,66 @@
|
||||
#ifndef __DRAWABLE_H__
|
||||
#define __DRAWABLE_H__
|
||||
|
||||
|
||||
#include <list>
|
||||
#include "qwt3d_global.h"
|
||||
#include "qwt3d_types.h"
|
||||
#include "qwt3d_io_gl2ps.h"
|
||||
|
||||
namespace Qwt3D
|
||||
{
|
||||
|
||||
//! ABC for Drawables
|
||||
class QWT3D_EXPORT Drawable
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
virtual ~Drawable() = 0;
|
||||
|
||||
virtual void draw();
|
||||
|
||||
virtual void saveGLState();
|
||||
virtual void restoreGLState();
|
||||
|
||||
void attach(Drawable*);
|
||||
void detach(Drawable*);
|
||||
void detachAll();
|
||||
|
||||
virtual void setColor(double r, double g, double b, double a = 1);
|
||||
virtual void setColor(Qwt3D::RGBA rgba);
|
||||
Qwt3D::Triple relativePosition(Qwt3D::Triple rel);
|
||||
|
||||
protected:
|
||||
|
||||
Qwt3D::RGBA color;
|
||||
void Enable(GLenum what, GLboolean val);
|
||||
Qwt3D::Triple ViewPort2World(Qwt3D::Triple win, bool* err = 0);
|
||||
Qwt3D::Triple World2ViewPort(Qwt3D::Triple obj, bool* err = 0);
|
||||
|
||||
GLdouble modelMatrix[16];
|
||||
GLdouble projMatrix[16];
|
||||
GLint viewport[4];
|
||||
|
||||
|
||||
private:
|
||||
|
||||
GLboolean ls;
|
||||
GLboolean pols;
|
||||
GLint polmode[2];
|
||||
GLfloat lw;
|
||||
GLint blsrc, bldst;
|
||||
GLdouble col[4];
|
||||
GLint pattern, factor;
|
||||
GLboolean sallowed;
|
||||
GLboolean tex2d;
|
||||
GLint matrixmode;
|
||||
GLfloat poloffs[2];
|
||||
GLboolean poloffsfill;
|
||||
|
||||
std::list<Drawable*> dlist;
|
||||
};
|
||||
|
||||
} // ns
|
||||
|
||||
#endif
|
@ -0,0 +1,62 @@
|
||||
#ifndef qwt3d_enrichment_h__2004_02_23_19_24_begin_guarded_code
|
||||
#define qwt3d_enrichment_h__2004_02_23_19_24_begin_guarded_code
|
||||
|
||||
#include "qwt3d_global.h"
|
||||
#include "qwt3d_types.h"
|
||||
|
||||
namespace Qwt3D
|
||||
{
|
||||
|
||||
class Plot3D;
|
||||
|
||||
|
||||
//! Abstract base class for data dependent visible user objects
|
||||
/**
|
||||
Enrichments provide a framework for user defined OPenGL objects. The base class has a pure virtuell
|
||||
function clone(). 2 additional functions are per default empty and could also get a new implementation
|
||||
in derived classes. They can be used for initialization issues or actions not depending on the related
|
||||
primitive.
|
||||
*/
|
||||
class QWT3D_EXPORT Enrichment
|
||||
{
|
||||
public:
|
||||
enum TYPE{
|
||||
VERTEXENRICHMENT,
|
||||
EDGEENRICHMENT,
|
||||
FACEENRICHMENT,
|
||||
VOXELENRICHMENT
|
||||
}; //!< Type of the Enrichment - only VERTEXENRICHMENT's are defined at this moment.
|
||||
|
||||
Enrichment() : plot(0) {}
|
||||
virtual ~Enrichment(){}
|
||||
virtual Enrichment* clone() const = 0; //!< The derived class should give back a new Derived(something) here
|
||||
virtual void drawBegin(){}; //!< Empty per default. Can be overwritten.
|
||||
virtual void drawEnd(){}; //!< Empty per default. Can be overwritten.
|
||||
virtual void assign(Plot3D const& pl) {plot = &pl;} //!< Assign to existent plot;
|
||||
virtual TYPE type() const = 0; //!< Overwrite
|
||||
|
||||
protected:
|
||||
const Plot3D* plot;
|
||||
};
|
||||
|
||||
//! Abstract base class for vertex dependent visible user objects
|
||||
/**
|
||||
VertexEnrichments introduce a specialized draw routine for vertex dependent data.
|
||||
draw() is called, when the Plot realizes its internal OpenGL data representation
|
||||
for every Vertex associated to his argument.
|
||||
*/
|
||||
class QWT3D_EXPORT VertexEnrichment : public Enrichment
|
||||
{
|
||||
public:
|
||||
|
||||
VertexEnrichment() : Qwt3D::Enrichment() {}
|
||||
virtual Enrichment* clone() const = 0; //!< The derived class should give back a new Derived(something) here
|
||||
virtual void draw(Qwt3D::Triple const&) = 0; //!< Overwrite this
|
||||
virtual TYPE type() const {return Qwt3D::Enrichment::VERTEXENRICHMENT;} //!< This gives VERTEXENRICHMENT
|
||||
};
|
||||
|
||||
// todo EdgeEnrichment, FaceEnrichment, VoxelEnrichment etc.
|
||||
|
||||
} // ns
|
||||
|
||||
#endif
|
@ -0,0 +1,116 @@
|
||||
#ifndef qwt3d_enrichment_std_h__2004_02_23_19_25_begin_guarded_code
|
||||
#define qwt3d_enrichment_std_h__2004_02_23_19_25_begin_guarded_code
|
||||
|
||||
#include "qwt3d_enrichment.h"
|
||||
|
||||
namespace Qwt3D
|
||||
{
|
||||
|
||||
class Plot3D;
|
||||
|
||||
//! The Cross Hair Style
|
||||
class QWT3D_EXPORT CrossHair : public VertexEnrichment
|
||||
{
|
||||
public:
|
||||
CrossHair();
|
||||
CrossHair(double rad, double linewidth, bool smooth, bool boxed);
|
||||
|
||||
Qwt3D::Enrichment* clone() const {return new CrossHair(*this);}
|
||||
|
||||
void configure(double rad, double linewidth, bool smooth, bool boxed);
|
||||
void drawBegin();
|
||||
void drawEnd();
|
||||
void draw(Qwt3D::Triple const&);
|
||||
|
||||
private:
|
||||
bool boxed_, smooth_;
|
||||
double linewidth_, radius_;
|
||||
GLboolean oldstate_;
|
||||
};
|
||||
|
||||
//! The Point Style
|
||||
class QWT3D_EXPORT Dot : public VertexEnrichment
|
||||
{
|
||||
public:
|
||||
Dot();
|
||||
Dot(double pointsize, bool smooth);
|
||||
|
||||
Qwt3D::Enrichment* clone() const {return new Dot(*this);}
|
||||
|
||||
void configure(double pointsize, bool smooth);
|
||||
void drawBegin();
|
||||
void drawEnd();
|
||||
void draw(Qwt3D::Triple const&);
|
||||
|
||||
private:
|
||||
bool smooth_;
|
||||
double pointsize_;
|
||||
GLboolean oldstate_;
|
||||
};
|
||||
|
||||
//! The Cone Style
|
||||
class QWT3D_EXPORT Cone : public VertexEnrichment
|
||||
{
|
||||
public:
|
||||
Cone();
|
||||
Cone(double rad, unsigned quality);
|
||||
~Cone();
|
||||
|
||||
Qwt3D::Enrichment* clone() const {return new Cone(*this);}
|
||||
|
||||
void configure(double rad, unsigned quality);
|
||||
void draw(Qwt3D::Triple const&);
|
||||
|
||||
private:
|
||||
GLUquadricObj *hat;
|
||||
GLUquadricObj *disk;
|
||||
unsigned quality_;
|
||||
double radius_;
|
||||
GLboolean oldstate_;
|
||||
};
|
||||
|
||||
//! 3D vector field.
|
||||
/**
|
||||
The class encapsulates a vector field including his OpenGL representation as arrow field.
|
||||
The arrows can be configured in different aspects (color, shape, painting quality).
|
||||
|
||||
*/
|
||||
class QWT3D_EXPORT Arrow : public VertexEnrichment
|
||||
{
|
||||
public:
|
||||
|
||||
Arrow();
|
||||
~Arrow();
|
||||
|
||||
Qwt3D::Enrichment* clone() const {return new Arrow(*this);}
|
||||
|
||||
void configure(int segs, double relconelength, double relconerad, double relstemrad);
|
||||
void setQuality(int val) {segments_ = val;} //!< Set the number of faces for the arrow
|
||||
void draw(Qwt3D::Triple const&);
|
||||
|
||||
void setTop(Qwt3D::Triple t){top_ = t;}
|
||||
void setColor(Qwt3D::RGBA rgba) {rgba_ = rgba;}
|
||||
|
||||
private:
|
||||
|
||||
GLUquadricObj *hat;
|
||||
GLUquadricObj *disk;
|
||||
GLUquadricObj *base;
|
||||
GLUquadricObj *bottom;
|
||||
GLboolean oldstate_;
|
||||
|
||||
double calcRotation(Qwt3D::Triple& axis, Qwt3D::FreeVector const& vec);
|
||||
|
||||
int segments_;
|
||||
double rel_cone_length;
|
||||
|
||||
double rel_cone_radius;
|
||||
double rel_stem_radius;
|
||||
|
||||
Qwt3D::Triple top_;
|
||||
Qwt3D::RGBA rgba_;
|
||||
};
|
||||
|
||||
} // ns
|
||||
|
||||
#endif
|
@ -0,0 +1,41 @@
|
||||
#ifndef qwt3d_function_h__2004_03_05_13_51_begin_guarded_code
|
||||
#define qwt3d_function_h__2004_03_05_13_51_begin_guarded_code
|
||||
|
||||
#include "qwt3d_gridmapping.h"
|
||||
|
||||
namespace Qwt3D
|
||||
{
|
||||
|
||||
class SurfacePlot;
|
||||
|
||||
//! Abstract base class for mathematical functions
|
||||
/**
|
||||
A Function encapsulates a mathematical function with rectangular domain. The user has to adapt the pure virtual operator()
|
||||
to get a working object. Also, the client code should call setDomain, setMesh and create for reasonable operating conditions.
|
||||
*/
|
||||
class QWT3D_EXPORT Function : public GridMapping
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
Function(); //!< Constructs Function object w/o assigned SurfacePlot.
|
||||
explicit Function(Qwt3D::SurfacePlot& plotWidget); //!< Constructs Function object and assigns a SurfacePlot
|
||||
explicit Function(Qwt3D::SurfacePlot* plotWidget); //!< Constructs Function object and assigns a SurfacePlot
|
||||
virtual double operator()(double x, double y) = 0; //!< Overwrite this.
|
||||
|
||||
void setMinZ(double val); //!< Sets minimal z value.
|
||||
void setMaxZ(double val); //!< Sets maximal z value.
|
||||
|
||||
//! Assigns a new SurfacePlot and creates a data representation for it.
|
||||
virtual bool create(Qwt3D::SurfacePlot& plotWidget);
|
||||
//! Creates data representation for the actual assigned SurfacePlot.
|
||||
virtual bool create();
|
||||
//! Assigns the object to another widget. To see the changes, you have to call this function before create().
|
||||
void assign(Qwt3D::SurfacePlot& plotWidget);
|
||||
//! Assigns the object to another widget. To see the changes, you have to call this function before create().
|
||||
void assign(Qwt3D::SurfacePlot* plotWidget);
|
||||
};
|
||||
|
||||
} // ns
|
||||
|
||||
#endif /* include guarded */
|
@ -0,0 +1,58 @@
|
||||
#ifndef QWT3D_GLOBAL_H
|
||||
#define QWT3D_GLOBAL_H
|
||||
|
||||
#include <qglobal.h>
|
||||
#if QT_VERSION < 0x040000
|
||||
#include <qmodules.h>
|
||||
#endif
|
||||
|
||||
#define QWT3D_MAJOR_VERSION 0
|
||||
#define QWT3D_MINOR_VERSION 2
|
||||
#define QWT3D_PATCH_VERSION 6
|
||||
|
||||
//
|
||||
// Create Qwt3d DLL if QWT3D_DLL is defined (Windows only)
|
||||
//
|
||||
|
||||
#if defined(Q_WS_WIN)
|
||||
#if defined(_MSC_VER) /* MSVC Compiler */
|
||||
#pragma warning(disable: 4251) // dll interface required for stl templates
|
||||
//pragma warning(disable: 4244) // 'conversion' conversion from 'type1' to 'type2', possible loss of data
|
||||
#pragma warning(disable: 4786) // truncating debug info after 255 characters
|
||||
#pragma warning(disable: 4660) // template-class specialization 'identifier' is already instantiated
|
||||
#if (_MSC_VER >= 1400) /* VS8 - not sure about VC7 */
|
||||
#pragma warning(disable: 4996) /* MS security enhancements */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(QWT3D_NODLL)
|
||||
#undef QWT3D_MAKEDLL
|
||||
#undef QWT3D_DLL
|
||||
#undef QWT3D_TEMPLATEDLL
|
||||
#endif
|
||||
|
||||
#ifdef QWT3D_DLL
|
||||
#if defined(QWT3D_MAKEDLL) /* create a Qwt3d DLL library */
|
||||
#undef QWT3D_DLL
|
||||
#define QWT3D_EXPORT __declspec(dllexport)
|
||||
#define QWT3D_TEMPLATEDLL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(QWT3D_DLL) /* use a Qwt3d DLL library */
|
||||
#define QWT3D_EXPORT __declspec(dllimport)
|
||||
#define QWT3D_TEMPLATEDLL
|
||||
#endif
|
||||
|
||||
#else // ! Q_WS_WIN
|
||||
#undef QWT3D_MAKEDLL /* ignore these for other platforms */
|
||||
#undef QWT3D_DLL
|
||||
#undef QWT3D_TEMPLATEDLL
|
||||
#endif
|
||||
|
||||
#ifndef QWT3D_EXPORT
|
||||
#define QWT3D_EXPORT
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
@ -0,0 +1,24 @@
|
||||
#ifndef qwt3d_graphplot_h__2004_03_06_01_57_begin_guarded_code
|
||||
#define qwt3d_graphplot_h__2004_03_06_01_57_begin_guarded_code
|
||||
|
||||
#include "qwt3d_plot.h"
|
||||
|
||||
namespace Qwt3D
|
||||
{
|
||||
|
||||
//! TODO
|
||||
class QWT3D_EXPORT GraphPlot : public Plot3D
|
||||
{
|
||||
// Q_OBJECT
|
||||
|
||||
public:
|
||||
GraphPlot( QWidget* parent = 0, const char* name = 0 );
|
||||
|
||||
protected:
|
||||
virtual void createData() = 0;
|
||||
};
|
||||
|
||||
} // ns
|
||||
|
||||
|
||||
#endif
|
@ -0,0 +1,34 @@
|
||||
#ifndef qwt3d_gridmapping_h__2004_03_06_12_31_begin_guarded_code
|
||||
#define qwt3d_gridmapping_h__2004_03_06_12_31_begin_guarded_code
|
||||
|
||||
#include "qwt3d_mapping.h"
|
||||
|
||||
namespace Qwt3D
|
||||
{
|
||||
|
||||
class SurfacePlot;
|
||||
|
||||
|
||||
//! Abstract base class for mappings acting on rectangular grids
|
||||
/**
|
||||
|
||||
*/
|
||||
class QWT3D_EXPORT GridMapping : public Mapping
|
||||
{
|
||||
public:
|
||||
GridMapping(); //!< Constructs GridMapping object w/o assigned SurfacePlot.
|
||||
|
||||
void setMesh(unsigned int columns, unsigned int rows); //!< Sets number of rows and columns.
|
||||
void setDomain(double minu, double maxu, double minv, double maxv); //!< Sets u-v domain boundaries.
|
||||
void restrictRange(Qwt3D::ParallelEpiped const&); //!< Restrict the mappings range to the parallelepiped
|
||||
|
||||
protected:
|
||||
Qwt3D::ParallelEpiped range_p;
|
||||
Qwt3D::SurfacePlot* plotwidget_p;
|
||||
unsigned int umesh_p, vmesh_p;
|
||||
double minu_p, maxu_p, minv_p, maxv_p;
|
||||
};
|
||||
|
||||
} // ns
|
||||
|
||||
#endif /* include guarded */
|
@ -0,0 +1,36 @@
|
||||
#ifndef __HELPER_H__
|
||||
#define __HELPER_H__
|
||||
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
namespace
|
||||
{
|
||||
inline double Min_(double a, double b)
|
||||
{
|
||||
return (a<b) ? a : b;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Qwt3D
|
||||
{
|
||||
|
||||
inline bool isPracticallyZero(double a, double b = 0)
|
||||
{
|
||||
if (!b)
|
||||
return (fabs (a) <= DBL_MIN);
|
||||
|
||||
return (fabs (a - b) <= Min_(fabs(a), fabs(b))*DBL_EPSILON);
|
||||
}
|
||||
|
||||
inline int round(double d)
|
||||
{
|
||||
return (d>0) ? int(d+0.5) : int(d-0.5);
|
||||
}
|
||||
|
||||
|
||||
} //ns
|
||||
|
||||
#endif
|
@ -0,0 +1,141 @@
|
||||
#ifndef __qwt3d_io_2003_07_04_23_27__
|
||||
#define __qwt3d_io_2003_07_04_23_27__
|
||||
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#include <qstring.h>
|
||||
#include <qstringlist.h>
|
||||
#include "qwt3d_global.h"
|
||||
|
||||
namespace Qwt3D
|
||||
{
|
||||
|
||||
class Plot3D;
|
||||
/**
|
||||
IO provides a generic interface for standard and user written I/O handlers.
|
||||
It also provides functionality for the registering of such handlers in the
|
||||
framework.\n
|
||||
The interface mimics roughly Qt's QImageIO functions for defining
|
||||
image input/output functions.
|
||||
*/
|
||||
class QWT3D_EXPORT IO
|
||||
{
|
||||
|
||||
public:
|
||||
/*!
|
||||
The function type that can be processed by the define... members.
|
||||
An extension is the IO::Functor.
|
||||
*/
|
||||
typedef bool (*Function)(Plot3D*, QString const& fname);
|
||||
|
||||
|
||||
/*!
|
||||
This class gives more flexibility in implementing
|
||||
userdefined IO handlers than the simple IO::Function type.
|
||||
*/
|
||||
class Functor
|
||||
{
|
||||
public:
|
||||
virtual ~Functor() {}
|
||||
/*! Must clone the content of *this for an object of a derived class with
|
||||
\c new and return the pointer. Like operator() the predefined Functors
|
||||
hide this function from the user, still allowing IO access
|
||||
(friend declaration)
|
||||
*/
|
||||
virtual Functor* clone() const = 0;
|
||||
/*! The workhorse of the user-defined implementation. Eventually, the
|
||||
framework will call this operator.
|
||||
*/
|
||||
virtual bool operator()(Plot3D* plot, QString const& fname) = 0;
|
||||
};
|
||||
|
||||
static bool defineInputHandler( QString const& format, Function func);
|
||||
static bool defineOutputHandler( QString const& format, Function func);
|
||||
static bool defineInputHandler( QString const& format, Functor const& func);
|
||||
static bool defineOutputHandler( QString const& format, Functor const& func);
|
||||
static bool save(Plot3D*, QString const& fname, QString const& format);
|
||||
static bool load(Plot3D*, QString const& fname, QString const& format);
|
||||
static QStringList inputFormatList();
|
||||
static QStringList outputFormatList();
|
||||
static Functor* outputHandler(QString const& format);
|
||||
static Functor* inputHandler(QString const& format);
|
||||
|
||||
private:
|
||||
IO(){}
|
||||
|
||||
//! Lightweight Functor encapsulating an IO::Function
|
||||
class Wrapper : public Functor
|
||||
{
|
||||
public:
|
||||
//! Performs actual input
|
||||
Functor* clone() const { return new Wrapper(*this); }
|
||||
//! Creates a Wrapper object from a function pointer
|
||||
explicit Wrapper(Function h) : hdl(h) {}
|
||||
//! Returns a pointer to the wrapped function
|
||||
bool operator()(Plot3D* plot, QString const& fname)
|
||||
{
|
||||
return (hdl) ? (*hdl)(plot, fname) : false;
|
||||
}
|
||||
private:
|
||||
Function hdl;
|
||||
};
|
||||
|
||||
struct Entry
|
||||
{
|
||||
Entry();
|
||||
~Entry();
|
||||
|
||||
Entry(Entry const& e);
|
||||
void operator=(Entry const& e);
|
||||
|
||||
Entry(QString const& s, Functor const& f);
|
||||
Entry(QString const& s, Function f);
|
||||
|
||||
QString fmt;
|
||||
Functor* iofunc;
|
||||
};
|
||||
|
||||
struct FormatCompare
|
||||
{
|
||||
explicit FormatCompare(Entry const& e);
|
||||
bool operator() (Entry const& e);
|
||||
|
||||
Entry e_;
|
||||
};
|
||||
|
||||
struct FormatCompare2
|
||||
{
|
||||
explicit FormatCompare2(QString s);
|
||||
bool operator() (Entry const& e);
|
||||
|
||||
QString s_;
|
||||
};
|
||||
|
||||
typedef std::vector<Entry> Container;
|
||||
typedef Container::iterator IT;
|
||||
|
||||
static bool add_unique(Container& l, Entry const& e);
|
||||
static IT find(Container& l, QString const& fmt);
|
||||
static Container& rlist();
|
||||
static Container& wlist();
|
||||
static void setupHandler();
|
||||
};
|
||||
|
||||
//! Provides Qt's Pixmap output facilities
|
||||
class QWT3D_EXPORT PixmapWriter : public IO::Functor
|
||||
{
|
||||
friend class IO;
|
||||
public:
|
||||
PixmapWriter() : quality_(-1) {}
|
||||
void setQuality(int val);
|
||||
private:
|
||||
IO::Functor* clone() const {return new PixmapWriter(*this);}
|
||||
bool operator()(Plot3D* plot, QString const& fname);
|
||||
QString fmt_;
|
||||
int quality_;
|
||||
};
|
||||
|
||||
} //ns
|
||||
|
||||
#endif
|
@ -0,0 +1,91 @@
|
||||
#ifndef qwt3d_io_gl2ps_h__2004_05_07_01_16_begin_guarded_code
|
||||
#define qwt3d_io_gl2ps_h__2004_05_07_01_16_begin_guarded_code
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#if QT_VERSION < 0x040000
|
||||
#include <qgl.h>
|
||||
#else
|
||||
#include <QtOpenGL/qgl.h>
|
||||
#endif
|
||||
|
||||
#include "qwt3d_types.h"
|
||||
#include "qwt3d_io.h"
|
||||
|
||||
namespace Qwt3D
|
||||
{
|
||||
|
||||
//! Provides EPS, PS, PDF and TeX output
|
||||
/*!
|
||||
|
||||
*/
|
||||
class QWT3D_EXPORT VectorWriter : public IO::Functor
|
||||
{
|
||||
friend class IO;
|
||||
|
||||
public:
|
||||
//! The possible output formats for the text parts of the scene
|
||||
enum TEXTMODE
|
||||
{
|
||||
PIXEL, //!< All text will be converted to pixmaps
|
||||
NATIVE, //!< Text output in the native output format
|
||||
TEX //!< Text output in additional LaTeX file as an overlay
|
||||
};
|
||||
//! The possible behaviour for landscape settings
|
||||
enum LANDSCAPEMODE
|
||||
{
|
||||
ON, //!< Landscape mode on
|
||||
OFF, //!< Landscape mode off
|
||||
AUTO //!< The output orientation depends on the plot widgets aspect ratio (default)
|
||||
};
|
||||
|
||||
//! The possible sorting types which are translated in gl2ps types
|
||||
enum SORTMODE
|
||||
{
|
||||
NOSORT, //!< No sorting at all
|
||||
SIMPLESORT, //!< A more simple (yet quicker) algorithm (default)
|
||||
BSPSORT //!< BSP SORT (best and slow!)
|
||||
};
|
||||
|
||||
VectorWriter();
|
||||
|
||||
void setLandscape(LANDSCAPEMODE val) {landscape_ = val;} //!< Sets landscape mode.
|
||||
LANDSCAPEMODE landscape() const {return landscape_;} //!< Returns the current landscape mode
|
||||
|
||||
void setTextMode(TEXTMODE val, QString fname = "");
|
||||
TEXTMODE textMode() const {return textmode_;} //!< Return current text output mode.
|
||||
|
||||
|
||||
//! Sets one of the SORTMODE sorting modes.
|
||||
void setSortMode(SORTMODE val) {sortmode_ = val;}
|
||||
SORTMODE sortMode() const {return sortmode_;} //!< Returns gl2ps sorting type.
|
||||
//! Turns compressed output on or off (no effect if zlib support is not available)
|
||||
void setCompressed(bool val);
|
||||
//! Returns compression mode (always false if zlib support has not been set)
|
||||
bool compressed() const {return compressed_;}
|
||||
|
||||
bool setFormat(QString const& format);
|
||||
|
||||
private:
|
||||
IO::Functor* clone() const;
|
||||
bool operator()(Plot3D* plot, QString const& fname);
|
||||
|
||||
GLint gl2ps_format_;
|
||||
bool formaterror_;
|
||||
bool compressed_;
|
||||
SORTMODE sortmode_;
|
||||
LANDSCAPEMODE landscape_;
|
||||
TEXTMODE textmode_;
|
||||
QString texfname_;
|
||||
};
|
||||
|
||||
GLint setDeviceLineWidth(GLfloat val);
|
||||
GLint setDevicePointSize(GLfloat val);
|
||||
GLint drawDevicePixels(GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);
|
||||
GLint drawDeviceText(const char* str, const char* fontname, int fontsize, Qwt3D::Triple pos, Qwt3D::RGBA rgba, Qwt3D::ANCHOR align, double gap);
|
||||
void setDevicePolygonOffset(GLfloat factor, GLfloat units);
|
||||
|
||||
|
||||
} // ns
|
||||
|
||||
#endif /* include guarded */
|
@ -0,0 +1,35 @@
|
||||
#ifndef qwt3d_reader_h__2004_03_07_14_03_begin_guarded_code
|
||||
#define qwt3d_reader_h__2004_03_07_14_03_begin_guarded_code
|
||||
|
||||
#include "qwt3d_io.h"
|
||||
|
||||
namespace Qwt3D
|
||||
{
|
||||
|
||||
/*!
|
||||
Functor for reading of native files containing grid data.
|
||||
As a standart input functor associated with "mes" and "MES"
|
||||
file extensions.
|
||||
*/
|
||||
class QWT3D_EXPORT NativeReader : public IO::Functor
|
||||
{
|
||||
friend class IO;
|
||||
|
||||
public:
|
||||
NativeReader();
|
||||
|
||||
private:
|
||||
//! Provides new NativeReader object.
|
||||
IO::Functor* clone() const{return new NativeReader(*this);}
|
||||
//! Performs actual input
|
||||
bool operator()(Plot3D* plot, QString const& fname);
|
||||
static const char* magicstring;
|
||||
double minz_, maxz_;
|
||||
bool collectInfo(FILE*& file, QString const& fname, unsigned& xmesh, unsigned& ymesh,
|
||||
double& minx, double& maxx, double& miny, double& maxy);
|
||||
};
|
||||
|
||||
|
||||
} // ns
|
||||
|
||||
#endif
|
@ -0,0 +1,80 @@
|
||||
#ifndef __LABELPIXMAP_H__
|
||||
#define __LABELPIXMAP_H__
|
||||
|
||||
#include <qpixmap.h>
|
||||
#include <qimage.h>
|
||||
#include <qfont.h>
|
||||
#include <qpainter.h>
|
||||
#include <qfontmetrics.h>
|
||||
|
||||
#include "qwt3d_drawable.h"
|
||||
|
||||
namespace Qwt3D
|
||||
{
|
||||
|
||||
//! A Qt string or an output device dependent string
|
||||
class QWT3D_EXPORT Label : public Drawable
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
Label();
|
||||
//! Construct label and initialize with font
|
||||
Label(const QString & family, int pointSize, int weight = QFont::Normal, bool italic = false);
|
||||
|
||||
//! Sets the labels font
|
||||
void setFont(QString const& family, int pointSize, int weight = QFont::Normal, bool italic = false);
|
||||
|
||||
void adjust(int gap); //!< Fine tunes label;
|
||||
double gap() const {return gap_;} //!< Returns the gap caused by adjust();
|
||||
void setPosition(Qwt3D::Triple pos, ANCHOR a = BottomLeft); //!< Sets the labels position
|
||||
void setRelPosition(Tuple rpos, ANCHOR a); //!< Sets the labels position relative to screen
|
||||
Qwt3D::Triple first() const { return beg_;} //!< Receives bottom left label position
|
||||
Qwt3D::Triple second() const { return end_;} //!< Receives top right label position
|
||||
ANCHOR anchor() const { return anchor_; } //!< Defines an anchor point for the labels surrounding rectangle
|
||||
virtual void setColor(double r, double g, double b, double a = 1);
|
||||
virtual void setColor(Qwt3D::RGBA rgba);
|
||||
|
||||
/*!
|
||||
\brief Sets the labels string
|
||||
For unicode labeling (<tt> QChar(0x3c0) </tt> etc.) please look at <a href="http://www.unicode.org/charts/">www.unicode.org</a>.
|
||||
*/
|
||||
void setString(QString const& s);
|
||||
void draw(); //!< Actual drawing
|
||||
|
||||
/**
|
||||
\brief Decides about use of PDF standard fonts for PDF output
|
||||
If true, Label can use one of the PDF standard fonts (unprecise positioning for now),
|
||||
otherwise it dumps pixmaps in the PDF stream (poor quality)
|
||||
*/
|
||||
static void useDeviceFonts(bool val);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Qwt3D::Triple beg_, end_, pos_;
|
||||
QPixmap pm_;
|
||||
QImage buf_, tex_;
|
||||
QFont font_;
|
||||
QString text_;
|
||||
|
||||
ANCHOR anchor_;
|
||||
|
||||
void init();
|
||||
void init(const QString & family, int pointSize, int weight = QFont::Normal, bool italic = false);
|
||||
void update(); //!< Enforces an update of the internal pixmap
|
||||
void convert2screen();
|
||||
double width() const;
|
||||
double height() const;
|
||||
|
||||
int gap_;
|
||||
|
||||
bool flagforupdate_;
|
||||
|
||||
static bool devicefonts_;
|
||||
|
||||
};
|
||||
|
||||
} // ns
|
||||
|
||||
#endif
|
@ -0,0 +1,27 @@
|
||||
#ifndef qwt3d_mapping_h__2004_03_05_13_51_begin_guarded_code
|
||||
#define qwt3d_mapping_h__2004_03_05_13_51_begin_guarded_code
|
||||
|
||||
#include <qstring.h>
|
||||
#include "qwt3d_global.h"
|
||||
#include "qwt3d_types.h"
|
||||
|
||||
namespace Qwt3D
|
||||
{
|
||||
|
||||
//! Abstract base class for general mappings
|
||||
/**
|
||||
|
||||
*/
|
||||
class QWT3D_EXPORT Mapping
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
virtual ~Mapping(){} //!< Destructor.
|
||||
virtual QString name() const { return QString(""); } //!< Descriptive String.
|
||||
};
|
||||
|
||||
|
||||
} // ns
|
||||
|
||||
#endif /* include guarded */
|
@ -0,0 +1,24 @@
|
||||
#ifndef qwt3d_multiplot_h__2004_03_06_02_05_begin_guarded_code
|
||||
#define qwt3d_multiplot_h__2004_03_06_02_05_begin_guarded_code
|
||||
|
||||
#include "qwt3d_plot.h"
|
||||
|
||||
namespace Qwt3D
|
||||
{
|
||||
|
||||
//! TODO
|
||||
class QWT3D_EXPORT MultiPlot : public Plot3D
|
||||
{
|
||||
// Q_OBJECT
|
||||
|
||||
public:
|
||||
MultiPlot( QWidget* parent = 0, const char* name = 0 ){}
|
||||
|
||||
protected:
|
||||
virtual void createData() = 0;
|
||||
};
|
||||
|
||||
} // ns
|
||||
|
||||
|
||||
#endif
|
@ -0,0 +1,130 @@
|
||||
#ifndef __openglhelper_2003_06_06_15_49__
|
||||
#define __openglhelper_2003_06_06_15_49__
|
||||
|
||||
#include "qglobal.h"
|
||||
#if QT_VERSION < 0x040000
|
||||
#include <qgl.h>
|
||||
#else
|
||||
#include <QtOpenGL/qgl.h>
|
||||
#endif
|
||||
|
||||
namespace Qwt3D
|
||||
{
|
||||
|
||||
#ifndef QWT3D_NOT_FOR_DOXYGEN
|
||||
|
||||
class GLStateBewarer
|
||||
{
|
||||
public:
|
||||
|
||||
GLStateBewarer(GLenum what, bool on, bool persist=false)
|
||||
{
|
||||
state_ = what;
|
||||
stateval_ = glIsEnabled(what);
|
||||
if (on)
|
||||
turnOn(persist);
|
||||
else
|
||||
turnOff(persist);
|
||||
}
|
||||
|
||||
~GLStateBewarer()
|
||||
{
|
||||
if (stateval_)
|
||||
glEnable(state_);
|
||||
else
|
||||
glDisable(state_);
|
||||
}
|
||||
|
||||
void turnOn(bool persist = false)
|
||||
{
|
||||
glEnable(state_);
|
||||
if (persist)
|
||||
stateval_ = true;
|
||||
}
|
||||
|
||||
void turnOff(bool persist = false)
|
||||
{
|
||||
glDisable(state_);
|
||||
if (persist)
|
||||
stateval_ = false;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
GLenum state_;
|
||||
bool stateval_;
|
||||
|
||||
};
|
||||
|
||||
inline const GLubyte* gl_error()
|
||||
{
|
||||
GLenum errcode;
|
||||
const GLubyte* err = 0;
|
||||
|
||||
if ((errcode = glGetError()) != GL_NO_ERROR)
|
||||
{
|
||||
err = gluErrorString(errcode);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
inline void SaveGlDeleteLists(GLuint& lstidx, GLsizei range)
|
||||
{
|
||||
if (glIsList(lstidx))
|
||||
glDeleteLists(lstidx, range);
|
||||
lstidx = 0;
|
||||
}
|
||||
|
||||
//! get OpenGL transformation matrices
|
||||
/**
|
||||
Don't rely on (use) this in display lists !
|
||||
\param modelMatrix should be a GLdouble[16]
|
||||
\param projMatrix should be a GLdouble[16]
|
||||
\param viewport should be a GLint[4]
|
||||
*/
|
||||
inline void getMatrices(GLdouble* modelMatrix, GLdouble* projMatrix, GLint* viewport)
|
||||
{
|
||||
glGetIntegerv(GL_VIEWPORT, viewport);
|
||||
glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix);
|
||||
glGetDoublev(GL_PROJECTION_MATRIX, projMatrix);
|
||||
}
|
||||
|
||||
//! simplified glut routine (glUnProject): windows coordinates_p --> object coordinates_p
|
||||
/**
|
||||
Don't rely on (use) this in display lists !
|
||||
*/
|
||||
inline bool ViewPort2World(double& objx, double& objy, double& objz, double winx, double winy, double winz)
|
||||
{
|
||||
GLdouble modelMatrix[16];
|
||||
GLdouble projMatrix[16];
|
||||
GLint viewport[4];
|
||||
|
||||
getMatrices(modelMatrix, projMatrix, viewport);
|
||||
int res = gluUnProject(winx, winy, winz, modelMatrix, projMatrix, viewport, &objx, &objy, &objz);
|
||||
|
||||
return (res == GL_FALSE) ? false : true;
|
||||
}
|
||||
|
||||
//! simplified glut routine (glProject): object coordinates_p --> windows coordinates_p
|
||||
/**
|
||||
Don't rely on (use) this in display lists !
|
||||
*/
|
||||
inline bool World2ViewPort(double& winx, double& winy, double& winz, double objx, double objy, double objz )
|
||||
{
|
||||
GLdouble modelMatrix[16];
|
||||
GLdouble projMatrix[16];
|
||||
GLint viewport[4];
|
||||
|
||||
getMatrices(modelMatrix, projMatrix, viewport);
|
||||
int res = gluProject(objx, objy, objz, modelMatrix, projMatrix, viewport, &winx, &winy, &winz);
|
||||
|
||||
return (res == GL_FALSE) ? false : true;
|
||||
}
|
||||
|
||||
|
||||
#endif // QWT3D_NOT_FOR_DOXYGEN
|
||||
|
||||
} // ns
|
||||
|
||||
#endif
|
@ -0,0 +1,44 @@
|
||||
#ifndef qwt3d_parametricsurface_h__2004_03_05_23_43_begin_guarded_code
|
||||
#define qwt3d_parametricsurface_h__2004_03_05_23_43_begin_guarded_code
|
||||
|
||||
#include "qwt3d_gridmapping.h"
|
||||
|
||||
namespace Qwt3D
|
||||
{
|
||||
|
||||
class SurfacePlot;
|
||||
|
||||
|
||||
//! Abstract base class for parametric surfaces
|
||||
/**
|
||||
|
||||
*/
|
||||
class QWT3D_EXPORT ParametricSurface : public GridMapping
|
||||
{
|
||||
|
||||
public:
|
||||
ParametricSurface(); //!< Constructs ParametricSurface object w/o assigned SurfacePlot.
|
||||
//! Constructs ParametricSurface object and assigns a SurfacePlot
|
||||
explicit ParametricSurface(Qwt3D::SurfacePlot& plotWidget);
|
||||
//! Constructs ParametricSurface object and assigns a SurfacePlot
|
||||
explicit ParametricSurface(Qwt3D::SurfacePlot* plotWidget);
|
||||
//! Overwrite this
|
||||
virtual Qwt3D::Triple operator()(double u, double v) = 0;
|
||||
//! Assigns a new SurfacePlot and creates a data representation for it.
|
||||
virtual bool create(Qwt3D::SurfacePlot& plotWidget);
|
||||
//! Creates data representation for the actual assigned SurfacePlot.
|
||||
virtual bool create();
|
||||
//! Assigns the object to another widget. To see the changes, you have to call this function before create().
|
||||
void assign(Qwt3D::SurfacePlot& plotWidget);
|
||||
//! Assigns the object to another widget. To see the changes, you have to call this function before create().
|
||||
void assign(Qwt3D::SurfacePlot* plotWidget);
|
||||
//! Provide information about periodicity of the 'u' resp. 'v' domains.
|
||||
void setPeriodic(bool u, bool v);
|
||||
|
||||
private:
|
||||
bool uperiodic_, vperiodic_;
|
||||
};
|
||||
|
||||
} // ns
|
||||
|
||||
#endif /* include guarded */
|
@ -0,0 +1,315 @@
|
||||
#ifndef __plot3d_2003_06_09_12_14__
|
||||
#define __plot3d_2003_06_09_12_14__
|
||||
|
||||
#include "qwt3d_coordsys.h"
|
||||
#include "qwt3d_enrichment_std.h"
|
||||
|
||||
namespace Qwt3D
|
||||
{
|
||||
|
||||
//! Base class for all plotting widgets
|
||||
/*!
|
||||
Plot3D handles all the common features for plotting widgets - coordinate system, transformations, mouse/keyboard
|
||||
handling, labeling etc.. It contains some pure virtual functions and is, in so far, an abstract base class.
|
||||
The class provides interfaces for data handling and implements basic data controlled color allocation.
|
||||
*/
|
||||
class QWT3D_EXPORT Plot3D : public QGLWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
#if QT_VERSION < 0x040000
|
||||
Plot3D( QWidget* parent = 0, const char* name = 0 );
|
||||
#else
|
||||
Plot3D ( QWidget * parent = 0, const QGLWidget * shareWidget = 0 );
|
||||
#endif
|
||||
virtual ~Plot3D();
|
||||
|
||||
QPixmap renderPixmap (int w=0, int h=0, bool useContext=false);
|
||||
void updateData(); //!< Recalculate data
|
||||
void createCoordinateSystem(Qwt3D::Triple beg, Qwt3D::Triple end);
|
||||
Qwt3D::CoordinateSystem* coordinates() { return &coordinates_p; } //!< Returns pointer to CoordinateSystem object
|
||||
Qwt3D::ColorLegend* legend() { return &legend_;} //!< Returns pointer to ColorLegend object
|
||||
|
||||
double xRotation() const { return xRot_;} //!< Returns rotation around X axis [-360..360] (some angles are equivalent)
|
||||
double yRotation() const { return yRot_;} //!< Returns rotation around Y axis [-360..360] (some angles are equivalent)
|
||||
double zRotation() const { return zRot_;} //!< Returns rotation around Z axis [-360..360] (some angles are equivalent)
|
||||
|
||||
double xShift() const { return xShift_;} //!< Returns shift along X axis (object coordinates)
|
||||
double yShift() const { return yShift_;} //!< Returns shift along Y axis (object coordinates)
|
||||
double zShift() const { return zShift_;} //!< Returns shift along Z axis (object coordinates)
|
||||
|
||||
double xViewportShift() const { return xVPShift_;} //!< Returns relative shift [-1..1] along X axis (view coordinates)
|
||||
double yViewportShift() const { return yVPShift_;} //!< Returns relative shift [-1..1] along Y axis (view coordinates)
|
||||
|
||||
double xScale() const { return xScale_;} //!< Returns scaling for X values [0..inf]
|
||||
double yScale() const { return yScale_;} //!< Returns scaling for Y values [0..inf]
|
||||
double zScale() const { return zScale_;} //!< Returns scaling for Z values [0..inf]
|
||||
|
||||
double zoom() const { return zoom_;} //!< Returns zoom (0..inf)
|
||||
|
||||
bool ortho() const { return ortho_; } //!< Returns orthogonal (true) or perspective (false) projection
|
||||
void setPlotStyle( Qwt3D::PLOTSTYLE val);
|
||||
Qwt3D::Enrichment* setPlotStyle( Qwt3D::Enrichment const& val);
|
||||
Qwt3D::PLOTSTYLE plotStyle() const { return plotstyle_; }//!< Returns plotting style
|
||||
//! Returns current Enrichment object used for plotting styles (if set, zero else)
|
||||
Qwt3D::Enrichment* userStyle() const { return userplotstyle_p; }
|
||||
void setShading( Qwt3D::SHADINGSTYLE val );
|
||||
Qwt3D::SHADINGSTYLE shading() const { return shading_; }//!< Returns shading style
|
||||
void setIsolines(int isolines);
|
||||
int isolines() const { return isolines_;} //!< Returns number of isolines
|
||||
|
||||
void setSmoothMesh(bool val) {smoothdatamesh_p = val;} //!< Enables/disables smooth data mesh lines. Default is false
|
||||
bool smoothDataMesh() const {return smoothdatamesh_p;} //!< True if mesh antialiasing is on
|
||||
void setBackgroundColor(Qwt3D::RGBA rgba); //!< Sets widgets background color
|
||||
Qwt3D::RGBA backgroundRGBAColor() const {return bgcolor_;} //!< Returns the widgets background color
|
||||
void setMeshColor(Qwt3D::RGBA rgba); //!< Sets color for data mesh
|
||||
Qwt3D::RGBA meshColor() const {return meshcolor_;} //!< Returns color for data mesh
|
||||
void setMeshLineWidth(double lw); //!< Sets line width for data mesh
|
||||
double meshLineWidth() const {return meshLineWidth_;} //!< Returns line width for data mesh
|
||||
void setDataColor(Color* col); //!< Sets new data color object
|
||||
const Color* dataColor() const {return datacolor_p;} //!< Returns data color object
|
||||
|
||||
virtual Qwt3D::Enrichment* addEnrichment(Qwt3D::Enrichment const&); //!< Add an Enrichment
|
||||
virtual bool degrade(Qwt3D::Enrichment*); //!< Remove an Enrichment
|
||||
|
||||
Qwt3D::ParallelEpiped hull() const { return hull_;} //!< Returns rectangular hull
|
||||
|
||||
void showColorLegend(bool);
|
||||
|
||||
void setCoordinateStyle(Qwt3D::COORDSTYLE st); //!< Sets style of coordinate system.
|
||||
void setPolygonOffset(double d);
|
||||
double polygonOffset() const {return polygonOffset_;} //!< Returns relative value for polygon offset [0..1]
|
||||
|
||||
void setTitlePosition(double rely, double relx = 0.5, Qwt3D::ANCHOR = Qwt3D::TopCenter);
|
||||
void setTitleFont(const QString& family, int pointSize, int weight = QFont::Normal, bool italic = false);
|
||||
void setTitleColor(Qwt3D::RGBA col) {title_.setColor(col);} //!< Set caption color
|
||||
void setTitle(const QString& title) {title_.setString(title);} //!< Set caption text (one row only)
|
||||
|
||||
|
||||
void assignMouse(MouseState xrot, MouseState yrot, MouseState zrot,
|
||||
MouseState xscale, MouseState yscale, MouseState zscale,
|
||||
MouseState zoom, MouseState xshift, MouseState yshift);
|
||||
|
||||
bool mouseEnabled() const; //!< Returns true, if the widget accept mouse input from the user
|
||||
void assignKeyboard(
|
||||
KeyboardState xrot_n, KeyboardState xrot_p
|
||||
,KeyboardState yrot_n, KeyboardState yrot_p
|
||||
,KeyboardState zrot_n, KeyboardState zrot_p
|
||||
,KeyboardState xscale_n, KeyboardState xscale_p
|
||||
,KeyboardState yscale_n, KeyboardState yscale_p
|
||||
,KeyboardState zscale_n, KeyboardState zscale_p
|
||||
,KeyboardState zoom_n, KeyboardState zoom_p
|
||||
,KeyboardState xshift_n, KeyboardState xshift_p
|
||||
,KeyboardState yshift_n, KeyboardState yshift_p
|
||||
);
|
||||
|
||||
bool keyboardEnabled() const; //!< Returns true, if the widget accept keyboard input from the user
|
||||
//! Sets speed for keyboard driven transformations
|
||||
void setKeySpeed(double rot, double scale, double shift);
|
||||
//! Gets speed for keyboard driven transformations
|
||||
void keySpeed(double& rot, double& scale, double& shift) const;
|
||||
|
||||
bool lightingEnabled() const; //!< Returns true, if Lighting is enabled, false else
|
||||
//! Turn light on
|
||||
void illuminate(unsigned light = 0);
|
||||
//! Turn light off
|
||||
void blowout(unsigned light = 0);
|
||||
|
||||
void setMaterialComponent(GLenum property, double r, double g, double b, double a = 1.0);
|
||||
void setMaterialComponent(GLenum property, double intensity);
|
||||
void setShininess(double exponent);
|
||||
void setLightComponent(GLenum property, double r, double g, double b, double a = 1.0, unsigned light=0);
|
||||
void setLightComponent(GLenum property, double intensity, unsigned light=0);
|
||||
|
||||
//! Returns Light 'idx' rotation around X axis [-360..360] (some angles are equivalent)
|
||||
double xLightRotation(unsigned idx = 0) const { return (idx<8) ? lights_[idx].rot.x : 0;}
|
||||
//! Returns Light 'idx' rotation around Y axis [-360..360] (some angles are equivalent)
|
||||
double yLightRotation(unsigned idx = 0) const { return (idx<8) ? lights_[idx].rot.y : 0;}
|
||||
//! Returns Light 'idx' rotation around Z axis [-360..360] (some angles are equivalent)
|
||||
double zLightRotation(unsigned idx = 0) const { return (idx<8) ? lights_[idx].rot.z : 0;}
|
||||
|
||||
//! Returns shift of Light 'idx 'along X axis (object coordinates)
|
||||
double xLightShift(unsigned idx = 0) const {return (idx<8) ? lights_[idx].shift.x : 0;}
|
||||
//! Returns shift of Light 'idx 'along Y axis (object coordinates)
|
||||
double yLightShift(unsigned idx = 0) const {return (idx<8) ? lights_[idx].shift.y : 0;}
|
||||
//! Returns shift of Light 'idx 'along Z axis (object coordinates)
|
||||
double zLightShift(unsigned idx = 0) const {return (idx<8) ? lights_[idx].shift.z : 0;}
|
||||
//! Returns true if valid data available, false else
|
||||
bool hasData() const { return (actualData_p) ? !actualData_p->empty() : false;}
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
//! Emitted, if the rotation is changed
|
||||
void rotationChanged( double xAngle, double yAngle, double zAngle );
|
||||
//! Emitted, if the shift is changed
|
||||
void shiftChanged( double xShift, double yShift, double zShift );
|
||||
//! Emitted, if the viewport shift is changed
|
||||
void vieportShiftChanged( double xShift, double yShift );
|
||||
//! Emitted, if the scaling is changed
|
||||
void scaleChanged( double xScale, double yScale, double zScale );
|
||||
//! Emitted, if the zoom is changed
|
||||
void zoomChanged(double);
|
||||
//! Emitted, if the projection mode is changed
|
||||
void projectionChanged(bool);
|
||||
|
||||
public slots:
|
||||
|
||||
void setRotation( double xVal, double yVal, double zVal );
|
||||
void setShift( double xVal, double yVal, double zVal );
|
||||
void setViewportShift( double xVal, double yVal );
|
||||
void setScale( double xVal, double yVal, double zVal );
|
||||
void setZoom( double );
|
||||
|
||||
void setOrtho(bool);
|
||||
|
||||
void enableMouse(bool val=true); //!< Enable mouse input
|
||||
void disableMouse(bool val =true); //!< Disable mouse input
|
||||
void enableKeyboard(bool val=true); //!< Enable keyboard input
|
||||
void disableKeyboard(bool val =true); //!< Disable keyboard input
|
||||
|
||||
void enableLighting(bool val = true); //!< Turn Lighting on or off
|
||||
void disableLighting(bool val = true); //!< Turn Lighting on or off
|
||||
|
||||
void setLightRotation( double xVal, double yVal, double zVal, unsigned int idx = 0 );
|
||||
void setLightShift( double xVal, double yVal, double zVal, unsigned int idx = 0 );
|
||||
|
||||
virtual bool savePixmap(QString const& fileName, QString const& format); //!< Saves content to pixmap format
|
||||
//! Saves content to vector format
|
||||
virtual bool saveVector(QString const& fileName, QString const& format, VectorWriter::TEXTMODE text, VectorWriter::SORTMODE sortmode);
|
||||
virtual bool save(QString const& fileName, QString const& format); //!< Saves content
|
||||
|
||||
protected:
|
||||
typedef std::list<Qwt3D::Enrichment*> EnrichmentList;
|
||||
typedef EnrichmentList::iterator ELIT;
|
||||
|
||||
void initializeGL();
|
||||
void paintGL();
|
||||
void resizeGL( int w, int h );
|
||||
|
||||
void mousePressEvent( QMouseEvent *e );
|
||||
void mouseReleaseEvent( QMouseEvent *e );
|
||||
void mouseMoveEvent( QMouseEvent *e );
|
||||
void wheelEvent( QWheelEvent *e );
|
||||
|
||||
void keyPressEvent( QKeyEvent *e );
|
||||
|
||||
Qwt3D::CoordinateSystem coordinates_p;
|
||||
Qwt3D::Color* datacolor_p;
|
||||
Qwt3D::Enrichment* userplotstyle_p;
|
||||
EnrichmentList elist_p;
|
||||
|
||||
virtual void calculateHull() = 0;
|
||||
virtual void createData() = 0;
|
||||
virtual void createEnrichment(Qwt3D::Enrichment&){}
|
||||
virtual void createEnrichments();
|
||||
|
||||
void createCoordinateSystem();
|
||||
void setHull(Qwt3D::ParallelEpiped p) {hull_ = p;}
|
||||
|
||||
bool initializedGL() const {return initializedGL_;}
|
||||
|
||||
enum OBJECTS
|
||||
{
|
||||
DataObject,
|
||||
LegendObject,
|
||||
NormalObject,
|
||||
DisplayListSize // only to have a vector length ...
|
||||
};
|
||||
std::vector<GLuint> displaylists_p;
|
||||
Qwt3D::Data* actualData_p;
|
||||
|
||||
|
||||
private:
|
||||
struct Light
|
||||
{
|
||||
Light() : unlit(true){}
|
||||
bool unlit;
|
||||
Qwt3D::Triple rot;
|
||||
Qwt3D::Triple shift;
|
||||
};
|
||||
std::vector<Light> lights_;
|
||||
|
||||
GLdouble xRot_, yRot_, zRot_, xShift_, yShift_, zShift_, zoom_
|
||||
, xScale_, yScale_, zScale_, xVPShift_, yVPShift_;
|
||||
|
||||
Qwt3D::RGBA meshcolor_;
|
||||
double meshLineWidth_;
|
||||
Qwt3D::RGBA bgcolor_;
|
||||
Qwt3D::PLOTSTYLE plotstyle_;
|
||||
Qwt3D::SHADINGSTYLE shading_;
|
||||
Qwt3D::FLOORSTYLE floorstyle_;
|
||||
bool ortho_;
|
||||
double polygonOffset_;
|
||||
int isolines_;
|
||||
bool displaylegend_;
|
||||
bool smoothdatamesh_p;
|
||||
|
||||
Qwt3D::ParallelEpiped hull_;
|
||||
|
||||
Qwt3D::ColorLegend legend_;
|
||||
|
||||
Label title_;
|
||||
Qwt3D::Tuple titlerel_;
|
||||
Qwt3D::ANCHOR titleanchor_;
|
||||
|
||||
|
||||
// mouse
|
||||
|
||||
QPoint lastMouseMovePosition_;
|
||||
bool mpressed_;
|
||||
|
||||
MouseState xrot_mstate_,
|
||||
yrot_mstate_,
|
||||
zrot_mstate_,
|
||||
xscale_mstate_,
|
||||
yscale_mstate_,
|
||||
zscale_mstate_,
|
||||
zoom_mstate_,
|
||||
xshift_mstate_,
|
||||
yshift_mstate_;
|
||||
|
||||
bool mouse_input_enabled_;
|
||||
|
||||
void setRotationMouse(MouseState bstate, double accel, QPoint diff);
|
||||
void setScaleMouse(MouseState bstate, double accel, QPoint diff);
|
||||
void setShiftMouse(MouseState bstate, double accel, QPoint diff);
|
||||
|
||||
// keyboard
|
||||
|
||||
bool kpressed_;
|
||||
|
||||
KeyboardState xrot_kstate_[2],
|
||||
yrot_kstate_[2],
|
||||
zrot_kstate_[2],
|
||||
xscale_kstate_[2],
|
||||
yscale_kstate_[2],
|
||||
zscale_kstate_[2],
|
||||
zoom_kstate_[2],
|
||||
xshift_kstate_[2],
|
||||
yshift_kstate_[2];
|
||||
|
||||
bool kbd_input_enabled_;
|
||||
double kbd_rot_speed_, kbd_scale_speed_, kbd_shift_speed_;
|
||||
|
||||
void setRotationKeyboard(KeyboardState kseq, double speed);
|
||||
void setScaleKeyboard(KeyboardState kseq, double speed);
|
||||
void setShiftKeyboard(KeyboardState kseq, double speed);
|
||||
|
||||
|
||||
|
||||
bool lighting_enabled_;
|
||||
void applyLight(unsigned idx);
|
||||
void applyLights();
|
||||
|
||||
bool initializedGL_;
|
||||
bool renderpixmaprequest_;
|
||||
};
|
||||
|
||||
|
||||
} // ns
|
||||
|
||||
|
||||
#endif
|
@ -0,0 +1,91 @@
|
||||
#ifndef qwt3d_portability_h__2005_07_02_11_55_begin_guarded_code
|
||||
#define qwt3d_portability_h__2005_07_02_11_55_begin_guarded_code
|
||||
|
||||
//! Portability classes providing transparent Qt3/4 support
|
||||
|
||||
#include <qnamespace.h>
|
||||
#include "qwt3d_global.h"
|
||||
|
||||
#if QT_VERSION < 0x040000
|
||||
|
||||
namespace Qwt3D
|
||||
{
|
||||
#define QWT3DLOCAL8BIT(qstring) \
|
||||
((const char*)(qstring.local8Bit()))
|
||||
|
||||
typedef int MouseState;
|
||||
typedef int KeyboardState;
|
||||
const Qt::TextFlags SingleLine = Qt::SingleLine;
|
||||
} // ns
|
||||
|
||||
|
||||
#else // Qt4
|
||||
|
||||
#include <QMouseEvent>
|
||||
|
||||
namespace Qwt3D
|
||||
{
|
||||
|
||||
#define QWT3DLOCAL8BIT(qstring) \
|
||||
((const char*)(qstring.toLocal8Bit()))
|
||||
|
||||
const Qt::TextFlag SingleLine = Qt::TextSingleLine;
|
||||
|
||||
//! This class creates a (mouse-button,modifier) pair (ordinary typedef for int if Qt3 is used)
|
||||
class MouseState
|
||||
{
|
||||
public:
|
||||
MouseState(Qt::MouseButtons mb = Qt::NoButton, Qt::KeyboardModifiers km = Qt::NoModifier)
|
||||
: mb_(mb), km_(km)
|
||||
{
|
||||
}
|
||||
|
||||
MouseState(Qt::MouseButton mb, Qt::KeyboardModifiers km = Qt::NoModifier)
|
||||
: mb_(mb), km_(km)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator==(const MouseState& ms)
|
||||
{
|
||||
return mb_ == ms.mb_ && km_ == ms.km_;
|
||||
}
|
||||
|
||||
bool operator!=(const MouseState& ms)
|
||||
{
|
||||
return !operator==(ms);
|
||||
}
|
||||
|
||||
private:
|
||||
Qt::MouseButtons mb_;
|
||||
Qt::KeyboardModifiers km_;
|
||||
};
|
||||
|
||||
//! This class creates a (key-button,modifier) pair (ordinary typedef for int if Qt3 is used)
|
||||
class KeyboardState
|
||||
{
|
||||
public:
|
||||
KeyboardState(int key = Qt::Key_unknown, Qt::KeyboardModifiers km = Qt::NoModifier)
|
||||
: key_(key), km_(km)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator==(const KeyboardState& ms)
|
||||
{
|
||||
return key_ == ms.key_ && km_ == ms.km_;
|
||||
}
|
||||
|
||||
bool operator!=(const KeyboardState& ms)
|
||||
{
|
||||
return !operator==(ms);
|
||||
}
|
||||
|
||||
private:
|
||||
int key_;
|
||||
Qt::KeyboardModifiers km_;
|
||||
};
|
||||
} // ns
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
@ -0,0 +1,87 @@
|
||||
#ifndef qwt3d_scale_h__2004_06_02_22_02_begin_guarded_code
|
||||
#define qwt3d_scale_h__2004_06_02_22_02_begin_guarded_code
|
||||
|
||||
#include <qstring.h>
|
||||
#include "qwt3d_types.h"
|
||||
#include "qwt3d_autoscaler.h"
|
||||
#include "qwt3d_autoptr.h"
|
||||
|
||||
namespace Qwt3D
|
||||
{
|
||||
|
||||
/*!
|
||||
The class encapsulates non-visual scales.
|
||||
She is utilized by Axis and also collaborates closely with AutoScaler.
|
||||
A Scale allows control over all aspects of tic generation including
|
||||
arbitrary transformations of tic values into corresponding strings.
|
||||
The strings contain what eventually will be shown as tic labels.\n
|
||||
Standard linear and logarithmic scales have been integrated yet into the Axis
|
||||
interface. User-defined axes can be derived from Scale, LinearScale et al.
|
||||
*/
|
||||
class QWT3D_EXPORT Scale
|
||||
{
|
||||
friend class Axis;
|
||||
friend class qwt3d_ptr<Scale>;
|
||||
|
||||
protected:
|
||||
Scale();
|
||||
virtual ~Scale(){}
|
||||
virtual QString ticLabel(unsigned int idx) const;
|
||||
|
||||
virtual void setLimits(double start, double stop);
|
||||
virtual void setMajors(int val) {majorintervals_p=val;} //!< Sets number of major intervals
|
||||
virtual void setMinors(int val) {minorintervals_p=val;} //!< Sets number of minor intervals per major interval
|
||||
virtual void setMajorLimits(double start, double stop);
|
||||
|
||||
int majors() const {return majorintervals_p;} //!< Returns major intervals
|
||||
int minors() const {return minorintervals_p;} //!< Returns minor intervals
|
||||
|
||||
//! Derived classes should return a new heap based object here.
|
||||
virtual Scale* clone() const = 0;
|
||||
//! This function should setup the 2 vectors for major and minor positions;
|
||||
virtual void calculate() = 0;
|
||||
virtual int autoscale(double& a, double& b, double start, double stop, int ivals);
|
||||
|
||||
std::vector<double> majors_p, minors_p;
|
||||
double start_p, stop_p;
|
||||
int majorintervals_p, minorintervals_p;
|
||||
double mstart_p, mstop_p;
|
||||
|
||||
private:
|
||||
void destroy() const {delete this;} //!< Used by qwt3d_ptr
|
||||
};
|
||||
|
||||
//! The standard (1:1) mapping class for axis numbering
|
||||
class QWT3D_EXPORT LinearScale : public Scale
|
||||
{
|
||||
friend class Axis;
|
||||
friend class qwt3d_ptr<Scale>;
|
||||
protected:
|
||||
int autoscale(double& a, double& b, double start, double stop, int ivals);
|
||||
//! Returns a new heap based object utilized from qwt3d_ptr
|
||||
Scale* clone() const {return new LinearScale(*this);}
|
||||
void calculate();
|
||||
LinearAutoScaler autoscaler_p;
|
||||
};
|
||||
|
||||
//! log10 scale
|
||||
class QWT3D_EXPORT LogScale : public Scale
|
||||
{
|
||||
friend class Axis;
|
||||
friend class qwt3d_ptr<Scale>;
|
||||
protected:
|
||||
QString ticLabel(unsigned int idx) const;
|
||||
void setMinors(int val);
|
||||
//! Standard ctor
|
||||
LogScale();
|
||||
//! Returns a new heap based object utilized from qwt3d_ptr
|
||||
Scale* clone() const {return new LogScale;}
|
||||
void calculate();
|
||||
private:
|
||||
void setupCounter(double& k, int& step);
|
||||
};
|
||||
|
||||
} // namespace Qwt3D
|
||||
|
||||
|
||||
#endif /* include guarded */
|
@ -0,0 +1,132 @@
|
||||
#ifndef qwt3d_SurfacePlot_h__2004_03_05_11_36_begin_guarded_code
|
||||
#define qwt3d_SurfacePlot_h__2004_03_05_11_36_begin_guarded_code
|
||||
|
||||
#include "qwt3d_plot.h"
|
||||
|
||||
namespace Qwt3D
|
||||
{
|
||||
//! A class representing Surfaces
|
||||
/**
|
||||
A SurfacePlot ...
|
||||
|
||||
*/
|
||||
class QWT3D_EXPORT SurfacePlot : public Plot3D
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
#if QT_VERSION < 0x040000
|
||||
SurfacePlot( QWidget* parent = 0, const char* name = 0 );
|
||||
#else
|
||||
SurfacePlot( QWidget * parent = 0, const QGLWidget * shareWidget = 0 );
|
||||
#endif
|
||||
~SurfacePlot();
|
||||
void updateNormals(); //!< Recalculates surface normals;
|
||||
int resolution() const {return resolution_p;} //!< Returns data resolution (1 means all data)
|
||||
std::pair<int,int> facets() const; //!< Returns the number of mesh cells for the ORIGINAL data
|
||||
bool loadFromData(Qwt3D::Triple** data, unsigned int columns, unsigned int rows
|
||||
, bool uperiodic = false, bool vperiodic = false);
|
||||
bool loadFromData(double** data, unsigned int columns, unsigned int rows
|
||||
,double minx, double maxx, double miny, double maxy);
|
||||
bool loadFromData(Qwt3D::TripleField const& data, Qwt3D::CellField const& poly);
|
||||
|
||||
|
||||
//! Equivalent to loadFromData();
|
||||
/**
|
||||
\deprecated Use loadFromData instead
|
||||
*/
|
||||
bool createDataRepresentation(Qwt3D::Triple** data, unsigned int columns, unsigned int rows
|
||||
, bool uperiodic = false, bool vperiodic = false)
|
||||
{
|
||||
return loadFromData(data, columns, rows, uperiodic, vperiodic);
|
||||
}
|
||||
//! Equivalent to loadFromData();
|
||||
/**
|
||||
\deprecated Use loadFromData instead
|
||||
*/
|
||||
bool createDataRepresentation(double** data, unsigned int columns, unsigned int rows
|
||||
,double minx, double maxx, double miny, double maxy)
|
||||
{
|
||||
return loadFromData(data, columns, rows, minx, maxx, miny, maxy);
|
||||
}
|
||||
//! Equivalent to loadFromData();
|
||||
/**
|
||||
\deprecated Use loadFromData instead
|
||||
*/
|
||||
bool createDataRepresentation(Qwt3D::TripleField const& data, Qwt3D::CellField const& poly)
|
||||
{
|
||||
return loadFromData(data, poly);
|
||||
}
|
||||
|
||||
|
||||
Qwt3D::FLOORSTYLE floorStyle() const { return floorstyle_;} //!< Return floor style
|
||||
void setFloorStyle( Qwt3D::FLOORSTYLE val ) {floorstyle_ = val;} //!< Sets floor style
|
||||
void showNormals(bool); //!< Draw normals to every vertex
|
||||
bool normals() const { return datanormals_p;} //!< Returns \c true, if normal drawing is on
|
||||
|
||||
void setNormalLength(double val); //!< Sets length of normals in percent per hull diagonale
|
||||
double normalLength() const { return normalLength_p; }//!< Returns relative length of normals
|
||||
void setNormalQuality(int val); //!< Increases plotting quality of normal arrows
|
||||
int normalQuality() const { return normalQuality_p; }//!< Returns plotting quality of normal arrows
|
||||
|
||||
|
||||
signals:
|
||||
void resolutionChanged(int);
|
||||
|
||||
public slots:
|
||||
void setResolution( int );
|
||||
|
||||
protected:
|
||||
bool datanormals_p;
|
||||
double normalLength_p;
|
||||
int normalQuality_p;
|
||||
|
||||
virtual void calculateHull();
|
||||
virtual void createData();
|
||||
virtual void createEnrichment(Qwt3D::Enrichment& p);
|
||||
virtual void createFloorData();
|
||||
void createNormals();
|
||||
void createPoints();
|
||||
|
||||
int resolution_p;
|
||||
|
||||
void readIn(Qwt3D::GridData& gdata, Triple** data, unsigned int columns, unsigned int rows);
|
||||
void readIn(Qwt3D::GridData& gdata, double** data, unsigned int columns, unsigned int rows,
|
||||
double minx, double maxx, double miny, double maxy);
|
||||
void calcNormals(GridData& gdata);
|
||||
void sewPeriodic(GridData& gdata);
|
||||
|
||||
//void calcLowResolution();
|
||||
private:
|
||||
|
||||
void Data2Floor();
|
||||
void Isolines2Floor();
|
||||
|
||||
Qwt3D::FLOORSTYLE floorstyle_;
|
||||
|
||||
// grid plot
|
||||
|
||||
Qwt3D::GridData* actualDataG_;
|
||||
virtual void createDataG();
|
||||
virtual void createFloorDataG();
|
||||
void createNormalsG();
|
||||
void Data2FloorG();
|
||||
void Isolines2FloorG();
|
||||
void setColorFromVertexG(int ix, int iy, bool skip = false);
|
||||
|
||||
|
||||
// mesh plot
|
||||
|
||||
Qwt3D::CellData* actualDataC_;
|
||||
virtual void createDataC();
|
||||
virtual void createFloorDataC();
|
||||
void createNormalsC();
|
||||
void Data2FloorC();
|
||||
void Isolines2FloorC();
|
||||
void setColorFromVertexC(int node, bool skip = false);
|
||||
};
|
||||
|
||||
} // ns
|
||||
|
||||
|
||||
#endif
|
@ -0,0 +1,455 @@
|
||||
#if defined(_MSC_VER) /* MSVC Compiler */
|
||||
#pragma warning ( disable : 4786 )
|
||||
#endif
|
||||
|
||||
#ifndef __DATATYPES_H__
|
||||
#define __DATATYPES_H__
|
||||
|
||||
#ifdef _DEBUG
|
||||
#include <fstream>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "qwt3d_global.h"
|
||||
|
||||
#if defined(Q_WS_WIN)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifndef WHEEL_DELTA
|
||||
#define WHEEL_DELTA 120
|
||||
#endif
|
||||
|
||||
#include "qwt3d_portability.h"
|
||||
#include "qwt3d_helper.h"
|
||||
#include "qwt3d_openglhelper.h"
|
||||
|
||||
//! Common namespace for all QwtPlot3D classes
|
||||
namespace Qwt3D
|
||||
{
|
||||
|
||||
const double PI = 3.14159265358979323846264338328;
|
||||
|
||||
//! Plotting style
|
||||
enum PLOTSTYLE
|
||||
{
|
||||
NOPLOT , //!< No visible data
|
||||
WIREFRAME , //!< Wireframe style
|
||||
HIDDENLINE , //!< Hidden Line style
|
||||
FILLED , //!< Color filled polygons w/o edges
|
||||
FILLEDMESH , //!< Color filled polygons w/ separately colored edges
|
||||
POINTS , //!< User defined style (used by Enrichments)
|
||||
USER //!< User defined style (used by Enrichments)
|
||||
};
|
||||
|
||||
//! Shading style
|
||||
enum SHADINGSTYLE
|
||||
{
|
||||
FLAT, //!< Flat shading (OpenGL)
|
||||
GOURAUD //!< Gouraud Shading (OpenGL)
|
||||
};
|
||||
|
||||
//! Style of Coordinate system
|
||||
enum COORDSTYLE
|
||||
{
|
||||
NOCOORD, //!< Coordinate system is not visible
|
||||
BOX, //!< Boxed
|
||||
FRAME //!< Frame - 3 visible axes
|
||||
};
|
||||
|
||||
//! Different types of axis scales
|
||||
enum SCALETYPE
|
||||
{
|
||||
LINEARSCALE,//!< Linear scaling
|
||||
LOG10SCALE, //!< Logarithmic scaling (base 10)
|
||||
USERSCALE //!< User-defined (for extensions)
|
||||
};
|
||||
|
||||
//! Plotting style for floor data (projections)
|
||||
enum FLOORSTYLE
|
||||
{
|
||||
NOFLOOR, //!< Empty floor
|
||||
FLOORISO, //!< Isoline projections visible
|
||||
FLOORDATA //!< Projected polygons visible
|
||||
};
|
||||
|
||||
//! Mesh type
|
||||
enum DATATYPE
|
||||
{
|
||||
GRID, //!< Rectangular grid
|
||||
POLYGON //!< Convex polygon
|
||||
};
|
||||
|
||||
//! The 12 axes
|
||||
/**
|
||||
\image html axes.png
|
||||
*/
|
||||
enum AXIS
|
||||
{
|
||||
X1 = 0, //!< 1st x-axis
|
||||
X2 = 3, //!< 2nd x-axis
|
||||
X3 = 4, //!< 3th x-axis
|
||||
X4 = 5, //!< 4th x-axis
|
||||
Y1 = 1, //!< 1st y-axis
|
||||
Y2 = 8, //!< 2nd y-axis
|
||||
Y3 = 7, //!< 3th y-axis
|
||||
Y4 = 6, //!< 4th y-axis
|
||||
Z1 = 2, //!< 1st z-axis
|
||||
Z2 = 9, //!< 2nd z-axis
|
||||
Z3 = 11, //!< 3th z-axis
|
||||
Z4 = 10 //!< 4th z-axis
|
||||
};
|
||||
|
||||
//! The 6 sides
|
||||
enum SIDE
|
||||
{
|
||||
NOSIDEGRID = 0,
|
||||
LEFT = 1 << 0,
|
||||
RIGHT = 1 << 1,
|
||||
CEIL = 1 << 2,
|
||||
FLOOR = 1 << 3,
|
||||
FRONT = 1 << 4,
|
||||
BACK = 1 << 5
|
||||
};
|
||||
|
||||
//! Possible anchor points for drawing operations
|
||||
enum ANCHOR
|
||||
{
|
||||
BottomLeft,
|
||||
BottomRight,
|
||||
BottomCenter,
|
||||
TopLeft,
|
||||
TopRight,
|
||||
TopCenter,
|
||||
CenterLeft,
|
||||
CenterRight,
|
||||
Center
|
||||
};
|
||||
|
||||
|
||||
//! Tuple <tt>[x,y]</tt>
|
||||
struct QWT3D_EXPORT Tuple
|
||||
{
|
||||
Tuple() : x(0), y(0) {} //!< Calls Tuple(0,0)
|
||||
Tuple(double X, double Y) : x(X), y(Y) {} //!< Initialize Tuple with x and y
|
||||
//! Tuple coordinates
|
||||
double x,y;
|
||||
};
|
||||
|
||||
//! Triple <tt>[x,y,z]</tt>
|
||||
/**
|
||||
Consider Triples also as vectors in R^3
|
||||
*/
|
||||
struct QWT3D_EXPORT Triple
|
||||
{
|
||||
//! Initialize Triple with x,y and z
|
||||
explicit Triple(double xv = 0,double yv = 0,double zv = 0)
|
||||
: x(xv), y(yv), z(zv)
|
||||
{
|
||||
}
|
||||
|
||||
#ifndef QWT3D_NOT_FOR_DOXYGEN
|
||||
#ifdef Q_OS_IRIX
|
||||
Triple(const Triple& val)
|
||||
{
|
||||
if (&val == this)
|
||||
return;
|
||||
x = val.x;
|
||||
y = val.y;
|
||||
z = val.z;
|
||||
}
|
||||
const Triple& operator=(const Triple& val)
|
||||
{
|
||||
if (&val == this)
|
||||
return *this;
|
||||
x = val.x;
|
||||
y = val.y;
|
||||
z = val.z;
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
#endif // QWT3D_NOT_FOR_DOXYGEN
|
||||
|
||||
//! Triple coordinates
|
||||
double x,y,z;
|
||||
|
||||
Triple& operator+=(Triple t)
|
||||
{
|
||||
x += t.x;
|
||||
y += t.y;
|
||||
z += t.z;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Triple& operator-=(Triple t)
|
||||
{
|
||||
x -= t.x;
|
||||
y -= t.y;
|
||||
z -= t.z;
|
||||
|
||||
return *this;
|
||||
}
|
||||
Triple& operator*=(double d)
|
||||
{
|
||||
x *= d;
|
||||
y *= d;
|
||||
z *= d;
|
||||
|
||||
return *this;
|
||||
}
|
||||
Triple& operator/=(double d)
|
||||
{
|
||||
x /= d;
|
||||
y /= d;
|
||||
z /= d;
|
||||
|
||||
return *this;
|
||||
}
|
||||
Triple& operator*=(Triple t) // scale
|
||||
{
|
||||
x *= t.x;
|
||||
y *= t.y;
|
||||
z *= t.z;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator!=(Triple t) const
|
||||
{
|
||||
return !isPracticallyZero(x,t.x) || !isPracticallyZero(y,t.y) || !isPracticallyZero(z,t.z);
|
||||
}
|
||||
|
||||
bool operator==(Triple t) const
|
||||
{
|
||||
return !operator!=(t);
|
||||
}
|
||||
|
||||
double length() const
|
||||
{
|
||||
double l2 = x*x + y*y + z*z;
|
||||
return (isPracticallyZero(l2)) ? 0 :sqrt(l2);
|
||||
}
|
||||
|
||||
void normalize()
|
||||
{
|
||||
double l = length();
|
||||
if (l)
|
||||
*this /= l;
|
||||
}
|
||||
};
|
||||
|
||||
inline const Triple operator+(const Triple& t, const Triple& t2)
|
||||
{
|
||||
return Triple(t) += t2;
|
||||
}
|
||||
inline const Triple operator-(const Triple& t, const Triple& t2)
|
||||
{
|
||||
return Triple(t) -= t2;
|
||||
}
|
||||
inline const Triple operator*(double d, const Triple& t)
|
||||
{
|
||||
return Triple(t) *= d;
|
||||
}
|
||||
inline const Triple operator*(const Triple& t, double d)
|
||||
{
|
||||
return Triple(t) *= d;
|
||||
}
|
||||
inline const Triple operator/(double d, const Triple& t)
|
||||
{
|
||||
return Triple(t) /= d;
|
||||
}
|
||||
inline const Triple operator/(const Triple& t, double d)
|
||||
{
|
||||
return Triple(t) /= d;
|
||||
}
|
||||
inline const Triple operator*(const Triple& t, const Triple& t2)
|
||||
{
|
||||
return Triple(t) *= t2;
|
||||
}
|
||||
|
||||
//! Parallelepiped spanned by 2 Triples
|
||||
/**
|
||||
Please use \em normalized Parallelepipeds:\n\n
|
||||
minVertex.x <= maxVertex.x\n
|
||||
minVertex.y <= maxVertex.y\n
|
||||
minVertex.z <= maxVertex.z\n
|
||||
*/
|
||||
struct QWT3D_EXPORT ParallelEpiped
|
||||
{
|
||||
//! Construct non-initialized Parallelepiped
|
||||
ParallelEpiped()
|
||||
{
|
||||
}
|
||||
|
||||
//! Construct initialized Parallelepiped
|
||||
/**
|
||||
minv -> minVertex\n
|
||||
maxv -> maxVertex\n
|
||||
*/
|
||||
ParallelEpiped(Triple minv, Triple maxv)
|
||||
: minVertex(minv), maxVertex(maxv)
|
||||
{
|
||||
}
|
||||
|
||||
Triple minVertex;
|
||||
Triple maxVertex;
|
||||
};
|
||||
|
||||
//! Free vector
|
||||
/**
|
||||
FreeVectors represent objects like normal vectors and other vector fields inside R^3
|
||||
*/
|
||||
struct QWT3D_EXPORT FreeVector
|
||||
{
|
||||
FreeVector()
|
||||
{
|
||||
}
|
||||
|
||||
//! Construct initialized vector
|
||||
/**
|
||||
b -> base\n
|
||||
e -> top\n
|
||||
*/
|
||||
FreeVector(Triple b, Triple t)
|
||||
: base(b), top(t)
|
||||
{
|
||||
}
|
||||
|
||||
Triple base;
|
||||
Triple top;
|
||||
};
|
||||
|
||||
//! A free vector field in R^3
|
||||
typedef std::vector<FreeVector> FreeVectorField;
|
||||
|
||||
//! A point field in R^3
|
||||
typedef std::vector<Triple> TripleField;
|
||||
//! Holds indices in a TripleField interpreted as counterclockwise node numbering for a convex polygon
|
||||
typedef std::vector<unsigned> Cell;
|
||||
//! Vector of convex polygons. You need a TripleField as base for the node data
|
||||
typedef std::vector<Cell> CellField;
|
||||
//! Returns the sum over the sizes of the single cells
|
||||
unsigned tesselationSize(Qwt3D::CellField const& t);
|
||||
|
||||
//! Red-Green-Blue-Alpha value
|
||||
struct QWT3D_EXPORT RGBA
|
||||
{
|
||||
RGBA()
|
||||
: r(0), g(0), b(0), a(1)
|
||||
{}
|
||||
RGBA(double rr, double gg, double bb, double aa = 1)
|
||||
: r(rr), g(gg), b(bb), a(aa)
|
||||
{}
|
||||
double r,g,b,a;
|
||||
};
|
||||
|
||||
//! A Color field
|
||||
typedef std::vector<RGBA> ColorVector;
|
||||
|
||||
#ifndef QWT3D_NOT_FOR_DOXYGEN
|
||||
|
||||
QWT3D_EXPORT QColor GL2Qt(GLdouble r, GLdouble g, GLdouble b); //!< RGB -> QColor
|
||||
QWT3D_EXPORT Qwt3D::RGBA Qt2GL(QColor col); //!< QColor -> RGBA
|
||||
|
||||
typedef double *Vertex;
|
||||
typedef std::vector<Vertex> DataRow;
|
||||
typedef std::vector<DataRow> DataMatrix;
|
||||
|
||||
|
||||
class Data
|
||||
{
|
||||
public:
|
||||
Qwt3D::DATATYPE datatype;
|
||||
Data() {datatype= Qwt3D::POLYGON;}
|
||||
virtual ~Data() {}
|
||||
virtual void clear() = 0; //!< destroy content
|
||||
virtual bool empty() const = 0; //!< no data
|
||||
void setHull(Qwt3D::ParallelEpiped const& h) {hull_p = h;}
|
||||
Qwt3D::ParallelEpiped const& hull() const {return hull_p;}
|
||||
|
||||
protected:
|
||||
Qwt3D::ParallelEpiped hull_p;
|
||||
};
|
||||
|
||||
|
||||
//! Implements a matrix of z-Values with limit access functions
|
||||
class GridData : public Data
|
||||
{
|
||||
public:
|
||||
GridData();
|
||||
GridData(unsigned int columns, unsigned int rows);//!< see setSize()
|
||||
~GridData() { clear();}
|
||||
|
||||
int columns() const;
|
||||
int rows() const;
|
||||
|
||||
void clear(); //!< destroy content
|
||||
bool empty() const { return vertices.empty();}
|
||||
void setSize(unsigned int columns, unsigned int rows); //!< destroys content and set new size, elements are uninitialized
|
||||
|
||||
DataMatrix vertices; //!< mesh vertices
|
||||
DataMatrix normals; //!< mesh normals
|
||||
void setPeriodic(bool u, bool v) {uperiodic_ = u; vperiodic_ = v;}
|
||||
bool uperiodic() const {return uperiodic_;}
|
||||
bool vperiodic() const {return vperiodic_;}
|
||||
|
||||
private:
|
||||
bool uperiodic_, vperiodic_;
|
||||
};
|
||||
|
||||
|
||||
//! Implements a graph-like cell structure with limit access functions
|
||||
class CellData : public Data
|
||||
{
|
||||
public:
|
||||
CellData() {datatype=Qwt3D::POLYGON;}
|
||||
~CellData() { clear();}
|
||||
|
||||
void clear(); //!< destroy content
|
||||
bool empty() const { return cells.empty();}
|
||||
|
||||
Triple const& operator()(unsigned cellnumber, unsigned vertexnumber);
|
||||
|
||||
CellField cells; //!< polygon/cell mesh
|
||||
TripleField nodes;
|
||||
TripleField normals; //!< mesh normals
|
||||
};
|
||||
|
||||
inline Triple normalizedcross(Triple const& u, Triple const& v)
|
||||
{
|
||||
Triple n;
|
||||
|
||||
/* compute the cross product (u x v for right-handed [ccw]) */
|
||||
n.x = u.y * v.z - u.z * v.y;
|
||||
n.y = u.z * v.x - u.x * v.z;
|
||||
n.z = u.x * v.y - u.y * v.x;
|
||||
|
||||
/* normalize */
|
||||
double l = n.length();
|
||||
if (l)
|
||||
{
|
||||
n /= l;
|
||||
}
|
||||
else
|
||||
{
|
||||
n = Triple(0,0,0);
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
inline double dotProduct(Triple const& u, Triple const& v)
|
||||
{
|
||||
return u.x*v.x + u.y*v.y + u.z*v.z;
|
||||
}
|
||||
|
||||
void convexhull2d( std::vector<unsigned>& idx, const std::vector<Qwt3D::Tuple>& src );
|
||||
|
||||
|
||||
#endif // QWT3D_NOT_FOR_DOXYGEN
|
||||
|
||||
} // ns
|
||||
|
||||
#endif
|
@ -0,0 +1,24 @@
|
||||
#ifndef qwt3d_volumeplot_h__2004_03_06_01_52_begin_guarded_code
|
||||
#define qwt3d_volumeplot_h__2004_03_06_01_52_begin_guarded_code
|
||||
|
||||
#include "qwt3d_plot.h"
|
||||
|
||||
namespace Qwt3D
|
||||
{
|
||||
|
||||
//! TODO
|
||||
class QWT3D_EXPORT VolumePlot : public Plot3D
|
||||
{
|
||||
// Q_OBJECT
|
||||
|
||||
public:
|
||||
VolumePlot( QWidget* parent = 0, const char* name = 0 ){}
|
||||
|
||||
protected:
|
||||
virtual void createData() = 0;
|
||||
};
|
||||
|
||||
} // ns
|
||||
|
||||
|
||||
#endif
|
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE TS><TS>
|
||||
<context>
|
||||
<name>NativeReader</name>
|
||||
<message>
|
||||
<source>NativeReader::read: cannot open data file "%s"
|
||||
</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
@ -0,0 +1,95 @@
|
||||
# pro file for building the makefile for qwtplot3d
|
||||
#
|
||||
|
||||
TARGET = qwtplot3d
|
||||
TEMPLATE = lib
|
||||
CONFIG += qt warn_on opengl thread zlib debug
|
||||
MOC_DIR = tmp
|
||||
OBJECTS_DIR = tmp
|
||||
INCLUDEPATH = include
|
||||
DEPENDPATH = include src
|
||||
DESTDIR = lib
|
||||
#DESTDIR = ../../../lib
|
||||
QT += opengl
|
||||
|
||||
win32:TEMPLATE = vclib
|
||||
win32:CONFIG += dll exceptions
|
||||
win32:dll:DEFINES += QT_DLL QWT3D_DLL QWT3D_MAKEDLL
|
||||
win32:QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_STL
|
||||
|
||||
# Comment the next line, if you have zlib on your windows system
|
||||
win32:CONFIG -= zlib
|
||||
|
||||
linux-g++:TMAKE_CXXFLAGS += -fno-exceptions
|
||||
unix:VERSION = 0.2.6
|
||||
|
||||
# Input
|
||||
SOURCES += src/qwt3d_axis.cpp \
|
||||
src/qwt3d_color.cpp \
|
||||
src/qwt3d_coordsys.cpp \
|
||||
src/qwt3d_drawable.cpp \
|
||||
src/qwt3d_mousekeyboard.cpp \
|
||||
src/qwt3d_movements.cpp \
|
||||
src/qwt3d_lighting.cpp \
|
||||
src/qwt3d_colorlegend.cpp \
|
||||
src/qwt3d_plot.cpp \
|
||||
src/qwt3d_label.cpp \
|
||||
src/qwt3d_types.cpp \
|
||||
src/qwt3d_enrichment_std.cpp \
|
||||
src/qwt3d_autoscaler.cpp \
|
||||
src/qwt3d_io_reader.cpp \
|
||||
src/qwt3d_io.cpp \
|
||||
src/qwt3d_scale.cpp
|
||||
|
||||
SOURCES += src/qwt3d_gridmapping.cpp \
|
||||
src/qwt3d_parametricsurface.cpp \
|
||||
src/qwt3d_function.cpp
|
||||
|
||||
SOURCES += src/qwt3d_surfaceplot.cpp \
|
||||
src/qwt3d_gridplot.cpp \
|
||||
src/qwt3d_meshplot.cpp
|
||||
|
||||
|
||||
HEADERS += include/qwt3d_color.h \
|
||||
include/qwt3d_global.h \
|
||||
include/qwt3d_types.h \
|
||||
include/qwt3d_axis.h \
|
||||
include/qwt3d_coordsys.h \
|
||||
include/qwt3d_drawable.h \
|
||||
include/qwt3d_helper.h \
|
||||
include/qwt3d_label.h \
|
||||
include/qwt3d_openglhelper.h \
|
||||
include/qwt3d_colorlegend.h \
|
||||
include/qwt3d_plot.h \
|
||||
include/qwt3d_enrichment.h \
|
||||
include/qwt3d_enrichment_std.h \
|
||||
include/qwt3d_autoscaler.h \
|
||||
include/qwt3d_autoptr.h \
|
||||
include/qwt3d_io.h \
|
||||
include/qwt3d_io_reader.h \
|
||||
include/qwt3d_scale.h \
|
||||
include/qwt3d_portability.h
|
||||
|
||||
HEADERS += include/qwt3d_mapping.h \
|
||||
include/qwt3d_gridmapping.h \
|
||||
include/qwt3d_parametricsurface.h \
|
||||
include/qwt3d_function.h
|
||||
|
||||
HEADERS += include/qwt3d_surfaceplot.h \
|
||||
include/qwt3d_volumeplot.h \
|
||||
include/qwt3d_graphplot.h \
|
||||
include/qwt3d_multiplot.h
|
||||
|
||||
# gl2ps support
|
||||
HEADERS+=3rdparty/gl2ps/gl2ps.h \
|
||||
include/qwt3d_io_gl2ps.h
|
||||
|
||||
SOURCES+=src/qwt3d_io_gl2ps.cpp \
|
||||
3rdparty/gl2ps/gl2ps.c
|
||||
|
||||
# zlib support for gl2ps
|
||||
zlib {
|
||||
DEFINES += GL2PS_HAVE_ZLIB
|
||||
win32:LIBS += zlib.lib
|
||||
unix:LIBS += -lz
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
sourcedir = 'V:\\\\cvs\\qwtplot3d\\'
|
||||
stext=""$(QTDIR)"\\bin\\"
|
||||
rtext="$(QTDIR)\\bin\\"
|
||||
|
||||
import os, string, sys
|
||||
from os.path import join, getsize
|
||||
for root, dirs, files in os.walk(sourcedir):
|
||||
for name in files:
|
||||
if '.vcproj' in name:
|
||||
f = file(join(root,name),'r')
|
||||
s = f.read()
|
||||
f.close()
|
||||
ss = string.replace(s,stext,rtext)
|
||||
f = file(join(root,name),'w+')
|
||||
f.write(ss);
|
||||
f.close();
|
@ -0,0 +1,67 @@
|
||||
import os.path
|
||||
import shutil
|
||||
import tarfile
|
||||
import zlib
|
||||
import zipfile
|
||||
from time import gmtime, strftime
|
||||
|
||||
refuseddirs = ['CVS','Debug','Release','moc','obj','tmp','data','hannes','doc','lib','bin']
|
||||
refusedfiles = ['Makefile','.cvsignore','gl2psTest.c','gl2ps.bat','gl2ps.pro']
|
||||
requiredfiles = ['qwtplot3d.dsw','examples.dsw','qwtplot3d.sln','examples.sln','thesis.tex','valgr.sh','qwtplot3d.supp','install.nsi']
|
||||
requiredfiletypes = ['pro','bat','cpp','c','h','ui','ts','png','rc','ico','py','qrc']
|
||||
srcfiletypes = ['cpp','c','h']
|
||||
|
||||
source = 'V:\\\\cvs\\porting24\\qwtplot3d\\'
|
||||
|
||||
#tstr = strftime("%y%m%d", gmtime())
|
||||
#tarname = 'V:\\\\cvs\\uploads\\' + tstr + 'plot3d.tgz'
|
||||
#zipname = 'V:\\\\cvs\\uploads\\' + tstr + 'plot3d.zip'
|
||||
|
||||
refuseddirs.append('scripts')
|
||||
tarname = 'V:\\\\cvs\\uploads\\qwtplot3d-0.2.6.tgz'
|
||||
zipname = 'V:\\\\cvs\\uploads\\qwtplot3d-0.2.6.zip'
|
||||
|
||||
|
||||
|
||||
def dos2unix(filename):
|
||||
if os.path.isdir(filename):
|
||||
print filename, "Directory!"
|
||||
return
|
||||
data = open(filename, "rb").read()
|
||||
if '\0' in data:
|
||||
print filename, "Binary!"
|
||||
return
|
||||
newdata = data.replace("\r\n", "\n")
|
||||
if newdata != data:
|
||||
print filename
|
||||
f = open(filename, "wb")
|
||||
f.write(newdata)
|
||||
f.close()
|
||||
|
||||
|
||||
def compresstree(src, tar, zip):
|
||||
names = os.listdir(src)
|
||||
|
||||
for name in names:
|
||||
srcname = os.path.join(src, name)
|
||||
if os.path.isdir(srcname):
|
||||
if name not in refuseddirs:
|
||||
compresstree(srcname,tar, zip)
|
||||
else:
|
||||
(base,ext) = os.path.splitext(name)
|
||||
ext2 = ext[1:]
|
||||
if ((ext2 in requiredfiletypes) and (name not in refusedfiles)) or (name in requiredfiles):
|
||||
zip.write(srcname, 'qwtplot3d/' + srcname[len(source):])
|
||||
if (ext2 in srcfiletypes):
|
||||
dos2unix(srcname)
|
||||
tar.add(srcname, 'qwtplot3d/' + srcname[len(source):])
|
||||
|
||||
|
||||
if os.path.exists(tarname):
|
||||
os.remove(tarname)
|
||||
|
||||
tar = tarfile.open(tarname, "w:gz")
|
||||
zip = zipfile.ZipFile(zipname, 'w', zipfile.ZIP_DEFLATED)
|
||||
compresstree(source,tar, zip)
|
||||
tar.close()
|
||||
zip.close()
|
@ -0,0 +1,36 @@
|
||||
import os.path
|
||||
import shutil
|
||||
import tarfile
|
||||
import zlib
|
||||
import zipfile
|
||||
from time import gmtime, strftime
|
||||
|
||||
refuseddirs = ['CVS','images']
|
||||
refuseddirsextra = ['CVS','small']
|
||||
|
||||
source = 'V:\\\\cvs\\porting24\\qwtplot3d\\doc\\'
|
||||
sourceim = 'V:\\\\cvs\\porting24\\qwtplot3d\\doc\\images\\'
|
||||
zipname = 'V:\\\\cvs\\uploads\\qwtplot3d-doc.zip'
|
||||
zipextraname = 'V:\\\\cvs\\uploads\\qwtplot3d-doc-extra.zip'
|
||||
|
||||
def compresstree(src, zip, refdir):
|
||||
names = os.listdir(src)
|
||||
|
||||
for name in names:
|
||||
srcname = os.path.join(src, name)
|
||||
if os.path.isdir(srcname):
|
||||
if name not in refdir:
|
||||
compresstree(srcname, zip, refdir)
|
||||
if name == 'images':
|
||||
compresstree(srcname +'\\small', zip, refdir)
|
||||
else:
|
||||
zip.write(srcname,'qwtplot3d\\doc\\' + srcname[len(source):])
|
||||
|
||||
|
||||
|
||||
zip = zipfile.ZipFile(zipname, 'w', zipfile.ZIP_DEFLATED)
|
||||
compresstree(source, zip, refuseddirs)
|
||||
zip.close()
|
||||
zip = zipfile.ZipFile(zipextraname, 'w', zipfile.ZIP_DEFLATED)
|
||||
compresstree(sourceim, zip, refuseddirsextra)
|
||||
zip.close()
|
@ -0,0 +1,17 @@
|
||||
{
|
||||
nvidia_suppression
|
||||
Addrcheck,Memcheck:Param
|
||||
ioctl(generic)
|
||||
obj:/lib/libc-2.3.2.so
|
||||
fun:NvRm*
|
||||
}
|
||||
{
|
||||
nvidia_suppression_2
|
||||
Addrcheck,Memcheck:Cond
|
||||
fun:__nvsym*
|
||||
}
|
||||
{
|
||||
nvidia_suppression_3
|
||||
Addrcheck,Memcheck:Cond
|
||||
obj:/usr/lib/opengl/nvidia/lib/libGL*
|
||||
}
|
@ -0,0 +1 @@
|
||||
valgrind --logfile=valog --suppressions=qwtplot3d.supp --error-limit=no $1
|
@ -0,0 +1,253 @@
|
||||
#include "qwt3d_helper.h"
|
||||
#include "qwt3d_autoscaler.h"
|
||||
|
||||
using namespace Qwt3D;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
double floorExt( int& exponent, double x, std::vector<double>& sortedmantissi)
|
||||
{
|
||||
if (x == 0.0)
|
||||
{
|
||||
exponent = 0;
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double sign = (x > 0) ? 1.0 : -1.0;
|
||||
double lx = log10(fabs(x));
|
||||
exponent = (int)floor(lx);
|
||||
|
||||
double fr = pow(10.0, lx - exponent);
|
||||
if (fr >= 10.0)
|
||||
{
|
||||
fr = 1.0;
|
||||
++exponent;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i=(int)sortedmantissi.size()-1; i>=0;--i)
|
||||
{
|
||||
if (fr>=sortedmantissi[i])
|
||||
{
|
||||
fr = sortedmantissi[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return sign * fr;
|
||||
}
|
||||
|
||||
/*
|
||||
\brief Find the largest value out of {1,2,5}*10^n with an integer number n
|
||||
which is smaller than or equal to x
|
||||
\param exponent n
|
||||
\param x Input value
|
||||
\return Mantissa
|
||||
*/
|
||||
double floor125( int& exponent, double x)
|
||||
{
|
||||
std::vector<double> m(2);
|
||||
m[0] = 1;
|
||||
m[1] = 2;
|
||||
m[2] = 5;
|
||||
return floorExt(exponent, x, m);
|
||||
}
|
||||
|
||||
} // anon ns
|
||||
|
||||
|
||||
//! Initializes with an {1,2,5} sequence of mantissas
|
||||
LinearAutoScaler::LinearAutoScaler()
|
||||
{
|
||||
init(0,1,1);
|
||||
mantissi_ = std::vector<double>(3);
|
||||
mantissi_[0] = 1;
|
||||
mantissi_[1] = 2;
|
||||
mantissi_[2] = 5;
|
||||
}
|
||||
//! Initialize with interval [0,1] and one requested interval
|
||||
/*!
|
||||
val mantisse A increasing ordered vector of values representing
|
||||
mantisse values between 1 and 9.
|
||||
*/
|
||||
LinearAutoScaler::LinearAutoScaler(std::vector<double>& mantisse)
|
||||
{
|
||||
init(0,1,1);
|
||||
if (mantisse.empty())
|
||||
{
|
||||
mantissi_ = std::vector<double>(3);
|
||||
mantissi_[0] = 1;
|
||||
mantissi_[1] = 2;
|
||||
mantissi_[2] = 5;
|
||||
return;
|
||||
}
|
||||
mantissi_ = mantisse;
|
||||
}
|
||||
|
||||
|
||||
//! Initialize with interval [start,stop] and number of requested intervals
|
||||
/**
|
||||
Switchs start and stop, if stop < start and sets intervals = 1 if ivals < 1
|
||||
*/
|
||||
void LinearAutoScaler::init(double start, double stop, int ivals)
|
||||
{
|
||||
start_ = start;
|
||||
stop_ = stop;
|
||||
intervals_ = ivals;
|
||||
|
||||
if (start_ > stop_)
|
||||
{
|
||||
double tmp = start_;
|
||||
start_ = stop_;
|
||||
stop_ = tmp;
|
||||
}
|
||||
if (intervals_ < 1)
|
||||
intervals_ = 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
\return Anchor value
|
||||
|
||||
\verbatim
|
||||
|_______|____________ _ _ _ _ _____|_____________|________________
|
||||
|
||||
0 m*10^n start anchor := c*m*10^n
|
||||
|
||||
c 'minimal' (anchor-start < m*10^n)
|
||||
\endverbatim
|
||||
*/
|
||||
double LinearAutoScaler::anchorvalue(double start, double m, int n)
|
||||
{
|
||||
double stepval = m * pow(10.0, n);
|
||||
return stepval * ceil(start / stepval);
|
||||
}
|
||||
|
||||
/*!
|
||||
\return New number of intervals (:= l_intervals + r_intervals)
|
||||
\param l_intervals Number of intervals left from anchor
|
||||
\param r_intervals Number of intervals right from anchor
|
||||
|
||||
\verbatim
|
||||
-l_intervals * i -2 * i -i +r_intervals * i
|
||||
|
|
||||
|______|_______ _ _ _ ____|____|___ _ _ _ _ _ _ _|_______|_______|_ _ _ _ _ _ _____|__|_____
|
||||
| | | |
|
||||
0 i := m*10^n start anchor stop
|
||||
|
||||
c 'minimal' (anchor-start < m*10^n)
|
||||
\endverbatim
|
||||
*/
|
||||
int LinearAutoScaler::segments(int& l_intervals, int& r_intervals, double start, double stop, double anchor, double m, int n)
|
||||
{
|
||||
double val = m * pow(10.0, n);
|
||||
double delta = (stop - anchor) / val;
|
||||
|
||||
r_intervals = (int)floor(delta); // right side intervals
|
||||
|
||||
delta = (anchor - start) / val;
|
||||
|
||||
l_intervals = (int)floor(delta); // left side intervals
|
||||
|
||||
return r_intervals + l_intervals;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief Does the actual scaling
|
||||
\return Number of intervals after rescaling. This will in the most cases differ
|
||||
from the requested interval number! Always >0.
|
||||
\param a Start value after scaling (always >= start)
|
||||
\param b Stop value after scaling (always <= stop)
|
||||
\param start Start value
|
||||
\param stop Stop value
|
||||
\param ivals Requested intervals
|
||||
\return Number of intervals after autoscaling
|
||||
|
||||
If the given interval has zero length the function returns the current
|
||||
interval number and a and b remain unchanged.
|
||||
*/
|
||||
int LinearAutoScaler::execute(double& a, double& b, double start, double stop, int ivals)
|
||||
{
|
||||
init(start,stop,ivals);
|
||||
|
||||
double delta = stop_ - start_;
|
||||
|
||||
if (isPracticallyZero(delta))
|
||||
return intervals_;
|
||||
|
||||
double c;
|
||||
int n;
|
||||
|
||||
c = floorExt(n, delta, mantissi_);
|
||||
|
||||
int l_ival, r_ival;
|
||||
|
||||
double anchor = anchorvalue(start_, c, n);
|
||||
int ival = segments(l_ival, r_ival, start_, stop_, anchor, c, n);
|
||||
|
||||
if (ival >= intervals_)
|
||||
{
|
||||
a = anchor - l_ival * c * pow(10.0,n);
|
||||
b = anchor + r_ival * c * pow(10.0,n);
|
||||
intervals_ = ival;
|
||||
return intervals_;
|
||||
}
|
||||
|
||||
int prev_ival, prev_l_ival, prev_r_ival;
|
||||
double prev_anchor;
|
||||
double prev_c;
|
||||
int prev_n;
|
||||
|
||||
while(1)
|
||||
{
|
||||
prev_c = c;
|
||||
prev_n = n;
|
||||
prev_anchor = anchor;
|
||||
prev_ival = ival;
|
||||
prev_l_ival = l_ival;
|
||||
prev_r_ival = r_ival;
|
||||
|
||||
|
||||
if (int(c) == 1)
|
||||
{
|
||||
c = mantissi_.back();
|
||||
--n;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int i=mantissi_.size()-1; i>0; --i)
|
||||
{
|
||||
if (int(c) == mantissi_[i])
|
||||
{
|
||||
c = mantissi_[i-1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
anchor = anchorvalue(start_, c, n);
|
||||
ival = segments(l_ival, r_ival, start_, stop_, anchor, c, n);
|
||||
|
||||
int prev_diff = intervals_ - prev_ival;
|
||||
int actual_diff = ival - intervals_;
|
||||
|
||||
if (prev_diff >= 0 && actual_diff >= 0)
|
||||
{
|
||||
if (prev_diff < actual_diff)
|
||||
{
|
||||
c = prev_c;
|
||||
n = prev_n;
|
||||
anchor = prev_anchor;
|
||||
ival = prev_ival;
|
||||
l_ival = prev_l_ival;
|
||||
r_ival = prev_r_ival;
|
||||
}
|
||||
a = anchor - l_ival * c * pow(10.0,n);
|
||||
b = anchor + r_ival * c * pow(10.0,n);
|
||||
intervals_ = ival;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return intervals_;
|
||||
}
|
@ -0,0 +1,386 @@
|
||||
#include "qwt3d_axis.h"
|
||||
|
||||
using namespace Qwt3D;
|
||||
|
||||
Axis::Axis()
|
||||
{
|
||||
init();
|
||||
};
|
||||
|
||||
Axis::~Axis()
|
||||
{
|
||||
}
|
||||
|
||||
Axis::Axis(Triple beg, Triple end)
|
||||
{
|
||||
init();
|
||||
setPosition(beg,end);
|
||||
}
|
||||
|
||||
void Axis::init()
|
||||
{
|
||||
detachAll();
|
||||
|
||||
scale_ = qwt3d_ptr<Scale>(new LinearScale);
|
||||
|
||||
beg_ = Triple(0.0, 0.0, 0.0);
|
||||
end_ = beg_;
|
||||
|
||||
majorintervals_ = 0;
|
||||
minorintervals_ = 0;
|
||||
setMajors(1);
|
||||
setMinors(1);
|
||||
setLimits(0,0);
|
||||
|
||||
setTicOrientation(0.0, 0.0, 0.0);
|
||||
setTicLength(0.0, 0.0);
|
||||
setColor(0.0, 0.0, 0.0);
|
||||
setLineWidth(1.0);
|
||||
symtics_ = false;
|
||||
drawNumbers_ = false;
|
||||
drawLabel_ = false;
|
||||
|
||||
drawTics_ = false;
|
||||
autoscale_ = true;
|
||||
markerLabel_.clear();
|
||||
numberfont_ = QFont("Courier",12);
|
||||
setLabelFont(QFont("Courier",14));
|
||||
|
||||
numbercolor_ = RGBA(0,0,0,0);
|
||||
|
||||
setNumberAnchor(Center);
|
||||
|
||||
numbergap_ = 0;
|
||||
labelgap_ = 0;
|
||||
}
|
||||
|
||||
void Axis::setPosition(const Triple& beg, const Triple& end)
|
||||
{
|
||||
beg_ = beg;
|
||||
end_ = end;
|
||||
}
|
||||
|
||||
void Axis::setMajors(int val)
|
||||
{
|
||||
if (val == majorintervals_)
|
||||
return;
|
||||
|
||||
majorintervals_ = (val<=0) ? 1 : val; // always >= 1
|
||||
}
|
||||
|
||||
/*!
|
||||
\see LogScale::setMinors().
|
||||
*/
|
||||
void Axis::setMinors(int val)
|
||||
{
|
||||
if (val == minorintervals_)
|
||||
return;
|
||||
|
||||
minorintervals_ = (val<=0) ? 1 : val; // always >= 1
|
||||
}
|
||||
|
||||
void Axis::setTicLength(double majorl, double minorl)
|
||||
{
|
||||
lmaj_ = majorl;
|
||||
lmin_ = minorl;
|
||||
}
|
||||
|
||||
void Axis::setTicOrientation(double tx, double ty, double tz)
|
||||
{
|
||||
setTicOrientation(Triple(tx,ty,tz));
|
||||
}
|
||||
|
||||
void Axis::setTicOrientation(const Triple& val)
|
||||
{
|
||||
orientation_ = val;
|
||||
orientation_.normalize();
|
||||
}
|
||||
|
||||
/**
|
||||
\param val thickness for axis base line
|
||||
\param majfac relative thickness for axis major tics (majfac*val)
|
||||
\param minfac relative thickness for axis minor tics (minfac*val)
|
||||
*/
|
||||
void Axis::setLineWidth(double val, double majfac, double minfac)
|
||||
{
|
||||
lineWidth_ = val;
|
||||
majLineWidth_ = majfac * lineWidth_;
|
||||
minLineWidth_ = minfac * lineWidth_;
|
||||
}
|
||||
|
||||
void Axis::draw()
|
||||
{
|
||||
Drawable::draw();
|
||||
|
||||
saveGLState();
|
||||
|
||||
// GLStateBewarer sb(GL_LINE_SMOOTH, true);
|
||||
// glBlendFunc(GL_ONE, GL_ZERO);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glColor4d(color.r,color.g,color.b,color.a);
|
||||
|
||||
drawBase();
|
||||
drawTics();
|
||||
drawLabel();
|
||||
|
||||
restoreGLState();
|
||||
}
|
||||
|
||||
/**
|
||||
Always use AFTER drawNumbers() ! (Needs length of number string)
|
||||
*/
|
||||
void Axis::drawLabel()
|
||||
{
|
||||
if (!drawLabel_)
|
||||
return;
|
||||
|
||||
Triple diff = end() - begin();
|
||||
Triple center = begin() + diff/2;
|
||||
|
||||
Triple bnumber = biggestNumberString();
|
||||
// double fac = 6*(second()-first()).length() / 100;
|
||||
|
||||
switch (scaleNumberAnchor_)
|
||||
{
|
||||
case BottomLeft:
|
||||
case TopLeft:
|
||||
case CenterLeft:
|
||||
bnumber.y = 0;
|
||||
break;
|
||||
case BottomRight:
|
||||
case TopRight:
|
||||
case CenterRight:
|
||||
bnumber.x = -bnumber.x;
|
||||
bnumber.y = 0;
|
||||
break;
|
||||
case TopCenter:
|
||||
bnumber.x = 0;
|
||||
bnumber.y = -bnumber.y;
|
||||
break;
|
||||
case BottomCenter:
|
||||
bnumber.x = 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Triple pos = ViewPort2World(World2ViewPort(center + ticOrientation() * lmaj_) + bnumber);
|
||||
setLabelPosition(pos, scaleNumberAnchor_);
|
||||
|
||||
label_.adjust(labelgap_);
|
||||
label_.draw();
|
||||
}
|
||||
|
||||
void Axis::drawBase()
|
||||
{
|
||||
setDeviceLineWidth( lineWidth_ );
|
||||
glBegin( GL_LINES );
|
||||
glVertex3d( beg_.x, beg_.y, beg_.z);
|
||||
glVertex3d( end_.x, end_.y, end_.z);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
bool Axis::prepTicCalculation(Triple& startpoint)
|
||||
{
|
||||
if (isPracticallyZero(start_, stop_))
|
||||
return false;
|
||||
|
||||
autostart_ = start_;
|
||||
autostop_ = stop_;
|
||||
|
||||
if (autoScale())
|
||||
{
|
||||
setMajors(scale_->autoscale(autostart_, autostop_, start_, stop_, majors()));
|
||||
if (isPracticallyZero(autostart_, autostop_))
|
||||
return false;
|
||||
}
|
||||
|
||||
scale_->setLimits(start_,stop_);
|
||||
scale_->setMajors(majors());
|
||||
scale_->setMinors(minors());
|
||||
scale_->setMajorLimits(autostart_,autostop_);
|
||||
scale_->calculate();
|
||||
|
||||
Triple normal = (end_ - beg_);
|
||||
//normal.normalize();
|
||||
Triple beg = beg_ + ((autostart_ - start_) / (stop_ - start_)) * normal;
|
||||
Triple end = end_ - ((stop_ - autostop_) / (stop_ - start_))* normal;
|
||||
|
||||
startpoint = end_ - beg_;
|
||||
|
||||
majorpos_.clear();
|
||||
minorpos_.clear();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Axis::recalculateTics()
|
||||
{
|
||||
Triple runningpoint;
|
||||
if (false==prepTicCalculation(runningpoint))
|
||||
return;
|
||||
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i != scale_->majors_p.size(); ++i)
|
||||
{
|
||||
double t = (scale_->majors_p[i] - start_) / (stop_-start_);
|
||||
majorpos_.push_back(beg_ + t * runningpoint);
|
||||
}
|
||||
for (i = 0; i != scale_->minors_p.size(); ++i)
|
||||
{
|
||||
double t = (scale_->minors_p[i] - start_) / (stop_-start_);
|
||||
minorpos_.push_back(beg_ + t * runningpoint);
|
||||
}
|
||||
}
|
||||
|
||||
void Axis::drawTics()
|
||||
{
|
||||
Triple runningpoint;
|
||||
if (!drawTics_ || false==prepTicCalculation(runningpoint))
|
||||
return;
|
||||
|
||||
unsigned int i;
|
||||
Triple nadir;
|
||||
|
||||
markerLabel_.resize(scale_->majors_p.size());
|
||||
setDeviceLineWidth(majLineWidth_);
|
||||
for (i = 0; i != scale_->majors_p.size(); ++i)
|
||||
{
|
||||
double t = (scale_->majors_p[i] - start_) / (stop_-start_);
|
||||
nadir = beg_ + t * runningpoint;
|
||||
majorpos_.push_back(drawTic(nadir, lmaj_));
|
||||
drawTicLabel(nadir + 1.2 * lmaj_ * orientation_, i);
|
||||
}
|
||||
setDeviceLineWidth(minLineWidth_);
|
||||
for (i = 0; i != scale_->minors_p.size(); ++i)
|
||||
{
|
||||
double t = (scale_->minors_p[i] - start_) / (stop_-start_);
|
||||
nadir = beg_ + t * runningpoint;
|
||||
minorpos_.push_back(drawTic(nadir, lmin_));
|
||||
}
|
||||
}
|
||||
|
||||
void Axis::drawTicLabel(Triple pos, int mtic)
|
||||
{
|
||||
if (!drawNumbers_ || (mtic < 0))
|
||||
return;
|
||||
|
||||
markerLabel_[mtic].setFont(numberfont_.family(), numberfont_.pointSize(), numberfont_.weight(), numberfont_.italic());
|
||||
markerLabel_[mtic].setColor(numbercolor_);
|
||||
markerLabel_[mtic].setString(scale_->ticLabel(mtic));
|
||||
markerLabel_[mtic].setPosition(pos, scaleNumberAnchor_);
|
||||
markerLabel_[mtic].adjust(numbergap_);
|
||||
markerLabel_[mtic].draw();
|
||||
}
|
||||
|
||||
Triple Axis::drawTic(Triple nadir, double length)
|
||||
{
|
||||
double ilength = (symtics_) ? -length : 0.0;
|
||||
|
||||
glBegin( GL_LINES );
|
||||
glVertex3d( nadir.x + ilength * orientation_.x,
|
||||
nadir.y + ilength * orientation_.y,
|
||||
nadir.z + ilength * orientation_.z) ;
|
||||
glVertex3d( nadir.x + length * orientation_.x,
|
||||
nadir.y + length * orientation_.y,
|
||||
nadir.z + length * orientation_.z);
|
||||
glEnd();
|
||||
return nadir;
|
||||
}
|
||||
|
||||
void Axis::setNumberFont(QString const& family, int pointSize, int weight, bool italic)
|
||||
{
|
||||
numberfont_ = QFont(family, pointSize, weight, italic );
|
||||
}
|
||||
|
||||
void Axis::setNumberFont(QFont const& font)
|
||||
{
|
||||
numberfont_ = font;
|
||||
}
|
||||
|
||||
void Axis::setNumberColor(RGBA col)
|
||||
{
|
||||
numbercolor_ = col;
|
||||
}
|
||||
|
||||
void Axis::setLabelFont(QString const& family, int pointSize, int weight, bool italic)
|
||||
{
|
||||
labelfont_ = QFont(family, pointSize, weight, italic );
|
||||
label_.setFont(family, pointSize, weight, italic);
|
||||
}
|
||||
|
||||
void Axis::setLabelFont(QFont const& font)
|
||||
{
|
||||
setLabelFont(font.family(), font.pointSize(), font.weight(), font.italic());
|
||||
}
|
||||
|
||||
void Axis::setLabelString(QString const& name)
|
||||
{
|
||||
label_.setString(name);
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets label position in conjunction with an anchoring strategy
|
||||
*/
|
||||
void Axis::setLabelPosition(const Triple& pos,Qwt3D::ANCHOR an)
|
||||
{
|
||||
label_.setPosition(pos, an);
|
||||
}
|
||||
|
||||
//! Sets color for label
|
||||
void Axis::setLabelColor(RGBA col)
|
||||
{
|
||||
label_.setColor(col);
|
||||
}
|
||||
|
||||
Triple Axis::biggestNumberString()
|
||||
{
|
||||
Triple ret;
|
||||
unsigned size = markerLabel_.size();
|
||||
|
||||
double width, height;
|
||||
|
||||
for (unsigned i=0; i!=size; ++i)
|
||||
{
|
||||
width = fabs( (World2ViewPort(markerLabel_[i].second())-World2ViewPort(markerLabel_[i].first())).x );
|
||||
height = fabs( (World2ViewPort(markerLabel_[i].second())-World2ViewPort(markerLabel_[i].first())).y );
|
||||
|
||||
if (width > ret.x)
|
||||
ret.x = width + markerLabel_[i].gap();
|
||||
if (height > ret.y)
|
||||
ret.y = height + markerLabel_[i].gap();;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*!
|
||||
This variant sets a user-defined scale object.
|
||||
Use with a heap based initialized pointer only.
|
||||
The axis adopts ownership.
|
||||
*/
|
||||
void Axis::setScale(Scale* val)
|
||||
{
|
||||
scale_ = qwt3d_ptr<Scale>(val);
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets one of the predefined scaling types.
|
||||
\warning Too small intervals in logarithmic scales lead to
|
||||
empty scales (or perhaps a scale only containing an isolated
|
||||
major tic). Better switch to linear scales in such cases.
|
||||
*/
|
||||
void Axis::setScale(Qwt3D::SCALETYPE val)
|
||||
{
|
||||
switch(val) {
|
||||
case Qwt3D::LINEARSCALE:
|
||||
setScale(new LinearScale);
|
||||
break;
|
||||
case Qwt3D::LOG10SCALE:
|
||||
setScale(new LogScale);
|
||||
setMinors(9);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
#include "qwt3d_color.h"
|
||||
#include "qwt3d_plot.h"
|
||||
|
||||
using namespace Qwt3D;
|
||||
|
||||
StandardColor::StandardColor(Plot3D* data, unsigned size)
|
||||
: data_(data)
|
||||
{
|
||||
Q_ASSERT(data_);
|
||||
|
||||
reset(size);
|
||||
}
|
||||
|
||||
void StandardColor::reset(unsigned size)
|
||||
{
|
||||
colors_ = ColorVector(size);
|
||||
RGBA elem;
|
||||
|
||||
double dsize = size;
|
||||
|
||||
for (unsigned int i=0; i!=size; ++i)
|
||||
{
|
||||
elem.r = i / dsize;
|
||||
elem.g = i / dsize / 4;
|
||||
elem.b = 1 - i/dsize;
|
||||
elem.a = 1.0;
|
||||
colors_[i] = elem;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Assigns a new ColorVector (Also overwrites the constructors size argument)
|
||||
*/
|
||||
void StandardColor::setColorVector(ColorVector const& cv)
|
||||
{
|
||||
colors_ = cv;
|
||||
}
|
||||
|
||||
void StandardColor::setAlpha(double a)
|
||||
{
|
||||
if (a<0 || a>1)
|
||||
return;
|
||||
|
||||
RGBA elem;
|
||||
|
||||
for (unsigned int i=0; i!=colors_.size(); ++i)
|
||||
{
|
||||
elem = colors_[i];
|
||||
elem.a = a;
|
||||
colors_[i] = elem;
|
||||
}
|
||||
}
|
||||
|
||||
RGBA StandardColor::operator()(double, double, double z) const
|
||||
{
|
||||
Q_ASSERT(data_);
|
||||
int index = (int)((colors_.size()-1) * (z - data_->hull().minVertex.z) / (data_->hull().maxVertex.z-data_->hull().minVertex.z));
|
||||
if (index < 0)
|
||||
index = 0;
|
||||
if ((unsigned int)index > colors_.size() - 1)
|
||||
index = (int)(colors_.size() - 1);
|
||||
return colors_[index];
|
||||
}
|
@ -0,0 +1,223 @@
|
||||
#if defined(_MSC_VER) /* MSVC Compiler */
|
||||
#pragma warning ( disable : 4305 )
|
||||
#endif
|
||||
|
||||
#include "qwt3d_colorlegend.h"
|
||||
|
||||
using namespace Qwt3D;
|
||||
|
||||
/**
|
||||
Contructs a legend object with an axis at the left
|
||||
side. The legend resides in the top-right area
|
||||
and has no caption. Scale numbering is shown.
|
||||
*/
|
||||
ColorLegend::ColorLegend()
|
||||
{
|
||||
axis_.setNumbers(true);
|
||||
axis_.setScaling(true);
|
||||
axis_.setNumberColor(RGBA(0,0,0,1));
|
||||
axis_.setNumberAnchor(CenterRight);
|
||||
axis_.setNumberFont(QFont("Courier",8));
|
||||
|
||||
caption_.setFont("Courier", 10, QFont::Bold);
|
||||
caption_.setColor(RGBA(0,0,0,1));
|
||||
axisposition_ = ColorLegend::Left;
|
||||
orientation_ = ColorLegend::BottomTop;
|
||||
showaxis_ = true;
|
||||
setRelPosition(Tuple(0.94, 1-0.36),Tuple(0.97, 1-0.04));
|
||||
}
|
||||
|
||||
void ColorLegend::setTitleString(QString const& s)
|
||||
{
|
||||
caption_.setString(s);
|
||||
}
|
||||
|
||||
void ColorLegend::setTitleFont(QString const& family, int pointSize, int weight, bool italic)
|
||||
{
|
||||
caption_.setFont(family, pointSize, weight, italic);
|
||||
}
|
||||
|
||||
void ColorLegend::setLimits(double start, double stop)
|
||||
{
|
||||
axis_.setLimits(start, stop);
|
||||
}
|
||||
|
||||
void ColorLegend::setMajors(int majors)
|
||||
{
|
||||
axis_.setMajors(majors);
|
||||
}
|
||||
|
||||
void ColorLegend::setMinors(int minors)
|
||||
{
|
||||
axis_.setMinors(minors);
|
||||
}
|
||||
|
||||
void ColorLegend::setAutoScale(bool val)
|
||||
{
|
||||
axis_.setAutoScale(val);
|
||||
}
|
||||
|
||||
void ColorLegend::setScale(SCALETYPE val)
|
||||
{
|
||||
axis_.setScale(val);
|
||||
}
|
||||
|
||||
void ColorLegend::setScale(Scale* val)
|
||||
{
|
||||
axis_.setScale(val);
|
||||
}
|
||||
|
||||
|
||||
void ColorLegend::setOrientation(ORIENTATION orientation, SCALEPOSITION pos)
|
||||
{
|
||||
orientation_ = orientation;
|
||||
axisposition_ = pos;
|
||||
|
||||
if (orientation_==BottomTop)
|
||||
{
|
||||
if (axisposition_ == Bottom || axisposition_ == Top)
|
||||
axisposition_ = Left;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (axisposition_ == Left || axisposition_ == Right)
|
||||
axisposition_ = Bottom;
|
||||
}
|
||||
}
|
||||
|
||||
void ColorLegend::setRelPosition(Tuple relMin, Tuple relMax)
|
||||
{
|
||||
relMin_ = relMin;
|
||||
relMax_ = relMax;
|
||||
}
|
||||
|
||||
void ColorLegend::setGeometryInternal()
|
||||
{
|
||||
double ot = .99;
|
||||
|
||||
getMatrices(modelMatrix, projMatrix, viewport);
|
||||
pe_.minVertex = relativePosition(Triple(relMin_.x, relMin_.y, ot));
|
||||
pe_.maxVertex = relativePosition(Triple(relMax_.x, relMax_.y, ot));
|
||||
|
||||
double diff = 0;
|
||||
Triple b;
|
||||
Triple e;
|
||||
|
||||
switch (axisposition_)
|
||||
{
|
||||
case ColorLegend::Left:
|
||||
b = pe_.minVertex;
|
||||
e = pe_.maxVertex; e.x = b.x;
|
||||
axis_.setTicOrientation(-1,0,0);
|
||||
axis_.setNumberAnchor(CenterRight);
|
||||
diff = pe_.maxVertex.x - pe_.minVertex.x;
|
||||
break;
|
||||
case ColorLegend::Right:
|
||||
e = pe_.maxVertex;
|
||||
b = pe_.minVertex; b.x = e.x;
|
||||
axis_.setTicOrientation(+1,0,0);
|
||||
axis_.setNumberAnchor(CenterLeft);
|
||||
diff = pe_.maxVertex.x - pe_.minVertex.x;
|
||||
break;
|
||||
case ColorLegend::Top:
|
||||
e = pe_.maxVertex;
|
||||
b = pe_.minVertex; b.z = e.z;
|
||||
axis_.setTicOrientation(0,0,+1);
|
||||
axis_.setNumberAnchor(BottomCenter);
|
||||
diff = pe_.maxVertex.z - pe_.minVertex.z;
|
||||
break;
|
||||
case ColorLegend::Bottom:
|
||||
b = pe_.minVertex;
|
||||
e = pe_.maxVertex; e.z = b.z;
|
||||
axis_.setTicOrientation(0,0,-1);
|
||||
axis_.setNumberAnchor(TopCenter);
|
||||
diff = pe_.maxVertex.z - pe_.minVertex.z;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
axis_.setPosition(b,e);
|
||||
diff /= 10;
|
||||
|
||||
axis_.setTicLength(diff, 0.6*diff);
|
||||
|
||||
Triple c;
|
||||
c.x = pe_.minVertex.x + ((pe_.maxVertex-pe_.minVertex) / 2).x;
|
||||
c.z = pe_.maxVertex.z;
|
||||
c.z += (pe_.maxVertex.z-pe_.minVertex.z)/20;
|
||||
c.y = pe_.maxVertex.y;
|
||||
|
||||
caption_.setPosition(c, BottomCenter);
|
||||
}
|
||||
|
||||
void ColorLegend::draw()
|
||||
{
|
||||
if (colors.empty())
|
||||
return;
|
||||
|
||||
setGeometryInternal();
|
||||
|
||||
saveGLState();
|
||||
|
||||
Triple one = pe_.minVertex;
|
||||
Triple two = pe_.maxVertex;
|
||||
|
||||
double h = (orientation_ == ColorLegend::BottomTop)
|
||||
? (two-one).z / colors.size()
|
||||
: (two-one).x / colors.size();
|
||||
|
||||
//glEnable(GL_DEPTH_TEST);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
GLStateBewarer(GL_POLYGON_OFFSET_FILL,true);
|
||||
// glPolygonOffset(0.0, 0.0);
|
||||
|
||||
glColor4d(0, 0, 0, 1);
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glVertex3d(one.x, one.y, one.z);
|
||||
glVertex3d(one.x, one.y, two.z);
|
||||
glVertex3d(two.x, one.y, two.z);
|
||||
glVertex3d(two.x, one.y, one.z);
|
||||
glEnd();
|
||||
|
||||
|
||||
unsigned size = colors.size();
|
||||
RGBA rgb;
|
||||
|
||||
if (orientation_ == ColorLegend::BottomTop)
|
||||
{
|
||||
for (unsigned i=1; i<=size; ++i)
|
||||
{
|
||||
rgb = colors[i-1];
|
||||
glColor4d(rgb.r,rgb.g,rgb.b,rgb.a);
|
||||
glBegin( GL_POLYGON );
|
||||
glVertex3d( one.x, one.y, one.z+(i-1)*h );
|
||||
glVertex3d( one.x, one.y, one.z+i*h );
|
||||
glVertex3d( two.x, one.y, one.z+i*h );
|
||||
glVertex3d( two.x, one.y, one.z+(i-1)*h );
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned i=1; i<=size; ++i)
|
||||
{
|
||||
rgb = colors[i-1];
|
||||
glColor4d(rgb.r,rgb.g,rgb.b,rgb.a);
|
||||
glBegin( GL_POLYGON );
|
||||
glVertex3d( one.x+(i-1)*h, one.y, one.z );
|
||||
glVertex3d( one.x+i*h, one.y, one.z );
|
||||
glVertex3d( one.x+i*h, one.y, two.z );
|
||||
glVertex3d( one.x+(i-1)*h, one.y, two.z );
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
restoreGLState();
|
||||
|
||||
if (showaxis_)
|
||||
axis_.draw();
|
||||
|
||||
caption_.draw();
|
||||
}
|
@ -0,0 +1,633 @@
|
||||
#include "qwt3d_coordsys.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace Qwt3D;
|
||||
|
||||
|
||||
CoordinateSystem::CoordinateSystem(Triple first, Triple second, COORDSTYLE st)
|
||||
{
|
||||
autodecoration_ = true;
|
||||
axes = std::vector<Axis>(12);
|
||||
setStyle(st);
|
||||
setLineSmooth(true);
|
||||
init(first,second);
|
||||
|
||||
setAxesColor(RGBA(0,0,0,1));
|
||||
setGridLinesColor(RGBA(0.2,0.2,0.2,1));
|
||||
setNumberFont("Courier", 12);
|
||||
setNumberColor(RGBA(0,0,0));
|
||||
setLabelFont("Courier", 14, QFont::Bold);
|
||||
setGridLines(false, false);
|
||||
}
|
||||
|
||||
CoordinateSystem::~CoordinateSystem()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
void CoordinateSystem::destroy()
|
||||
{
|
||||
for (unsigned i=0; i!=axes.size(); ++i)
|
||||
axes[i].setLabelString("");
|
||||
|
||||
detachAll();
|
||||
}
|
||||
|
||||
void CoordinateSystem::init(Triple first, Triple second)
|
||||
{
|
||||
destroy();
|
||||
|
||||
for (unsigned i=0; i!=axes.size(); ++i)
|
||||
axes[i].setScale(LINEARSCALE);
|
||||
|
||||
Triple dv = second - first;
|
||||
|
||||
setPosition(first, second);
|
||||
|
||||
double majl = dv.length() / 100; // 1 %
|
||||
setTicLength(majl, 0.6 * majl);
|
||||
|
||||
axes[X1].setPosition(first, first+Triple(dv.x, 0, 0)); // front bottom x
|
||||
axes[Y1].setPosition(first, first+Triple( 0, dv.y, 0)); // bottom left y
|
||||
axes[Z1].setPosition (first+Triple( 0, dv.y, 0), first+Triple( 0, dv.y, dv.z)); // back left z
|
||||
axes[X1].setTicOrientation(0,-1,0);
|
||||
axes[Y1].setTicOrientation(-1,0,0);
|
||||
axes[Z1].setTicOrientation(-1,0,0);
|
||||
|
||||
axes[X1].setLimits(first.x, second.x);
|
||||
axes[X2].setLimits(first.x, second.x);
|
||||
axes[X3].setLimits(first.x, second.x);
|
||||
axes[X4].setLimits(first.x, second.x);
|
||||
|
||||
axes[Y1].setLimits(first.y, second.y);
|
||||
axes[Y2].setLimits(first.y, second.y);
|
||||
axes[Y3].setLimits(first.y, second.y);
|
||||
axes[Y4].setLimits(first.y, second.y);
|
||||
|
||||
axes[Z1].setLimits(first.z, second.z);
|
||||
axes[Z2].setLimits(first.z, second.z);
|
||||
axes[Z3].setLimits(first.z, second.z);
|
||||
axes[Z4].setLimits(first.z, second.z);
|
||||
|
||||
// remaining x axes
|
||||
axes[X2].setPosition(first+Triple( 0, 0, dv.z), first+Triple( dv.x, 0, dv.z)); // front top x
|
||||
axes[X3].setPosition(first+Triple( 0, dv.y, dv.z), second); // back top x
|
||||
axes[X4].setPosition(first+Triple( 0, dv.y, 0), first+Triple( dv.x, dv.y, 0)); // back bottom x
|
||||
axes[X2].setTicOrientation(0,-1,0);
|
||||
axes[X3].setTicOrientation(0,1,0);
|
||||
axes[X4].setTicOrientation(0,1,0);
|
||||
|
||||
// remaining y axes
|
||||
axes[Y2].setPosition(first+Triple(dv.x, 0, 0), first+Triple(dv.x, dv.y, 0)); // bottom right y
|
||||
axes[Y3].setPosition(first+Triple(dv.x, 0, dv.z), second); // top right y
|
||||
axes[Y4].setPosition(first+Triple(0, 0, dv.z), first+Triple(0, dv.y, dv.z)); // top left y
|
||||
axes[Y2].setTicOrientation(1,0,0);
|
||||
axes[Y3].setTicOrientation(1,0,0);
|
||||
axes[Y4].setTicOrientation (-1,0,0);
|
||||
|
||||
// remaining z axes
|
||||
axes[Z2].setPosition(first, first+Triple( 0, 0, dv.z)); // front left z
|
||||
axes[Z4].setPosition(first+Triple(dv.x, dv.y, 0), second ); // back right z
|
||||
axes[Z3].setPosition(first+Triple(dv.x, 0, 0), first+Triple(dv.x, 0, dv.z)); // front right z
|
||||
axes[Z2].setTicOrientation(-1,0,0);
|
||||
axes[Z4].setTicOrientation(1,0,0);
|
||||
axes[Z3].setTicOrientation(1,0,0);
|
||||
|
||||
setStyle(style_);
|
||||
}
|
||||
|
||||
void CoordinateSystem::draw()
|
||||
{
|
||||
// saveGLState();
|
||||
|
||||
GLStateBewarer sb(GL_LINE_SMOOTH, true);
|
||||
|
||||
if (!lineSmooth())
|
||||
sb.turnOff();
|
||||
|
||||
|
||||
if (autoDecoration())
|
||||
chooseAxes();
|
||||
|
||||
Drawable::draw();
|
||||
|
||||
if( style_ == NOCOORD)
|
||||
return;
|
||||
|
||||
if (majorgridlines_ || minorgridlines_)
|
||||
recalculateAxesTics();
|
||||
if (majorgridlines_)
|
||||
drawMajorGridLines();
|
||||
if (minorgridlines_)
|
||||
drawMinorGridLines();
|
||||
|
||||
// restoreGLState();
|
||||
}
|
||||
|
||||
|
||||
//! build convex hull (6 axes: 2 x, 2 y, 2 z) and choose one of them at a time for scales, labels etc.
|
||||
void CoordinateSystem::chooseAxes()
|
||||
{
|
||||
vector<Triple> beg(axes.size());
|
||||
vector<Triple> end(axes.size());
|
||||
vector<Tuple> src(2*axes.size());
|
||||
|
||||
unsigned i;
|
||||
// collect axes viewport coordinates and initialize
|
||||
for (i=0; i!=axes.size(); ++i)
|
||||
{
|
||||
if (style() != NOCOORD)
|
||||
attach(&axes[i]);
|
||||
|
||||
beg[i] = World2ViewPort(axes[i].begin());
|
||||
end[i] = World2ViewPort(axes[i].end());
|
||||
src[i] = Tuple(beg[i].x, beg[i].y);
|
||||
src[axes.size()+i] = Tuple(end[i].x, end[i].y);
|
||||
|
||||
axes[i].setScaling(false);
|
||||
axes[i].setNumbers(false);
|
||||
axes[i].setLabel(false);
|
||||
}
|
||||
|
||||
vector<unsigned> idx;
|
||||
convexhull2d(idx,src);
|
||||
|
||||
int rem_x = -1;
|
||||
int rem_y = -1;
|
||||
int rem_z = -1;
|
||||
|
||||
|
||||
bool left;
|
||||
|
||||
int choice_x = -1;
|
||||
int choice_y = -1;
|
||||
int choice_z = -1;
|
||||
|
||||
int other_x = -1;
|
||||
int other_y = -1;
|
||||
int other_z = -1;
|
||||
|
||||
//traverse convex hull
|
||||
for (unsigned k=0; k!=idx.size(); ++k)
|
||||
{
|
||||
Triple one, two;
|
||||
|
||||
if (idx[k] >= axes.size()) // is end point
|
||||
one = end[idx[k]-axes.size()];
|
||||
else // is begin point
|
||||
one = beg[idx[k]];
|
||||
|
||||
unsigned int next = idx[(k+1) % idx.size()]; // next point in cv (considered as ring buffer of points)
|
||||
|
||||
if (next >= axes.size())
|
||||
two = end[next-axes.size()];
|
||||
else
|
||||
two = beg[next];
|
||||
|
||||
for (i=0; i!=axes.size(); ++i)
|
||||
{
|
||||
if (
|
||||
(one == beg[i] && two == end[i])
|
||||
||
|
||||
(two == beg[i] && one == end[i])
|
||||
)
|
||||
{
|
||||
if (i==X1 || i==X2 || i==X3 || i==X4) // x Achsen
|
||||
{
|
||||
if (rem_x>=0) // schon zweite Achse der konvexen Huelle ?
|
||||
{
|
||||
// untere der beiden x Achsen
|
||||
double y = min(min(end[rem_x].y,end[i].y),min(beg[rem_x].y,beg[i].y));
|
||||
choice_x = (y == beg[i].y || y == end[i].y) ? i : rem_x;
|
||||
|
||||
other_x = (choice_x == (int)i) ? rem_x : (int)i;
|
||||
left = (beg[choice_x].x < beg[other_x].x || end[choice_x].x < end[other_x].x)
|
||||
? true
|
||||
: false;
|
||||
|
||||
autoDecorateExposedAxis(axes[choice_x], left);
|
||||
|
||||
rem_x = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
rem_x = i;
|
||||
}
|
||||
}
|
||||
else if (i==Y1 || i==Y2 || i==Y3 || i==Y4)
|
||||
{
|
||||
if (rem_y>=0)
|
||||
{
|
||||
// untere der beiden y Achsen
|
||||
double y = min(min(end[rem_y].y,end[i].y),min(beg[rem_y].y,beg[i].y));
|
||||
choice_y = (y == beg[i].y || y == end[i].y) ? i : rem_y;
|
||||
|
||||
other_y = (choice_y == (int)i) ? rem_y : (int)i;
|
||||
left = (beg[choice_y].x < beg[other_y].x || end[choice_y].x < end[other_y].x)
|
||||
? true
|
||||
: false;
|
||||
autoDecorateExposedAxis(axes[choice_y], left);
|
||||
|
||||
rem_y = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
rem_y = i;
|
||||
}
|
||||
}
|
||||
else if (i==Z1 || i==Z2 || i==Z3 || i==Z4)
|
||||
{
|
||||
if (rem_z>=0)
|
||||
{
|
||||
// hintere der beiden z Achsen
|
||||
double z = max(max(end[rem_z].z,end[i].z),max(beg[rem_z].z,beg[i].z));
|
||||
choice_z = (z == beg[i].z || z == end[i].z) ? i : rem_z;
|
||||
|
||||
other_z = (choice_z == (int)i) ? rem_z : (int)i;
|
||||
|
||||
rem_z = -1;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
rem_z = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // for axes
|
||||
} // for idx
|
||||
|
||||
// fit z axis in - the onthewall axis if the decorated axes build a continous line, the opposite else
|
||||
if (choice_x>=0 && choice_y>=0 && choice_z>=0)
|
||||
{
|
||||
left = (beg[choice_z].x < beg[other_z].x || end[choice_z].x < end[other_z].x)
|
||||
? true
|
||||
: false;
|
||||
|
||||
|
||||
if (
|
||||
axes[choice_z].begin() == axes[choice_x].begin()
|
||||
|| axes[choice_z].begin() == axes[choice_x].end()
|
||||
|| axes[choice_z].begin() == axes[choice_y].begin()
|
||||
|| axes[choice_z].begin() == axes[choice_y].end()
|
||||
|| axes[choice_z].end() == axes[choice_x].begin()
|
||||
|| axes[choice_z].end() == axes[choice_x].end()
|
||||
|| axes[choice_z].end() == axes[choice_y].begin()
|
||||
|| axes[choice_z].end() == axes[choice_y].end()
|
||||
|
||||
)
|
||||
{
|
||||
autoDecorateExposedAxis(axes[choice_z], left);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
autoDecorateExposedAxis(axes[other_z], !left);
|
||||
choice_z = other_z; // for FRAME
|
||||
}
|
||||
}
|
||||
|
||||
if (style() == FRAME)
|
||||
{
|
||||
for (i=0; i!=axes.size(); ++i)
|
||||
{
|
||||
if ((int)i!=choice_x && (int)i!=choice_y && (int)i!=choice_z)
|
||||
detach(&axes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CoordinateSystem::autoDecorateExposedAxis(Axis& ax, bool left)
|
||||
{
|
||||
Triple diff = World2ViewPort(ax.end()) - World2ViewPort(ax.begin());
|
||||
|
||||
diff = Triple(diff.x,diff.y,0); // projection
|
||||
|
||||
double s = diff.length();
|
||||
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
ax.setScaling(true);
|
||||
ax.setNumbers(true);
|
||||
ax.setLabel(true);
|
||||
|
||||
const double SQRT_2 = 0.7071067;
|
||||
double sina = fabs(diff.y / s);
|
||||
|
||||
|
||||
if (left) // leftmost (compared with antagonist in CV) axis -> draw decorations on the left side
|
||||
{
|
||||
if ( diff.x >= 0 && diff.y >= 0 && sina < SQRT_2) // 0..Pi/4
|
||||
{
|
||||
ax.setNumberAnchor(BottomCenter);
|
||||
}
|
||||
else if ( diff.x >= 0 && diff.y >= 0 && !left) // octant 2
|
||||
{
|
||||
ax.setNumberAnchor(CenterRight);
|
||||
}
|
||||
else if ( diff.x <= 0 && diff.y >= 0 && sina >= SQRT_2) // octant 3
|
||||
{
|
||||
ax.setNumberAnchor(CenterRight);
|
||||
}
|
||||
else if ( diff.x <= 0 && diff.y >= 0 ) // octant 4
|
||||
{
|
||||
ax.setNumberAnchor(TopCenter);
|
||||
}
|
||||
else if ( diff.x <= 0 && diff.y <= 0 && sina <= SQRT_2) // octant 5
|
||||
{
|
||||
ax.setNumberAnchor(BottomCenter);
|
||||
}
|
||||
else if ( diff.x <= 0 && diff.y <= 0) // octant 6
|
||||
{
|
||||
ax.setNumberAnchor(CenterRight);
|
||||
}
|
||||
else if ( diff.x >= 0 && diff.y <= 0 && sina >= SQRT_2) // octant 7
|
||||
{
|
||||
ax.setNumberAnchor(CenterRight);
|
||||
}
|
||||
else if ( diff.x >= 0 && diff.y <= 0) // octant 8
|
||||
{
|
||||
ax.setNumberAnchor(TopCenter);
|
||||
}
|
||||
}
|
||||
else // rightmost axis
|
||||
{
|
||||
if ( diff.x >= 0 && diff.y >= 0 && sina <= SQRT_2)
|
||||
{
|
||||
ax.setNumberAnchor(TopCenter);
|
||||
}
|
||||
else if ( diff.x >= 0 && diff.y >= 0 && !left)
|
||||
{
|
||||
ax.setNumberAnchor(CenterLeft);
|
||||
}
|
||||
else if ( diff.x <= 0 && diff.y >= 0 && sina >= SQRT_2)
|
||||
{
|
||||
ax.setNumberAnchor(CenterLeft);
|
||||
}
|
||||
else if ( diff.x <= 0 && diff.y >= 0)
|
||||
{
|
||||
ax.setNumberAnchor(BottomCenter);
|
||||
}
|
||||
else if ( diff.x <= 0 && diff.y <= 0 && sina <= SQRT_2)
|
||||
{
|
||||
ax.setNumberAnchor(TopCenter);
|
||||
}
|
||||
else if ( diff.x <= 0 && diff.y <= 0)
|
||||
{
|
||||
ax.setNumberAnchor(CenterLeft);
|
||||
}
|
||||
else if ( diff.x >= 0 && diff.y <= 0 && sina >= SQRT_2)
|
||||
{
|
||||
ax.setNumberAnchor(CenterLeft);
|
||||
}
|
||||
else if ( diff.x >= 0 && diff.y <= 0)
|
||||
{
|
||||
ax.setNumberAnchor(BottomCenter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CoordinateSystem::setPosition(Triple first, Triple second)
|
||||
{
|
||||
first_ = first;
|
||||
second_ = second;
|
||||
}
|
||||
|
||||
void CoordinateSystem::setTicLength(double major, double minor)
|
||||
{
|
||||
for (unsigned i=0; i!=axes.size(); ++i)
|
||||
axes[i].setTicLength(major, minor);
|
||||
}
|
||||
|
||||
void CoordinateSystem::adjustNumbers(int val)
|
||||
{
|
||||
for (unsigned i=0; i!=axes.size(); ++i)
|
||||
axes[i].adjustNumbers(val);
|
||||
}
|
||||
|
||||
void CoordinateSystem::adjustLabels(int val)
|
||||
{
|
||||
for (unsigned i=0; i!=axes.size(); ++i)
|
||||
axes[i].adjustLabel(val);
|
||||
}
|
||||
|
||||
void CoordinateSystem::setAutoScale(bool val)
|
||||
{
|
||||
for (unsigned i=0; i!=axes.size(); ++i)
|
||||
axes[i].setAutoScale(val);
|
||||
}
|
||||
|
||||
void CoordinateSystem::setAxesColor(RGBA val)
|
||||
{
|
||||
for (unsigned i=0; i!=axes.size(); ++i)
|
||||
axes[i].setColor(val);
|
||||
}
|
||||
|
||||
void CoordinateSystem::recalculateAxesTics()
|
||||
{
|
||||
for (unsigned i=0; i!=axes.size(); ++i)
|
||||
axes[i].recalculateTics();
|
||||
}
|
||||
|
||||
void CoordinateSystem::setNumberFont(QString const& family, int pointSize, int weight, bool italic)
|
||||
{
|
||||
for (unsigned i=0; i!=axes.size(); ++i)
|
||||
axes[i].setNumberFont(family,pointSize,weight,italic);
|
||||
}
|
||||
|
||||
void CoordinateSystem::setNumberFont(QFont const& font)
|
||||
{
|
||||
for (unsigned i=0; i!=axes.size(); ++i)
|
||||
axes[i].setNumberFont(font);
|
||||
}
|
||||
|
||||
void CoordinateSystem::setNumberColor(RGBA val)
|
||||
{
|
||||
for (unsigned i=0; i!=axes.size(); ++i)
|
||||
axes[i].setNumberColor( val);
|
||||
}
|
||||
|
||||
void CoordinateSystem::setStandardScale()
|
||||
{
|
||||
for (unsigned i=0; i!=axes.size(); ++i)
|
||||
axes[i].setScale(LINEARSCALE);
|
||||
}
|
||||
|
||||
void CoordinateSystem::setLabelFont(QFont const& font)
|
||||
{
|
||||
for (unsigned i=0; i!=axes.size(); ++i)
|
||||
axes[i].setLabelFont(font);
|
||||
}
|
||||
|
||||
|
||||
void CoordinateSystem::setLabelFont(QString const& family, int pointSize, int weight, bool italic)
|
||||
{
|
||||
setLabelFont(QFont(family,pointSize,weight,italic));
|
||||
}
|
||||
|
||||
void CoordinateSystem::setLabelColor(RGBA val)
|
||||
{
|
||||
for (unsigned i=0; i!=axes.size(); ++i)
|
||||
axes[i].setLabelColor(val);
|
||||
}
|
||||
|
||||
void CoordinateSystem::setLineWidth(double val, double majfac, double minfac)
|
||||
{
|
||||
for (unsigned i=0; i!=axes.size(); ++i)
|
||||
axes[i].setLineWidth(val, majfac, minfac);
|
||||
}
|
||||
|
||||
void CoordinateSystem::setStyle(COORDSTYLE s, AXIS frame_1, AXIS frame_2, AXIS frame_3)
|
||||
{
|
||||
style_ = s;
|
||||
|
||||
switch (s)
|
||||
{
|
||||
case NOCOORD:
|
||||
{
|
||||
for (unsigned i=0; i!=axes.size(); ++i)
|
||||
detach (&axes[i]);
|
||||
}
|
||||
break;
|
||||
case BOX:
|
||||
{
|
||||
for (unsigned i=0; i!=axes.size(); ++i)
|
||||
attach (&axes[i]);
|
||||
}
|
||||
break;
|
||||
case FRAME:
|
||||
{
|
||||
for (unsigned i=0; i!=axes.size(); ++i)
|
||||
detach (&axes[i]);
|
||||
if (!autoDecoration())
|
||||
{
|
||||
attach(&axes[frame_1]);
|
||||
attach(&axes[frame_2]);
|
||||
attach(&axes[frame_3]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
The axis used for tic calculation is chosen randomly from the respective pair.
|
||||
For most cases an identical tic distribution is therefore recommended.
|
||||
\param majors Draw grid between major tics
|
||||
\param minors Draw grid between minor tics
|
||||
\param sides Side(s), where the grid should be drawn
|
||||
*/
|
||||
void CoordinateSystem::setGridLines(bool majors, bool minors, int sides)
|
||||
{
|
||||
sides_ = sides;
|
||||
majorgridlines_ = majors;
|
||||
minorgridlines_ = minors;
|
||||
}
|
||||
|
||||
void CoordinateSystem::drawMajorGridLines()
|
||||
{
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glColor4d(gridlinecolor_.r,gridlinecolor_.g,gridlinecolor_.b,gridlinecolor_.a);
|
||||
setDeviceLineWidth(axes[X1].majLineWidth());
|
||||
|
||||
glBegin( GL_LINES );
|
||||
if (sides_ & Qwt3D::FLOOR)
|
||||
{
|
||||
drawMajorGridLines(axes[X1],axes[X4]);
|
||||
drawMajorGridLines(axes[Y1],axes[Y2]);
|
||||
}
|
||||
if (sides_ & Qwt3D::CEIL)
|
||||
{
|
||||
drawMajorGridLines(axes[X2],axes[X3]);
|
||||
drawMajorGridLines(axes[Y3],axes[Y4]);
|
||||
}
|
||||
if (sides_ & Qwt3D::LEFT)
|
||||
{
|
||||
drawMajorGridLines(axes[Y1],axes[Y4]);
|
||||
drawMajorGridLines(axes[Z1],axes[Z2]);
|
||||
}
|
||||
if (sides_ & Qwt3D::RIGHT)
|
||||
{
|
||||
drawMajorGridLines(axes[Y2],axes[Y3]);
|
||||
drawMajorGridLines(axes[Z3],axes[Z4]);
|
||||
}
|
||||
if (sides_ & Qwt3D::FRONT)
|
||||
{
|
||||
drawMajorGridLines(axes[X1],axes[X2]);
|
||||
drawMajorGridLines(axes[Z2],axes[Z3]);
|
||||
}
|
||||
if (sides_ & Qwt3D::BACK)
|
||||
{
|
||||
drawMajorGridLines(axes[X3],axes[X4]);
|
||||
drawMajorGridLines(axes[Z4],axes[Z1]);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void CoordinateSystem::drawMinorGridLines()
|
||||
{
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glColor4d(gridlinecolor_.r,gridlinecolor_.g,gridlinecolor_.b,gridlinecolor_.a);
|
||||
setDeviceLineWidth(axes[X1].minLineWidth());
|
||||
|
||||
glBegin( GL_LINES );
|
||||
if (sides_ & Qwt3D::FLOOR)
|
||||
{
|
||||
drawMinorGridLines(axes[X1],axes[X4]);
|
||||
drawMinorGridLines(axes[Y1],axes[Y2]);
|
||||
}
|
||||
if (sides_ & Qwt3D::CEIL)
|
||||
{
|
||||
drawMinorGridLines(axes[X2],axes[X3]);
|
||||
drawMinorGridLines(axes[Y3],axes[Y4]);
|
||||
}
|
||||
if (sides_ & Qwt3D::LEFT)
|
||||
{
|
||||
drawMinorGridLines(axes[Y1],axes[Y4]);
|
||||
drawMinorGridLines(axes[Z1],axes[Z2]);
|
||||
}
|
||||
if (sides_ & Qwt3D::RIGHT)
|
||||
{
|
||||
drawMinorGridLines(axes[Y2],axes[Y3]);
|
||||
drawMinorGridLines(axes[Z3],axes[Z4]);
|
||||
}
|
||||
if (sides_ & Qwt3D::FRONT)
|
||||
{
|
||||
drawMinorGridLines(axes[X1],axes[X2]);
|
||||
drawMinorGridLines(axes[Z2],axes[Z3]);
|
||||
}
|
||||
if (sides_ & Qwt3D::BACK)
|
||||
{
|
||||
drawMinorGridLines(axes[X3],axes[X4]);
|
||||
drawMinorGridLines(axes[Z4],axes[Z1]);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void CoordinateSystem::drawMajorGridLines(Axis& a0, Axis& a1)
|
||||
{
|
||||
Triple d = a1.begin()-a0.begin();
|
||||
|
||||
for (unsigned int i=0; i!=a0.majorPositions().size(); ++i)
|
||||
{
|
||||
glVertex3d( a0.majorPositions()[i].x, a0.majorPositions()[i].y, a0.majorPositions()[i].z );
|
||||
glVertex3d( a0.majorPositions()[i].x + d.x, a0.majorPositions()[i].y + d.y, a0.majorPositions()[i].z +d.z);
|
||||
}
|
||||
}
|
||||
|
||||
void CoordinateSystem::drawMinorGridLines(Axis& a0, Axis& a1)
|
||||
{
|
||||
Triple d = a1.begin()-a0.begin();
|
||||
|
||||
for (unsigned int i=0; i!=a0.minorPositions().size(); ++i)
|
||||
{
|
||||
glVertex3d( a0.minorPositions()[i].x, a0.minorPositions()[i].y, a0.minorPositions()[i].z );
|
||||
glVertex3d( a0.minorPositions()[i].x + d.x, a0.minorPositions()[i].y + d.y, a0.minorPositions()[i].z +d.z);
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
#if defined(_MSC_VER) /* MSVC Compiler */
|
||||
#pragma warning ( disable : 4305 )
|
||||
#pragma warning ( disable : 4786 )
|
||||
#endif
|
||||
|
||||
#include "qwt3d_plot.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace Qwt3D;
|
||||
|
@ -0,0 +1,140 @@
|
||||
#include "qwt3d_drawable.h"
|
||||
|
||||
using namespace Qwt3D;
|
||||
|
||||
Drawable::~Drawable()
|
||||
{
|
||||
detachAll();
|
||||
}
|
||||
|
||||
void Drawable::saveGLState()
|
||||
{
|
||||
glGetBooleanv(GL_LINE_SMOOTH, &ls);
|
||||
glGetBooleanv(GL_POLYGON_SMOOTH, &pols);
|
||||
glGetFloatv(GL_LINE_WIDTH, &lw);
|
||||
glGetIntegerv(GL_BLEND_SRC, &blsrc);
|
||||
glGetIntegerv(GL_BLEND_DST, &bldst);
|
||||
glGetDoublev(GL_CURRENT_COLOR, col);
|
||||
glGetIntegerv(GL_LINE_STIPPLE_PATTERN, &pattern);
|
||||
glGetIntegerv(GL_LINE_STIPPLE_REPEAT, &factor);
|
||||
glGetBooleanv(GL_LINE_STIPPLE, &sallowed);
|
||||
glGetBooleanv(GL_TEXTURE_2D, &tex2d);
|
||||
glGetIntegerv(GL_POLYGON_MODE, polmode);
|
||||
glGetIntegerv(GL_MATRIX_MODE, &matrixmode);
|
||||
glGetFloatv(GL_POLYGON_OFFSET_FACTOR, &poloffs[0]);
|
||||
glGetFloatv(GL_POLYGON_OFFSET_UNITS, &poloffs[1]);
|
||||
glGetBooleanv(GL_POLYGON_OFFSET_FILL, &poloffsfill);
|
||||
}
|
||||
|
||||
void Drawable::restoreGLState()
|
||||
{
|
||||
Enable(GL_LINE_SMOOTH, ls);
|
||||
Enable(GL_POLYGON_SMOOTH, pols);
|
||||
|
||||
setDeviceLineWidth(lw);
|
||||
glBlendFunc(blsrc, bldst);
|
||||
glColor4dv(col);
|
||||
|
||||
glLineStipple(factor,pattern);
|
||||
Enable(GL_LINE_STIPPLE,sallowed);
|
||||
Enable(GL_TEXTURE_2D,tex2d);
|
||||
glPolygonMode(polmode[0], polmode[1]);
|
||||
glMatrixMode(matrixmode);
|
||||
glPolygonOffset(poloffs[0], poloffs[1]);
|
||||
setDevicePolygonOffset(poloffs[0], poloffs[1]);
|
||||
|
||||
Enable(GL_POLYGON_OFFSET_FILL, poloffsfill);
|
||||
}
|
||||
|
||||
void Drawable::Enable(GLenum what, GLboolean val)
|
||||
{
|
||||
if (val)
|
||||
glEnable(what);
|
||||
else
|
||||
glDisable(what);
|
||||
}
|
||||
|
||||
void Drawable::attach(Drawable* dr)
|
||||
{
|
||||
if ( dlist.end() == std::find( dlist.begin(), dlist.end(), dr ) )
|
||||
if (dr)
|
||||
{
|
||||
dlist.push_back(dr);
|
||||
}
|
||||
}
|
||||
|
||||
void Drawable::detach(Drawable* dr)
|
||||
{
|
||||
std::list<Drawable*>::iterator it = std::find(dlist.begin(), dlist.end(), dr);
|
||||
|
||||
if ( it != dlist.end() )
|
||||
{
|
||||
dlist.erase(it);
|
||||
}
|
||||
}
|
||||
void Drawable::detachAll()
|
||||
{
|
||||
dlist.clear();
|
||||
}
|
||||
|
||||
|
||||
//! simplified glut routine (glUnProject): windows coordinates_p --> object coordinates_p
|
||||
/**
|
||||
Don't rely on (use) this in display lists !
|
||||
*/
|
||||
Triple Drawable::ViewPort2World(Triple win, bool* err)
|
||||
{
|
||||
Triple obj;
|
||||
|
||||
getMatrices(modelMatrix, projMatrix, viewport);
|
||||
int res = gluUnProject(win.x, win.y, win.z, modelMatrix, projMatrix, viewport, &obj.x, &obj.y, &obj.z);
|
||||
|
||||
if (err)
|
||||
*err = (res) ? false : true;
|
||||
return obj;
|
||||
}
|
||||
|
||||
//! simplified glut routine (glProject): object coordinates_p --> windows coordinates_p
|
||||
/**
|
||||
Don't rely on (use) this in display lists !
|
||||
*/
|
||||
Triple Drawable::World2ViewPort(Triple obj, bool* err)
|
||||
{
|
||||
Triple win;
|
||||
|
||||
getMatrices(modelMatrix, projMatrix, viewport);
|
||||
int res = gluProject(obj.x, obj.y, obj.z, modelMatrix, projMatrix, viewport, &win.x, &win.y, &win.z);
|
||||
|
||||
if (err)
|
||||
*err = (res) ? false : true;
|
||||
return win;
|
||||
}
|
||||
|
||||
/**
|
||||
Don't rely on (use) this in display lists !
|
||||
*/
|
||||
Triple Drawable::relativePosition(Triple rel)
|
||||
{
|
||||
return ViewPort2World(Triple((rel.x-viewport[0])*viewport[2],(rel.y-viewport[1])*viewport[3],rel.z));
|
||||
}
|
||||
|
||||
void Drawable::draw()
|
||||
{
|
||||
saveGLState();
|
||||
|
||||
for (std::list<Drawable*>::iterator it = dlist.begin(); it!=dlist.end(); ++it)
|
||||
{
|
||||
(*it)->draw();
|
||||
}
|
||||
restoreGLState();
|
||||
}
|
||||
|
||||
void Drawable::setColor(double r, double g, double b, double a)
|
||||
{
|
||||
color = RGBA(r,g,b,a);
|
||||
}
|
||||
|
||||
void Drawable::setColor(RGBA rgba)
|
||||
{
|
||||
color = rgba;
|
||||
}
|
@ -0,0 +1,347 @@
|
||||
#include <math.h>
|
||||
#include "qwt3d_color.h"
|
||||
#include "qwt3d_plot.h"
|
||||
#include "qwt3d_enrichment_std.h"
|
||||
|
||||
using namespace Qwt3D;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CrossHair
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
CrossHair::CrossHair()
|
||||
{
|
||||
configure(0, 1, false, false);
|
||||
}
|
||||
|
||||
CrossHair::CrossHair(double rad, double linewidth, bool smooth, bool boxed)
|
||||
{
|
||||
configure(rad, linewidth, smooth, boxed);
|
||||
}
|
||||
|
||||
void CrossHair::configure(double rad, double linewidth, bool smooth, bool boxed)
|
||||
{
|
||||
plot = 0;
|
||||
radius_ = rad;
|
||||
linewidth_ = linewidth;
|
||||
smooth_ = smooth;
|
||||
boxed_ = boxed;
|
||||
}
|
||||
|
||||
void CrossHair::drawBegin()
|
||||
{
|
||||
setDeviceLineWidth( linewidth_ );
|
||||
oldstate_ = glIsEnabled(GL_LINE_SMOOTH);
|
||||
if (smooth_)
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
else
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
glBegin( GL_LINES );
|
||||
}
|
||||
|
||||
void CrossHair::drawEnd()
|
||||
{
|
||||
glEnd();
|
||||
|
||||
if (oldstate_)
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
else
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
}
|
||||
|
||||
void CrossHair::draw(Qwt3D::Triple const& pos)
|
||||
{
|
||||
RGBA rgba = (*plot->dataColor())(pos);
|
||||
glColor4d(rgba.r,rgba.g,rgba.b,rgba.a);
|
||||
|
||||
double diag = (plot->hull().maxVertex-plot->hull().minVertex).length() * radius_;
|
||||
|
||||
glVertex3d( pos.x - diag, pos.y, pos.z);
|
||||
glVertex3d( pos.x + diag, pos.y, pos.z);
|
||||
|
||||
glVertex3d( pos.x, pos.y - diag, pos.z);
|
||||
glVertex3d( pos.x, pos.y + diag, pos.z);
|
||||
|
||||
glVertex3d( pos.x, pos.y, pos.z - diag);
|
||||
glVertex3d( pos.x, pos.y, pos.z + diag);
|
||||
|
||||
// hull
|
||||
|
||||
if (!boxed_)
|
||||
return;
|
||||
|
||||
glVertex3d( pos.x - diag, pos.y - diag, pos.z + diag);
|
||||
glVertex3d( pos.x + diag, pos.y - diag, pos.z + diag);
|
||||
glVertex3d( pos.x - diag, pos.y - diag, pos.z - diag);
|
||||
glVertex3d( pos.x + diag, pos.y - diag, pos.z - diag);
|
||||
|
||||
glVertex3d( pos.x - diag, pos.y + diag, pos.z + diag);
|
||||
glVertex3d( pos.x + diag, pos.y + diag, pos.z + diag);
|
||||
glVertex3d( pos.x - diag, pos.y + diag, pos.z - diag);
|
||||
glVertex3d( pos.x + diag, pos.y + diag, pos.z - diag);
|
||||
|
||||
glVertex3d( pos.x - diag, pos.y - diag, pos.z + diag);
|
||||
glVertex3d( pos.x - diag, pos.y + diag, pos.z + diag);
|
||||
glVertex3d( pos.x - diag, pos.y - diag, pos.z - diag);
|
||||
glVertex3d( pos.x - diag, pos.y + diag, pos.z - diag);
|
||||
|
||||
glVertex3d( pos.x + diag, pos.y - diag, pos.z + diag);
|
||||
glVertex3d( pos.x + diag, pos.y + diag, pos.z + diag);
|
||||
glVertex3d( pos.x + diag, pos.y - diag, pos.z - diag);
|
||||
glVertex3d( pos.x + diag, pos.y + diag, pos.z - diag);
|
||||
|
||||
glVertex3d( pos.x - diag, pos.y - diag, pos.z - diag);
|
||||
glVertex3d( pos.x - diag, pos.y - diag, pos.z + diag);
|
||||
glVertex3d( pos.x + diag, pos.y - diag, pos.z - diag);
|
||||
glVertex3d( pos.x + diag, pos.y - diag, pos.z + diag);
|
||||
|
||||
glVertex3d( pos.x - diag, pos.y + diag, pos.z - diag);
|
||||
glVertex3d( pos.x - diag, pos.y + diag, pos.z + diag);
|
||||
glVertex3d( pos.x + diag, pos.y + diag, pos.z - diag);
|
||||
glVertex3d( pos.x + diag, pos.y + diag, pos.z + diag);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dot
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
Dot::Dot()
|
||||
{
|
||||
configure(1, false);
|
||||
}
|
||||
|
||||
Dot::Dot(double pointsize, bool smooth)
|
||||
{
|
||||
configure(pointsize, smooth);
|
||||
}
|
||||
|
||||
void Dot::configure(double pointsize, bool smooth)
|
||||
{
|
||||
plot = 0;
|
||||
pointsize_ = pointsize;
|
||||
smooth_ = smooth;
|
||||
}
|
||||
|
||||
void Dot::drawBegin()
|
||||
{
|
||||
setDevicePointSize( pointsize_ );
|
||||
oldstate_ = glIsEnabled(GL_POINT_SMOOTH);
|
||||
if (smooth_)
|
||||
glEnable(GL_POINT_SMOOTH);
|
||||
else
|
||||
glDisable(GL_POINT_SMOOTH);
|
||||
|
||||
//glPointSize(10);
|
||||
glBegin( GL_POINTS );
|
||||
}
|
||||
|
||||
void Dot::drawEnd()
|
||||
{
|
||||
glEnd();
|
||||
|
||||
if (oldstate_)
|
||||
glEnable(GL_POINT_SMOOTH);
|
||||
else
|
||||
glDisable(GL_POINT_SMOOTH);
|
||||
}
|
||||
|
||||
void Dot::draw(Qwt3D::Triple const& pos)
|
||||
{
|
||||
RGBA rgba = (*plot->dataColor())(pos);
|
||||
glColor4d(rgba.r,rgba.g,rgba.b,rgba.a);
|
||||
glVertex3d( pos.x, pos.y, pos.z);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Cone
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
Cone::Cone()
|
||||
{
|
||||
hat = gluNewQuadric();
|
||||
disk = gluNewQuadric();
|
||||
|
||||
configure(0, 3);
|
||||
}
|
||||
|
||||
Cone::Cone(double rad, unsigned quality)
|
||||
{
|
||||
hat = gluNewQuadric();
|
||||
disk = gluNewQuadric();
|
||||
|
||||
configure(rad, quality);
|
||||
}
|
||||
|
||||
Cone::~Cone()
|
||||
{
|
||||
gluDeleteQuadric(hat);
|
||||
gluDeleteQuadric(disk);
|
||||
}
|
||||
|
||||
void Cone::configure(double rad, unsigned quality)
|
||||
{
|
||||
plot = 0;
|
||||
radius_ = rad;
|
||||
quality_ = quality;
|
||||
oldstate_ = GL_FALSE;
|
||||
|
||||
gluQuadricDrawStyle(hat,GLU_FILL);
|
||||
gluQuadricNormals(hat,GLU_SMOOTH);
|
||||
gluQuadricOrientation(hat,GLU_OUTSIDE);
|
||||
gluQuadricDrawStyle(disk,GLU_FILL);
|
||||
gluQuadricNormals(disk,GLU_SMOOTH);
|
||||
gluQuadricOrientation(disk,GLU_OUTSIDE);
|
||||
}
|
||||
|
||||
void Cone::draw(Qwt3D::Triple const& pos)
|
||||
{
|
||||
RGBA rgba = (*plot->dataColor())(pos);
|
||||
glColor4d(rgba.r,rgba.g,rgba.b,rgba.a);
|
||||
|
||||
GLint mode;
|
||||
glGetIntegerv(GL_MATRIX_MODE, &mode);
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glPushMatrix();
|
||||
|
||||
glTranslatef(pos.x, pos.y, pos.z);
|
||||
|
||||
gluCylinder(hat, 0.0, radius_, radius_*2, quality_, 1);
|
||||
glTranslatef(0, 0, radius_*2);
|
||||
gluDisk(disk, 0.0, radius_, quality_, 1);
|
||||
|
||||
glPopMatrix();
|
||||
glMatrixMode(mode);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Arrow
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
Arrow::Arrow()
|
||||
{
|
||||
hat = gluNewQuadric();
|
||||
disk = gluNewQuadric();
|
||||
base = gluNewQuadric();
|
||||
bottom = gluNewQuadric();
|
||||
|
||||
gluQuadricDrawStyle(hat,GLU_FILL);
|
||||
gluQuadricNormals(hat,GLU_SMOOTH);
|
||||
gluQuadricOrientation(hat,GLU_OUTSIDE);
|
||||
gluQuadricDrawStyle(disk,GLU_FILL);
|
||||
gluQuadricNormals(disk,GLU_SMOOTH);
|
||||
gluQuadricOrientation(disk,GLU_OUTSIDE);
|
||||
gluQuadricDrawStyle(base,GLU_FILL);
|
||||
gluQuadricNormals(base,GLU_SMOOTH);
|
||||
gluQuadricOrientation(base,GLU_OUTSIDE);
|
||||
gluQuadricDrawStyle(bottom,GLU_FILL);
|
||||
gluQuadricNormals(bottom,GLU_SMOOTH);
|
||||
gluQuadricOrientation(bottom,GLU_OUTSIDE);
|
||||
|
||||
configure(3, 0.4, 0.06, 0.02);
|
||||
}
|
||||
|
||||
Arrow::~Arrow()
|
||||
{
|
||||
gluDeleteQuadric(hat);
|
||||
gluDeleteQuadric(disk);
|
||||
gluDeleteQuadric(base);
|
||||
gluDeleteQuadric(bottom);
|
||||
}
|
||||
|
||||
/**
|
||||
\param segs number of faces for the fields arrows (see the gallery for examples)
|
||||
\param relconelength see picture
|
||||
\param relconerad see picture
|
||||
\param relstemrad see picture
|
||||
\image html arrowanatomy.png
|
||||
*/
|
||||
void Arrow::configure(int segs, double relconelength, double relconerad, double relstemrad)
|
||||
{
|
||||
plot = 0;
|
||||
segments_ = segs;
|
||||
oldstate_ = GL_FALSE;
|
||||
rel_cone_length = relconelength;
|
||||
rel_cone_radius = relconerad;
|
||||
rel_stem_radius = relstemrad;
|
||||
}
|
||||
|
||||
void Arrow::draw(Qwt3D::Triple const& pos)
|
||||
{
|
||||
Triple end = top_;
|
||||
Triple beg = pos;
|
||||
Triple vdiff = end-beg;
|
||||
double length = vdiff.length();
|
||||
glColor4d(rgba_.r,rgba_.g,rgba_.b,rgba_.a);
|
||||
|
||||
double radius[2];
|
||||
radius[0] = rel_cone_radius * length;
|
||||
radius[1] = rel_stem_radius * length;
|
||||
|
||||
GLint mode;
|
||||
glGetIntegerv(GL_MATRIX_MODE, &mode);
|
||||
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glPushMatrix();
|
||||
|
||||
|
||||
Triple axis;
|
||||
double phi = calcRotation(axis, FreeVector(beg,end));
|
||||
|
||||
glTranslatef(beg.x, beg.y, beg.z);
|
||||
glRotatef(phi, axis.x, axis.y, axis.z);
|
||||
|
||||
double baseheight = (1-rel_cone_length) * length;
|
||||
|
||||
glTranslatef(0, 0, baseheight);
|
||||
|
||||
gluCylinder(hat, radius[0], 0.0, rel_cone_length * length, segments_,1);
|
||||
gluDisk(disk,radius[1],radius[0], segments_,1);
|
||||
|
||||
glTranslatef(0, 0, -baseheight);
|
||||
|
||||
gluCylinder(base, radius[1],radius[1], baseheight,segments_,1);
|
||||
gluDisk(disk,0,radius[1],segments_,1);
|
||||
|
||||
glPopMatrix();
|
||||
glMatrixMode(mode);
|
||||
}
|
||||
|
||||
|
||||
//! transform a vector on the z axis with length |beg-end|, to get them in coincidence with the vector(beg,end)
|
||||
/**
|
||||
\return Angle in degree to rotate
|
||||
\param axis The axis to rotate around
|
||||
\param beg result vector base point
|
||||
\param end result vector top point
|
||||
*/
|
||||
double Arrow::calcRotation(Triple& axis, FreeVector const& vec)
|
||||
{
|
||||
|
||||
Triple end = vec.top;
|
||||
Triple beg = vec.base;
|
||||
|
||||
Triple firstbeg(0.0,0.0,0.0);
|
||||
Triple firstend(0.0,0.0,(end-beg).length());
|
||||
|
||||
Triple first = firstend - firstbeg;
|
||||
first.normalize();
|
||||
|
||||
Triple second = end-beg;
|
||||
second.normalize();
|
||||
|
||||
axis = normalizedcross(first,second);
|
||||
double cosphi = dotProduct(first,second);
|
||||
|
||||
return 180 * acos(cosphi) / Qwt3D::PI;
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
#include "qwt3d_surfaceplot.h"
|
||||
#include "qwt3d_function.h"
|
||||
|
||||
using namespace Qwt3D;
|
||||
|
||||
Function::Function()
|
||||
:GridMapping()
|
||||
{
|
||||
}
|
||||
|
||||
Function::Function(SurfacePlot& pw)
|
||||
:GridMapping()
|
||||
{
|
||||
plotwidget_p = &pw;
|
||||
}
|
||||
|
||||
Function::Function(SurfacePlot* pw)
|
||||
:GridMapping()
|
||||
{
|
||||
plotwidget_p = pw;
|
||||
}
|
||||
|
||||
void Function::assign(SurfacePlot& plotWidget)
|
||||
{
|
||||
if (&plotWidget != plotwidget_p)
|
||||
plotwidget_p = &plotWidget;
|
||||
}
|
||||
|
||||
void Function::assign(SurfacePlot* plotWidget)
|
||||
{
|
||||
if (plotWidget != plotwidget_p)
|
||||
plotwidget_p = plotWidget;
|
||||
}
|
||||
|
||||
void Function:: setMinZ(double val)
|
||||
{
|
||||
range_p.minVertex.z = val;
|
||||
}
|
||||
|
||||
void Function:: setMaxZ(double val)
|
||||
{
|
||||
range_p.maxVertex.z = val;
|
||||
}
|
||||
|
||||
bool Function::create()
|
||||
{
|
||||
if ((umesh_p<=2) || (vmesh_p<=2) || !plotwidget_p)
|
||||
return false;
|
||||
|
||||
/* allocate some space for the mesh */
|
||||
double** data = new double* [umesh_p] ;
|
||||
|
||||
unsigned i,j;
|
||||
for ( i = 0; i < umesh_p; i++)
|
||||
{
|
||||
data[i] = new double [vmesh_p];
|
||||
}
|
||||
|
||||
/* get the data */
|
||||
|
||||
double dx = (maxu_p - minu_p) / (umesh_p - 1);
|
||||
double dy = (maxv_p - minv_p) / (vmesh_p - 1);
|
||||
|
||||
for (i = 0; i < umesh_p; ++i)
|
||||
{
|
||||
for (j = 0; j < vmesh_p; ++j)
|
||||
{
|
||||
data[i][j] = operator()(minu_p + i*dx, minv_p + j*dy);
|
||||
|
||||
if (data[i][j] > range_p.maxVertex.z)
|
||||
data[i][j] = range_p.maxVertex.z;
|
||||
else if (data[i][j] < range_p.minVertex.z)
|
||||
data[i][j] = range_p.minVertex.z;
|
||||
}
|
||||
}
|
||||
|
||||
Q_ASSERT(plotwidget_p);
|
||||
if (!plotwidget_p)
|
||||
{
|
||||
fprintf(stderr,"Function: no valid Plot3D Widget assigned");
|
||||
}
|
||||
else
|
||||
{
|
||||
((SurfacePlot*)plotwidget_p)->loadFromData(data, umesh_p, vmesh_p, minu_p, maxu_p, minv_p, maxv_p);
|
||||
}
|
||||
|
||||
for ( i = 0; i < umesh_p; i++)
|
||||
{
|
||||
delete [] data[i];
|
||||
}
|
||||
|
||||
delete [] data;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Function::create(SurfacePlot& pl)
|
||||
{
|
||||
assign(pl);
|
||||
return create();
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
#include "qwt3d_gridmapping.h"
|
||||
#include "qwt3d_surfaceplot.h"
|
||||
|
||||
using namespace Qwt3D;
|
||||
|
||||
GridMapping::GridMapping()
|
||||
{
|
||||
plotwidget_p = 0;
|
||||
setMesh(0,0);
|
||||
setDomain(0,0,0,0);
|
||||
restrictRange(ParallelEpiped(Triple(-DBL_MAX,-DBL_MAX,-DBL_MAX),Triple(DBL_MAX,DBL_MAX,DBL_MAX)));
|
||||
}
|
||||
|
||||
void GridMapping::setMesh(unsigned int columns,unsigned int rows)
|
||||
{
|
||||
umesh_p = columns;
|
||||
vmesh_p = rows;
|
||||
}
|
||||
|
||||
void GridMapping::setDomain(double minu, double maxu, double minv, double maxv)
|
||||
{
|
||||
minu_p = minu;
|
||||
maxu_p = maxu;
|
||||
minv_p = minv;
|
||||
maxv_p = maxv;
|
||||
}
|
||||
|
||||
void GridMapping::restrictRange(Qwt3D::ParallelEpiped const& p)
|
||||
{
|
||||
range_p = p;
|
||||
}
|
||||
|
@ -0,0 +1,596 @@
|
||||
#if defined(_MSC_VER) /* MSVC Compiler */
|
||||
#pragma warning ( disable : 4305 )
|
||||
#pragma warning ( disable : 4786 )
|
||||
#endif
|
||||
|
||||
#include "qwt3d_surfaceplot.h"
|
||||
#include "qwt3d_enrichment_std.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace Qwt3D;
|
||||
|
||||
|
||||
|
||||
void SurfacePlot::createDataG()
|
||||
{
|
||||
createFloorData();
|
||||
|
||||
if (plotStyle() == NOPLOT)
|
||||
return;
|
||||
|
||||
int i, j;
|
||||
RGBA col;
|
||||
int step = resolution();
|
||||
|
||||
if (plotStyle() == Qwt3D::POINTS)
|
||||
{
|
||||
createPoints();
|
||||
return;
|
||||
}
|
||||
else if (plotStyle() == Qwt3D::USER)
|
||||
{
|
||||
if (userplotstyle_p)
|
||||
createEnrichment(*userplotstyle_p);
|
||||
return;
|
||||
}
|
||||
|
||||
setDeviceLineWidth(meshLineWidth());
|
||||
|
||||
GLStateBewarer sb(GL_POLYGON_OFFSET_FILL,true);
|
||||
setDevicePolygonOffset(polygonOffset(),1.0);
|
||||
|
||||
GLStateBewarer sb2(GL_LINE_SMOOTH, smoothDataMesh());
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
|
||||
int lastcol = actualDataG_->columns();
|
||||
int lastrow = actualDataG_->rows();
|
||||
|
||||
if (plotStyle() != WIREFRAME)
|
||||
{
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_QUADS);
|
||||
|
||||
bool hl = (plotStyle() == HIDDENLINE);
|
||||
if (hl)
|
||||
{
|
||||
col = backgroundRGBAColor();
|
||||
glColor4d(col.r, col.g, col.b, col.a);
|
||||
}
|
||||
|
||||
for (i = 0; i < lastcol - step; i += step)
|
||||
{
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
setColorFromVertexG(i, 0, hl);
|
||||
glNormal3dv(actualDataG_->normals[i][0]);
|
||||
glVertex3dv(actualDataG_->vertices[i][0]);
|
||||
|
||||
setColorFromVertexG(i+step, 0, hl);
|
||||
glNormal3dv(actualDataG_->normals[i+step][0]);
|
||||
glVertex3dv(actualDataG_->vertices[i+step][0]);
|
||||
|
||||
for (j = 0; j < lastrow - step; j += step)
|
||||
{
|
||||
setColorFromVertexG(i,j+step, hl);
|
||||
glNormal3dv(actualDataG_->normals[i][j+step]);
|
||||
glVertex3dv(actualDataG_->vertices[i][j+step]);
|
||||
|
||||
setColorFromVertexG(i+step, j+step, hl);
|
||||
glNormal3dv(actualDataG_->normals[i+step][j+step]);
|
||||
glVertex3dv(actualDataG_->vertices[i+step][j+step]);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
if (plotStyle() == FILLEDMESH || plotStyle() == WIREFRAME || plotStyle() == HIDDENLINE)
|
||||
{
|
||||
glColor4d(meshColor().r, meshColor().g, meshColor().b, meshColor().a);
|
||||
|
||||
if (step < actualDataG_->columns() && step < actualDataG_->rows())
|
||||
{
|
||||
glBegin(GL_LINE_LOOP);
|
||||
for (i = 0; i < actualDataG_->columns() - step; i += step)
|
||||
glVertex3dv(actualDataG_->vertices[i][0]);
|
||||
for (j = 0; j < actualDataG_->rows() - step; j += step)
|
||||
glVertex3dv(actualDataG_->vertices[i][j]);
|
||||
for (; i >= 0; i -= step)
|
||||
glVertex3dv(actualDataG_->vertices[i][j]);
|
||||
for (; j >= 0; j -= step)
|
||||
glVertex3dv(actualDataG_->vertices[0][j]);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
// weaving
|
||||
for (i = step; i < actualDataG_->columns() - step; i += step)
|
||||
{
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (j = 0; j < actualDataG_->rows(); j += step)
|
||||
glVertex3dv(actualDataG_->vertices[i][j]);
|
||||
glEnd();
|
||||
}
|
||||
for (j = step; j < actualDataG_->rows() - step; j += step)
|
||||
{
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (i = 0; i < actualDataG_->columns(); i += step)
|
||||
glVertex3dv(actualDataG_->vertices[i][j]);
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SurfacePlot::setColorFromVertexG(int ix, int iy, bool skip)
|
||||
{
|
||||
if (skip)
|
||||
return;
|
||||
|
||||
RGBA col = (*datacolor_p)(
|
||||
actualDataG_->vertices[ix][iy][0],
|
||||
actualDataG_->vertices[ix][iy][1],
|
||||
actualDataG_->vertices[ix][iy][2]);
|
||||
|
||||
glColor4d(col.r, col.g, col.b, col.a);
|
||||
}
|
||||
|
||||
|
||||
void SurfacePlot::createNormalsG()
|
||||
{
|
||||
if (!normals() || actualDataG_->empty())
|
||||
return;
|
||||
|
||||
Arrow arrow;
|
||||
arrow.setQuality(normalQuality());
|
||||
|
||||
Triple basev, topv, norm;
|
||||
|
||||
int step = resolution();
|
||||
|
||||
double diag = (actualDataG_->hull().maxVertex-actualDataG_->hull().minVertex).length() * normalLength();
|
||||
|
||||
arrow.assign(*this);
|
||||
arrow.drawBegin();
|
||||
for (int i = 0; i <= actualDataG_->columns() - step; i += step)
|
||||
{
|
||||
for (int j = 0; j <= actualDataG_->rows() - step; j += step)
|
||||
{
|
||||
basev = Triple(actualDataG_->vertices[i][j][0],actualDataG_->vertices[i][j][1],actualDataG_->vertices[i][j][2]);
|
||||
topv = Triple(actualDataG_->vertices[i][j][0]+actualDataG_->normals[i][j][0],
|
||||
actualDataG_->vertices[i][j][1]+actualDataG_->normals[i][j][1],
|
||||
actualDataG_->vertices[i][j][2]+actualDataG_->normals[i][j][2]);
|
||||
|
||||
norm = topv-basev;
|
||||
norm.normalize();
|
||||
norm *= diag;
|
||||
|
||||
arrow.setTop(basev+norm);
|
||||
arrow.setColor((*datacolor_p)(basev.x,basev.y,basev.z));
|
||||
arrow.draw(basev);
|
||||
}
|
||||
}
|
||||
arrow.drawEnd();
|
||||
}
|
||||
|
||||
void SurfacePlot::readIn(GridData& gdata, Triple** data, unsigned int columns, unsigned int rows)
|
||||
{
|
||||
gdata.setSize(columns,rows);
|
||||
|
||||
ParallelEpiped range(Triple(DBL_MAX,DBL_MAX,DBL_MAX),Triple(-DBL_MAX,-DBL_MAX,-DBL_MAX));
|
||||
|
||||
/* fill out the vertex array for the mesh. */
|
||||
for (unsigned i = 0; i != columns; ++i)
|
||||
{
|
||||
for (unsigned j = 0; j != rows; ++j)
|
||||
{
|
||||
gdata.vertices[i][j][0] = data[i][j].x;
|
||||
gdata.vertices[i][j][1] = data[i][j].y;
|
||||
gdata.vertices[i][j][2] = data[i][j].z;
|
||||
|
||||
if (data[i][j].x > range.maxVertex.x)
|
||||
range.maxVertex.x = data[i][j].x;
|
||||
if (data[i][j].y > range.maxVertex.y)
|
||||
range.maxVertex.y = data[i][j].y;
|
||||
if (data[i][j].z > range.maxVertex.z)
|
||||
range.maxVertex.z = data[i][j].z;
|
||||
if (data[i][j].x < range.minVertex.x)
|
||||
range.minVertex.x = data[i][j].x;
|
||||
if (data[i][j].y < range.minVertex.y)
|
||||
range.minVertex.y = data[i][j].y;
|
||||
if (data[i][j].z < range.minVertex.z)
|
||||
range.minVertex.z = data[i][j].z;
|
||||
}
|
||||
}
|
||||
gdata.setHull(range);
|
||||
}
|
||||
|
||||
|
||||
void SurfacePlot::readIn(GridData& gdata, double** data, unsigned int columns, unsigned int rows
|
||||
, double minx, double maxx, double miny, double maxy)
|
||||
{
|
||||
gdata.setPeriodic(false,false);
|
||||
gdata.setSize(columns,rows);
|
||||
|
||||
double dx = (maxx - minx) / (gdata.columns() - 1);
|
||||
double dy = (maxy - miny) / (gdata.rows() - 1);
|
||||
|
||||
double tmin = DBL_MAX;
|
||||
double tmax = -DBL_MAX;
|
||||
|
||||
/* fill out the vertex array for the mesh. */
|
||||
for (unsigned i = 0; i != columns; ++i)
|
||||
{
|
||||
for (unsigned j = 0; j != rows; ++j)
|
||||
{
|
||||
gdata.vertices[i][j][0] = minx + i*dx;
|
||||
gdata.vertices[i][j][1] = miny + j*dy;
|
||||
gdata.vertices[i][j][2] = data[i][j];
|
||||
|
||||
if (data[i][j] > tmax)
|
||||
tmax = data[i][j];
|
||||
if (data[i][j] < tmin)
|
||||
tmin = data[i][j];
|
||||
}
|
||||
}
|
||||
ParallelEpiped hull =
|
||||
ParallelEpiped(
|
||||
Triple(
|
||||
gdata.vertices[0][0][0],
|
||||
gdata.vertices[0][0][1],
|
||||
tmin
|
||||
),
|
||||
Triple(
|
||||
gdata.vertices[gdata.columns()-1][gdata.rows()-1][0],
|
||||
gdata.vertices[gdata.columns()-1][gdata.rows()-1][1],
|
||||
tmax
|
||||
)
|
||||
);
|
||||
|
||||
gdata.setHull(hull);
|
||||
}
|
||||
|
||||
|
||||
void SurfacePlot::calcNormals(GridData& gdata)
|
||||
{
|
||||
|
||||
unsigned int rows = gdata.rows();
|
||||
unsigned int columns = gdata.columns();
|
||||
|
||||
// normals
|
||||
|
||||
Triple u, v, n; // for cross product
|
||||
|
||||
for (unsigned i = 0; i != columns; ++i)
|
||||
{
|
||||
for (unsigned j = 0; j != rows; ++j)
|
||||
{
|
||||
n = Triple(0,0,0);
|
||||
|
||||
|
||||
if (i<columns-1 && j<rows-1)
|
||||
{
|
||||
/* get two vectors to cross */
|
||||
u = Triple(
|
||||
gdata.vertices[i+1][j][0] - gdata.vertices[i][j][0],
|
||||
gdata.vertices[i+1][j][1] - gdata.vertices[i][j][1],
|
||||
gdata.vertices[i+1][j][2] - gdata.vertices[i][j][2]
|
||||
);
|
||||
|
||||
v = Triple(
|
||||
gdata.vertices[i][j+1][0] - gdata.vertices[i][j][0],
|
||||
gdata.vertices[i][j+1][1] - gdata.vertices[i][j][1],
|
||||
gdata.vertices[i][j+1][2] - gdata.vertices[i][j][2]
|
||||
);
|
||||
/* get the normalized cross product */
|
||||
n += normalizedcross(u,v); // right hand system here !
|
||||
}
|
||||
|
||||
if (i>0 && j<rows-1)
|
||||
{
|
||||
u = Triple(
|
||||
gdata.vertices[i][j+1][0] - gdata.vertices[i][j][0],
|
||||
gdata.vertices[i][j+1][1] - gdata.vertices[i][j][1],
|
||||
gdata.vertices[i][j+1][2] - gdata.vertices[i][j][2]
|
||||
);
|
||||
v = Triple(
|
||||
gdata.vertices[i-1][j][0] - gdata.vertices[i][j][0],
|
||||
gdata.vertices[i-1][j][1] - gdata.vertices[i][j][1],
|
||||
gdata.vertices[i-1][j][2] - gdata.vertices[i][j][2]
|
||||
);
|
||||
n += normalizedcross(u,v);
|
||||
}
|
||||
|
||||
if (i>0 && j>0)
|
||||
{
|
||||
u = Triple(
|
||||
gdata.vertices[i-1][j][0] - gdata.vertices[i][j][0],
|
||||
gdata.vertices[i-1][j][1] - gdata.vertices[i][j][1],
|
||||
gdata.vertices[i-1][j][2] - gdata.vertices[i][j][2]
|
||||
);
|
||||
|
||||
v = Triple(
|
||||
gdata.vertices[i][j-1][0] - gdata.vertices[i][j][0],
|
||||
gdata.vertices[i][j-1][1] - gdata.vertices[i][j][1],
|
||||
gdata.vertices[i][j-1][2] - gdata.vertices[i][j][2]
|
||||
);
|
||||
n += normalizedcross(u,v);
|
||||
}
|
||||
|
||||
if (i<columns-1 && j>0)
|
||||
{
|
||||
u = Triple(
|
||||
gdata.vertices[i][j-1][0] - gdata.vertices[i][j][0],
|
||||
gdata.vertices[i][j-1][1] - gdata.vertices[i][j][1],
|
||||
gdata.vertices[i][j-1][2] - gdata.vertices[i][j][2]
|
||||
);
|
||||
|
||||
v = Triple(
|
||||
gdata.vertices[i+1][j][0] - gdata.vertices[i][j][0],
|
||||
gdata.vertices[i+1][j][1] - gdata.vertices[i][j][1],
|
||||
gdata.vertices[i+1][j][2] - gdata.vertices[i][j][2]
|
||||
);
|
||||
n += normalizedcross(u,v);
|
||||
}
|
||||
n.normalize();
|
||||
|
||||
gdata.normals[i][j][0] = n.x;
|
||||
gdata.normals[i][j][1] = n.y;
|
||||
gdata.normals[i][j][2] = n.z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SurfacePlot::sewPeriodic(GridData& gdata)
|
||||
{
|
||||
// sewing
|
||||
|
||||
Triple n;
|
||||
|
||||
unsigned int columns = gdata.columns();
|
||||
unsigned int rows = gdata.rows();
|
||||
|
||||
if (gdata.uperiodic())
|
||||
{
|
||||
for (unsigned i = 0; i != columns; ++i)
|
||||
{
|
||||
n = Triple(
|
||||
gdata.normals[i][0][0] + gdata.normals[i][rows-1][0],
|
||||
gdata.normals[i][0][1] + gdata.normals[i][rows-1][1],
|
||||
gdata.normals[i][0][2] + gdata.normals[i][rows-1][2]
|
||||
);
|
||||
|
||||
n.normalize();
|
||||
gdata.normals[i][0][0] = gdata.normals[i][rows-1][0] = n.x;
|
||||
gdata.normals[i][0][1] = gdata.normals[i][rows-1][1] = n.y;
|
||||
gdata.normals[i][0][2] = gdata.normals[i][rows-1][2] = n.z;
|
||||
}
|
||||
}
|
||||
if (gdata.vperiodic())
|
||||
{
|
||||
for (unsigned j = 0; j != rows; ++j)
|
||||
{
|
||||
n = Triple(
|
||||
gdata.normals[0][j][0] + gdata.normals[columns-1][j][0],
|
||||
gdata.normals[0][j][1] + gdata.normals[columns-1][j][1],
|
||||
gdata.normals[0][j][2] + gdata.normals[columns-1][j][2]
|
||||
);
|
||||
|
||||
n.normalize();
|
||||
gdata.normals[0][j][0] = gdata.normals[columns-1][j][0] = n.x;
|
||||
gdata.normals[0][j][1] = gdata.normals[columns-1][j][1] = n.y;
|
||||
gdata.normals[0][j][2] = gdata.normals[columns-1][j][2] = n.z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Convert user grid data to internal vertex structure.
|
||||
See also NativeReader::read() and Function::create()
|
||||
*/
|
||||
bool SurfacePlot::loadFromData(Triple** data, unsigned int columns, unsigned int rows, bool uperiodic, bool vperiodic)
|
||||
{
|
||||
actualDataC_->clear();
|
||||
actualData_p = actualDataG_;
|
||||
|
||||
readIn(*actualDataG_, data, columns, rows);
|
||||
calcNormals(*actualDataG_);
|
||||
actualDataG_->setPeriodic(uperiodic,vperiodic);
|
||||
sewPeriodic(*actualDataG_);
|
||||
|
||||
updateData();
|
||||
updateNormals();
|
||||
createCoordinateSystem();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
Convert user grid data to internal vertex structure.
|
||||
See also NativeReader::read() and Function::create()
|
||||
*/
|
||||
bool SurfacePlot::loadFromData(double** data, unsigned int columns, unsigned int rows
|
||||
, double minx, double maxx, double miny, double maxy)
|
||||
{
|
||||
actualDataC_->clear();
|
||||
actualData_p = actualDataG_;
|
||||
|
||||
actualDataG_->setPeriodic(false,false);
|
||||
actualDataG_->setSize(columns,rows);
|
||||
readIn(*actualDataG_,data,columns,rows,minx,maxx,miny,maxy);
|
||||
calcNormals(*actualDataG_);
|
||||
|
||||
updateData();
|
||||
updateNormals();
|
||||
createCoordinateSystem();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void SurfacePlot::createFloorDataG()
|
||||
{
|
||||
switch (floorStyle())
|
||||
{
|
||||
case FLOORDATA:
|
||||
Data2FloorG();
|
||||
break;
|
||||
case FLOORISO:
|
||||
Isolines2FloorG();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SurfacePlot::Data2FloorG()
|
||||
{
|
||||
if (actualData_p->empty())
|
||||
return;
|
||||
|
||||
int step = resolution();
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_QUADS);
|
||||
|
||||
double zshift = actualData_p->hull().minVertex.z;
|
||||
for (int i = 0; i < actualDataG_->columns() - step; i += step)
|
||||
{
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
setColorFromVertexG(i, 0);
|
||||
glVertex3d(actualDataG_->vertices[i][0][0], actualDataG_->vertices[i][0][1], zshift);
|
||||
|
||||
setColorFromVertexG(i+step, 0);
|
||||
glVertex3d(actualDataG_->vertices[i+step][0][0],actualDataG_->vertices[i+step][0][1], zshift);
|
||||
for (int j = 0; j < actualDataG_->rows() - step; j += step)
|
||||
{
|
||||
setColorFromVertexG(i, j+step);
|
||||
glVertex3d(actualDataG_->vertices[i][j+step][0],actualDataG_->vertices[i][j+step][1], zshift);
|
||||
|
||||
setColorFromVertexG(i+step, j+step);
|
||||
glVertex3d(actualDataG_->vertices[i+step][j+step][0],actualDataG_->vertices[i+step][j+step][1], zshift);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
void SurfacePlot::Isolines2FloorG()
|
||||
{
|
||||
if (isolines() <= 0 || actualData_p->empty())
|
||||
return;
|
||||
|
||||
double count = (actualData_p->hull().maxVertex.z - actualData_p->hull().minVertex.z) / isolines();
|
||||
|
||||
RGBA col;
|
||||
|
||||
int step = resolution();
|
||||
|
||||
double zshift = actualData_p->hull().minVertex.z;
|
||||
|
||||
int cols = actualDataG_->columns();
|
||||
int rows = actualDataG_->rows();
|
||||
|
||||
Triple t[4];
|
||||
vector<Triple> intersection;
|
||||
|
||||
double lambda = 0;
|
||||
|
||||
GLStateBewarer sb2(GL_LINE_SMOOTH, false);
|
||||
|
||||
for (int k = 0; k != isolines(); ++k)
|
||||
{
|
||||
double val = zshift + k * count;
|
||||
|
||||
for (int i = 0; i < cols-step; i += step)
|
||||
{
|
||||
for (int j = 0; j < rows-step; j += step)
|
||||
{
|
||||
t[0] = Triple( actualDataG_->vertices[i][j][0],
|
||||
actualDataG_->vertices[i][j][1],
|
||||
actualDataG_->vertices[i][j][2]);
|
||||
|
||||
col = (*datacolor_p)(t[0].x,t[0].y,t[0].z);
|
||||
glColor4d(col.r, col.g, col.b, col.a);
|
||||
// glColor4d(0,0,0,1);
|
||||
|
||||
t[1] = Triple( actualDataG_->vertices[i+step][j][0],
|
||||
actualDataG_->vertices[i+step][j][1],
|
||||
actualDataG_->vertices[i+step][j][2]);
|
||||
t[2] = Triple( actualDataG_->vertices[i+step][j+step][0],
|
||||
actualDataG_->vertices[i+step][j+step][1],
|
||||
actualDataG_->vertices[i+step][j+step][2]);
|
||||
t[3] = Triple( actualDataG_->vertices[i][j+step][0],
|
||||
actualDataG_->vertices[i][j+step][1],
|
||||
actualDataG_->vertices[i][j+step][2]);
|
||||
|
||||
double diff = 0;
|
||||
for (int m = 0; m!=4; ++m)
|
||||
{
|
||||
int mm = (m+1)%4;
|
||||
if ((val>=t[m].z && val<=t[mm].z) || (val>=t[mm].z && val<=t[m].z))
|
||||
{
|
||||
diff = t[mm].z - t[m].z;
|
||||
|
||||
if (isPracticallyZero(diff)) // degenerated
|
||||
{
|
||||
intersection.push_back(t[m]);
|
||||
intersection.push_back(t[mm]);
|
||||
continue;
|
||||
}
|
||||
|
||||
lambda = (val - t[m].z) / diff;
|
||||
intersection.push_back(Triple(t[m].x + lambda * (t[mm].x-t[m].x), t[m].y + lambda * (t[mm].y-t[m].y), val));
|
||||
}
|
||||
}
|
||||
|
||||
if (!intersection.empty())
|
||||
{
|
||||
if (intersection.size()>2)
|
||||
{
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (unsigned dd = 0; dd!=intersection.size(); ++dd)
|
||||
{
|
||||
glVertex3d(intersection[dd].x, intersection[dd].y, zshift);
|
||||
}
|
||||
glEnd();
|
||||
glBegin(GL_POINTS);
|
||||
glVertex3d(intersection[0].x,intersection[0].y,zshift);
|
||||
glEnd();
|
||||
}
|
||||
else if (intersection.size() == 2)
|
||||
{
|
||||
glBegin(GL_LINES);
|
||||
glVertex3d(intersection[0].x,intersection[0].y,zshift);
|
||||
glVertex3d(intersection[1].x,intersection[1].y,zshift);
|
||||
|
||||
// small pixel gap problem (see OpenGL spec.)
|
||||
glVertex3d(intersection[1].x,intersection[1].y,zshift);
|
||||
glVertex3d(intersection[0].x,intersection[0].y,zshift);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
intersection.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
void SurfacePlot::calcLowResolution()
|
||||
{
|
||||
if (!actualDataG_)
|
||||
return;
|
||||
|
||||
int res = resolution();
|
||||
if (res == 1)
|
||||
{
|
||||
lowresData_p = *actualDataG_;
|
||||
return;
|
||||
}
|
||||
|
||||
GridData const& src = *actualDataG_;
|
||||
result.clear();
|
||||
|
||||
|
||||
}*/
|
||||
|
@ -0,0 +1,355 @@
|
||||
#include <time.h>
|
||||
|
||||
#include "qwt3d_plot.h"
|
||||
#include "qwt3d_io_gl2ps.h"
|
||||
#include "qwt3d_io_reader.h"
|
||||
#if QT_VERSION < 0x040000
|
||||
#else
|
||||
#include <QImageWriter>
|
||||
#endif
|
||||
|
||||
using namespace Qwt3D;
|
||||
|
||||
IO::Entry::Entry() : iofunc(0)
|
||||
{
|
||||
}
|
||||
|
||||
IO::Entry::~Entry()
|
||||
{
|
||||
delete iofunc;
|
||||
}
|
||||
|
||||
IO::Entry::Entry(IO::Entry const& e)
|
||||
{
|
||||
if (this==&e)
|
||||
return;
|
||||
|
||||
fmt = e.fmt;
|
||||
iofunc = e.iofunc->clone();
|
||||
}
|
||||
|
||||
void IO::Entry::operator=(IO::Entry const& e)
|
||||
{
|
||||
if (this==&e)
|
||||
return;
|
||||
|
||||
delete iofunc;
|
||||
fmt = e.fmt;
|
||||
iofunc = e.iofunc->clone();
|
||||
}
|
||||
|
||||
IO::Entry::Entry(QString const& s, Functor const& f)
|
||||
: fmt(s)
|
||||
{
|
||||
iofunc = f.clone();
|
||||
}
|
||||
|
||||
IO::Entry::Entry(QString const& s, Function f)
|
||||
: fmt(s)
|
||||
{
|
||||
Wrapper w(f);
|
||||
iofunc = w.clone();
|
||||
}
|
||||
|
||||
|
||||
IO::FormatCompare::FormatCompare(IO::Entry const& e)
|
||||
{
|
||||
e_ = e;
|
||||
}
|
||||
|
||||
bool IO::FormatCompare::operator() (IO::Entry const& e)
|
||||
{
|
||||
return ( e.fmt == e_.fmt);
|
||||
}
|
||||
|
||||
IO::FormatCompare2::FormatCompare2(QString s)
|
||||
{
|
||||
s_ = s;
|
||||
}
|
||||
|
||||
bool IO::FormatCompare2::operator() (IO::Entry const& e)
|
||||
{
|
||||
return( e.fmt == s_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool IO::add_unique(Container& l, Entry const& e)
|
||||
{
|
||||
FormatCompare comp(e);
|
||||
l.erase(std::remove_if(l.begin(), l.end(), comp), l.end());
|
||||
l.push_back(e);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
IO::IT IO::find(Container& l, QString const& fmt)
|
||||
{
|
||||
FormatCompare2 comp(fmt);
|
||||
return std::find_if(l.begin(), l.end(), comp);
|
||||
}
|
||||
|
||||
IO::Container& IO::rlist()
|
||||
{
|
||||
static Container rl = Container();
|
||||
static bool rfirst = true;
|
||||
bool f = false;
|
||||
f = rfirst;
|
||||
if (rfirst)
|
||||
{
|
||||
rfirst = false;
|
||||
setupHandler();
|
||||
}
|
||||
return rl;
|
||||
}
|
||||
|
||||
IO::Container& IO::wlist()
|
||||
{
|
||||
static Container wl = Container();
|
||||
static bool wfirst = true;
|
||||
bool f = false;
|
||||
f = wfirst;
|
||||
if (wfirst)
|
||||
{
|
||||
wfirst = false;
|
||||
setupHandler();
|
||||
}
|
||||
return wl;
|
||||
}
|
||||
|
||||
/*!
|
||||
Registers a new IO::Function for data input.\n
|
||||
Every call overwrites a formerly registered handler for the same format string
|
||||
(case sensitive).
|
||||
*/
|
||||
bool IO::defineInputHandler(QString const& format, IO::Function func)
|
||||
{
|
||||
return add_unique(rlist(), Entry(format, func));
|
||||
}
|
||||
|
||||
/*!
|
||||
Registers a new Functor for data input.\n
|
||||
Every call overwrites a formerly registered handler for the same format string
|
||||
(case sensitive).
|
||||
*/
|
||||
bool IO::defineInputHandler(QString const& format, IO::Functor const& func)
|
||||
{
|
||||
return add_unique(rlist(), Entry(format, func));
|
||||
}
|
||||
|
||||
/*!
|
||||
Registers a new IO::Function for data output.
|
||||
Every call overwrites a formerly registered handler for the same format string
|
||||
(case sensitive).
|
||||
*/
|
||||
bool IO::defineOutputHandler(QString const& format, IO::Function func)
|
||||
{
|
||||
return add_unique(wlist(), Entry(format, func));
|
||||
}
|
||||
|
||||
/*!
|
||||
Registers a new Functor for data output.\n
|
||||
Every call overwrites a formerly registered handler for the same format string
|
||||
(case sensitive).
|
||||
*/
|
||||
bool IO::defineOutputHandler(QString const& format, IO::Functor const& func)
|
||||
{
|
||||
return add_unique(wlist(), Entry(format, func));
|
||||
}
|
||||
|
||||
/*!
|
||||
Applies a reading IO::Function or IO::Functor.
|
||||
\param plot Plot with the content that should be loaded
|
||||
\param fname File name
|
||||
\param format Input format
|
||||
\return The return value from the called Function/Functor.
|
||||
The function returns false, if no registered handler could be found.
|
||||
*/
|
||||
bool IO::load(Plot3D* plot, QString const& fname, QString const& format)
|
||||
{
|
||||
IT it = IO::find(rlist(), format);
|
||||
|
||||
if (it == rlist().end())
|
||||
return false;
|
||||
|
||||
return (*it->iofunc)(plot, fname);
|
||||
}
|
||||
|
||||
/*!
|
||||
Applies a writing IO::Function or IO::Functor.
|
||||
\param plot Plot with the content that should be saved
|
||||
\param fname File name
|
||||
\param format Output format
|
||||
\return The return value from the called Function/Functor.
|
||||
The function returns false, if no registered handler could be found.
|
||||
*/
|
||||
bool IO::save(Plot3D* plot, QString const& fname, QString const& format)
|
||||
{
|
||||
IT it = IO::find(wlist(), format);
|
||||
|
||||
if (it == wlist().end())
|
||||
return false;
|
||||
|
||||
return (*it->iofunc)(plot, fname);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a list of currently registered input formats.
|
||||
*/
|
||||
QStringList IO::inputFormatList()
|
||||
{
|
||||
QStringList list;
|
||||
for ( IT it = rlist().begin(); it!=rlist().end(); ++it )
|
||||
list.append(it->fmt);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a list of currently registered output formats.
|
||||
*/
|
||||
QStringList IO::outputFormatList()
|
||||
{
|
||||
QStringList list;
|
||||
for ( IT it = wlist().begin(); it!=wlist().end(); ++it )
|
||||
list.append(it->fmt);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the input functor in charge for format and 0 if non-existent.
|
||||
*/
|
||||
IO::Functor* IO::inputHandler(QString const& format)
|
||||
{
|
||||
IO::IT it = IO::find(rlist(), format);
|
||||
|
||||
if (it==rlist().end())
|
||||
return 0;
|
||||
|
||||
return it->iofunc;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the output functor in charge for format and 0 if non-existent.
|
||||
*/
|
||||
IO::Functor* IO::outputHandler(QString const& format)
|
||||
{
|
||||
IO::IT it = IO::find(wlist(), format);
|
||||
|
||||
if (it==wlist().end())
|
||||
return 0;
|
||||
|
||||
return it->iofunc;
|
||||
}
|
||||
|
||||
bool PixmapWriter::operator()(Plot3D* plot, QString const& fname)
|
||||
{
|
||||
QImage im = plot->grabFrameBuffer(true);
|
||||
|
||||
#if QT_VERSION < 0x040000
|
||||
QImageIO iio;
|
||||
iio.setImage(im);
|
||||
#else
|
||||
QImageWriter iio;
|
||||
#endif
|
||||
iio.setFormat(QWT3DLOCAL8BIT(fmt_));
|
||||
iio.setQuality(quality_);
|
||||
iio.setFileName(fname);
|
||||
#if QT_VERSION < 0x040000
|
||||
return iio.write();
|
||||
#else
|
||||
return iio.write(im);
|
||||
#endif
|
||||
}
|
||||
|
||||
//! Calls Qt's QImageIO::setQuality() function.
|
||||
void PixmapWriter::setQuality(int val)
|
||||
{
|
||||
quality_ = val;
|
||||
}
|
||||
|
||||
void IO::setupHandler()
|
||||
{
|
||||
#if QT_VERSION < 0x040000
|
||||
QStringList list = QImage::outputFormatList();
|
||||
QStringList::Iterator it = list.begin();
|
||||
#else
|
||||
QList<QByteArray> list = QImageWriter::supportedImageFormats();
|
||||
QList<QByteArray>::Iterator it = list.begin();
|
||||
#endif
|
||||
PixmapWriter qtw;
|
||||
while( it != list.end() )
|
||||
{
|
||||
qtw.fmt_ = *it;
|
||||
defineOutputHandler(*it, qtw);
|
||||
++it;
|
||||
}
|
||||
VectorWriter vecfunc;
|
||||
vecfunc.setCompressed(false);
|
||||
vecfunc.setFormat("EPS");
|
||||
defineOutputHandler("EPS", vecfunc);
|
||||
vecfunc.setFormat("PS");
|
||||
defineOutputHandler("PS", vecfunc);
|
||||
|
||||
#ifdef GL2PS_HAVE_ZLIB
|
||||
vecfunc.setCompressed(true);
|
||||
vecfunc.setFormat("EPS_GZ");
|
||||
defineOutputHandler("EPS_GZ", vecfunc);
|
||||
vecfunc.setFormat("PS_GZ");
|
||||
defineOutputHandler("PS_GZ", vecfunc);
|
||||
#endif
|
||||
vecfunc.setFormat("PDF");
|
||||
defineOutputHandler("PDF", vecfunc);
|
||||
|
||||
defineInputHandler("mes", NativeReader());
|
||||
defineInputHandler("MES", NativeReader());
|
||||
}
|
||||
|
||||
/*!
|
||||
\deprecated Use Plot3D::save or IO::save instead.
|
||||
|
||||
Writes vector data supported by gl2ps. The corresponding format types are "EPS","PS"or "PDF".
|
||||
If zlib has been configured this will be extended by "EPS_GZ" and "PS_GZ".
|
||||
\b Beware: BSPSORT turns out to behave very slowly and memory consuming, especially in cases where
|
||||
many polygons appear. It is still more exact than SIMPLESORT.
|
||||
*/
|
||||
bool Plot3D::saveVector(QString const& fileName, QString const& format, VectorWriter::TEXTMODE text, VectorWriter::SORTMODE sortmode)
|
||||
{
|
||||
if (format == "EPS" || format == "EPS_GZ" || format == "PS"
|
||||
|| format == "PS_GZ" || format == "PDF")
|
||||
{
|
||||
VectorWriter* gl2ps = (VectorWriter*)IO::outputHandler(format);
|
||||
if (gl2ps)
|
||||
{
|
||||
gl2ps->setSortMode(sortmode);
|
||||
gl2ps->setTextMode(text);
|
||||
}
|
||||
return IO::save(this, fileName, format);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/*!
|
||||
\deprecated Use Plot3D::save or IO::save instead.
|
||||
|
||||
Saves the framebuffer to the file fileName using one of the image file formats supported by Qt.
|
||||
*/
|
||||
bool Plot3D::savePixmap(QString const& fileName, QString const& format)
|
||||
{
|
||||
if (format == "EPS" || format == "EPS_GZ" || format == "PS"
|
||||
|| format == "PS_GZ" || format == "PDF")
|
||||
return false;
|
||||
|
||||
return IO::save(this, fileName, format);
|
||||
}
|
||||
|
||||
/*!
|
||||
Saves content in one of the registered output formats. To modify the
|
||||
behaviour for more complex output handling use IO::outputHandler.
|
||||
*/
|
||||
bool Plot3D::save(QString const& fileName, QString const& format)
|
||||
{
|
||||
return IO::save(this, fileName, format);
|
||||
}
|
||||
|
@ -0,0 +1,387 @@
|
||||
#if defined(_MSC_VER) /* MSVC Compiler */
|
||||
#pragma warning ( disable : 4786 )
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
#include "qwt3d_openglhelper.h"
|
||||
#include "../3rdparty/gl2ps/gl2ps.h"
|
||||
#include "qwt3d_io_gl2ps.h"
|
||||
#include "qwt3d_plot.h"
|
||||
|
||||
using namespace Qwt3D;
|
||||
|
||||
//! Provides a new VectorWriter object.
|
||||
IO::Functor* VectorWriter::clone() const
|
||||
{
|
||||
return new VectorWriter(*this);
|
||||
}
|
||||
|
||||
VectorWriter::VectorWriter()
|
||||
: gl2ps_format_(GL2PS_EPS),
|
||||
formaterror_(false),
|
||||
#ifdef GL2PS_HAVE_ZLIB
|
||||
compressed_(true),
|
||||
#else
|
||||
compressed_(false),
|
||||
#endif
|
||||
sortmode_(SIMPLESORT),
|
||||
landscape_(VectorWriter::AUTO),
|
||||
textmode_(VectorWriter::PIXEL),
|
||||
texfname_("")
|
||||
{}
|
||||
|
||||
|
||||
/*!
|
||||
Sets the mode for text output:\n
|
||||
\param val The underlying format for the generated output:\n
|
||||
PIXEL - poor quality but exact positioning\n
|
||||
NATIVE - high quality but inexact positioning\n
|
||||
TEX - high quality and exact positioning, arbitrary TeX strings as content for
|
||||
the saved labels are possible. The disadvantage is the need for an additionally TeX run
|
||||
to get the final output.\n
|
||||
\param fname Optional, used only in conjunction with TeX output; file name
|
||||
for the generated TeX file. If not set, a file called "OUTPUT.FOR.tex"
|
||||
will be generated, where "OUTPUT.FOR" describes the file name argument for IO::save().\n\n
|
||||
(04/05/27: On Linux platforms, pdflatex seems a file named 'dump_0.pdf.tex' mistakenly to
|
||||
identify as PDF file.)
|
||||
*/
|
||||
void VectorWriter::setTextMode(TEXTMODE val, QString fname)
|
||||
{
|
||||
textmode_ = val;
|
||||
texfname_ = (fname.isEmpty()) ? QString("") : fname;
|
||||
}
|
||||
|
||||
|
||||
#ifdef GL2PS_HAVE_ZLIB
|
||||
//! Turns compressed output on or off (no effect if zlib support has not been set)
|
||||
void VectorWriter::setCompressed(bool val)
|
||||
{
|
||||
compressed_ = val;
|
||||
}
|
||||
#else
|
||||
//! Turns compressed output on or off (no effect if zlib support has not been set)
|
||||
void VectorWriter::setCompressed(bool)
|
||||
{
|
||||
compressed_ = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*!
|
||||
Set output format, must be one of "EPS_GZ", "PS_GZ", "EPS",
|
||||
"PS", "PDF" (case sensitive)
|
||||
*/
|
||||
bool VectorWriter::setFormat(QString const& format)
|
||||
{
|
||||
if (format == QString("EPS"))
|
||||
{
|
||||
gl2ps_format_ = GL2PS_EPS;
|
||||
}
|
||||
else if (format == QString("PS"))
|
||||
{
|
||||
gl2ps_format_ = GL2PS_PS;
|
||||
}
|
||||
else if (format == QString("PDF"))
|
||||
{
|
||||
gl2ps_format_ = GL2PS_PDF;
|
||||
}
|
||||
#ifdef GL2PS_HAVE_ZLIB
|
||||
else if (format == QString("EPS_GZ"))
|
||||
{
|
||||
gl2ps_format_ = GL2PS_EPS;
|
||||
}
|
||||
else if (format == QString("PS_GZ"))
|
||||
{
|
||||
gl2ps_format_ = GL2PS_PS;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
formaterror_ = true;
|
||||
return false;
|
||||
}
|
||||
formaterror_ = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Performs actual output
|
||||
bool VectorWriter::operator()(Plot3D* plot, QString const& fname)
|
||||
{
|
||||
if (formaterror_)
|
||||
return false;
|
||||
|
||||
plot->makeCurrent();
|
||||
|
||||
|
||||
GLint bufsize = 0, state = GL2PS_OVERFLOW;
|
||||
GLint viewport[4];
|
||||
|
||||
glGetIntegerv(GL_VIEWPORT, viewport);
|
||||
|
||||
GLint options = GL2PS_SIMPLE_LINE_OFFSET | GL2PS_SILENT | GL2PS_DRAW_BACKGROUND |
|
||||
GL2PS_OCCLUSION_CULL | GL2PS_BEST_ROOT;
|
||||
|
||||
|
||||
if (compressed_)
|
||||
options |= GL2PS_COMPRESS;
|
||||
|
||||
switch (landscape_)
|
||||
{
|
||||
case VectorWriter::AUTO:
|
||||
if (viewport[2] - viewport[0] > viewport[3] - viewport[0])
|
||||
options |= GL2PS_LANDSCAPE;
|
||||
break;
|
||||
case VectorWriter::ON:
|
||||
options |= GL2PS_LANDSCAPE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
int sortmode = GL2PS_SIMPLE_SORT;
|
||||
switch (sortmode_)
|
||||
{
|
||||
case VectorWriter::NOSORT:
|
||||
sortmode = GL2PS_NO_SORT;
|
||||
break;
|
||||
case VectorWriter::SIMPLESORT:
|
||||
sortmode = GL2PS_SIMPLE_SORT;
|
||||
break;
|
||||
case VectorWriter::BSPSORT:
|
||||
sortmode = GL2PS_BSP_SORT;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (textmode_)
|
||||
{
|
||||
case NATIVE:
|
||||
Label::useDeviceFonts(true);
|
||||
break;
|
||||
case PIXEL:
|
||||
Label::useDeviceFonts(false);
|
||||
break;
|
||||
case TEX:
|
||||
options |= GL2PS_NO_PIXMAP | GL2PS_NO_TEXT;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
QString version = QString::number(QWT3D_MAJOR_VERSION) + "."
|
||||
+ QString::number(QWT3D_MINOR_VERSION) + "."
|
||||
+ QString::number(QWT3D_PATCH_VERSION);
|
||||
|
||||
QString producer = QString("QwtPlot3D ") + version +
|
||||
" (beta) , (C) 2002";
|
||||
|
||||
// calculate actual year
|
||||
time_t now;
|
||||
struct tm *newtime;
|
||||
time(&now);
|
||||
newtime = gmtime(&now);
|
||||
if (newtime && newtime->tm_year + 1900 > 2002)
|
||||
producer += "-" + QString::number(newtime->tm_year+1900);
|
||||
|
||||
producer += " Micha Bieber <krischnamurti@users.sourceforge.net>";
|
||||
|
||||
FILE *fp = fopen(QWT3DLOCAL8BIT(fname), "wb");
|
||||
if (!fp)
|
||||
{
|
||||
Label::useDeviceFonts(false);
|
||||
return false;
|
||||
}
|
||||
while( state == GL2PS_OVERFLOW )
|
||||
{
|
||||
bufsize += 2*1024*1024;
|
||||
gl2psBeginPage ( "---", QWT3DLOCAL8BIT(producer), viewport,
|
||||
gl2ps_format_, sortmode,
|
||||
options, GL_RGBA, 0, NULL, 0, 0, 0, bufsize,
|
||||
fp, QWT3DLOCAL8BIT(fname) );
|
||||
|
||||
plot->updateData();
|
||||
plot->updateGL();
|
||||
state = gl2psEndPage();
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
// extra TeX file
|
||||
if (textmode_ == TEX)
|
||||
{
|
||||
QString fn = (texfname_.isEmpty())
|
||||
? fname + ".tex"
|
||||
: texfname_;
|
||||
|
||||
fp = fopen(QWT3DLOCAL8BIT(fn), "wb");
|
||||
if (!fp)
|
||||
{
|
||||
Label::useDeviceFonts(false);
|
||||
return false;
|
||||
}
|
||||
Label::useDeviceFonts(true);
|
||||
options &= ~GL2PS_NO_PIXMAP & ~GL2PS_NO_TEXT;
|
||||
state = GL2PS_OVERFLOW;
|
||||
while( state == GL2PS_OVERFLOW )
|
||||
{
|
||||
bufsize += 2*1024*1024;
|
||||
gl2psBeginPage ( "---", QWT3DLOCAL8BIT(producer), viewport,
|
||||
GL2PS_TEX, sortmode,
|
||||
options, GL_RGBA, 0, NULL, 0, 0, 0, bufsize,
|
||||
fp, QWT3DLOCAL8BIT(fn) );
|
||||
|
||||
plot->updateData();
|
||||
plot->updateGL();
|
||||
state = gl2psEndPage();
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
|
||||
Label::useDeviceFonts(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// moved
|
||||
|
||||
GLint Qwt3D::setDeviceLineWidth(GLfloat val)
|
||||
{
|
||||
if (val<0)
|
||||
val=0;
|
||||
|
||||
GLint ret = gl2psLineWidth(val);
|
||||
|
||||
GLfloat lw[2];
|
||||
glGetFloatv(GL_LINE_WIDTH_RANGE, lw);
|
||||
|
||||
if (val < lw[0])
|
||||
val = lw[0];
|
||||
else if (val > lw[1])
|
||||
val = lw[1];
|
||||
|
||||
glLineWidth(val);
|
||||
return ret;
|
||||
}
|
||||
|
||||
GLint Qwt3D::setDevicePointSize(GLfloat val)
|
||||
{
|
||||
if (val<0)
|
||||
val=0;
|
||||
|
||||
GLint ret = gl2psPointSize(val);
|
||||
|
||||
GLfloat lw[2];
|
||||
glGetFloatv(GL_POINT_SIZE_RANGE, lw);
|
||||
|
||||
if (val < lw[0])
|
||||
val = lw[0];
|
||||
else if (val > lw[1])
|
||||
val = lw[1];
|
||||
|
||||
glPointSize(val);
|
||||
return ret;
|
||||
}
|
||||
|
||||
GLint Qwt3D::drawDevicePixels(GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type,
|
||||
const void *pixels)
|
||||
{
|
||||
glDrawPixels(width, height, format, type, pixels);
|
||||
|
||||
if(format != GL_RGBA || type != GL_UNSIGNED_BYTE)
|
||||
return GL2PS_ERROR;
|
||||
|
||||
GLfloat* convertedpixel = (GLfloat*)malloc(3 * width * height * sizeof(GLfloat));
|
||||
if (!convertedpixel)
|
||||
return GL2PS_ERROR;
|
||||
|
||||
GLubyte* px = (GLubyte*)pixels;
|
||||
for (int i=0; i!=3*width*height; i+=3)
|
||||
{
|
||||
int pxi = (4*i)/3;
|
||||
convertedpixel[i] = px[pxi] / float(255);
|
||||
convertedpixel[i+1] = px[pxi+1] / float(255);
|
||||
convertedpixel[i+2] = px[pxi+2] / float(255);
|
||||
}
|
||||
GLint ret = gl2psDrawPixels(width, height, 0, 0, GL_RGB, GL_FLOAT, convertedpixel);
|
||||
free(convertedpixel);
|
||||
return ret;
|
||||
}
|
||||
|
||||
GLint Qwt3D::drawDeviceText(const char* str, const char* fontname, int fontsize, Triple pos, RGBA /*rgba*/, ANCHOR align, double gap)
|
||||
{
|
||||
double vp[3];
|
||||
|
||||
World2ViewPort(vp[0], vp[1], vp[2], pos.x, pos.y, pos.z);
|
||||
Triple start(vp[0],vp[1],vp[2]);
|
||||
|
||||
GLdouble fcol[4];
|
||||
glGetDoublev(GL_CURRENT_COLOR, fcol);
|
||||
GLdouble bcol[4];
|
||||
glGetDoublev(GL_COLOR_CLEAR_VALUE, bcol);
|
||||
|
||||
// glColor4d(color.r, color.g, color.b, color.a);
|
||||
// glClearColor(color.r, color.g, color.b, color.a);
|
||||
|
||||
GLint ret = GL2PS_SUCCESS;
|
||||
|
||||
GLint a = GL2PS_TEXT_BL;
|
||||
switch(align)
|
||||
{
|
||||
case Center:
|
||||
a = GL2PS_TEXT_C;
|
||||
break;
|
||||
case CenterLeft:
|
||||
a = GL2PS_TEXT_CL;
|
||||
start += Triple(gap,0,0);
|
||||
break;
|
||||
case CenterRight:
|
||||
a = GL2PS_TEXT_CR;
|
||||
start += Triple(-gap,0,0);
|
||||
break;
|
||||
case BottomCenter:
|
||||
a = GL2PS_TEXT_B;
|
||||
start += Triple(0,gap,0);
|
||||
break;
|
||||
case BottomLeft:
|
||||
a = GL2PS_TEXT_BL;
|
||||
start += Triple(gap,gap,0);
|
||||
break;
|
||||
case BottomRight:
|
||||
a = GL2PS_TEXT_BR;
|
||||
start += Triple(-gap,gap,0);
|
||||
break;
|
||||
case TopCenter:
|
||||
a = GL2PS_TEXT_T;
|
||||
start += Triple(0,-gap,0);
|
||||
break;
|
||||
case TopLeft:
|
||||
a = GL2PS_TEXT_TL;
|
||||
start += Triple(gap,-gap,0);
|
||||
break;
|
||||
case TopRight:
|
||||
a = GL2PS_TEXT_TR;
|
||||
start += Triple(-gap,-gap,0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
ViewPort2World(vp[0], vp[1], vp[2], start.x, start.y, start.z);
|
||||
Triple adjpos(vp[0],vp[1],vp[2]);
|
||||
|
||||
glRasterPos3d(adjpos.x, adjpos.y, adjpos.z);
|
||||
ret = gl2psTextOpt(str, fontname, (int)fontsize, a, 0);
|
||||
glColor4dv(fcol);
|
||||
glClearColor(bcol[0], bcol[1], bcol[2], bcol[3]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Qwt3D::setDevicePolygonOffset(GLfloat factor, GLfloat units)
|
||||
{
|
||||
glPolygonOffset(factor, units);
|
||||
gl2psEnable(GL2PS_POLYGON_OFFSET_FILL);
|
||||
}
|
||||
|
@ -0,0 +1,225 @@
|
||||
#if defined(_MSC_VER) /* MSVC Compiler */
|
||||
#pragma warning ( disable : 4786 )
|
||||
#endif
|
||||
|
||||
#include <float.h>
|
||||
#include <stdio.h>
|
||||
#include <qtextstream.h>
|
||||
|
||||
#include "qwt3d_surfaceplot.h"
|
||||
#include "qwt3d_io_reader.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace Qwt3D;
|
||||
|
||||
const char* NativeReader::magicstring = "jk:11051895-17021986";
|
||||
|
||||
namespace
|
||||
{
|
||||
FILE* open(QString fname)
|
||||
{
|
||||
FILE* file = fopen(QWT3DLOCAL8BIT(fname), "r");
|
||||
if (!file)
|
||||
{
|
||||
fprintf(stderr, "NativeReader::read: cannot open data file \"%s\"\n", QWT3DLOCAL8BIT(fname));
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
int read_char (FILE * fp, bool skipcomments = true)
|
||||
{
|
||||
int c;
|
||||
|
||||
if ((c = fgetc (fp)) == EOF)
|
||||
return (c);
|
||||
if (skipcomments)
|
||||
{
|
||||
if (c == '#')
|
||||
{
|
||||
do
|
||||
{
|
||||
if ((c = fgetc (fp)) == EOF)
|
||||
return (c);
|
||||
}
|
||||
while (c != '\n' && c != '\r');
|
||||
}
|
||||
}
|
||||
return (c);
|
||||
}
|
||||
|
||||
char* read_field (FILE * fp, bool skipcomments = true)
|
||||
{
|
||||
static char buf[71];
|
||||
int c, i;
|
||||
|
||||
do
|
||||
{
|
||||
if ((c = read_char (fp,skipcomments)) == EOF)
|
||||
return (NULL);
|
||||
}
|
||||
while (isspace (c));
|
||||
for (i = 0; i < 70 && !isspace (c); ++i)
|
||||
{
|
||||
buf[i] = c;
|
||||
if ((c = read_char (fp,skipcomments)) == EOF)
|
||||
break;
|
||||
}
|
||||
buf[i] = '\0';
|
||||
return (buf);
|
||||
}
|
||||
|
||||
|
||||
//! set to data begin
|
||||
bool extract_info(FILE* fp, unsigned int& xmesh, unsigned int& ymesh, double& xmin, double& xmax, double& ymin, double& ymax)
|
||||
{
|
||||
char* p;
|
||||
|
||||
// find out the size
|
||||
if ((p = read_field (fp)) == 0)
|
||||
return false;
|
||||
xmesh = (unsigned int)atoi(p);
|
||||
|
||||
if ((p = read_field (fp)) == 0)
|
||||
return false;
|
||||
ymesh = (unsigned int)atoi (p);
|
||||
|
||||
if (xmesh < 1 || ymesh < 1)
|
||||
return false;
|
||||
|
||||
// ... and the limits
|
||||
if ((p = read_field (fp)) == 0)
|
||||
return false;
|
||||
xmin = atof (p);
|
||||
|
||||
if ((p = read_field (fp)) == 0)
|
||||
return false;
|
||||
xmax = atof (p);
|
||||
|
||||
if ((p = read_field (fp)) == 0)
|
||||
return false;
|
||||
ymin = atof (p);
|
||||
|
||||
if ((p = read_field (fp)) == 0)
|
||||
return false;
|
||||
ymax = atof (p);
|
||||
|
||||
if (xmin > xmax || ymin > ymax)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//! find out what the magic string is and compare
|
||||
bool check_magic(FILE* fp, const char* val)
|
||||
{
|
||||
char* p;
|
||||
if ((p = read_field (fp,false)) == 0)
|
||||
return false;
|
||||
|
||||
if (strcmp (p, val ) != 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
//! find out what the type is
|
||||
bool check_type(FILE* fp, const char* val)
|
||||
{
|
||||
char* p;
|
||||
if ((p = read_field (fp)) == 0)
|
||||
return false;
|
||||
|
||||
if (strcmp (p, val ) != 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
double** allocateData(int columns, int rows)
|
||||
{
|
||||
double** data = new double* [columns] ;
|
||||
|
||||
for ( int i = 0; i < columns; ++i)
|
||||
{
|
||||
data[i] = new double [rows];
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
void deleteData(double**data, int columns)
|
||||
{
|
||||
for ( int i = 0; i < columns; i++)
|
||||
{
|
||||
delete [] data[i];
|
||||
}
|
||||
delete [] data;
|
||||
}
|
||||
}
|
||||
|
||||
NativeReader::NativeReader()
|
||||
: minz_(-DBL_MAX), maxz_(DBL_MAX)
|
||||
{
|
||||
}
|
||||
|
||||
bool NativeReader::collectInfo(FILE*& file, QString const& fname, unsigned& xmesh, unsigned& ymesh,
|
||||
double& minx, double& maxx, double& miny, double& maxy)
|
||||
{
|
||||
if (fname.isEmpty())
|
||||
return false;
|
||||
|
||||
file = open(fname);
|
||||
|
||||
if (!file)
|
||||
return false;
|
||||
|
||||
|
||||
if (
|
||||
(!check_magic(file, magicstring))
|
||||
||(!check_type(file, "MESH"))
|
||||
||(!extract_info(file, xmesh, ymesh, minx, maxx, miny, maxy))
|
||||
)
|
||||
{
|
||||
fclose(file);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool NativeReader::operator()(Plot3D* plot, QString const& fname)
|
||||
{
|
||||
|
||||
FILE* file;
|
||||
unsigned int xmesh, ymesh;
|
||||
double minx, maxx, miny, maxy;
|
||||
|
||||
if ( !collectInfo(file, fname, xmesh, ymesh, minx, maxx, miny, maxy) )
|
||||
return false;
|
||||
|
||||
/* allocate some space for the mesh */
|
||||
double** data = allocateData(xmesh, ymesh);
|
||||
|
||||
for (unsigned int j = 0; j < ymesh; j++)
|
||||
{
|
||||
for (unsigned int i = 0; i < xmesh; i++)
|
||||
{
|
||||
if (fscanf(file, "%lf", &data[i][j]) != 1)
|
||||
{
|
||||
fprintf(stderr, "NativeReader::read: error in data file \"%s\"\n", QWT3DLOCAL8BIT(fname));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (data[i][j] > maxz_)
|
||||
data[i][j] = maxz_;
|
||||
else if (data[i][j] < minz_)
|
||||
data[i][j] = minz_;
|
||||
}
|
||||
}
|
||||
|
||||
/* close the file */
|
||||
fclose(file);
|
||||
|
||||
((SurfacePlot*)plot)->loadFromData(data, xmesh, ymesh, minx, maxx, miny, maxy);
|
||||
deleteData(data,xmesh);
|
||||
|
||||
return true;
|
||||
}
|
@ -0,0 +1,262 @@
|
||||
#include <qbitmap.h>
|
||||
#include "qwt3d_label.h"
|
||||
|
||||
using namespace Qwt3D;
|
||||
|
||||
bool Label::devicefonts_ = false;
|
||||
|
||||
Label::Label()
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
Label::Label(const QString & family, int pointSize, int weight, bool italic)
|
||||
{
|
||||
init(family, pointSize, weight, italic);
|
||||
}
|
||||
|
||||
|
||||
void Label::init(const QString & family, int pointSize, int weight, bool italic)
|
||||
{
|
||||
init();
|
||||
font_ = QFont(family, pointSize, weight, italic );
|
||||
}
|
||||
|
||||
void Label::init()
|
||||
{
|
||||
beg_ = Triple(0.0, 0.0, 0.0);
|
||||
end_ = beg_;
|
||||
pos_ = beg_;
|
||||
setColor(0,0,0);
|
||||
pm_ = QPixmap(0, 0);
|
||||
font_ = QFont();
|
||||
anchor_ = BottomLeft;
|
||||
gap_ = 0;
|
||||
flagforupdate_ = true;
|
||||
}
|
||||
|
||||
void Label::useDeviceFonts(bool val)
|
||||
{
|
||||
devicefonts_ = val;
|
||||
}
|
||||
|
||||
void Label::setFont(const QString & family, int pointSize, int weight, bool italic)
|
||||
{
|
||||
font_ = QFont(family, pointSize, weight, italic );
|
||||
flagforupdate_ = true;
|
||||
}
|
||||
|
||||
void Label::setString(QString const& s)
|
||||
{
|
||||
text_ = s;
|
||||
flagforupdate_ = true;
|
||||
}
|
||||
|
||||
void Label::setColor(double r, double g, double b, double a)
|
||||
{
|
||||
Drawable::setColor(r,g,b,a);
|
||||
flagforupdate_ = true;
|
||||
}
|
||||
|
||||
void Label::setColor(Qwt3D::RGBA rgba)
|
||||
{
|
||||
Drawable::setColor(rgba);
|
||||
flagforupdate_ = true;
|
||||
}
|
||||
|
||||
/**
|
||||
example:
|
||||
|
||||
\verbatim
|
||||
|
||||
Anchor TopCenter (*) resp. BottomRight(X)
|
||||
|
||||
+----*----+
|
||||
| Pixmap |
|
||||
+---------X
|
||||
|
||||
\endverbatim
|
||||
*/
|
||||
void Label::setPosition(Triple pos, ANCHOR a)
|
||||
{
|
||||
anchor_ = a;
|
||||
pos_ = pos;
|
||||
}
|
||||
|
||||
void Label::setRelPosition(Tuple rpos, ANCHOR a)
|
||||
{
|
||||
double ot = 0.99;
|
||||
|
||||
getMatrices(modelMatrix, projMatrix, viewport);
|
||||
beg_ = relativePosition(Triple(rpos.x, rpos.y, ot));
|
||||
setPosition(beg_, a);
|
||||
}
|
||||
|
||||
void Label::update()
|
||||
{
|
||||
QPainter p;
|
||||
QFontMetrics fm(font_);
|
||||
|
||||
QFontInfo info(font_);
|
||||
|
||||
QRect r = QRect(QPoint(0,0),fm.size(Qwt3D::SingleLine, text_));//fm.boundingRect(text_) misbehaviour under linux;
|
||||
|
||||
#if QT_VERSION < 0x040000
|
||||
r.moveBy(0, -r.top());
|
||||
#else
|
||||
r.translate(0, -r.top());
|
||||
#endif
|
||||
|
||||
pm_ = QPixmap(r.width(), r.bottom());
|
||||
|
||||
if (pm_.isNull()) // else crash under linux
|
||||
{
|
||||
r = QRect(QPoint(0,0),fm.size(Qwt3D::SingleLine, QString(" "))); // draw empty space else //todo
|
||||
#if QT_VERSION < 0x040000
|
||||
r.moveBy(0, -r.top());
|
||||
#else
|
||||
r.translate(0, -r.top());
|
||||
#endif
|
||||
pm_ = QPixmap(r.width(), r.bottom());
|
||||
}
|
||||
|
||||
QBitmap bm(pm_.width(),pm_.height());
|
||||
bm.fill(Qt::color0);
|
||||
p.begin( &bm );
|
||||
p.setPen(Qt::color1);
|
||||
p.setFont(font_);
|
||||
p.drawText(0,r.height() - fm.descent() -1 , text_);
|
||||
p.end();
|
||||
|
||||
pm_.setMask(bm);
|
||||
|
||||
// avoids uninitialized areas in some cases
|
||||
#if QT_VERSION < 0x040000
|
||||
pm_.fill();
|
||||
#endif
|
||||
p.begin( &pm_ );
|
||||
p.setFont( font_ );
|
||||
p.setPen( Qt::SolidLine );
|
||||
p.setPen( GL2Qt(color.r, color.g, color.b) );
|
||||
|
||||
p.drawText(0,r.height() - fm.descent() -1 , text_);
|
||||
p.end();
|
||||
#if QT_VERSION < 0x040000
|
||||
buf_ = pm_.convertToImage();
|
||||
#else
|
||||
buf_ = pm_.toImage();
|
||||
#endif
|
||||
tex_ = QGLWidget::convertToGLFormat( buf_ ); // flipped 32bit RGBA ?
|
||||
}
|
||||
|
||||
/**
|
||||
Adds an additional shift to the anchor point. This happens in a more or less intelligent manner
|
||||
depending on the nature of the anchor:
|
||||
\verbatim
|
||||
anchor type shift
|
||||
|
||||
left aligned -->
|
||||
right aligned <--
|
||||
top aligned top-down
|
||||
bottom aligned bottom-up
|
||||
\endverbatim
|
||||
The unit is user space dependend (one pixel on screen - play around to get satisfying results)
|
||||
*/
|
||||
void Label::adjust(int gap)
|
||||
{
|
||||
gap_ = gap;
|
||||
}
|
||||
|
||||
void Label::convert2screen()
|
||||
{
|
||||
Triple start = World2ViewPort(pos_);
|
||||
|
||||
switch (anchor_)
|
||||
{
|
||||
case BottomLeft :
|
||||
beg_ = pos_;
|
||||
break;
|
||||
case BottomRight:
|
||||
beg_ = ViewPort2World(start - Triple(width() + gap_, 0, 0));
|
||||
break;
|
||||
case BottomCenter:
|
||||
beg_ = ViewPort2World(start - Triple(width() / 2, -gap_, 0));
|
||||
break;
|
||||
case TopRight:
|
||||
beg_ = ViewPort2World(start - Triple(width() + gap_, height(), 0));
|
||||
break;
|
||||
case TopLeft:
|
||||
beg_ = ViewPort2World(start - Triple(-gap_, height(), 0));
|
||||
break;
|
||||
case TopCenter:
|
||||
beg_ = ViewPort2World(start - Triple(width() / 2, height() + gap_, 0));
|
||||
break;
|
||||
case CenterLeft:
|
||||
beg_ = ViewPort2World(start - Triple(-gap_, height() / 2, 0));
|
||||
break;
|
||||
case CenterRight:
|
||||
beg_ = ViewPort2World(start - Triple(width() + gap_, height() / 2, 0));
|
||||
break;
|
||||
case Center:
|
||||
beg_ = ViewPort2World(start - Triple(width() / 2, height() / 2, 0));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
start = World2ViewPort(beg_);
|
||||
end_ = ViewPort2World(start + Triple(width(), height(), 0));
|
||||
}
|
||||
|
||||
void Label::draw()
|
||||
{
|
||||
if (flagforupdate_)
|
||||
{
|
||||
update();
|
||||
flagforupdate_ = false;
|
||||
}
|
||||
|
||||
if (buf_.isNull())
|
||||
return;
|
||||
|
||||
GLboolean b;
|
||||
GLint func;
|
||||
GLdouble v;
|
||||
glGetBooleanv(GL_ALPHA_TEST, &b);
|
||||
glGetIntegerv(GL_ALPHA_TEST_FUNC, &func);
|
||||
glGetDoublev(GL_ALPHA_TEST_REF, &v);
|
||||
|
||||
glEnable (GL_ALPHA_TEST);
|
||||
glAlphaFunc (GL_NOTEQUAL, 0.0);
|
||||
|
||||
convert2screen();
|
||||
glRasterPos3d(beg_.x, beg_.y, beg_.z);
|
||||
|
||||
|
||||
int w = tex_.width();
|
||||
int h = tex_.height();
|
||||
|
||||
if (devicefonts_)
|
||||
{
|
||||
drawDeviceText(QWT3DLOCAL8BIT(text_), "Courier", font_.pointSize(), pos_, color, anchor_, gap_);
|
||||
}
|
||||
else
|
||||
{
|
||||
drawDevicePixels(w, h, GL_RGBA, GL_UNSIGNED_BYTE, tex_.bits());
|
||||
// glDrawPixels(w, h, GL_RGBA, GL_UNSIGNED_BYTE, tex_.bits());
|
||||
}
|
||||
|
||||
|
||||
glAlphaFunc(func,v);
|
||||
Enable(GL_ALPHA_TEST, b);
|
||||
}
|
||||
|
||||
|
||||
double Label::width() const
|
||||
{
|
||||
return pm_.width();
|
||||
}
|
||||
|
||||
double Label::height() const
|
||||
{
|
||||
return pm_.height();
|
||||
}
|
@ -0,0 +1,192 @@
|
||||
#if defined(_MSC_VER) /* MSVC Compiler */
|
||||
#pragma warning ( disable : 4305 )
|
||||
#pragma warning ( disable : 4786 )
|
||||
#endif
|
||||
|
||||
#include <float.h>
|
||||
#include "qwt3d_plot.h"
|
||||
|
||||
using namespace Qwt3D;
|
||||
|
||||
namespace {
|
||||
inline GLenum lightEnum(unsigned idx)
|
||||
{
|
||||
switch(idx) {
|
||||
case 0:
|
||||
return GL_LIGHT0;
|
||||
case 1:
|
||||
return GL_LIGHT1;
|
||||
case 2:
|
||||
return GL_LIGHT2;
|
||||
case 3:
|
||||
return GL_LIGHT3;
|
||||
case 4:
|
||||
return GL_LIGHT4;
|
||||
case 5:
|
||||
return GL_LIGHT5;
|
||||
case 6:
|
||||
return GL_LIGHT6;
|
||||
case 7:
|
||||
return GL_LIGHT7;
|
||||
default:
|
||||
return GL_LIGHT0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Plot3D::enableLighting(bool val)
|
||||
{
|
||||
if (lighting_enabled_ == val)
|
||||
return;
|
||||
|
||||
lighting_enabled_ = val;
|
||||
makeCurrent();
|
||||
if (val)
|
||||
glEnable(GL_LIGHTING);
|
||||
else
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
if (!initializedGL())
|
||||
return;
|
||||
updateGL();
|
||||
}
|
||||
|
||||
void Plot3D::disableLighting(bool val)
|
||||
{
|
||||
enableLighting(!val);
|
||||
}
|
||||
|
||||
bool Plot3D::lightingEnabled() const
|
||||
{
|
||||
return lighting_enabled_;
|
||||
}
|
||||
|
||||
/**
|
||||
\param light light number [0..7]
|
||||
\see setLight
|
||||
*/
|
||||
void Plot3D::illuminate(unsigned light)
|
||||
{
|
||||
if (light>7)
|
||||
return;
|
||||
lights_[light].unlit = false;
|
||||
}
|
||||
/**
|
||||
\param light light number [0..7]
|
||||
\see setLight
|
||||
*/
|
||||
void Plot3D::blowout(unsigned light)
|
||||
{
|
||||
if (light>7)
|
||||
return;
|
||||
lights_[light].unlit = false;
|
||||
}
|
||||
|
||||
/**
|
||||
Sets GL material properties
|
||||
*/
|
||||
void Plot3D::setMaterialComponent(GLenum property, double r, double g, double b, double a)
|
||||
{
|
||||
GLfloat rgba[4] = {(GLfloat)r, (GLfloat)g, (GLfloat)b, (GLfloat)a};
|
||||
makeCurrent();
|
||||
glMaterialfv(GL_FRONT_AND_BACK, property, rgba);
|
||||
}
|
||||
|
||||
/**
|
||||
This function is for convenience. It sets GL material properties with the equal r,g,b values
|
||||
and a blending alpha with value 1.0
|
||||
*/
|
||||
void Plot3D::setMaterialComponent(GLenum property, double intensity)
|
||||
{
|
||||
setMaterialComponent(property,intensity,intensity,intensity,1.0);
|
||||
}
|
||||
|
||||
/**
|
||||
Sets GL shininess
|
||||
*/
|
||||
void Plot3D::setShininess(double exponent)
|
||||
{
|
||||
makeCurrent();
|
||||
glMaterialf(GL_FRONT, GL_SHININESS, exponent);
|
||||
}
|
||||
|
||||
/**
|
||||
Sets GL light properties for light 'light'
|
||||
*/
|
||||
void Plot3D::setLightComponent(GLenum property, double r, double g, double b, double a, unsigned light)
|
||||
{
|
||||
GLfloat rgba[4] = {(GLfloat)r, (GLfloat)g, (GLfloat)b, (GLfloat)a};
|
||||
makeCurrent();
|
||||
glLightfv(lightEnum(light), property, rgba);
|
||||
}
|
||||
|
||||
/**
|
||||
This function is for convenience. It sets GL light properties with the equal r,g,b values
|
||||
and a blending alpha with value 1.0
|
||||
*/
|
||||
void Plot3D::setLightComponent(GLenum property, double intensity, unsigned light)
|
||||
{
|
||||
setLightComponent(property,intensity,intensity,intensity,1.0, lightEnum(light));
|
||||
}
|
||||
|
||||
/**
|
||||
Set the rotation angle of the light source. If you look along the respective axis towards ascending values,
|
||||
the rotation is performed in mathematical \e negative sense
|
||||
\param xVal angle in \e degree to rotate around the X axis
|
||||
\param yVal angle in \e degree to rotate around the Y axis
|
||||
\param zVal angle in \e degree to rotate around the Z axis
|
||||
\param light light number
|
||||
*/
|
||||
void Plot3D::setLightRotation( double xVal, double yVal, double zVal, unsigned light )
|
||||
{
|
||||
if (light>7)
|
||||
return;
|
||||
lights_[light].rot.x = xVal;
|
||||
lights_[light].rot.y = yVal;
|
||||
lights_[light].rot.z = zVal;
|
||||
}
|
||||
|
||||
/**
|
||||
Set the shift in light source (world) coordinates.
|
||||
\param xVal shift along (world) X axis
|
||||
\param yVal shift along (world) Y axis
|
||||
\param zVal shift along (world) Z axis
|
||||
\param light light number
|
||||
\see setViewportShift()
|
||||
*/
|
||||
void Plot3D::setLightShift( double xVal, double yVal, double zVal, unsigned light )
|
||||
{
|
||||
if (light>7)
|
||||
return;
|
||||
lights_[light].shift.x = xVal;
|
||||
lights_[light].shift.y = yVal;
|
||||
lights_[light].shift.z = zVal;
|
||||
}
|
||||
|
||||
void Plot3D::applyLight(unsigned light)
|
||||
{
|
||||
if (lights_[light].unlit)
|
||||
return;
|
||||
|
||||
glEnable(lightEnum(light));
|
||||
glLoadIdentity();
|
||||
|
||||
glRotatef( lights_[light].rot.x-90, 1.0, 0.0, 0.0 );
|
||||
glRotatef( lights_[light].rot.y , 0.0, 1.0, 0.0 );
|
||||
glRotatef( lights_[light].rot.z , 0.0, 0.0, 1.0 );
|
||||
GLfloat lightPos[4] = { lights_[light].shift.x, lights_[light].shift.y, lights_[light].shift.z, 1.0};
|
||||
GLenum le = lightEnum(light);
|
||||
glLightfv(le, GL_POSITION, lightPos);
|
||||
}
|
||||
|
||||
void Plot3D::applyLights()
|
||||
{
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glPushMatrix();
|
||||
for (unsigned i=0; i<8; ++i)
|
||||
{
|
||||
applyLight(i);
|
||||
}
|
||||
glPopMatrix();
|
||||
}
|
@ -0,0 +1,320 @@
|
||||
#if defined(_MSC_VER) /* MSVC Compiler */
|
||||
#pragma warning ( disable : 4305 )
|
||||
#pragma warning ( disable : 4786 )
|
||||
#endif
|
||||
|
||||
#include "qwt3d_surfaceplot.h"
|
||||
#include "qwt3d_enrichment_std.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace Qwt3D;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// cell specific
|
||||
//
|
||||
|
||||
|
||||
void SurfacePlot::createDataC()
|
||||
{
|
||||
createFloorDataC();
|
||||
|
||||
if (plotStyle() == NOPLOT)
|
||||
return;
|
||||
|
||||
if (plotStyle() == Qwt3D::POINTS)
|
||||
{
|
||||
createPoints();
|
||||
return;
|
||||
}
|
||||
else if (plotStyle() == Qwt3D::USER)
|
||||
{
|
||||
if (userplotstyle_p)
|
||||
createEnrichment(*userplotstyle_p);
|
||||
return;
|
||||
}
|
||||
|
||||
setDeviceLineWidth(meshLineWidth());
|
||||
GLStateBewarer sb(GL_POLYGON_OFFSET_FILL,true);
|
||||
setDevicePolygonOffset(polygonOffset(),1.0);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
int idx = 0;
|
||||
if (plotStyle() != WIREFRAME)
|
||||
{
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_QUADS);
|
||||
|
||||
bool hl = (plotStyle() == HIDDENLINE);
|
||||
if (hl)
|
||||
{
|
||||
RGBA col = backgroundRGBAColor();
|
||||
glColor4d(col.r, col.g, col.b, col.a);
|
||||
}
|
||||
|
||||
for (unsigned i=0; i!=actualDataC_->cells.size(); ++i)
|
||||
{
|
||||
glBegin(GL_POLYGON);
|
||||
for (unsigned j=0; j!=actualDataC_->cells[i].size(); ++j)
|
||||
{
|
||||
idx = actualDataC_->cells[i][j];
|
||||
setColorFromVertexC(idx, hl);
|
||||
glVertex3d( actualDataC_->nodes[idx].x, actualDataC_->nodes[idx].y, actualDataC_->nodes[idx].z );
|
||||
glNormal3d( actualDataC_->normals[idx].x, actualDataC_->normals[idx].y, actualDataC_->normals[idx].z );
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
if (plotStyle() == FILLEDMESH || plotStyle() == WIREFRAME || plotStyle() == HIDDENLINE)
|
||||
{
|
||||
glColor4d(meshColor().r, meshColor().g, meshColor().b, meshColor().a);
|
||||
{
|
||||
for (unsigned i=0; i!=actualDataC_->cells.size(); ++i)
|
||||
{
|
||||
glBegin(GL_LINE_LOOP);
|
||||
for (unsigned j=0; j!=actualDataC_->cells[i].size(); ++j)
|
||||
{
|
||||
idx = actualDataC_->cells[i][j];
|
||||
glVertex3d( actualDataC_->nodes[idx].x, actualDataC_->nodes[idx].y, actualDataC_->nodes[idx].z );
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ci = cell index
|
||||
// cv = vertex index in cell ci
|
||||
void SurfacePlot::setColorFromVertexC(int node, bool skip)
|
||||
{
|
||||
if (skip)
|
||||
return;
|
||||
|
||||
RGBA col = (*datacolor_p)(
|
||||
actualDataC_->nodes[node].x, actualDataC_->nodes[node].y, actualDataC_->nodes[node].z);
|
||||
|
||||
glColor4d(col.r, col.g, col.b, col.a);
|
||||
}
|
||||
|
||||
void SurfacePlot::createFloorDataC()
|
||||
{
|
||||
switch (floorStyle())
|
||||
{
|
||||
case FLOORDATA:
|
||||
Data2FloorC();
|
||||
break;
|
||||
case FLOORISO:
|
||||
Isolines2FloorC();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SurfacePlot::Data2FloorC()
|
||||
{
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
|
||||
double zshift = actualDataC_->hull().minVertex.z;
|
||||
int idx;
|
||||
|
||||
for (unsigned i = 0; i!=actualDataC_->cells.size(); ++i)
|
||||
{
|
||||
glBegin(GL_POLYGON);
|
||||
for (unsigned j=0; j!=actualDataC_->cells[i].size(); ++j)
|
||||
{
|
||||
idx = actualDataC_->cells[i][j];
|
||||
setColorFromVertexC(idx);
|
||||
glVertex3d( actualDataC_->nodes[idx].x, actualDataC_->nodes[idx].y, zshift );
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
void SurfacePlot::Isolines2FloorC()
|
||||
{
|
||||
if (isolines() <= 0 || actualData_p->empty())
|
||||
return;
|
||||
|
||||
double step = (actualData_p->hull().maxVertex.z - actualData_p->hull().minVertex.z) / isolines();
|
||||
|
||||
RGBA col;
|
||||
|
||||
double zshift = actualData_p->hull().minVertex.z;
|
||||
|
||||
TripleField nodes;
|
||||
TripleField intersection;
|
||||
|
||||
double lambda = 0;
|
||||
|
||||
GLStateBewarer sb2(GL_LINE_SMOOTH, false);
|
||||
|
||||
for (int k = 0; k != isolines(); ++k)
|
||||
{
|
||||
double val = zshift + k * step;
|
||||
|
||||
for (unsigned i=0; i!=actualDataC_->cells.size(); ++i)
|
||||
{
|
||||
nodes.clear();
|
||||
unsigned cellnodes = actualDataC_->cells[i].size();
|
||||
for (unsigned j=0; j!=cellnodes; ++j)
|
||||
{
|
||||
nodes.push_back(actualDataC_->nodes[actualDataC_->cells[i][j]]);
|
||||
}
|
||||
|
||||
double diff = 0;
|
||||
for (unsigned m = 0; m!=cellnodes; ++m)
|
||||
{
|
||||
unsigned mm = (m+1)%cellnodes;
|
||||
if ((val>=nodes[m].z && val<=nodes[mm].z) || (val>=nodes[mm].z && val<=nodes[m].z))
|
||||
{
|
||||
diff = nodes[mm].z - nodes[m].z;
|
||||
|
||||
if (isPracticallyZero(diff)) // degenerated
|
||||
{
|
||||
intersection.push_back(nodes[m]);
|
||||
intersection.push_back(nodes[mm]);
|
||||
continue;
|
||||
}
|
||||
|
||||
lambda = (val - nodes[m].z) / diff;
|
||||
intersection.push_back(Triple(nodes[m].x + lambda * (nodes[mm].x-nodes[m].x), nodes[m].y + lambda * (nodes[mm].y-nodes[m].y), val));
|
||||
}
|
||||
}
|
||||
|
||||
if (!intersection.empty())
|
||||
{
|
||||
col = (*datacolor_p)(nodes[0].x,nodes[0].y,nodes[0].z);
|
||||
glColor4d(col.r, col.g, col.b, col.a);
|
||||
if (intersection.size()>2)
|
||||
{
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (unsigned dd = 0; dd!=intersection.size(); ++dd)
|
||||
{
|
||||
glVertex3d(intersection[dd].x, intersection[dd].y, zshift);
|
||||
}
|
||||
glEnd();
|
||||
glBegin(GL_POINTS);
|
||||
glVertex3d(intersection[0].x,intersection[0].y,zshift);
|
||||
glEnd();
|
||||
}
|
||||
else if (intersection.size() == 2)
|
||||
{
|
||||
glBegin(GL_LINES);
|
||||
glVertex3d(intersection[0].x,intersection[0].y,zshift);
|
||||
glVertex3d(intersection[1].x,intersection[1].y,zshift);
|
||||
|
||||
// small pixel gap problem (see OpenGL spec.)
|
||||
glVertex3d(intersection[1].x,intersection[1].y,zshift);
|
||||
glVertex3d(intersection[0].x,intersection[0].y,zshift);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
intersection.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SurfacePlot::createNormalsC()
|
||||
{
|
||||
if (!normals() || actualData_p->empty())
|
||||
return;
|
||||
|
||||
if (actualDataC_->nodes.size() != actualDataC_->normals.size())
|
||||
return;
|
||||
Arrow arrow;
|
||||
arrow.setQuality(normalQuality());
|
||||
|
||||
Triple basev, topv, norm;
|
||||
|
||||
double diag = (actualData_p->hull().maxVertex-actualData_p->hull().minVertex).length() * normalLength();
|
||||
|
||||
RGBA col;
|
||||
arrow.assign(*this);
|
||||
arrow.drawBegin();
|
||||
for (unsigned i = 0; i != actualDataC_->normals.size(); ++i)
|
||||
{
|
||||
basev = actualDataC_->nodes[i];
|
||||
topv = basev + actualDataC_->normals[i];
|
||||
|
||||
norm = topv-basev;
|
||||
norm.normalize();
|
||||
norm *= diag;
|
||||
|
||||
arrow.setTop(basev+norm);
|
||||
arrow.setColor((*datacolor_p)(basev.x,basev.y,basev.z));
|
||||
arrow.draw(basev);
|
||||
}
|
||||
arrow.drawEnd();
|
||||
}
|
||||
|
||||
/*!
|
||||
Convert user (non-rectangular) mesh based data to internal structure.
|
||||
See also Qwt3D::TripleField and Qwt3D::CellField
|
||||
*/
|
||||
bool SurfacePlot::loadFromData(TripleField const& data, CellField const& poly)
|
||||
{
|
||||
actualDataG_->clear();
|
||||
actualData_p = actualDataC_;
|
||||
|
||||
actualDataC_->nodes = data;
|
||||
actualDataC_->cells = poly;
|
||||
actualDataC_->normals = TripleField(actualDataC_->nodes.size());
|
||||
|
||||
unsigned i;
|
||||
|
||||
// normals for the moment
|
||||
Triple n, u, v;
|
||||
for ( i = 0; i < poly.size(); ++i)
|
||||
{
|
||||
if (poly[i].size() < 3)
|
||||
n = Triple(0,0,0);
|
||||
else
|
||||
{
|
||||
for (unsigned j = 0; j < poly[i].size(); ++j)
|
||||
{
|
||||
unsigned jj = (j+1) % poly[i].size();
|
||||
unsigned pjj = (j) ? j-1 : poly[i].size()-1;
|
||||
u = actualDataC_->nodes[poly[i][jj]]-actualDataC_->nodes[poly[i][j]];
|
||||
v = actualDataC_->nodes[poly[i][pjj]]-actualDataC_->nodes[poly[i][j]];
|
||||
n = normalizedcross(u,v);
|
||||
actualDataC_->normals[poly[i][j]] += n;
|
||||
}
|
||||
}
|
||||
}
|
||||
for ( i = 0; i != actualDataC_->normals.size(); ++i)
|
||||
{
|
||||
actualDataC_->normals[i].normalize();
|
||||
}
|
||||
|
||||
ParallelEpiped hull(Triple(DBL_MAX,DBL_MAX,DBL_MAX),Triple(-DBL_MAX,-DBL_MAX,-DBL_MAX));
|
||||
|
||||
for (i = 0; i!=data.size(); ++i)
|
||||
{
|
||||
if (data[i].x < hull.minVertex.x)
|
||||
hull.minVertex.x = data[i].x;
|
||||
if (data[i].y < hull.minVertex.y)
|
||||
hull.minVertex.y = data[i].y;
|
||||
if (data[i].z < hull.minVertex.z)
|
||||
hull.minVertex.z = data[i].z;
|
||||
|
||||
if (data[i].x > hull.maxVertex.x)
|
||||
hull.maxVertex.x = data[i].x;
|
||||
if (data[i].y > hull.maxVertex.y)
|
||||
hull.maxVertex.y = data[i].y;
|
||||
if (data[i].z > hull.maxVertex.z)
|
||||
hull.maxVertex.z = data[i].z;
|
||||
}
|
||||
|
||||
actualDataC_->setHull(hull);
|
||||
|
||||
updateData();
|
||||
updateNormals();
|
||||
createCoordinateSystem();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,387 @@
|
||||
#if defined(_MSC_VER) /* MSVC Compiler */
|
||||
#pragma warning ( disable : 4305 )
|
||||
#pragma warning ( disable : 4786 )
|
||||
#endif
|
||||
|
||||
#include "qwt3d_plot.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace Qwt3D;
|
||||
|
||||
|
||||
/**
|
||||
Standard mouse button Function. Prepares the call to mouseMoveEvent
|
||||
\see mouseMoveEvent()
|
||||
*/
|
||||
void Plot3D::mousePressEvent( QMouseEvent *e )
|
||||
{
|
||||
lastMouseMovePosition_ = e->pos();
|
||||
mpressed_ = true;
|
||||
}
|
||||
|
||||
/**
|
||||
Standard mouse button Function. Completes the call to mouseMoveEvent
|
||||
\see mouseMoveEvent()
|
||||
*/
|
||||
void Plot3D::mouseReleaseEvent( QMouseEvent* )
|
||||
{
|
||||
mpressed_ = false;
|
||||
}
|
||||
|
||||
/**
|
||||
Standard mouse button Function
|
||||
\see assignMouse()
|
||||
*/
|
||||
void Plot3D::mouseMoveEvent( QMouseEvent *e )
|
||||
{
|
||||
if (!mpressed_ || !mouseEnabled())
|
||||
{
|
||||
e->ignore();
|
||||
return;
|
||||
}
|
||||
|
||||
#if QT_VERSION < 0x040000
|
||||
MouseState bstate = e->state();
|
||||
#else
|
||||
MouseState bstate(e->buttons(),e->modifiers());
|
||||
#endif
|
||||
|
||||
QPoint diff = e->pos() - lastMouseMovePosition_;
|
||||
|
||||
setRotationMouse(bstate, 3, diff);
|
||||
setScaleMouse(bstate, 5, diff);
|
||||
setShiftMouse(bstate, 2, diff);
|
||||
|
||||
lastMouseMovePosition_ = e->pos();
|
||||
}
|
||||
|
||||
void Plot3D::setRotationMouse(MouseState bstate, double accel, QPoint diff)
|
||||
{
|
||||
// Rotation
|
||||
double w = max(1,width());
|
||||
double h = max(1,height());
|
||||
|
||||
double relx = accel*360 * diff.x() / w;
|
||||
double relyz = accel*360 * diff.y() / h;
|
||||
|
||||
double new_xrot = xRotation();
|
||||
double new_yrot = yRotation();
|
||||
double new_zrot = zRotation();
|
||||
|
||||
if ( bstate == xrot_mstate_ )
|
||||
new_xrot = round(xRotation() + relyz) % 360;
|
||||
if ( bstate == yrot_mstate_ )
|
||||
new_yrot = round(yRotation() + relx) % 360;
|
||||
if ( bstate == zrot_mstate_ )
|
||||
new_zrot = round(zRotation() + relx) % 360;
|
||||
|
||||
setRotation(new_xrot, new_yrot, new_zrot);
|
||||
}
|
||||
|
||||
void Plot3D::setScaleMouse(MouseState bstate, double accel, QPoint diff)
|
||||
{
|
||||
// Scale
|
||||
double w = max(1,width());
|
||||
double h = max(1,height());
|
||||
|
||||
double relx = diff.x() * accel / w; relx = exp(relx) - 1;
|
||||
double relyz = diff.y() * accel / h; relyz = exp(relyz) - 1;
|
||||
|
||||
double new_xscale = xScale();
|
||||
double new_yscale = yScale();
|
||||
double new_zscale = zScale();
|
||||
|
||||
if ( bstate == xscale_mstate_)
|
||||
new_xscale = max(0.0,xScale() + relx);
|
||||
if ( bstate == yscale_mstate_)
|
||||
new_yscale = max(0.0,yScale() - relyz);
|
||||
if ( bstate == zscale_mstate_)
|
||||
new_zscale = max(0.0,zScale() - relyz);
|
||||
|
||||
setScale(new_xscale, new_yscale, new_zscale);
|
||||
|
||||
if ( bstate == zoom_mstate_)
|
||||
setZoom(max(0.0,zoom() - relyz));
|
||||
}
|
||||
|
||||
void Plot3D::setShiftMouse(MouseState bstate, double accel, QPoint diff)
|
||||
{
|
||||
// Shift
|
||||
double w = max(1,width());
|
||||
double h = max(1,height());
|
||||
|
||||
double relx = diff.x() * accel / w;
|
||||
double relyz = diff.y() * accel / h;
|
||||
|
||||
double new_xshift = xViewportShift();
|
||||
double new_yshift = yViewportShift();
|
||||
|
||||
if ( bstate == xshift_mstate_)
|
||||
new_xshift = xViewportShift() + relx;
|
||||
if ( bstate == yshift_mstate_)
|
||||
new_yshift = yViewportShift() - relyz;
|
||||
|
||||
setViewportShift(new_xshift, new_yshift);
|
||||
}
|
||||
|
||||
/**
|
||||
Standard wheel Function - zoom (wheel only) or z-scale (shift+wheel)
|
||||
*/
|
||||
void Plot3D::wheelEvent( QWheelEvent *e )
|
||||
{
|
||||
if (!mouseEnabled())
|
||||
return;
|
||||
|
||||
double accel = 0.05;
|
||||
|
||||
double step = accel * e->delta() / WHEEL_DELTA ;
|
||||
step = exp(step)-1;
|
||||
|
||||
#if QT_VERSION < 0x040000
|
||||
if ( e->state() & Qt::ShiftButton )
|
||||
#else
|
||||
if ( e->modifiers() & Qt::ShiftModifier )
|
||||
#endif
|
||||
setScale(xScale(),yScale(), max(0.0,zScale() + step));
|
||||
else
|
||||
setZoom(max(0.0,zoom() + step ));
|
||||
}
|
||||
|
||||
/**
|
||||
Sets the key/mousebutton combination for data/coordinatesystem moves inside the widget\n\n
|
||||
default behaviour:\n
|
||||
|
||||
\verbatim
|
||||
rotate around x axis: Qt::LeftButton
|
||||
rotate around y axis: Qt::LeftButton | Qt::ShiftButton
|
||||
rotate around z axis: Qt::LeftButton
|
||||
scale x: Qt::LeftButton | Qt::AltButton
|
||||
scale y: Qt::LeftButton | Qt::AltButton
|
||||
scale z: Qt::LeftButton | Qt::AltButton | Qt::ShiftButton
|
||||
zoom: Qt::LeftButton | Qt::AltButton | Qt::ControlButton
|
||||
shifting along x: Qt::LeftButton | Qt::ControlButton
|
||||
shifting along y: Qt::LeftButton | Qt::ControlButton
|
||||
\endverbatim
|
||||
|
||||
mouseMoveEvent() evaluates this function - if overridden, their usefulness becomes somehow limited
|
||||
*/
|
||||
void Plot3D::assignMouse(MouseState xrot, MouseState yrot, MouseState zrot,
|
||||
MouseState xscale, MouseState yscale, MouseState zscale,
|
||||
MouseState zoom, MouseState xshift, MouseState yshift)
|
||||
{
|
||||
xrot_mstate_ = xrot;
|
||||
yrot_mstate_ = yrot;
|
||||
zrot_mstate_ = zrot;
|
||||
xscale_mstate_ = xscale;
|
||||
yscale_mstate_ = yscale;
|
||||
zscale_mstate_ = zscale;
|
||||
zoom_mstate_ = zoom;
|
||||
xshift_mstate_ = xshift;
|
||||
yshift_mstate_ = yshift;
|
||||
}
|
||||
|
||||
/**
|
||||
The function has no effect if you derive from Plot3D and overrides the mouse Function too careless.
|
||||
In this case check first against mouseEnabled() in your version of mouseMoveEvent() and wheelEvent().
|
||||
A more fine grained input control can be achieved by combining assignMouse() with enableMouse().
|
||||
*/
|
||||
void Plot3D::enableMouse(bool val) {mouse_input_enabled_ = val;}
|
||||
|
||||
/**
|
||||
\see enableMouse()
|
||||
*/
|
||||
void Plot3D::disableMouse(bool val) {mouse_input_enabled_ = !val;}
|
||||
bool Plot3D::mouseEnabled() const {return mouse_input_enabled_;}
|
||||
|
||||
|
||||
|
||||
|
||||
void Plot3D::keyPressEvent( QKeyEvent *e )
|
||||
{
|
||||
if (!keyboardEnabled())
|
||||
{
|
||||
e->ignore();
|
||||
return;
|
||||
}
|
||||
|
||||
#if QT_VERSION < 0x040000
|
||||
int bstate = e->state() & Qt::KeyButtonMask; // filter kbd modifier only
|
||||
KeyboardState keyseq = bstate + e->key();
|
||||
#else
|
||||
KeyboardState keyseq(e->key(), e->modifiers());
|
||||
#endif
|
||||
|
||||
setRotationKeyboard(keyseq, kbd_rot_speed_);
|
||||
setScaleKeyboard(keyseq, kbd_scale_speed_);
|
||||
setShiftKeyboard(keyseq, kbd_shift_speed_);
|
||||
}
|
||||
|
||||
void Plot3D::setRotationKeyboard(KeyboardState kseq, double speed)
|
||||
{
|
||||
// Rotation
|
||||
double w = max(1,width());
|
||||
double h = max(1,height());
|
||||
|
||||
double relx = speed*360 / w;
|
||||
double relyz = speed*360 / h;
|
||||
|
||||
double new_xrot = xRotation();
|
||||
double new_yrot = yRotation();
|
||||
double new_zrot = zRotation();
|
||||
|
||||
if ( kseq == xrot_kstate_[0] )
|
||||
new_xrot = round(xRotation() + relyz) % 360;
|
||||
if ( kseq == xrot_kstate_[1] )
|
||||
new_xrot = round(xRotation() - relyz) % 360;
|
||||
if ( kseq == yrot_kstate_[0] )
|
||||
new_yrot = round(yRotation() + relx) % 360;
|
||||
if ( kseq == yrot_kstate_[1] )
|
||||
new_yrot = round(yRotation() - relx) % 360;
|
||||
if ( kseq == zrot_kstate_[0] )
|
||||
new_zrot = round(zRotation() + relx) % 360;
|
||||
if ( kseq == zrot_kstate_[1] )
|
||||
new_zrot = round(zRotation() - relx) % 360;
|
||||
|
||||
setRotation(new_xrot, new_yrot, new_zrot);
|
||||
}
|
||||
|
||||
void Plot3D::setScaleKeyboard(KeyboardState kseq, double speed)
|
||||
{
|
||||
// Scale
|
||||
double w = max(1,width());
|
||||
double h = max(1,height());
|
||||
|
||||
double relx = speed / w; relx = exp(relx) - 1;
|
||||
double relyz = speed / h; relyz = exp(relyz) - 1;
|
||||
|
||||
double new_xscale = xScale();
|
||||
double new_yscale = yScale();
|
||||
double new_zscale = zScale();
|
||||
|
||||
if ( kseq == xscale_kstate_[0])
|
||||
new_xscale = max(0.0,xScale() + relx);
|
||||
if ( kseq == xscale_kstate_[1])
|
||||
new_xscale = max(0.0,xScale() - relx);
|
||||
if ( kseq == yscale_kstate_[0])
|
||||
new_yscale = max(0.0,yScale() - relyz);
|
||||
if ( kseq == yscale_kstate_[1])
|
||||
new_yscale = max(0.0,yScale() + relyz);
|
||||
if ( kseq == zscale_kstate_[0])
|
||||
new_zscale = max(0.0,zScale() - relyz);
|
||||
if ( kseq == zscale_kstate_[1])
|
||||
new_zscale = max(0.0,zScale() + relyz);
|
||||
|
||||
setScale(new_xscale, new_yscale, new_zscale);
|
||||
|
||||
if ( kseq == zoom_kstate_[0])
|
||||
setZoom(max(0.0,zoom() - relyz));
|
||||
if ( kseq == zoom_kstate_[1])
|
||||
setZoom(max(0.0,zoom() + relyz));
|
||||
}
|
||||
|
||||
void Plot3D::setShiftKeyboard(KeyboardState kseq, double speed)
|
||||
{
|
||||
// Shift
|
||||
double w = max(1,width());
|
||||
double h = max(1,height());
|
||||
|
||||
double relx = speed / w;
|
||||
double relyz = speed / h;
|
||||
|
||||
double new_xshift = xViewportShift();
|
||||
double new_yshift = yViewportShift();
|
||||
|
||||
if ( kseq == xshift_kstate_[0])
|
||||
new_xshift = xViewportShift() + relx;
|
||||
if ( kseq == xshift_kstate_[1])
|
||||
new_xshift = xViewportShift() - relx;
|
||||
if ( kseq == yshift_kstate_[0])
|
||||
new_yshift = yViewportShift() - relyz;
|
||||
if ( kseq == yshift_kstate_[1])
|
||||
new_yshift = yViewportShift() + relyz;
|
||||
|
||||
setViewportShift(new_xshift, new_yshift);
|
||||
}
|
||||
|
||||
/**
|
||||
Sets the keybutton combination for data/coordinatesystem moves inside the widget\n\n
|
||||
default behaviour:\n
|
||||
|
||||
\verbatim
|
||||
rotate around x axis: [Key_Down, Key_Up]
|
||||
rotate around y axis: SHIFT+[Key_Right, Key_Left]
|
||||
rotate around z axis: [Key_Right, Key_Left]
|
||||
scale x: ALT+[Key_Right, Key_Left]
|
||||
scale y: ALT+[Key_Up, Key_Down]
|
||||
scale z: ALT+SHIFT[Key_Down, Key_Up]
|
||||
zoom: ALT+CTRL+[Key_Down, Key_Up]
|
||||
shifting along x: CTRL+[Key_Right, Key_Left]
|
||||
shifting along z: CTRL+[Key_Down, Key_Up]
|
||||
\endverbatim
|
||||
*/
|
||||
void Plot3D::assignKeyboard(
|
||||
KeyboardState xrot_n, KeyboardState xrot_p
|
||||
,KeyboardState yrot_n, KeyboardState yrot_p
|
||||
,KeyboardState zrot_n, KeyboardState zrot_p
|
||||
,KeyboardState xscale_n, KeyboardState xscale_p
|
||||
,KeyboardState yscale_n, KeyboardState yscale_p
|
||||
,KeyboardState zscale_n, KeyboardState zscale_p
|
||||
,KeyboardState zoom_n, KeyboardState zoom_p
|
||||
,KeyboardState xshift_n, KeyboardState xshift_p
|
||||
,KeyboardState yshift_n, KeyboardState yshift_p
|
||||
)
|
||||
{
|
||||
xrot_kstate_[0] = xrot_n;
|
||||
yrot_kstate_[0] = yrot_n;
|
||||
zrot_kstate_[0] = zrot_n;
|
||||
xrot_kstate_[1] = xrot_p;
|
||||
yrot_kstate_[1] = yrot_p;
|
||||
zrot_kstate_[1] = zrot_p;
|
||||
|
||||
xscale_kstate_[0] = xscale_n;
|
||||
yscale_kstate_[0] = yscale_n;
|
||||
zscale_kstate_[0] = zscale_n;
|
||||
xscale_kstate_[1] = xscale_p;
|
||||
yscale_kstate_[1] = yscale_p;
|
||||
zscale_kstate_[1] = zscale_p;
|
||||
|
||||
zoom_kstate_[0] = zoom_n;
|
||||
xshift_kstate_[0] = xshift_n;
|
||||
yshift_kstate_[0] = yshift_n;
|
||||
zoom_kstate_[1] = zoom_p;
|
||||
xshift_kstate_[1] = xshift_p;
|
||||
yshift_kstate_[1] = yshift_p;
|
||||
}
|
||||
|
||||
/**
|
||||
The function has no effect if you derive from Plot3D and overrides the keyboard Functions too careless.
|
||||
In this case check first against keyboardEnabled() in your version of keyPressEvent()
|
||||
A more fine grained input control can be achieved by combining assignKeyboard() with enableKeyboard().
|
||||
*/
|
||||
void Plot3D::enableKeyboard(bool val) {kbd_input_enabled_ = val;}
|
||||
|
||||
/**
|
||||
\see enableKeyboard()
|
||||
*/
|
||||
void Plot3D::disableKeyboard(bool val) {kbd_input_enabled_ = !val;}
|
||||
bool Plot3D::keyboardEnabled() const {return kbd_input_enabled_;}
|
||||
|
||||
/**
|
||||
Values < 0 are ignored. Default is (3,5,5)
|
||||
*/
|
||||
void Plot3D::setKeySpeed(double rot, double scale, double shift)
|
||||
{
|
||||
if (rot > 0)
|
||||
kbd_rot_speed_ = rot;
|
||||
if (scale > 0)
|
||||
kbd_scale_speed_ = scale;
|
||||
if (shift > 0)
|
||||
kbd_shift_speed_ = shift;
|
||||
}
|
||||
|
||||
void Plot3D::keySpeed(double& rot, double& scale, double& shift) const
|
||||
{
|
||||
rot = kbd_rot_speed_;
|
||||
scale = kbd_scale_speed_;
|
||||
shift = kbd_shift_speed_;
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
#if defined(_MSC_VER) /* MSVC Compiler */
|
||||
#pragma warning ( disable : 4305 )
|
||||
#pragma warning ( disable : 4786 )
|
||||
#endif
|
||||
|
||||
#include <float.h>
|
||||
#include "qwt3d_plot.h"
|
||||
|
||||
using namespace Qwt3D;
|
||||
|
||||
|
||||
/**
|
||||
Set the rotation angle of the object. If you look along the respective axis towards ascending values,
|
||||
the rotation is performed in mathematical \e negative sense
|
||||
\param xVal angle in \e degree to rotate around the X axis
|
||||
\param yVal angle in \e degree to rotate around the Y axis
|
||||
\param zVal angle in \e degree to rotate around the Z axis
|
||||
*/
|
||||
void Plot3D::setRotation( double xVal, double yVal, double zVal )
|
||||
{
|
||||
if (xRot_ == xVal && yRot_ == yVal && zRot_ == zVal)
|
||||
return;
|
||||
|
||||
xRot_ = xVal;
|
||||
yRot_ = yVal;
|
||||
zRot_ = zVal;
|
||||
|
||||
updateGL();
|
||||
emit rotationChanged(xVal, yVal, zVal);
|
||||
}
|
||||
|
||||
/**
|
||||
Set the shift in object (world) coordinates.
|
||||
\param xVal shift along (world) X axis
|
||||
\param yVal shift along (world) Y axis
|
||||
\param zVal shift along (world) Z axis
|
||||
\see setViewportShift()
|
||||
*/
|
||||
void Plot3D::setShift( double xVal, double yVal, double zVal )
|
||||
{
|
||||
if (xShift_ == xVal && yShift_ == yVal && zShift_ == zVal)
|
||||
return;
|
||||
|
||||
xShift_ = xVal;
|
||||
yShift_ = yVal;
|
||||
zShift_ = zVal;
|
||||
updateGL();
|
||||
emit shiftChanged(xVal, yVal, zVal);
|
||||
}
|
||||
|
||||
/**
|
||||
Performs shifting along screen axes.
|
||||
The shift moves points inside a sphere,
|
||||
which encloses the unscaled and unzoomed data
|
||||
by multiples of the spheres diameter
|
||||
|
||||
\param xVal shift along (view) X axis
|
||||
\param yVal shift along (view) Y axis
|
||||
\see setShift()
|
||||
*/
|
||||
void Plot3D::setViewportShift( double xVal, double yVal )
|
||||
{
|
||||
if (xVPShift_ == xVal && yVPShift_ == yVal)
|
||||
return;
|
||||
|
||||
xVPShift_ = xVal;
|
||||
yVPShift_ = yVal;
|
||||
|
||||
updateGL();
|
||||
emit vieportShiftChanged(xVPShift_, yVPShift_);
|
||||
}
|
||||
|
||||
/**
|
||||
Set the scale in object (world) coordinates.
|
||||
\param xVal scaling for X values
|
||||
\param yVal scaling for Y values
|
||||
\param zVal scaling for Z values
|
||||
|
||||
A respective value of 1 represents no scaling;
|
||||
*/
|
||||
void Plot3D::setScale( double xVal, double yVal, double zVal )
|
||||
{
|
||||
if (xScale_ == xVal && yScale_ == yVal && zScale_ == zVal)
|
||||
return;
|
||||
|
||||
xScale_ = (xVal < DBL_EPSILON ) ? DBL_EPSILON : xVal;
|
||||
yScale_ = (yVal < DBL_EPSILON ) ? DBL_EPSILON : yVal;
|
||||
zScale_ = (zVal < DBL_EPSILON ) ? DBL_EPSILON : zVal;
|
||||
|
||||
updateGL();
|
||||
emit scaleChanged(xVal, yVal, zVal);
|
||||
}
|
||||
|
||||
/**
|
||||
Set the (zoom in addition to scale).
|
||||
\param val zoom value (value == 1 indicates no zooming)
|
||||
*/
|
||||
void Plot3D::setZoom( double val )
|
||||
{
|
||||
if (zoom_ == val)
|
||||
return;
|
||||
|
||||
zoom_ = (val < DBL_EPSILON ) ? DBL_EPSILON : val;
|
||||
updateGL();
|
||||
emit zoomChanged(val);
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
#include "qwt3d_parametricsurface.h"
|
||||
#include "qwt3d_surfaceplot.h"
|
||||
|
||||
using namespace Qwt3D;
|
||||
|
||||
ParametricSurface::ParametricSurface()
|
||||
:GridMapping()
|
||||
{
|
||||
}
|
||||
|
||||
ParametricSurface::ParametricSurface(SurfacePlot& pw)
|
||||
:GridMapping()
|
||||
{
|
||||
plotwidget_p = &pw;
|
||||
uperiodic_ = false;
|
||||
vperiodic_ = false;
|
||||
}
|
||||
|
||||
ParametricSurface::ParametricSurface(SurfacePlot* pw)
|
||||
:GridMapping()
|
||||
{
|
||||
plotwidget_p = pw;
|
||||
uperiodic_ = false;
|
||||
vperiodic_ = false;
|
||||
}
|
||||
|
||||
void ParametricSurface::setPeriodic(bool u, bool v)
|
||||
{
|
||||
uperiodic_ = u;
|
||||
vperiodic_ = v;
|
||||
}
|
||||
|
||||
void ParametricSurface::assign(SurfacePlot& plotWidget)
|
||||
{
|
||||
if (&plotWidget != plotwidget_p)
|
||||
plotwidget_p = &plotWidget;
|
||||
}
|
||||
|
||||
void ParametricSurface::assign(SurfacePlot* plotWidget)
|
||||
{
|
||||
if (plotWidget != plotwidget_p)
|
||||
plotwidget_p = plotWidget;
|
||||
}
|
||||
|
||||
/**
|
||||
For plotWidget != 0 the function permanently assigns her argument (In fact, assign(plotWidget) is called)
|
||||
*/
|
||||
bool ParametricSurface::create()
|
||||
{
|
||||
if ((umesh_p<=2) || (vmesh_p<=2) || !plotwidget_p)
|
||||
return false;
|
||||
|
||||
/* allocate some space for the mesh */
|
||||
Triple** data = new Triple* [umesh_p] ;
|
||||
|
||||
unsigned i,j;
|
||||
for ( i = 0; i < umesh_p; i++)
|
||||
{
|
||||
data[i] = new Triple [vmesh_p];
|
||||
}
|
||||
|
||||
/* get the data */
|
||||
|
||||
double du = (maxu_p - minu_p) / (umesh_p - 1);
|
||||
double dv = (maxv_p - minv_p) / (vmesh_p - 1);
|
||||
|
||||
for (i = 0; i < umesh_p; ++i)
|
||||
{
|
||||
for (j = 0; j < vmesh_p; ++j)
|
||||
{
|
||||
data[i][j] = operator()(minu_p + i*du, minv_p + j*dv);
|
||||
|
||||
if (data[i][j].x > range_p.maxVertex.x)
|
||||
data[i][j].x = range_p.maxVertex.x;
|
||||
else if (data[i][j].y > range_p.maxVertex.y)
|
||||
data[i][j].y = range_p.maxVertex.y;
|
||||
else if (data[i][j].z > range_p.maxVertex.z)
|
||||
data[i][j].z = range_p.maxVertex.z;
|
||||
else if (data[i][j].x < range_p.minVertex.x)
|
||||
data[i][j].x = range_p.minVertex.x;
|
||||
else if (data[i][j].y < range_p.minVertex.y)
|
||||
data[i][j].y = range_p.minVertex.y;
|
||||
else if (data[i][j].z < range_p.minVertex.z)
|
||||
data[i][j].z = range_p.minVertex.z;
|
||||
}
|
||||
}
|
||||
|
||||
((SurfacePlot*)plotwidget_p)->loadFromData(data, umesh_p, vmesh_p, uperiodic_, vperiodic_);
|
||||
|
||||
for ( i = 0; i < umesh_p; i++)
|
||||
{
|
||||
delete [] data[i];
|
||||
}
|
||||
|
||||
delete [] data;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParametricSurface::create(SurfacePlot& pl)
|
||||
{
|
||||
assign(pl);
|
||||
return create();
|
||||
}
|
@ -0,0 +1,498 @@
|
||||
#if defined(_MSC_VER) /* MSVC Compiler */
|
||||
#pragma warning ( disable : 4305 )
|
||||
#pragma warning ( disable : 4786 )
|
||||
#endif
|
||||
|
||||
#include "qwt3d_plot.h"
|
||||
#include "qwt3d_enrichment.h"
|
||||
|
||||
|
||||
using namespace Qwt3D;
|
||||
|
||||
/*!
|
||||
This should be the first call in your derived classes constructors.
|
||||
*/
|
||||
#if QT_VERSION < 0x040000
|
||||
Plot3D::Plot3D( QWidget* parent, const char* name )
|
||||
: QGLWidget( parent, name )
|
||||
#else
|
||||
Plot3D::Plot3D( QWidget * parent, const QGLWidget * shareWidget)
|
||||
: QGLWidget( parent, shareWidget)
|
||||
#endif
|
||||
{
|
||||
initializedGL_ = false;
|
||||
renderpixmaprequest_ = false;
|
||||
xRot_ = yRot_ = zRot_ = 0.0; // default object rotation
|
||||
|
||||
xShift_ = yShift_ = zShift_ = xVPShift_ = yVPShift_ = 0.0;
|
||||
xScale_ = yScale_ = zScale_ = 1.0;
|
||||
zoom_ = 1;
|
||||
ortho_ = true;
|
||||
plotstyle_ = FILLEDMESH;
|
||||
userplotstyle_p = 0;
|
||||
shading_ = GOURAUD;
|
||||
floorstyle_ = NOFLOOR;
|
||||
isolines_ = 10;
|
||||
displaylegend_ = false;
|
||||
smoothdatamesh_p = false;
|
||||
actualData_p = 0;
|
||||
|
||||
lastMouseMovePosition_ = QPoint(0,0);
|
||||
mpressed_ = false;
|
||||
mouse_input_enabled_ = true;
|
||||
|
||||
setPolygonOffset(0.5);
|
||||
setMeshColor(RGBA(0.0,0.0,0.0));
|
||||
setMeshLineWidth(1);
|
||||
setBackgroundColor(RGBA(1.0,1.0,1.0,1.0));
|
||||
|
||||
displaylists_p = std::vector<GLuint>(DisplayListSize);
|
||||
for (unsigned k=0; k!=displaylists_p.size(); ++k)
|
||||
{
|
||||
displaylists_p[k] = 0;
|
||||
}
|
||||
|
||||
datacolor_p = new StandardColor(this, 100);
|
||||
title_.setFont("Courier", 16, QFont::Bold);
|
||||
title_.setString("");
|
||||
|
||||
setTitlePosition(0.95);
|
||||
|
||||
kbd_input_enabled_ = true;
|
||||
|
||||
#if QT_VERSION < 0x040000
|
||||
setFocusPolicy(QWidget::StrongFocus);
|
||||
assignMouse(Qt::LeftButton,
|
||||
Qt::LeftButton | Qt::ShiftButton,
|
||||
Qt::LeftButton,
|
||||
Qt::LeftButton | Qt::AltButton,
|
||||
Qt::LeftButton | Qt::AltButton,
|
||||
Qt::LeftButton | Qt::AltButton | Qt::ShiftButton,
|
||||
Qt::LeftButton | Qt::AltButton | Qt::ControlButton,
|
||||
Qt::LeftButton | Qt::ControlButton,
|
||||
Qt::LeftButton | Qt::ControlButton);
|
||||
|
||||
|
||||
assignKeyboard(Qt::Key_Down, Qt::Key_Up,
|
||||
Qt::ShiftButton + Qt::Key_Right, Qt::ShiftButton + Qt::Key_Left,
|
||||
Qt::Key_Right, Qt::Key_Left,
|
||||
Qt::AltButton + Qt::Key_Right, Qt::AltButton + Qt::Key_Left,
|
||||
Qt::AltButton + Qt::Key_Down, Qt::AltButton + Qt::Key_Up,
|
||||
Qt::AltButton + Qt::ShiftButton + Qt::Key_Down, Qt::AltButton + Qt::ShiftButton + Qt::Key_Up,
|
||||
Qt::AltButton + Qt::ControlButton + Qt::Key_Down, Qt::AltButton + Qt::ControlButton + Qt::Key_Up,
|
||||
Qt::ControlButton + Qt::Key_Right, Qt::ControlButton + Qt::Key_Left,
|
||||
Qt::ControlButton + Qt::Key_Down, Qt::ControlButton + Qt::Key_Up
|
||||
);
|
||||
#else
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
assignMouse(Qt::LeftButton,
|
||||
MouseState(Qt::LeftButton, Qt::ShiftModifier),
|
||||
Qt::LeftButton,
|
||||
MouseState(Qt::LeftButton, Qt::AltModifier),
|
||||
MouseState(Qt::LeftButton, Qt::AltModifier),
|
||||
MouseState(Qt::LeftButton, Qt::AltModifier | Qt::ShiftModifier),
|
||||
MouseState(Qt::LeftButton, Qt::AltModifier | Qt::ControlModifier),
|
||||
MouseState(Qt::LeftButton, Qt::ControlModifier),
|
||||
MouseState(Qt::LeftButton, Qt::ControlModifier)
|
||||
);
|
||||
|
||||
|
||||
assignKeyboard(Qt::Key_Down, Qt::Key_Up,
|
||||
KeyboardState(Qt::Key_Right, Qt::ShiftModifier), KeyboardState(Qt::Key_Left, Qt::ShiftModifier),
|
||||
Qt::Key_Right, Qt::Key_Left,
|
||||
KeyboardState(Qt::Key_Right, Qt::AltModifier), KeyboardState(Qt::Key_Left, Qt::AltModifier),
|
||||
KeyboardState(Qt::Key_Down, Qt::AltModifier), KeyboardState(Qt::Key_Up, Qt::AltModifier),
|
||||
KeyboardState(Qt::Key_Down, Qt::AltModifier|Qt::ShiftModifier), KeyboardState(Qt::Key_Up, Qt::AltModifier|Qt::ShiftModifier),
|
||||
KeyboardState(Qt::Key_Down, Qt::AltModifier|Qt::ControlModifier), KeyboardState(Qt::Key_Up, Qt::AltModifier|Qt::ControlModifier),
|
||||
KeyboardState(Qt::Key_Right, Qt::ControlModifier), KeyboardState(Qt::Key_Left, Qt::ControlModifier),
|
||||
KeyboardState(Qt::Key_Down, Qt::ControlModifier), KeyboardState(Qt::Key_Up, Qt::ControlModifier)
|
||||
);
|
||||
#endif
|
||||
setKeySpeed(3,5,5);
|
||||
|
||||
legend_.setLimits(0, 100);
|
||||
legend_.setMajors(10);
|
||||
legend_.setMinors(2);
|
||||
legend_.setOrientation(ColorLegend::BottomTop, ColorLegend::Left);
|
||||
|
||||
lighting_enabled_ = false;
|
||||
disableLighting();
|
||||
lights_ = std::vector<Light>(8);
|
||||
}
|
||||
|
||||
/*!
|
||||
Release allocated resources
|
||||
*/
|
||||
|
||||
Plot3D::~Plot3D()
|
||||
{
|
||||
makeCurrent();
|
||||
SaveGlDeleteLists( displaylists_p[0], displaylists_p.size() );
|
||||
datacolor_p->destroy();
|
||||
delete userplotstyle_p;
|
||||
for (ELIT it = elist_p.begin(); it!=elist_p.end(); ++it)
|
||||
delete (*it);
|
||||
|
||||
elist_p.clear();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Set up the OpenGL rendering state
|
||||
*/
|
||||
void Plot3D::initializeGL()
|
||||
{
|
||||
glEnable( GL_BLEND );
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
// Set up the lights
|
||||
|
||||
disableLighting();
|
||||
|
||||
GLfloat whiteAmb[4] = {1.0, 1.0, 1.0, 1.0};
|
||||
|
||||
setLightShift(0, 0, 3000);
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
|
||||
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
|
||||
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, whiteAmb);
|
||||
|
||||
setMaterialComponent(GL_DIFFUSE, 1.0);
|
||||
setMaterialComponent(GL_SPECULAR, 0.3);
|
||||
setMaterialComponent(GL_SHININESS, 5.0);
|
||||
setLightComponent(GL_DIFFUSE, 1.0);
|
||||
setLightComponent(GL_SPECULAR, 1.0);
|
||||
|
||||
initializedGL_ = true;
|
||||
if (renderpixmaprequest_)
|
||||
{
|
||||
updateData();
|
||||
renderpixmaprequest_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Paint the widgets content.
|
||||
*/
|
||||
void Plot3D::paintGL()
|
||||
{
|
||||
glClearColor(bgcolor_.r, bgcolor_.g, bgcolor_.b, bgcolor_.a);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glPushMatrix();
|
||||
applyLights();
|
||||
|
||||
glRotatef( -90, 1.0, 0.0, 0.0 );
|
||||
glRotatef( 0.0, 0.0, 1.0, 0.0 );
|
||||
glRotatef( 0.0, 0.0, 0.0, 1.0 );
|
||||
|
||||
if (displaylegend_)
|
||||
{
|
||||
legend_.draw();
|
||||
}
|
||||
title_.setRelPosition(titlerel_, titleanchor_);
|
||||
title_.draw();
|
||||
|
||||
Triple beg = coordinates_p.first();
|
||||
Triple end = coordinates_p.second();
|
||||
|
||||
Triple center = beg + (end-beg) / 2;
|
||||
double radius = (center-beg).length();
|
||||
|
||||
glLoadIdentity();
|
||||
|
||||
glRotatef( xRot_-90, 1.0, 0.0, 0.0 );
|
||||
glRotatef( yRot_, 0.0, 1.0, 0.0 );
|
||||
glRotatef( zRot_, 0.0, 0.0, 1.0 );
|
||||
|
||||
glScalef( zoom_ * xScale_, zoom_ * yScale_, zoom_ * zScale_ );
|
||||
|
||||
glTranslatef(xShift_-center.x, yShift_-center.y, zShift_-center.z);
|
||||
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glLoadIdentity();
|
||||
|
||||
if (beg != end)
|
||||
{
|
||||
if (ortho_)
|
||||
{
|
||||
glOrtho( -radius, +radius, -radius, +radius, 0, 40 * radius);
|
||||
}
|
||||
else
|
||||
{
|
||||
glFrustum( -radius, +radius, -radius, +radius, 5 * radius, 400 * radius );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ortho_)
|
||||
glOrtho( -1.0, 1.0, -1.0, 1.0, 10.0, 100.0 );
|
||||
else
|
||||
glFrustum( -1.0, 1.0, -1.0, 1.0, 10.0, 100.0 );
|
||||
}
|
||||
|
||||
glTranslatef( xVPShift_ * 2 * radius , yVPShift_ * 2 * radius , -7 * radius );
|
||||
|
||||
if (lighting_enabled_)
|
||||
glEnable(GL_NORMALIZE);
|
||||
|
||||
for (unsigned i=0; i!= displaylists_p.size(); ++i)
|
||||
{
|
||||
if (i!=LegendObject)
|
||||
glCallList( displaylists_p[i] );
|
||||
}
|
||||
coordinates_p.draw();
|
||||
|
||||
if (lighting_enabled_)
|
||||
glDisable(GL_NORMALIZE);
|
||||
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Set up the OpenGL view port
|
||||
*/
|
||||
void Plot3D::resizeGL( int w, int h )
|
||||
{
|
||||
glViewport( 0, 0, w, h );
|
||||
paintGL();
|
||||
}
|
||||
|
||||
/*!
|
||||
Reimplemented from QGLWidget
|
||||
*/
|
||||
QPixmap Plot3D::renderPixmap(int w/* =0 */, int h/* =0 */, bool useContext/* =false */)
|
||||
{
|
||||
renderpixmaprequest_ = true;
|
||||
return QGLWidget::renderPixmap(w,h,useContext);
|
||||
}
|
||||
|
||||
/*!
|
||||
Create a coordinate system with generating corners beg and end
|
||||
*/
|
||||
void Plot3D::createCoordinateSystem( Triple beg, Triple end )
|
||||
{
|
||||
if (beg != coordinates_p.first() || end != coordinates_p.second())
|
||||
coordinates_p.init(beg, end);
|
||||
}
|
||||
|
||||
/*!
|
||||
Create a coordinate system from data
|
||||
*/
|
||||
void Plot3D::createCoordinateSystem()
|
||||
{
|
||||
calculateHull();
|
||||
Triple beg = hull().minVertex; // Irix 6.5 compiler bug
|
||||
Triple end = hull().maxVertex;
|
||||
createCoordinateSystem(beg, end);
|
||||
}
|
||||
|
||||
/*!
|
||||
Show a color legend
|
||||
*/
|
||||
void Plot3D::showColorLegend( bool show )
|
||||
{
|
||||
displaylegend_ = show;
|
||||
if (show)
|
||||
datacolor_p->createVector(legend_.colors);
|
||||
updateGL();
|
||||
}
|
||||
|
||||
void Plot3D::setMeshColor(RGBA rgba)
|
||||
{
|
||||
meshcolor_ = rgba;
|
||||
}
|
||||
|
||||
void Plot3D::setBackgroundColor(RGBA rgba)
|
||||
{
|
||||
bgcolor_ = rgba;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
assign a new coloring object for the data.
|
||||
*/
|
||||
void Plot3D::setDataColor( Color* col )
|
||||
{
|
||||
Q_ASSERT(datacolor_p);
|
||||
|
||||
datacolor_p->destroy();
|
||||
datacolor_p = col;
|
||||
}
|
||||
|
||||
/*!
|
||||
Set up ortogonal or perspective mode and updates widget
|
||||
*/
|
||||
void Plot3D::setOrtho( bool val )
|
||||
{
|
||||
if (val == ortho_)
|
||||
return;
|
||||
ortho_ = val;
|
||||
updateGL();
|
||||
|
||||
emit projectionChanged(val);
|
||||
}
|
||||
|
||||
/*!
|
||||
Set style of coordinate system
|
||||
*/
|
||||
void Plot3D::setCoordinateStyle(COORDSTYLE st)
|
||||
{
|
||||
coordinates_p.setStyle(st);
|
||||
updateGL();
|
||||
}
|
||||
|
||||
/*!
|
||||
Set plotstyle for the standard plotting types. An argument of value Qwt3D::USER
|
||||
is ignored.
|
||||
*/
|
||||
void Plot3D::setPlotStyle( PLOTSTYLE val )
|
||||
{
|
||||
if (val == Qwt3D::USER)
|
||||
return;
|
||||
delete userplotstyle_p;
|
||||
userplotstyle_p = 0;
|
||||
plotstyle_ = val;
|
||||
}
|
||||
|
||||
/*!
|
||||
Set plotstyle to Qwt3D::USER and an associated enrichment object.
|
||||
*/
|
||||
Qwt3D::Enrichment* Plot3D::setPlotStyle( Qwt3D::Enrichment const& obj )
|
||||
{
|
||||
if (&obj == userplotstyle_p)
|
||||
return userplotstyle_p;
|
||||
|
||||
delete userplotstyle_p;
|
||||
userplotstyle_p = obj.clone();
|
||||
plotstyle_ = Qwt3D::USER;
|
||||
return userplotstyle_p;
|
||||
}
|
||||
|
||||
/*!
|
||||
Set shading style
|
||||
*/
|
||||
void Plot3D::setShading( SHADINGSTYLE val )
|
||||
{
|
||||
if (val == shading_)
|
||||
return;
|
||||
|
||||
shading_ = val;
|
||||
|
||||
switch (shading_)
|
||||
{
|
||||
case FLAT:
|
||||
glShadeModel(GL_FLAT);
|
||||
break;
|
||||
case GOURAUD:
|
||||
glShadeModel(GL_SMOOTH);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
updateGL();
|
||||
}
|
||||
|
||||
/*!
|
||||
Set number of isolines. The lines are equidistant between minimal and maximal Z value
|
||||
*/
|
||||
void Plot3D::setIsolines(int steps)
|
||||
{
|
||||
if (steps < 0)
|
||||
return;
|
||||
|
||||
isolines_ = steps;
|
||||
}
|
||||
|
||||
/*!
|
||||
Set Polygon offset. The function affects the OpenGL rendering process.
|
||||
Try different values for surfaces with polygons only and with mesh and polygons
|
||||
*/
|
||||
void Plot3D::setPolygonOffset( double val )
|
||||
{
|
||||
polygonOffset_ = val;
|
||||
}
|
||||
|
||||
void Plot3D::setMeshLineWidth( double val )
|
||||
{
|
||||
Q_ASSERT(val>=0);
|
||||
|
||||
if (val < 0)
|
||||
return;
|
||||
|
||||
meshLineWidth_ = val;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Set relative caption position (0.5,0.5) means, the anchor point lies in the center of the screen
|
||||
*/
|
||||
void Plot3D::setTitlePosition(double rely, double relx, Qwt3D::ANCHOR anchor)
|
||||
{
|
||||
titlerel_.y = (rely<0 || rely>1) ? 0.5 : rely;
|
||||
titlerel_.x = (relx<0 || relx>1) ? 0.5 : relx;
|
||||
|
||||
titleanchor_ = anchor;
|
||||
}
|
||||
|
||||
/*!
|
||||
Set caption font
|
||||
*/
|
||||
void Plot3D::setTitleFont(const QString& family, int pointSize, int weight, bool italic)
|
||||
{
|
||||
title_.setFont(family, pointSize, weight, italic);
|
||||
}
|
||||
|
||||
Enrichment* Plot3D::addEnrichment(Enrichment const& e)
|
||||
{
|
||||
if ( elist_p.end() == std::find( elist_p.begin(), elist_p.end(), &e ) )
|
||||
elist_p.push_back(e.clone());
|
||||
return elist_p.back();
|
||||
}
|
||||
|
||||
bool Plot3D::degrade(Enrichment* e)
|
||||
{
|
||||
ELIT it = std::find(elist_p.begin(), elist_p.end(), e);
|
||||
|
||||
if ( it != elist_p.end() )
|
||||
{
|
||||
delete (*it);
|
||||
elist_p.erase(it);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Plot3D::createEnrichments()
|
||||
{
|
||||
for (ELIT it = elist_p.begin(); it!=elist_p.end(); ++it)
|
||||
{
|
||||
this->createEnrichment(**it);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Update OpenGL data representation
|
||||
*/
|
||||
void Plot3D::updateData()
|
||||
{
|
||||
makeCurrent();
|
||||
GLStateBewarer dt(GL_DEPTH_TEST, true);
|
||||
GLStateBewarer ls(GL_LINE_SMOOTH, true);
|
||||
|
||||
calculateHull();
|
||||
|
||||
SaveGlDeleteLists(displaylists_p[DataObject], 1); // nur Daten
|
||||
|
||||
displaylists_p[DataObject] = glGenLists(1);
|
||||
glNewList(displaylists_p[DataObject], GL_COMPILE);
|
||||
|
||||
this->createEnrichments();
|
||||
this->createData();
|
||||
|
||||
glEndList();
|
||||
}
|
@ -0,0 +1,304 @@
|
||||
#include "qwt3d_scale.h"
|
||||
|
||||
using namespace Qwt3D;
|
||||
|
||||
Scale::Scale()
|
||||
: start_p(0.), stop_p(0.),
|
||||
majorintervals_p(0), minorintervals_p(0),
|
||||
mstart_p(0.), mstop_p(0.)
|
||||
{
|
||||
}
|
||||
|
||||
/*! The function maps the double value at tic-position idx to a final
|
||||
representation. The default return value is simply the tic values QString
|
||||
representation. Overwrite this function, if you plan to transform the value
|
||||
in some way. See e.g. LogScale::ticLabel.
|
||||
\param idx the current major tic index
|
||||
\return The QString representation for the value corresponding to a valid index,
|
||||
an empty QString else.
|
||||
*/
|
||||
QString Scale::ticLabel(unsigned int idx) const
|
||||
{
|
||||
if (idx<majors_p.size())
|
||||
{
|
||||
return QString::number(majors_p[idx]);
|
||||
}
|
||||
return QString("");
|
||||
}
|
||||
|
||||
//! Sets start and stop value for the scale;
|
||||
void Scale::setLimits(double start, double stop)
|
||||
{
|
||||
if (start < stop)
|
||||
{
|
||||
start_p = start;
|
||||
stop_p = stop;
|
||||
return;
|
||||
}
|
||||
start_p = stop;
|
||||
stop_p = start;
|
||||
}
|
||||
|
||||
//! Sets value of first major tic
|
||||
void Scale::setMajorLimits(double start, double stop)
|
||||
{
|
||||
if (start < stop)
|
||||
{
|
||||
mstart_p = start;
|
||||
mstop_p = stop;
|
||||
return;
|
||||
}
|
||||
mstart_p = stop;
|
||||
mstop_p = start;
|
||||
}
|
||||
|
||||
/*!
|
||||
\param a First major tic after applying autoscaling
|
||||
\param b Last major tic after applying autoscaling
|
||||
\param start Scale begin
|
||||
\param stop Scale end
|
||||
\param ivals Requested number of major intervals
|
||||
\return Number of major intervals after autoscaling\n
|
||||
|
||||
The default implementation sets a=start, b=stop and returns ivals.
|
||||
*/
|
||||
int Scale::autoscale(double& a, double& b, double start, double stop, int ivals)
|
||||
{
|
||||
a = start;
|
||||
b = stop;
|
||||
return ivals;
|
||||
}
|
||||
|
||||
/***************************
|
||||
*
|
||||
* linear scales
|
||||
*
|
||||
***************************/
|
||||
|
||||
|
||||
//! Applies LinearAutoScaler::execute()
|
||||
int LinearScale::autoscale(double& a, double& b, double start, double stop, int ivals)
|
||||
{
|
||||
return autoscaler_p.execute(a, b, start, stop, ivals);
|
||||
}
|
||||
|
||||
//! Creates the major and minor vector for the scale
|
||||
void LinearScale::calculate()
|
||||
{
|
||||
majors_p.clear();
|
||||
minors_p.clear();
|
||||
|
||||
double interval = mstop_p-mstart_p;
|
||||
|
||||
double runningval;
|
||||
int i=0;
|
||||
|
||||
// majors
|
||||
|
||||
// first tic
|
||||
// if (mstart_p<start_p || mstop_p>stop_p)
|
||||
// return;
|
||||
|
||||
majors_p.push_back(mstart_p);
|
||||
|
||||
// remaining tics
|
||||
for (i = 1; i <= majorintervals_p; ++i)
|
||||
{
|
||||
double t = double(i) / majorintervals_p;
|
||||
runningval = mstart_p + t * interval;
|
||||
if (runningval>stop_p)
|
||||
break;
|
||||
if (isPracticallyZero(mstart_p, -t*interval)) // prevent rounding errors near 0
|
||||
runningval = 0.0;
|
||||
majors_p.push_back(runningval);
|
||||
}
|
||||
majorintervals_p = majors_p.size();
|
||||
if (majorintervals_p)
|
||||
--majorintervals_p;
|
||||
|
||||
|
||||
// minors
|
||||
|
||||
if (!majorintervals_p || !minorintervals_p) // no valid interval
|
||||
{
|
||||
minorintervals_p = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// start_p mstart_p
|
||||
// |_____________|_____ _ _ _
|
||||
|
||||
double step = (majors_p[1]-majors_p[0]) / minorintervals_p;
|
||||
if (isPracticallyZero(step))
|
||||
return;
|
||||
|
||||
runningval = mstart_p-step;
|
||||
while (runningval>start_p)
|
||||
{
|
||||
minors_p.push_back(runningval);
|
||||
runningval -= step;
|
||||
}
|
||||
|
||||
// mstart_p mstop_p
|
||||
// ________|_____ _ _ _ _ _ ___|__________
|
||||
|
||||
for (i=0; i!=majorintervals_p; ++i)
|
||||
{
|
||||
runningval = majors_p[i] + step;
|
||||
for (int j=0; j!=minorintervals_p; ++j)
|
||||
{
|
||||
minors_p.push_back(runningval);
|
||||
runningval += step;
|
||||
}
|
||||
}
|
||||
|
||||
// mstop_p stop_p
|
||||
// _ _ _|_____________|
|
||||
|
||||
runningval = mstop_p + step;
|
||||
while (runningval<stop_p)
|
||||
{
|
||||
minors_p.push_back(runningval);
|
||||
runningval += step;
|
||||
}
|
||||
}
|
||||
|
||||
void LogScale::setupCounter(double& k, int& step)
|
||||
{
|
||||
switch(minorintervals_p)
|
||||
{
|
||||
case 9:
|
||||
k=9;
|
||||
step=1;
|
||||
break;
|
||||
case 5:
|
||||
k=8;
|
||||
step=2;
|
||||
break;
|
||||
case 3:
|
||||
k=5;
|
||||
step=3;
|
||||
break;
|
||||
case 2:
|
||||
k=5;
|
||||
step=5;
|
||||
break;
|
||||
default:
|
||||
k=9;
|
||||
step=1;
|
||||
}
|
||||
}
|
||||
|
||||
/*! Creates major and minor vectors for the scale.
|
||||
\warning If the interval is too small, the scale becomes empty
|
||||
or will contain only a single major tic. There is no automatism
|
||||
(also not planned for now) for an 'intelligent' guess, what to do.
|
||||
Better switch manually to linear to scales in such cases.
|
||||
*/
|
||||
void LogScale::calculate()
|
||||
{
|
||||
majors_p.clear();
|
||||
minors_p.clear();
|
||||
|
||||
if (start_p < DBL_MIN_10_EXP)
|
||||
start_p = DBL_MIN_10_EXP;
|
||||
if (stop_p > DBL_MAX_10_EXP)
|
||||
stop_p = DBL_MAX_10_EXP;
|
||||
|
||||
double interval = stop_p-start_p;
|
||||
if (interval<=0)
|
||||
return;
|
||||
|
||||
double runningval = floor(start_p);
|
||||
while(runningval<=stop_p)
|
||||
{
|
||||
if (runningval>=start_p)
|
||||
majors_p.push_back(runningval);
|
||||
++runningval;
|
||||
}
|
||||
majorintervals_p = majors_p.size();
|
||||
if (majorintervals_p)
|
||||
--majorintervals_p;
|
||||
|
||||
if (majors_p.size()<1) // not even a single major tic
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// minors
|
||||
|
||||
// start_p mstart_p
|
||||
// |_____________|_____ _ _ _
|
||||
|
||||
double k;
|
||||
int step;
|
||||
setupCounter(k,step);
|
||||
runningval = log10(k)+(majors_p[0]-1);
|
||||
while (runningval>start_p && k>1)
|
||||
{
|
||||
minors_p.push_back(runningval);
|
||||
k -=step;
|
||||
runningval = log10(k)+(majors_p[0]-1);
|
||||
}
|
||||
|
||||
// mstart_p mstop_p
|
||||
// ________|_____ _ _ _ _ _ ___|__________
|
||||
|
||||
for (int i=0; i!=majorintervals_p; ++i)
|
||||
{
|
||||
setupCounter(k,step);
|
||||
runningval = log10(k)+(majors_p[i]);
|
||||
while (k>1)
|
||||
{
|
||||
minors_p.push_back(runningval);
|
||||
k-=step;
|
||||
runningval = log10(k)+(majors_p[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// mstop_p stop_p
|
||||
// _ _ _|_____________|
|
||||
|
||||
setupCounter(k,step);
|
||||
runningval = log10(k)+(majors_p.back());
|
||||
do
|
||||
{
|
||||
k-=step;
|
||||
runningval = log10(k)+(majors_p.back());
|
||||
}
|
||||
while(runningval>=stop_p);
|
||||
while (k>1)
|
||||
{
|
||||
minors_p.push_back(runningval);
|
||||
k-=step;
|
||||
runningval = log10(k)+(majors_p.back());
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the minor intervals for the logarithmic scale. Only values of 9,5,3 or 2
|
||||
are accepted as arguments. They will produce mantissa sets of {2,3,4,5,6,7,8,9},
|
||||
{2,4,6,8}, {2,5} or {5} respectively.
|
||||
*/
|
||||
void LogScale::setMinors(int val)
|
||||
{
|
||||
if ((val == 2) || (val == 3) || (val == 5) || (val == 9))
|
||||
minorintervals_p = val;
|
||||
}
|
||||
|
||||
LogScale::LogScale()
|
||||
{
|
||||
minorintervals_p = 9;
|
||||
}
|
||||
|
||||
//! Returns a power of 10 associated to the major value at index idx.
|
||||
QString LogScale::ticLabel(unsigned int idx) const
|
||||
{
|
||||
if (idx<majors_p.size())
|
||||
{
|
||||
double val = majors_p[idx];
|
||||
return QString::number(pow(double(10), val));
|
||||
}
|
||||
return QString("");
|
||||
}
|
@ -0,0 +1,183 @@
|
||||
#include "qwt3d_surfaceplot.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace Qwt3D;
|
||||
|
||||
/**
|
||||
Initializes with dataNormals()==false, NOFLOOR, resolution() == 1
|
||||
*/
|
||||
#if QT_VERSION < 0x040000
|
||||
SurfacePlot::SurfacePlot( QWidget* parent, const char* name )
|
||||
: Plot3D( parent, name )
|
||||
#else
|
||||
SurfacePlot::SurfacePlot( QWidget * parent, const QGLWidget * shareWidget)
|
||||
: Plot3D( parent, shareWidget)
|
||||
#endif
|
||||
{
|
||||
datanormals_p = false;
|
||||
normalLength_p = 0.02;
|
||||
normalQuality_p = 3;
|
||||
|
||||
resolution_p = 1;
|
||||
actualDataG_ = new GridData();
|
||||
actualDataC_ = new CellData();
|
||||
|
||||
actualData_p = actualDataG_;
|
||||
|
||||
floorstyle_ = NOFLOOR;
|
||||
}
|
||||
|
||||
SurfacePlot::~SurfacePlot()
|
||||
{
|
||||
delete actualDataG_;
|
||||
delete actualDataC_;
|
||||
}
|
||||
|
||||
void SurfacePlot::showNormals(bool b)
|
||||
{
|
||||
datanormals_p = b;
|
||||
}
|
||||
|
||||
/**
|
||||
Values < 0 or > 1 are ignored
|
||||
*/
|
||||
void SurfacePlot::setNormalLength(double val)
|
||||
{
|
||||
if (val<0 || val>1)
|
||||
return;
|
||||
normalLength_p = val;
|
||||
}
|
||||
|
||||
/**
|
||||
Values < 3 are ignored
|
||||
*/
|
||||
void SurfacePlot::setNormalQuality(int val)
|
||||
{
|
||||
if (val<3)
|
||||
return;
|
||||
normalQuality_p = val;
|
||||
}
|
||||
|
||||
/**
|
||||
Calculates the smallest x-y-z parallelepiped enclosing the data.
|
||||
It can be accessed by hull();
|
||||
*/
|
||||
void SurfacePlot::calculateHull()
|
||||
{
|
||||
if (actualData_p->empty())
|
||||
return;
|
||||
setHull(actualData_p->hull());
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets data resolution (res == 1 original resolution) and updates widget
|
||||
If res < 1, the function does nothing
|
||||
*/
|
||||
void SurfacePlot::setResolution( int res )
|
||||
{
|
||||
if (!actualData_p || actualData_p->datatype == Qwt3D::POLYGON)
|
||||
return;
|
||||
|
||||
if ((resolution_p == res) || res < 1)
|
||||
return;
|
||||
|
||||
resolution_p = res;
|
||||
updateNormals();
|
||||
updateData();
|
||||
if (initializedGL())
|
||||
updateGL();
|
||||
|
||||
emit resolutionChanged(res);
|
||||
}
|
||||
|
||||
void SurfacePlot::updateNormals()
|
||||
{
|
||||
SaveGlDeleteLists(displaylists_p[NormalObject], 1);
|
||||
|
||||
if (plotStyle() == NOPLOT && !normals() || !actualData_p)
|
||||
return;
|
||||
|
||||
displaylists_p[NormalObject] = glGenLists(1);
|
||||
glNewList(displaylists_p[NormalObject], GL_COMPILE);
|
||||
|
||||
if (actualData_p->datatype == Qwt3D::POLYGON)
|
||||
createNormalsC();
|
||||
else if (actualData_p->datatype == Qwt3D::GRID)
|
||||
createNormalsG();
|
||||
|
||||
glEndList();
|
||||
}
|
||||
|
||||
void SurfacePlot::createData()
|
||||
{
|
||||
if (!actualData_p)
|
||||
return;
|
||||
if (actualData_p->datatype == Qwt3D::POLYGON)
|
||||
createDataC();
|
||||
else if (actualData_p->datatype == Qwt3D::GRID)
|
||||
createDataG();
|
||||
}
|
||||
|
||||
|
||||
void SurfacePlot::createFloorData()
|
||||
{
|
||||
if (!actualData_p)
|
||||
return;
|
||||
if (actualData_p->datatype == Qwt3D::POLYGON)
|
||||
createFloorDataC();
|
||||
else if (actualData_p->datatype == Qwt3D::GRID)
|
||||
createFloorDataG();
|
||||
}
|
||||
|
||||
/**
|
||||
The returned value is not affected by resolution(). The pair gives (columns,rows) for grid data
|
||||
, (number of cells,1) for free formed data (datatype() == POLYGON) and (0,0) else
|
||||
*/
|
||||
pair<int,int> SurfacePlot::facets() const
|
||||
{
|
||||
if (!hasData())
|
||||
return pair<int,int>(0,0);
|
||||
|
||||
if (actualData_p->datatype == Qwt3D::POLYGON)
|
||||
return pair<int,int>(int(actualDataC_->cells.size()), 1);
|
||||
else if (actualData_p->datatype == Qwt3D::GRID)
|
||||
return pair<int,int>(actualDataG_->columns(), actualDataG_->rows());
|
||||
else
|
||||
return pair<int,int>(0,0);
|
||||
}
|
||||
|
||||
void SurfacePlot::createPoints()
|
||||
{
|
||||
Dot pt;
|
||||
createEnrichment(pt);
|
||||
}
|
||||
|
||||
void SurfacePlot::createEnrichment(Enrichment& p)
|
||||
{
|
||||
if (!actualData_p)
|
||||
return;
|
||||
|
||||
//todo future work
|
||||
if (p.type() != Enrichment::VERTEXENRICHMENT)
|
||||
return;
|
||||
|
||||
p.assign(*this);
|
||||
p.drawBegin();
|
||||
|
||||
VertexEnrichment* ve = (VertexEnrichment*)&p;
|
||||
if (actualData_p->datatype == Qwt3D::POLYGON)
|
||||
{
|
||||
for (unsigned i = 0; i != actualDataC_->normals.size(); ++i)
|
||||
ve->draw(actualDataC_->nodes[i]);
|
||||
}
|
||||
else if (actualData_p->datatype == Qwt3D::GRID)
|
||||
{
|
||||
int step = resolution();
|
||||
for (int i = 0; i <= actualDataG_->columns() - step; i += step)
|
||||
for (int j = 0; j <= actualDataG_->rows() - step; j += step)
|
||||
ve->draw(Triple(actualDataG_->vertices[i][j][0],
|
||||
actualDataG_->vertices[i][j][1],
|
||||
actualDataG_->vertices[i][j][2]));
|
||||
}
|
||||
p.drawEnd();
|
||||
}
|
@ -0,0 +1,222 @@
|
||||
#if defined(_MSC_VER) /* MSVC Compiler */
|
||||
#pragma warning ( disable : 4786 )
|
||||
#endif
|
||||
|
||||
#include <stdlib.h> // qsort
|
||||
#include <algorithm>
|
||||
#include <float.h>
|
||||
#include "qwt3d_types.h"
|
||||
|
||||
using namespace Qwt3D;
|
||||
|
||||
#ifndef QWT3D_NOT_FOR_DOXYGEN
|
||||
|
||||
namespace {
|
||||
// convex hull
|
||||
|
||||
typedef double coordinate_type;
|
||||
|
||||
int ccw(coordinate_type **P, int i, int j, int k) {
|
||||
coordinate_type a = P[i][0] - P[j][0],
|
||||
b = P[i][1] - P[j][1],
|
||||
c = P[k][0] - P[j][0],
|
||||
d = P[k][1] - P[j][1];
|
||||
return a*d - b*c <= 0; /* true if points i, j, k counterclockwise */
|
||||
}
|
||||
|
||||
|
||||
#define CMPM(c,A,B) \
|
||||
v = (*(coordinate_type**)A)[c] - (*(coordinate_type**)B)[c];\
|
||||
if (v>0) return 1;\
|
||||
if (v<0) return -1;
|
||||
|
||||
int cmpl(const void *a, const void *b) {
|
||||
double v;
|
||||
CMPM(0,a,b);
|
||||
CMPM(1,b,a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cmph(const void *a, const void *b) {return cmpl(b,a);}
|
||||
|
||||
|
||||
int make_chain(coordinate_type** V, int n, int (*cmp)(const void*, const void*)) {
|
||||
int i, j, s = 1;
|
||||
coordinate_type* t;
|
||||
|
||||
qsort(V, n, sizeof(coordinate_type*), cmp);
|
||||
for (i=2; i<n; i++) {
|
||||
for (j=s; j>=1 && ccw(V, i, j, j-1); j--){}
|
||||
s = j+1;
|
||||
t = V[s]; V[s] = V[i]; V[i] = t;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
int _ch2d(coordinate_type **P, int n) {
|
||||
int u = make_chain(P, n, cmpl); /* make lower hull */
|
||||
if (!n) return 0;
|
||||
P[n] = P[0];
|
||||
return u+make_chain(P+u, n-u+1, cmph); /* make upper hull */
|
||||
}
|
||||
|
||||
|
||||
} // ns anon
|
||||
|
||||
|
||||
GridData::GridData()
|
||||
{
|
||||
datatype = Qwt3D::GRID;
|
||||
setSize(0,0);
|
||||
setPeriodic(false,false);
|
||||
}
|
||||
|
||||
GridData::GridData(unsigned int columns, unsigned int rows)
|
||||
{
|
||||
datatype = Qwt3D::GRID;
|
||||
setSize(columns,rows);
|
||||
setPeriodic(false,false);
|
||||
}
|
||||
|
||||
int GridData::columns() const
|
||||
{
|
||||
return (int)vertices.size();
|
||||
}
|
||||
|
||||
int GridData::rows() const
|
||||
{
|
||||
return (empty()) ? 0 : (int)vertices[0].size();
|
||||
}
|
||||
|
||||
void GridData::clear()
|
||||
{
|
||||
setHull(ParallelEpiped());
|
||||
{
|
||||
for (unsigned i=0; i!=vertices.size(); ++i)
|
||||
{
|
||||
for (unsigned j=0; j!=vertices[i].size(); ++j)
|
||||
{
|
||||
delete [] vertices[i][j];
|
||||
}
|
||||
vertices[i].clear();
|
||||
}
|
||||
}
|
||||
|
||||
vertices.clear();
|
||||
|
||||
{
|
||||
for (unsigned i=0; i!=normals.size(); ++i)
|
||||
{
|
||||
for (unsigned j=0; j!=normals[i].size(); ++j)
|
||||
{
|
||||
delete [] normals[i][j];
|
||||
}
|
||||
normals[i].clear();
|
||||
}
|
||||
}
|
||||
|
||||
normals.clear();
|
||||
}
|
||||
|
||||
|
||||
void GridData::setSize(unsigned int columns, unsigned int rows)
|
||||
{
|
||||
this->clear();
|
||||
vertices = std::vector<DataRow>(columns);
|
||||
{
|
||||
for (unsigned int i=0; i!=vertices.size(); ++i)
|
||||
{
|
||||
vertices[i] = DataRow(rows);
|
||||
for (unsigned int j=0; j!=vertices[i].size(); ++j)
|
||||
{
|
||||
vertices[i][j] = new GLdouble[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
normals = std::vector<DataRow>(columns);
|
||||
{
|
||||
for (unsigned int i=0; i!=normals.size(); ++i)
|
||||
{
|
||||
normals[i] = DataRow(rows);
|
||||
for (unsigned int j=0; j!=normals[i].size(); ++j)
|
||||
{
|
||||
normals[i][j] = new GLdouble[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Triple const& CellData::operator()(unsigned cellnumber, unsigned vertexnumber)
|
||||
{
|
||||
return nodes[cells[cellnumber][vertexnumber]];
|
||||
}
|
||||
|
||||
void CellData::clear()
|
||||
{
|
||||
setHull(ParallelEpiped());
|
||||
cells.clear();
|
||||
nodes.clear();
|
||||
normals.clear();
|
||||
}
|
||||
|
||||
QColor Qwt3D::GL2Qt(GLdouble r, GLdouble g, GLdouble b)
|
||||
{
|
||||
return QColor(round(r * 255), round(g * 255), round(b * 255));
|
||||
}
|
||||
|
||||
RGBA Qwt3D::Qt2GL(QColor col)
|
||||
{
|
||||
QRgb qrgb = col.rgb();
|
||||
RGBA rgba;
|
||||
rgba.r = qRed(qrgb) / 255.0;
|
||||
rgba.g = qGreen(qrgb) / 255.0;
|
||||
rgba.b = qBlue(qrgb) / 255.0;
|
||||
rgba.a = qAlpha(qrgb) / 255.0;
|
||||
return rgba;
|
||||
}
|
||||
|
||||
|
||||
void Qwt3D::convexhull2d( std::vector<unsigned>& idx, const std::vector<Tuple>& src )
|
||||
{
|
||||
idx.clear();
|
||||
if (src.empty())
|
||||
return;
|
||||
if (src.size()==1)
|
||||
{
|
||||
idx.push_back(0);
|
||||
return;
|
||||
}
|
||||
coordinate_type** points = new coordinate_type*[src.size()+1] ;
|
||||
coordinate_type* P = new coordinate_type[src.size()*2];
|
||||
|
||||
int i;
|
||||
for (i=0; i<(int)src.size(); ++i)
|
||||
{
|
||||
points[i] = &P[2*i];
|
||||
points[i][0] = src[i].x;
|
||||
points[i][1] = src[i].y;
|
||||
}
|
||||
|
||||
coordinate_type* start = points[0];
|
||||
int m = _ch2d( points, src.size() );
|
||||
idx.resize(m);
|
||||
|
||||
for (i=0; i<m; ++i)
|
||||
{
|
||||
idx[i] = (points[i] - start)/2;
|
||||
}
|
||||
delete [] points;
|
||||
delete [] P;
|
||||
}
|
||||
|
||||
unsigned Qwt3D::tesselationSize(CellField const& t)
|
||||
{
|
||||
unsigned ret = 0;
|
||||
|
||||
for (unsigned i=0; i!=t.size(); ++i)
|
||||
ret += t[i].size();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif // QWT3D_NOT_FOR_DOXYGEN
|