diff --git a/doc/texinfo/api.texi b/doc/texinfo/api.texi index c150500998463c9c9139e2eb29487f082478fb6b..1dfac67e44d271f82aca3b95b4454c05cbdbdc38 100644 --- a/doc/texinfo/api.texi +++ b/doc/texinfo/api.texi @@ -186,7 +186,7 @@ are listed in the Gmsh reference manual. @item Language-specific definition: @url{@value{GITLAB-PREFIX}/api/gmsh.h#L123,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L97,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L364,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L178,Julia} @item Examples: -C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/t8.cpp#L118,t8.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/x3.cpp#L93,x3.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/t8.py#L152,t8.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/x3.py#L84,x3.py}, @url{@value{GITLAB-PREFIX}/examples/api/test.py#L5,test.py}) +C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/t8.cpp#L134,t8.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/t8.py#L136,t8.py}, @url{@value{GITLAB-PREFIX}/examples/api/test.py#L5,test.py}) @end table @item gmsh/option/setString @@ -204,7 +204,7 @@ are listed in the Gmsh reference manual. @item Language-specific definition: @url{@value{GITLAB-PREFIX}/api/gmsh.h#L131,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L104,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L386,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L196,Julia} @item Examples: -C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/t4.cpp#L151,t4.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/t8.cpp#L92,t8.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/t4.py#L159,t4.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/t8.py#L89,t8.py}) +C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/t4.cpp#L153,t4.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/t4.py#L161,t4.py}) @end table @item gmsh/option/getString @@ -5411,8 +5411,6 @@ access view options. integer value @item Language-specific definition: @url{@value{GITLAB-PREFIX}/api/gmsh.h#L3230,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L2864,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L7129,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L6158,Julia} -@item Examples: -C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/x3.cpp#L89,x3.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/t8.py#L81,t8.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/x3.py#L81,x3.py}) @end table @item gmsh/view/getTags @@ -5428,7 +5426,7 @@ Get the tags of all views. @item Language-specific definition: @url{@value{GITLAB-PREFIX}/api/gmsh.h#L3235,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L2868,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L7149,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L6175,Julia} @item Examples: -Python (@url{@value{GITLAB-PREFIX}/tutorials/python/t8.py#L78,t8.py}, @url{@value{GITLAB-PREFIX}/examples/api/plugin.py#L31,plugin.py}) +C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/t8.cpp#L81,t8.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/t9.cpp#L37,t9.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/t8.py#L77,t8.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/t9.py#L27,t9.py}, @url{@value{GITLAB-PREFIX}/examples/api/plugin.py#L31,plugin.py}) @end table @item gmsh/view/addModelData @@ -5627,7 +5625,7 @@ matrices. @item Language-specific definition: @url{@value{GITLAB-PREFIX}/api/gmsh.h#L3376,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3001,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L7427,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L6422,Julia} @item Examples: -C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/x3.cpp#L129,x3.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/x3.py#L113,x3.py}) +C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/x3.cpp#L126,x3.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/x3.py#L110,x3.py}) @end table @item gmsh/view/addAlias @@ -5694,7 +5692,7 @@ specified dimension. @item Language-specific definition: @url{@value{GITLAB-PREFIX}/api/gmsh.h#L3421,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3043,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L7506,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L6487,Julia} @item Examples: -C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/x3.cpp#L101,x3.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/x3.py#L89,x3.py}) +C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/x3.cpp#L98,x3.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/x3.py#L86,x3.py}) @end table @item gmsh/view/write @@ -5711,7 +5709,7 @@ file extension. Append to the file if @code{append} is set. @item Language-specific definition: @url{@value{GITLAB-PREFIX}/api/gmsh.h#L3440,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3061,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L7555,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L6506,Julia} @item Examples: -C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/x3.cpp#L107,x3.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/x4.cpp#L88,x4.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/x3.py#L92,x3.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/x4.py#L81,x4.py}, @url{@value{GITLAB-PREFIX}/examples/api/adapt_mesh.py#L91,adapt_mesh.py}, @url{@value{GITLAB-PREFIX}/examples/api/normals.py#L43,normals.py}, @url{@value{GITLAB-PREFIX}/examples/api/plugin.py#L33,plugin.py}, ...) +C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/x3.cpp#L104,x3.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/x4.cpp#L88,x4.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/x3.py#L89,x3.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/x4.py#L81,x4.py}, @url{@value{GITLAB-PREFIX}/examples/api/adapt_mesh.py#L91,adapt_mesh.py}, @url{@value{GITLAB-PREFIX}/examples/api/normals.py#L43,normals.py}, @url{@value{GITLAB-PREFIX}/examples/api/plugin.py#L33,plugin.py}, ...) @end table @item gmsh/view/setVisibilityPerWindow @@ -5748,6 +5746,8 @@ Set the numerical option @code{name} to value @code{value} for the view with tag - @item Language-specific definition: @url{@value{GITLAB-PREFIX}/api/gmsh.h#L3458,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3075,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L7596,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L6545,Julia} +@item Examples: +C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/t8.cpp#L83,t8.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/t9.cpp#L73,t9.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/x3.cpp#L87,x3.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/t8.py#L80,t8.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/t9.py#L63,t9.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/x3.py#L79,x3.py}) @end table @item gmsh/view/option/getNumber @@ -5763,6 +5763,8 @@ Get the @code{value} of the numerical option @code{name} for the view with tag - @item Language-specific definition: @url{@value{GITLAB-PREFIX}/api/gmsh.h#L3466,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3081,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L7614,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L6562,Julia} +@item Examples: +C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/t8.cpp#L121,t8.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/x3.cpp#L90,x3.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/t8.py#L122,t8.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/x3.py#L81,x3.py}) @end table @item gmsh/view/option/setString @@ -5778,6 +5780,8 @@ Set the string option @code{name} to value @code{value} for the view with tag - @item Language-specific definition: @url{@value{GITLAB-PREFIX}/api/gmsh.h#L3473,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3087,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L7635,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L6578,Julia} +@item Examples: +C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/t4.cpp#L151,t4.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/t8.cpp#L95,t8.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/t4.py#L159,t4.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/t8.py#L92,t8.py}) @end table @item gmsh/view/option/getString @@ -5861,7 +5865,7 @@ Set the numerical option @code{option} to the value @code{value} for plugin @item Language-specific definition: @url{@value{GITLAB-PREFIX}/api/gmsh.h#L3523,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3126,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L7749,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L6678,Julia} @item Examples: -C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/t9.cpp#L38,t9.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/t21.cpp#L144,t21.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/t9.py#L30,t9.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/t21.py#L131,t21.py}, @url{@value{GITLAB-PREFIX}/examples/api/crack3d.py#L29,crack3d.py}, @url{@value{GITLAB-PREFIX}/examples/api/crack.py#L33,crack.py}, @url{@value{GITLAB-PREFIX}/examples/api/get_data_perf.py#L15,get_data_perf.py}, ...) +C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/t9.cpp#L41,t9.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/t21.cpp#L144,t21.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/t9.py#L31,t9.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/t21.py#L131,t21.py}, @url{@value{GITLAB-PREFIX}/examples/api/crack3d.py#L29,crack3d.py}, @url{@value{GITLAB-PREFIX}/examples/api/crack.py#L33,crack.py}, @url{@value{GITLAB-PREFIX}/examples/api/get_data_perf.py#L15,get_data_perf.py}, ...) @end table @item gmsh/plugin/setString @@ -5878,7 +5882,7 @@ Set the string option @code{option} to the value @code{value} for plugin @item Language-specific definition: @url{@value{GITLAB-PREFIX}/api/gmsh.h#L3530,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3132,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L7766,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L6693,Julia} @item Examples: -C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/t9.cpp#L54,t9.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/t9.py#L46,t9.py}) +C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/t9.cpp#L57,t9.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/t9.py#L47,t9.py}) @end table @item gmsh/plugin/run @@ -5894,7 +5898,7 @@ integer value @item Language-specific definition: @url{@value{GITLAB-PREFIX}/api/gmsh.h#L3537,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3138,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L7783,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L6710,Julia} @item Examples: -C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/t9.cpp#L40,t9.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/t21.cpp#L147,t21.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/t9.py#L32,t9.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/t21.py#L134,t21.py}, @url{@value{GITLAB-PREFIX}/examples/api/crack3d.py#L32,crack3d.py}, @url{@value{GITLAB-PREFIX}/examples/api/crack.py#L35,crack.py}, @url{@value{GITLAB-PREFIX}/examples/api/get_data_perf.py#L16,get_data_perf.py}, ...) +C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/t9.cpp#L43,t9.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/t21.cpp#L147,t21.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/t9.py#L33,t9.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/t21.py#L134,t21.py}, @url{@value{GITLAB-PREFIX}/examples/api/crack3d.py#L32,crack3d.py}, @url{@value{GITLAB-PREFIX}/examples/api/crack.py#L35,crack.py}, @url{@value{GITLAB-PREFIX}/examples/api/get_data_perf.py#L16,get_data_perf.py}, ...) @end table @end ftable @@ -5916,7 +5920,7 @@ Draw all the OpenGL scenes. @item Language-specific definition: @url{@value{GITLAB-PREFIX}/api/gmsh.h#L3546,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3142,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L7806,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L6735,Julia} @item Examples: -C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/t3.cpp#L129,t3.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/t8.cpp#L150,t8.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/t13.cpp#L129,t13.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/t21.cpp#L192,t21.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/t3.py#L120,t3.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/t8.py#L178,t8.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/t13.py#L115,t13.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/t21.py#L162,t21.py}, @url{@value{GITLAB-PREFIX}/examples/api/split_window.py#L44,split_window.py}) +C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/t3.cpp#L129,t3.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/t8.cpp#L151,t8.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/t13.cpp#L129,t13.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/t21.cpp#L192,t21.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/t3.py#L120,t3.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/t8.py#L150,t8.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/t13.py#L115,t13.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/t21.py#L162,t21.py}, @url{@value{GITLAB-PREFIX}/examples/api/split_window.py#L44,split_window.py}) @end table @end ftable @@ -5938,7 +5942,7 @@ Create the FLTK graphical user interface. Can only be called in the main thread. @item Language-specific definition: @url{@value{GITLAB-PREFIX}/api/gmsh.h#L3556,C++}, @url{@value{GITLAB-PREFIX}/api/gmshc.h#L3146,C}, @url{@value{GITLAB-PREFIX}/api/gmsh.py#L7825,Python}, @url{@value{GITLAB-PREFIX}/api/gmsh.jl#L6760,Julia} @item Examples: -C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/t3.cpp#L136,t3.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/t8.cpp#L76,t8.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/t13.cpp#L136,t13.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/t21.cpp#L199,t21.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/t3.py#L124,t3.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/t8.py#L71,t8.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/t13.py#L119,t13.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/t21.py#L166,t21.py}, @url{@value{GITLAB-PREFIX}/examples/api/custom_gui.py#L112,custom_gui.py}, ...) +C++ (@url{@value{GITLAB-PREFIX}/tutorials/c++/t3.cpp#L136,t3.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/t8.cpp#L71,t8.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/t13.cpp#L136,t13.cpp}, @url{@value{GITLAB-PREFIX}/tutorials/c++/t21.cpp#L199,t21.cpp}), Python (@url{@value{GITLAB-PREFIX}/tutorials/python/t3.py#L124,t3.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/t8.py#L68,t8.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/t13.py#L119,t13.py}, @url{@value{GITLAB-PREFIX}/tutorials/python/t21.py#L166,t21.py}, @url{@value{GITLAB-PREFIX}/examples/api/custom_gui.py#L112,custom_gui.py}, ...) @end table @item gmsh/fltk/finalize diff --git a/tutorials/c++/t4.cpp b/tutorials/c++/t4.cpp index 2cd77568dac8e7a154353296d558bf0e68ff761e..0a19166cce15a9179cca0103cf4f15390704dd44 100644 --- a/tutorials/c++/t4.cpp +++ b/tutorials/c++/t4.cpp @@ -148,8 +148,8 @@ int main(int argc, char **argv) // Views and geometrical entities can be made to respond to double-click // events, here to print some messages to the console: - gmsh::option::setString("View[0].DoubleClickedCommand", - "Printf('View[0] has been double-clicked!');"); + gmsh::view::option::setString(v, "DoubleClickedCommand", + "Printf('View[0] has been double-clicked!');"); gmsh::option::setString("Geometry.DoubleClickedLineCommand", "Printf('Curve %g has been double-clicked!', " "Geometry.DoubleClickedEntityTag);"); diff --git a/tutorials/c++/t8.cpp b/tutorials/c++/t8.cpp index a446a6e757f5f6cf4ab0ae61d8e9b9e4dec29320..3823bf98f22d44a2d41547ad80b39a7c3f2ea0b8 100644 --- a/tutorials/c++/t8.cpp +++ b/tutorials/c++/t8.cpp @@ -59,13 +59,8 @@ int main(int argc, char **argv) int white[3] = {255, 255, 255}; int black[3] = {0, 0, 0}; gmsh::option::setColor("General.Background", white[0], white[1], white[2]); - - // We can make our own shorter versions of repetitive methods - auto set_color = [](std::string name, int c[3]) -> void { - gmsh::option::setColor(name, c[0], c[1], c[2]); - }; - set_color("General.Foreground", black); - set_color("General.Text", black); + gmsh::option::setColor("General.Foreground", black[0], black[1], black[2]); + gmsh::option::setColor("General.Text", black[0], black[1], black[2]); gmsh::option::setNumber("General.Orthographic", 0); gmsh::option::setNumber("General.Axes", 0); @@ -76,31 +71,39 @@ int main(int argc, char **argv) if(!args.count("-nopopup")) gmsh::fltk::initialize(); // We also set some options for each post-processing view: - gmsh::option::setNumber("View[0].IntervalsType", 2); - gmsh::option::setNumber("View[0].OffsetZ", 0.05); - gmsh::option::setNumber("View[0].RaiseZ", 0); - gmsh::option::setNumber("View[0].Light", 1); - gmsh::option::setNumber("View[0].ShowScale", 0); - gmsh::option::setNumber("View[0].SmoothNormals", 1); - - gmsh::option::setNumber("View[1].IntervalsType", 1); - // We can't yet set the ColorTable through the API - // gmsh::option::setColorTable("View[1].ColorTable", "{ Green, Blue }"); - gmsh::option::setNumber("View[1].NbIso", 10); - gmsh::option::setNumber("View[1].ShowScale", 0); - - gmsh::option::setString("View[2].Name", "Test..."); - gmsh::option::setNumber("View[2].Axes", 1); - gmsh::option::setNumber("View[2].IntervalsType", 2); - gmsh::option::setNumber("View[2].Type", 2); - gmsh::option::setNumber("View[2].IntervalsType", 2); - gmsh::option::setNumber("View[2].AutoPosition", 0); - gmsh::option::setNumber("View[2].PositionX", 85); - gmsh::option::setNumber("View[2].PositionY", 50); - gmsh::option::setNumber("View[2].Width", 200); - gmsh::option::setNumber("View[2].Height", 130); - - gmsh::option::setNumber("View[3].Visible", 0); + + // If we were to follow the geo example blindly, we would read the number of + // views from the relevant option value, and use the gmsh::option::setNumber() + // and gmsh::option::setString() functions. A nicer way is to use + // gmsh::view::getTags() and to use the gmsh::view::setNumber() and + // gmsh::view::setString() functions. + std::vector<int> v; + gmsh::view::getTags(v); + + gmsh::view::option::setNumber(v[0], "IntervalsType", 2); + gmsh::view::option::setNumber(v[0], "OffsetZ", 0.05); + gmsh::view::option::setNumber(v[0], "RaiseZ", 0); + gmsh::view::option::setNumber(v[0], "Light", 1); + gmsh::view::option::setNumber(v[0], "ShowScale", 0); + gmsh::view::option::setNumber(v[0], "SmoothNormals", 1); + + gmsh::view::option::setNumber(v[1], "IntervalsType", 1); + // Note that we can't yet set the ColorTable through the API + gmsh::view::option::setNumber(v[1], "NbIso", 10); + gmsh::view::option::setNumber(v[1], "ShowScale", 0); + + gmsh::view::option::setString(v[2], "Name", "Test..."); + gmsh::view::option::setNumber(v[2], "Axes", 1); + gmsh::view::option::setNumber(v[2], "IntervalsType", 2); + gmsh::view::option::setNumber(v[2], "Type", 2); + gmsh::view::option::setNumber(v[2], "IntervalsType", 2); + gmsh::view::option::setNumber(v[2], "AutoPosition", 0); + gmsh::view::option::setNumber(v[2], "PositionX", 85); + gmsh::view::option::setNumber(v[2], "PositionY", 50); + gmsh::view::option::setNumber(v[2], "Width", 200); + gmsh::view::option::setNumber(v[2], "Height", 130); + + gmsh::view::option::setNumber(v[3], "Visible", 0); // You can save an MPEG movie directly by selecting `File->Export' in the // GUI. Several predefined animations are setup, for looping on all the time @@ -115,20 +118,18 @@ int main(int argc, char **argv) for(int num = 1; num <= 3; num++) { double nbt; - gmsh::option::getNumber("View[0].NbTimeStep", nbt); + gmsh::view::option::getNumber(v[0], "NbTimeStep", nbt); t = (t < nbt - 1) ? t + 1 : 0; // Set time step - gmsh::option::setNumber("View[0].TimeStep", t); - gmsh::option::setNumber("View[1].TimeStep", t); - gmsh::option::setNumber("View[2].TimeStep", t); - gmsh::option::setNumber("View[3].TimeStep", t); + for(auto vv : v) gmsh::view::option::setNumber(vv, "TimeStep", t); double max; - gmsh::option::getNumber("View[0].Max", max); - gmsh::option::setNumber("View[0].RaiseZ", 0.01 / max * t); + gmsh::view::option::getNumber(v[0], "Max", max); + gmsh::view::option::setNumber(v[0], "RaiseZ", 0.01 / max * t); if(num == 3) { + // Resize the graphics when num == 3, to create 640x480 frames double mw; gmsh::option::getNumber("General.MenuWidth", mw); gmsh::option::setNumber("General.GraphicsWidth", mw + 640); diff --git a/tutorials/c++/t9.cpp b/tutorials/c++/t9.cpp index 37abbe6201037825cc5eb9e45dcf4fd56303a6a6..146d71e63cfb734bdfd30c0fdcaf3c38ad6a0adf 100644 --- a/tutorials/c++/t9.cpp +++ b/tutorials/c++/t9.cpp @@ -33,11 +33,14 @@ int main(int argc, char **argv) return 0; } + std::vector<int> v; + gmsh::view::getTags(v); + // We then set some options for the `Isosurface' plugin (which extracts an // isosurface from a 3D scalar view), and run it: gmsh::plugin::setNumber("Isosurface", "Value", 0.67); // Iso-value level gmsh::plugin::setNumber("Isosurface", "View", 0); // Source view is View[0] - gmsh::plugin::run("Isosurface"); // Run the plugin! + int v1 = gmsh::plugin::run("Isosurface"); // Run the plugin! // We also set some options for the `CutPlane' plugin (which computes a // section of a 3D view using the plane A*x+B*y+C*z+D=0), and then run it: @@ -46,7 +49,7 @@ int main(int argc, char **argv) gmsh::plugin::setNumber("CutPlane", "C", 1); gmsh::plugin::setNumber("CutPlane", "D", 0); gmsh::plugin::setNumber("CutPlane", "View", 0); - gmsh::plugin::run("CutPlane"); + int v2 = gmsh::plugin::run("CutPlane"); // Add a title (By convention, for window coordinates a value greater than // 99999 represents the center. We could also use `General.GraphicsWidth / 2', @@ -67,12 +70,12 @@ int main(int argc, char **argv) gmsh::plugin::run("Annotate"); // We finish by setting some options: - gmsh::option::setNumber("View[0].Light", 1); - gmsh::option::setNumber("View[0].IntervalsType", 1); - gmsh::option::setNumber("View[0].NbIso", 6); - gmsh::option::setNumber("View[0].SmoothNormals", 1); - gmsh::option::setNumber("View[1].IntervalsType", 2); - gmsh::option::setNumber("View[2].IntervalsType", 2); + gmsh::view::option::setNumber(v[0], "Light", 1); + gmsh::view::option::setNumber(v[0], "IntervalsType", 1); + gmsh::view::option::setNumber(v[0], "NbIso", 6); + gmsh::view::option::setNumber(v[0], "SmoothNormals", 1); + gmsh::view::option::setNumber(v1, "IntervalsType", 2); + gmsh::view::option::setNumber(v2, "IntervalsType", 2); // Launch the GUI to see the results: std::set<std::string> args(argv, argv + argc); diff --git a/tutorials/c++/x3.cpp b/tutorials/c++/x3.cpp index 25e1b5fcf17eb3447c76dc1370d802cdd83f576d..f5ee1e24c8784452ea882386aa58f132c3178c86 100644 --- a/tutorials/c++/x3.cpp +++ b/tutorials/c++/x3.cpp @@ -83,15 +83,12 @@ int main(int argc, char **argv) {"Align", "Center", "Font", "Helvetica"}); // The various attributes of the view can be queried and changed using the - // option interface. Beware that the option interface uses view indices - // instead of view tags; so to change the current time step and the intervals - // type, and to retrieve the total number of steps, one would do: - std::string v1 = "View[" + std::to_string(gmsh::view::getIndex(t1)) + "]"; - gmsh::option::setNumber(v1 + ".TimeStep", 5); - gmsh::option::setNumber(v1 + ".IntervalsType", 3); + // option interface: + gmsh::view::option::setNumber(t1, "TimeStep", 5); + gmsh::view::option::setNumber(t1, "IntervalsType", 3); double ns; - gmsh::option::getNumber(v1 + ".NbTimeStep", ns); - std::cout << v1 << " with tag " << t1 << " has " << ns << " time steps\n"; + gmsh::view::option::getNumber(t1, "NbTimeStep", ns); + std::cout << "View " << t1 << " has " << ns << " time steps" << std::endl; // Views can be queried and modified in various ways using plugins (see // `t9.py'), or probed directly using `gmsh::view::probe()' - here at point @@ -101,7 +98,7 @@ int main(int argc, char **argv) gmsh::view::probe(t1, 0.9, 0.1, 0, val, distance); std::cout << "Value at (0.9, 0.1, 0):"; for(auto v : val) std::cout << " " << v; - std::cout << "\n"; + std::cout << std::endl; // Views can be saved to disk using `gmsh::view::write()': gmsh::view::write(t1, "x3.pos"); @@ -148,10 +145,9 @@ int main(int argc, char **argv) // visualization, set a visualization error threshold and a maximum // subdivision level (Gmsh does automatic mesh refinement to visualize the // high-order field with the requested accuracy): - std::string v2 = "View[" + std::to_string(gmsh::view::getIndex(t2)) + "]"; - gmsh::option::setNumber(v2 + ".AdaptVisualizationGrid", 1); - gmsh::option::setNumber(v2 + ".TargetError", 1e-2); - gmsh::option::setNumber(v2 + ".MaxRecursionLevel", 5); + gmsh::view::option::setNumber(t2, "AdaptVisualizationGrid", 1); + gmsh::view::option::setNumber(t2, "TargetError", 1e-2); + gmsh::view::option::setNumber(t2, "MaxRecursionLevel", 5); // Launch the GUI to see the results: std::set<std::string> args(argv, argv + argc); diff --git a/tutorials/julia/t4.jl b/tutorials/julia/t4.jl index 9290020cf5d48599b0c5bb36ebc11091fda150e1..6ba5b361e6ce6180998d0080a542b65be92714ad 100644 --- a/tutorials/julia/t4.jl +++ b/tutorials/julia/t4.jl @@ -99,8 +99,8 @@ gmsh.view.addListDataString(v, [0, 0.12, 0], gmsh.view.addListDataString(v, [150, -7], ["file://../t4_image.png@20x0"]) -gmsh.option.setString("View[0].DoubleClickedCommand", - "Printf('View[0] has been double-clicked!');") +gmsh.view.option.setString(v, "DoubleClickedCommand", + "Printf('View[0] has been double-clicked!');") gmsh.option.setString( "Geometry.DoubleClickedLineCommand", "Printf('Curve %g has been double-clicked!', Geometry.DoubleClickedEntityTag);") diff --git a/tutorials/python/t4.py b/tutorials/python/t4.py index 4ed2fbd02b195f429a6ca1e9ff2f66a1f95a976e..f901c691ba6c533dc66f625081ae9ce4a73e0a32 100644 --- a/tutorials/python/t4.py +++ b/tutorials/python/t4.py @@ -156,8 +156,8 @@ gmsh.view.addListDataString(v, [150, -7], ["file://../t4_image.png@20x0"]) # Views and geometrical entities can be made to respond to double-click # events, here to print some messages to the console: -gmsh.option.setString("View[0].DoubleClickedCommand", - "Printf('View[0] has been double-clicked!');") +gmsh.view.option.setString(v, "DoubleClickedCommand", + "Printf('View[0] has been double-clicked!');") gmsh.option.setString( "Geometry.DoubleClickedLineCommand", "Printf('Curve %g has been double-clicked!', " diff --git a/tutorials/python/t8.py b/tutorials/python/t8.py index 3232a5f1a3f4e080d6880a8ee4e92c004bd8221c..321ff2794fd60f0e75790170f821a8d647f7a602 100644 --- a/tutorials/python/t8.py +++ b/tutorials/python/t8.py @@ -56,11 +56,8 @@ black = (0, 0, 0) # Setting a color option of "X.Y" actually sets the option "X.Color.Y" # Sets "General.Color.Background", etc. gmsh.option.setColor("General.Background", white[0], white[1], white[2]) - -# We can make our own shorter versions of repetitive methods -set_color = lambda name, c: gmsh.option.setColor(name, c[0], c[1], c[2]) -set_color("General.Foreground", black) -set_color("General.Text", black) +gmsh.option.setColor("General.Foreground", black[0], black[1], black[2]) +gmsh.option.setColor("General.Text", black[0], black[1], black[2]) gmsh.option.setNumber("General.Orthographic", 0) gmsh.option.setNumber("General.Axes", 0) @@ -73,62 +70,37 @@ if '-nopopup' not in sys.argv: # We also set some options for each post-processing view: # If we were to follow the geo example blindly, we would read the number of -# views from the relevant option value. A nicer way is to use -# gmsh.view.getTags() -view_tags = [v0, v1, v2, v3] = gmsh.view.getTags() - -# View name format helper function: returns "View[index]." for a given view tag -view_fmt = lambda v_tag: "View[" + str(gmsh.view.getIndex(v_tag)) + "]." - - -# Option setter -def set_opt(name, val): - # if it's a string, call the string method - val_type = type(val) - if val_type == type("str"): - gmsh.option.setString(name, val) - # otherwise call the number method - elif val_type == type(0.5) or val_type == type(1): - gmsh.option.setNumber(name, val) - else: - print("error: bad input to set_opt: " + name + " = " + str(val)) - print("error: set_opt is only meant for numbers and strings, aborting") - quit(1) - - -# We'll use this helper function for our views -set_view_opt = lambda v_tag, name, val: set_opt(view_fmt(v_tag) + name, val) +# views from the relevant option value, and use the gmsh.option.setNumber() +# and gmsh.option.setString() functions. A nicer way is to use +# gmsh.view.getTags() and to use the gmsh.view.setNumber() and +# gmsh.view.setString() functions. +v = gmsh.view.getTags() # We set some options for each post-processing view: -# v0 -set_view_opt(v0, "IntervalsType", 2) -set_view_opt(v0, "OffsetZ", 0.05) -set_view_opt(v0, "RaiseZ", 0) -set_view_opt(v0, "Light", 1) -set_view_opt(v0, "ShowScale", 0) -set_view_opt(v0, "SmoothNormals", 1) - -# v1 -set_view_opt(v1, "IntervalsType", 1) -# We can't yet set the ColorTable in API -# gmsh.option.setColorTable(view_opt[v1] + "ColorTable", "{ Green, Blue }") -set_view_opt(v1, "NbIso", 10) -set_view_opt(v1, "ShowScale", 0) - -# v2 -set_view_opt(v2, "Name", "Test...") -set_view_opt(v2, "Axes", 1) -set_view_opt(v2, "IntervalsType", 2) -set_view_opt(v2, "Type", 2) -set_view_opt(v2, "IntervalsType", 2) -set_view_opt(v2, "AutoPosition", 0) -set_view_opt(v2, "PositionX", 85) -set_view_opt(v2, "PositionY", 50) -set_view_opt(v2, "Width", 200) -set_view_opt(v2, "Height", 130) - -# v3 -set_view_opt(v3, "Visible", 0) +gmsh.view.option.setNumber(v[0], "IntervalsType", 2) +gmsh.view.option.setNumber(v[0], "OffsetZ", 0.05) +gmsh.view.option.setNumber(v[0], "RaiseZ", 0) +gmsh.view.option.setNumber(v[0], "Light", 1) +gmsh.view.option.setNumber(v[0], "ShowScale", 0) +gmsh.view.option.setNumber(v[0], "SmoothNormals", 1) + +gmsh.view.option.setNumber(v[1], "IntervalsType", 1) +# Note that we can't yet set the ColorTable in API +gmsh.view.option.setNumber(v[1], "NbIso", 10) +gmsh.view.option.setNumber(v[1], "ShowScale", 0) + +gmsh.view.option.setString(v[2], "Name", "Test...") +gmsh.view.option.setNumber(v[2], "Axes", 1) +gmsh.view.option.setNumber(v[2], "IntervalsType", 2) +gmsh.view.option.setNumber(v[2], "Type", 2) +gmsh.view.option.setNumber(v[2], "IntervalsType", 2) +gmsh.view.option.setNumber(v[2], "AutoPosition", 0) +gmsh.view.option.setNumber(v[2], "PositionX", 85) +gmsh.view.option.setNumber(v[2], "PositionY", 50) +gmsh.view.option.setNumber(v[2], "Width", 200) +gmsh.view.option.setNumber(v[2], "Height", 130) + +gmsh.view.option.setNumber(v[3], "Visible", 0) # You can save an MPEG movie directly by selecting `File->Export' in the # GUI. Several predefined animations are setup, for looping on all the time @@ -144,35 +116,35 @@ t = 0 # Initial step for num in range(1, 4): # Set time step - for v in view_tags: - set_view_opt(v, "TimeStep", t) - - # helper function to match the geo file's +=, -= operators for numbers - adjust_num_opt =\ - lambda name, diff: set_opt(name, gmsh.option.getNumber(name) + diff) + for vv in v: + gmsh.view.option.setNumber(vv, "TimeStep", t) - current_step = gmsh.option.getNumber(view_fmt(v0) + "TimeStep") - max_step = gmsh.option.getNumber(view_fmt(v0) + "NbTimeStep") - 1 + current_step = gmsh.view.option.getNumber(v[0], "TimeStep") + max_step = gmsh.view.option.getNumber(v[0], "NbTimeStep") - 1 if current_step < max_step: t = t + 1 else: t = 0 - v0_max = gmsh.option.getNumber(view_fmt(v0) + "Max") - adjust_num_opt(view_fmt(v0) + "RaiseZ", 0.01 / v0_max * t) + gmsh.view.option.setNumber(v[0], "RaiseZ", + gmsh.view.option.getNumber(v[0], "RaiseZ") + + 0.01 / gmsh.view.option.getNumber(v[0], "Max") * t) if num == 3: - set_opt("General.GraphicsWidth", - gmsh.option.getNumber("General.MenuWidth") + 640) - set_opt("General.GraphicsHeight", 480) + # Resize the graphics when num == 3, to create 640x480 frames + gmsh.option.setNumber("General.GraphicsWidth", + gmsh.option.getNumber("General.MenuWidth") + 640) + gmsh.option.setNumber("General.GraphicsHeight", 480) frames = 50 for num2 in range(frames): # Incrementally rotate the scene - adjust_num_opt("General.RotationX", 10) - set_opt("General.RotationY", - gmsh.option.getNumber("General.RotationX") / 3) - adjust_num_opt("General.RotationZ", 0.1) + gmsh.option.setNumber("General.RotationX", + gmsh.option.getNumber("General.RotationX") + 10) + gmsh.option.setNumber("General.RotationY", + gmsh.option.getNumber("General.RotationX") / 3) + gmsh.option.setNumber("General.RotationZ", + gmsh.option.getNumber("General.RotationZ") + 0.1) # Draw the scene gmsh.graphics.draw() diff --git a/tutorials/python/t9.py b/tutorials/python/t9.py index d125889af571d6e5293f68905e1cc4bda6275d30..2ac7f5017f0fc4d1d0871c7b1173b4e37c0bd1fb 100644 --- a/tutorials/python/t9.py +++ b/tutorials/python/t9.py @@ -24,12 +24,13 @@ gmsh.initialize() # Let us for example include a three-dimensional scalar view: path = os.path.dirname(os.path.abspath(__file__)) gmsh.merge(os.path.join(path, os.pardir, 'view3.pos')) +v = gmsh.view.getTags() # We then set some options for the `Isosurface' plugin (which extracts an # isosurface from a 3D scalar view), and run it: gmsh.plugin.setNumber("Isosurface", "Value", 0.67) gmsh.plugin.setNumber("Isosurface", "View", 0) -gmsh.plugin.run("Isosurface") +v1 = gmsh.plugin.run("Isosurface") # We also set some options for the `CutPlane' plugin (which computes a section # of a 3D view using the plane A*x+B*y+C*z+D=0), and then run it: @@ -38,7 +39,7 @@ gmsh.plugin.setNumber("CutPlane", "B", 0.2) gmsh.plugin.setNumber("CutPlane", "C", 1) gmsh.plugin.setNumber("CutPlane", "D", 0) gmsh.plugin.setNumber("CutPlane", "View", 0) -gmsh.plugin.run("CutPlane") +v2 = gmsh.plugin.run("CutPlane") # Add a title (By convention, for window coordinates a value greater than 99999 # represents the center. We could also use `General.GraphicsWidth / 2', but that @@ -59,12 +60,12 @@ gmsh.plugin.setNumber("Annotate", "FontSize", 12) gmsh.plugin.run("Annotate") # We finish by setting some options: -gmsh.option.setNumber("View[0].Light", 1) -gmsh.option.setNumber("View[0].IntervalsType", 1) -gmsh.option.setNumber("View[0].NbIso", 6) -gmsh.option.setNumber("View[0].SmoothNormals", 1) -gmsh.option.setNumber("View[1].IntervalsType", 2) -gmsh.option.setNumber("View[2].IntervalsType", 2) +gmsh.view.option.setNumber(v[0], "Light", 1) +gmsh.view.option.setNumber(v[0], "IntervalsType", 1) +gmsh.view.option.setNumber(v[0], "NbIso", 6) +gmsh.view.option.setNumber(v[0], "SmoothNormals", 1) +gmsh.view.option.setNumber(v1, "IntervalsType", 2) +gmsh.view.option.setNumber(v2, "IntervalsType", 2) # Launch the GUI to see the results: if '-nopopup' not in sys.argv: diff --git a/tutorials/python/x3.py b/tutorials/python/x3.py index 5e743252a664c0488ea0a8e738517fcc3446bcad..572c695d8bdb021f414a4d73527cd6da482ba15f 100644 --- a/tutorials/python/x3.py +++ b/tutorials/python/x3.py @@ -75,14 +75,11 @@ gmsh.view.addListDataString(t1, [0.5, 1.5, 0.], ["Align", "Center", "Font", "Helvetica"]) # The various attributes of the view can be queried and changed using the option -# interface. Beware that the option interface uses view indices instead of view -# tags; so to change the current time step and the intervals type, and to -# retrieve the total number of steps, one would do: -v1 = "View[" + str(gmsh.view.getIndex(t1)) + "]" -gmsh.option.setNumber(v1 + ".TimeStep", 5) -gmsh.option.setNumber(v1 + ".IntervalsType", 3) -ns = gmsh.option.getNumber(v1 + ".NbTimeStep") -print(v1 + " with tag " + str(t1) + " has " + str(ns) + " time steps") +# interface: +gmsh.view.option.setNumber(t1, "TimeStep", 5) +gmsh.view.option.setNumber(t1, "IntervalsType", 3) +ns = gmsh.view.option.getNumber(t1, "NbTimeStep") +print("View " + str(t1) + " has " + str(ns) + " time steps") # Views can be queried and modified in various ways using plugins (see `t9.py'), # or probed directly using `gmsh.view.probe()' - here at point (0.9, 0.1, 0): @@ -140,10 +137,9 @@ gmsh.view.addListData(t2, "SQ", 1, quad) # visualization, set a visualization error threshold and a maximum subdivision # level (Gmsh does automatic mesh refinement to visualize the high-order field # with the requested accuracy): -v2 = "View[" + str(gmsh.view.getIndex(t2)) + "]" -gmsh.option.setNumber(v2 + ".AdaptVisualizationGrid", 1) -gmsh.option.setNumber(v2 + ".TargetError", 1e-2) -gmsh.option.setNumber(v2 + ".MaxRecursionLevel", 5) +gmsh.view.option.setNumber(t2, "AdaptVisualizationGrid", 1) +gmsh.view.option.setNumber(t2, "TargetError", 1e-2) +gmsh.view.option.setNumber(t2, "MaxRecursionLevel", 5) # Launch the GUI to see the results: if '-nopopup' not in sys.argv: diff --git a/tutorials/t4.geo b/tutorials/t4.geo index d1822712ef93fc427dd69419c99373319aa0cf72..a584011330de51cf43ddc62d9bb0d383e25723ed 100644 --- a/tutorials/t4.geo +++ b/tutorials/t4.geo @@ -118,7 +118,7 @@ View "comments" { // here to print some messages to the console: View[0].DoubleClickedCommand = "Printf('View[0] has been double-clicked!');"; -Geometry.DoubleClickedLineCommand = "Printf('Curve %g has been double-clicked!', +Geometry.DoubleClickedCurveCommand = "Printf('Curve %g has been double-clicked!', Geometry.DoubleClickedEntityTag);"; // We can also change the color of some entities: