Skip to content

Commit

Permalink
[mathgl] Update to v2.5 (#22081)
Browse files Browse the repository at this point in the history
* [mathgl] Update to v2.5 and apply fixes

* Update CI baseline
  • Loading branch information
wtywtykk authored Dec 28, 2021
1 parent 52f690e commit 9502b20
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 185 deletions.
14 changes: 14 additions & 0 deletions ports/mathgl/fix_arma_sprintf.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git "a/include/mgl2/define.h" "b/include/mgl2/define.h"
index e23ec04..8e79086 100644
--- "a/include/mgl2/define.h"
+++ "b/include/mgl2/define.h"
@@ -141,7 +140,9 @@ typedef long msize;
#define getcwd _getcwd
#define chdir _chdir // BORLAND has chdir
#endif
+#if (_MSC_VER<1500)
#define snprintf _snprintf
+#endif
#if (_MSC_VER<1600) // based on https://hg.python.org/cpython/rev/9aedb876c2d7
#define hypot _hypot
#endif
11 changes: 11 additions & 0 deletions ports/mathgl/fix_attribute.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/include/mgl2/define.h 2021-12-08 13:59:55.000000000 +0800
+++ a/include/mgl2/define.h 2021-12-15 10:39:09.701079400 +0800
@@ -66,6 +66,8 @@
#else
#define MGL_FUNC_CONST
#define MGL_FUNC_PURE
+#define MGL_FUNC_INIT
+#define MGL_FUNC_FINI
#endif
#define MGL_EXPORT_CONST MGL_EXPORT MGL_FUNC_CONST
#define MGL_EXPORT_PURE MGL_EXPORT MGL_FUNC_PURE
115 changes: 0 additions & 115 deletions ports/mathgl/fix_cmakelists_and_cpp.patch
Original file line number Diff line number Diff line change
Expand Up @@ -15,121 +15,6 @@ index 1649104..eeec1c1 100644
install(
TARGETS mgllab
RUNTIME DESTINATION bin )
diff --git a/mgllab/table.cpp b/mgllab/table.cpp
index 5243549..23eebe5 100644
--- a/mgllab/table.cpp
+++ b/mgllab/table.cpp
@@ -559,8 +559,13 @@ public:
o->tooltip(_("Change data values and close this window"));
w->set_modal(); w->end();
}
- double min() { return wmin->value(); }
- double max() { return wmax->value(); }
+ #if WIN32
+ double _min() { return wmin->value(); }
+ double _max() { return wmax->value(); }
+ #else
+ double min() { return wmin->value(); }
+ double max() { return wmax->value(); }
+ #endif
int sym() { return wsym->value(); }
bool ok() { return !result.empty(); }
void cb_ok()
@@ -581,8 +586,14 @@ void fill_cb(Fl_Widget*, void*v)
HMDT d = dynamic_cast<HMDT>(e->var);
HADT c = dynamic_cast<HADT>(e->var);
char ch = nrm_dlg.result[0];
- if(d) { d->Fill(nrm_dlg.min(),nrm_dlg.max(),ch); e->refresh(); }
- if(c) { c->Fill(nrm_dlg.min(),nrm_dlg.max(),ch); e->refresh(); }
+ #if WIN32
+ if(d) { d->Fill(nrm_dlg._min(),nrm_dlg._max(),ch); e->refresh(); }
+ if(c) { c->Fill(nrm_dlg._min(),nrm_dlg._max(),ch); e->refresh(); }
+ #else
+ if(d) { d->Fill(nrm_dlg.min(),nrm_dlg.max(),ch); e->refresh(); }
+ if(c) { c->Fill(nrm_dlg.min(),nrm_dlg.max(),ch); e->refresh(); }
+ #endif
+
}
}
//-----------------------------------------------------------------------------
@@ -594,8 +605,13 @@ void normal_cb(Fl_Widget*, void*v)
{
HMDT d = dynamic_cast<HMDT>(e->var);
HADT c = dynamic_cast<HADT>(e->var);
- if(d) { d->Norm(nrm_dlg.min(),nrm_dlg.max(),nrm_dlg.sym()); e->refresh(); }
- if(c) { c->Fill(nrm_dlg.min(),nrm_dlg.max(),nrm_dlg.sym()); e->refresh(); }
+ #if WIN32
+ if(d) { d->Norm(nrm_dlg._min(),nrm_dlg._max(),nrm_dlg.sym()); e->refresh(); }
+ if(c) { c->Fill(nrm_dlg._min(),nrm_dlg._max(),nrm_dlg.sym()); e->refresh(); }
+ #else
+ if(d) { d->Norm(nrm_dlg.min(),nrm_dlg.max(),nrm_dlg.sym()); e->refresh(); }
+ if(c) { c->Fill(nrm_dlg.min(),nrm_dlg.max(),nrm_dlg.sym()); e->refresh(); }
+ #endif
}
}
//-----------------------------------------------------------------------------
diff --git a/src/parser.cpp b/src/parser.cpp
index 577191d..e6909a1 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -58,7 +58,10 @@ void mglParser::FillBaseCmd()
HMDT MGL_NO_EXPORT mglFormulaCalc(std::wstring string, mglParser *arg, const std::vector<mglDataA*> &head);
HADT MGL_NO_EXPORT mglFormulaCalcC(std::wstring string, mglParser *arg, const std::vector<mglDataA*> &head);
//-----------------------------------------------------------------------------
+#ifndef MGL_ASK_FUNC
+#define MGL_ASK_FUNC
MGL_EXPORT void (*mgl_ask_func)(const wchar_t *, wchar_t *)=0;
+#endif
void MGL_EXPORT mgl_ask_gets(const wchar_t *quest, wchar_t *res)
{ printf("%ls\n",quest); if(!fgetws(res,1024,stdin)) *res=0; }
//-----------------------------------------------------------------------------
@@ -69,7 +72,10 @@ void MGL_EXPORT mgl_progress_txt(int value, int maximal, HMGL)
else for(int i=prev;i<value;i++) printf("#");
prev = value; fflush(stdout);
}
+#ifndef MGL_PROGRESS_FUNC
+#define MGL_PROGRESS_FUNC
MGL_EXPORT void (*mgl_progress_func)(int value, int maximal, HMGL)=mgl_progress_txt;
+#endif
void MGL_EXPORT mgl_progress(int value, int maximal, HMGL gr)
{ mgl_progress_func(value, maximal, gr); }
//-----------------------------------------------------------------------------
diff --git a/utils/mglview.cpp b/utils/mglview.cpp
index d360df3..7e2634b 100644
--- a/utils/mglview.cpp
+++ b/utils/mglview.cpp
@@ -29,6 +29,18 @@
#include "mgl2/qt.h"
#endif
//-----------------------------------------------------------------------------
+#ifdef WIN32
+#ifndef MGL_ASK_FUNC
+#define MGL_ASK_FUNC
+MGL_EXPORT void (*mgl_ask_func)(const wchar_t *, wchar_t *)=0;
+#endif
+#ifndef MGL_PROGRESS_FUNC
+#define MGL_PROGRESS_FUNC
+MGL_EXPORT void (*mgl_progress_func)(int value, int maximal, HMGL)=0;
+#endif
+MGL_EXPORT std::string mglGlobalMess; ///< Buffer for receiving global messages
+#endif
+//-----------------------------------------------------------------------------
std::wstring str, opt;
std::vector<std::string> anim;
mglParse p(true);
diff --git a/include/mgl2/datac.h b/include/mgl2/datac.h
index f2c0251..0e69de7 100644
--- a/include/mgl2/datac.h
+++ b/include/mgl2/datac.h
@@ -474,7 +474,7 @@ using mglDataA::Momentum;
void set_v(mreal val, long i,long j=0,long k=0) { a[i+nx*(j+ny*k)]=val; }
#else
/// Get the value in given cell of the data with border checking
- mreal v(long i,long j=0,long k=0) const { return mgl_abs(mgl_datac_get_value(this,i,j,k)); }
+ mreal v(long i,long j=0,long k=0) const { return abs(a[i+nx*(j+ny*k)]); }
/// Set the value in given cell of the data
void set_v(mreal val, long i,long j=0,long k=0) { mgl_datac_set_value(this,val,i,j,k); }
#endif
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d0c779d..acd9d7f 100644
--- a/CMakeLists.txt
Expand Down
21 changes: 21 additions & 0 deletions ports/mathgl/fix_default_graph_init.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git "a/src/canvas_cf.cpp" "b/src/canvas_cf.cpp"
index 5e1443a..26a0a8e 100644
--- "a/src/canvas_cf.cpp"
+++ "b/src/canvas_cf.cpp"
@@ -50,7 +50,6 @@ void MGL_EXPORT MGL_FUNC_INIT mgl_init() // TODO try to add ld option: "-init mg
#endif
for(long i=0;i<360;i++) mgl_cos[i] = cos(i*M_PI/180.);
if(!mglDefFont) mglDefFont = new mglFont(MGL_DEF_FONT_NAME);
- if(!mglDefaultGr) mglDefaultGr = new mglCanvas(600,400);
}
}
void MGL_EXPORT MGL_FUNC_FINI mgl_fini() // TODO try to add ld option: "-fini mgl_fini"
@@ -434,7 +433,7 @@ void MGL_EXPORT mgl_set_legend_marks(HMGL gr, int num)
uintptr_t MGL_EXPORT mgl_create_graph_(int *width, int *height)
{ return uintptr_t(new mglCanvas(*width,*height)); }
void MGL_EXPORT mgl_delete_graph_(uintptr_t *gr) { delete _GR_; }
-uintptr_t MGL_EXPORT mgl_default_graph_() { return uintptr_t(&mglDefaultGr); }
+uintptr_t MGL_EXPORT mgl_default_graph_() { return uintptr_t(mgl_default_graph()); }
void MGL_EXPORT mgl_set_size_scl_(double *scl) { mgl_set_size_scl(*scl); }
void MGL_EXPORT mgl_set_size_(uintptr_t *gr, int *width, int *height)
{ mgl_set_size(_GR_,*width,*height); }
28 changes: 28 additions & 0 deletions ports/mathgl/fix_mglDataList.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/include/mgl2/abstract.h b/include/mgl2/abstract.h
index c8c53b8..245333b 100644
--- a/include/mgl2/abstract.h
+++ b/include/mgl2/abstract.h
@@ -235,7 +235,11 @@ struct MGL_EXPORT mglNum
};
//-----------------------------------------------------------------------------
/// List of user-defined data arrays
+#ifndef MGL_WIDGETS_DLL
MGL_EXPORT extern std::vector<mglDataA*> mglDataList;
+#else
+__declspec(dllimport) extern std::vector<mglDataA*> mglDataList;
+#endif
//-----------------------------------------------------------------------------
/// Abstract class for data array
class MGL_EXPORT mglDataA
diff --git a/widgets/CMakeLists.txt b/widgets/CMakeLists.txt
index a9e1269..4c1d0d4 100644
--- a/widgets/CMakeLists.txt
+++ b/widgets/CMakeLists.txt
@@ -2,6 +2,7 @@ include(GenerateExportHeader)

