docs: vendor OpenCPN audit source baseline
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
# 外部参考
|
# 外部参考
|
||||||
|
|
||||||
本项目独立实现 CM93 importer,不复制 OpenCPN GPL 源码。
|
本项目独立实现 CM93 importer;为保证 S-52 / CM93 对照审计可在不同机器复现,仓库内另行保存一份只读 OpenCPN GPL 上游源码快照,作为外部参考资料,不与 CM95 自有实现混合。
|
||||||
|
|
||||||
|
固定参考快照:`docs/外部参考/OpenCPN源码基线_f7211b4e/`,上游 commit 为 `f7211b4e1874c453e37a7f190aa191c55a25c32e`,目录内保留原始版权声明、GPL 许可证和 SHA-256 校验清单。
|
||||||
|
|
||||||
用于核对行为和 MySQL 兼容性的公开参考:
|
用于核对行为和 MySQL 兼容性的公开参考:
|
||||||
|
|
||||||
|
|||||||
1
docs/外部参考/OpenCPN源码基线_f7211b4e/上游提交.txt
Normal file
1
docs/外部参考/OpenCPN源码基线_f7211b4e/上游提交.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
f7211b4e1874c453e37a7f190aa191c55a25c32e
|
||||||
6527
docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/gui/src/cm93.cpp
Normal file
6527
docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/gui/src/cm93.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,305 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
*
|
||||||
|
* Project: OpenCPN
|
||||||
|
*
|
||||||
|
***************************************************************************
|
||||||
|
* Copyright (C) 2017 by David S. Register *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 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 the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include "Cs52_shaders.h"
|
||||||
|
|
||||||
|
#if defined(USE_ANDROID_GLES2) || defined(ocpnUSE_GLSL)
|
||||||
|
|
||||||
|
#ifdef USE_ANDROID_GLES2
|
||||||
|
#include <GLES2/gl2.h>
|
||||||
|
#include "qdebug.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_ANDROID_GLES2
|
||||||
|
const GLchar* Cpreamble =
|
||||||
|
"\n";
|
||||||
|
#else
|
||||||
|
const GLchar* Cpreamble =
|
||||||
|
"#version 120\n"
|
||||||
|
"#define precision\n"
|
||||||
|
"#define lowp\n"
|
||||||
|
"#define mediump\n"
|
||||||
|
"#define highp\n";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// Simple colored triangle shader
|
||||||
|
|
||||||
|
static const GLchar* xcolor_tri_vertex_shader_source =
|
||||||
|
"attribute vec2 position;\n"
|
||||||
|
"uniform mat4 MVMatrix;\n"
|
||||||
|
"uniform mat4 TransformMatrix;\n"
|
||||||
|
"uniform vec4 color;\n"
|
||||||
|
"varying vec4 fragColor;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" fragColor = color;\n"
|
||||||
|
" gl_Position = MVMatrix * TransformMatrix * vec4(position, 0.0, 1.0);\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
static const GLchar* xcolor_tri_fragment_shader_source =
|
||||||
|
"precision lowp float;\n"
|
||||||
|
"varying vec4 fragColor;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" gl_FragColor = fragColor;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
// Simple 2D texture shader
|
||||||
|
static const GLchar* xtexture_2D_vertex_shader_source =
|
||||||
|
"attribute vec2 position;\n"
|
||||||
|
"attribute vec2 aUV;\n"
|
||||||
|
"uniform mat4 MVMatrix;\n"
|
||||||
|
"uniform mat4 TransformMatrix;\n"
|
||||||
|
"varying vec2 varCoord;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" gl_Position = MVMatrix * TransformMatrix * vec4(position, 0.0, 1.0);\n"
|
||||||
|
" varCoord = aUV;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
static const GLchar* xtexture_2D_fragment_shader_source =
|
||||||
|
"precision lowp float;\n"
|
||||||
|
"uniform sampler2D uTex;\n"
|
||||||
|
"varying vec2 varCoord;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" gl_FragColor = texture2D(uTex, varCoord);\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
// 2D texture shader with color modulation, used for colored text
|
||||||
|
static const GLchar * xtexture_2D_ColorMod_vertex_shader_source =
|
||||||
|
"precision highp float;\n"
|
||||||
|
"attribute vec2 position;\n"
|
||||||
|
"attribute vec2 aUV;\n"
|
||||||
|
"uniform mat4 MVMatrix;\n"
|
||||||
|
"uniform mat4 TransformMatrix;\n"
|
||||||
|
"varying vec2 varCoord;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" gl_Position = MVMatrix * TransformMatrix * vec4(position, 0.0, 1.0);\n"
|
||||||
|
" varCoord = aUV;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
static const GLchar * xtexture_2D_ColorMod_fragment_shader_source =
|
||||||
|
"precision highp float;\n"
|
||||||
|
"uniform sampler2D uTex;\n"
|
||||||
|
"uniform vec4 color;\n"
|
||||||
|
"varying vec2 varCoord;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" vec4 col=texture2D(uTex, varCoord);\n"
|
||||||
|
" gl_FragColor = color;\n"
|
||||||
|
" gl_FragColor.a = col.a;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
// Circle shader
|
||||||
|
|
||||||
|
static const GLchar* xcircle_filled_vertex_shader_source =
|
||||||
|
"precision highp float;\n"
|
||||||
|
"attribute vec2 aPos;\n"
|
||||||
|
"uniform mat4 MVMatrix;\n"
|
||||||
|
"uniform mat4 TransformMatrix;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" gl_Position = MVMatrix * TransformMatrix * vec4(aPos, 0.0, 1.0);\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
static const GLchar* xcircle_filled_fragment_shader_source =
|
||||||
|
"precision highp float;\n"
|
||||||
|
"uniform float border_width;\n"
|
||||||
|
"uniform float circle_radius;\n"
|
||||||
|
"uniform vec4 circle_color;\n"
|
||||||
|
"uniform vec4 border_color;\n"
|
||||||
|
"uniform vec2 circle_center;\n"
|
||||||
|
"void main(){\n"
|
||||||
|
"float d = distance(gl_FragCoord.xy, circle_center);\n"
|
||||||
|
"if (d < (circle_radius - border_width)) { gl_FragColor = circle_color; }\n"
|
||||||
|
"else if (d < circle_radius) { gl_FragColor = border_color; }\n"
|
||||||
|
"else { gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); }\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
// Alpha 2D texture shader
|
||||||
|
static const GLchar* xtexture_2DA_vertex_shader_source =
|
||||||
|
"attribute vec2 position;\n"
|
||||||
|
"attribute vec2 aUV;\n"
|
||||||
|
"uniform mat4 MVMatrix;\n"
|
||||||
|
"uniform mat4 TransformMatrix;\n"
|
||||||
|
"varying vec2 varCoord;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" gl_Position = MVMatrix * TransformMatrix * vec4(position, 0.0, 1.0);\n"
|
||||||
|
" varCoord = aUV;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
static const GLchar* xtexture_2DA_fragment_shader_source =
|
||||||
|
"precision lowp float;\n"
|
||||||
|
"uniform sampler2D uTex;\n"
|
||||||
|
"varying vec2 varCoord;\n"
|
||||||
|
"uniform vec4 color;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" gl_FragColor = texture2D(uTex, varCoord) + color;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
|
||||||
|
//https://vitaliburkov.wordpress.com/2016/09/17/simple-and-fast-high-quality-antialiased-lines-with-opengl/
|
||||||
|
static const GLchar* xAALine_vertex_shader_source =
|
||||||
|
"uniform vec2 uViewPort; //Width and Height of the viewport\n"
|
||||||
|
"varying vec2 vLineCenter;\n"
|
||||||
|
"attribute vec2 position;\n"
|
||||||
|
"uniform mat4 MVMatrix;\n"
|
||||||
|
"uniform mat4 TransformMatrix;\n"
|
||||||
|
"void main()\n"
|
||||||
|
"{\n"
|
||||||
|
" vec4 pp = MVMatrix * vec4(position, 0.0, 1.0);\n"
|
||||||
|
" gl_Position = pp;\n"
|
||||||
|
" vec2 vp = uViewPort;\n"
|
||||||
|
" vLineCenter = 0.5*(pp.xy + vec2(1, 1))*vp;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
|
||||||
|
static const GLchar* xAALine_fragment_shader_source =
|
||||||
|
"precision mediump float;\n"
|
||||||
|
"uniform float uLineWidth;\n"
|
||||||
|
"uniform vec4 color;\n"
|
||||||
|
"uniform float uBlendFactor; //1.5..2.5\n"
|
||||||
|
"varying vec2 vLineCenter;\n"
|
||||||
|
"void main()\n"
|
||||||
|
"{\n"
|
||||||
|
" vec4 col = color;\n"
|
||||||
|
" float d = length(vLineCenter-gl_FragCoord.xy);\n"
|
||||||
|
" float w = uLineWidth;\n"
|
||||||
|
" if (d>w)\n"
|
||||||
|
" col.w = 0.0;\n"
|
||||||
|
" else{\n"
|
||||||
|
" if(float((w/2-d)/(w/2)) < .5){\n"
|
||||||
|
" //col.w *= pow(float((w-d)/w), uBlendFactor);\n"
|
||||||
|
" col.w *= pow(float((w/2-d)/(w/2)), uBlendFactor);\n"
|
||||||
|
" }\n"
|
||||||
|
" }\n"
|
||||||
|
" gl_FragColor = col;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
|
||||||
|
CGLShaderProgram *pCAALine_shader_program[2];
|
||||||
|
CGLShaderProgram *pCcolor_tri_shader_program[2];
|
||||||
|
CGLShaderProgram *pCtexture_2D_shader_program[2];
|
||||||
|
CGLShaderProgram *pCcircle_filled_shader_program[2];
|
||||||
|
CGLShaderProgram *pCtexture_2DA_shader_program[2];
|
||||||
|
CGLShaderProgram *pCtexture_2D_Color_shader_program[2];
|
||||||
|
|
||||||
|
bool bCShadersLoaded[2];
|
||||||
|
|
||||||
|
bool loadCShaders(int index) {
|
||||||
|
// Are the shaders ready?
|
||||||
|
if (bCShadersLoaded[index]) {
|
||||||
|
reConfigureCShaders(index);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ret_val = true;
|
||||||
|
|
||||||
|
// Simple colored triangle shader
|
||||||
|
if (!pCcolor_tri_shader_program[index]) {
|
||||||
|
CGLShaderProgram *shaderProgram = new CGLShaderProgram;
|
||||||
|
shaderProgram->addShaderFromSource(xcolor_tri_vertex_shader_source, GL_VERTEX_SHADER);
|
||||||
|
shaderProgram->addShaderFromSource(xcolor_tri_fragment_shader_source, GL_FRAGMENT_SHADER);
|
||||||
|
shaderProgram->linkProgram();
|
||||||
|
|
||||||
|
if (shaderProgram->isOK())
|
||||||
|
pCcolor_tri_shader_program[index] = shaderProgram;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pCtexture_2D_shader_program[index]) {
|
||||||
|
CGLShaderProgram *shaderProgram = new CGLShaderProgram;
|
||||||
|
shaderProgram->addShaderFromSource(xtexture_2D_vertex_shader_source, GL_VERTEX_SHADER);
|
||||||
|
shaderProgram->addShaderFromSource(xtexture_2D_fragment_shader_source, GL_FRAGMENT_SHADER);
|
||||||
|
shaderProgram->linkProgram();
|
||||||
|
|
||||||
|
if (shaderProgram->isOK())
|
||||||
|
pCtexture_2D_shader_program[index] = shaderProgram;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pCtexture_2D_Color_shader_program[index]) {
|
||||||
|
CGLShaderProgram *shaderProgram = new CGLShaderProgram;
|
||||||
|
shaderProgram->addShaderFromSource(xtexture_2D_ColorMod_vertex_shader_source, GL_VERTEX_SHADER);
|
||||||
|
shaderProgram->addShaderFromSource(xtexture_2D_ColorMod_fragment_shader_source, GL_FRAGMENT_SHADER);
|
||||||
|
shaderProgram->linkProgram();
|
||||||
|
|
||||||
|
if (shaderProgram->isOK())
|
||||||
|
pCtexture_2D_Color_shader_program[index] = shaderProgram;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
|
if (!pcircle_filled_shader_program[index]) {
|
||||||
|
GLShaderProgram *shaderProgram = new GLShaderProgram;
|
||||||
|
shaderProgram->addShaderFromSource(circle_filled_vertex_shader_source, GL_VERTEX_SHADER);
|
||||||
|
shaderProgram->addShaderFromSource(circle_filled_fragment_shader_source, GL_FRAGMENT_SHADER);
|
||||||
|
shaderProgram->linkProgram();
|
||||||
|
|
||||||
|
if (shaderProgram->isOK())
|
||||||
|
pcircle_filled_shader_program[index] = shaderProgram;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ptexture_2DA_shader_program[index]) {
|
||||||
|
GLShaderProgram *shaderProgram = new GLShaderProgram;
|
||||||
|
shaderProgram->addShaderFromSource(texture_2DA_vertex_shader_source, GL_VERTEX_SHADER);
|
||||||
|
shaderProgram->addShaderFromSource(texture_2DA_fragment_shader_source, GL_FRAGMENT_SHADER);
|
||||||
|
shaderProgram->linkProgram();
|
||||||
|
|
||||||
|
if (shaderProgram->isOK())
|
||||||
|
ptexture_2DA_shader_program[index] = shaderProgram;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pAALine_shader_program[index]) {
|
||||||
|
GLShaderProgram *shaderProgram = new GLShaderProgram;
|
||||||
|
shaderProgram->addShaderFromSource(AALine_fragment_shader_source, GL_FRAGMENT_SHADER);
|
||||||
|
shaderProgram->addShaderFromSource(AALine_vertex_shader_source, GL_VERTEX_SHADER);
|
||||||
|
shaderProgram->linkProgram();
|
||||||
|
|
||||||
|
if (shaderProgram->isOK())
|
||||||
|
pAALine_shader_program[index] = shaderProgram;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bCShadersLoaded[index] = true;
|
||||||
|
reConfigureCShaders(index);
|
||||||
|
|
||||||
|
return ret_val;
|
||||||
|
}
|
||||||
|
|
||||||
|
void reConfigureCShaders(int index) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void unloadCShaders() {
|
||||||
|
bCShadersLoaded[0] = bCShadersLoaded[1] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGLShaderProgram *CGetStaticTriShader() {
|
||||||
|
CGLShaderProgram *shaderProgram = new CGLShaderProgram;
|
||||||
|
shaderProgram->addShaderFromSource(xcolor_tri_vertex_shader_source, GL_VERTEX_SHADER);
|
||||||
|
shaderProgram->addShaderFromSource(xcolor_tri_fragment_shader_source, GL_FRAGMENT_SHADER);
|
||||||
|
shaderProgram->linkProgram();
|
||||||
|
|
||||||
|
if (shaderProgram->isOK())
|
||||||
|
return shaderProgram;
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,186 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
*
|
||||||
|
* Project: OpenCPN
|
||||||
|
*
|
||||||
|
***************************************************************************
|
||||||
|
* Copyright (C) 2017 by David S. Register *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 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 the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __XSHADERS_H__
|
||||||
|
#define __XSHADERS_H__
|
||||||
|
|
||||||
|
#include <wx/wxprec.h>
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#endif // precompiled headers
|
||||||
|
|
||||||
|
#include "s52plibGL.h"
|
||||||
|
|
||||||
|
#ifdef __OCPN__ANDROID__
|
||||||
|
#include "qdebug.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
#include <fstream>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
class CGLShaderProgram;
|
||||||
|
|
||||||
|
extern CGLShaderProgram *pAALine_shader_program[2];
|
||||||
|
extern CGLShaderProgram *pCcolor_tri_shader_program[2];
|
||||||
|
extern CGLShaderProgram *pCtexture_2D_shader_program[2];
|
||||||
|
extern CGLShaderProgram *pcircle_filled_shader_program[2];
|
||||||
|
extern CGLShaderProgram *ptexture_2DA_shader_program[2];
|
||||||
|
extern CGLShaderProgram *pCtexture_2D_Color_shader_program[2];
|
||||||
|
|
||||||
|
extern const GLchar* Cpreamble;
|
||||||
|
|
||||||
|
class CGLShaderProgram
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CGLShaderProgram() : programId_(0), linked_(false) {
|
||||||
|
programId_ = glCreateProgram();
|
||||||
|
}
|
||||||
|
~CGLShaderProgram() { }
|
||||||
|
|
||||||
|
bool addShaderFromSource(std::string const &shaderSource, GLenum shaderType) {
|
||||||
|
char const *shaderCStr = shaderSource.c_str();
|
||||||
|
GLuint shaderId = glCreateShader(shaderType);
|
||||||
|
|
||||||
|
GLchar const* files[] = { Cpreamble, shaderCStr };
|
||||||
|
GLint lengths[] = { (GLint)strlen(Cpreamble), (GLint)strlen(shaderCStr) };
|
||||||
|
|
||||||
|
glShaderSource(shaderId, 2, files, lengths);
|
||||||
|
|
||||||
|
glCompileShader(shaderId);
|
||||||
|
glGetShaderiv(shaderId, GL_COMPILE_STATUS, &success);
|
||||||
|
if (!success) {
|
||||||
|
GLint logLength = 0;
|
||||||
|
glGetShaderiv(shaderId, GL_INFO_LOG_LENGTH, &logLength);
|
||||||
|
if (logLength > 0) {
|
||||||
|
auto log = std::unique_ptr<char[]>(new char[logLength]);
|
||||||
|
glGetShaderInfoLog(shaderId, logLength, &logLength, log.get());
|
||||||
|
printf("ERROR::SHADER::COMPILATION_FAILED\n%s\n", log.get());
|
||||||
|
#ifdef USE_ANDROID_GLES2
|
||||||
|
qDebug() << "SHADER COMPILE ERROR " << log.get();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
glAttachShader(programId_, shaderId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool linkProgram() {
|
||||||
|
glLinkProgram(programId_);
|
||||||
|
glGetProgramiv( programId_, GL_LINK_STATUS, &linkSuccess); //requesting the status
|
||||||
|
if (linkSuccess == GL_FALSE) {
|
||||||
|
GLint logLength = 0;
|
||||||
|
glGetShaderiv(programId_, GL_INFO_LOG_LENGTH, &logLength);
|
||||||
|
if (logLength > 0) {
|
||||||
|
auto log = std::unique_ptr<char[]>(new char[logLength]);
|
||||||
|
glGetShaderInfoLog(programId_, logLength, &logLength, log.get());
|
||||||
|
printf("ERROR::SHADER::LINK_FAILED\n%s\n", log.get());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
linked_ = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Bind() { glUseProgram(programId_); }
|
||||||
|
void UnBind() {
|
||||||
|
glDisableVertexAttribArray(0);
|
||||||
|
glUseProgram(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetUniform1f( const std::string &name, float value) {
|
||||||
|
GLint loc = getUniformLocation(name);
|
||||||
|
glUniform1f( loc, value);
|
||||||
|
}
|
||||||
|
void SetUniform2fv( const std::string &name, float *value) {
|
||||||
|
GLint loc = getUniformLocation(name);
|
||||||
|
glUniform2fv( loc, 1, value);
|
||||||
|
}
|
||||||
|
void SetUniform4fv( const std::string &name, float *value) {
|
||||||
|
GLint loc = getUniformLocation(name);
|
||||||
|
glUniform4fv( loc, 1, value);
|
||||||
|
}
|
||||||
|
void SetUniform1i( const std::string &name, GLint value) {
|
||||||
|
GLint loc = getUniformLocation(name);
|
||||||
|
glUniform1i( loc, value);
|
||||||
|
}
|
||||||
|
void SetUniformMatrix4fv( const std::string &name, float *value) {
|
||||||
|
GLint matloc = getUniformLocation(name);
|
||||||
|
glUniformMatrix4fv(matloc, 1, GL_FALSE, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetAttributePointerf( const std::string &name, float *value ){
|
||||||
|
GLint aloc = getAttributeLocation( name);
|
||||||
|
glVertexAttribPointer(aloc, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), value);
|
||||||
|
glEnableVertexAttribArray(aloc);
|
||||||
|
|
||||||
|
// Disable VBO's (vertex buffer objects) for attributes.
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
GLint getAttributeLocation(const std::string &name) {
|
||||||
|
if(m_attribLocationCache.find(name) != m_attribLocationCache.end())
|
||||||
|
return m_attribLocationCache[name];
|
||||||
|
|
||||||
|
GLint loc = glGetAttribLocation(programId_, name.c_str());
|
||||||
|
m_attribLocationCache[name] = loc;
|
||||||
|
return loc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GLuint programId() const { return programId_; }
|
||||||
|
bool isOK() const { return linked_; }
|
||||||
|
|
||||||
|
GLint getUniformLocation(const std::string &name) {
|
||||||
|
if(m_uniformLocationCache.find(name) != m_uniformLocationCache.end())
|
||||||
|
return m_uniformLocationCache[name];
|
||||||
|
|
||||||
|
GLint loc = glGetUniformLocation(programId_, name.c_str());
|
||||||
|
m_uniformLocationCache[name] = loc;
|
||||||
|
return loc;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unordered_map<std::string, GLint> m_uniformLocationCache;
|
||||||
|
std::unordered_map<std::string, GLint> m_attribLocationCache;
|
||||||
|
GLuint programId_;
|
||||||
|
bool linked_;
|
||||||
|
GLint success;
|
||||||
|
GLint linkSuccess;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
bool loadCShaders(int index = 0);
|
||||||
|
void reConfigureCShaders(int index = 0);
|
||||||
|
void unloadCShaders();
|
||||||
|
|
||||||
|
CGLShaderProgram *CGetStaticTriShader();
|
||||||
|
#endif
|
||||||
179
docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/DepthFont.cpp
Executable file
179
docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/DepthFont.cpp
Executable file
@@ -0,0 +1,179 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
*
|
||||||
|
* Project: OpenCPN
|
||||||
|
* Purpose: texture OpenGL text rendering built from wxFont
|
||||||
|
* Author: Sean D'Epagnier
|
||||||
|
*
|
||||||
|
***************************************************************************
|
||||||
|
* Copyright (C) 2014 Sean D'Epagnier *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 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 the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
|
||||||
|
#include "s52plibGL.h"
|
||||||
|
|
||||||
|
#include "DepthFont.h"
|
||||||
|
#include "s52_plib_utils.h"
|
||||||
|
|
||||||
|
DepthFont::DepthFont() {
|
||||||
|
texobj = 0;
|
||||||
|
m_built = false;
|
||||||
|
m_scaleFactor = 0;
|
||||||
|
m_ContentScaleFactor = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
DepthFont::~DepthFont() { Delete(); }
|
||||||
|
|
||||||
|
void DepthFont::Build(wxFont *font, double scale, double dip_factor) {
|
||||||
|
/* avoid rebuilding if the parameters are the same */
|
||||||
|
if (m_built && (*font == m_font)) return;
|
||||||
|
|
||||||
|
m_font = *font;
|
||||||
|
m_scaleFactor = scale;
|
||||||
|
m_dip_factor = dip_factor;
|
||||||
|
|
||||||
|
m_maxglyphw = 0;
|
||||||
|
m_maxglyphh = 0;
|
||||||
|
|
||||||
|
double scaler = m_ContentScaleFactor * dip_factor;
|
||||||
|
|
||||||
|
wxFont *scaled_font = GetS52Utils()->GetFont(font, scaler);
|
||||||
|
wxScreenDC sdc;
|
||||||
|
sdc.SetFont(*scaled_font);
|
||||||
|
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
wxCoord gw, gh;
|
||||||
|
wxString text;
|
||||||
|
text = wxString::Format(_T("%d"), i);
|
||||||
|
wxCoord descent, exlead;
|
||||||
|
sdc.GetTextExtent(text, &gw, &gh, &descent, &exlead,
|
||||||
|
scaled_font); // measure the text
|
||||||
|
|
||||||
|
tgi[i].width = gw;
|
||||||
|
tgi[i].height = gh; // - descent;
|
||||||
|
|
||||||
|
tgi[i].advance = gw;
|
||||||
|
tgi[i].advance *= dip_factor;
|
||||||
|
if (i == 1)
|
||||||
|
m_width_one = gw;
|
||||||
|
|
||||||
|
m_maxglyphw = wxMax(tgi[i].width + tgi[i].advance, m_maxglyphw);
|
||||||
|
m_maxglyphh = wxMax(tgi[i].height, m_maxglyphh);
|
||||||
|
}
|
||||||
|
|
||||||
|
int w = 10 * m_maxglyphw;
|
||||||
|
int h = m_maxglyphh;
|
||||||
|
|
||||||
|
/* make power of 2 */
|
||||||
|
|
||||||
|
for (tex_w = 1; tex_w < w; tex_w *= 2)
|
||||||
|
;
|
||||||
|
for (tex_h = 1; tex_h < h; tex_h *= 2)
|
||||||
|
;
|
||||||
|
|
||||||
|
wxBitmap tbmp(tex_w, tex_h);
|
||||||
|
wxMemoryDC dc;
|
||||||
|
dc.SelectObject(tbmp);
|
||||||
|
dc.SetFont(*scaled_font);
|
||||||
|
|
||||||
|
/* fill bitmap with black */
|
||||||
|
dc.SetBackground(wxBrush(wxColour(0, 0, 0)));
|
||||||
|
dc.Clear();
|
||||||
|
|
||||||
|
/* draw the text white */
|
||||||
|
dc.SetTextForeground(wxColour(255, 255, 255));
|
||||||
|
|
||||||
|
/* wxPen pen(wxColour( 255, 255, 255 ));
|
||||||
|
wxBrush brush(wxColour( 255, 255, 255 ), wxTRANSPARENT);
|
||||||
|
dc.SetPen(pen);
|
||||||
|
dc.SetBrush(brush);
|
||||||
|
*/
|
||||||
|
int row = 0, col = 0;
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
tgi[i].x = col * m_maxglyphw;
|
||||||
|
tgi[i].y = row * m_maxglyphh;
|
||||||
|
|
||||||
|
wxString text;
|
||||||
|
text = wxString::Format(_T("%d"), i);
|
||||||
|
|
||||||
|
dc.DrawText(text, tgi[i].x, tgi[i].y);
|
||||||
|
|
||||||
|
col++;
|
||||||
|
}
|
||||||
|
|
||||||
|
dc.SelectObject(wxNullBitmap);
|
||||||
|
|
||||||
|
wxImage image = tbmp.ConvertToImage();
|
||||||
|
|
||||||
|
GLuint format, internalformat;
|
||||||
|
int stride;
|
||||||
|
|
||||||
|
format = GL_ALPHA;
|
||||||
|
internalformat = format;
|
||||||
|
stride = 1;
|
||||||
|
|
||||||
|
unsigned char *imgdata = image.GetData();
|
||||||
|
|
||||||
|
if (imgdata) {
|
||||||
|
unsigned char *teximage = (unsigned char *)malloc(stride * tex_w * tex_h);
|
||||||
|
|
||||||
|
for (int j = 0; j < tex_w * tex_h; j++)
|
||||||
|
for (int k = 0; k < stride; k++)
|
||||||
|
teximage[j * stride + k] = imgdata[3 * j];
|
||||||
|
|
||||||
|
glGenTextures(1, &texobj);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, texobj);
|
||||||
|
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, internalformat, tex_w, tex_h, 0, format,
|
||||||
|
GL_UNSIGNED_BYTE, teximage);
|
||||||
|
|
||||||
|
free(teximage);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_built = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthFont::Delete() {
|
||||||
|
if (texobj) {
|
||||||
|
glDeleteTextures(1, &texobj);
|
||||||
|
texobj = 0;
|
||||||
|
}
|
||||||
|
m_built = false;
|
||||||
|
m_scaleFactor = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DepthFont::GetGLTextureRect(wxRect &texrect, int symIndex) {
|
||||||
|
if (symIndex < 10) {
|
||||||
|
texrect.x = tgi[symIndex].x;
|
||||||
|
texrect.y = tgi[symIndex].y;
|
||||||
|
texrect.width = tgi[symIndex].width + (m_width_one / 10);
|
||||||
|
texrect.height = tgi[symIndex].height;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
texrect.x = tgi[0].x;
|
||||||
|
texrect.y = tgi[0].y;
|
||||||
|
texrect.width = tgi[0].width;
|
||||||
|
texrect.height = tgi[0].height;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
*
|
||||||
|
* Project: OpenCPN
|
||||||
|
* Purpose: OpenGL text rendering
|
||||||
|
* Author: David Register, Sean D'Epagnier
|
||||||
|
*
|
||||||
|
***************************************************************************
|
||||||
|
* Copyright (C) 2020 David Register *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 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 the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __DEPTHFONT_H__
|
||||||
|
#define __DEPTHFONT_H__
|
||||||
|
|
||||||
|
#include <wx/font.h>
|
||||||
|
|
||||||
|
#define SOUND_MAX_GLYPH 50
|
||||||
|
|
||||||
|
struct SoundTexGlyphInfo {
|
||||||
|
int x, y, width, height;
|
||||||
|
float advance;
|
||||||
|
};
|
||||||
|
|
||||||
|
class DepthFont {
|
||||||
|
public:
|
||||||
|
DepthFont();
|
||||||
|
~DepthFont();
|
||||||
|
|
||||||
|
void Build(wxFont *font, double scale, double dip_factor = 1.0);
|
||||||
|
void Delete();
|
||||||
|
|
||||||
|
bool IsBuilt() { return m_built; }
|
||||||
|
unsigned int GetTexture() { return texobj; }
|
||||||
|
bool GetGLTextureRect(wxRect &texrect, int symIndex);
|
||||||
|
wxSize GLTextureSize() { return wxSize(tex_w, tex_h); };
|
||||||
|
double GetScale() { return m_scaleFactor; }
|
||||||
|
void SetContentScaleFactor(double s){m_ContentScaleFactor = s;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxFont m_font;
|
||||||
|
|
||||||
|
SoundTexGlyphInfo tgi[SOUND_MAX_GLYPH];
|
||||||
|
|
||||||
|
unsigned int texobj;
|
||||||
|
int tex_w, tex_h;
|
||||||
|
int m_maxglyphw;
|
||||||
|
int m_maxglyphh;
|
||||||
|
bool m_built;
|
||||||
|
|
||||||
|
float m_dx;
|
||||||
|
float m_dy;
|
||||||
|
double m_scaleFactor;
|
||||||
|
double m_ContentScaleFactor;
|
||||||
|
int m_width_one;
|
||||||
|
double m_dip_factor;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
542
docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/TexFont.cpp
Executable file
542
docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/TexFont.cpp
Executable file
@@ -0,0 +1,542 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
*
|
||||||
|
* Project: OpenCPN
|
||||||
|
* Purpose: texture OpenGL text rendering built from wxFont
|
||||||
|
* Author: Sean D'Epagnier
|
||||||
|
*
|
||||||
|
***************************************************************************
|
||||||
|
* Copyright (C) 2014 Sean D'Epagnier *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 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 the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
|
||||||
|
#ifdef ocpnUSE_GL
|
||||||
|
#ifdef __OCPN_USE_GLEW__
|
||||||
|
#ifndef __OCPN__ANDROID__
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#include "glew.h"
|
||||||
|
#elif defined(__WXQT__) || defined(__WXGTK__)
|
||||||
|
#include <GL/glew.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__OCPN__ANDROID__)
|
||||||
|
#include <qopengl.h>
|
||||||
|
#include <GL/gl_private.h> // this is a cut-down version of gl.h
|
||||||
|
#include <GLES2/gl2.h>
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
#define GL_GLEXT_PROTOTYPES
|
||||||
|
#include <GL/gl.h>
|
||||||
|
#include <GL/glu.h>
|
||||||
|
//typedef void (__stdcall * _GLUfuncptr)(void);
|
||||||
|
#elif defined(__WXOSX__)
|
||||||
|
#include <OpenGL/gl.h>
|
||||||
|
#include <OpenGL/glu.h>
|
||||||
|
typedef void (* _GLUfuncptr)();
|
||||||
|
#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0
|
||||||
|
#elif defined(__WXQT__) || defined(__WXGTK__)
|
||||||
|
#define GL_GLEXT_PROTOTYPES
|
||||||
|
#include <GL/glu.h>
|
||||||
|
#include <GL/gl.h>
|
||||||
|
#include <GL/glx.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "TexFont.h"
|
||||||
|
#include "linmath.h"
|
||||||
|
#ifdef ocpnUSE_GL
|
||||||
|
#include "Cs52_shaders.h"
|
||||||
|
|
||||||
|
CGLShaderProgram *m_TexFontShader;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "s52_plib_utils.h"
|
||||||
|
|
||||||
|
TexFont::TexFont() {
|
||||||
|
texobj = 0;
|
||||||
|
m_blur = false;
|
||||||
|
m_built = false;
|
||||||
|
m_color = wxColor(0, 0, 0);
|
||||||
|
m_angle = 0;
|
||||||
|
m_ContentScaleFactor = 1.0;
|
||||||
|
|
||||||
|
m_shadersLoaded = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TexFont::~TexFont() { Delete(); }
|
||||||
|
|
||||||
|
void TexFont::Build(wxFont &font, double scale_factor, double dpi_factor, bool blur) {
|
||||||
|
/* avoid rebuilding if the parameters are the same */
|
||||||
|
if (m_built && (font == m_font) && (blur == m_blur)) return;
|
||||||
|
|
||||||
|
m_font = font;
|
||||||
|
m_blur = blur;
|
||||||
|
|
||||||
|
m_maxglyphw = 0;
|
||||||
|
m_maxglyphh = 0;
|
||||||
|
|
||||||
|
double scaler = scale_factor / dpi_factor;
|
||||||
|
scaler /= m_ContentScaleFactor;
|
||||||
|
|
||||||
|
wxFont *scaled_font = GetS52Utils()->GetFont(&font, scaler);
|
||||||
|
wxScreenDC sdc;
|
||||||
|
sdc.SetFont(*scaled_font);
|
||||||
|
|
||||||
|
for (int i = MIN_GLYPH; i < MAX_GLYPH; i++) {
|
||||||
|
wxCoord gw, gh;
|
||||||
|
wxString text;
|
||||||
|
if (i == DEGREE_GLYPH)
|
||||||
|
text = wxString::Format(_T("%c"), 0x00B0); //_T("?");
|
||||||
|
else
|
||||||
|
text = wxString::Format(_T("%c"), i);
|
||||||
|
wxCoord descent, exlead;
|
||||||
|
sdc.GetTextExtent(text, &gw, &gh, &descent, &exlead,
|
||||||
|
scaled_font); // measure the text
|
||||||
|
|
||||||
|
tgi[i].width = gw;
|
||||||
|
tgi[i].height = gh;
|
||||||
|
|
||||||
|
tgi[i].advance = gw;
|
||||||
|
tgi[i].advance *= dpi_factor;
|
||||||
|
|
||||||
|
|
||||||
|
m_maxglyphw = wxMax(tgi[i].width, m_maxglyphw);
|
||||||
|
m_maxglyphh = wxMax(tgi[i].height, m_maxglyphh);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* add extra pixel to give a border between rows of characters
|
||||||
|
without this, in some cases a faint line can be see on the edge
|
||||||
|
from the character above */
|
||||||
|
m_maxglyphh++;
|
||||||
|
|
||||||
|
int w = COLS_GLYPHS * m_maxglyphw;
|
||||||
|
int h = ROWS_GLYPHS * m_maxglyphh;
|
||||||
|
|
||||||
|
wxASSERT(w < 2048 && h < 2048);
|
||||||
|
|
||||||
|
/* make power of 2 */
|
||||||
|
for (tex_w = 1; tex_w < w; tex_w *= 2)
|
||||||
|
;
|
||||||
|
for (tex_h = 1; tex_h < h; tex_h *= 2)
|
||||||
|
;
|
||||||
|
|
||||||
|
wxBitmap tbmp(tex_w, tex_h);
|
||||||
|
wxMemoryDC dc;
|
||||||
|
dc.SelectObject(tbmp);
|
||||||
|
dc.SetFont(*scaled_font);
|
||||||
|
|
||||||
|
/* fill bitmap with black */
|
||||||
|
dc.SetBackground(wxBrush(wxColour(0, 0, 0)));
|
||||||
|
dc.Clear();
|
||||||
|
|
||||||
|
/* draw the text white */
|
||||||
|
dc.SetTextForeground(wxColour(255, 255, 255));
|
||||||
|
|
||||||
|
/* wxPen pen(wxColour( 255, 255, 255 ));
|
||||||
|
wxBrush brush(wxColour( 255, 255, 255 ), wxTRANSPARENT);
|
||||||
|
dc.SetPen(pen);
|
||||||
|
dc.SetBrush(brush);
|
||||||
|
*/
|
||||||
|
int row = 0, col = 0;
|
||||||
|
for (int i = MIN_GLYPH; i < MAX_GLYPH; i++) {
|
||||||
|
if (col == COLS_GLYPHS) {
|
||||||
|
col = 0;
|
||||||
|
row++;
|
||||||
|
}
|
||||||
|
|
||||||
|
tgi[i].x = col * m_maxglyphw;
|
||||||
|
tgi[i].y = row * m_maxglyphh;
|
||||||
|
|
||||||
|
wxString text;
|
||||||
|
if (i == DEGREE_GLYPH)
|
||||||
|
text = wxString::Format(_T("%c"), 0x00B0); //_T("?");
|
||||||
|
else
|
||||||
|
text = wxString::Format(_T("%c"), i);
|
||||||
|
|
||||||
|
dc.DrawText(text, tgi[i].x, tgi[i].y);
|
||||||
|
|
||||||
|
// dc.DrawRectangle(tgi[i].x, tgi[i].y, tgi[i].advance,
|
||||||
|
// tgi[i].height);
|
||||||
|
col++;
|
||||||
|
}
|
||||||
|
|
||||||
|
dc.SelectObject(wxNullBitmap);
|
||||||
|
|
||||||
|
wxImage image = tbmp.ConvertToImage();
|
||||||
|
|
||||||
|
unsigned int format = 0, internalformat = 0;
|
||||||
|
int stride;
|
||||||
|
|
||||||
|
#ifdef ocpnUSE_GL
|
||||||
|
format = GL_ALPHA;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
internalformat = format;
|
||||||
|
stride = 1;
|
||||||
|
|
||||||
|
if (m_blur) image = image.Blur(1);
|
||||||
|
|
||||||
|
unsigned char *imgdata = image.GetData();
|
||||||
|
|
||||||
|
if (imgdata) {
|
||||||
|
unsigned char *teximage = (unsigned char *)malloc(stride * tex_w * tex_h);
|
||||||
|
|
||||||
|
for (int j = 0; j < tex_w * tex_h; j++)
|
||||||
|
for (int k = 0; k < stride; k++)
|
||||||
|
teximage[j * stride + k] = imgdata[3 * j];
|
||||||
|
|
||||||
|
Delete();
|
||||||
|
|
||||||
|
#ifdef ocpnUSE_GL
|
||||||
|
glGenTextures(1, &texobj);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, texobj);
|
||||||
|
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
|
||||||
|
GL_NEAREST /*GL_LINEAR*/);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
|
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, internalformat, tex_w, tex_h, 0, format,
|
||||||
|
GL_UNSIGNED_BYTE, teximage);
|
||||||
|
#endif
|
||||||
|
free(teximage);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
m_built = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TexFont::Delete() {
|
||||||
|
if (texobj) {
|
||||||
|
#ifdef ocpnUSE_GL
|
||||||
|
glDeleteTextures(1, &texobj);
|
||||||
|
#endif
|
||||||
|
texobj = 0;
|
||||||
|
}
|
||||||
|
m_built = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TexFont::GetTextExtent(const char *string, int *width, int *height) {
|
||||||
|
int w = 0, h = 0;
|
||||||
|
|
||||||
|
for (int i = 0; string[i]; i++) {
|
||||||
|
unsigned char c = string[i];
|
||||||
|
if (c == '\n') {
|
||||||
|
h += tgi[(int)'A'].height;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (c == 0xc2 && (unsigned char)string[i + 1] == 0xb0) {
|
||||||
|
c = DEGREE_GLYPH;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (c < MIN_GLYPH || c >= MAX_GLYPH) continue;
|
||||||
|
|
||||||
|
TexGlyphInfo &tgisi = tgi[c];
|
||||||
|
w += tgisi.advance;
|
||||||
|
if (tgisi.height > h) h = tgisi.height;
|
||||||
|
}
|
||||||
|
if (width) *width = w;
|
||||||
|
if (height) *height = h;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TexFont::GetTextExtent(const wxString &string, int *width, int *height) {
|
||||||
|
GetTextExtent((const char *)string.ToUTF8(), width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TexFont::RenderGlyph(int c) {
|
||||||
|
#ifdef ocpnUSE_GL
|
||||||
|
if (c < MIN_GLYPH || c >= MAX_GLYPH) return;
|
||||||
|
|
||||||
|
TexGlyphInfo &tgic = tgi[c];
|
||||||
|
|
||||||
|
int x = tgic.x, y = tgic.y;
|
||||||
|
float w = m_maxglyphw, h = m_maxglyphh;
|
||||||
|
float tx1 = (float)x / (float)tex_w;
|
||||||
|
float tx2 = (float)(x + w) / (float)tex_w;
|
||||||
|
float ty1 = (float)y / (float)tex_h;
|
||||||
|
float ty2 = (float)(y + h) / (float)tex_h;
|
||||||
|
|
||||||
|
if(!m_TexFontShader)
|
||||||
|
return;
|
||||||
|
|
||||||
|
float uv[8];
|
||||||
|
float coords[8];
|
||||||
|
|
||||||
|
// normal uv
|
||||||
|
uv[0] = tx1;
|
||||||
|
uv[1] = ty1;
|
||||||
|
uv[2] = tx2;
|
||||||
|
uv[3] = ty1;
|
||||||
|
uv[4] = tx2;
|
||||||
|
uv[5] = ty2;
|
||||||
|
uv[6] = tx1;
|
||||||
|
uv[7] = ty2;
|
||||||
|
|
||||||
|
// pixels
|
||||||
|
coords[0] = 0;
|
||||||
|
coords[1] = 0;
|
||||||
|
coords[2] = w;
|
||||||
|
coords[3] = 0;
|
||||||
|
coords[4] = w;
|
||||||
|
coords[5] = h;
|
||||||
|
coords[6] = 0;
|
||||||
|
coords[7] = h;
|
||||||
|
|
||||||
|
m_TexFontShader->Bind();
|
||||||
|
|
||||||
|
// Set up the texture sampler to texture unit 0
|
||||||
|
m_TexFontShader->SetUniform1i( "uTex", 0);
|
||||||
|
|
||||||
|
float colorv[4];
|
||||||
|
colorv[0] = m_color.Red() / float(256);
|
||||||
|
colorv[1] = m_color.Green() / float(256);
|
||||||
|
colorv[2] = m_color.Blue() / float(256);
|
||||||
|
colorv[3] = 0;
|
||||||
|
|
||||||
|
m_TexFontShader->SetUniform4fv( "color", colorv);
|
||||||
|
|
||||||
|
// Rotate
|
||||||
|
//float angle = 0;
|
||||||
|
mat4x4 I, Q;
|
||||||
|
mat4x4_identity(I);
|
||||||
|
mat4x4_identity(Q);
|
||||||
|
//mat4x4_rotate_Z(Q, I, m_angle);
|
||||||
|
|
||||||
|
// Translate
|
||||||
|
Q[3][0] = m_dx; // - m_vpwidth/2; //m_dx;
|
||||||
|
Q[3][1] = m_dy;// - m_vpheight/2; //m_dy;
|
||||||
|
|
||||||
|
// mat4x4_translate_in_place(I, m_dx, m_dy, 0);
|
||||||
|
// mat4x4_rotate_Z(Q, I, m_angle);
|
||||||
|
//mat4x4_translate_in_place(Q, -m_dx, -m_dy, 0);
|
||||||
|
|
||||||
|
m_TexFontShader->SetUniformMatrix4fv( "TransformMatrix", (GLfloat *)Q);
|
||||||
|
|
||||||
|
// For some reason, glDrawElements is busted on Android
|
||||||
|
// So we do this a hard ugly way, drawing two triangles...
|
||||||
|
#if 0
|
||||||
|
GLushort indices1[] = {0,1,3,2};
|
||||||
|
glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_SHORT, indices1);
|
||||||
|
#else
|
||||||
|
|
||||||
|
float co1[8];
|
||||||
|
co1[0] = coords[0];
|
||||||
|
co1[1] = coords[1];
|
||||||
|
co1[2] = coords[2];
|
||||||
|
co1[3] = coords[3];
|
||||||
|
co1[4] = coords[6];
|
||||||
|
co1[5] = coords[7];
|
||||||
|
co1[6] = coords[4];
|
||||||
|
co1[7] = coords[5];
|
||||||
|
|
||||||
|
float tco1[8];
|
||||||
|
tco1[0] = uv[0];
|
||||||
|
tco1[1] = uv[1];
|
||||||
|
tco1[2] = uv[2];
|
||||||
|
tco1[3] = uv[3];
|
||||||
|
tco1[4] = uv[6];
|
||||||
|
tco1[5] = uv[7];
|
||||||
|
tco1[6] = uv[4];
|
||||||
|
tco1[7] = uv[5];
|
||||||
|
|
||||||
|
m_TexFontShader->SetAttributePointerf( "position", co1);
|
||||||
|
m_TexFontShader->SetAttributePointerf( "aUV", tco1);
|
||||||
|
|
||||||
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
|
||||||
|
m_TexFontShader->UnBind();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
m_dx += tgic.advance; // * cos(m_angle); // + tgic.advance * sin(m_angle);
|
||||||
|
//m_dy += tgic.advance * sin(m_angle); // - tgic.advance * cos(m_angle);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void TexFont::RenderString(const char *string, int x, int y, float angle) {
|
||||||
|
#ifdef ocpnUSE_GL
|
||||||
|
|
||||||
|
#if !defined(USE_ANDROID_GLES2) && !defined(ocpnUSE_GLSL)
|
||||||
|
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(x, y, 0);
|
||||||
|
|
||||||
|
glPushMatrix();
|
||||||
|
glBindTexture(GL_TEXTURE_2D, texobj);
|
||||||
|
|
||||||
|
for (int i = 0; string[i]; i++) {
|
||||||
|
if (string[i] == '\n') {
|
||||||
|
glPopMatrix();
|
||||||
|
glTranslatef(0, tgi[(int)'A'].height, 0);
|
||||||
|
glPushMatrix();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
/* degree symbol */
|
||||||
|
if ((unsigned char)string[i] == 0xc2 &&
|
||||||
|
(unsigned char)string[i + 1] == 0xb0) {
|
||||||
|
RenderGlyph(DEGREE_GLYPH);
|
||||||
|
i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
RenderGlyph(string[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
glPopMatrix();
|
||||||
|
glPopMatrix();
|
||||||
|
#else
|
||||||
|
//FIXME (dave) this is awful code, drawing chars glyph at a time.
|
||||||
|
//FIXME (dave) Also, need to render string at an angle....
|
||||||
|
m_dx = (x - m_vpwidth/2) * cos(angle) + (y - m_vpheight/2) * sin(angle);
|
||||||
|
m_dx += m_vpwidth/2;
|
||||||
|
m_dy = -(x - m_vpwidth/2) * sin(angle) + (y - m_vpheight/2) * cos(angle);
|
||||||
|
m_dy += m_vpheight/2;
|
||||||
|
|
||||||
|
m_dx = x;
|
||||||
|
m_dy = y;
|
||||||
|
m_angle = angle;
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_2D, texobj);
|
||||||
|
|
||||||
|
for (int i = 0; string[i]; i++) {
|
||||||
|
if (string[i] == '\n') {
|
||||||
|
m_dy += tgi[(int)'A'].height;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
/* degree symbol */
|
||||||
|
if ((unsigned char)string[i] == 0xc2 &&
|
||||||
|
(unsigned char)string[i + 1] == 0xb0) {
|
||||||
|
RenderGlyph(DEGREE_GLYPH);
|
||||||
|
i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
RenderGlyph(string[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void TexFont::RenderString(const wxString &string, int x, int y, float angle) {
|
||||||
|
#ifdef ocpnUSE_GL
|
||||||
|
LoadTexFontShaders();
|
||||||
|
#endif
|
||||||
|
RenderString((const char *)string.ToUTF8(), x, y, angle);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TexFont::PrepareShader(int width, int height, double rotation){
|
||||||
|
#ifdef ocpnUSE_GL
|
||||||
|
if(!m_TexFontShader)
|
||||||
|
LoadTexFontShaders();
|
||||||
|
|
||||||
|
m_vpwidth = width;
|
||||||
|
m_vpheight = height;
|
||||||
|
|
||||||
|
mat4x4 m;
|
||||||
|
float vp_transform[16];
|
||||||
|
mat4x4_identity(m);
|
||||||
|
mat4x4_scale_aniso((float(*)[4])vp_transform, m, 2.0 / (float)width,
|
||||||
|
-2.0 / (float)height, 1.0);
|
||||||
|
// Rotate
|
||||||
|
mat4x4 Q;
|
||||||
|
mat4x4_rotate_Z(Q, (float(*)[4])vp_transform, rotation);
|
||||||
|
mat4x4_translate_in_place(Q, -width / 2.0, -height / 2.0, 0);
|
||||||
|
|
||||||
|
mat4x4 I;
|
||||||
|
mat4x4_identity(I);
|
||||||
|
|
||||||
|
m_TexFontShader->Bind();
|
||||||
|
m_TexFontShader->SetUniformMatrix4fv( "MVMatrix", (GLfloat *)Q);
|
||||||
|
m_TexFontShader->SetUniformMatrix4fv( "TransformMatrix", (GLfloat *)I);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef ocpnUSE_GL
|
||||||
|
#if defined(USE_ANDROID_GLES2) || defined(ocpnUSE_GLSL)
|
||||||
|
|
||||||
|
#ifdef USE_ANDROID_GLES2
|
||||||
|
const GLchar* TexFont_preamble =
|
||||||
|
"\n";
|
||||||
|
#else
|
||||||
|
const GLchar* TexFont_preamble =
|
||||||
|
"#version 120\n"
|
||||||
|
"#define precision\n"
|
||||||
|
"#define lowp\n"
|
||||||
|
"#define mediump\n"
|
||||||
|
"#define highp\n";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// 2D texture shader with color modulation, used for colored text
|
||||||
|
static const GLchar *TexFont_vertex_shader_source =
|
||||||
|
"precision highp float;\n"
|
||||||
|
"attribute vec2 position;\n"
|
||||||
|
"attribute vec2 aUV;\n"
|
||||||
|
"uniform mat4 MVMatrix;\n"
|
||||||
|
"uniform mat4 TransformMatrix;\n"
|
||||||
|
"varying vec2 varCoord;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" gl_Position = MVMatrix * TransformMatrix * vec4(position, 0.0, 1.0);\n"
|
||||||
|
" //varCoord = aUV.st;\n"
|
||||||
|
" varCoord = aUV;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
static const GLchar *TexFont_fragment_shader_source =
|
||||||
|
"precision highp float;\n"
|
||||||
|
"uniform sampler2D uTex;\n"
|
||||||
|
"uniform vec4 color;\n"
|
||||||
|
"varying vec2 varCoord;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" vec4 col=texture2D(uTex, varCoord);\n"
|
||||||
|
" gl_FragColor = color;\n"
|
||||||
|
" gl_FragColor.a = col.a;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
|
||||||
|
bool TexFont::LoadTexFontShaders() {
|
||||||
|
bool ret_val = true;
|
||||||
|
|
||||||
|
// Are the shaders ready?
|
||||||
|
if(m_TexFontShader)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Simple colored triangle shader
|
||||||
|
if (!m_TexFontShader) {
|
||||||
|
CGLShaderProgram *shaderProgram = new CGLShaderProgram;
|
||||||
|
shaderProgram->addShaderFromSource(TexFont_vertex_shader_source, GL_VERTEX_SHADER);
|
||||||
|
shaderProgram->addShaderFromSource(TexFont_fragment_shader_source, GL_FRAGMENT_SHADER);
|
||||||
|
shaderProgram->linkProgram();
|
||||||
|
|
||||||
|
if (shaderProgram->isOK())
|
||||||
|
m_TexFontShader = shaderProgram;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_shadersLoaded = true;
|
||||||
|
|
||||||
|
return ret_val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
*
|
||||||
|
* Project: OpenCPN
|
||||||
|
* Purpose: OpenGL text rendering
|
||||||
|
* Author: Sean D'Epagnier
|
||||||
|
*
|
||||||
|
***************************************************************************
|
||||||
|
* Copyright (C) 2014 Sean D'Epagnier *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 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 the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __TEXFONT_H__
|
||||||
|
#define __TEXFONT_H__
|
||||||
|
|
||||||
|
#include <wx/colour.h>
|
||||||
|
#include <wx/font.h>
|
||||||
|
|
||||||
|
/* support ascii plus degree symbol for now pack font in a single texture 16x8
|
||||||
|
*/
|
||||||
|
#define DEGREE_GLYPH 127
|
||||||
|
#define MIN_GLYPH 32
|
||||||
|
#define MAX_GLYPH 128
|
||||||
|
|
||||||
|
#define NUM_GLYPHS (MAX_GLYPH - MIN_GLYPH)
|
||||||
|
|
||||||
|
#define COLS_GLYPHS 16
|
||||||
|
#define ROWS_GLYPHS ((NUM_GLYPHS / COLS_GLYPHS) + 1)
|
||||||
|
|
||||||
|
struct TexGlyphInfo {
|
||||||
|
int x, y, width, height;
|
||||||
|
float advance;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TexFont {
|
||||||
|
public:
|
||||||
|
TexFont();
|
||||||
|
~TexFont();
|
||||||
|
|
||||||
|
void Build(wxFont &font, double scale_factor, double dpi_factor, bool blur = false);
|
||||||
|
void Delete();
|
||||||
|
|
||||||
|
void GetTextExtent(const wxString &string, int *width, int *height);
|
||||||
|
void RenderString(const char *string, int x=0, int y=0, float angle = 0.0);
|
||||||
|
void RenderString(const wxString &string, int x=0, int y=0, float angle = 0.0);
|
||||||
|
bool IsBuilt() { return m_built; }
|
||||||
|
void SetColor(wxColor &color) { m_color = color; }
|
||||||
|
void PrepareShader(int width, int height, double rotation);
|
||||||
|
void SetContentScaleFactor(double s){m_ContentScaleFactor = s;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void GetTextExtent(const char *string, int *width, int *height);
|
||||||
|
void RenderGlyph(int c);
|
||||||
|
bool LoadTexFontShaders();
|
||||||
|
|
||||||
|
wxFont m_font;
|
||||||
|
bool m_blur;
|
||||||
|
|
||||||
|
TexGlyphInfo tgi[MAX_GLYPH];
|
||||||
|
|
||||||
|
unsigned int texobj;
|
||||||
|
int tex_w, tex_h;
|
||||||
|
int m_maxglyphw;
|
||||||
|
int m_maxglyphh;
|
||||||
|
bool m_built;
|
||||||
|
|
||||||
|
float m_dx, m_dy;
|
||||||
|
float m_angle;
|
||||||
|
int m_vpwidth, m_vpheight;
|
||||||
|
|
||||||
|
wxColor m_color;
|
||||||
|
|
||||||
|
bool m_shadersLoaded;
|
||||||
|
double m_ContentScaleFactor;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
TexFont *GetTexFont(wxFont *key);
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
@@ -0,0 +1,885 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
*
|
||||||
|
* Project: OpenCPN
|
||||||
|
* Purpose: Chart Symbols
|
||||||
|
* Author: Jesper Weissglas
|
||||||
|
*
|
||||||
|
***************************************************************************
|
||||||
|
* Copyright (C) 2010 by David S. Register *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 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 the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
|
**************************************************************************/
|
||||||
|
//#include "config.h"
|
||||||
|
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/wx.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/filename.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#if defined(__OCPN__ANDROID__)
|
||||||
|
#include <qopengl.h>
|
||||||
|
#include <GL/gl_private.h> // this is a cut-down version of gl.h
|
||||||
|
#include <GLES2/gl2.h>
|
||||||
|
#elif defined(__MSVC__)
|
||||||
|
#include "glew.h"
|
||||||
|
#elif defined(__WXOSX__)
|
||||||
|
#include <OpenGL/gl.h>
|
||||||
|
#include <OpenGL/glu.h>
|
||||||
|
typedef void (* _GLUfuncptr)();
|
||||||
|
#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0
|
||||||
|
#elif defined(__WXQT__) || defined(__WXGTK__)
|
||||||
|
#include <GL/glew.h>
|
||||||
|
#include <GL/glu.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "chartsymbols.h"
|
||||||
|
#ifdef ocpnUSE_GL
|
||||||
|
#include <wx/glcanvas.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "s52plib.h"
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ChartSymbols::ChartSymbols(void) {}
|
||||||
|
|
||||||
|
ChartSymbols::~ChartSymbols(void) {}
|
||||||
|
|
||||||
|
void ChartSymbols::InitializeTables(void) {
|
||||||
|
rasterSymbolsLoadedColorMapNumber = -1;
|
||||||
|
ColorTableIndex = 0;
|
||||||
|
rasterSymbolsTexture = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChartSymbols::DeleteGlobals(void) {
|
||||||
|
m_symbolGraphicLocations.clear();
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < m_colorTables.GetCount(); i++) {
|
||||||
|
colTable *ct = (colTable *)m_colorTables.Item(i);
|
||||||
|
delete ct->tableName;
|
||||||
|
ct->colors.clear();
|
||||||
|
ct->wxColors.clear();
|
||||||
|
delete ct;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_colorTables.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChartSymbols::ProcessColorTables(pugi::xml_node &node) {
|
||||||
|
for (pugi::xml_node child = node.first_child(); child != 0;
|
||||||
|
child = child.next_sibling()) {
|
||||||
|
const char *pcn = child.name();
|
||||||
|
|
||||||
|
if (!strcmp(pcn, "color-table")) {
|
||||||
|
colTable *colortable = new colTable;
|
||||||
|
colortable->tableName =
|
||||||
|
new wxString(child.first_attribute().value(), wxConvUTF8);
|
||||||
|
|
||||||
|
pugi::xml_node colorNode = child.first_child();
|
||||||
|
while (colorNode) {
|
||||||
|
if (!strcmp(colorNode.name(), "graphics-file")) {
|
||||||
|
colortable->rasterFileName =
|
||||||
|
wxString(colorNode.first_attribute().value(), wxConvUTF8);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strcmp(colorNode.name(), "color")) {
|
||||||
|
wxString key;
|
||||||
|
S52color color;
|
||||||
|
|
||||||
|
for (pugi::xml_attribute attr = colorNode.first_attribute(); attr;
|
||||||
|
attr = attr.next_attribute()) {
|
||||||
|
const char *pca = attr.name();
|
||||||
|
if (!strcmp(pca, "name")) {
|
||||||
|
strncpy(color.colName, attr.value(), 5);
|
||||||
|
color.colName[5] = 0;
|
||||||
|
key = wxString(attr.value(), wxConvUTF8);
|
||||||
|
|
||||||
|
} else if (!strcmp(pca, "r")) {
|
||||||
|
color.R = attr.as_int();
|
||||||
|
} else if (!strcmp(pca, "g")) {
|
||||||
|
color.G = attr.as_int();
|
||||||
|
} else if (!strcmp(pca, "b")) {
|
||||||
|
color.B = attr.as_int();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
colortable->colors[key] = color;
|
||||||
|
wxColour wxcolor(color.R, color.G, color.B);
|
||||||
|
colortable->wxColors[key] = wxcolor;
|
||||||
|
}
|
||||||
|
|
||||||
|
colorNode = colorNode.next_sibling();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_colorTables.Add((void *)colortable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define TGET_INT_PROPERTY_VALUE(node, name, target) \
|
||||||
|
propVal = wxString(node->Attribute(name), wxConvUTF8); \
|
||||||
|
propVal.ToLong(&numVal, 0); \
|
||||||
|
target = numVal;
|
||||||
|
void ChartSymbols::ProcessLookups(pugi::xml_node &node) {
|
||||||
|
Lookup lookup;
|
||||||
|
|
||||||
|
for (pugi::xml_node child = node.first_child(); child != 0;
|
||||||
|
child = child.next_sibling()) {
|
||||||
|
const char *pcn = child.name();
|
||||||
|
|
||||||
|
if (!strcmp(pcn, "lookup")) {
|
||||||
|
for (pugi::xml_attribute attr = child.first_attribute(); attr;
|
||||||
|
attr = attr.next_attribute()) {
|
||||||
|
const char *pca = attr.name();
|
||||||
|
if (!strcmp(pca, "name")) {
|
||||||
|
lookup.name = wxString(attr.value(), wxConvUTF8);
|
||||||
|
} else if (!strcmp(pca, "RCID")) {
|
||||||
|
lookup.RCID = attr.as_int();
|
||||||
|
} else if (!strcmp(pca, "id")) {
|
||||||
|
lookup.id = attr.as_int();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pugi::xml_node lookupNode = child.first_child();
|
||||||
|
while (lookupNode) {
|
||||||
|
const char *nodeText = lookupNode.first_child().value();
|
||||||
|
|
||||||
|
if (!strcmp(lookupNode.name(), "type")) {
|
||||||
|
if (!strcmp(nodeText, "Area"))
|
||||||
|
lookup.type = AREAS_T;
|
||||||
|
else if (!strcmp(nodeText, "Line"))
|
||||||
|
lookup.type = LINES_T;
|
||||||
|
else
|
||||||
|
lookup.type = POINT_T;
|
||||||
|
} else if (!strcmp(lookupNode.name(), "disp-prio")) {
|
||||||
|
if (!strcmp(nodeText, "Group 1"))
|
||||||
|
lookup.displayPrio = PRIO_GROUP1;
|
||||||
|
else if (!strcmp(nodeText, "Area 1"))
|
||||||
|
lookup.displayPrio = PRIO_AREA_1;
|
||||||
|
else if (!strcmp(nodeText, "Area 2"))
|
||||||
|
lookup.displayPrio = PRIO_AREA_2;
|
||||||
|
else if (!strcmp(nodeText, "Point Symbol"))
|
||||||
|
lookup.displayPrio = PRIO_SYMB_POINT;
|
||||||
|
else if (!strcmp(nodeText, "Line Symbol"))
|
||||||
|
lookup.displayPrio = PRIO_SYMB_LINE;
|
||||||
|
else if (!strcmp(nodeText, "Area Symbol"))
|
||||||
|
lookup.displayPrio = PRIO_SYMB_AREA;
|
||||||
|
else if (!strcmp(nodeText, "Routing"))
|
||||||
|
lookup.displayPrio = PRIO_ROUTEING;
|
||||||
|
else if (!strcmp(nodeText, "Hazards"))
|
||||||
|
lookup.displayPrio = PRIO_HAZARDS;
|
||||||
|
else if (!strcmp(nodeText, "Mariners"))
|
||||||
|
lookup.displayPrio = PRIO_MARINERS;
|
||||||
|
else
|
||||||
|
lookup.displayPrio = PRIO_NODATA;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (!strcmp(lookupNode.name(), "radar-prio")) {
|
||||||
|
if (!strcmp(nodeText, "On Top"))
|
||||||
|
lookup.radarPrio = RAD_OVER;
|
||||||
|
else
|
||||||
|
lookup.radarPrio = RAD_SUPP;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (!strcmp(lookupNode.name(), "table-name")) {
|
||||||
|
if (!strcmp(nodeText, "Simplified"))
|
||||||
|
lookup.tableName = SIMPLIFIED;
|
||||||
|
else if (!strcmp(nodeText, "Lines"))
|
||||||
|
lookup.tableName = LINES;
|
||||||
|
else if (!strcmp(nodeText, "Plain"))
|
||||||
|
lookup.tableName = PLAIN_BOUNDARIES;
|
||||||
|
else if (!strcmp(nodeText, "Symbolized"))
|
||||||
|
lookup.tableName = SYMBOLIZED_BOUNDARIES;
|
||||||
|
else
|
||||||
|
lookup.tableName = PAPER_CHART;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (!strcmp(lookupNode.name(), "display-cat")) {
|
||||||
|
if (!strcmp(nodeText, "Displaybase"))
|
||||||
|
lookup.displayCat = DISPLAYBASE;
|
||||||
|
else if (!strcmp(nodeText, "Standard"))
|
||||||
|
lookup.displayCat = STANDARD;
|
||||||
|
else if (!strcmp(nodeText, "Other"))
|
||||||
|
lookup.displayCat = OTHER;
|
||||||
|
else if (!strcmp(nodeText, "Mariners"))
|
||||||
|
lookup.displayCat = MARINERS_STANDARD;
|
||||||
|
else
|
||||||
|
lookup.displayCat = OTHER;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (!strcmp(lookupNode.name(), "comment")) {
|
||||||
|
lookup.comment = lookupNode.first_child().text().as_int();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (!strcmp(lookupNode.name(), "instruction")) {
|
||||||
|
wxString inst(nodeText, wxConvUTF8);
|
||||||
|
lookup.instruction = inst;
|
||||||
|
lookup.instruction.Append('\037');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (!strcmp(lookupNode.name(), "attrib-code")) {
|
||||||
|
int nc = strlen(nodeText);
|
||||||
|
if (nc >= 6) { // ignore spurious short fields
|
||||||
|
std::string attVal = std::string(nodeText);
|
||||||
|
if(attVal.length() == 6)
|
||||||
|
attVal += ' ';
|
||||||
|
lookup.attributeCodeArray.push_back(attVal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lookupNode = lookupNode.next_sibling();
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildLookup(lookup);
|
||||||
|
lookup.attributeCodeArray.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChartSymbols::ProcessVectorTag(pugi::xml_node &vectorNode,
|
||||||
|
SymbolSizeInfo_t &vectorSize) {
|
||||||
|
vectorSize.size.x = vectorNode.attribute("width").as_int();
|
||||||
|
vectorSize.size.y = vectorNode.attribute("height").as_int();
|
||||||
|
|
||||||
|
for (pugi::xml_node child = vectorNode.first_child(); child != 0;
|
||||||
|
child = child.next_sibling()) {
|
||||||
|
const char *nodeType = child.name();
|
||||||
|
|
||||||
|
if (!strcmp(nodeType, "distance")) {
|
||||||
|
vectorSize.minDistance = child.attribute("min").as_int();
|
||||||
|
vectorSize.maxDistance = child.attribute("max").as_int();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (!strcmp(nodeType, "origin")) {
|
||||||
|
vectorSize.origin.x = child.attribute("x").as_int();
|
||||||
|
vectorSize.origin.y = child.attribute("y").as_int();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (!strcmp(nodeType, "pivot")) {
|
||||||
|
vectorSize.pivot.x = child.attribute("x").as_int();
|
||||||
|
vectorSize.pivot.y = child.attribute("y").as_int();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChartSymbols::ProcessLinestyles(pugi::xml_node &node) {
|
||||||
|
LineStyle lineStyle;
|
||||||
|
|
||||||
|
for (pugi::xml_node child = node.first_child(); child != 0;
|
||||||
|
child = child.next_sibling()) {
|
||||||
|
lineStyle.RCID = child.attribute("RCID").as_int();
|
||||||
|
|
||||||
|
pugi::xml_node lineNode = child.first_child();
|
||||||
|
while (lineNode) {
|
||||||
|
const char *nodeText = lineNode.first_child().value();
|
||||||
|
const char *nodeType = lineNode.name();
|
||||||
|
|
||||||
|
if (!strcmp(nodeType, "description"))
|
||||||
|
lineStyle.description = nodeText;
|
||||||
|
else if (!strcmp(nodeType, "name"))
|
||||||
|
lineStyle.name = nodeText;
|
||||||
|
else if (!strcmp(nodeType, "color-ref"))
|
||||||
|
lineStyle.colorRef = nodeText;
|
||||||
|
else if (!strcmp(nodeType, "HPGL"))
|
||||||
|
lineStyle.HPGL = nodeText;
|
||||||
|
else if (!strcmp(nodeType, "vector"))
|
||||||
|
ProcessVectorTag(lineNode, lineStyle.vectorSize);
|
||||||
|
|
||||||
|
lineNode = lineNode.next_sibling();
|
||||||
|
}
|
||||||
|
BuildLineStyle(lineStyle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChartSymbols::ProcessPatterns(pugi::xml_node &node) {
|
||||||
|
OCPNPattern pattern;
|
||||||
|
|
||||||
|
for (pugi::xml_node child = node.first_child(); child != 0;
|
||||||
|
child = child.next_sibling()) {
|
||||||
|
pattern.RCID = child.attribute("RCID").as_int();
|
||||||
|
|
||||||
|
pattern.hasVector = false;
|
||||||
|
pattern.hasBitmap = false;
|
||||||
|
pattern.preferBitmap = true;
|
||||||
|
|
||||||
|
pugi::xml_node pattNode = child.first_child();
|
||||||
|
while (pattNode) {
|
||||||
|
const char *nodeText = pattNode.first_child().value();
|
||||||
|
const char *nodeType = pattNode.name();
|
||||||
|
|
||||||
|
if (!strcmp(nodeType, "description"))
|
||||||
|
pattern.description = nodeText;
|
||||||
|
else if (!strcmp(nodeType, "name"))
|
||||||
|
pattern.name = nodeText;
|
||||||
|
else if (!strcmp(nodeType, "filltype"))
|
||||||
|
pattern.fillType = nodeText[0];
|
||||||
|
else if (!strcmp(nodeType, "spacing"))
|
||||||
|
pattern.spacing = nodeText[0];
|
||||||
|
else if (!strcmp(nodeType, "definition"))
|
||||||
|
pattern.hasVector = !strcmp(nodeText, "V");
|
||||||
|
else if (!strcmp(nodeType, "color-ref"))
|
||||||
|
pattern.colorRef = nodeText;
|
||||||
|
else if (!strcmp(nodeType, "HPGL")) {
|
||||||
|
pattern.HPGL = nodeText;
|
||||||
|
pattern.hasVector = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (!strcmp(nodeType, "prefer-bitmap")) {
|
||||||
|
if (!strcmp(nodeText, "no"))
|
||||||
|
pattern.preferBitmap = false;
|
||||||
|
else if (!strcmp(nodeText, "false"))
|
||||||
|
pattern.preferBitmap = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (!strcmp(nodeType, "bitmap")) {
|
||||||
|
pattern.bitmapSize.size.x = pattNode.attribute("width").as_int();
|
||||||
|
pattern.bitmapSize.size.y = pattNode.attribute("height").as_int();
|
||||||
|
|
||||||
|
for (pugi::xml_node child = pattNode.first_child(); child != 0;
|
||||||
|
child = child.next_sibling()) {
|
||||||
|
const char *nodeType = child.name();
|
||||||
|
|
||||||
|
if (!strcmp(nodeType, "distance")) {
|
||||||
|
pattern.bitmapSize.minDistance = child.attribute("min").as_int();
|
||||||
|
pattern.bitmapSize.maxDistance = child.attribute("max").as_int();
|
||||||
|
} else if (!strcmp(nodeType, "origin")) {
|
||||||
|
pattern.bitmapSize.origin.x = child.attribute("x").as_int();
|
||||||
|
pattern.bitmapSize.origin.y = child.attribute("y").as_int();
|
||||||
|
} else if (!strcmp(nodeType, "pivot")) {
|
||||||
|
pattern.bitmapSize.pivot.x = child.attribute("x").as_int();
|
||||||
|
pattern.bitmapSize.pivot.y = child.attribute("y").as_int();
|
||||||
|
} else if (!strcmp(nodeType, "graphics-location")) {
|
||||||
|
pattern.bitmapSize.graphics.x = child.attribute("x").as_int();
|
||||||
|
pattern.bitmapSize.graphics.y = child.attribute("y").as_int();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (!strcmp(nodeType, "vector"))
|
||||||
|
ProcessVectorTag(pattNode, pattern.vectorSize);
|
||||||
|
|
||||||
|
pattNode = pattNode.next_sibling();
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildPattern(pattern);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChartSymbols::ProcessSymbols(pugi::xml_node &node) {
|
||||||
|
ChartSymbol symbol;
|
||||||
|
|
||||||
|
for (pugi::xml_node child = node.first_child(); child != 0;
|
||||||
|
child = child.next_sibling()) {
|
||||||
|
symbol.RCID = child.attribute("RCID").as_int();
|
||||||
|
|
||||||
|
symbol.hasVector = false;
|
||||||
|
symbol.hasBitmap = false;
|
||||||
|
symbol.preferBitmap = true;
|
||||||
|
|
||||||
|
pugi::xml_node symbolNode = child.first_child();
|
||||||
|
while (symbolNode) {
|
||||||
|
const char *nodeText = symbolNode.first_child().value();
|
||||||
|
const char *nodeType = symbolNode.name();
|
||||||
|
|
||||||
|
if (!strcmp(nodeType, "description"))
|
||||||
|
symbol.description = nodeText;
|
||||||
|
else if (!strcmp(nodeType, "name"))
|
||||||
|
symbol.name = nodeText;
|
||||||
|
else if (!strcmp(nodeType, "definition"))
|
||||||
|
symbol.hasVector = !strcmp(nodeText, "V");
|
||||||
|
else if (!strcmp(nodeType, "color-ref"))
|
||||||
|
symbol.colorRef = nodeText;
|
||||||
|
|
||||||
|
else if (!strcmp(nodeType, "prefer-bitmap")) {
|
||||||
|
if (!strcmp(nodeText, "no"))
|
||||||
|
symbol.preferBitmap = false;
|
||||||
|
else if (!strcmp(nodeText, "false"))
|
||||||
|
symbol.preferBitmap = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (!strcmp(nodeType, "bitmap")) {
|
||||||
|
symbol.bitmapSize.size.x = symbolNode.attribute("width").as_int();
|
||||||
|
symbol.bitmapSize.size.y = symbolNode.attribute("height").as_int();
|
||||||
|
symbol.hasBitmap = true;
|
||||||
|
|
||||||
|
for (pugi::xml_node child = symbolNode.first_child(); child != 0;
|
||||||
|
child = child.next_sibling()) {
|
||||||
|
const char *nodeType = child.name();
|
||||||
|
|
||||||
|
if (!strcmp(nodeType, "distance")) {
|
||||||
|
symbol.bitmapSize.minDistance = child.attribute("min").as_int();
|
||||||
|
symbol.bitmapSize.maxDistance = child.attribute("max").as_int();
|
||||||
|
} else if (!strcmp(nodeType, "origin")) {
|
||||||
|
symbol.bitmapSize.origin.x = child.attribute("x").as_int();
|
||||||
|
symbol.bitmapSize.origin.y = child.attribute("y").as_int();
|
||||||
|
} else if (!strcmp(nodeType, "pivot")) {
|
||||||
|
symbol.bitmapSize.pivot.x = child.attribute("x").as_int();
|
||||||
|
symbol.bitmapSize.pivot.y = child.attribute("y").as_int();
|
||||||
|
} else if (!strcmp(nodeType, "graphics-location")) {
|
||||||
|
symbol.bitmapSize.graphics.x = child.attribute("x").as_int();
|
||||||
|
symbol.bitmapSize.graphics.y = child.attribute("y").as_int();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (!strcmp(nodeType, "vector")) {
|
||||||
|
symbol.vectorSize.size.x = symbolNode.attribute("width").as_int();
|
||||||
|
symbol.vectorSize.size.y = symbolNode.attribute("height").as_int();
|
||||||
|
symbol.hasVector = true;
|
||||||
|
|
||||||
|
for (pugi::xml_node child = symbolNode.first_child(); child != 0;
|
||||||
|
child = child.next_sibling()) {
|
||||||
|
const char *nodeType = child.name();
|
||||||
|
|
||||||
|
if (!strcmp(nodeType, "distance")) {
|
||||||
|
symbol.vectorSize.minDistance = child.attribute("min").as_int();
|
||||||
|
symbol.vectorSize.maxDistance = child.attribute("max").as_int();
|
||||||
|
} else if (!strcmp(nodeType, "origin")) {
|
||||||
|
symbol.vectorSize.origin.x = child.attribute("x").as_int();
|
||||||
|
symbol.vectorSize.origin.y = child.attribute("y").as_int();
|
||||||
|
} else if (!strcmp(nodeType, "pivot")) {
|
||||||
|
symbol.vectorSize.pivot.x = child.attribute("x").as_int();
|
||||||
|
symbol.vectorSize.pivot.y = child.attribute("y").as_int();
|
||||||
|
} else if (!strcmp(nodeType, "HPGL")) {
|
||||||
|
symbol.HPGL = wxString(child.first_child().value(), wxConvUTF8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
symbolNode = symbolNode.next_sibling();
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildSymbol(symbol);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ChartSymbols::BuildLookup(Lookup &lookup) {
|
||||||
|
auto LUP = new LUPrec();
|
||||||
|
|
||||||
|
LUP->RCID = lookup.RCID;
|
||||||
|
LUP->nSequence = lookup.id;
|
||||||
|
LUP->DISC = lookup.displayCat;
|
||||||
|
LUP->FTYP = lookup.type;
|
||||||
|
LUP->DPRI = lookup.displayPrio;
|
||||||
|
LUP->RPRI = lookup.radarPrio;
|
||||||
|
LUP->TNAM = lookup.tableName;
|
||||||
|
LUP->OBCL[6] = 0;
|
||||||
|
memcpy(LUP->OBCL, lookup.name.mb_str(), 7);
|
||||||
|
|
||||||
|
LUP->ATTArray = lookup.attributeCodeArray;
|
||||||
|
|
||||||
|
LUP->INST = lookup.instruction;
|
||||||
|
LUP->LUCM = lookup.comment;
|
||||||
|
|
||||||
|
// Add LUP to array
|
||||||
|
// Search the LUPArray to see if there is already a LUP with this RCID
|
||||||
|
// If found, replace it with the new LUP
|
||||||
|
// This provides a facility for updating the LUP tables after loading a basic
|
||||||
|
// set
|
||||||
|
|
||||||
|
unsigned int index = 0;
|
||||||
|
wxArrayOfLUPrec *pLUPARRAYtyped = plib->SelectLUPARRAY(LUP->TNAM);
|
||||||
|
|
||||||
|
while (index < pLUPARRAYtyped->GetCount()) {
|
||||||
|
auto pLUPCandidate = pLUPARRAYtyped->Item(index);
|
||||||
|
if (LUP->RCID == pLUPCandidate->RCID) {
|
||||||
|
pLUPARRAYtyped->RemoveAt(index);
|
||||||
|
plib->DestroyLUP(pLUPCandidate); // empties the LUP
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
pLUPARRAYtyped->Add(LUP);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChartSymbols::BuildLineStyle(LineStyle &lineStyle) {
|
||||||
|
Rule *lnstmp = NULL;
|
||||||
|
Rule *lnst = (Rule *)calloc(1, sizeof(Rule));
|
||||||
|
plib->pAlloc->Add(lnst);
|
||||||
|
|
||||||
|
lnst->RCID = lineStyle.RCID;
|
||||||
|
memcpy(lnst->name.PANM, lineStyle.name.mb_str(), 8);
|
||||||
|
lnst->bitmap.PBTM = NULL;
|
||||||
|
|
||||||
|
lnst->vector.LVCT = (char *)malloc(lineStyle.HPGL.Len() + 1);
|
||||||
|
strcpy(lnst->vector.LVCT, lineStyle.HPGL.mb_str());
|
||||||
|
|
||||||
|
lnst->colRef.LCRF = (char *)malloc(lineStyle.colorRef.Len() + 1);
|
||||||
|
strcpy(lnst->colRef.LCRF, lineStyle.colorRef.mb_str());
|
||||||
|
|
||||||
|
lnst->pos.line.minDist.PAMI = lineStyle.vectorSize.minDistance;
|
||||||
|
lnst->pos.line.maxDist.PAMA = lineStyle.vectorSize.maxDistance;
|
||||||
|
|
||||||
|
lnst->pos.line.pivot_x.PACL = lineStyle.vectorSize.pivot.x;
|
||||||
|
lnst->pos.line.pivot_y.PARW = lineStyle.vectorSize.pivot.y;
|
||||||
|
|
||||||
|
lnst->pos.line.bnbox_w.PAHL = lineStyle.vectorSize.size.x;
|
||||||
|
lnst->pos.line.bnbox_h.PAVL = lineStyle.vectorSize.size.y;
|
||||||
|
|
||||||
|
lnst->pos.line.bnbox_x.SBXC = lineStyle.vectorSize.origin.x;
|
||||||
|
lnst->pos.line.bnbox_y.SBXR = lineStyle.vectorSize.origin.y;
|
||||||
|
|
||||||
|
lnstmp = (*plib->_line_sym)[lineStyle.name];
|
||||||
|
|
||||||
|
if (NULL == lnstmp)
|
||||||
|
(*plib->_line_sym)[lineStyle.name] = lnst;
|
||||||
|
else if (strncmp(lnst->name.LINM, lnstmp->name.LINM, 8))
|
||||||
|
(*plib->_line_sym)[lineStyle.name] = lnst;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ChartSymbols::BuildPattern(OCPNPattern &pattern) {
|
||||||
|
Rule *pattmp = NULL;
|
||||||
|
|
||||||
|
Rule *patt = (Rule *)calloc(1, sizeof(Rule));
|
||||||
|
plib->pAlloc->Add(patt);
|
||||||
|
|
||||||
|
patt->RCID = pattern.RCID;
|
||||||
|
patt->exposition.PXPO = new wxString(pattern.description);
|
||||||
|
memcpy(patt->name.PANM, pattern.name.mb_str(), 8);
|
||||||
|
patt->bitmap.PBTM = NULL;
|
||||||
|
patt->fillType.PATP = pattern.fillType;
|
||||||
|
patt->spacing.PASP = pattern.spacing;
|
||||||
|
|
||||||
|
patt->vector.PVCT = (char *)malloc(pattern.HPGL.Len() + 1);
|
||||||
|
strcpy(patt->vector.PVCT, pattern.HPGL.mb_str());
|
||||||
|
|
||||||
|
patt->colRef.PCRF = (char *)malloc(pattern.colorRef.Len() + 1);
|
||||||
|
strcpy(patt->colRef.PCRF, pattern.colorRef.mb_str());
|
||||||
|
|
||||||
|
SymbolSizeInfo_t patternSize;
|
||||||
|
|
||||||
|
if (pattern.hasVector && !(pattern.preferBitmap && pattern.hasBitmap)) {
|
||||||
|
patt->definition.PADF = 'V';
|
||||||
|
patternSize = pattern.vectorSize;
|
||||||
|
} else {
|
||||||
|
patt->definition.PADF = 'R';
|
||||||
|
patternSize = pattern.bitmapSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
patt->pos.patt.minDist.PAMI = patternSize.minDistance;
|
||||||
|
patt->pos.patt.maxDist.PAMA = patternSize.maxDistance;
|
||||||
|
|
||||||
|
patt->pos.patt.pivot_x.PACL = patternSize.pivot.x;
|
||||||
|
patt->pos.patt.pivot_y.PARW = patternSize.pivot.y;
|
||||||
|
|
||||||
|
patt->pos.patt.bnbox_w.PAHL = patternSize.size.x;
|
||||||
|
patt->pos.patt.bnbox_h.PAVL = patternSize.size.y;
|
||||||
|
|
||||||
|
patt->pos.patt.bnbox_x.SBXC = patternSize.origin.x;
|
||||||
|
patt->pos.patt.bnbox_y.SBXR = patternSize.origin.y;
|
||||||
|
|
||||||
|
wxRect graphicsLocation(pattern.bitmapSize.graphics, pattern.bitmapSize.size);
|
||||||
|
m_symbolGraphicLocations[pattern.name] = graphicsLocation;
|
||||||
|
|
||||||
|
// check if key already there
|
||||||
|
|
||||||
|
pattmp = (*plib->_patt_sym)[pattern.name];
|
||||||
|
|
||||||
|
if (NULL == pattmp) {
|
||||||
|
(*plib->_patt_sym)[pattern.name] = patt; // insert in hash table
|
||||||
|
} else // already something here with same key...
|
||||||
|
{ // if the pattern names are not identical
|
||||||
|
if (strncmp(patt->name.PANM, pattmp->name.PANM, 8)) {
|
||||||
|
(*plib->_patt_sym)[pattern.name] = patt; // replace the pattern
|
||||||
|
plib->DestroyPatternRuleNode(
|
||||||
|
pattmp); // remember to free to replaced node
|
||||||
|
// the node itself is destroyed as part of pAlloc
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ChartSymbols::BuildSymbol(ChartSymbol &symbol) {
|
||||||
|
Rule *symb = (Rule *)calloc(1, sizeof(Rule));
|
||||||
|
plib->pAlloc->Add(symb);
|
||||||
|
|
||||||
|
wxString SVCT;
|
||||||
|
wxString SCRF;
|
||||||
|
|
||||||
|
symb->RCID = symbol.RCID;
|
||||||
|
memcpy(symb->name.SYNM, symbol.name.char_str(), 8);
|
||||||
|
|
||||||
|
symb->exposition.SXPO = new wxString(symbol.description);
|
||||||
|
|
||||||
|
symb->vector.SVCT = (char *)malloc(symbol.HPGL.Len() + 1);
|
||||||
|
strcpy(symb->vector.SVCT, symbol.HPGL.mb_str());
|
||||||
|
|
||||||
|
symb->colRef.SCRF = (char *)malloc(symbol.colorRef.Len() + 1);
|
||||||
|
strcpy(symb->colRef.SCRF, symbol.colorRef.mb_str());
|
||||||
|
|
||||||
|
symb->bitmap.SBTM = NULL;
|
||||||
|
|
||||||
|
SymbolSizeInfo_t symbolSize;
|
||||||
|
|
||||||
|
if (symbol.hasVector && !(symbol.preferBitmap && symbol.hasBitmap)) {
|
||||||
|
symb->definition.SYDF = 'V';
|
||||||
|
symbolSize = symbol.vectorSize;
|
||||||
|
} else {
|
||||||
|
symb->definition.SYDF = 'R';
|
||||||
|
symbolSize = symbol.bitmapSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
symb->pos.symb.minDist.PAMI = symbolSize.minDistance;
|
||||||
|
symb->pos.symb.maxDist.PAMA = symbolSize.maxDistance;
|
||||||
|
|
||||||
|
symb->pos.symb.pivot_x.SYCL = symbolSize.pivot.x;
|
||||||
|
symb->pos.symb.pivot_y.SYRW = symbolSize.pivot.y;
|
||||||
|
|
||||||
|
symb->pos.symb.bnbox_w.SYHL = symbolSize.size.x;
|
||||||
|
symb->pos.symb.bnbox_h.SYVL = symbolSize.size.y;
|
||||||
|
|
||||||
|
symb->pos.symb.bnbox_x.SBXC = symbolSize.origin.x;
|
||||||
|
symb->pos.symb.bnbox_y.SBXR = symbolSize.origin.y;
|
||||||
|
|
||||||
|
wxRect graphicsLocation(symbol.bitmapSize.graphics, symbol.bitmapSize.size);
|
||||||
|
m_symbolGraphicLocations[symbol.name] = graphicsLocation;
|
||||||
|
|
||||||
|
// Already something here with same key? Then free its strings, otherwise they
|
||||||
|
// leak.
|
||||||
|
Rule *symbtmp = (*plib->_symb_sym)[symbol.name];
|
||||||
|
if (symbtmp) {
|
||||||
|
free(symbtmp->colRef.SCRF);
|
||||||
|
free(symbtmp->vector.SVCT);
|
||||||
|
delete symbtmp->exposition.SXPO;
|
||||||
|
}
|
||||||
|
|
||||||
|
(*plib->_symb_sym)[symbol.name] = symb;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ChartSymbols::LoadConfigFile(s52plib *plibArg,
|
||||||
|
const wxString &s52ilePath) {
|
||||||
|
plib = plibArg;
|
||||||
|
|
||||||
|
// Expect to find library data XML file in same folder as other S52 data.
|
||||||
|
// Files in CWD takes precedence.
|
||||||
|
|
||||||
|
wxString name, extension;
|
||||||
|
wxString xmlFileName = _T("chartsymbols.xml");
|
||||||
|
|
||||||
|
wxFileName::SplitPath(s52ilePath, &configFileDirectory, &name, &extension);
|
||||||
|
wxString fullFilePath =
|
||||||
|
configFileDirectory + wxFileName::GetPathSeparator() + xmlFileName;
|
||||||
|
|
||||||
|
if (wxFileName::FileExists(xmlFileName)) {
|
||||||
|
fullFilePath = xmlFileName;
|
||||||
|
configFileDirectory = _T(".");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!wxFileName::FileExists(fullFilePath)) {
|
||||||
|
wxString msg(_T("ChartSymbols ConfigFile not found: "));
|
||||||
|
msg += fullFilePath;
|
||||||
|
wxLogMessage(msg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_symbolsDoc.load_file(fullFilePath.fn_str())) {
|
||||||
|
wxString msg(_T("ChartSymbols loaded from "));
|
||||||
|
msg += fullFilePath;
|
||||||
|
wxLogMessage(msg);
|
||||||
|
|
||||||
|
pugi::xml_node elements = m_symbolsDoc.child("chartsymbols");
|
||||||
|
|
||||||
|
for (pugi::xml_node element = elements.first_child(); element;
|
||||||
|
element = element.next_sibling()) {
|
||||||
|
if (!strcmp(element.name(), "color-tables"))
|
||||||
|
ProcessColorTables(element);
|
||||||
|
else if (!strcmp(element.name(), "lookups"))
|
||||||
|
ProcessLookups(element);
|
||||||
|
else if (!strcmp(element.name(), "line-styles"))
|
||||||
|
ProcessLinestyles(element);
|
||||||
|
else if (!strcmp(element.name(), "patterns"))
|
||||||
|
ProcessPatterns(element);
|
||||||
|
else if (!strcmp(element.name(), "symbols"))
|
||||||
|
ProcessSymbols(element);
|
||||||
|
}
|
||||||
|
m_symbolsDoc.reset(); // purge the document to recover memory;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void ChartSymbols::SetColorTableIndex(int index, bool flush,
|
||||||
|
const ChartCtx& ctx) {
|
||||||
|
ColorTableIndex = index;
|
||||||
|
LoadRasterFileForColorTable(ColorTableIndex, flush, ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ChartSymbols::LoadRasterFileForColorTable(int tableNo, bool flush,
|
||||||
|
const ChartCtx& ctx) {
|
||||||
|
if (tableNo == rasterSymbolsLoadedColorMapNumber && !flush) {
|
||||||
|
if (ctx.m_use_opengl) {
|
||||||
|
if (rasterSymbolsTexture) return true;
|
||||||
|
#ifdef ocpnUSE_GL
|
||||||
|
if (!ctx.m_texture_rectangle_format && rasterSymbols.IsOk())
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (rasterSymbols.IsOk()) return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
colTable *coltab = (colTable *)m_colorTables.Item(tableNo);
|
||||||
|
|
||||||
|
wxString filename = configFileDirectory + wxFileName::GetPathSeparator() +
|
||||||
|
coltab->rasterFileName;
|
||||||
|
|
||||||
|
wxImage rasterFileImg;
|
||||||
|
if (rasterFileImg.LoadFile(filename, wxBITMAP_TYPE_PNG)) {
|
||||||
|
#ifdef ocpnUSE_GL
|
||||||
|
/* for opengl mode, load the symbols into a texture */
|
||||||
|
if (ctx.m_use_opengl && ctx.m_texture_rectangle_format) {
|
||||||
|
int w = rasterFileImg.GetWidth();
|
||||||
|
int h = rasterFileImg.GetHeight();
|
||||||
|
|
||||||
|
// Get the glRGBA format data from the wxImage
|
||||||
|
unsigned char *d = rasterFileImg.GetData();
|
||||||
|
unsigned char *a = rasterFileImg.GetAlpha();
|
||||||
|
|
||||||
|
/* combine rgb with alpha */
|
||||||
|
unsigned char *e = (unsigned char *)malloc(w * h * 4);
|
||||||
|
if (d && a) {
|
||||||
|
for (int y = 0; y < h; y++)
|
||||||
|
for (int x = 0; x < w; x++) {
|
||||||
|
int off = (y * w + x);
|
||||||
|
|
||||||
|
e[off * 4 + 0] = d[off * 3 + 0];
|
||||||
|
e[off * 4 + 1] = d[off * 3 + 1];
|
||||||
|
e[off * 4 + 2] = d[off * 3 + 2];
|
||||||
|
e[off * 4 + 3] = a[off];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!rasterSymbolsTexture) glGenTextures(1, &rasterSymbolsTexture);
|
||||||
|
|
||||||
|
glBindTexture(ctx.m_texture_rectangle_format, rasterSymbolsTexture);
|
||||||
|
|
||||||
|
/* unfortunately this texture looks terrible with compression */
|
||||||
|
GLuint format = GL_RGBA;
|
||||||
|
glTexImage2D(ctx.m_texture_rectangle_format, 0, format, w, h, 0, GL_RGBA,
|
||||||
|
GL_UNSIGNED_BYTE, e);
|
||||||
|
|
||||||
|
// glTexParameteri( g_texture_rectangle_format,
|
||||||
|
// GL_TEXTURE_MAG_FILTER, GL_NEAREST ); glTexParameteri(
|
||||||
|
// g_texture_rectangle_format, GL_TEXTURE_MIN_FILTER,
|
||||||
|
// GL_NEAREST );
|
||||||
|
|
||||||
|
glTexParameteri(ctx.m_texture_rectangle_format, GL_TEXTURE_WRAP_S,
|
||||||
|
GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(ctx.m_texture_rectangle_format, GL_TEXTURE_WRAP_T,
|
||||||
|
GL_CLAMP_TO_EDGE);
|
||||||
|
|
||||||
|
glTexParameteri(ctx.m_texture_rectangle_format, GL_TEXTURE_MAG_FILTER,
|
||||||
|
GL_LINEAR); // No mipmapping
|
||||||
|
glTexParameteri(ctx.m_texture_rectangle_format, GL_TEXTURE_MIN_FILTER,
|
||||||
|
GL_LINEAR);
|
||||||
|
|
||||||
|
rasterSymbolsTextureSize = wxSize(w, h);
|
||||||
|
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
|
free(e);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
{ rasterSymbols = wxBitmap(rasterFileImg, -1 /*32*/); }
|
||||||
|
|
||||||
|
rasterSymbolsLoadedColorMapNumber = tableNo;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString msg(_T("ChartSymbols...Failed to load raster symbols file "));
|
||||||
|
msg += filename;
|
||||||
|
wxLogMessage(msg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
S52color *ChartSymbols::GetColor(const char *colorName, int fromTable) {
|
||||||
|
colTable *colortable;
|
||||||
|
wxString key(colorName, wxConvUTF8, 5);
|
||||||
|
colortable = (colTable *)m_colorTables.Item(fromTable);
|
||||||
|
return &(colortable->colors[key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxColor ChartSymbols::GetwxColor(const wxString &colorName, int fromTable) {
|
||||||
|
colTable *colortable;
|
||||||
|
colortable = (colTable *)m_colorTables.Item(fromTable);
|
||||||
|
wxColor c = colortable->wxColors[colorName];
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxColor ChartSymbols::GetwxColor(const char *colorName, int fromTable) {
|
||||||
|
wxString key(colorName, wxConvUTF8, 5);
|
||||||
|
return GetwxColor(key, fromTable);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ChartSymbols::FindColorTable(const wxString &tableName) {
|
||||||
|
for (unsigned int i = 0; i < m_colorTables.GetCount(); i++) {
|
||||||
|
colTable *ct = (colTable *)m_colorTables.Item(i);
|
||||||
|
if (tableName.IsSameAs(*ct->tableName)) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ChartSymbols::UpdateTableColor( std::string table_name, std::string color_name, wxColor& new_color){
|
||||||
|
int table_index = FindColorTable( wxString(table_name.c_str()));
|
||||||
|
|
||||||
|
colTable *colortable = (colTable *)m_colorTables.Item(table_index);
|
||||||
|
wxString key(color_name.c_str(), wxConvUTF8, 5);
|
||||||
|
|
||||||
|
colortable->wxColors[key] = new_color;
|
||||||
|
if (colortable->colors.find(key) != colortable->colors.end()) {
|
||||||
|
S52color *color = &colortable->colors[key];
|
||||||
|
color->R = new_color.Red();
|
||||||
|
color->G = new_color.Green();
|
||||||
|
color->B = new_color.Blue();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString ChartSymbols::HashKey(const char *symbolName) {
|
||||||
|
char key[9];
|
||||||
|
key[8] = 0;
|
||||||
|
strncpy(key, symbolName, 8);
|
||||||
|
return wxString(key, wxConvUTF8);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxImage ChartSymbols::GetImage(const char *symbolName) {
|
||||||
|
wxRect bmArea = m_symbolGraphicLocations[HashKey(symbolName)];
|
||||||
|
if (rasterSymbols.IsOk()) {
|
||||||
|
wxBitmap bitmap = rasterSymbols.GetSubBitmap(bmArea);
|
||||||
|
return bitmap.ConvertToImage();
|
||||||
|
} else
|
||||||
|
return wxImage(1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int ChartSymbols::GetGLTextureRect(wxRect &rect,
|
||||||
|
const char *symbolName) {
|
||||||
|
rect = m_symbolGraphicLocations[HashKey(symbolName)];
|
||||||
|
return rasterSymbolsTexture;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxSize ChartSymbols::GLTextureSize() { return rasterSymbolsTextureSize; }
|
||||||
204
docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/chartsymbols.h
Executable file
204
docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/chartsymbols.h
Executable file
@@ -0,0 +1,204 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
*
|
||||||
|
* Project: OpenCPN
|
||||||
|
* Purpose: Chart Symbols
|
||||||
|
* Author: Jesper Weissglas
|
||||||
|
*
|
||||||
|
***************************************************************************
|
||||||
|
* Copyright (C) 2010 by David S. Register *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 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 the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _CHARTSYMBOLS_H_
|
||||||
|
#define _CHARTSYMBOLS_H_
|
||||||
|
|
||||||
|
#ifdef ocpnUSE_GL
|
||||||
|
#ifdef __OCPN_USE_GLEW__
|
||||||
|
#ifndef __OCPN__ANDROID__
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#include "glew.h"
|
||||||
|
#elif defined(__WXQT__) || defined(__WXGTK__)
|
||||||
|
#include <GL/glew.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__OCPN__ANDROID__)
|
||||||
|
//#include <GLES2/gl2.h>
|
||||||
|
#include <qopengl.h>
|
||||||
|
#include <GL/gl_private.h> // this is a cut-down version of gl.h
|
||||||
|
#include <GLES2/gl2.h>
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
#define GL_GLEXT_PROTOTYPES
|
||||||
|
#include <GL/gl.h>
|
||||||
|
#include <GL/glu.h>
|
||||||
|
//typedef void (__stdcall * _GLUfuncptr)(void);
|
||||||
|
#elif defined(__WXOSX__)
|
||||||
|
#include <OpenGL/gl.h>
|
||||||
|
#include <OpenGL/glu.h>
|
||||||
|
typedef void (* _GLUfuncptr)();
|
||||||
|
#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0
|
||||||
|
#elif defined(__WXQT__) || defined(__WXGTK__)
|
||||||
|
#define GL_GLEXT_PROTOTYPES
|
||||||
|
#include <GL/glu.h>
|
||||||
|
#include <GL/gl.h>
|
||||||
|
#include <GL/glx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include "s52s57.h"
|
||||||
|
#include "pugixml.hpp"
|
||||||
|
class s52plib;
|
||||||
|
|
||||||
|
WX_DECLARE_STRING_HASH_MAP(wxRect, symbolGraphicsHashMap);
|
||||||
|
|
||||||
|
class Lookup {
|
||||||
|
public:
|
||||||
|
int RCID;
|
||||||
|
int id;
|
||||||
|
wxString name;
|
||||||
|
Object_t type; // 'A' Area, 'L' Line, 'P' Point
|
||||||
|
DisPrio displayPrio; // Display Priority
|
||||||
|
RadPrio radarPrio; // 'O' or 'S', Radar Priority
|
||||||
|
LUPname tableName; // FTYP: areas, points, lines
|
||||||
|
std::vector<std::string> attributeCodeArray; // ArrayString of LUP Attributes
|
||||||
|
wxString instruction; // Instruction Field (rules)
|
||||||
|
DisCat displayCat; // Display Categorie: D/S/O, DisplayBase, Standard, Other
|
||||||
|
int comment; // Look-Up Comment (PLib3.x put 'groupes' here,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct _SymbolSizeInfo {
|
||||||
|
wxSize size;
|
||||||
|
wxPoint origin;
|
||||||
|
wxPoint pivot;
|
||||||
|
wxPoint graphics;
|
||||||
|
int minDistance;
|
||||||
|
int maxDistance;
|
||||||
|
} SymbolSizeInfo_t;
|
||||||
|
|
||||||
|
class OCPNPattern {
|
||||||
|
public:
|
||||||
|
int RCID;
|
||||||
|
wxString name;
|
||||||
|
wxString description;
|
||||||
|
wxString colorRef;
|
||||||
|
bool hasVector;
|
||||||
|
bool hasBitmap;
|
||||||
|
bool preferBitmap;
|
||||||
|
char fillType;
|
||||||
|
char spacing;
|
||||||
|
SymbolSizeInfo_t bitmapSize;
|
||||||
|
SymbolSizeInfo_t vectorSize;
|
||||||
|
wxBitmap bitmap;
|
||||||
|
wxString HPGL;
|
||||||
|
};
|
||||||
|
|
||||||
|
class LineStyle {
|
||||||
|
public:
|
||||||
|
int RCID;
|
||||||
|
wxString name;
|
||||||
|
wxString description;
|
||||||
|
wxString colorRef;
|
||||||
|
SymbolSizeInfo_t vectorSize;
|
||||||
|
wxBitmap bitmap;
|
||||||
|
wxString HPGL;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Generic method argument wrapping differences using opengl or not */
|
||||||
|
struct ChartCtx {
|
||||||
|
#ifdef ocpnUSE_GL
|
||||||
|
const bool m_use_opengl;
|
||||||
|
const GLenum m_texture_rectangle_format;
|
||||||
|
ChartCtx(bool use_opengl, GLenum rect_format)
|
||||||
|
: m_use_opengl(use_opengl), m_texture_rectangle_format(rect_format) {}
|
||||||
|
#else
|
||||||
|
const bool m_use_opengl;
|
||||||
|
ChartCtx(bool use_opengl) : m_use_opengl(use_opengl) {}
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class ChartSymbol {
|
||||||
|
public:
|
||||||
|
wxString name;
|
||||||
|
int RCID;
|
||||||
|
bool hasVector;
|
||||||
|
bool hasBitmap;
|
||||||
|
bool preferBitmap;
|
||||||
|
wxString description;
|
||||||
|
wxString colorRef;
|
||||||
|
SymbolSizeInfo_t bitmapSize;
|
||||||
|
SymbolSizeInfo_t vectorSize;
|
||||||
|
wxString HPGL;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ChartSymbols {
|
||||||
|
public:
|
||||||
|
ChartSymbols(void);
|
||||||
|
~ChartSymbols(void);
|
||||||
|
bool LoadConfigFile(s52plib *plibArg, const wxString &path);
|
||||||
|
|
||||||
|
void InitializeTables(void);
|
||||||
|
void DeleteGlobals(void);
|
||||||
|
int FindColorTable(const wxString &tableName);
|
||||||
|
S52color *GetColor(const char *colorName, int fromTable);
|
||||||
|
wxColor GetwxColor(const wxString &colorName, int fromTable);
|
||||||
|
wxColor GetwxColor(const char *colorName, int fromTable);
|
||||||
|
wxString HashKey(const char *symbolName);
|
||||||
|
wxImage GetImage(const char *symbolName);
|
||||||
|
unsigned int GetGLTextureRect(wxRect &rect, const char *symbolName);
|
||||||
|
wxSize GLTextureSize();
|
||||||
|
void SetTextureFormat( int format){ m_texture_rectangle_format = format; }
|
||||||
|
int LoadRasterFileForColorTable(int table_nr, bool flush,
|
||||||
|
const ChartCtx& ctx);
|
||||||
|
void SetColorTableIndex(int index, bool flush, const ChartCtx& ctx);
|
||||||
|
|
||||||
|
wxArrayPtrVoid m_colorTables;
|
||||||
|
unsigned int rasterSymbolsTexture;
|
||||||
|
wxSize rasterSymbolsTextureSize;
|
||||||
|
wxBitmap rasterSymbols;
|
||||||
|
int rasterSymbolsLoadedColorMapNumber;
|
||||||
|
wxString configFileDirectory;
|
||||||
|
int ColorTableIndex;
|
||||||
|
symbolGraphicsHashMap m_symbolGraphicLocations;
|
||||||
|
bool UpdateTableColor( std::string table_name, std::string color_name, wxColor& new_color);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void BuildLineStyle(LineStyle &lineStyle);
|
||||||
|
void BuildLookup(Lookup &lookup);
|
||||||
|
void BuildPattern(OCPNPattern &pattern);
|
||||||
|
void BuildSymbol(ChartSymbol &symol);
|
||||||
|
|
||||||
|
void ProcessColorTables(pugi::xml_node &node);
|
||||||
|
void ProcessLookups(pugi::xml_node &node);
|
||||||
|
void ProcessLinestyles(pugi::xml_node &node);
|
||||||
|
void ProcessPatterns(pugi::xml_node &node);
|
||||||
|
void ProcessSymbols(pugi::xml_node &node);
|
||||||
|
void ProcessVectorTag(pugi::xml_node &vectorNode,
|
||||||
|
SymbolSizeInfo_t &vectorSize);
|
||||||
|
|
||||||
|
pugi::xml_document m_symbolsDoc;
|
||||||
|
GLenum m_texture_rectangle_format;
|
||||||
|
|
||||||
|
s52plib *plib;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Project: OpenCP
|
||||||
|
* Purpose: Color Types
|
||||||
|
* Author: David Register
|
||||||
|
*
|
||||||
|
***************************************************************************
|
||||||
|
* Copyright (C) 2022 by David S. Register *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 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 the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
|
***************************************************************************
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _COLORTYPES_H_
|
||||||
|
#define _COLORTYPES_H_
|
||||||
|
|
||||||
|
typedef struct _S52color {
|
||||||
|
char colName[20];
|
||||||
|
unsigned char R;
|
||||||
|
unsigned char G;
|
||||||
|
unsigned char B;
|
||||||
|
} S52color;
|
||||||
|
|
||||||
|
WX_DECLARE_STRING_HASH_MAP(S52color, colorHashMap);
|
||||||
|
WX_DECLARE_STRING_HASH_MAP(wxColour, wxColorHashMap);
|
||||||
|
|
||||||
|
typedef enum ColorScheme {
|
||||||
|
GLOBAL_COLOR_SCHEME_RGB,
|
||||||
|
GLOBAL_COLOR_SCHEME_DAY,
|
||||||
|
GLOBAL_COLOR_SCHEME_DUSK,
|
||||||
|
GLOBAL_COLOR_SCHEME_NIGHT,
|
||||||
|
N_COLOR_SCHEMES
|
||||||
|
} _ColorScheme;
|
||||||
|
|
||||||
|
typedef struct _colTable {
|
||||||
|
wxString *tableName;
|
||||||
|
wxString rasterFileName;
|
||||||
|
wxArrayPtrVoid *color;
|
||||||
|
colorHashMap colors;
|
||||||
|
wxColorHashMap wxColors;
|
||||||
|
} colTable;
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
1514
docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/mygeom.cpp
Normal file
1514
docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/mygeom.cpp
Normal file
File diff suppressed because it is too large
Load Diff
304
docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/mygeom.h
Normal file
304
docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/mygeom.h
Normal file
@@ -0,0 +1,304 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Project: OpenCPN
|
||||||
|
* Purpose: Tesselation of Polygon Object
|
||||||
|
* Author: David Register
|
||||||
|
*
|
||||||
|
***************************************************************************
|
||||||
|
* Copyright (C) 2010 by David S. Register *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 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 the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
|
***************************************************************************
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __MYGEOM_H
|
||||||
|
#define __MYGEOM_H
|
||||||
|
|
||||||
|
// For compilers that support precompilation, includes "wx/wx.h".
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
//#include <wx/wfstream.h>
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
#if defined(__OCPN__ANDROID__)
|
||||||
|
#include <qopengl.h>
|
||||||
|
#include <GL/gl_private.h> // this is a cut-down version of gl.h
|
||||||
|
#include <GLES2/gl2.h>
|
||||||
|
#elif defined(__MSVC__)
|
||||||
|
#include "glew.h"
|
||||||
|
#elif defined(__WXOSX__)
|
||||||
|
#include <OpenGL/gl.h>
|
||||||
|
#include <OpenGL/glu.h>
|
||||||
|
typedef void (* _GLUfuncptr)();
|
||||||
|
#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0
|
||||||
|
#elif defined(__WXQT__) || defined(__WXGTK__)
|
||||||
|
#include <GL/glew.h>
|
||||||
|
#include <GL/glu.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__OCPN__ANDROID__)
|
||||||
|
#include <qopengl.h>
|
||||||
|
#include <GL/gl_private.h> // this is a cut-down version of gl.h
|
||||||
|
#include <GLES2/gl2.h>
|
||||||
|
#else
|
||||||
|
#ifdef ocpnUSE_GL
|
||||||
|
#if defined(__MSVC__)
|
||||||
|
#include "glew.h"
|
||||||
|
#elif defined(__WXOSX__)
|
||||||
|
#include <OpenGL/gl.h>
|
||||||
|
#include <OpenGL/glu.h>
|
||||||
|
typedef void (* _GLUfuncptr)();
|
||||||
|
#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0
|
||||||
|
#elif defined(__WXQT__) || defined(__WXGTK__)
|
||||||
|
#include <GL/glew.h>
|
||||||
|
#include <GL/glu.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
class OGRGeometry;
|
||||||
|
class OGRPolygon;
|
||||||
|
|
||||||
|
#define TESS_VERT 0 // constants describing preferred tess orientation
|
||||||
|
#define TESS_HORZ 1
|
||||||
|
|
||||||
|
#define EQUAL_EPS 1.0e-7 // tolerance value
|
||||||
|
|
||||||
|
// nota bene These definitions are identical to OpenGL prototypes
|
||||||
|
#define PTG_TRIANGLES 0x0004
|
||||||
|
#define PTG_TRIANGLE_STRIP 0x0005
|
||||||
|
#define PTG_TRIANGLE_FAN 0x0006
|
||||||
|
|
||||||
|
// Error Return Codes
|
||||||
|
#define ERROR_NONE 0
|
||||||
|
#define ERROR_NO_DLL 1
|
||||||
|
#define ERROR_BAD_OGRPOLY 2
|
||||||
|
|
||||||
|
// Some external prototypes
|
||||||
|
|
||||||
|
#define DATA_TYPE_FLOAT 0
|
||||||
|
#define DATA_TYPE_DOUBLE 1
|
||||||
|
#define DATA_TYPE_SHORT 2
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Internal data structures used for describing/rendering tesselated
|
||||||
|
// polygons
|
||||||
|
//
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class Extended_Geometry {
|
||||||
|
public:
|
||||||
|
Extended_Geometry();
|
||||||
|
~Extended_Geometry();
|
||||||
|
|
||||||
|
OGRGeometry *pogrGeom;
|
||||||
|
int n_vector_indices;
|
||||||
|
int *pvector_index;
|
||||||
|
int n_contours; // parameters passed to trapezoid tesselator
|
||||||
|
int *contour_array;
|
||||||
|
int n_max_vertex;
|
||||||
|
int pointx;
|
||||||
|
int pointy;
|
||||||
|
wxPoint2DDouble *vertex_array;
|
||||||
|
int xmin, xmax, ymin, ymax;
|
||||||
|
int n_max_edge_points;
|
||||||
|
|
||||||
|
// Conversion parameters
|
||||||
|
// for (assummed linear) convertions from vertex_array points to
|
||||||
|
// easting/northing, metres from 0,0 To convert to lat/lon, use simple
|
||||||
|
// merctor equations
|
||||||
|
double x_rate;
|
||||||
|
double x_offset;
|
||||||
|
double y_rate;
|
||||||
|
double y_offset;
|
||||||
|
double ref_lat; // Lower left corner of the cell containing this feature
|
||||||
|
double ref_lon;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TriPrim {
|
||||||
|
public:
|
||||||
|
TriPrim();
|
||||||
|
~TriPrim();
|
||||||
|
void FreeMem(void);
|
||||||
|
|
||||||
|
unsigned int type; // Type of triangle primitive
|
||||||
|
// May be PTG_TRIANGLES
|
||||||
|
// PTG_TRIANGLE_STRIP
|
||||||
|
// PTG_TRIANGLE_FAN
|
||||||
|
|
||||||
|
int nVert;
|
||||||
|
double *p_vertex; // Pointer to vertex array, x,y,x,y.....
|
||||||
|
|
||||||
|
LLBBox tri_box;
|
||||||
|
|
||||||
|
TriPrim *p_next; // chain link
|
||||||
|
};
|
||||||
|
|
||||||
|
class LegacyTriPrim {
|
||||||
|
public:
|
||||||
|
LegacyTriPrim();
|
||||||
|
~LegacyTriPrim();
|
||||||
|
void FreeMem(void);
|
||||||
|
|
||||||
|
unsigned int type; // Type of triangle primitive
|
||||||
|
// May be PTG_TRIANGLES
|
||||||
|
// PTG_TRIANGLE_STRIP
|
||||||
|
// PTG_TRIANGLE_FAN
|
||||||
|
|
||||||
|
int nVert;
|
||||||
|
double *p_vertex; // Pointer to vertex array, x,y,x,y.....
|
||||||
|
|
||||||
|
double minx, miny, maxx, maxy;
|
||||||
|
|
||||||
|
LegacyTriPrim *p_next; // chain link
|
||||||
|
};
|
||||||
|
|
||||||
|
class PolyTriGroup {
|
||||||
|
public:
|
||||||
|
PolyTriGroup();
|
||||||
|
PolyTriGroup(Extended_Geometry *pxGeom);
|
||||||
|
~PolyTriGroup();
|
||||||
|
|
||||||
|
int nContours;
|
||||||
|
int *pn_vertex; // pointer to array of poly vertex counts
|
||||||
|
float *pgroup_geom; // pointer to Raw geometry, used for contour line drawing
|
||||||
|
|
||||||
|
TriPrim *tri_prim_head; // head of linked list of TriPrims
|
||||||
|
bool m_bSMSENC;
|
||||||
|
bool bsingle_alloc;
|
||||||
|
unsigned char *single_buffer;
|
||||||
|
int single_buffer_size;
|
||||||
|
int data_type; // p_vertex in TriPrim chain is FLOAT or DOUBLE
|
||||||
|
float sfactor;
|
||||||
|
float soffset;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int my_bufgets(char *buf, int buf_len_max);
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int ilseg;
|
||||||
|
int irseg;
|
||||||
|
double loy;
|
||||||
|
double hiy;
|
||||||
|
|
||||||
|
} trapz_t;
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Triangle Tesselator Class
|
||||||
|
//
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
class OGRPolygon;
|
||||||
|
class GLUtesselator;
|
||||||
|
|
||||||
|
class PolyTessGeo {
|
||||||
|
public:
|
||||||
|
PolyTessGeo();
|
||||||
|
~PolyTessGeo();
|
||||||
|
|
||||||
|
PolyTessGeo(OGRPolygon *poly, bool bSENC_SM, double ref_lat, double ref_lon,
|
||||||
|
double LOD_meters); // Build this from OGRPolygon
|
||||||
|
|
||||||
|
PolyTessGeo(Extended_Geometry *pxGeom);
|
||||||
|
|
||||||
|
PolyTessGeo(unsigned char *polybuf, int nrecl, int index,
|
||||||
|
int senc_file_version);
|
||||||
|
|
||||||
|
bool IsOk() { return m_bOK; }
|
||||||
|
|
||||||
|
int BuildDeferredTess(void);
|
||||||
|
|
||||||
|
double Get_xmin() { return xmin; }
|
||||||
|
double Get_xmax() { return xmax; }
|
||||||
|
double Get_ymin() { return ymin; }
|
||||||
|
double Get_ymax() { return ymax; }
|
||||||
|
void SetExtents(double x_left, double y_bot, double x_right, double y_top);
|
||||||
|
|
||||||
|
PolyTriGroup *Get_PolyTriGroup_head() { return m_ppg_head; }
|
||||||
|
int GetnVertexMax() { return m_nvertex_max; }
|
||||||
|
void SetnVertexMax(int max) { m_nvertex_max = max; }
|
||||||
|
int GetnContours() { return m_ncnt; }
|
||||||
|
|
||||||
|
int ErrorCode;
|
||||||
|
void GetRefPos( double *lat, double *lon);
|
||||||
|
void Set_PolyTriGroup_head(PolyTriGroup *head) { m_ppg_head = head; }
|
||||||
|
void Set_OK(bool bok) { m_bOK = bok; }
|
||||||
|
|
||||||
|
void SetPPGHead(PolyTriGroup *head) { m_ppg_head = head; }
|
||||||
|
int my_bufgets(char *buf, int buf_len_max);
|
||||||
|
|
||||||
|
GLUtesselator *GLUtessobj;
|
||||||
|
wxArrayPtrVoid *m_pCombineVertexArray;
|
||||||
|
double *m_pwork_buf;
|
||||||
|
int m_buf_len;
|
||||||
|
int m_buf_idx;
|
||||||
|
TriPrim *m_pTPG_Last;
|
||||||
|
TriPrim *m_pTPG_Head;
|
||||||
|
int m_gltri_type;
|
||||||
|
int m_nvcall;
|
||||||
|
int m_nvmax;
|
||||||
|
bool m_bmerc_transform;
|
||||||
|
double mx_rate, mx_offset, my_rate, my_offset;
|
||||||
|
bool m_b_senc_sm;
|
||||||
|
double m_ref_lat, m_ref_lon;
|
||||||
|
int m_tess_orient;
|
||||||
|
double m_feature_ref_lat, m_feature_ref_lon;
|
||||||
|
double m_feature_easting, m_feature_northing;
|
||||||
|
|
||||||
|
double earthAxis;
|
||||||
|
bool m_bcm93;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int BuildTess(void);
|
||||||
|
// int BuildTessGL2(void);
|
||||||
|
// int PolyTessGeoGL(OGRPolygon *poly, bool bSENC_SM, double ref_lat, double
|
||||||
|
// ref_lon);
|
||||||
|
int BuildTessGLU(void);
|
||||||
|
int BuildTessGLFromXG(void);
|
||||||
|
|
||||||
|
// Data
|
||||||
|
|
||||||
|
bool m_bOK;
|
||||||
|
|
||||||
|
Extended_Geometry *m_pxgeom;
|
||||||
|
|
||||||
|
double xmin, xmax, ymin, ymax;
|
||||||
|
PolyTriGroup *m_ppg_head; // head of a PolyTriGroup chain
|
||||||
|
int m_nvertex_max; // and computed max vertex count
|
||||||
|
// used by drawing primitives as
|
||||||
|
// optimization
|
||||||
|
|
||||||
|
int m_ncnt;
|
||||||
|
int m_nwkb;
|
||||||
|
int *m_cntr;
|
||||||
|
char *m_buf_head;
|
||||||
|
char *m_buf_ptr; // used to read passed SENC record
|
||||||
|
int m_nrecl;
|
||||||
|
|
||||||
|
double m_LOD_meters;
|
||||||
|
|
||||||
|
double **m_vertexPtrArray;
|
||||||
|
bool m_printStats;
|
||||||
|
bool m_bstripify;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#include "s52_plib_utils.h"
|
||||||
|
|
||||||
|
static class _DefaultUtils : public S52PlibUtils {
|
||||||
|
/** Default implementation: return unscaled font. */
|
||||||
|
wxFont* GetFont(wxFont* font, double scale) override { return font; }
|
||||||
|
wxFont* GetDefaultFont(wxString label, int Ptsize) override {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
wxFont* GetScaledFont(int pointSize, wxFontFamily family, wxFontStyle style,
|
||||||
|
wxFontWeight weight, const wxString faceName,
|
||||||
|
double scale) override {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
} DefaultUtils;
|
||||||
|
|
||||||
|
static S52PlibUtils* s_the_utils = &DefaultUtils;
|
||||||
|
|
||||||
|
S52PlibUtils* GetS52Utils() { return s_the_utils; }
|
||||||
|
void SetUtils(S52PlibUtils* utils) { s_the_utils = utils; }
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#ifndef S52_PLIB_UTILS_H
|
||||||
|
#define S52_PLIB_UTILS_H
|
||||||
|
|
||||||
|
#include <wx/font.h>
|
||||||
|
|
||||||
|
/** Interface implemented by calling code */
|
||||||
|
class S52PlibUtils {
|
||||||
|
public:
|
||||||
|
/** Get a scaled font based on given; created if not already existing. */
|
||||||
|
virtual wxFont* GetFont(wxFont* font, double scale) = 0;
|
||||||
|
virtual wxFont* GetDefaultFont(wxString label, int Ptsize) = 0;
|
||||||
|
virtual wxFont* GetScaledFont(int pointSize, wxFontFamily family,
|
||||||
|
wxFontStyle style, wxFontWeight weight,
|
||||||
|
const wxString faceName, double scale) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
S52PlibUtils* GetS52Utils();
|
||||||
|
|
||||||
|
void SetUtils(S52PlibUtils* utils);
|
||||||
|
#endif // S52_PLIB_UTILS_H
|
||||||
6261
docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/s52cnsy.cpp
Normal file
6261
docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/s52cnsy.cpp
Normal file
File diff suppressed because it is too large
Load Diff
12765
docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/s52plib.cpp
Normal file
12765
docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/s52plib.cpp
Normal file
File diff suppressed because it is too large
Load Diff
737
docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/s52plib.h
Normal file
737
docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/s52plib.h
Normal file
@@ -0,0 +1,737 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
*
|
||||||
|
* Project: OpenCPN
|
||||||
|
* Purpose: S52 Presentation Library
|
||||||
|
* Author: David Register
|
||||||
|
*
|
||||||
|
***************************************************************************
|
||||||
|
* Copyright (C) 2010 by David S. Register *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 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 the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#ifndef _S52PLIB_H_
|
||||||
|
#define _S52PLIB_H_
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include "s52s57.h" //types
|
||||||
|
|
||||||
|
class wxGLContext;
|
||||||
|
|
||||||
|
#include "LLRegion.h"
|
||||||
|
#include "DepthFont.h"
|
||||||
|
#include "chartsymbols.h"
|
||||||
|
#include "TexFont.h"
|
||||||
|
|
||||||
|
#include <wx/dcgraph.h> // supplemental, for Mac
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
// ChartType constants
|
||||||
|
typedef enum S52_ChartTypeEnum {
|
||||||
|
S52_CHART_TYPE_UNKNOWN = 0,
|
||||||
|
S52_CHART_TYPE_DUMMY,
|
||||||
|
S52_CHART_TYPE_DONTCARE,
|
||||||
|
S52_CHART_TYPE_KAP,
|
||||||
|
S52_CHART_TYPE_GEO,
|
||||||
|
S52_CHART_TYPE_S57,
|
||||||
|
S52_CHART_TYPE_CM93,
|
||||||
|
S52_CHART_TYPE_CM93COMP,
|
||||||
|
S52_CHART_TYPE_PLUGIN,
|
||||||
|
S52_CHART_TYPE_MBTILES
|
||||||
|
} _S52_ChartTypeEnum;
|
||||||
|
|
||||||
|
// Correct some deficincies in MacOS OpenGL include files
|
||||||
|
#ifdef __WXOSX__
|
||||||
|
typedef void (*PFNGLGENBUFFERSPROC)(GLsizei n, GLuint *buffers);
|
||||||
|
typedef void (*PFNGLBINDBUFFERPROC)(GLenum target, GLuint buffer);
|
||||||
|
typedef void (*PFNGLDELETEBUFFERSPROC)(GLsizei n, const GLuint *buffers);
|
||||||
|
typedef void (*PFNGLGETBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname,
|
||||||
|
GLint *params);
|
||||||
|
typedef void (*PFNGLDELETERENDERBUFFERSEXTPROC)(GLsizei n,
|
||||||
|
const GLuint *renderbuffers);
|
||||||
|
typedef void (*PFNGLDELETEFRAMEBUFFERSEXTPROC)(GLsizei n,
|
||||||
|
const GLuint *framebuffers);
|
||||||
|
typedef void (*PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)(GLenum target, GLint level,
|
||||||
|
GLint xoffset, GLsizei width,
|
||||||
|
GLenum format,
|
||||||
|
GLsizei imageSize,
|
||||||
|
const GLvoid *data);
|
||||||
|
typedef void (*PFNGLGETCOMPRESSEDTEXIMAGEPROC)(GLenum target, GLint level,
|
||||||
|
GLvoid *img);
|
||||||
|
typedef GLenum (*PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)(GLenum target);
|
||||||
|
typedef void (*PFNGLBINDRENDERBUFFEREXTPROC)(GLenum target,
|
||||||
|
GLuint renderbuffer);
|
||||||
|
typedef void (*PFNGLBUFFERDATAPROC)(GLenum target, GLsizeiptr size,
|
||||||
|
const GLvoid *data, GLenum usage);
|
||||||
|
typedef void (*PFNGLGENFRAMEBUFFERSEXTPROC)(GLsizei n, GLuint *framebuffers);
|
||||||
|
typedef void (*PFNGLGENRENDERBUFFERSEXTPROC)(GLsizei n, GLuint *renderbuffers);
|
||||||
|
typedef void (*PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)(GLenum target,
|
||||||
|
GLenum attachment,
|
||||||
|
GLenum textarget,
|
||||||
|
GLuint texture, GLint level);
|
||||||
|
typedef void (*PFNGLCOMPRESSEDTEXIMAGE2DPROC)(GLenum target, GLint level,
|
||||||
|
GLenum internalformat,
|
||||||
|
GLsizei width, GLsizei height,
|
||||||
|
GLint border, GLsizei imageSize,
|
||||||
|
const GLvoid *data);
|
||||||
|
typedef void (*PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)(GLenum target,
|
||||||
|
GLenum attachment,
|
||||||
|
GLenum renderbuffertarget,
|
||||||
|
GLuint renderbuffer);
|
||||||
|
typedef void (*PFNGLRENDERBUFFERSTORAGEEXTPROC)(GLenum target,
|
||||||
|
GLenum internalformat,
|
||||||
|
GLsizei width, GLsizei height);
|
||||||
|
typedef void (*PFNGLBINDFRAMEBUFFEREXTPROC)(GLenum target, GLuint framebuffer);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define INVALID_COORD (-2147483647 - 1)
|
||||||
|
|
||||||
|
// wxWindows Hash Map Declarations
|
||||||
|
#include <wx/hashmap.h>
|
||||||
|
class RuleHash;
|
||||||
|
|
||||||
|
WX_DECLARE_HASH_MAP(wxString, Rule *, wxStringHash, wxStringEqual, RuleHash);
|
||||||
|
|
||||||
|
WX_DEFINE_SORTED_ARRAY(LUPrec *, wxArrayOfLUPrec);
|
||||||
|
|
||||||
|
WX_DECLARE_LIST(S52_TextC, TextObjList);
|
||||||
|
|
||||||
|
struct CARC_Buffer {
|
||||||
|
unsigned char color[3][4];
|
||||||
|
float line_width[3];
|
||||||
|
int steps;
|
||||||
|
|
||||||
|
int size;
|
||||||
|
float *data;
|
||||||
|
};
|
||||||
|
WX_DECLARE_STRING_HASH_MAP(CARC_Buffer, CARC_Hash);
|
||||||
|
WX_DECLARE_STRING_HASH_MAP(int, CARC_DL_Hash);
|
||||||
|
|
||||||
|
struct SoundingSym {
|
||||||
|
Rule *prule;
|
||||||
|
wxPoint2DDouble r;
|
||||||
|
wxUint32 color_RGB;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PixelCache;
|
||||||
|
|
||||||
|
class RenderFromHPGL;
|
||||||
|
class TexFont;
|
||||||
|
class wxFileConfig;
|
||||||
|
|
||||||
|
class noshow_element {
|
||||||
|
public:
|
||||||
|
char obj[7];
|
||||||
|
};
|
||||||
|
|
||||||
|
WX_DECLARE_OBJARRAY(noshow_element, ArrayOfNoshow);
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// LUP Array container, and friends
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
typedef struct _LUPHashIndex {
|
||||||
|
int n_start;
|
||||||
|
int count;
|
||||||
|
} LUPHashIndex;
|
||||||
|
|
||||||
|
WX_DECLARE_STRING_HASH_MAP(LUPHashIndex *, LUPArrayIndexHash);
|
||||||
|
|
||||||
|
class s52plib; // Forward
|
||||||
|
extern s52plib *ps52plib; ///< Global instance
|
||||||
|
|
||||||
|
/** in s52cnsy */
|
||||||
|
extern bool GetDoubleAttr(S57Obj *obj, const char *AttrName, double &val);
|
||||||
|
|
||||||
|
class LUPArrayContainer {
|
||||||
|
public:
|
||||||
|
LUPArrayContainer();
|
||||||
|
~LUPArrayContainer();
|
||||||
|
|
||||||
|
wxArrayOfLUPrec *GetLUPArray(void) { return LUPArray; }
|
||||||
|
LUPHashIndex *GetArrayIndexHelper(const char *objectName);
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxArrayOfLUPrec *LUPArray; // Sorted Array
|
||||||
|
LUPArrayIndexHash IndexHash;
|
||||||
|
};
|
||||||
|
|
||||||
|
class VPointCompat {
|
||||||
|
public:
|
||||||
|
int pix_width;
|
||||||
|
int pix_height;
|
||||||
|
double view_scale_ppm;
|
||||||
|
double rotation;
|
||||||
|
double clat;
|
||||||
|
double clon;
|
||||||
|
double chart_scale;
|
||||||
|
wxRect rv_rect;
|
||||||
|
double ref_scale;
|
||||||
|
double display_scale;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
TexFont *cache;
|
||||||
|
wxFont *key;
|
||||||
|
} TexFontCache;
|
||||||
|
|
||||||
|
void toSM_plib(double lat, double lon, double lat0, double lon0, double *x,
|
||||||
|
double *y);
|
||||||
|
|
||||||
|
void fromSM_plib(double x, double y, double lat0, double lon0, double *lat,
|
||||||
|
double *lon);
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// s52plib definition
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
class s52plib {
|
||||||
|
public:
|
||||||
|
s52plib(const wxString &PLib, bool b_forceLegacy = false);
|
||||||
|
~s52plib();
|
||||||
|
|
||||||
|
// TODO: SetPPM, SetDisplayWidth etc. should be combined to be set together by
|
||||||
|
// pointing them to info about current monitor
|
||||||
|
/**
|
||||||
|
* Set pixels per millimeter for symbol rendering.
|
||||||
|
* @param ppmm Logical pixels per millimeter of display.
|
||||||
|
*/
|
||||||
|
void SetPPMM(float ppmm);
|
||||||
|
void SetDisplayWidth(size_t pixels) { m_display_width = pixels; }
|
||||||
|
float GetPPMM() { return canvas_pix_per_mm; }
|
||||||
|
void SetDIPFactor(double factor);
|
||||||
|
void SetContentScaleFactor(double factor);
|
||||||
|
|
||||||
|
void SetOCPNVersion(int major, int minor, int patch);
|
||||||
|
|
||||||
|
double GetRVScaleFactor() { return m_rv_scale_factor; }
|
||||||
|
|
||||||
|
LUPrec *S52_LUPLookup(LUPname LUP_name, const char *objectName, S57Obj *pObj,
|
||||||
|
bool bStrict = 0);
|
||||||
|
int _LUP2rules(LUPrec *LUP, S57Obj *pObj);
|
||||||
|
S52color *getColor(const char *colorName);
|
||||||
|
wxColour getwxColour(const wxString &colorName);
|
||||||
|
|
||||||
|
void UpdateMarinerParams(void);
|
||||||
|
void ClearCNSYLUPArray(void);
|
||||||
|
|
||||||
|
void GenerateStateHash();
|
||||||
|
long GetStateHash() { return m_state_hash; }
|
||||||
|
|
||||||
|
void SetPLIBColorScheme(wxString scheme, const ChartCtx &ctx);
|
||||||
|
void SetPLIBColorScheme(ColorScheme cs, const ChartCtx &ctx);
|
||||||
|
wxString GetPLIBColorScheme(void) { return m_ColorScheme; }
|
||||||
|
|
||||||
|
void SetGLRendererString(const wxString &renderer);
|
||||||
|
wxString GetGLRendererString() { return m_renderer_string; }
|
||||||
|
void SetGLOptions(bool b_useStencil, bool b_useStencilAP, bool b_useScissors,
|
||||||
|
bool b_useFBO, bool b_useVBO, int nTextureFormat,
|
||||||
|
float MinCartographicLineWidth, float MinSymbolLineWidth);
|
||||||
|
void SetUseGLSL(bool useGLSL) { m_useGLSL = useGLSL; }
|
||||||
|
|
||||||
|
bool ObjectRenderCheck(ObjRazRules *rzRules);
|
||||||
|
bool ObjectRenderCheckRules(ObjRazRules *rzRules, bool check_noshow = false);
|
||||||
|
bool ObjectRenderCheckPos(ObjRazRules *rzRules);
|
||||||
|
bool ObjectRenderCheckPosReduced(ObjRazRules *rzRules);
|
||||||
|
bool ObjectRenderCheckCat(ObjRazRules *rzRules);
|
||||||
|
bool ObjectRenderCheckCS(ObjRazRules *rzRules);
|
||||||
|
bool ObjectRenderCheckDates(ObjRazRules *rzRules);
|
||||||
|
|
||||||
|
static void DestroyLUP(LUPrec *pLUP);
|
||||||
|
static void ClearRulesCache(Rule *pR);
|
||||||
|
DisCat findLUPDisCat(const char *objectName, LUPname TNAM);
|
||||||
|
|
||||||
|
// Temporarily save/restore the current colortable index
|
||||||
|
// Useful for Thumbnail rendering
|
||||||
|
void SaveColorScheme(void) { m_colortable_index_save = m_colortable_index; }
|
||||||
|
void RestoreColorScheme(void) {}
|
||||||
|
|
||||||
|
// Rendering stuff
|
||||||
|
void PrepareForRender(VPointCompat *vp);
|
||||||
|
void PrepareForRender(void);
|
||||||
|
void AdjustTextList(int dx, int dy, int screenw, int screenh);
|
||||||
|
void ClearTextList(void);
|
||||||
|
int SetLineFeaturePriority(ObjRazRules *rzRules, int npriority);
|
||||||
|
void FlushSymbolCaches(const ChartCtx &ctx);
|
||||||
|
|
||||||
|
// For DC's
|
||||||
|
int RenderObjectToDC(wxDC *pdc, ObjRazRules *rzRules);
|
||||||
|
int RenderObjectToDCText(wxDC *pdc, ObjRazRules *rzRules);
|
||||||
|
int RenderAreaToDC(wxDC *pdc, ObjRazRules *rzRules,
|
||||||
|
render_canvas_parms *pb_spec);
|
||||||
|
|
||||||
|
// Accessors
|
||||||
|
bool GetShowSoundings() { return m_bShowSoundg; }
|
||||||
|
void SetShowSoundings(bool f) {
|
||||||
|
m_bShowSoundg = f;
|
||||||
|
GenerateStateHash();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GetShowS57Text() { return m_bShowS57Text; }
|
||||||
|
void SetShowS57Text(bool f) {
|
||||||
|
m_bShowS57Text = f;
|
||||||
|
GenerateStateHash();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GetShowS57ImportantTextOnly() { return m_bShowS57ImportantTextOnly; }
|
||||||
|
void SetShowS57ImportantTextOnly(bool f) {
|
||||||
|
m_bShowS57ImportantTextOnly = f;
|
||||||
|
GenerateStateHash();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetLightsOff(bool val) { m_lightsOff = val; }
|
||||||
|
bool GetLightsOff() { return m_lightsOff; }
|
||||||
|
|
||||||
|
void SetAnchorOn(bool val);
|
||||||
|
bool GetAnchorOn();
|
||||||
|
|
||||||
|
void SetQualityOfData(bool val);
|
||||||
|
bool GetQualityOfData();
|
||||||
|
|
||||||
|
void SetScaleFactorExp(double ChartScaleFactorExp);
|
||||||
|
void SetScaleFactorZoomMod(int chart_zoom_modifier_vector);
|
||||||
|
|
||||||
|
int GetMajorVersion(void) { return m_VersionMajor; }
|
||||||
|
int GetMinorVersion(void) { return m_VersionMinor; }
|
||||||
|
|
||||||
|
void SetTextOverlapAvoid(bool f) { m_bDeClutterText = f; }
|
||||||
|
void SetShowNationalText(bool f) { m_bShowNationalTexts = f; }
|
||||||
|
void SetShowAtonText(bool f) { m_bShowAtonText = f; }
|
||||||
|
void SetShowLdisText(bool f) { m_bShowLdisText = f; }
|
||||||
|
void SetExtendLightSectors(bool f) { m_bExtendLightSectors = f; }
|
||||||
|
|
||||||
|
void SetDisplayCategory(enum _DisCat cat);
|
||||||
|
DisCat GetDisplayCategory() { return m_nDisplayCategory; }
|
||||||
|
|
||||||
|
void SetGLPolygonSmoothing(bool bset) { m_GLPolygonSmoothing = bset; }
|
||||||
|
bool GetGLPolygonSmoothing() { return m_GLPolygonSmoothing; }
|
||||||
|
void SetGLLineSmoothing(bool bset) { m_GLLineSmoothing = bset; }
|
||||||
|
bool GetGLLineSmoothing() { return m_GLLineSmoothing; }
|
||||||
|
|
||||||
|
wxArrayOfLUPrec *SelectLUPARRAY(LUPname TNAM);
|
||||||
|
LUPArrayContainer *SelectLUPArrayContainer(LUPname TNAM);
|
||||||
|
|
||||||
|
void DestroyPatternRuleNode(Rule *pR);
|
||||||
|
void DestroyRuleNode(Rule *pR);
|
||||||
|
static void DestroyRulesChain(Rules *top);
|
||||||
|
|
||||||
|
// For OpenGL
|
||||||
|
int RenderObjectToGL(const wxGLContext &glcc, ObjRazRules *rzRules);
|
||||||
|
int RenderAreaToGL(const wxGLContext &glcc, ObjRazRules *rzRules);
|
||||||
|
int RenderObjectToGLText(const wxGLContext &glcc, ObjRazRules *rzRules);
|
||||||
|
|
||||||
|
bool EnableGLLS(bool benable);
|
||||||
|
|
||||||
|
bool IsObjNoshow(const char *objcl);
|
||||||
|
void AddObjNoshow(const char *objcl);
|
||||||
|
void RemoveObjNoshow(const char *objcl);
|
||||||
|
void ClearNoshow(void);
|
||||||
|
void SaveObjNoshow() { m_saved_noshow = m_noshow_array; };
|
||||||
|
void RestoreObjNoshow() { m_noshow_array = m_saved_noshow; };
|
||||||
|
|
||||||
|
void SetVPointCompat(int pix_width, int pix_height, double view_scale_ppm,
|
||||||
|
double rotation, double clat, double clon,
|
||||||
|
double chart_scale, wxRect rv_rect, LLBBox &bbox,
|
||||||
|
double ref_scale, double display_scale);
|
||||||
|
|
||||||
|
// Todo accessors
|
||||||
|
LUPname m_nSymbolStyle;
|
||||||
|
LUPname m_nBoundaryStyle;
|
||||||
|
bool m_bOK;
|
||||||
|
|
||||||
|
bool m_bShowSoundg;
|
||||||
|
bool m_bShowMeta;
|
||||||
|
bool m_bShowS57Text;
|
||||||
|
bool m_bUseSCAMIN;
|
||||||
|
bool m_bUseSUPER_SCAMIN;
|
||||||
|
bool m_bShowAtonText;
|
||||||
|
bool m_bShowLdisText;
|
||||||
|
bool m_bExtendLightSectors;
|
||||||
|
bool m_bShowS57ImportantTextOnly;
|
||||||
|
bool m_bDeClutterText;
|
||||||
|
bool m_bShowNationalTexts;
|
||||||
|
int m_nSoundingFactor;
|
||||||
|
double m_SoundingsScaleFactor;
|
||||||
|
int m_nTextFactor;
|
||||||
|
double m_TextScaleFactor;
|
||||||
|
int m_SoundingsPointSize;
|
||||||
|
double m_SoundingsFontSizeMM;
|
||||||
|
double m_soundFontDelta;
|
||||||
|
double m_ChartScaleFactorExp;
|
||||||
|
int m_chart_zoom_modifier_vector;
|
||||||
|
double m_dipfactor;
|
||||||
|
double m_ContentScaleFactor;
|
||||||
|
double m_FinalTextScaleFactor;
|
||||||
|
|
||||||
|
int m_VersionMajor;
|
||||||
|
int m_VersionMinor;
|
||||||
|
|
||||||
|
int m_nDepthUnitDisplay;
|
||||||
|
bool m_isSoundingFontSet;
|
||||||
|
int m_sounding_char_width;
|
||||||
|
int m_sounding_char_height;
|
||||||
|
int m_sounding_char_descent;
|
||||||
|
#ifdef ocpnUSE_GL
|
||||||
|
GLint m_sounding_shader_uni_color;
|
||||||
|
GLint m_sounding_shader_uni_uTex;
|
||||||
|
GLint m_sounding_shader_attr_position;
|
||||||
|
GLint m_sounding_shader_attr_aUV;
|
||||||
|
GLint m_sounding_shader_uni_transform;
|
||||||
|
#endif
|
||||||
|
// Preferred display unit for vertical heights (meters/feet).
|
||||||
|
// 0 = meters, 1 = feet
|
||||||
|
int m_nHeightUnitDisplay;
|
||||||
|
|
||||||
|
// Library data
|
||||||
|
wxArrayPtrVoid *pAlloc;
|
||||||
|
|
||||||
|
RuleHash *_line_sym; // line symbolisation rules
|
||||||
|
RuleHash *_patt_sym; // pattern symbolisation rules
|
||||||
|
RuleHash *_cond_sym; // conditional symbolisation rules
|
||||||
|
RuleHash *_symb_symR; // symbol symbolisation rules, Raster
|
||||||
|
|
||||||
|
LUPArrayContainer *line_LAC;
|
||||||
|
LUPArrayContainer *areaPlain_LAC;
|
||||||
|
LUPArrayContainer *areaSymbol_LAC;
|
||||||
|
LUPArrayContainer *pointSimple_LAC;
|
||||||
|
LUPArrayContainer *pointPaper_LAC;
|
||||||
|
|
||||||
|
wxArrayOfLUPrec *condSymbolLUPArray; // Dynamic Conditional Symbology
|
||||||
|
|
||||||
|
wxArrayPtrVoid *pOBJLArray; // Used for Display Filtering
|
||||||
|
std::vector<wxString> OBJLDescriptions;
|
||||||
|
|
||||||
|
RuleHash *_symb_sym; // symbol symbolisation rules
|
||||||
|
std::unordered_map<int, std::string> m_natsur_hash;
|
||||||
|
// hash table for cacheing NATSUR string values
|
||||||
|
// from int attributes
|
||||||
|
|
||||||
|
int m_myConfig;
|
||||||
|
|
||||||
|
double lastLightLat;
|
||||||
|
double lastLightLon;
|
||||||
|
float m_GLMinCartographicLineWidth;
|
||||||
|
float m_GLMinSymbolLineWidth;
|
||||||
|
|
||||||
|
ChartSymbols m_chartSymbols;
|
||||||
|
|
||||||
|
void PLIB_LoadS57GlobalConfig(wxFileConfig *pconfig);
|
||||||
|
void PLIB_LoadS57ObjectConfig(wxFileConfig *pconfig);
|
||||||
|
void SetReducedBBox(LLBBox box) { reducedBBox = box; }
|
||||||
|
|
||||||
|
void RenderTex(char *str, char *col, wxPoint &r, wxPoint &pivot,
|
||||||
|
wxPoint origin, float scale, double rot_angle, float sym_len,
|
||||||
|
float sym_height, float seg_len);
|
||||||
|
int BuildLCSymbolTexture(char *str, char *col, wxPoint &r, wxPoint &pivot,
|
||||||
|
wxPoint origin, float scale, float sym_len,
|
||||||
|
float sym_height);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int S52_load_Plib(const wxString &PLib, bool b_forceLegacy);
|
||||||
|
bool S52_flush_Plib();
|
||||||
|
|
||||||
|
void PLIB_LoadS57Config();
|
||||||
|
|
||||||
|
void InitializeNatsurHash();
|
||||||
|
bool PreloadOBJLFromCSV(const wxString &csv_file);
|
||||||
|
|
||||||
|
int DoRenderObject(wxDC *pdcin, ObjRazRules *rzRules);
|
||||||
|
int DoRenderObjectTextOnly(wxDC *pdcin, ObjRazRules *rzRules);
|
||||||
|
|
||||||
|
// Area Renderers
|
||||||
|
int RenderToBufferAC(ObjRazRules *rzRules, Rules *rules,
|
||||||
|
render_canvas_parms *pb_spec);
|
||||||
|
int RenderToBufferAP(ObjRazRules *rzRules, Rules *rules,
|
||||||
|
render_canvas_parms *pb_spec);
|
||||||
|
|
||||||
|
int RenderToGLAC(ObjRazRules *rzRules, Rules *rules);
|
||||||
|
int RenderToGLAC_GLSL(ObjRazRules *rzRules, Rules *rules);
|
||||||
|
|
||||||
|
int RenderToGLAP(ObjRazRules *rzRules, Rules *rules);
|
||||||
|
int RenderToGLAP_GLSL(ObjRazRules *rzRules, Rules *rules);
|
||||||
|
|
||||||
|
// Object Renderers
|
||||||
|
int RenderTX(ObjRazRules *rzRules, Rules *rules);
|
||||||
|
int RenderTE(ObjRazRules *rzRules, Rules *rules);
|
||||||
|
int RenderSY(ObjRazRules *rzRules, Rules *rules);
|
||||||
|
int RenderLS(ObjRazRules *rzRules, Rules *rules);
|
||||||
|
int RenderLC(ObjRazRules *rzRules, Rules *rules);
|
||||||
|
int RenderMPS(ObjRazRules *rzRules, Rules *rules);
|
||||||
|
void RenderMPSArray(ObjRazRules *rzRules, std::vector<SoundingSym> array);
|
||||||
|
int RenderCARC(ObjRazRules *rzRules, Rules *rules);
|
||||||
|
char *RenderCS(ObjRazRules *rzRules, Rules *rules);
|
||||||
|
int RenderGLLS(ObjRazRules *rzRules, Rules *rules);
|
||||||
|
int RenderGLLC(ObjRazRules *rzRules, Rules *rules);
|
||||||
|
|
||||||
|
int RenderCARC_VBO(ObjRazRules *rzRules, Rules *rules);
|
||||||
|
int RenderCARC_GLSL(ObjRazRules *rzRules, Rules *rules);
|
||||||
|
|
||||||
|
void UpdateOBJLArray(S57Obj *obj);
|
||||||
|
|
||||||
|
int reduceLOD(double LOD_meters, int nPoints, double *source,
|
||||||
|
wxPoint2DDouble **dest, int *maskIn, int **maskOut);
|
||||||
|
int ComputeWinding(ObjRazRules *rzRules, Rules *rules);
|
||||||
|
|
||||||
|
int RenderLSLegacy(ObjRazRules *rzRules, Rules *rules);
|
||||||
|
int RenderLCLegacy(ObjRazRules *rzRules, Rules *rules);
|
||||||
|
int RenderGLLSLegacy(ObjRazRules *rzRules, Rules *rules);
|
||||||
|
int RenderGLLCLegacy(ObjRazRules *rzRules, Rules *rules);
|
||||||
|
int RenderLSPlugIn(ObjRazRules *rzRules, Rules *rules);
|
||||||
|
int RenderLCPlugIn(ObjRazRules *rzRules, Rules *rules);
|
||||||
|
int RenderLCTexture(ObjRazRules *rzRules, Rules *rules);
|
||||||
|
|
||||||
|
int RenderLS_Dash_GLSL(ObjRazRules *rzRules, Rules *rules);
|
||||||
|
|
||||||
|
void DrawDashLine(wxPen &pen, double x1, double y1, double x2, double y2);
|
||||||
|
|
||||||
|
render_canvas_parms *CreatePatternBufferSpec(ObjRazRules *rzRules,
|
||||||
|
Rules *rules, bool b_revrgb,
|
||||||
|
bool b_pot = false);
|
||||||
|
|
||||||
|
void RenderToBufferFilledPolygon(ObjRazRules *rzRules, S57Obj *obj,
|
||||||
|
S52color *c, render_canvas_parms *pb_spec,
|
||||||
|
render_canvas_parms *patt_spec);
|
||||||
|
|
||||||
|
void draw_lc_poly_texture(wxDC *pdc, wxColor &color, int width, wxPoint2DDouble *ptp,
|
||||||
|
int *mask, int npt, float sym_len, float sym_height,
|
||||||
|
float sym_factor, Rule *draw_rule, bool winding_cw);
|
||||||
|
void draw_lc_poly(wxDC *pdc, wxColor &color, int width, wxPoint *ptp,
|
||||||
|
int *mask, int npt, float sym_len, float sym_height,
|
||||||
|
float sym_factor, Rule *draw_rule);
|
||||||
|
|
||||||
|
bool RenderHPGL(ObjRazRules *rzRules, Rule *rule_in, wxPoint2DDouble &r,
|
||||||
|
float rot_angle = 0., double uScale = 1.0);
|
||||||
|
bool RenderRasterSymbol(ObjRazRules *rzRules, Rule *prule, wxPoint2DDouble &r,
|
||||||
|
float rot_angle = 0.);
|
||||||
|
bool RenderCachedVectorSymbol(ObjRazRules *rzRules, Rule *rule_in, wxPoint2DDouble &r,
|
||||||
|
float rot_angle, double uScale);
|
||||||
|
int BuildHPGLTexture(ObjRazRules *rzRules, Rule *rule_in, wxPoint2DDouble &r,
|
||||||
|
float rot_angle, double uScale);
|
||||||
|
|
||||||
|
void SetupSoundingFont();
|
||||||
|
bool RenderSoundingSymbol(ObjRazRules *rzRules, Rule *prule, wxPoint &r,
|
||||||
|
wxColor symColor, float rot_angle = 0.);
|
||||||
|
wxImage RuleXBMToImage(Rule *prule);
|
||||||
|
|
||||||
|
bool RenderText(wxDC *pdc, S52_TextC *ptext, double x, double y, wxRect2D *pRectDrawn,
|
||||||
|
S57Obj *pobj, bool bCheckOverlap);
|
||||||
|
|
||||||
|
bool CheckTextRectList(const wxRect2D &test_rect, S52_TextC *ptext);
|
||||||
|
int RenderT_All(ObjRazRules *rzRules, Rules *rules, bool bTX);
|
||||||
|
|
||||||
|
int PrioritizeLineFeature(ObjRazRules *rzRules, int npriority);
|
||||||
|
|
||||||
|
int dda_tri(wxPoint *ptp, S52color *c, render_canvas_parms *pb_spec,
|
||||||
|
render_canvas_parms *pPatt_spec);
|
||||||
|
int dda_trap(wxPoint *segs, int lseg, int rseg, int ytop, int ybot,
|
||||||
|
S52color *c, render_canvas_parms *pb_spec,
|
||||||
|
render_canvas_parms *pPatt_spec);
|
||||||
|
|
||||||
|
LUPrec *FindBestLUP(wxArrayOfLUPrec *LUPArray, unsigned int startIndex,
|
||||||
|
unsigned int count, S57Obj *pObj, bool bStrict);
|
||||||
|
|
||||||
|
void SetGLClipRect(const VPointCompat &vp, const wxRect &rect);
|
||||||
|
|
||||||
|
char *_getParamVal(ObjRazRules *rzRules, char *str, char *buf, int bsz);
|
||||||
|
S52_TextC *S52_PL_parseTX(ObjRazRules *rzRules, Rules *rules, char *cmd);
|
||||||
|
char *_parseTEXT(ObjRazRules *rzRules, S52_TextC *text, char *str0);
|
||||||
|
S52_TextC *S52_PL_parseTE(ObjRazRules *rzRules, Rules *rules, char *cmd);
|
||||||
|
|
||||||
|
Rules *StringToRules(const wxString &str_in);
|
||||||
|
void GetAndAddCSRules(ObjRazRules *rzRules, Rules *rules);
|
||||||
|
|
||||||
|
void DestroyPattRules(RuleHash *rh);
|
||||||
|
void DestroyRules(RuleHash *rh);
|
||||||
|
void DestroyLUPArray(wxArrayOfLUPrec *pLUPArray);
|
||||||
|
|
||||||
|
bool TextRenderCheck(ObjRazRules *rzRules);
|
||||||
|
bool inter_tri_rect(wxPoint *ptp, render_canvas_parms *pb_spec);
|
||||||
|
|
||||||
|
bool GetPointPixArray(ObjRazRules *rzRules, wxPoint2DDouble *pd, wxPoint *pp,
|
||||||
|
int nv);
|
||||||
|
bool GetPointPixSingle(ObjRazRules *rzRules, float north, float east,
|
||||||
|
wxPoint *r);
|
||||||
|
void GetPixPointSingle(int pixx, int pixy, double *plat, double *plon);
|
||||||
|
void GetPixPointSingleNoRotate(int pixx, int pixy, double *plat,
|
||||||
|
double *plon);
|
||||||
|
bool GetDoublePointPixSingle(ObjRazRules *rzRules, float north, float east,
|
||||||
|
wxPoint2DDouble *r);
|
||||||
|
bool GetDoublePointPixArray(ObjRazRules *rzRules, wxPoint2DDouble *pd, wxPoint2DDouble *pp,
|
||||||
|
int nv);
|
||||||
|
|
||||||
|
void GetLLFromPix(const wxPoint2DDouble &p, double *lat, double *lon);
|
||||||
|
wxPoint GetPixFromLL(double lat, double lon);
|
||||||
|
wxPoint GetPixFromLLROT(double lat, double lon, double rotation);
|
||||||
|
wxPoint2DDouble GetDoublePixFromLL(double lat, double lon);
|
||||||
|
wxPoint2DDouble GetDoublePixFromLLROT(double lat, double lon,
|
||||||
|
double rotation);
|
||||||
|
|
||||||
|
LLBBox &GetBBox() { return BBox; }
|
||||||
|
LLBBox GetReducedBBox() { return reducedBBox; }
|
||||||
|
|
||||||
|
wxString m_plib_file;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of pixels per millimeter of the canvas.
|
||||||
|
*
|
||||||
|
* @note Set by parent, used to scale symbols/lines/patterns.
|
||||||
|
*/
|
||||||
|
float canvas_pix_per_mm;
|
||||||
|
double m_rv_scale_factor;
|
||||||
|
float m_display_size_mm;
|
||||||
|
size_t m_display_width;
|
||||||
|
|
||||||
|
S52color m_unused_color;
|
||||||
|
wxColor m_unused_wxColor;
|
||||||
|
|
||||||
|
bool bUseRasterSym;
|
||||||
|
|
||||||
|
wxDC *m_pdc; // The current DC
|
||||||
|
|
||||||
|
// #ifdef ocpnUSE_GL
|
||||||
|
wxGLContext *m_glcc;
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
int *ledge;
|
||||||
|
int *redge;
|
||||||
|
|
||||||
|
int m_colortable_index;
|
||||||
|
int m_colortable_index_save;
|
||||||
|
|
||||||
|
TextObjList m_textObjList;
|
||||||
|
|
||||||
|
wxString m_ColorScheme;
|
||||||
|
|
||||||
|
bool m_lightsOff;
|
||||||
|
bool m_anchorOn;
|
||||||
|
bool m_qualityOfDataOn;
|
||||||
|
|
||||||
|
long m_state_hash;
|
||||||
|
|
||||||
|
bool m_txf_ready;
|
||||||
|
int m_txf_avg_char_width;
|
||||||
|
int m_txf_avg_char_height;
|
||||||
|
CARC_Hash m_CARC_hashmap;
|
||||||
|
CARC_DL_Hash m_CARC_DL_hashmap;
|
||||||
|
RenderFromHPGL *HPGL;
|
||||||
|
|
||||||
|
TexFont *m_txf;
|
||||||
|
DepthFont m_texSoundings;
|
||||||
|
bool m_benableGLLS;
|
||||||
|
DisCat m_nDisplayCategory;
|
||||||
|
ArrayOfNoshow m_noshow_array;
|
||||||
|
ArrayOfNoshow m_saved_noshow;
|
||||||
|
|
||||||
|
int m_coreVersionMajor;
|
||||||
|
int m_coreVersionMinor;
|
||||||
|
int m_coreVersionPatch;
|
||||||
|
|
||||||
|
// GL Options, set by core depending on hardware capability
|
||||||
|
bool m_useStencil;
|
||||||
|
bool m_useStencilAP;
|
||||||
|
bool m_useScissors;
|
||||||
|
bool m_useFBO;
|
||||||
|
bool m_useVBO;
|
||||||
|
bool m_GLAC_VBO;
|
||||||
|
int m_TextureFormat;
|
||||||
|
bool m_GLLineSmoothing;
|
||||||
|
bool m_GLPolygonSmoothing;
|
||||||
|
wxFont *m_soundFont;
|
||||||
|
bool m_useGLSL;
|
||||||
|
|
||||||
|
double m_displayScale;
|
||||||
|
|
||||||
|
VPointCompat vp_plib;
|
||||||
|
LLBBox BBox;
|
||||||
|
#define TXF_CACHE 8
|
||||||
|
TexFontCache s_txf[TXF_CACHE];
|
||||||
|
wxString m_renderer_string;
|
||||||
|
wxFont *ChartTextDefaultFont;
|
||||||
|
|
||||||
|
LLBBox reducedBBox;
|
||||||
|
std::unordered_map<std::string, int> vector_symbol_cache;
|
||||||
|
std::unordered_map<std::string, int> lc_vector_symbol_cache;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define HPGL_FILLED true
|
||||||
|
|
||||||
|
class RenderFromHPGL {
|
||||||
|
public:
|
||||||
|
RenderFromHPGL(s52plib *plibarg);
|
||||||
|
~RenderFromHPGL();
|
||||||
|
|
||||||
|
void SetTargetDC(wxDC *pdc);
|
||||||
|
void SetTargetOpenGl();
|
||||||
|
#if wxUSE_GRAPHICS_CONTEXT
|
||||||
|
void SetTargetGCDC(wxGCDC *gdc);
|
||||||
|
#endif
|
||||||
|
void SetVP(VPointCompat *pVP) { m_vp = pVP; }
|
||||||
|
void SetContentScaleFactor(double factor) { m_content_scale_factor = factor; }
|
||||||
|
bool Render(char *str, char *col, wxPoint2DDouble &r, wxPoint &pivot, wxPoint origin,
|
||||||
|
float scale, double rot_angle, bool bSymbol);
|
||||||
|
wxBrush *getBrush() { return brush; }
|
||||||
|
|
||||||
|
GLUtesselator *m_tobj;
|
||||||
|
int s_odc_tess_vertex_idx;
|
||||||
|
int s_odc_tess_vertex_idx_this;
|
||||||
|
int s_odc_tess_buf_len;
|
||||||
|
GLenum s_odc_tess_mode;
|
||||||
|
int s_odc_nvertex;
|
||||||
|
GLfloat *s_odc_tess_work_buf;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const char *findColorNameInRef(char colorCode, char *col);
|
||||||
|
void RotatePoint(wxPoint2DDouble &point, wxPoint origin, double angle);
|
||||||
|
wxPoint ParsePoint(wxString &argument);
|
||||||
|
void SetPen();
|
||||||
|
void Line(wxPoint2DDouble from, wxPoint2DDouble to);
|
||||||
|
void Circle(wxPoint2DDouble center, int radius, bool filled = false);
|
||||||
|
void Polygon();
|
||||||
|
|
||||||
|
void DrawPolygonTessellated(int n, wxPoint points[], wxCoord xoffset,
|
||||||
|
wxCoord yoffset);
|
||||||
|
void DrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset,
|
||||||
|
float scale, float angle);
|
||||||
|
|
||||||
|
s52plib *plib;
|
||||||
|
double scaleFactor;
|
||||||
|
|
||||||
|
wxDC *targetDC;
|
||||||
|
#if wxUSE_GRAPHICS_CONTEXT
|
||||||
|
wxGCDC *targetGCDC;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
wxColor penColor;
|
||||||
|
wxPen *pen;
|
||||||
|
wxColor brushColor;
|
||||||
|
wxBrush *brush;
|
||||||
|
long penWidth;
|
||||||
|
int transparency;
|
||||||
|
double m_content_scale_factor;
|
||||||
|
|
||||||
|
int noPoints;
|
||||||
|
wxPoint polygon[100];
|
||||||
|
|
||||||
|
float m_currentColor[4];
|
||||||
|
|
||||||
|
bool renderToDC;
|
||||||
|
bool renderToOpenGl;
|
||||||
|
bool renderToGCDC;
|
||||||
|
VPointCompat *m_vp;
|
||||||
|
|
||||||
|
float *workBuf;
|
||||||
|
size_t workBufSize;
|
||||||
|
unsigned int workBufIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //_S52PLIB_H_
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Project: OpenCPN
|
||||||
|
* Purpose: Global Build Options
|
||||||
|
* Author: David Register
|
||||||
|
*
|
||||||
|
***************************************************************************
|
||||||
|
* Copyright (C) 2010 by David S. Register *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 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 the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
|
***************************************************************************
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// OpenGL Build options for S52PLIB
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
#ifndef _S52PLIBGL_H_
|
||||||
|
#define _S52PLIBGL_H_
|
||||||
|
|
||||||
|
//#include "config.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__OCPN__ANDROID__)
|
||||||
|
#include <qopengl.h>
|
||||||
|
#include <GL/gl_private.h> // this is a cut-down version of gl.h
|
||||||
|
#include <GLES2/gl2.h>
|
||||||
|
#elif defined(__MSVC__)
|
||||||
|
#include "glew.h"
|
||||||
|
#elif defined(__WXOSX__)
|
||||||
|
#include <OpenGL/gl.h>
|
||||||
|
#include <OpenGL/glu.h>
|
||||||
|
typedef void (* _GLUfuncptr)();
|
||||||
|
#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0
|
||||||
|
#elif defined(__WXQT__) || defined(__WXGTK__)
|
||||||
|
#include <GL/glew.h>
|
||||||
|
#include <GL/glu.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // __FILE__
|
||||||
646
docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/s52s57.h
Normal file
646
docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/s52s57.h
Normal file
@@ -0,0 +1,646 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Project: OpenCP
|
||||||
|
* Purpose: S52 PLIB and S57 Chart data types
|
||||||
|
* Author: David Register
|
||||||
|
*
|
||||||
|
***************************************************************************
|
||||||
|
* Copyright (C) 2010 by David S. Register *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 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 the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
|
***************************************************************************
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _S52S57_H_
|
||||||
|
#define _S52S57_H_
|
||||||
|
|
||||||
|
#include "bbox.h"
|
||||||
|
#include "color_types.h"
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <vector>
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
#define CURRENT_SENC_FORMAT_VERSION 201
|
||||||
|
|
||||||
|
#define OBJL_NAME_LEN 6
|
||||||
|
|
||||||
|
// Fwd Defns
|
||||||
|
class wxArrayOfS57attVal;
|
||||||
|
class OGREnvelope;
|
||||||
|
class OGRGeometry;
|
||||||
|
class VE_Element;
|
||||||
|
class VC_Element;
|
||||||
|
|
||||||
|
class wxRect2D {
|
||||||
|
public:
|
||||||
|
double x;
|
||||||
|
double y;
|
||||||
|
double width;
|
||||||
|
double height;
|
||||||
|
|
||||||
|
wxRect2D();
|
||||||
|
wxRect2D(double xx, double yy, double w, double h);
|
||||||
|
void SetX(double _x){ x = _x;}
|
||||||
|
void SetY(double _y){ y = _y;}
|
||||||
|
void SetWidth(double _width){ width = _width;}
|
||||||
|
void SetHeight(double _height){ height = _height;}
|
||||||
|
|
||||||
|
bool Intersects(const wxRect2D& other,
|
||||||
|
double epsilon = 1e-6) const;
|
||||||
|
wxRect2D Union(const wxRect2D& other) const;
|
||||||
|
bool IsEmpty() const {return width <= 0.0 || height <= 0.0;}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// name of the addressed look up table set (fifth letter)
|
||||||
|
typedef enum _LUPname {
|
||||||
|
SIMPLIFIED = 'L', // points
|
||||||
|
PAPER_CHART = 'R', // points
|
||||||
|
LINES = 'S', // lines
|
||||||
|
PLAIN_BOUNDARIES = 'N', // areas
|
||||||
|
SYMBOLIZED_BOUNDARIES = 'O', // areas
|
||||||
|
LUPNAME_NUM = 5
|
||||||
|
} LUPname;
|
||||||
|
|
||||||
|
// Addressed Object Type
|
||||||
|
typedef enum _Object_t {
|
||||||
|
POINT_T = 'P',
|
||||||
|
LINES_T = 'L',
|
||||||
|
AREAS_T = 'A',
|
||||||
|
OBJ_NUM = 3 // number of object type
|
||||||
|
} Object_t;
|
||||||
|
|
||||||
|
// Display Priority
|
||||||
|
typedef enum _DisPrio {
|
||||||
|
PRIO_NODATA = '0', // no data fill area pattern
|
||||||
|
PRIO_GROUP1 = '1', // S57 group 1 filled areas
|
||||||
|
PRIO_AREA_1 = '2', // superimposed areas
|
||||||
|
PRIO_AREA_2 = '3', // superimposed areas also water features
|
||||||
|
PRIO_SYMB_POINT = '4', // point symbol also land features
|
||||||
|
PRIO_SYMB_LINE = '5', // line symbol also restricted areas
|
||||||
|
PRIO_SYMB_AREA = '6', // area symbol also traffic areas
|
||||||
|
PRIO_ROUTEING = '7', // routeing lines
|
||||||
|
PRIO_HAZARDS = '8', // hazards
|
||||||
|
PRIO_MARINERS = '9', // VRM, EBL, own ship
|
||||||
|
PRIO_NUM = 10 // number of priority levels
|
||||||
|
|
||||||
|
} DisPrio;
|
||||||
|
|
||||||
|
// RADAR Priority
|
||||||
|
typedef enum _RadPrio {
|
||||||
|
RAD_OVER = 'O', // presentation on top of RADAR
|
||||||
|
RAD_SUPP = 'S', // presentation suppressed by RADAR
|
||||||
|
RAD_NUM = 2
|
||||||
|
} RadPrio;
|
||||||
|
|
||||||
|
// PixelPtr type flags
|
||||||
|
enum {
|
||||||
|
ID_EMPTY = 0,
|
||||||
|
ID_wxBitmap,
|
||||||
|
ID_RGBA,
|
||||||
|
ID_GL_PATT_SPEC,
|
||||||
|
ID_RGB_PATT_SPEC,
|
||||||
|
ID_GLIST
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// display category type
|
||||||
|
typedef enum _DisCat {
|
||||||
|
DISPLAYBASE = 'D', //
|
||||||
|
STANDARD = 'S', //
|
||||||
|
OTHER = 'O', // O for OTHER
|
||||||
|
MARINERS_STANDARD = 'M', // Mariner specified
|
||||||
|
MARINERS_OTHER, // value not defined
|
||||||
|
DISP_CAT_NUM, // value not defined
|
||||||
|
} DisCat;
|
||||||
|
|
||||||
|
#define MASK_POINT 1
|
||||||
|
#define MASK_LINE 2
|
||||||
|
#define MASK_AREA 4
|
||||||
|
#define MASK_MPS 8
|
||||||
|
#define MASK_ALL MASK_POINT + MASK_LINE + MASK_AREA + MASK_MPS
|
||||||
|
|
||||||
|
typedef enum _Rules_t {
|
||||||
|
RUL_NONE, // no rule type (init)
|
||||||
|
RUL_TXT_TX, // TX
|
||||||
|
RUL_TXT_TE, // TE
|
||||||
|
RUL_SYM_PT, // SY
|
||||||
|
RUL_SIM_LN, // LS
|
||||||
|
RUL_COM_LN, // LC
|
||||||
|
RUL_ARE_CO, // AC
|
||||||
|
RUL_ARE_PA, // AP
|
||||||
|
RUL_CND_SY, // CS
|
||||||
|
RUL_MUL_SG, // Multipoint Sounding
|
||||||
|
RUL_ARC_2C // Circular Arc, used for sector lights, opencpn private
|
||||||
|
} Rules_t;
|
||||||
|
|
||||||
|
//-- SYMBOLISATION MODULE STRUCTURE -----------------------------
|
||||||
|
// position parameter: LINE, PATTERN, SYMBOL
|
||||||
|
typedef struct _position {
|
||||||
|
union {
|
||||||
|
int dummy1, PAMI, dummy2;
|
||||||
|
} minDist;
|
||||||
|
union {
|
||||||
|
int dummy1, PAMA, dummy2;
|
||||||
|
} maxDist;
|
||||||
|
union {
|
||||||
|
int LICL, PACL, SYCL;
|
||||||
|
} pivot_x;
|
||||||
|
union {
|
||||||
|
int LIRW, PARW, SYRW;
|
||||||
|
} pivot_y;
|
||||||
|
union {
|
||||||
|
int LIHL, PAHL, SYHL;
|
||||||
|
} bnbox_w;
|
||||||
|
union {
|
||||||
|
int LIVL, PAVL, SYVL;
|
||||||
|
} bnbox_h;
|
||||||
|
union {
|
||||||
|
int LBXC, PBXC, SBXC;
|
||||||
|
} bnbox_x; // UpLft crnr
|
||||||
|
union {
|
||||||
|
int LBXR, PBXR, SBXR;
|
||||||
|
} bnbox_y; // UpLft crnr
|
||||||
|
} position;
|
||||||
|
|
||||||
|
// rule parameter for : LINE, PATTERN, SYMBOL
|
||||||
|
typedef struct _Rule {
|
||||||
|
int RCID;
|
||||||
|
union {
|
||||||
|
char LINM[8], PANM[8], SYNM[8];
|
||||||
|
} name;
|
||||||
|
union {
|
||||||
|
char dummy, PADF, SYDF;
|
||||||
|
} definition;
|
||||||
|
union {
|
||||||
|
char dummy1, PATP, dummy2;
|
||||||
|
} fillType;
|
||||||
|
union {
|
||||||
|
char dummy1, PASP, dummy2;
|
||||||
|
} spacing;
|
||||||
|
union {
|
||||||
|
position line, patt, symb;
|
||||||
|
} pos;
|
||||||
|
union {
|
||||||
|
wxString *LXPO, *PXPO, *SXPO;
|
||||||
|
} exposition;
|
||||||
|
union {
|
||||||
|
wxString *dummy, *PBTM, *SBTM;
|
||||||
|
} bitmap;
|
||||||
|
union {
|
||||||
|
char *LCRF, *PCRF, *SCRF;
|
||||||
|
} colRef;
|
||||||
|
union {
|
||||||
|
char *LVCT, *PVCT, *SVCT;
|
||||||
|
} vector;
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
int parm0; // always indicates form of pixelPtr
|
||||||
|
int parm1; // integer parameters
|
||||||
|
int parm2;
|
||||||
|
int parm3;
|
||||||
|
int parm4;
|
||||||
|
int parm5;
|
||||||
|
int parm6;
|
||||||
|
int parm7;
|
||||||
|
void *pixelPtr; // opaque pointer
|
||||||
|
|
||||||
|
} Rule;
|
||||||
|
|
||||||
|
typedef struct _Rules {
|
||||||
|
Rules_t ruleType;
|
||||||
|
char *INSTstr; // Symbology Instruction string
|
||||||
|
Rule *razRule; // rule
|
||||||
|
char *INST0; // Head of the entire object Instruction string
|
||||||
|
int n_sequence; // sequence number in list, used to identify a particular
|
||||||
|
// rule
|
||||||
|
bool b_private_razRule; // marker indicating that razRule should be free'd on
|
||||||
|
// Rules destroy
|
||||||
|
struct _Rules *next;
|
||||||
|
} Rules;
|
||||||
|
|
||||||
|
// LOOKUP MODULE CLASS
|
||||||
|
|
||||||
|
class LUPrec {
|
||||||
|
public:
|
||||||
|
~LUPrec() { ATTArray.clear(); };
|
||||||
|
int RCID; // record identifier
|
||||||
|
char OBCL[7]; // Name (6 char) '\0' terminated
|
||||||
|
Object_t FTYP; // 'A' Area, 'L' Line, 'P' Point
|
||||||
|
DisPrio DPRI; // Display Priority
|
||||||
|
RadPrio RPRI; // 'O' or 'S', Radar Priority
|
||||||
|
LUPname TNAM; // FTYP: areas, points, lines
|
||||||
|
std::vector<std::string> ATTArray; // Array of LUP Attributes
|
||||||
|
wxString INST; // Instruction Field (rules)
|
||||||
|
DisCat DISC; // Display Categorie: D/S/O, DisplayBase, Standard, Other
|
||||||
|
int LUCM; // Look-Up Comment (PLib3.x put 'groupes' here,
|
||||||
|
// hence 'int', but its a string in the specs)
|
||||||
|
int nSequence; // A sequence number, indicating order of encounter in
|
||||||
|
// the PLIB file
|
||||||
|
Rules *ruleList; // rasterization rule list
|
||||||
|
};
|
||||||
|
|
||||||
|
// Conditional Symbology
|
||||||
|
typedef struct _Cond {
|
||||||
|
const char *name;
|
||||||
|
void *(*condInst)(void *param);
|
||||||
|
} Cond;
|
||||||
|
|
||||||
|
class S52_TextC {
|
||||||
|
public:
|
||||||
|
S52_TextC();
|
||||||
|
~S52_TextC();
|
||||||
|
|
||||||
|
wxString frmtd; // formated text string
|
||||||
|
char hjust;
|
||||||
|
char vjust;
|
||||||
|
char space;
|
||||||
|
char style; // CHARS
|
||||||
|
char weight; // CHARS
|
||||||
|
char width; // CHARS
|
||||||
|
int bsize; // CHARS -body size
|
||||||
|
int xoffs; // text offsets, in units of bsize
|
||||||
|
int yoffs; //
|
||||||
|
S52color *pcol; // pointer to S52colour
|
||||||
|
int dis; // display
|
||||||
|
wxFont *pFont;
|
||||||
|
int rul_seq_creator; // sequence number of the Rule creating this object
|
||||||
|
int RGBA_width;
|
||||||
|
int RGBA_height;
|
||||||
|
int rendered_char_height;
|
||||||
|
wxRect2D
|
||||||
|
rText; // rectangle of the text as currently rendered, used for declutter
|
||||||
|
bool bnat; // frmtd is National text, UTF-8 encoded
|
||||||
|
bool bspecial_char; // frmtd has special ASCII characters, i.e. > 127
|
||||||
|
int avgCharWidth;
|
||||||
|
int texobj;
|
||||||
|
int text_width;
|
||||||
|
int text_height;
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// WARNING: must be in sync OGRatt_t
|
||||||
|
|
||||||
|
typedef enum _OGRatt_t {
|
||||||
|
OGR_INT,
|
||||||
|
OGR_INT_LST,
|
||||||
|
OGR_REAL,
|
||||||
|
OGR_REAL_LST,
|
||||||
|
OGR_STR,
|
||||||
|
} OGRatt_t;
|
||||||
|
|
||||||
|
typedef struct _S57attVal {
|
||||||
|
void *value;
|
||||||
|
OGRatt_t valType;
|
||||||
|
} S57attVal;
|
||||||
|
|
||||||
|
WX_DEFINE_ARRAY(S57attVal *, wxArrayOfS57attVal);
|
||||||
|
|
||||||
|
typedef struct _OBJLElement {
|
||||||
|
char OBJLName[OBJL_NAME_LEN];
|
||||||
|
int nViz;
|
||||||
|
} OBJLElement;
|
||||||
|
|
||||||
|
// OGR primitive type
|
||||||
|
typedef enum _geoPrim_t {
|
||||||
|
GEO_POINT,
|
||||||
|
GEO_LINE,
|
||||||
|
GEO_AREA,
|
||||||
|
GEO_META,
|
||||||
|
GEO_PRIM, // number of primitive
|
||||||
|
} GeoPrim_t;
|
||||||
|
|
||||||
|
typedef struct _pt {
|
||||||
|
double x;
|
||||||
|
double y;
|
||||||
|
} pt;
|
||||||
|
|
||||||
|
// Fwd References
|
||||||
|
class s57chart;
|
||||||
|
class S57Obj;
|
||||||
|
class OGRFeature;
|
||||||
|
class PolyTessGeo;
|
||||||
|
class line_segment_element;
|
||||||
|
class PI_line_segment_element;
|
||||||
|
|
||||||
|
struct chart_context {
|
||||||
|
std::unordered_map<unsigned, VC_Element *> *m_pvc_hash;
|
||||||
|
std::unordered_map<unsigned, VE_Element *> *m_pve_hash;
|
||||||
|
double ref_lat;
|
||||||
|
double ref_lon;
|
||||||
|
wxArrayPtrVoid *pFloatingATONArray;
|
||||||
|
wxArrayPtrVoid *pRigidATONArray;
|
||||||
|
void *chart;
|
||||||
|
double safety_contour;
|
||||||
|
float *vertex_buffer;
|
||||||
|
int vboID;
|
||||||
|
int chart_type;
|
||||||
|
int chart_scale;
|
||||||
|
std::list<S57Obj *> *(s57chart::*pt2GetAssociatedObjects)(S57Obj *obj);
|
||||||
|
};
|
||||||
|
|
||||||
|
class LineGeometryDescriptor {
|
||||||
|
public:
|
||||||
|
double extent_s_lat;
|
||||||
|
double extent_n_lat;
|
||||||
|
double extent_w_lon;
|
||||||
|
double extent_e_lon;
|
||||||
|
int indexCount;
|
||||||
|
int *indexTable;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct _MultipointGeometryDescriptor {
|
||||||
|
double extent_s_lat;
|
||||||
|
double extent_n_lat;
|
||||||
|
double extent_w_lon;
|
||||||
|
double extent_e_lon;
|
||||||
|
int pointCount;
|
||||||
|
void *pointTable;
|
||||||
|
} MultipointGeometryDescriptor;
|
||||||
|
|
||||||
|
class S57Obj {
|
||||||
|
public:
|
||||||
|
// Public Methods
|
||||||
|
S57Obj();
|
||||||
|
~S57Obj();
|
||||||
|
|
||||||
|
S57Obj(const char *featureName);
|
||||||
|
|
||||||
|
wxString GetAttrValueAsString(const char *attr);
|
||||||
|
int GetAttributeIndex(const char *AttrSeek);
|
||||||
|
|
||||||
|
bool AddIntegerAttribute(const char *acronym, int val);
|
||||||
|
bool AddIntegerListAttribute(const char *acronym, int *pval, int nValue);
|
||||||
|
bool AddDoubleAttribute(const char *acronym, double val);
|
||||||
|
bool AddDoubleListAttribute(const char *acronym, double *pval, int nValue);
|
||||||
|
bool AddStringAttribute(const char *acronym, char *val);
|
||||||
|
|
||||||
|
bool SetPointGeometry(double lat, double lon, double ref_lat, double ref_lon);
|
||||||
|
bool SetLineGeometry(LineGeometryDescriptor *pGeo, GeoPrim_t geoType,
|
||||||
|
double ref_lat, double ref_lon);
|
||||||
|
bool SetAreaGeometry(PolyTessGeo *ppg, double ref_lat, double ref_lon);
|
||||||
|
bool SetMultipointGeometry(MultipointGeometryDescriptor *pGeo, double ref_lat,
|
||||||
|
double ref_lon);
|
||||||
|
|
||||||
|
// Private Methods
|
||||||
|
private:
|
||||||
|
void Init();
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Instance Data
|
||||||
|
char FeatureName[8];
|
||||||
|
GeoPrim_t Primitive_type;
|
||||||
|
|
||||||
|
char *att_array;
|
||||||
|
wxArrayOfS57attVal *attVal;
|
||||||
|
int n_attr;
|
||||||
|
|
||||||
|
int iOBJL;
|
||||||
|
int Index;
|
||||||
|
|
||||||
|
double x; // for POINT
|
||||||
|
double y;
|
||||||
|
double z;
|
||||||
|
int npt; // number of points as needed by arrays
|
||||||
|
|
||||||
|
pt *geoPt; // used for cm93 line feature select check
|
||||||
|
|
||||||
|
double *geoPtz; // an array[3] for MultiPoint, SM with Z, i.e. depth
|
||||||
|
double *geoPtMulti; // an array[2] for MultiPoint, lat/lon to make bbox
|
||||||
|
// of decomposed points
|
||||||
|
PolyTessGeo *pPolyTessGeo;
|
||||||
|
|
||||||
|
LLBBox BBObj; // lat/lon BBox of the rendered object
|
||||||
|
double m_lat; // The lat/lon of the object's "reference" point
|
||||||
|
double m_lon;
|
||||||
|
|
||||||
|
Rules *CSrules; // per object conditional symbology
|
||||||
|
int bCS_Added;
|
||||||
|
|
||||||
|
S52_TextC *FText;
|
||||||
|
int bFText_Added;
|
||||||
|
wxRect rText;
|
||||||
|
|
||||||
|
int Scamin; // SCAMIN attribute decoded during load
|
||||||
|
int SuperScamin;
|
||||||
|
bool bIsClone;
|
||||||
|
int nRef; // Reference counter, to signal OK for deletion
|
||||||
|
bool bIsAton; // This object is an aid-to-navigation
|
||||||
|
bool bIsAssociable; // This object is DRGARE or DEPARE
|
||||||
|
|
||||||
|
int m_n_lsindex;
|
||||||
|
int *m_lsindex_array;
|
||||||
|
int m_n_edge_max_points;
|
||||||
|
line_segment_element *m_ls_list;
|
||||||
|
PI_line_segment_element *m_ls_list_legacy;
|
||||||
|
|
||||||
|
DisCat m_DisplayCat;
|
||||||
|
int m_DPRI; // display priority, assigned from initial LUP
|
||||||
|
// May be adjusted by CS
|
||||||
|
bool m_bcategory_mutable; // CS procedure may move this object to a higher
|
||||||
|
// category. Used as a hint to rendering filter
|
||||||
|
// logic
|
||||||
|
|
||||||
|
// This transform converts from object geometry
|
||||||
|
// to SM coordinates.
|
||||||
|
double x_rate; // These auxiliary transform coefficients are
|
||||||
|
double y_rate; // to be used in GetPointPix() and friends
|
||||||
|
double x_origin; // on a per-object basis if necessary
|
||||||
|
double y_origin;
|
||||||
|
|
||||||
|
chart_context *m_chart_context; // per-chart constants, carried in each
|
||||||
|
// object for convenience
|
||||||
|
int auxParm0; // some per-object auxiliary parameters, used for OpenGL
|
||||||
|
int auxParm1;
|
||||||
|
int auxParm2;
|
||||||
|
int auxParm3;
|
||||||
|
|
||||||
|
bool bBBObj_valid;
|
||||||
|
bool bOK_to_Render;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::vector<S57Obj *> S57ObjVector;
|
||||||
|
|
||||||
|
typedef struct _sm_parms {
|
||||||
|
double easting_vp_center;
|
||||||
|
double northing_vp_center;
|
||||||
|
} sm_parms;
|
||||||
|
|
||||||
|
WX_DEFINE_ARRAY_PTR(Rules *, ArrayOfRules);
|
||||||
|
|
||||||
|
typedef struct _mps_container {
|
||||||
|
ArrayOfRules *cs_rules;
|
||||||
|
} mps_container;
|
||||||
|
|
||||||
|
// object rasterization rules
|
||||||
|
typedef struct _ObjRazRules {
|
||||||
|
LUPrec *LUP;
|
||||||
|
S57Obj *obj;
|
||||||
|
sm_parms *sm_transform_parms;
|
||||||
|
struct _ObjRazRules *child; // child list, used only for MultiPoint Soundings
|
||||||
|
struct _ObjRazRules *next;
|
||||||
|
struct _mps_container *mps;
|
||||||
|
} ObjRazRules;
|
||||||
|
|
||||||
|
WX_DECLARE_LIST(ObjRazRules, ListOfObjRazRules);
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Used for s52 Fast Polygon Renderer
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
class render_canvas_parms {
|
||||||
|
public:
|
||||||
|
render_canvas_parms(void);
|
||||||
|
~render_canvas_parms(void);
|
||||||
|
|
||||||
|
unsigned char *pix_buff;
|
||||||
|
int lclip;
|
||||||
|
int rclip;
|
||||||
|
int pb_pitch;
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
int w_pot;
|
||||||
|
int h_pot;
|
||||||
|
int depth;
|
||||||
|
bool b_stagger;
|
||||||
|
int OGL_tex_name;
|
||||||
|
bool b_revrgb;
|
||||||
|
};
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Classes used to create arrays of geometry elements
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class VE_Element {
|
||||||
|
public:
|
||||||
|
unsigned int index;
|
||||||
|
unsigned int nCount;
|
||||||
|
float *pPoints;
|
||||||
|
int max_priority;
|
||||||
|
size_t vbo_offset;
|
||||||
|
LLBBox edgeBBox;
|
||||||
|
};
|
||||||
|
|
||||||
|
class VC_Element {
|
||||||
|
public:
|
||||||
|
unsigned int index;
|
||||||
|
float *pPoint;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::vector<VE_Element *> VE_ElementVector;
|
||||||
|
typedef std::vector<VC_Element *> VC_ElementVector;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
TYPE_CE = 0,
|
||||||
|
TYPE_CC,
|
||||||
|
TYPE_EC,
|
||||||
|
TYPE_EE,
|
||||||
|
TYPE_EE_REV
|
||||||
|
} SegmentType;
|
||||||
|
|
||||||
|
class connector_segment {
|
||||||
|
public:
|
||||||
|
int vbo_offset;
|
||||||
|
int max_priority_cs;
|
||||||
|
float cs_lat_avg; // segment centroid
|
||||||
|
float cs_lon_avg;
|
||||||
|
};
|
||||||
|
|
||||||
|
class line_segment_element {
|
||||||
|
public:
|
||||||
|
int priority;
|
||||||
|
union {
|
||||||
|
connector_segment *pcs;
|
||||||
|
VE_Element *pedge;
|
||||||
|
};
|
||||||
|
SegmentType ls_type;
|
||||||
|
|
||||||
|
line_segment_element *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
#if 0 // TODO
|
||||||
|
class line_segment_element_legacy
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
size_t vbo_offset;
|
||||||
|
size_t n_points;
|
||||||
|
int priority;
|
||||||
|
float lat_max; // segment bounding box
|
||||||
|
float lat_min;
|
||||||
|
float lon_max;
|
||||||
|
float lon_min;
|
||||||
|
int type;
|
||||||
|
void *private0;
|
||||||
|
|
||||||
|
line_segment_element *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class connector_segment
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void *start;
|
||||||
|
void *end;
|
||||||
|
SegmentType type;
|
||||||
|
int vbo_offset;
|
||||||
|
int max_priority;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class connector_key {
|
||||||
|
public:
|
||||||
|
connector_key() { memset(k, 0, sizeof k); }
|
||||||
|
|
||||||
|
connector_key(SegmentType t, int a, int b) { set(t, a, b); }
|
||||||
|
|
||||||
|
void set(SegmentType t, int a, int b) {
|
||||||
|
memcpy(k, &a, sizeof a);
|
||||||
|
memcpy(&k[sizeof a], &b, sizeof b);
|
||||||
|
k[sizeof(a) + sizeof(b)] = (unsigned char)t;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long hash() const;
|
||||||
|
|
||||||
|
unsigned char k[sizeof(int) + sizeof(int) + sizeof(char)];
|
||||||
|
};
|
||||||
|
|
||||||
|
class connHash {
|
||||||
|
public:
|
||||||
|
connHash() {}
|
||||||
|
unsigned long operator()(const connector_key &k) const { return k.hash(); }
|
||||||
|
|
||||||
|
connHash &operator=(const connHash &) { return *this; }
|
||||||
|
};
|
||||||
|
|
||||||
|
// comparison operator
|
||||||
|
class connEqual {
|
||||||
|
public:
|
||||||
|
connEqual() {}
|
||||||
|
bool operator()(const connector_key &a, const connector_key &b) const {
|
||||||
|
return memcmp(a.k, b.k, sizeof b.k) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
connEqual &operator=(const connEqual &) { return *this; }
|
||||||
|
};
|
||||||
|
|
||||||
|
WX_DECLARE_HASH_MAP(connector_key, connector_segment *, connHash, connEqual,
|
||||||
|
connected_segment_hash);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,756 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
*
|
||||||
|
* Project: OpenCPN
|
||||||
|
* Purpose: S52 Presentation Library
|
||||||
|
* Authors: David Register
|
||||||
|
* Jesper Weissglas
|
||||||
|
*
|
||||||
|
***************************************************************************
|
||||||
|
* Copyright (C) 2010 by David S. Register *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 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 the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(USE_ANDROID_GLES2) || defined(ocpnUSE_GLSL)
|
||||||
|
|
||||||
|
#include "s52shaders.h"
|
||||||
|
|
||||||
|
#ifdef USE_ANDROID_GLES2
|
||||||
|
const GLchar* S52_preamble =
|
||||||
|
"\n";
|
||||||
|
#else
|
||||||
|
const GLchar* S52_preamble =
|
||||||
|
"#version 120\n"
|
||||||
|
"#define precision\n"
|
||||||
|
"#define lowp\n"
|
||||||
|
"#define mediump\n"
|
||||||
|
"#define highp\n";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// Simple colored triangle shader
|
||||||
|
|
||||||
|
static const GLchar *S52color_tri_vertex_shader_source =
|
||||||
|
"attribute vec2 position;\n"
|
||||||
|
"uniform mat4 MVMatrix;\n"
|
||||||
|
"uniform mat4 TransformMatrix;\n"
|
||||||
|
"uniform vec4 color;\n"
|
||||||
|
"varying vec4 fragColor;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" fragColor = color;\n"
|
||||||
|
" gl_Position = MVMatrix * TransformMatrix * vec4(position, 0.0, 1.0);\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
static const GLchar *S52color_tri_fragment_shader_source =
|
||||||
|
"precision highp float;\n"
|
||||||
|
"varying vec4 fragColor;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" gl_FragColor = fragColor;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
// Simple 2D texture shader
|
||||||
|
static const GLchar *S52texture_2D_vertex_shader_source =
|
||||||
|
"attribute vec2 position;\n"
|
||||||
|
"attribute vec2 aUV;\n"
|
||||||
|
"uniform mat4 MVMatrix;\n"
|
||||||
|
"uniform mat4 TransformMatrix;\n"
|
||||||
|
"varying vec2 varCoord;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" gl_Position = MVMatrix * TransformMatrix * vec4(position, 0.0, 1.0);\n"
|
||||||
|
" //varCoord = aUV.st;\n"
|
||||||
|
" varCoord = aUV;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
static const GLchar *S52texture_2D_fragment_shader_source =
|
||||||
|
"precision highp float;\n"
|
||||||
|
"uniform sampler2D uTex;\n"
|
||||||
|
"varying vec2 varCoord;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" gl_FragColor = texture2D(uTex, varCoord);\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
// 2D texture shader with color modulation, used for colored text
|
||||||
|
static const GLchar *S52texture_2D_ColorMod_vertex_shader_source =
|
||||||
|
"precision highp float;\n"
|
||||||
|
"attribute vec2 position;\n"
|
||||||
|
"attribute vec2 aUV;\n"
|
||||||
|
"uniform mat4 MVMatrix;\n"
|
||||||
|
"uniform mat4 TransformMatrix;\n"
|
||||||
|
"varying vec2 varCoord;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" gl_Position = MVMatrix * TransformMatrix * vec4(position, 0.0, 1.0);\n"
|
||||||
|
" //varCoord = aUV.st;\n"
|
||||||
|
" varCoord = aUV;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
static const GLchar *S52texture_2D_ColorMod_fragment_shader_source =
|
||||||
|
"precision highp float;\n"
|
||||||
|
"uniform sampler2D uTex;\n"
|
||||||
|
"uniform vec4 color;\n"
|
||||||
|
"varying vec2 varCoord;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" vec4 col=texture2D(uTex, varCoord);\n"
|
||||||
|
" gl_FragColor = color;\n"
|
||||||
|
" gl_FragColor.a = col.a;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
// Circle shader
|
||||||
|
|
||||||
|
static const GLchar *S52circle_filled_vertex_shader_source =
|
||||||
|
"precision highp float;\n"
|
||||||
|
"attribute vec2 aPos;\n"
|
||||||
|
"uniform mat4 MVMatrix;\n"
|
||||||
|
"uniform mat4 TransformMatrix;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" gl_Position = MVMatrix * TransformMatrix * vec4(aPos, 0.0, 1.0);\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
static const GLchar *S52circle_filled_fragment_shader_source =
|
||||||
|
"precision highp float;\n"
|
||||||
|
"uniform float border_width;\n"
|
||||||
|
"uniform float circle_radius;\n"
|
||||||
|
"uniform vec4 circle_color;\n"
|
||||||
|
"uniform vec4 border_color;\n"
|
||||||
|
"uniform vec2 circle_center;\n"
|
||||||
|
"void main(){\n"
|
||||||
|
"float d = distance(gl_FragCoord.xy, circle_center);\n"
|
||||||
|
"if (d < (circle_radius - border_width)) { gl_FragColor = circle_color; }\n"
|
||||||
|
"else if (d < circle_radius) { gl_FragColor = border_color; }\n"
|
||||||
|
"else { gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); }\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
// Ring shader
|
||||||
|
|
||||||
|
static const GLchar *S52ring_vertex_shader_source =
|
||||||
|
"precision highp float;\n"
|
||||||
|
"attribute vec2 aPos;\n"
|
||||||
|
"uniform mat4 MVMatrix;\n"
|
||||||
|
"uniform mat4 TransformMatrix;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" gl_Position = MVMatrix * TransformMatrix * vec4(aPos, 0.0, 1.0);\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
static const GLchar *S52ring_fragment_shader_source_old =
|
||||||
|
"precision highp float;\n"
|
||||||
|
"uniform float border_width;\n"
|
||||||
|
"uniform float circle_radius;\n"
|
||||||
|
"uniform float ring_width;\n"
|
||||||
|
"uniform vec4 circle_color;\n"
|
||||||
|
"uniform vec4 border_color;\n"
|
||||||
|
"uniform vec2 circle_center;\n"
|
||||||
|
"uniform float sector_1;\n"
|
||||||
|
"uniform float sector_2;\n"
|
||||||
|
|
||||||
|
"void main(){\n"
|
||||||
|
"const float PI = 3.14159265358979323846264;\n"
|
||||||
|
"bool bdraw = false;\n"
|
||||||
|
|
||||||
|
"float angle = atan(gl_FragCoord.y-circle_center.y, "
|
||||||
|
"gl_FragCoord.x-circle_center.x);\n"
|
||||||
|
"angle = PI/2.0 - angle;\n"
|
||||||
|
"if(angle < 0.0) angle += PI * 2.0;\n"
|
||||||
|
|
||||||
|
"if(sector_2 > PI * 2.0){\n"
|
||||||
|
" if((angle > sector_1) && (angle < (PI * 2.0) )){\n"
|
||||||
|
" bdraw = true;\n"
|
||||||
|
" }\n"
|
||||||
|
" if(angle < sector_2 - (PI * 2.0)){\n"
|
||||||
|
" bdraw = true;\n"
|
||||||
|
" }\n"
|
||||||
|
"} else {\n"
|
||||||
|
" if((angle > sector_1) && (angle < sector_2)){\n"
|
||||||
|
" bdraw = true;\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
|
||||||
|
"if(bdraw){\n"
|
||||||
|
" float d = distance(gl_FragCoord.xy, circle_center);\n"
|
||||||
|
" if (d > circle_radius) {\n"
|
||||||
|
" discard;\n"
|
||||||
|
" } else if( d > (circle_radius - border_width)) {\n"
|
||||||
|
" gl_FragColor = border_color;\n"
|
||||||
|
" } else if( d > (circle_radius - border_width - ring_width)) {\n"
|
||||||
|
" gl_FragColor = circle_color;\n"
|
||||||
|
" } else if( d > (circle_radius - border_width - ring_width - "
|
||||||
|
"border_width)) {\n"
|
||||||
|
" gl_FragColor = border_color;\n"
|
||||||
|
" } else {\n"
|
||||||
|
" discard;\n"
|
||||||
|
" }\n"
|
||||||
|
"} else{\n"
|
||||||
|
" discard;\n"
|
||||||
|
"}\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
|
||||||
|
static const GLchar *S52ring_fragment_shader_source =
|
||||||
|
"precision highp float;\n"
|
||||||
|
"uniform float ring_width;\n"
|
||||||
|
"uniform float circle_radius;\n"
|
||||||
|
"uniform vec4 ring_color;\n"
|
||||||
|
"uniform vec2 circle_center;\n"
|
||||||
|
"uniform float sector_1;\n"
|
||||||
|
"uniform float sector_2;\n"
|
||||||
|
|
||||||
|
"void main(){\n"
|
||||||
|
"const float PI = 3.14159265358979323846264;\n"
|
||||||
|
"bool bdraw = false;\n"
|
||||||
|
|
||||||
|
"float angle = atan(gl_FragCoord.y-circle_center.y, "
|
||||||
|
"gl_FragCoord.x-circle_center.x);\n"
|
||||||
|
"angle = PI/2.0 - angle;\n"
|
||||||
|
"if(angle < 0.0) angle += PI * 2.0;\n"
|
||||||
|
|
||||||
|
"if(sector_2 > PI * 2.0){\n"
|
||||||
|
" if((angle > sector_1) && (angle < (PI * 2.0) )){\n"
|
||||||
|
" bdraw = true;\n"
|
||||||
|
" }\n"
|
||||||
|
" if(angle < sector_2 - (PI * 2.0)){\n"
|
||||||
|
" bdraw = true;\n"
|
||||||
|
" }\n"
|
||||||
|
"} else {\n"
|
||||||
|
" if((angle > sector_1) && (angle < sector_2)){\n"
|
||||||
|
" bdraw = true;\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
|
||||||
|
"if(bdraw){\n"
|
||||||
|
" float d = distance(gl_FragCoord.xy, circle_center);\n"
|
||||||
|
" float delta = 0.9;\n"
|
||||||
|
" if (d > circle_radius + ring_width/2.) {\n"
|
||||||
|
" discard;\n"
|
||||||
|
" } else if( d > (circle_radius )) {\n"
|
||||||
|
" float alpha = smoothstep(circle_radius + ring_width/2. -delta, circle_radius + ring_width/2., d);\n"
|
||||||
|
" gl_FragColor = ring_color;\n"
|
||||||
|
" gl_FragColor.w = 1.-alpha;\n"
|
||||||
|
" }\n"
|
||||||
|
" else if( d > (circle_radius - ring_width/2. - delta)) {\n"
|
||||||
|
" gl_FragColor = ring_color;\n"
|
||||||
|
" float alpha = smoothstep(circle_radius - ring_width/2. - delta, circle_radius - ring_width/2., d);\n"
|
||||||
|
" gl_FragColor.w = alpha;\n"
|
||||||
|
" }\n"
|
||||||
|
" else {\n"
|
||||||
|
" discard;\n"
|
||||||
|
" }\n"
|
||||||
|
"} else{\n"
|
||||||
|
" discard;\n"
|
||||||
|
"}\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
// Dash/Dot line shader
|
||||||
|
static const GLchar *S52Dash_vertex_shader_source =
|
||||||
|
"attribute vec2 position;\n"
|
||||||
|
"uniform mat4 MVMatrix;\n"
|
||||||
|
"uniform mat4 TransformMatrix;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" gl_Position = MVMatrix * TransformMatrix * vec4(position, 0.0, 1.0);\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
static const GLchar *S52Dash_fragment_shader_source =
|
||||||
|
"precision highp float;\n"
|
||||||
|
"uniform sampler2D uTex;\n"
|
||||||
|
"uniform vec2 startPos;\n"
|
||||||
|
"uniform float texWidth;\n"
|
||||||
|
"uniform float dashFactor;\n"
|
||||||
|
"uniform vec4 color;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" float d = distance(gl_FragCoord.xy, startPos);\n"
|
||||||
|
" float x = mod(d,texWidth) / texWidth;\n"
|
||||||
|
" if(x < dashFactor) gl_FragColor = color;\n"
|
||||||
|
" else gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
// Texture shader for Area Pattern
|
||||||
|
static const GLchar *S52AP_vertex_shader_source =
|
||||||
|
"attribute vec2 position;\n"
|
||||||
|
"attribute vec2 aUV;\n"
|
||||||
|
"uniform mat4 MVMatrix;\n"
|
||||||
|
"uniform mat4 TransformMatrix;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" gl_Position = MVMatrix * TransformMatrix * vec4(position, 0.0, 1.0);\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
static const GLchar* S52AP_fragment_shader_source =
|
||||||
|
"precision highp float;\n"
|
||||||
|
"uniform sampler2D uTex;\n"
|
||||||
|
"uniform float texWidth;\n"
|
||||||
|
"uniform float texHeight;\n"
|
||||||
|
"uniform float texPOTWidth;\n"
|
||||||
|
"uniform float texPOTHeight;\n"
|
||||||
|
"uniform float staggerFactor;\n"
|
||||||
|
"uniform vec4 color;\n"
|
||||||
|
"uniform float xOff;\n"
|
||||||
|
"uniform float yOff;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" float yp = floor((gl_FragCoord.y + yOff) / texHeight);\n"
|
||||||
|
" float fstagger = 0.0;\n"
|
||||||
|
" //if(mod(yp, 2.0) < 0.1) fstagger = staggerFactor;\n"
|
||||||
|
" float xStag = xOff + (fstagger * texWidth);\n"
|
||||||
|
" float x = mod((gl_FragCoord.x - xStag),texWidth) / texPOTWidth;\n"
|
||||||
|
" float y = mod((gl_FragCoord.y + yOff),texHeight) / texPOTHeight;\n"
|
||||||
|
" gl_FragColor = texture2D(uTex, vec2(x, (texHeight / texPOTHeight) - y));\n"
|
||||||
|
"}\n";
|
||||||
|
#else
|
||||||
|
|
||||||
|
static const GLchar *S52AP_fragment_shader_source =
|
||||||
|
"precision highp float;\n"
|
||||||
|
"uniform sampler2D uTex;\n"
|
||||||
|
"uniform float texWidth;\n"
|
||||||
|
"uniform float texHeight;\n"
|
||||||
|
"uniform float texPOTWidth;\n"
|
||||||
|
"uniform float texPOTHeight;\n"
|
||||||
|
"uniform float staggerFactor;\n"
|
||||||
|
"uniform vec4 color;\n"
|
||||||
|
"uniform float xOff;\n"
|
||||||
|
"uniform float yOff;\n"
|
||||||
|
"uniform float yOffM;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" float yp = floor((gl_FragCoord.y + yOffM ) / texPOTHeight);\n"
|
||||||
|
" float fstagger = 0.0;\n"
|
||||||
|
" if(mod(yp, 2.0) < 0.1) fstagger = 0.5;\n"
|
||||||
|
" float x = (gl_FragCoord.x - xOff) / texPOTWidth;\n"
|
||||||
|
" float y = (gl_FragCoord.y + yOff) / texPOTHeight;\n"
|
||||||
|
" gl_FragColor = texture2D(uTex, vec2(x + fstagger, -y));\n"
|
||||||
|
"}\n";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
GLint S52color_tri_fragment_shader;
|
||||||
|
GLint S52color_tri_vertex_shader;
|
||||||
|
|
||||||
|
GLint S52texture_2D_fragment_shader;
|
||||||
|
GLint S52texture_2D_vertex_shader;
|
||||||
|
|
||||||
|
GLint S52texture_2D_ColorMod_fragment_shader;
|
||||||
|
GLint S52texture_2D_ColorMod_vertex_shader;
|
||||||
|
|
||||||
|
GLint S52circle_filled_vertex_shader;
|
||||||
|
GLint S52circle_filled_fragment_shader;
|
||||||
|
|
||||||
|
GLint S52ring_vertex_shader;
|
||||||
|
GLint S52ring_fragment_shader;
|
||||||
|
|
||||||
|
GLint S52Dash_vertex_shader;
|
||||||
|
GLint S52Dash_fragment_shader;
|
||||||
|
|
||||||
|
GLint S52AP_vertex_shader;
|
||||||
|
GLint S52AP_fragment_shader;
|
||||||
|
|
||||||
|
extern GLint S52color_tri_shader_program;
|
||||||
|
extern GLint S52texture_2D_shader_program;
|
||||||
|
extern GLint S52texture_2D_ColorMod_shader_program;
|
||||||
|
extern GLint S52circle_filled_shader_program;
|
||||||
|
extern GLint S52ring_shader_program;
|
||||||
|
extern GLint S52Dash_shader_program;
|
||||||
|
extern GLint S52AP_shader_program;
|
||||||
|
|
||||||
|
S52_GLShaderProgram *pS52texture_2D_ColorMod_shader_program;
|
||||||
|
|
||||||
|
|
||||||
|
bool shadersLoaded = false;
|
||||||
|
|
||||||
|
bool loadS52Shaders() {
|
||||||
|
bool ret_val = true;
|
||||||
|
//GLint success;
|
||||||
|
|
||||||
|
enum Consts { INFOLOG_LEN = 512 };
|
||||||
|
#if 0
|
||||||
|
GLchar infoLog[INFOLOG_LEN];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Are the shaders ready?
|
||||||
|
if(shadersLoaded)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Simple colored triangle shader
|
||||||
|
|
||||||
|
if (!S52color_tri_vertex_shader) {
|
||||||
|
auto shaderProgram = S52_GLShaderProgram::Builder()
|
||||||
|
.addShaderFromSource(S52color_tri_vertex_shader_source, GL_VERTEX_SHADER)
|
||||||
|
.addShaderFromSource(S52color_tri_fragment_shader_source, GL_FRAGMENT_SHADER)
|
||||||
|
.linkProgram();
|
||||||
|
|
||||||
|
S52color_tri_shader_program = shaderProgram.programId();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!S52texture_2D_shader_program) {
|
||||||
|
auto shaderProgram = S52_GLShaderProgram::Builder()
|
||||||
|
.addShaderFromSource(S52texture_2D_vertex_shader_source, GL_VERTEX_SHADER)
|
||||||
|
.addShaderFromSource(S52texture_2D_fragment_shader_source, GL_FRAGMENT_SHADER)
|
||||||
|
.linkProgram();
|
||||||
|
|
||||||
|
S52texture_2D_shader_program = shaderProgram.programId();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// Simple 2D texture shader
|
||||||
|
|
||||||
|
if (!S52texture_2D_vertex_shader) {
|
||||||
|
/* Vertex shader */
|
||||||
|
S52texture_2D_vertex_shader = glCreateShader(GL_VERTEX_SHADER);
|
||||||
|
glShaderSource(S52texture_2D_vertex_shader, 1,
|
||||||
|
&S52texture_2D_vertex_shader_source, NULL);
|
||||||
|
glCompileShader(S52texture_2D_vertex_shader);
|
||||||
|
glGetShaderiv(S52texture_2D_vertex_shader, GL_COMPILE_STATUS, &success);
|
||||||
|
if (!success) {
|
||||||
|
glGetShaderInfoLog(S52texture_2D_vertex_shader, INFOLOG_LEN, NULL,
|
||||||
|
infoLog);
|
||||||
|
// printf("ERROR::SHADER::VERTEX::COMPILATION_FAILED\n%s\n",
|
||||||
|
// infoLog);
|
||||||
|
ret_val = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!S52texture_2D_fragment_shader) {
|
||||||
|
/* Fragment shader */
|
||||||
|
S52texture_2D_fragment_shader = glCreateShader(GL_FRAGMENT_SHADER);
|
||||||
|
glShaderSource(S52texture_2D_fragment_shader, 1,
|
||||||
|
&S52texture_2D_fragment_shader_source, NULL);
|
||||||
|
glCompileShader(S52texture_2D_fragment_shader);
|
||||||
|
glGetShaderiv(S52texture_2D_fragment_shader, GL_COMPILE_STATUS, &success);
|
||||||
|
if (!success) {
|
||||||
|
glGetShaderInfoLog(S52texture_2D_fragment_shader, INFOLOG_LEN, NULL,
|
||||||
|
infoLog);
|
||||||
|
// printf("ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\n%s\n",
|
||||||
|
// infoLog);
|
||||||
|
ret_val = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!S52texture_2D_shader_program) {
|
||||||
|
/* Link shaders */
|
||||||
|
S52texture_2D_shader_program = glCreateProgram();
|
||||||
|
glAttachShader(S52texture_2D_shader_program, S52texture_2D_vertex_shader);
|
||||||
|
glAttachShader(S52texture_2D_shader_program, S52texture_2D_fragment_shader);
|
||||||
|
glLinkProgram(S52texture_2D_shader_program);
|
||||||
|
glGetProgramiv(S52texture_2D_shader_program, GL_LINK_STATUS, &success);
|
||||||
|
if (!success) {
|
||||||
|
glGetProgramInfoLog(S52texture_2D_shader_program, INFOLOG_LEN, NULL,
|
||||||
|
infoLog);
|
||||||
|
// printf("ERROR::SHADER::PROGRAM::LINKING_FAILED\n%s\n", infoLog);
|
||||||
|
ret_val = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// 2D texture shader with color Modulate
|
||||||
|
if (!S52texture_2D_ColorMod_shader_program) {
|
||||||
|
|
||||||
|
auto shaderProgram = S52_GLShaderProgram::Builder()
|
||||||
|
.addShaderFromSource(S52texture_2D_ColorMod_vertex_shader_source, GL_VERTEX_SHADER)
|
||||||
|
.addShaderFromSource(S52texture_2D_ColorMod_fragment_shader_source, GL_FRAGMENT_SHADER)
|
||||||
|
.linkProgram();
|
||||||
|
|
||||||
|
S52texture_2D_ColorMod_shader_program = shaderProgram.programId();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (!S52texture_2D_ColorMod_vertex_shader) {
|
||||||
|
/* Vertex shader */
|
||||||
|
S52texture_2D_ColorMod_vertex_shader = glCreateShader(GL_VERTEX_SHADER);
|
||||||
|
glShaderSource(S52texture_2D_ColorMod_vertex_shader, 1,
|
||||||
|
&S52texture_2D_ColorMod_vertex_shader_source, NULL);
|
||||||
|
glCompileShader(S52texture_2D_ColorMod_vertex_shader);
|
||||||
|
glGetShaderiv(S52texture_2D_ColorMod_vertex_shader, GL_COMPILE_STATUS,
|
||||||
|
&success);
|
||||||
|
if (!success) {
|
||||||
|
glGetShaderInfoLog(S52texture_2D_ColorMod_vertex_shader, INFOLOG_LEN,
|
||||||
|
NULL, infoLog);
|
||||||
|
// printf("ERROR::SHADER::VERTEX::COMPILATION_FAILED\n%s\n",
|
||||||
|
// infoLog);
|
||||||
|
ret_val = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!S52texture_2D_ColorMod_fragment_shader) {
|
||||||
|
/* Fragment shader */
|
||||||
|
S52texture_2D_ColorMod_fragment_shader = glCreateShader(GL_FRAGMENT_SHADER);
|
||||||
|
glShaderSource(S52texture_2D_ColorMod_fragment_shader, 1,
|
||||||
|
&S52texture_2D_ColorMod_fragment_shader_source, NULL);
|
||||||
|
glCompileShader(S52texture_2D_ColorMod_fragment_shader);
|
||||||
|
glGetShaderiv(S52texture_2D_ColorMod_fragment_shader, GL_COMPILE_STATUS,
|
||||||
|
&success);
|
||||||
|
if (!success) {
|
||||||
|
glGetShaderInfoLog(S52texture_2D_ColorMod_fragment_shader, INFOLOG_LEN,
|
||||||
|
NULL, infoLog);
|
||||||
|
// printf("ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\n%s\n",
|
||||||
|
// infoLog);
|
||||||
|
ret_val = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!S52texture_2D_ColorMod_shader_program) {
|
||||||
|
/* Link shaders */
|
||||||
|
S52texture_2D_ColorMod_shader_program = glCreateProgram();
|
||||||
|
glAttachShader(S52texture_2D_ColorMod_shader_program,
|
||||||
|
S52texture_2D_ColorMod_vertex_shader);
|
||||||
|
glAttachShader(S52texture_2D_ColorMod_shader_program,
|
||||||
|
S52texture_2D_ColorMod_fragment_shader);
|
||||||
|
glLinkProgram(S52texture_2D_ColorMod_shader_program);
|
||||||
|
glGetProgramiv(S52texture_2D_ColorMod_shader_program, GL_LINK_STATUS,
|
||||||
|
&success);
|
||||||
|
if (!success) {
|
||||||
|
glGetProgramInfoLog(S52texture_2D_ColorMod_shader_program, INFOLOG_LEN,
|
||||||
|
NULL, infoLog);
|
||||||
|
// printf("ERROR::SHADER::PROGRAM::LINKING_FAILED\n%s\n", infoLog);
|
||||||
|
ret_val = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Circle shader
|
||||||
|
if (!S52circle_filled_shader_program) {
|
||||||
|
auto shaderProgram = S52_GLShaderProgram::Builder()
|
||||||
|
.addShaderFromSource(S52circle_filled_vertex_shader_source, GL_VERTEX_SHADER)
|
||||||
|
.addShaderFromSource(S52circle_filled_fragment_shader_source, GL_FRAGMENT_SHADER)
|
||||||
|
.linkProgram();
|
||||||
|
|
||||||
|
S52circle_filled_shader_program = shaderProgram.programId();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (!S52circle_filled_vertex_shader) {
|
||||||
|
/* Vertex shader */
|
||||||
|
S52circle_filled_vertex_shader = glCreateShader(GL_VERTEX_SHADER);
|
||||||
|
glShaderSource(S52circle_filled_vertex_shader, 1,
|
||||||
|
&S52circle_filled_vertex_shader_source, NULL);
|
||||||
|
glCompileShader(S52circle_filled_vertex_shader);
|
||||||
|
glGetShaderiv(S52circle_filled_vertex_shader, GL_COMPILE_STATUS, &success);
|
||||||
|
if (!success) {
|
||||||
|
glGetShaderInfoLog(S52circle_filled_vertex_shader, INFOLOG_LEN, NULL,
|
||||||
|
infoLog);
|
||||||
|
// printf("ERROR::SHADER::VERTEX::COMPILATION_FAILED\n%s\n",
|
||||||
|
// infoLog);
|
||||||
|
ret_val = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!S52circle_filled_fragment_shader) {
|
||||||
|
/* Fragment shader */
|
||||||
|
S52circle_filled_fragment_shader = glCreateShader(GL_FRAGMENT_SHADER);
|
||||||
|
glShaderSource(S52circle_filled_fragment_shader, 1,
|
||||||
|
&S52circle_filled_fragment_shader_source, NULL);
|
||||||
|
glCompileShader(S52circle_filled_fragment_shader);
|
||||||
|
glGetShaderiv(S52circle_filled_fragment_shader, GL_COMPILE_STATUS,
|
||||||
|
&success);
|
||||||
|
if (!success) {
|
||||||
|
glGetShaderInfoLog(S52circle_filled_fragment_shader, INFOLOG_LEN, NULL,
|
||||||
|
infoLog);
|
||||||
|
// printf("ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\n%s\n",
|
||||||
|
// infoLog);
|
||||||
|
ret_val = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!S52circle_filled_shader_program) {
|
||||||
|
/* Link shaders */
|
||||||
|
S52circle_filled_shader_program = glCreateProgram();
|
||||||
|
glAttachShader(S52circle_filled_shader_program,
|
||||||
|
S52circle_filled_vertex_shader);
|
||||||
|
glAttachShader(S52circle_filled_shader_program,
|
||||||
|
S52circle_filled_fragment_shader);
|
||||||
|
glLinkProgram(S52circle_filled_shader_program);
|
||||||
|
glGetProgramiv(S52circle_filled_shader_program, GL_LINK_STATUS, &success);
|
||||||
|
if (!success) {
|
||||||
|
glGetProgramInfoLog(S52circle_filled_shader_program, INFOLOG_LEN, NULL,
|
||||||
|
infoLog);
|
||||||
|
// printf("ERROR::SHADER::PROGRAM::LINKING_FAILED\n%s\n",
|
||||||
|
// infoLog);
|
||||||
|
ret_val = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Ring shader
|
||||||
|
if (!S52ring_shader_program) {
|
||||||
|
auto shaderProgram = S52_GLShaderProgram::Builder()
|
||||||
|
.addShaderFromSource(S52ring_vertex_shader_source, GL_VERTEX_SHADER)
|
||||||
|
.addShaderFromSource(S52ring_fragment_shader_source, GL_FRAGMENT_SHADER)
|
||||||
|
.linkProgram();
|
||||||
|
|
||||||
|
S52ring_shader_program = shaderProgram.programId();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (!S52ring_vertex_shader) {
|
||||||
|
/* Vertex shader */
|
||||||
|
S52ring_vertex_shader = glCreateShader(GL_VERTEX_SHADER);
|
||||||
|
glShaderSource(S52ring_vertex_shader, 1, &S52ring_vertex_shader_source,
|
||||||
|
NULL);
|
||||||
|
glCompileShader(S52ring_vertex_shader);
|
||||||
|
glGetShaderiv(S52ring_vertex_shader, GL_COMPILE_STATUS, &success);
|
||||||
|
if (!success) {
|
||||||
|
glGetShaderInfoLog(S52ring_vertex_shader, INFOLOG_LEN, NULL, infoLog);
|
||||||
|
// printf("ERROR::SHADER::VERTEX::COMPILATION_FAILED\n%s\n",
|
||||||
|
// infoLog);
|
||||||
|
ret_val = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!S52ring_fragment_shader) {
|
||||||
|
/* Fragment shader */
|
||||||
|
S52ring_fragment_shader = glCreateShader(GL_FRAGMENT_SHADER);
|
||||||
|
glShaderSource(S52ring_fragment_shader, 1, &S52ring_fragment_shader_source,
|
||||||
|
NULL);
|
||||||
|
glCompileShader(S52ring_fragment_shader);
|
||||||
|
glGetShaderiv(S52ring_fragment_shader, GL_COMPILE_STATUS, &success);
|
||||||
|
if (!success) {
|
||||||
|
glGetShaderInfoLog(S52ring_fragment_shader, INFOLOG_LEN, NULL, infoLog);
|
||||||
|
// printf("ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\n%s\n",
|
||||||
|
// infoLog);
|
||||||
|
ret_val = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!S52ring_shader_program) {
|
||||||
|
/* Link shaders */
|
||||||
|
S52ring_shader_program = glCreateProgram();
|
||||||
|
glAttachShader(S52ring_shader_program, S52ring_vertex_shader);
|
||||||
|
glAttachShader(S52ring_shader_program, S52ring_fragment_shader);
|
||||||
|
glLinkProgram(S52ring_shader_program);
|
||||||
|
glGetProgramiv(S52ring_shader_program, GL_LINK_STATUS, &success);
|
||||||
|
if (!success) {
|
||||||
|
glGetProgramInfoLog(S52ring_shader_program, INFOLOG_LEN, NULL, infoLog);
|
||||||
|
// printf("ERROR::SHADER::PROGRAM::LINKING_FAILED\n%s\n",
|
||||||
|
// infoLog);
|
||||||
|
ret_val = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Dash shader
|
||||||
|
if (!S52Dash_shader_program) {
|
||||||
|
auto shaderProgram = S52_GLShaderProgram::Builder()
|
||||||
|
.addShaderFromSource(S52Dash_vertex_shader_source, GL_VERTEX_SHADER)
|
||||||
|
.addShaderFromSource(S52Dash_fragment_shader_source, GL_FRAGMENT_SHADER)
|
||||||
|
.linkProgram();
|
||||||
|
|
||||||
|
S52Dash_shader_program = shaderProgram.programId();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (!S52Dash_vertex_shader) {
|
||||||
|
/* Vertex shader */
|
||||||
|
S52Dash_vertex_shader = glCreateShader(GL_VERTEX_SHADER);
|
||||||
|
glShaderSource(S52Dash_vertex_shader, 1, &S52Dash_vertex_shader_source,
|
||||||
|
NULL);
|
||||||
|
glCompileShader(S52Dash_vertex_shader);
|
||||||
|
glGetShaderiv(S52Dash_vertex_shader, GL_COMPILE_STATUS, &success);
|
||||||
|
if (!success) {
|
||||||
|
glGetShaderInfoLog(S52ring_vertex_shader, INFOLOG_LEN, NULL, infoLog);
|
||||||
|
// printf("ERROR::SHADER::VERTEX::COMPILATION_FAILED\n%s\n",
|
||||||
|
// infoLog);
|
||||||
|
ret_val = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!S52Dash_fragment_shader) {
|
||||||
|
/* Fragment shader */
|
||||||
|
S52Dash_fragment_shader = glCreateShader(GL_FRAGMENT_SHADER);
|
||||||
|
glShaderSource(S52Dash_fragment_shader, 1, &S52Dash_fragment_shader_source,
|
||||||
|
NULL);
|
||||||
|
glCompileShader(S52Dash_fragment_shader);
|
||||||
|
glGetShaderiv(S52Dash_fragment_shader, GL_COMPILE_STATUS, &success);
|
||||||
|
if (!success) {
|
||||||
|
glGetShaderInfoLog(S52Dash_fragment_shader, INFOLOG_LEN, NULL, infoLog);
|
||||||
|
// printf("ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\n%s\n",
|
||||||
|
// infoLog);
|
||||||
|
ret_val = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!S52Dash_shader_program) {
|
||||||
|
/* Link shaders */
|
||||||
|
S52Dash_shader_program = glCreateProgram();
|
||||||
|
glAttachShader(S52Dash_shader_program, S52Dash_vertex_shader);
|
||||||
|
glAttachShader(S52Dash_shader_program, S52Dash_fragment_shader);
|
||||||
|
glLinkProgram(S52Dash_shader_program);
|
||||||
|
glGetProgramiv(S52Dash_shader_program, GL_LINK_STATUS, &success);
|
||||||
|
if (!success) {
|
||||||
|
glGetProgramInfoLog(S52Dash_shader_program, INFOLOG_LEN, NULL, infoLog);
|
||||||
|
// printf("ERROR::SHADER::PROGRAM::LINKING_FAILED\n%s\n",
|
||||||
|
// infoLog);
|
||||||
|
ret_val = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// AP shader
|
||||||
|
if (!S52AP_shader_program) {
|
||||||
|
auto shaderProgram = S52_GLShaderProgram::Builder()
|
||||||
|
.addShaderFromSource(S52AP_vertex_shader_source, GL_VERTEX_SHADER)
|
||||||
|
.addShaderFromSource(S52AP_fragment_shader_source, GL_FRAGMENT_SHADER)
|
||||||
|
.linkProgram();
|
||||||
|
|
||||||
|
S52AP_shader_program = shaderProgram.programId();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (!S52AP_vertex_shader) {
|
||||||
|
/* Vertex shader */
|
||||||
|
S52AP_vertex_shader = glCreateShader(GL_VERTEX_SHADER);
|
||||||
|
glShaderSource(S52AP_vertex_shader, 1, &S52AP_vertex_shader_source, NULL);
|
||||||
|
glCompileShader(S52AP_vertex_shader);
|
||||||
|
glGetShaderiv(S52AP_vertex_shader, GL_COMPILE_STATUS, &success);
|
||||||
|
if (!success) {
|
||||||
|
glGetShaderInfoLog(S52ring_vertex_shader, INFOLOG_LEN, NULL, infoLog);
|
||||||
|
// printf("ERROR::SHADER::VERTEX::COMPILATION_FAILED\n%s\n",
|
||||||
|
// infoLog);
|
||||||
|
ret_val = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!S52AP_fragment_shader) {
|
||||||
|
/* Fragment shader */
|
||||||
|
S52AP_fragment_shader = glCreateShader(GL_FRAGMENT_SHADER);
|
||||||
|
glShaderSource(S52AP_fragment_shader, 1, &S52AP_fragment_shader_source,
|
||||||
|
NULL);
|
||||||
|
glCompileShader(S52AP_fragment_shader);
|
||||||
|
glGetShaderiv(S52AP_fragment_shader, GL_COMPILE_STATUS, &success);
|
||||||
|
if (!success) {
|
||||||
|
glGetShaderInfoLog(S52AP_fragment_shader, INFOLOG_LEN, NULL, infoLog);
|
||||||
|
// printf("ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\n%s\n",
|
||||||
|
// infoLog);
|
||||||
|
ret_val = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!S52AP_shader_program) {
|
||||||
|
/* Link shaders */
|
||||||
|
S52AP_shader_program = glCreateProgram();
|
||||||
|
glAttachShader(S52AP_shader_program, S52AP_vertex_shader);
|
||||||
|
glAttachShader(S52AP_shader_program, S52AP_fragment_shader);
|
||||||
|
glLinkProgram(S52AP_shader_program);
|
||||||
|
glGetProgramiv(S52AP_shader_program, GL_LINK_STATUS, &success);
|
||||||
|
if (!success) {
|
||||||
|
glGetProgramInfoLog(S52AP_shader_program, INFOLOG_LEN, NULL, infoLog);
|
||||||
|
// printf("ERROR::SHADER::PROGRAM::LINKING_FAILED\n%s\n",
|
||||||
|
// infoLog);
|
||||||
|
ret_val = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
shadersLoaded = true;
|
||||||
|
|
||||||
|
return ret_val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
139
docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/s52shaders.h
Executable file
139
docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/s52shaders.h
Executable file
@@ -0,0 +1,139 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
*
|
||||||
|
* Project: OpenCPN
|
||||||
|
* Purpose: S52 Presentation Library
|
||||||
|
* Authors: David Register
|
||||||
|
* Jesper Weissglas
|
||||||
|
*
|
||||||
|
***************************************************************************
|
||||||
|
* Copyright (C) 2010 by David S. Register *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 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 the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __S52SHADERS_H__
|
||||||
|
#define __S52SHADERS_H__
|
||||||
|
|
||||||
|
#if defined(USE_ANDROID_GLES2) || defined(ocpnUSE_GLSL)
|
||||||
|
#include <string>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "s52plibGL.h"
|
||||||
|
|
||||||
|
extern const GLchar* S52_preamble;
|
||||||
|
|
||||||
|
enum Consts { INFOLOG_LEN = 512 };
|
||||||
|
|
||||||
|
class S52_GLShaderProgram
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
class Builder {
|
||||||
|
public:
|
||||||
|
Builder() : linked_(false) {
|
||||||
|
programId_ = glCreateProgram();
|
||||||
|
}
|
||||||
|
|
||||||
|
Builder & addShaderFromSource(std::string const &shaderSource, GLenum shaderType) {
|
||||||
|
char const *shaderCStr = shaderSource.c_str();
|
||||||
|
GLuint shaderId = glCreateShader(shaderType);
|
||||||
|
|
||||||
|
GLchar const* files[] = { S52_preamble, shaderCStr };
|
||||||
|
GLint lengths[] = { (GLint)strlen(S52_preamble), (GLint)strlen(shaderCStr) };
|
||||||
|
|
||||||
|
glShaderSource(shaderId, 2, files, lengths);
|
||||||
|
//glShaderSource(shaderId, 1, &shaderCStr, nullptr);
|
||||||
|
|
||||||
|
glCompileShader(shaderId);
|
||||||
|
glGetShaderiv(shaderId, GL_COMPILE_STATUS, &success);
|
||||||
|
if (!success) {
|
||||||
|
glGetShaderInfoLog(shaderId, INFOLOG_LEN, NULL, infoLog);
|
||||||
|
printf("ERROR::SHADER::COMPILATION_FAILED\n%s\n", infoLog);
|
||||||
|
//ret_val = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
glAttachShader(programId_, shaderId);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// void addShaderFromFile(std::string const &shaderFile, GLenum shaderType) {
|
||||||
|
// std::ifstream fileName(shaderFile);
|
||||||
|
// std::istreambuf_iterator<char> fileBegin(fileName), fileEnd;
|
||||||
|
// std::string fileContents(fileBegin, fileEnd);
|
||||||
|
// return addShaderFromSource(fileContents, shaderType);
|
||||||
|
// }
|
||||||
|
|
||||||
|
S52_GLShaderProgram linkProgram() {
|
||||||
|
glLinkProgram(programId_);
|
||||||
|
glGetProgramiv( programId_, GL_LINK_STATUS, &linkSuccess); //requesting the status
|
||||||
|
if (linkSuccess == GL_FALSE) {
|
||||||
|
glGetProgramInfoLog(programId_, INFOLOG_LEN, NULL, infoLog);
|
||||||
|
printf("ERROR::SHADER::LINK_FAILED\n%s\n", infoLog);
|
||||||
|
}
|
||||||
|
|
||||||
|
S52_GLShaderProgram theProgram(programId_);
|
||||||
|
//deleteAttachedShaders(programId_);
|
||||||
|
linked_ = true;
|
||||||
|
return theProgram;
|
||||||
|
}
|
||||||
|
|
||||||
|
~Builder() {
|
||||||
|
if(!linked_) {
|
||||||
|
glDeleteProgram(programId_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
GLuint programId_;
|
||||||
|
bool linked_;
|
||||||
|
GLint success;
|
||||||
|
GLint linkSuccess;
|
||||||
|
GLchar infoLog[INFOLOG_LEN];
|
||||||
|
};
|
||||||
|
|
||||||
|
S52_GLShaderProgram() : programId_(0) { }
|
||||||
|
|
||||||
|
S52_GLShaderProgram(S52_GLShaderProgram &&other) {
|
||||||
|
*this = std::move(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
S52_GLShaderProgram &operator=(S52_GLShaderProgram &&other)
|
||||||
|
{
|
||||||
|
programId_ = other.programId_;
|
||||||
|
other.programId_ = 0;
|
||||||
|
|
||||||
|
if (other.programId_ != 0) {
|
||||||
|
glDeleteProgram(other.programId_);
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
~S52_GLShaderProgram() { }
|
||||||
|
|
||||||
|
GLuint programId() const { return programId_; }
|
||||||
|
|
||||||
|
S52_GLShaderProgram(S52_GLShaderProgram const &other) = delete;
|
||||||
|
S52_GLShaderProgram &operator=(S52_GLShaderProgram const &other) = delete;
|
||||||
|
private:
|
||||||
|
S52_GLShaderProgram(GLuint programId) : programId_(programId) { }
|
||||||
|
GLuint programId_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,189 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Project: OpenCPN
|
||||||
|
* Purpose: S52 Utility Library
|
||||||
|
* Author: David Register, Sylvain Duclos
|
||||||
|
*
|
||||||
|
***************************************************************************
|
||||||
|
* Copyright (C) 2010 by David S. Register *
|
||||||
|
* *
|
||||||
|
* Copyright (C) 2000-2004 Sylvain Duclos *
|
||||||
|
* sduclos@users.sourceforgue.net *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 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 the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
|
***************************************************************************
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "s52utils.h"
|
||||||
|
//#include <stdio.h> // FILE
|
||||||
|
//#include <string.h> // strncmp()
|
||||||
|
|
||||||
|
//#include <stdlib.h> // exit()
|
||||||
|
|
||||||
|
// configuration file
|
||||||
|
#define CONF_NAME "./s52test.conf"
|
||||||
|
|
||||||
|
#define TRUE 1
|
||||||
|
#define FALSE 0
|
||||||
|
|
||||||
|
//#define CPATH_MAX 255
|
||||||
|
///////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// GLOBAL MARINER PARAMETER (will move out)
|
||||||
|
//
|
||||||
|
// NOTE: value for Chart No 1 found in README
|
||||||
|
//
|
||||||
|
// Soundings ON
|
||||||
|
// Text ON
|
||||||
|
// Depth Shades 4
|
||||||
|
// Safety Contour 10 m
|
||||||
|
// Safety Depth 7 m
|
||||||
|
// Shallow 5 m
|
||||||
|
// Deep 30 m
|
||||||
|
|
||||||
|
/* A) value for Chart No 1 */
|
||||||
|
/*
|
||||||
|
double SHOW_TEXT = TRUE; // view group 23
|
||||||
|
double TWO_SHADES = FALSE; // flag indicating selection of two depth
|
||||||
|
shades (on/off) [default ON] double SAFETY_CONTOUR = 10.0; // selected
|
||||||
|
safety contour (meters) [IMO PS 3.6] double SAFETY_DEPTH = 7.0; //
|
||||||
|
selected safety depth (meters) [IMO PS 3.7] double SHALLOW_CONTOUR = 5.0; //
|
||||||
|
selected shallow water contour (meters) (optional) double DEEP_CONTOUR = 30.0;
|
||||||
|
// selected deepwatercontour (meters) (optional)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* B) value for testing */
|
||||||
|
/*
|
||||||
|
//gboolean TWO_SHADES = TRUE; // flag indicating selection of two depth
|
||||||
|
shades (on/off) [default ON] gboolean TWO_SHADES = FALSE; // flag
|
||||||
|
indicating selection of two depth shades (on/off) [default ON] gboolean
|
||||||
|
SHOW_TEXT = TRUE; // view group 23
|
||||||
|
//double SAFETY_DEPTH = 30.0; // selected safety depth (meters) [IMO
|
||||||
|
PS 3.7]
|
||||||
|
//double SHALLOW_CONTOUR = 2.0; // selected shallow water contour
|
||||||
|
(meters) (optional) double SAFETY_DEPTH = 15.0; // selected safety
|
||||||
|
depth (meters) [IMO PS 3.7] double SHALLOW_CONTOUR = 5.0; // selected
|
||||||
|
shallow water contour (meters) (optional)
|
||||||
|
//double SAFETY_CONTOUR = 30.0; // selected safety contour (meters) [IMO
|
||||||
|
PS 3.6]
|
||||||
|
//double DEEP_CONTOUR = 30.0; // selected deepwatercontour (meters)
|
||||||
|
(optional)
|
||||||
|
//double SAFETY_CONTOUR = 5.0; // selected safety contour (meters) [IMO
|
||||||
|
PS 3.6]
|
||||||
|
//double DEEP_CONTOUR = 10.0; // selected deepwatercontour (meters)
|
||||||
|
(optional) double SAFETY_CONTOUR = 10.0; // selected safety contour
|
||||||
|
(meters) [IMO PS 3.6] double DEEP_CONTOUR = 15.0; // selected
|
||||||
|
deepwatercontour (meters) (optional)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* param needed for certain conditional symbology */
|
||||||
|
/*
|
||||||
|
gboolean SHALLOW_PATTERN = FALSE; // flag indicating selection of shallow
|
||||||
|
water highlight (on/off)(optional) [default OFF] gboolean SHIPS_OUTLINE =
|
||||||
|
FALSE; // flag indicating selection of ship scale symbol (on/off) [IMO
|
||||||
|
PS 8.4] double DISTANCE_TAGS = 0.0; // selected spacing of "distance to
|
||||||
|
run" tags at a route (nm) double TIME_TAGS = 0.0; // selected
|
||||||
|
spacing of time tags at the pasttrack (min) gboolean FULL_SECTORS = TRUE; //
|
||||||
|
show full length light sector lines gboolean SYMBOLIZED_BND = TRUE; //
|
||||||
|
symbolized area boundaries
|
||||||
|
*/
|
||||||
|
|
||||||
|
// WARNING: must be in sync with S52_MAR_param_t
|
||||||
|
/*
|
||||||
|
static char *_MARparamNm[] = {
|
||||||
|
"S52_MAR_NONE", //= 0, // default
|
||||||
|
"S52_MAR_SHOW_TEXT", //= 1, // view group 23
|
||||||
|
"S52_MAR_TWO_SHADES", //= 2, // flag indicating selection of two
|
||||||
|
depth shades (on/off) [default ON] "S52_MAR_SAFETY_CONTOUR", //= 3, //
|
||||||
|
selected safety contour (meters) [IMO PS 3.6] "S52_MAR_SAFETY_DEPTH", //= 4,
|
||||||
|
// selected safety depth (meters) [IMO PS 3.7] "S52_MAR_SHALLOW_CONTOUR", //=
|
||||||
|
5, // selected shallow water contour (meters) (optional)
|
||||||
|
"S52_MAR_DEEP_CONTOUR", //= 6, // selected deepwatercontour (meters)
|
||||||
|
(optional) "S52_MAR_SHALLOW_PATTERN", //= 7, // flag indicating selection of
|
||||||
|
shallow water highlight (on/off)(optional) [default OFF]
|
||||||
|
"S52_MAR_SHIPS_OUTLINE", //= 8, // flag indicating selection of ship
|
||||||
|
scale symbol (on/off) [IMO PS 8.4] "S52_MAR_DISTANCE_TAGS", //= 9, //
|
||||||
|
selected spacing of "distance to run" tags at a route (nm) "S52_MAR_TIME_TAGS",
|
||||||
|
//= 10, // selected spacing of time tags at the pasttrack (min)
|
||||||
|
"S52_MAR_FULL_SECTORS", //= 11, // show full length light sector lines
|
||||||
|
"S52_MAR_SYMBOLIZED_BND", //= 12, // symbolized area boundaries
|
||||||
|
"S52_MAR_SYMPLIFIED_PNT", //= 13, // simplified point
|
||||||
|
"S52_MAR_DISP_CATEGORY", //= 14, // display category
|
||||||
|
"S52_MAR_COLOR_PALETTE", //= 15, // color palette
|
||||||
|
|
||||||
|
"S52_MAR_NUM" //= 16 // number of parameters
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
// WARNING: must be in sync with _MARparamNm
|
||||||
|
static double _MARparamVal[] = {
|
||||||
|
0.0, // NONE
|
||||||
|
TRUE, // SHOW_TEXT
|
||||||
|
FALSE, // TWO_SHADES
|
||||||
|
|
||||||
|
3.0, // SAFETY_CONTOUR
|
||||||
|
// 0.0, // SAFETY_CONTOUR --to test DEPCNT02 selection (GL) in
|
||||||
|
// CA49995A.000 0.5, // SAFETY_CONTOUR --to test DEPCNT02 selection (GL)
|
||||||
|
// in CA49995A.000
|
||||||
|
|
||||||
|
3.0, // SAFETY_DEPTH
|
||||||
|
// 5.0, // SAFETY_DEPTH
|
||||||
|
|
||||||
|
2.0, // SHALLOW_CONTOUR
|
||||||
|
6.0, // DEEP_CONTOUR
|
||||||
|
|
||||||
|
// FALSE, // SHALLOW_PATTERN
|
||||||
|
TRUE, // SHALLOW_PATTERN
|
||||||
|
|
||||||
|
FALSE, // SHIPS_OUTLINE
|
||||||
|
0.0, // DISTANCE_TAGS
|
||||||
|
0.0, // TIME_TAGS
|
||||||
|
TRUE, // FULL_SECTORS
|
||||||
|
FALSE, // SYMBOLIZED_BND
|
||||||
|
|
||||||
|
FALSE, // SYMPLIFIED_PNT
|
||||||
|
|
||||||
|
// 'D', // S52_MAR_DISP_CATEGORY --DISPLAYBASE
|
||||||
|
// 'S', // S52_MAR_DISP_CATEGORY --STANDARD
|
||||||
|
'O', // S52_MAR_DISP_CATEGORY --OTHER
|
||||||
|
|
||||||
|
// 0, // S52_MAR_COLOR_PALETTE --DAY_BRIGHT
|
||||||
|
1, // S52_MAR_COLOR_PALETTE --DAY_BLACKBACK
|
||||||
|
// 2, // S52_MAR_COLOR_PALETTE --DAY_WHITEBACK
|
||||||
|
// 3, // S52_MAR_COLOR_PALETTE --DUSK
|
||||||
|
// 4, // S52_MAR_COLOR_PALETTE --NIGHT
|
||||||
|
|
||||||
|
16.0 // NUM
|
||||||
|
};
|
||||||
|
|
||||||
|
double S52_getMarinerParam(S52_MAR_param_t param)
|
||||||
|
// return Mariner parameter or '0.0' if fail
|
||||||
|
// FIXME: check mariner param against groups selection
|
||||||
|
{
|
||||||
|
// DSR
|
||||||
|
return _MARparamVal[param];
|
||||||
|
}
|
||||||
|
|
||||||
|
int S52_setMarinerParam(S52_MAR_param_t param, double val) {
|
||||||
|
if (S52_MAR_NONE < param && param < S52_MAR_NUM)
|
||||||
|
_MARparamVal[param] = val;
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
// S52utils.h: utility
|
||||||
|
//
|
||||||
|
// Project: OpENCview
|
||||||
|
|
||||||
|
/*
|
||||||
|
This file is part of the OpENCview project, a viewer of ENC
|
||||||
|
Copyright (C) 2000-2004 Sylvain Duclos sduclos@users.sourceforgue.net
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 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 the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||||
|
USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __S52UTILS_H__
|
||||||
|
#define __S52UTILS_H__
|
||||||
|
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/wx.h"
|
||||||
|
#endif // precompiled headers
|
||||||
|
|
||||||
|
inline int roundint (double x)
|
||||||
|
{
|
||||||
|
#ifdef __WXOSX__
|
||||||
|
return wxRound(x); //FS#1278
|
||||||
|
#else
|
||||||
|
int tmp = static_cast<int>(x);
|
||||||
|
tmp += (x - tmp >= .5) - (x - tmp <= -.5);
|
||||||
|
return tmp;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef SOLARIS
|
||||||
|
// well should be cc
|
||||||
|
#define PRINTF printf(__FILE__ ":%i: : ", __LINE__), printf
|
||||||
|
#else
|
||||||
|
#define PRINTF printf(__FILE__ ":%i: %s(): ", __LINE__, __FUNCTION__), printf
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// valid label in .conf file
|
||||||
|
#define CONF_CATALOG "CATALOG"
|
||||||
|
#define CONF_PLIB "PLIB"
|
||||||
|
#define CONF_CHART "CHART"
|
||||||
|
#define CONF_RGB "DUMMY_RGB_BRIGHT"
|
||||||
|
|
||||||
|
// global parameter for mariners' selection
|
||||||
|
typedef enum _S52_MAR_param_t {
|
||||||
|
S52_MAR_NONE = 0, // default
|
||||||
|
S52_MAR_SHOW_TEXT = 1, // view group 23
|
||||||
|
S52_MAR_TWO_SHADES =
|
||||||
|
2, // flag indicating selection of two depth shades (on/off) [default ON]
|
||||||
|
S52_MAR_SAFETY_CONTOUR = 3, // selected safety contour (meters) [IMO PS 3.6]
|
||||||
|
S52_MAR_SAFETY_DEPTH = 4, // selected safety depth (meters) [IMO PS 3.7]
|
||||||
|
S52_MAR_SHALLOW_CONTOUR =
|
||||||
|
5, // selected shallow water contour (meters) (optional)
|
||||||
|
S52_MAR_DEEP_CONTOUR = 6, // selected deepwatercontour (meters) (optional)
|
||||||
|
S52_MAR_SHALLOW_PATTERN = 7, // flag indicating selection of shallow water
|
||||||
|
// highlight (on/off)(optional) [default OFF]
|
||||||
|
S52_MAR_SHIPS_OUTLINE = 8, // flag indicating selection of ship scale symbol
|
||||||
|
// (on/off) [IMO PS 8.4]
|
||||||
|
S52_MAR_DISTANCE_TAGS =
|
||||||
|
9, // selected spacing of "distance to run" tags at a route (nm)
|
||||||
|
S52_MAR_TIME_TAGS =
|
||||||
|
10, // selected spacing of time tags at the pasttrack (min)
|
||||||
|
S52_MAR_FULL_SECTORS = 11, // show full length light sector lines
|
||||||
|
S52_MAR_SYMBOLIZED_BND = 12, // symbolized area boundaries
|
||||||
|
|
||||||
|
S52_MAR_SYMPLIFIED_PNT = 13, // simplified point
|
||||||
|
|
||||||
|
S52_MAR_DISP_CATEGORY = 14, // display category
|
||||||
|
|
||||||
|
S52_MAR_COLOR_PALETTE = 15, // color palette
|
||||||
|
|
||||||
|
S52_MAR_NUM = 16 // number of parameters
|
||||||
|
} S52_MAR_param_t;
|
||||||
|
|
||||||
|
extern double S52_getMarinerParam(S52_MAR_param_t param);
|
||||||
|
extern int S52_setMarinerParam(S52_MAR_param_t param, double val);
|
||||||
|
#endif
|
||||||
25
docs/外部参考/OpenCPN源码基线_f7211b4e/文件校验.sha256
Normal file
25
docs/外部参考/OpenCPN源码基线_f7211b4e/文件校验.sha256
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
b09e4785c5ef8418993606c2ba875422f113f30ccee4deadaef3f53aa06318d9 /root/sourceserver/cm95/docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/gui/src/cm93.cpp
|
||||||
|
e693b1dbbc40927c3a69a6cf3c16d295393ba378909d8fbae1216d79ab364a70 /root/sourceserver/cm95/docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/Cs52_shaders.cpp
|
||||||
|
738f294ed682e5bd8a379f125a80bf07c431f8ee780bc2c2024880286f1c34e3 /root/sourceserver/cm95/docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/Cs52_shaders.h
|
||||||
|
d5428f5265d1a82999b50ea6a05a054bf69230ddd2048bb2d9e0cee3a666da43 /root/sourceserver/cm95/docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/DepthFont.cpp
|
||||||
|
c3fd65c8d5013d359230bde03173d0711e1652a079e3e5a4af0232a9bb949324 /root/sourceserver/cm95/docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/DepthFont.h
|
||||||
|
9e8ec4c5b43b0499b5388e155f7de45f61a4f82edda156957552d7e488939ee5 /root/sourceserver/cm95/docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/TexFont.cpp
|
||||||
|
617f486076ede172c50b129a65df5765d2314594e6355f77920ba55567d338d5 /root/sourceserver/cm95/docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/TexFont.h
|
||||||
|
561d9fc303bca922a5b285184ba9e3b82f0ebac72e6c9f4bed99a6b7c51607fa /root/sourceserver/cm95/docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/chartsymbols.cpp
|
||||||
|
75b1eb93beb0aaff3a2693c12dde6c597fa5cac5b04c1e2c06896fbb5fb8283e /root/sourceserver/cm95/docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/chartsymbols.h
|
||||||
|
0b226162ee9dd15140db40f16495caf1bd999f3691b15b43cf6efd6306826446 /root/sourceserver/cm95/docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/color_types.h
|
||||||
|
1594f55ee1c88752be8004ca0b43a254312cc1dda96d98e7ee74db8fdf4a7093 /root/sourceserver/cm95/docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/mygeom.cpp
|
||||||
|
cc713bce1cceb54f44e95007c173b49f48336e8771072429950991cdcc1fac6b /root/sourceserver/cm95/docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/mygeom.h
|
||||||
|
baee3344a78848fc589828ac0c8bab6c147937a60d18d3864ce72265b2fe2238 /root/sourceserver/cm95/docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/s52_plib_utils.cpp
|
||||||
|
87f531bb7acc8d8a487f5237a85cebb663d86578e320f3ec566b1b42f18d55b4 /root/sourceserver/cm95/docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/s52_plib_utils.h
|
||||||
|
d094d9345fa76acf601ca2c1a48da7d65f06f3086b8f810e6d1ab9f8a5014ea4 /root/sourceserver/cm95/docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/s52cnsy.cpp
|
||||||
|
b376900cc16a5d2358feda178b9aa82c0853aa84fa61106b1590c49136f98970 /root/sourceserver/cm95/docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/s52plib.cpp
|
||||||
|
2a8fe104e646f52459d98c9aa1a0a014dde79421de6df96987650d7577436a40 /root/sourceserver/cm95/docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/s52plib.h
|
||||||
|
8f08fc6af340e1965b268f8f26c7ed7e7052e488a7cb5150016ebed99c74e98b /root/sourceserver/cm95/docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/s52plibGL.h
|
||||||
|
96d561915b867f5764c7d26b9577a52d121591665a1209a9feca106502cfccfc /root/sourceserver/cm95/docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/s52s57.h
|
||||||
|
5fea9dbbcd3ea21318792114ea436336f52dc19947acd2bac2af1d626816bbaf /root/sourceserver/cm95/docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/s52shaders.cpp
|
||||||
|
72b23f6ad581612b4a7881c83747170f039405bec2766bf465ca89af37575f0b /root/sourceserver/cm95/docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/s52shaders.h
|
||||||
|
cee04cc331ff70d94a88ec3061e6714f7ec7b8226727bd14d87be3c2c3c30ba6 /root/sourceserver/cm95/docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/s52utils.cpp
|
||||||
|
4feeefb368bf1aafd1620c15fe54662b8d2f9651cecc4123648b18aecfd1f74d /root/sourceserver/cm95/docs/外部参考/OpenCPN源码基线_f7211b4e/上游源码/libs/s52plib/src/s52utils.h
|
||||||
|
ead06c5e9b243275923928f60659a759507ab7ce56abebdefbcf6fcd22dba96c /root/sourceserver/cm95/docs/外部参考/OpenCPN源码基线_f7211b4e/许可证/COPYING.gplv2
|
||||||
|
3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986 /root/sourceserver/cm95/docs/外部参考/OpenCPN源码基线_f7211b4e/许可证/COPYING.gplv3
|
||||||
278
docs/外部参考/OpenCPN源码基线_f7211b4e/许可证/COPYING.gplv2
Normal file
278
docs/外部参考/OpenCPN源码基线_f7211b4e/许可证/COPYING.gplv2
Normal file
@@ -0,0 +1,278 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 2, June 1991
|
||||||
|
|
||||||
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The licenses for most software are designed to take away your
|
||||||
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
License is intended to guarantee your freedom to share and change free
|
||||||
|
software--to make sure the software is free for all its users. This
|
||||||
|
General Public License applies to most of the Free Software
|
||||||
|
Foundation's software and to any other program whose authors commit to
|
||||||
|
using it. (Some other Free Software Foundation software is covered by
|
||||||
|
the GNU Lesser General Public License instead.) You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
this service if you wish), that you receive source code or can get it
|
||||||
|
if you want it, that you can change the software or use pieces of it
|
||||||
|
in new free programs; and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to make restrictions that forbid
|
||||||
|
anyone to deny you these rights or to ask you to surrender the rights.
|
||||||
|
These restrictions translate to certain responsibilities for you if you
|
||||||
|
distribute copies of the software, or if you modify it.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must give the recipients all the rights that
|
||||||
|
you have. You must make sure that they, too, receive or can get the
|
||||||
|
source code. And you must show them these terms so they know their
|
||||||
|
rights.
|
||||||
|
|
||||||
|
We protect your rights with two steps: (1) copyright the software, and
|
||||||
|
(2) offer you this license which gives you legal permission to copy,
|
||||||
|
distribute and/or modify the software.
|
||||||
|
|
||||||
|
Also, for each author's protection and ours, we want to make certain
|
||||||
|
that everyone understands that there is no warranty for this free
|
||||||
|
software. If the software is modified by someone else and passed on, we
|
||||||
|
want its recipients to know that what they have is not the original, so
|
||||||
|
that any problems introduced by others will not reflect on the original
|
||||||
|
authors' reputations.
|
||||||
|
|
||||||
|
Finally, any free program is threatened constantly by software
|
||||||
|
patents. We wish to avoid the danger that redistributors of a free
|
||||||
|
program will individually obtain patent licenses, in effect making the
|
||||||
|
program proprietary. To prevent this, we have made it clear that any
|
||||||
|
patent must be licensed for everyone's free use or not licensed at all.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. This License applies to any program or other work which contains
|
||||||
|
a notice placed by the copyright holder saying it may be distributed
|
||||||
|
under the terms of this General Public License. The "Program", below,
|
||||||
|
refers to any such program or work, and a "work based on the Program"
|
||||||
|
means either the Program or any derivative work under copyright law:
|
||||||
|
that is to say, a work containing the Program or a portion of it,
|
||||||
|
either verbatim or with modifications and/or translated into another
|
||||||
|
language. (Hereinafter, translation is included without limitation in
|
||||||
|
the term "modification".) Each licensee is addressed as "you".
|
||||||
|
|
||||||
|
Activities other than copying, distribution and modification are not
|
||||||
|
covered by this License; they are outside its scope. The act of
|
||||||
|
running the Program is not restricted, and the output from the Program
|
||||||
|
is covered only if its contents constitute a work based on the
|
||||||
|
Program (independent of having been made by running the Program).
|
||||||
|
Whether that is true depends on what the Program does.
|
||||||
|
|
||||||
|
1. You may copy and distribute verbatim copies of the Program's
|
||||||
|
source code as you receive it, in any medium, provided that you
|
||||||
|
conspicuously and appropriately publish on each copy an appropriate
|
||||||
|
copyright notice and disclaimer of warranty; keep intact all the
|
||||||
|
notices that refer to this License and to the absence of any warranty;
|
||||||
|
and give any other recipients of the Program a copy of this License
|
||||||
|
along with the Program.
|
||||||
|
|
||||||
|
You may charge a fee for the physical act of transferring a copy, and
|
||||||
|
you may at your option offer warranty protection in exchange for a fee.
|
||||||
|
|
||||||
|
2. You may modify your copy or copies of the Program or any portion
|
||||||
|
of it, thus forming a work based on the Program, and copy and
|
||||||
|
distribute such modifications or work under the terms of Section 1
|
||||||
|
above, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) You must cause the modified files to carry prominent notices
|
||||||
|
stating that you changed the files and the date of any change.
|
||||||
|
|
||||||
|
b) You must cause any work that you distribute or publish, that in
|
||||||
|
whole or in part contains or is derived from the Program or any
|
||||||
|
part thereof, to be licensed as a whole at no charge to all third
|
||||||
|
parties under the terms of this License.
|
||||||
|
|
||||||
|
c) If the modified program normally reads commands interactively
|
||||||
|
when run, you must cause it, when started running for such
|
||||||
|
interactive use in the most ordinary way, to print or display an
|
||||||
|
announcement including an appropriate copyright notice and a
|
||||||
|
notice that there is no warranty (or else, saying that you provide
|
||||||
|
a warranty) and that users may redistribute the program under
|
||||||
|
these conditions, and telling the user how to view a copy of this
|
||||||
|
License. (Exception: if the Program itself is interactive but
|
||||||
|
does not normally print such an announcement, your work based on
|
||||||
|
the Program is not required to print an announcement.)
|
||||||
|
|
||||||
|
These requirements apply to the modified work as a whole. If
|
||||||
|
identifiable sections of that work are not derived from the Program,
|
||||||
|
and can be reasonably considered independent and separate works in
|
||||||
|
themselves, then this License, and its terms, do not apply to those
|
||||||
|
sections when you distribute them as separate works. But when you
|
||||||
|
distribute the same sections as part of a whole which is a work based
|
||||||
|
on the Program, the distribution of the whole must be on the terms of
|
||||||
|
this License, whose permissions for other licensees extend to the
|
||||||
|
entire whole, and thus to each and every part regardless of who wrote it.
|
||||||
|
|
||||||
|
Thus, it is not the intent of this section to claim rights or contest
|
||||||
|
your rights to work written entirely by you; rather, the intent is to
|
||||||
|
exercise the right to control the distribution of derivative or
|
||||||
|
collective works based on the Program.
|
||||||
|
|
||||||
|
In addition, mere aggregation of another work not based on the Program
|
||||||
|
with the Program (or with a work based on the Program) on a volume of
|
||||||
|
a storage or distribution medium does not bring the other work under
|
||||||
|
the scope of this License.
|
||||||
|
|
||||||
|
3. You may copy and distribute the Program (or a work based on it,
|
||||||
|
under Section 2) in object code or executable form under the terms of
|
||||||
|
Sections 1 and 2 above provided that you also do one of the following:
|
||||||
|
|
||||||
|
a) Accompany it with the complete corresponding machine-readable
|
||||||
|
source code, which must be distributed under the terms of Sections
|
||||||
|
1 and 2 above on a medium customarily used for software interchange; or,
|
||||||
|
|
||||||
|
b) Accompany it with a written offer, valid for at least three
|
||||||
|
years, to give any third party, for a charge no more than your
|
||||||
|
cost of physically performing source distribution, a complete
|
||||||
|
machine-readable copy of the corresponding source code, to be
|
||||||
|
distributed under the terms of Sections 1 and 2 above on a medium
|
||||||
|
customarily used for software interchange; or,
|
||||||
|
|
||||||
|
c) Accompany it with the information you received as to the offer
|
||||||
|
to distribute corresponding source code. (This alternative is
|
||||||
|
allowed only for noncommercial distribution and only if you
|
||||||
|
received the program in object code or executable form with such
|
||||||
|
an offer, in accord with Subsection b above.)
|
||||||
|
|
||||||
|
The source code for a work means the preferred form of the work for
|
||||||
|
making modifications to it. For an executable work, complete source
|
||||||
|
code means all the source code for all modules it contains, plus any
|
||||||
|
associated interface definition files, plus the scripts used to
|
||||||
|
control compilation and installation of the executable. However, as a
|
||||||
|
special exception, the source code distributed need not include
|
||||||
|
anything that is normally distributed (in either source or binary
|
||||||
|
form) with the major components (compiler, kernel, and so on) of the
|
||||||
|
operating system on which the executable runs, unless that component
|
||||||
|
itself accompanies the executable.
|
||||||
|
|
||||||
|
If distribution of executable or object code is made by offering
|
||||||
|
access to copy from a designated place, then offering equivalent
|
||||||
|
access to copy the source code from the same place counts as
|
||||||
|
distribution of the source code, even though third parties are not
|
||||||
|
compelled to copy the source along with the object code.
|
||||||
|
|
||||||
|
4. You may not copy, modify, sublicense, or distribute the Program
|
||||||
|
except as expressly provided under this License. Any attempt
|
||||||
|
otherwise to copy, modify, sublicense or distribute the Program is
|
||||||
|
void, and will automatically terminate your rights under this License.
|
||||||
|
However, parties who have received copies, or rights, from you under
|
||||||
|
this License will not have their licenses terminated so long as such
|
||||||
|
parties remain in full compliance.
|
||||||
|
|
||||||
|
5. You are not required to accept this License, since you have not
|
||||||
|
signed it. However, nothing else grants you permission to modify or
|
||||||
|
distribute the Program or its derivative works. These actions are
|
||||||
|
prohibited by law if you do not accept this License. Therefore, by
|
||||||
|
modifying or distributing the Program (or any work based on the
|
||||||
|
Program), you indicate your acceptance of this License to do so, and
|
||||||
|
all its terms and conditions for copying, distributing or modifying
|
||||||
|
the Program or works based on it.
|
||||||
|
|
||||||
|
6. Each time you redistribute the Program (or any work based on the
|
||||||
|
Program), the recipient automatically receives a license from the
|
||||||
|
original licensor to copy, distribute or modify the Program subject to
|
||||||
|
these terms and conditions. You may not impose any further
|
||||||
|
restrictions on the recipients' exercise of the rights granted herein.
|
||||||
|
You are not responsible for enforcing compliance by third parties to
|
||||||
|
this License.
|
||||||
|
|
||||||
|
7. If, as a consequence of a court judgment or allegation of patent
|
||||||
|
infringement or for any other reason (not limited to patent issues),
|
||||||
|
conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot
|
||||||
|
distribute so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you
|
||||||
|
may not distribute the Program at all. For example, if a patent
|
||||||
|
license would not permit royalty-free redistribution of the Program by
|
||||||
|
all those who receive copies directly or indirectly through you, then
|
||||||
|
the only way you could satisfy both it and this License would be to
|
||||||
|
refrain entirely from distribution of the Program.
|
||||||
|
|
||||||
|
If any portion of this section is held invalid or unenforceable under
|
||||||
|
any particular circumstance, the balance of the section is intended to
|
||||||
|
apply and the section as a whole is intended to apply in other
|
||||||
|
circumstances.
|
||||||
|
|
||||||
|
It is not the purpose of this section to induce you to infringe any
|
||||||
|
patents or other property right claims or to contest validity of any
|
||||||
|
such claims; this section has the sole purpose of protecting the
|
||||||
|
integrity of the free software distribution system, which is
|
||||||
|
implemented by public license practices. Many people have made
|
||||||
|
generous contributions to the wide range of software distributed
|
||||||
|
through that system in reliance on consistent application of that
|
||||||
|
system; it is up to the author/donor to decide if he or she is willing
|
||||||
|
to distribute software through any other system and a licensee cannot
|
||||||
|
impose that choice.
|
||||||
|
|
||||||
|
This section is intended to make thoroughly clear what is believed to
|
||||||
|
be a consequence of the rest of this License.
|
||||||
|
|
||||||
|
8. If the distribution and/or use of the Program is restricted in
|
||||||
|
certain countries either by patents or by copyrighted interfaces, the
|
||||||
|
original copyright holder who places the Program under this License
|
||||||
|
may add an explicit geographical distribution limitation excluding
|
||||||
|
those countries, so that distribution is permitted only in or among
|
||||||
|
countries not thus excluded. In such case, this License incorporates
|
||||||
|
the limitation as if written in the body of this License.
|
||||||
|
|
||||||
|
9. The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Program
|
||||||
|
specifies a version number of this License which applies to it and "any
|
||||||
|
later version", you have the option of following the terms and conditions
|
||||||
|
either of that version or of any later version published by the Free
|
||||||
|
Software Foundation. If the Program does not specify a version number of
|
||||||
|
this License, you may choose any version ever published by the Free Software
|
||||||
|
Foundation.
|
||||||
|
|
||||||
|
10. If you wish to incorporate parts of the Program into other free
|
||||||
|
programs whose distribution conditions are different, write to the author
|
||||||
|
to ask for permission. For software which is copyrighted by the Free
|
||||||
|
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||||
|
make exceptions for this. Our decision will be guided by the two goals
|
||||||
|
of preserving the free status of all derivatives of our free software and
|
||||||
|
of promoting the sharing and reuse of software generally.
|
||||||
|
|
||||||
|
NO WARRANTY
|
||||||
|
|
||||||
|
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||||
|
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||||
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||||
|
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||||
|
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||||
|
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||||
|
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||||
|
REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||||
|
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||||
|
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||||
|
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||||
|
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||||
|
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGES.
|
||||||
674
docs/外部参考/OpenCPN源码基线_f7211b4e/许可证/COPYING.gplv3
Normal file
674
docs/外部参考/OpenCPN源码基线_f7211b4e/许可证/COPYING.gplv3
Normal file
@@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
25
docs/外部参考/OpenCPN源码基线_f7211b4e/说明.md
Normal file
25
docs/外部参考/OpenCPN源码基线_f7211b4e/说明.md
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# OpenCPN 对照源码基线说明
|
||||||
|
|
||||||
|
本目录保存 CM95 → PBF → S-52 / OpenCPN 流程等价审计使用的 OpenCPN 上游源码快照。
|
||||||
|
|
||||||
|
## 固定上游基线
|
||||||
|
|
||||||
|
- OpenCPN commit:`f7211b4e1874c453e37a7f190aa191c55a25c32e`
|
||||||
|
- 本地取得来源:`/tmp/opencpn-s52-audit/`
|
||||||
|
- 保存方式:按上游原始文件内容复制,不对源码做修改。
|
||||||
|
- `gui/src/cm93.cpp` 因原 checkout 使用 sparse-checkout 未落到工作树,使用 `git show <commit>:gui/src/cm93.cpp` 从同一 commit 直接导出。
|
||||||
|
- `/tmp/opencpn_cm93.cpp` 与该 commit 的 `gui/src/cm93.cpp` SHA-256 已确认完全一致。
|
||||||
|
|
||||||
|
## 保存范围
|
||||||
|
|
||||||
|
- `上游源码/gui/src/cm93.cpp`:CM93 对象创建、M_COVR 与 CM93→S57/S-52 类转换参考。
|
||||||
|
- `上游源码/libs/s52plib/src/`:完整 S-52 Presentation Library 源码目录,包含 CSP、Lookup/rule parser、primitive renderer、chartsymbols 与相关辅助实现。
|
||||||
|
- `许可证/`:上游 GPL v2 / GPL v3 许可证原文。
|
||||||
|
- `文件校验.sha256`:本目录上游源码与许可证文件的 SHA-256 校验清单。
|
||||||
|
- `上游提交.txt`:固定 commit 全长 hash。
|
||||||
|
|
||||||
|
## 审计规则
|
||||||
|
|
||||||
|
后续 CM95 的 OpenCPN Code-First S-52 Rendering Equivalence Audit 应优先引用本目录,不再依赖 `/tmp` 临时文件。
|
||||||
|
本目录是只读参考快照;如果以后切换 OpenCPN 基线,不覆盖本目录,而应新增新的 commit 基线目录并在审计报告中明确使用哪一版。
|
||||||
|
源码文件保留其原始版权与许可证声明;CM95 自有代码与此上游参考快照必须保持清晰边界。
|
||||||
Reference in New Issue
Block a user