if(MSVC)
add_definitions(-DMGL_LIB_MSVC)
+ add_definitions(-DMGL_WIDGETS_DLL)
endif(MSVC)

if(MGL_HAVE_FLTK)
13 changes: 9 additions & 4 deletions ports/mathgl/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
set(MATHGL_VERSION "2.4.3")
set(MATHGL_VERSION "2.5")

vcpkg_from_sourceforge(
OUT_SOURCE_PATH SOURCE_PATH
REPO mathgl/mathgl
REF mathgl%20${MATHGL_VERSION}
FILENAME "mathgl-${MATHGL_VERSION}.tar.gz"
SHA512 e47fc8171ce80c8b33a8f03d9375bc036455dae539b47cf4ee922f8fa36f5afcf8b3f0666997764e453eb698c0e8c03da36dd0ac2bf71c158e95309b247d27de
SHA512 1fe27962ffef8d7127c4e1294d735e5da4dd2d647397f09705c3ca860f90bd06fd447ff614e584f3d2b874a02262c5518be37d59e9e0a838dd5b8b64fd77ef9d
PATCHES
type_fix.patch
fix_cmakelists_and_cpp.patch
fix_attribute.patch
fix_default_graph_init.patch
fix_mglDataList.patch
fix_arma_sprintf.patch
)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
hdf5 enable-hdf5
fltk enable-fltk
gif enable-gif
arma enable-arma
png enable-png
zlib enable-zlib
jpeg enable-jpeg
Expand All @@ -38,7 +43,7 @@ if(NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore
file(REMOVE "${CURRENT_PACKAGES_DIR}/mathgl2-config.cmake")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/mathgl2-config.cmake")
else()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/mathgl)
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/mathgl2)
endif()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
Expand Down
62 changes: 0 additions & 62 deletions ports/mathgl/type_fix.patch

This file was deleted.

9 changes: 7 additions & 2 deletions ports/mathgl/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "mathgl",
"version": "2.4.3",
"port-version": 8,
"version": "2.5",
"description": "MathGL is a free library of fast C++ routines for the plotting of the data varied in one or more dimensions",
"dependencies": [
{
Expand All @@ -20,6 +19,12 @@
"zlib"
],
"features": {
"arma": {
"description": "Armadillo support",
"dependencies": [
"armadillo"
]
},
"fltk": {
"description": "fltk module",
"dependencies": [
Expand Down
4 changes: 2 additions & 2 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -4297,8 +4297,8 @@
"port-version": 1
},
"mathgl": {
"baseline": "2.4.3",
"port-version": 8
"baseline": "2.5",
"port-version": 0
},
"matio": {
"baseline": "1.5.19",
Expand Down
5 changes: 5 additions & 0 deletions versions/m-/mathgl.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "d75f46bbb8d518f326f688d355d5e9d241f44dc6",
"version": "2.5",
"port-version": 0
},
{
"git-tree": "27b4e9bc3b747e8c53489a5ef16b85a3f6035504",
"version": "2.4.3",
Expand Down

0 comments on commit 9502b20

Please sign in to comment.