diff options
Diffstat (limited to 'modules/graphics/macros')
416 files changed, 21636 insertions, 0 deletions
diff --git a/modules/graphics/macros/%BevelBor_i_h.bin b/modules/graphics/macros/%BevelBor_i_h.bin Binary files differnew file mode 100755 index 000000000..1b257da9c --- /dev/null +++ b/modules/graphics/macros/%BevelBor_i_h.bin diff --git a/modules/graphics/macros/%BevelBor_i_h.sci b/modules/graphics/macros/%BevelBor_i_h.sci new file mode 100755 index 000000000..37622b59f --- /dev/null +++ b/modules/graphics/macros/%BevelBor_i_h.sci @@ -0,0 +1,14 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function h = %BevelBor_i_h(i,v,h) + if type(i)==10 then + set(h,i,v) + else + error(msprintf(_("%s: Wrong type for input argument #%d.\n"),"%BevelBor_i_h",1)); + end +endfunction diff --git a/modules/graphics/macros/%BevelBor_p.bin b/modules/graphics/macros/%BevelBor_p.bin Binary files differnew file mode 100755 index 000000000..65e7aba1b --- /dev/null +++ b/modules/graphics/macros/%BevelBor_p.bin diff --git a/modules/graphics/macros/%BevelBor_p.sci b/modules/graphics/macros/%BevelBor_p.sci new file mode 100755 index 000000000..ce82a7015 --- /dev/null +++ b/modules/graphics/macros/%BevelBor_p.sci @@ -0,0 +1,28 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function %BevelBor_p(t) + count = size(t(1), "*"); + + printf("Bevel Border\n"); + printf(" Type : %s\n", sci2exp(t.type)); + + if count == 2 then + return + end + + printf(" Highlight outer : %s\n", sci2exp(t.hlouter)); + + if count == 4 then + printf(" Shadow outer : %s\n", sci2exp(t.shadowouter)); + return; + end + + printf(" Highlight inner : %s\n", sci2exp(t.hlinner)); + printf(" Shadow outer : %s\n", sci2exp(t.shadowouter)); + printf(" Shadow inner : %s\n", sci2exp(t.shadowinner)); +endfunction diff --git a/modules/graphics/macros/%BorderCo_i_h.bin b/modules/graphics/macros/%BorderCo_i_h.bin Binary files differnew file mode 100755 index 000000000..6a712085e --- /dev/null +++ b/modules/graphics/macros/%BorderCo_i_h.bin diff --git a/modules/graphics/macros/%BorderCo_i_h.sci b/modules/graphics/macros/%BorderCo_i_h.sci new file mode 100755 index 000000000..7a270bc8a --- /dev/null +++ b/modules/graphics/macros/%BorderCo_i_h.sci @@ -0,0 +1,14 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function h = %BorderCo_i_h(i,v,h) + if type(i)==10 then + set(h,i,v) + else + error(msprintf(_("%s: Wrong type for input argument #%d.\n"),"%BorderCo_i_h",1)); + end +endfunction diff --git a/modules/graphics/macros/%BorderCo_p.bin b/modules/graphics/macros/%BorderCo_p.bin Binary files differnew file mode 100755 index 000000000..3cb63b800 --- /dev/null +++ b/modules/graphics/macros/%BorderCo_p.bin diff --git a/modules/graphics/macros/%BorderCo_p.sci b/modules/graphics/macros/%BorderCo_p.sci new file mode 100755 index 000000000..5ae9865d8 --- /dev/null +++ b/modules/graphics/macros/%BorderCo_p.sci @@ -0,0 +1,12 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function %BorderCo_p(t) + printf("Border Layout\n"); + printf(" Position : %s\n", sci2exp(t.position)); + printf(" PreferredSize : %s\n", sci2exp(t.preferredsize)); +endfunction diff --git a/modules/graphics/macros/%Compound_i_h.bin b/modules/graphics/macros/%Compound_i_h.bin Binary files differnew file mode 100755 index 000000000..e02dddcb2 --- /dev/null +++ b/modules/graphics/macros/%Compound_i_h.bin diff --git a/modules/graphics/macros/%Compound_i_h.sci b/modules/graphics/macros/%Compound_i_h.sci new file mode 100755 index 000000000..e62602ee2 --- /dev/null +++ b/modules/graphics/macros/%Compound_i_h.sci @@ -0,0 +1,14 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function h = %Compound_i_h(i,v,h) + if type(i)==10 then + set(h,i,v) + else + error(msprintf(_("%s: Wrong type for input argument #%d.\n"),"%Compound_i_h",1)); + end +endfunction diff --git a/modules/graphics/macros/%Compound_p.bin b/modules/graphics/macros/%Compound_p.bin Binary files differnew file mode 100755 index 000000000..f9969636c --- /dev/null +++ b/modules/graphics/macros/%Compound_p.bin diff --git a/modules/graphics/macros/%Compound_p.sci b/modules/graphics/macros/%Compound_p.sci new file mode 100755 index 000000000..611193e7d --- /dev/null +++ b/modules/graphics/macros/%Compound_p.sci @@ -0,0 +1,20 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function %Compound_p(t) + count = size(t(1), "*"); + + printf("Compound Border\n"); + + if count == 1 then + printf(" No option\n"); + return; + end + + printf(" Outer : %s\n", typeof(t.outer)); + printf(" Inner : %s\n", typeof(t.inner)); +endfunction diff --git a/modules/graphics/macros/%EmptyBor_i_h.bin b/modules/graphics/macros/%EmptyBor_i_h.bin Binary files differnew file mode 100755 index 000000000..269b2cf47 --- /dev/null +++ b/modules/graphics/macros/%EmptyBor_i_h.bin diff --git a/modules/graphics/macros/%EmptyBor_i_h.sci b/modules/graphics/macros/%EmptyBor_i_h.sci new file mode 100755 index 000000000..e84200e35 --- /dev/null +++ b/modules/graphics/macros/%EmptyBor_i_h.sci @@ -0,0 +1,14 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function h = %EmptyBor_i_h(i,v,h) + if type(i)==10 then + set(h,i,v) + else + error(msprintf(_("%s: Wrong type for input argument #%d.\n"),"%EmptyBor_i_h",1)); + end +endfunction diff --git a/modules/graphics/macros/%EmptyBor_p.bin b/modules/graphics/macros/%EmptyBor_p.bin Binary files differnew file mode 100755 index 000000000..d24d0e224 --- /dev/null +++ b/modules/graphics/macros/%EmptyBor_p.bin diff --git a/modules/graphics/macros/%EmptyBor_p.sci b/modules/graphics/macros/%EmptyBor_p.sci new file mode 100755 index 000000000..9459280b3 --- /dev/null +++ b/modules/graphics/macros/%EmptyBor_p.sci @@ -0,0 +1,22 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function %EmptyBor_p(t) + count = size(t(1), "*"); + + printf("Empty Border\n"); + + if count == 1 then + printf(" No option\n"); + return; + end + + printf(" Top : %s\n", sci2exp(t.top)); + printf(" Left : %s\n", sci2exp(t.left)); + printf(" Bottom : %s\n", sci2exp(t.bottom)); + printf(" Right : %s\n", sci2exp(t.right)); +endfunction diff --git a/modules/graphics/macros/%EtchedBo_i_h.bin b/modules/graphics/macros/%EtchedBo_i_h.bin Binary files differnew file mode 100755 index 000000000..b650b2316 --- /dev/null +++ b/modules/graphics/macros/%EtchedBo_i_h.bin diff --git a/modules/graphics/macros/%EtchedBo_i_h.sci b/modules/graphics/macros/%EtchedBo_i_h.sci new file mode 100755 index 000000000..b3c31ecb9 --- /dev/null +++ b/modules/graphics/macros/%EtchedBo_i_h.sci @@ -0,0 +1,14 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function h = %EtchedBo_i_h(i,v,h) + if type(i)==10 then + set(h,i,v) + else + error(msprintf(_("%s: Wrong type for input argument #%d.\n"),"%EtchedBo_i_h",1)); + end +endfunction diff --git a/modules/graphics/macros/%EtchedBo_p.bin b/modules/graphics/macros/%EtchedBo_p.bin Binary files differnew file mode 100755 index 000000000..60bcd9bc0 --- /dev/null +++ b/modules/graphics/macros/%EtchedBo_p.bin diff --git a/modules/graphics/macros/%EtchedBo_p.sci b/modules/graphics/macros/%EtchedBo_p.sci new file mode 100755 index 000000000..10b727335 --- /dev/null +++ b/modules/graphics/macros/%EtchedBo_p.sci @@ -0,0 +1,32 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function %EtchedBo_p(t) + count = size(t(1), "*"); + + printf("Etched Border\n"); + + if count == 1 then + printf(" No option\n"); + return; + end + + if count == 2 then + printf(" Type : %s\n", sci2exp(t.type)); + return; + end + + if count == 3 then + printf(" Highlight : %s\n", sci2exp(t.hl)); + printf(" Shadow : %s\n", sci2exp(t.shadow)); + return; + end + + printf(" Type : %s\n", sci2exp(t.type)); + printf(" Highlight : %s\n", sci2exp(t.hl)); + printf(" Shadow : %s\n", sci2exp(t.shadow)); +endfunction diff --git a/modules/graphics/macros/%GridBagC_i_h.bin b/modules/graphics/macros/%GridBagC_i_h.bin Binary files differnew file mode 100755 index 000000000..559bfc83a --- /dev/null +++ b/modules/graphics/macros/%GridBagC_i_h.bin diff --git a/modules/graphics/macros/%GridBagC_i_h.sci b/modules/graphics/macros/%GridBagC_i_h.sci new file mode 100755 index 000000000..0a2df4f46 --- /dev/null +++ b/modules/graphics/macros/%GridBagC_i_h.sci @@ -0,0 +1,14 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function h = %GridBagC_i_h(i,v,h) + if type(i)==10 then + set(h,i,v) + else + error(msprintf(_("%s: Wrong type for input argument #%d.\n"),"%GridBagC_i_h",1)); + end +endfunction diff --git a/modules/graphics/macros/%GridBagC_p.bin b/modules/graphics/macros/%GridBagC_p.bin Binary files differnew file mode 100755 index 000000000..4ea4dc763 --- /dev/null +++ b/modules/graphics/macros/%GridBagC_p.bin diff --git a/modules/graphics/macros/%GridBagC_p.sci b/modules/graphics/macros/%GridBagC_p.sci new file mode 100755 index 000000000..e168ee805 --- /dev/null +++ b/modules/graphics/macros/%GridBagC_p.sci @@ -0,0 +1,16 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function %GridBagC_p(t) + printf("GridBag Layout\n"); + printf(" Grid : %s\n", sci2exp(t.grid)); + printf(" Weight : %s\n", sci2exp(t.weight)); + printf(" Fill : %s\n", sci2exp(t.fill)); + printf(" Anchor : %s\n", sci2exp(t.anchor)); + printf(" Padding : %s\n", sci2exp(t.padding)); + printf(" PreferredSize : %s\n", sci2exp(t.preferredsize)); +endfunction diff --git a/modules/graphics/macros/%GridCons_i_h.bin b/modules/graphics/macros/%GridCons_i_h.bin Binary files differnew file mode 100755 index 000000000..96dadbfaf --- /dev/null +++ b/modules/graphics/macros/%GridCons_i_h.bin diff --git a/modules/graphics/macros/%GridCons_i_h.sci b/modules/graphics/macros/%GridCons_i_h.sci new file mode 100755 index 000000000..87747e111 --- /dev/null +++ b/modules/graphics/macros/%GridCons_i_h.sci @@ -0,0 +1,14 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function h = %GridCons_i_h(i,v,h) + if type(i)==10 then + set(h,i,v) + else + error(msprintf(_("%s: Wrong type for input argument #%d.\n"),"%GridCons_i_h",1)); + end +endfunction diff --git a/modules/graphics/macros/%GridCons_p.bin b/modules/graphics/macros/%GridCons_p.bin Binary files differnew file mode 100755 index 000000000..4b3dce59d --- /dev/null +++ b/modules/graphics/macros/%GridCons_p.bin diff --git a/modules/graphics/macros/%GridCons_p.sci b/modules/graphics/macros/%GridCons_p.sci new file mode 100755 index 000000000..7d3392c83 --- /dev/null +++ b/modules/graphics/macros/%GridCons_p.sci @@ -0,0 +1,11 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function %GridCons_p(t) + printf("Grid Layout\n"); + printf(" No option\n"); +endfunction diff --git a/modules/graphics/macros/%LineBord_i_h.bin b/modules/graphics/macros/%LineBord_i_h.bin Binary files differnew file mode 100755 index 000000000..170f4564a --- /dev/null +++ b/modules/graphics/macros/%LineBord_i_h.bin diff --git a/modules/graphics/macros/%LineBord_i_h.sci b/modules/graphics/macros/%LineBord_i_h.sci new file mode 100755 index 000000000..c215e4cfc --- /dev/null +++ b/modules/graphics/macros/%LineBord_i_h.sci @@ -0,0 +1,14 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function h = %LineBord_i_h(i,v,h) + if type(i)==10 then + set(h,i,v) + else + error(msprintf(_("%s: Wrong type for input argument #%d.\n"),"%LineBord_i_h",1)); + end +endfunction diff --git a/modules/graphics/macros/%LineBord_p.bin b/modules/graphics/macros/%LineBord_p.bin Binary files differnew file mode 100755 index 000000000..6c4190712 --- /dev/null +++ b/modules/graphics/macros/%LineBord_p.bin diff --git a/modules/graphics/macros/%LineBord_p.sci b/modules/graphics/macros/%LineBord_p.sci new file mode 100755 index 000000000..93000730d --- /dev/null +++ b/modules/graphics/macros/%LineBord_p.sci @@ -0,0 +1,25 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function %LineBord_p(t) + count = size(t(1), "*"); + + printf("Line Border\n"); + printf(" Color : %s\n", sci2exp(t.color)); + + if count < 3 then + return; + end + + printf(" Thickness : %s\n", sci2exp(t.thickness)); + + if count < 4 then + return; + end + + printf(" Rounded : %s\n", sci2exp(t.rounded)); +endfunction diff --git a/modules/graphics/macros/%MatteBor_i_h.bin b/modules/graphics/macros/%MatteBor_i_h.bin Binary files differnew file mode 100755 index 000000000..a9d907564 --- /dev/null +++ b/modules/graphics/macros/%MatteBor_i_h.bin diff --git a/modules/graphics/macros/%MatteBor_i_h.sci b/modules/graphics/macros/%MatteBor_i_h.sci new file mode 100755 index 000000000..ac1c64889 --- /dev/null +++ b/modules/graphics/macros/%MatteBor_i_h.sci @@ -0,0 +1,14 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function h = %MatteBor_i_h(i,v,h) + if type(i)==10 then + set(h,i,v) + else + error(msprintf(_("%s: Wrong type for input argument #%d.\n"),"%MatteBor_i_h",1)); + end +endfunction diff --git a/modules/graphics/macros/%MatteBor_p.bin b/modules/graphics/macros/%MatteBor_p.bin Binary files differnew file mode 100755 index 000000000..cbdd2cf4c --- /dev/null +++ b/modules/graphics/macros/%MatteBor_p.bin diff --git a/modules/graphics/macros/%MatteBor_p.sci b/modules/graphics/macros/%MatteBor_p.sci new file mode 100755 index 000000000..97da2f66b --- /dev/null +++ b/modules/graphics/macros/%MatteBor_p.sci @@ -0,0 +1,17 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function %MatteBor_p(t) + count = size(t(1), "*"); + + printf("Matte Border\n"); + printf(" Top : %s\n", sci2exp(t.top)); + printf(" Left : %s\n", sci2exp(t.left)); + printf(" Bottom : %s\n", sci2exp(t.bottom)); + printf(" Right : %s\n", sci2exp(t.right)); + printf(" Color : %s\n", sci2exp(t.color)); +endfunction diff --git a/modules/graphics/macros/%NoBorder_i_h.bin b/modules/graphics/macros/%NoBorder_i_h.bin Binary files differnew file mode 100755 index 000000000..07be78be2 --- /dev/null +++ b/modules/graphics/macros/%NoBorder_i_h.bin diff --git a/modules/graphics/macros/%NoBorder_i_h.sci b/modules/graphics/macros/%NoBorder_i_h.sci new file mode 100755 index 000000000..1feaf91b1 --- /dev/null +++ b/modules/graphics/macros/%NoBorder_i_h.sci @@ -0,0 +1,14 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function h = %NoBorder_i_h(i,v,h) + if type(i)==10 then + set(h,i,v) + else + error(msprintf(_("%s: Wrong type for input argument #%d.\n"),"%NoBorder_i_h",1)); + end +endfunction diff --git a/modules/graphics/macros/%NoBorder_p.bin b/modules/graphics/macros/%NoBorder_p.bin Binary files differnew file mode 100755 index 000000000..c78e5d58d --- /dev/null +++ b/modules/graphics/macros/%NoBorder_p.bin diff --git a/modules/graphics/macros/%NoBorder_p.sci b/modules/graphics/macros/%NoBorder_p.sci new file mode 100755 index 000000000..968162273 --- /dev/null +++ b/modules/graphics/macros/%NoBorder_p.sci @@ -0,0 +1,11 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function %NoBorder_p(t) + printf("No Border\n"); + printf(" No option\n"); +endfunction diff --git a/modules/graphics/macros/%NoLayout_i_h.bin b/modules/graphics/macros/%NoLayout_i_h.bin Binary files differnew file mode 100755 index 000000000..d2705fb4c --- /dev/null +++ b/modules/graphics/macros/%NoLayout_i_h.bin diff --git a/modules/graphics/macros/%NoLayout_i_h.sci b/modules/graphics/macros/%NoLayout_i_h.sci new file mode 100755 index 000000000..a8b377dd1 --- /dev/null +++ b/modules/graphics/macros/%NoLayout_i_h.sci @@ -0,0 +1,14 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function h = %NoLayout_i_h(i,v,h) + if type(i)==10 then + set(h,i,v) + else + error(msprintf(_("%s: Wrong type for input argument #%d.\n"),"%NoLayout_i_h",1)); + end +endfunction diff --git a/modules/graphics/macros/%NoLayout_p.bin b/modules/graphics/macros/%NoLayout_p.bin Binary files differnew file mode 100755 index 000000000..cc614c7e5 --- /dev/null +++ b/modules/graphics/macros/%NoLayout_p.bin diff --git a/modules/graphics/macros/%NoLayout_p.sci b/modules/graphics/macros/%NoLayout_p.sci new file mode 100755 index 000000000..de57a16ba --- /dev/null +++ b/modules/graphics/macros/%NoLayout_p.sci @@ -0,0 +1,11 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function %NoLayout_p(t) + printf("NoLayout\n"); + printf(" No option\n"); +endfunction diff --git a/modules/graphics/macros/%OptBorde_i_h.bin b/modules/graphics/macros/%OptBorde_i_h.bin Binary files differnew file mode 100755 index 000000000..9758bf031 --- /dev/null +++ b/modules/graphics/macros/%OptBorde_i_h.bin diff --git a/modules/graphics/macros/%OptBorde_i_h.sci b/modules/graphics/macros/%OptBorde_i_h.sci new file mode 100755 index 000000000..ae02b296b --- /dev/null +++ b/modules/graphics/macros/%OptBorde_i_h.sci @@ -0,0 +1,14 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function h = %OptBorde_i_h(i,v,h) + if type(i)==10 then + set(h,i,v) + else + error(msprintf(_("%s: Wrong type for input argument #%d.\n"),"%OptBorde_i_h",1)); + end +endfunction diff --git a/modules/graphics/macros/%OptBorde_p.bin b/modules/graphics/macros/%OptBorde_p.bin Binary files differnew file mode 100755 index 000000000..91ce8db19 --- /dev/null +++ b/modules/graphics/macros/%OptBorde_p.bin diff --git a/modules/graphics/macros/%OptBorde_p.sci b/modules/graphics/macros/%OptBorde_p.sci new file mode 100755 index 000000000..2937fbdf1 --- /dev/null +++ b/modules/graphics/macros/%OptBorde_p.sci @@ -0,0 +1,11 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function %OptBorde_p(t) + printf("Border Layout Options\n"); + printf(" Padding : %s\n", sci2exp(t.padding)); +endfunction diff --git a/modules/graphics/macros/%OptGridB_i_h.bin b/modules/graphics/macros/%OptGridB_i_h.bin Binary files differnew file mode 100755 index 000000000..77453e4f9 --- /dev/null +++ b/modules/graphics/macros/%OptGridB_i_h.bin diff --git a/modules/graphics/macros/%OptGridB_i_h.sci b/modules/graphics/macros/%OptGridB_i_h.sci new file mode 100755 index 000000000..86c1c6754 --- /dev/null +++ b/modules/graphics/macros/%OptGridB_i_h.sci @@ -0,0 +1,14 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function h = %OptGridB_i_h(i,v,h) + if type(i)==10 then + set(h,i,v) + else + error(msprintf(_("%s: Wrong type for input argument #%d.\n"),"%OptGridB_i_h",1)); + end +endfunction diff --git a/modules/graphics/macros/%OptGridB_p.bin b/modules/graphics/macros/%OptGridB_p.bin Binary files differnew file mode 100755 index 000000000..9db91804e --- /dev/null +++ b/modules/graphics/macros/%OptGridB_p.bin diff --git a/modules/graphics/macros/%OptGridB_p.sci b/modules/graphics/macros/%OptGridB_p.sci new file mode 100755 index 000000000..463d0fe03 --- /dev/null +++ b/modules/graphics/macros/%OptGridB_p.sci @@ -0,0 +1,11 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function %OptGridB_p(t) + printf("Gridbag Layout Options\n"); + printf(" No option\n"); +endfunction diff --git a/modules/graphics/macros/%OptGrid_i_h.bin b/modules/graphics/macros/%OptGrid_i_h.bin Binary files differnew file mode 100755 index 000000000..7a896903e --- /dev/null +++ b/modules/graphics/macros/%OptGrid_i_h.bin diff --git a/modules/graphics/macros/%OptGrid_i_h.sci b/modules/graphics/macros/%OptGrid_i_h.sci new file mode 100755 index 000000000..2bd04cfe4 --- /dev/null +++ b/modules/graphics/macros/%OptGrid_i_h.sci @@ -0,0 +1,14 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function h = %OptGrid_i_h(i,v,h) + if type(i)==10 then + set(h,i,v) + else + error(msprintf(_("%s: Wrong type for input argument #%d.\n"),"%OptGrid_i_h",1)); + end +endfunction diff --git a/modules/graphics/macros/%OptGrid_p.bin b/modules/graphics/macros/%OptGrid_p.bin Binary files differnew file mode 100755 index 000000000..1fecd29d1 --- /dev/null +++ b/modules/graphics/macros/%OptGrid_p.bin diff --git a/modules/graphics/macros/%OptGrid_p.sci b/modules/graphics/macros/%OptGrid_p.sci new file mode 100755 index 000000000..17909ba52 --- /dev/null +++ b/modules/graphics/macros/%OptGrid_p.sci @@ -0,0 +1,12 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function %OptGrid_p(t) + printf("Grid Layout Options\n"); + printf(" Grid : %s\n", sci2exp(t.grid)); + printf(" Padding : %s\n", sci2exp(t.padding)); +endfunction diff --git a/modules/graphics/macros/%OptNoLay_i_h.bin b/modules/graphics/macros/%OptNoLay_i_h.bin Binary files differnew file mode 100755 index 000000000..ac74bf979 --- /dev/null +++ b/modules/graphics/macros/%OptNoLay_i_h.bin diff --git a/modules/graphics/macros/%OptNoLay_i_h.sci b/modules/graphics/macros/%OptNoLay_i_h.sci new file mode 100755 index 000000000..fe1772d6d --- /dev/null +++ b/modules/graphics/macros/%OptNoLay_i_h.sci @@ -0,0 +1,14 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function h = %OptNoLay_i_h(i,v,h) + if type(i)==10 then + set(h,i,v) + else + error(msprintf(_("%s: Wrong type for input argument #%d.\n"),"%OptNoLay_i_h",1)); + end +endfunction diff --git a/modules/graphics/macros/%OptNoLay_p.bin b/modules/graphics/macros/%OptNoLay_p.bin Binary files differnew file mode 100755 index 000000000..7e242be13 --- /dev/null +++ b/modules/graphics/macros/%OptNoLay_p.bin diff --git a/modules/graphics/macros/%OptNoLay_p.sci b/modules/graphics/macros/%OptNoLay_p.sci new file mode 100755 index 000000000..ca7796c78 --- /dev/null +++ b/modules/graphics/macros/%OptNoLay_p.sci @@ -0,0 +1,11 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function %OptNoLay_p(t) + printf("No Layout Options\n"); + printf(" No option\n"); +endfunction diff --git a/modules/graphics/macros/%SoftBeve_i_h.bin b/modules/graphics/macros/%SoftBeve_i_h.bin Binary files differnew file mode 100755 index 000000000..9c4cc1ae5 --- /dev/null +++ b/modules/graphics/macros/%SoftBeve_i_h.bin diff --git a/modules/graphics/macros/%SoftBeve_i_h.sci b/modules/graphics/macros/%SoftBeve_i_h.sci new file mode 100755 index 000000000..ed1bb1802 --- /dev/null +++ b/modules/graphics/macros/%SoftBeve_i_h.sci @@ -0,0 +1,14 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function h = %SoftBeve_i_h(i,v,h) + if type(i)==10 then + set(h,i,v) + else + error(msprintf(_("%s: Wrong type for input argument #%d.\n"),"%SoftBeve_i_h",1)); + end +endfunction diff --git a/modules/graphics/macros/%SoftBeve_p.bin b/modules/graphics/macros/%SoftBeve_p.bin Binary files differnew file mode 100755 index 000000000..1cd2081cb --- /dev/null +++ b/modules/graphics/macros/%SoftBeve_p.bin diff --git a/modules/graphics/macros/%SoftBeve_p.sci b/modules/graphics/macros/%SoftBeve_p.sci new file mode 100755 index 000000000..da131fcc9 --- /dev/null +++ b/modules/graphics/macros/%SoftBeve_p.sci @@ -0,0 +1,28 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function %SoftBeve_p(t) + count = size(t(1), "*"); + + printf("SoftBevel Border\n"); + printf(" Type : %s\n", sci2exp(t.type)); + + if count == 2 then + return + end + + printf(" Highlight outer : %s\n", sci2exp(t.hlouter)); + + if count == 4 then + printf(" Shadow outer : %s\n", sci2exp(t.shadowouter)); + return; + end + + printf(" Highlight inner : %s\n", sci2exp(t.hlinner)); + printf(" Shadow outer : %s\n", sci2exp(t.shadowouter)); + printf(" Shadow inner : %s\n", sci2exp(t.shadowinner)); +endfunction diff --git a/modules/graphics/macros/%TitledBo_i_h.bin b/modules/graphics/macros/%TitledBo_i_h.bin Binary files differnew file mode 100755 index 000000000..ac34d6809 --- /dev/null +++ b/modules/graphics/macros/%TitledBo_i_h.bin diff --git a/modules/graphics/macros/%TitledBo_i_h.sci b/modules/graphics/macros/%TitledBo_i_h.sci new file mode 100755 index 000000000..e402b4e40 --- /dev/null +++ b/modules/graphics/macros/%TitledBo_i_h.sci @@ -0,0 +1,14 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function h = %TitledBo_i_h(i,v,h) + if type(i)==10 then + set(h,i,v) + else + error(msprintf(_("%s: Wrong type for input argument #%d.\n"),"%TitledBo_i_h",1)); + end +endfunction diff --git a/modules/graphics/macros/%TitledBo_p.bin b/modules/graphics/macros/%TitledBo_p.bin Binary files differnew file mode 100755 index 000000000..4ae5d33bf --- /dev/null +++ b/modules/graphics/macros/%TitledBo_p.bin diff --git a/modules/graphics/macros/%TitledBo_p.sci b/modules/graphics/macros/%TitledBo_p.sci new file mode 100755 index 000000000..d5f66865c --- /dev/null +++ b/modules/graphics/macros/%TitledBo_p.sci @@ -0,0 +1,42 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2104 - Scilab Enterprises - Antoine ELIAS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function %TitledBo_p(t) + count = size(t(1), "*"); + + printf("Titled Border\n"); + if count == 2 then + if typeof(t(2)) == "string" then + printf(" Title : %s\n", sci2exp(t.title)); + else + printf(" Border : %s\n", typeof(t.border)); + end + return; + end + + printf(" Border : %s\n", typeof(t.border)); + printf(" Title : %s\n", sci2exp(t.title)); + + if count < 5 then + return; + end + + printf(" Justification : %s\n", sci2exp(t.justification)); + printf(" Position : %s\n", sci2exp(t.position)); + + if count < 6 then + return; + end + + printf(" Font : %s\n", typeof(t.font)); + + if count < 7 then + return; + end + + printf(" Color : %s\n", sci2exp(t.color)); +endfunction diff --git a/modules/graphics/macros/%_Matplot.bin b/modules/graphics/macros/%_Matplot.bin Binary files differnew file mode 100755 index 000000000..3193f0ea9 --- /dev/null +++ b/modules/graphics/macros/%_Matplot.bin diff --git a/modules/graphics/macros/%_Matplot.sci b/modules/graphics/macros/%_Matplot.sci new file mode 100755 index 000000000..d017ef1a1 --- /dev/null +++ b/modules/graphics/macros/%_Matplot.sci @@ -0,0 +1,34 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2012 - Samuel GOUGEON +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +// +// This is the demonstration script of Matplot +// used when calling Matplot without any parameter. + +function %_Matplot() + ny = 400; + nx = 300; + M = pmodulo((0:(ny-1))'*ones(1:nx) + ones(ny,1)*(0:nx-1),ceil(max(nx,ny)/3)); + + Matplot(M) + + f = gcf(); + my_plot_desc = _("Classical Matplot"); + f.figure_name = my_plot_desc; + f.color_map = coolcolormap(nx); + + a = gca(); + a.tight_limits = "on"; + a.isoview = "on"; + a.title.font_size = 2; + Tlab = _("Matplot(M) with size(M)=>(%d,%d)\nThe color''s number of pixel(i,j)\n = rounded value of M(i,j)"); + Xlab = _("For data-scaled axes, please use Matplot1(..)"); + Ylab = _("Axes are scaled with M''s indices"); + xtitle(msprintf(Tlab,ny,nx), Xlab, Ylab); +endfunction + diff --git a/modules/graphics/macros/%_Matplot1.bin b/modules/graphics/macros/%_Matplot1.bin Binary files differnew file mode 100755 index 000000000..7534cbc79 --- /dev/null +++ b/modules/graphics/macros/%_Matplot1.bin diff --git a/modules/graphics/macros/%_Matplot1.sci b/modules/graphics/macros/%_Matplot1.sci new file mode 100755 index 000000000..6f6373263 --- /dev/null +++ b/modules/graphics/macros/%_Matplot1.sci @@ -0,0 +1,42 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2012 - Samuel GOUGEON +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +// +// This is the demonstration script of Matplot1 +// used when calling Matplot1 without any parameter. +// + +function %_Matplot1() + nc = 200 // Number of colors + np = 2 // Number of periods + nx = 350 + ny = 300 + [X,Y] = meshgrid(-nx/2:nx/2, -ny/2:ny/2); + R = sqrt(X.^2+Y.^2); + R = (R-min(R))/(max(R)-min(R))*nc*np; + R = 1+pmodulo(R,nc); + xmin = -15, xmax = 40, ymin = -0.03, ymax = 0.01 + + Matplot1(R,[xmin ymin xmax ymax]); + + f = gcf(); + my_plot_desc = _("Classical Matplot1"); + f.figure_name = my_plot_desc; + f.color_map = hsvcolormap(nc); + + a = gca() + a.data_bounds=[xmin ymin ; xmax ymax]; + a.tight_limits = "on" + a.axes_visible=["on" "on" "off"]; + a.title.font_size = 2 + a.x_label.font_size = 2 + Tlab = _("Matplot1(M, [ %g %g %g %g ]) with size(M)=>(%d,%d)\npixel(i,j) is drawn with color number int(M(i,j))"); + Xlab = _("Axes are scaled with [xmin ymin xmax ymax] specified") + xtitle(msprintf(Tlab,xmin,ymin,xmax,ymax,nx,ny),Xlab) +endfunction + diff --git a/modules/graphics/macros/%_champ.bin b/modules/graphics/macros/%_champ.bin Binary files differnew file mode 100755 index 000000000..1d52dd4a3 --- /dev/null +++ b/modules/graphics/macros/%_champ.bin diff --git a/modules/graphics/macros/%_champ.sci b/modules/graphics/macros/%_champ.sci new file mode 100755 index 000000000..a518d6ff8 --- /dev/null +++ b/modules/graphics/macros/%_champ.sci @@ -0,0 +1,20 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Jean-Baptiste Silvy +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +// +// + +// +// This is the demonstration script of champ +// used when calling champ without any parameter. +// + +function [] = %_champ() + champ(1:10,1:10,rand(10,10),rand(10,10),1.0); +endfunction diff --git a/modules/graphics/macros/%_champ1.bin b/modules/graphics/macros/%_champ1.bin Binary files differnew file mode 100755 index 000000000..2d9666c86 --- /dev/null +++ b/modules/graphics/macros/%_champ1.bin diff --git a/modules/graphics/macros/%_champ1.sci b/modules/graphics/macros/%_champ1.sci new file mode 100755 index 000000000..93d86a7c0 --- /dev/null +++ b/modules/graphics/macros/%_champ1.sci @@ -0,0 +1,20 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Jean-Baptiste Silvy +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +// +// + +// +// This is the demonstration script of champ1 +// used when calling champ1 without any parameter. +// + +function [] = %_champ1() + champ1(1:10,1:10,rand(10,10),rand(10,10),1.0); +endfunction diff --git a/modules/graphics/macros/%_fec.bin b/modules/graphics/macros/%_fec.bin Binary files differnew file mode 100755 index 000000000..41c81d74a --- /dev/null +++ b/modules/graphics/macros/%_fec.bin diff --git a/modules/graphics/macros/%_fec.sci b/modules/graphics/macros/%_fec.sci new file mode 100755 index 000000000..1655dccc7 --- /dev/null +++ b/modules/graphics/macros/%_fec.sci @@ -0,0 +1,43 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Jean-Baptiste Silvy +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +// +// + +// +// This is the demonstration script of fec +// used when calling fec without any parameter. +// + +function [] = %_fec() + mode(0) + exec("SCI/modules/graphics/demos/fec/fec_demo.sci",-1); + clf(); + xset("colormap",jetcolormap(128)); + N=20; + n=1:N; + x=cos(n*2*%pi/N); + y=sin(n*2*%pi/N); + noeuds=N; + noeul=[(1:(N))',x',y',0*ones(N,1)]; + noeul=[noeul;(N+1),0,0,0]; + trianl=[]; + for i=1:(N-1),trianl=[trianl;i,i,i+1,N+1,0];end + trianl=[trianl;N,N,1,N+1,0]; + triang=N; + rect=[-1.2,-1.2,1.2,1.2]; + drawlater(); + fec(noeul(:,2),noeul(:,3),trianl,(1:N+1)',"030"," ",rect); + meshvisu(3,rect); + drawnow(); + show_window(); + + mode(-1) + +endfunction diff --git a/modules/graphics/macros/%_grayplot.bin b/modules/graphics/macros/%_grayplot.bin Binary files differnew file mode 100755 index 000000000..9d1fc5165 --- /dev/null +++ b/modules/graphics/macros/%_grayplot.bin diff --git a/modules/graphics/macros/%_grayplot.sci b/modules/graphics/macros/%_grayplot.sci new file mode 100755 index 000000000..b469fd8c3 --- /dev/null +++ b/modules/graphics/macros/%_grayplot.sci @@ -0,0 +1,27 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Jean-Baptiste Silvy +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +// +// + +// +// This is the demonstration script of grayplot +// used when calling grayplot without any parameter. +// + +function [] = %_grayplot() + t=-%pi:0.05:%pi; + m=sin(t)'*cos(t); + grayplot(t,t,m); + f = gcf(); + my_plot_desc = "grayplot"; + f.figure_name = my_plot_desc; + xtitle(my_plot_desc," "," "," "); + f.color_map = hotcolormap(128); +endfunction diff --git a/modules/graphics/macros/%_param3d.bin b/modules/graphics/macros/%_param3d.bin Binary files differnew file mode 100755 index 000000000..b0bfe3ffb --- /dev/null +++ b/modules/graphics/macros/%_param3d.bin diff --git a/modules/graphics/macros/%_param3d.sci b/modules/graphics/macros/%_param3d.sci new file mode 100755 index 000000000..76f0242c2 --- /dev/null +++ b/modules/graphics/macros/%_param3d.sci @@ -0,0 +1,21 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Jean-Baptiste Silvy +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +// +// + +// +// This is the demonstration script of param3d +// used when calling param3d without any parameter. +// + +function [] = %_param3d() + t=0:0.1:5*%pi; + param3d(sin(t),cos(t),t/10,35,45,"X@Y@Z",[2,4]); +endfunction diff --git a/modules/graphics/macros/%_param3d1.bin b/modules/graphics/macros/%_param3d1.bin Binary files differnew file mode 100755 index 000000000..c046bf7a1 --- /dev/null +++ b/modules/graphics/macros/%_param3d1.bin diff --git a/modules/graphics/macros/%_param3d1.sci b/modules/graphics/macros/%_param3d1.sci new file mode 100755 index 000000000..e5ef05441 --- /dev/null +++ b/modules/graphics/macros/%_param3d1.sci @@ -0,0 +1,21 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Jean-Baptiste Silvy +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +// +// + +// +// This is the demonstration script of param3d1 +// used when calling param3d1 without any parameter. +// + +function [] = %_param3d1() + t=0:0.1:5*%pi; + param3d1(sin(t),cos(t),t/10,35,45,"X@Y@Z",[2,4]); +endfunction diff --git a/modules/graphics/macros/%_plot2d.bin b/modules/graphics/macros/%_plot2d.bin Binary files differnew file mode 100755 index 000000000..0c3cb2304 --- /dev/null +++ b/modules/graphics/macros/%_plot2d.bin diff --git a/modules/graphics/macros/%_plot2d.sci b/modules/graphics/macros/%_plot2d.sci new file mode 100755 index 000000000..63f83af39 --- /dev/null +++ b/modules/graphics/macros/%_plot2d.sci @@ -0,0 +1,21 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Jean-Baptiste Silvy +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +// +// + +// +// This is the demonstration script of plot2d +// used when calling plot2d without any parameter. +// + +function [] = %_plot2d() + x=(0:0.1:2*%pi)'; + plot2d(x, [sin(x),sin(2*x),sin(3*x)], style=[-1,-2,3], rect=[0,-2,2*%pi,2], axesflag=1); +endfunction diff --git a/modules/graphics/macros/%_plot2d1.bin b/modules/graphics/macros/%_plot2d1.bin Binary files differnew file mode 100755 index 000000000..9f3c924a6 --- /dev/null +++ b/modules/graphics/macros/%_plot2d1.bin diff --git a/modules/graphics/macros/%_plot2d1.sci b/modules/graphics/macros/%_plot2d1.sci new file mode 100755 index 000000000..328689f6d --- /dev/null +++ b/modules/graphics/macros/%_plot2d1.sci @@ -0,0 +1,21 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Jean-Baptiste Silvy +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +// +// + +// +// This is the demonstration script of plot2d1 +// used when calling plot2d1 without any parameter. +// + +function [] = %_plot2d1() + x=(0:0.1:2*%pi)'; + plot2d1(x, [sin(x),sin(2*x),sin(3*x)], style=[1,2,3], rect=[0,-2,2*%pi,2]); +endfunction diff --git a/modules/graphics/macros/%_plot2d2.bin b/modules/graphics/macros/%_plot2d2.bin Binary files differnew file mode 100755 index 000000000..ccc361cc5 --- /dev/null +++ b/modules/graphics/macros/%_plot2d2.bin diff --git a/modules/graphics/macros/%_plot2d2.sci b/modules/graphics/macros/%_plot2d2.sci new file mode 100755 index 000000000..b091b3103 --- /dev/null +++ b/modules/graphics/macros/%_plot2d2.sci @@ -0,0 +1,21 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Jean-Baptiste Silvy +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +// +// + +// +// This is the demonstration script of plot2d2 +// used when calling plot2d2 without any parameter. +// + +function [] = %_plot2d2() + x=(0:0.1:2*%pi)'; + plot2d2(x, [sin(x),sin(2*x),sin(3*x)], style=[1,2,3], rect=[0,-2,2*%pi,2]); +endfunction diff --git a/modules/graphics/macros/%_plot2d3.bin b/modules/graphics/macros/%_plot2d3.bin Binary files differnew file mode 100755 index 000000000..118082d66 --- /dev/null +++ b/modules/graphics/macros/%_plot2d3.bin diff --git a/modules/graphics/macros/%_plot2d3.sci b/modules/graphics/macros/%_plot2d3.sci new file mode 100755 index 000000000..260a7824d --- /dev/null +++ b/modules/graphics/macros/%_plot2d3.sci @@ -0,0 +1,21 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Jean-Baptiste Silvy +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +// +// + +// +// This is the demonstration script of plot2d3 +// used when calling plot2d3 without any parameter. +// + +function [] = %_plot2d3() + x=(0:0.1:2*%pi)'; + plot2d3(x, [sin(x),sin(2*x),sin(3*x)], style=[1,2,3], rect=[0,-2,2*%pi,2]); +endfunction diff --git a/modules/graphics/macros/%_plot2d4.bin b/modules/graphics/macros/%_plot2d4.bin Binary files differnew file mode 100755 index 000000000..b837dce17 --- /dev/null +++ b/modules/graphics/macros/%_plot2d4.bin diff --git a/modules/graphics/macros/%_plot2d4.sci b/modules/graphics/macros/%_plot2d4.sci new file mode 100755 index 000000000..bb0f3601b --- /dev/null +++ b/modules/graphics/macros/%_plot2d4.sci @@ -0,0 +1,21 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Jean-Baptiste Silvy +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +// +// + +// +// This is the demonstration script of plot2d4 +// used when calling plot2d4 without any parameter. +// + +function [] = %_plot2d4() + x=(0:0.1:2*%pi)'; + plot2d4(x, [sin(x),sin(2*x),sin(3*x)], style=[1,2,3], rect=[0,-2,2*%pi,2]); +endfunction diff --git a/modules/graphics/macros/%_plot3d.bin b/modules/graphics/macros/%_plot3d.bin Binary files differnew file mode 100755 index 000000000..d122d0f17 --- /dev/null +++ b/modules/graphics/macros/%_plot3d.bin diff --git a/modules/graphics/macros/%_plot3d.sci b/modules/graphics/macros/%_plot3d.sci new file mode 100755 index 000000000..1bf036800 --- /dev/null +++ b/modules/graphics/macros/%_plot3d.sci @@ -0,0 +1,26 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009-2009 - DIGITEO - Bruno JOFRET +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +// +// + +// +// This is the demonstration script of plot3d +// used when calling plot3d without any parameter. +// + +function [] = %_plot3d() + x = %pi * [-1:0.05:1]'; + z = sin(x)*cos(x)'; + plot3d(x, x, z, 70, 70); + e=gce(); + e.color_flag = 1; + f = gcf(); + f.color_map = jetcolormap(32); +endfunction diff --git a/modules/graphics/macros/%_plot3d1.bin b/modules/graphics/macros/%_plot3d1.bin Binary files differnew file mode 100755 index 000000000..482808788 --- /dev/null +++ b/modules/graphics/macros/%_plot3d1.bin diff --git a/modules/graphics/macros/%_plot3d1.sci b/modules/graphics/macros/%_plot3d1.sci new file mode 100755 index 000000000..87ac3be40 --- /dev/null +++ b/modules/graphics/macros/%_plot3d1.sci @@ -0,0 +1,24 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Jean-Baptiste Silvy +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +// +// + +// +// This is the demonstration script of plot3d1 +// used when calling plot3d1 without any parameter. +// + +function [] = %_plot3d1() + x = %pi * [-1:0.05:1]'; + z = sin(x)*cos(x)'; + plot3d1(x, x, z, 70, 70); + f = gcf(); + f.color_map = jetcolormap(32); +endfunction diff --git a/modules/graphics/macros/%_xget.bin b/modules/graphics/macros/%_xget.bin Binary files differnew file mode 100755 index 000000000..4516589ed --- /dev/null +++ b/modules/graphics/macros/%_xget.bin diff --git a/modules/graphics/macros/%_xget.sci b/modules/graphics/macros/%_xget.sci new file mode 100755 index 000000000..bbbc6892a --- /dev/null +++ b/modules/graphics/macros/%_xget.sci @@ -0,0 +1,20 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Jean-Baptiste Silvy +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +// +// + +// +// This is the demonstration script of xget +// used when calling xget without any parameter. +// + +function [] = %_xget() + ged(1); +endfunction diff --git a/modules/graphics/macros/%_xset.bin b/modules/graphics/macros/%_xset.bin Binary files differnew file mode 100755 index 000000000..c00a67dd2 --- /dev/null +++ b/modules/graphics/macros/%_xset.bin diff --git a/modules/graphics/macros/%_xset.sci b/modules/graphics/macros/%_xset.sci new file mode 100755 index 000000000..4006e8652 --- /dev/null +++ b/modules/graphics/macros/%_xset.sci @@ -0,0 +1,20 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Jean-Baptiste Silvy +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +// +// + +// +// This is the demonstration script of xset +// used when calling xset without any parameter. +// + +function [] = %_xset() + ged(1); +endfunction diff --git a/modules/graphics/macros/%_xstringb.bin b/modules/graphics/macros/%_xstringb.bin Binary files differnew file mode 100755 index 000000000..995bd06de --- /dev/null +++ b/modules/graphics/macros/%_xstringb.bin diff --git a/modules/graphics/macros/%_xstringb.sci b/modules/graphics/macros/%_xstringb.sci new file mode 100755 index 000000000..0dd1ca3b7 --- /dev/null +++ b/modules/graphics/macros/%_xstringb.sci @@ -0,0 +1,26 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Jean-Baptiste Silvy +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +// +// + +// +// This is the demonstration script of xstringb +// used when calling xstringb without any parameter. +// + +function [] = %_xstringb() + scf(); + axes = gca(); + axes.axes_visible = "on"; + str = ["Scilab","is";"not","Esilab"]; + xstringb(0.1,0.1,str,0.5,0.5,"fill"); + txt = gce(); + txt.box = "on"; +endfunction diff --git a/modules/graphics/macros/%_xtitle.bin b/modules/graphics/macros/%_xtitle.bin Binary files differnew file mode 100755 index 000000000..72c957082 --- /dev/null +++ b/modules/graphics/macros/%_xtitle.bin diff --git a/modules/graphics/macros/%_xtitle.sci b/modules/graphics/macros/%_xtitle.sci new file mode 100755 index 000000000..923a11909 --- /dev/null +++ b/modules/graphics/macros/%_xtitle.sci @@ -0,0 +1,22 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Jean-Baptiste Silvy +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +// +// + +// +// This is the demonstration script of xtitle +// used when calling xtitle without any parameter. +// + +function [] = %_xtitle() + x=(1:10)'; + plot2d(x, x); + xtitle(["Title";"Main"], "x", "y"); +endfunction diff --git a/modules/graphics/macros/%h_copy.bin b/modules/graphics/macros/%h_copy.bin Binary files differnew file mode 100755 index 000000000..f2b5d0be3 --- /dev/null +++ b/modules/graphics/macros/%h_copy.bin diff --git a/modules/graphics/macros/%h_copy.sci b/modules/graphics/macros/%h_copy.sci new file mode 100755 index 000000000..3b42d921d --- /dev/null +++ b/modules/graphics/macros/%h_copy.sci @@ -0,0 +1,33 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// Copyright (C) 2013-2013 - Scilab Enterprises - Bruno JOFRET +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +// +// + +function h=%h_copy(h,ax) + filename = tempname(); + save(filename,"h") + if argn(2)<2 then + load(filename) + else + if ax.type=="Axes" then + a=get("current_axes") + set("current_axes", ax) + load(filename) + set("current_axes", a) + else + a = gcf() + scf(ax) + load(filename) + scf(a) + end + end + mdelete(filename); +endfunction diff --git a/modules/graphics/macros/%h_delete.bin b/modules/graphics/macros/%h_delete.bin Binary files differnew file mode 100755 index 000000000..8a73d5604 --- /dev/null +++ b/modules/graphics/macros/%h_delete.bin diff --git a/modules/graphics/macros/%h_delete.sci b/modules/graphics/macros/%h_delete.sci new file mode 100755 index 000000000..0db729c5b --- /dev/null +++ b/modules/graphics/macros/%h_delete.sci @@ -0,0 +1,13 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +function %h_delete(varargin) + // No operation overloading function + // We allow the user to overload the %h_delete function +endfunction diff --git a/modules/graphics/macros/%h_e.bin b/modules/graphics/macros/%h_e.bin Binary files differnew file mode 100755 index 000000000..2c781964e --- /dev/null +++ b/modules/graphics/macros/%h_e.bin diff --git a/modules/graphics/macros/%h_e.sci b/modules/graphics/macros/%h_e.sci new file mode 100755 index 000000000..06a2e2baa --- /dev/null +++ b/modules/graphics/macros/%h_e.sci @@ -0,0 +1,41 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +function r=%h_e(i,h) + h=h + if type(i)==10 then + r=get(h,i) + elseif type(i)==15 then + n=lstsize(i) + + for k=1:n + p=i(k) + if type(p)==10 then + if type(h)==9 then + h=get(h,p), + else + h=h(p) + end + elseif or(type(p)==[1 2 4 8 129]) then + h=h(p) + elseif type(p)==15 then + h=h(p(:)) + else + error("Invalid path") + end + end + r=h + elseif type(i)==1 then + r=h(i) + else + error("Invalid path") + end + + if type(r)==10 then r=stripblanks(r),end +endfunction diff --git a/modules/graphics/macros/%h_get.bin b/modules/graphics/macros/%h_get.bin Binary files differnew file mode 100755 index 000000000..cf8aa4b08 --- /dev/null +++ b/modules/graphics/macros/%h_get.bin diff --git a/modules/graphics/macros/%h_get.sci b/modules/graphics/macros/%h_get.sci new file mode 100755 index 000000000..957bac089 --- /dev/null +++ b/modules/graphics/macros/%h_get.sci @@ -0,0 +1,23 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +function out_vect = %h_get(varargin) + out_vect = []; + if (lstsize(varargin) == 2) + hdl = varargin(1) + str = varargin(2) + for i=1:size(hdl,"*") + out_vect = [out_vect, get(hdl(i),str)] + end + + elseif (lstsize(varargin) == 1) + str = varargin(1) + out_vect = get(str) + end +endfunction diff --git a/modules/graphics/macros/%h_i_h.bin b/modules/graphics/macros/%h_i_h.bin Binary files differnew file mode 100755 index 000000000..c40dd2d49 --- /dev/null +++ b/modules/graphics/macros/%h_i_h.bin diff --git a/modules/graphics/macros/%h_i_h.sci b/modules/graphics/macros/%h_i_h.sci new file mode 100755 index 000000000..31ee98da6 --- /dev/null +++ b/modules/graphics/macros/%h_i_h.sci @@ -0,0 +1,17 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Calixte DENIZET +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +function a=%h_i_h(i1, b, a) + if type(i1) == 10 then + set(a, i1, b) + else + error("Invalid path") + end +endfunction diff --git a/modules/graphics/macros/%h_load.bin b/modules/graphics/macros/%h_load.bin Binary files differnew file mode 100755 index 000000000..7c35f8a75 --- /dev/null +++ b/modules/graphics/macros/%h_load.bin diff --git a/modules/graphics/macros/%h_load.sci b/modules/graphics/macros/%h_load.sci new file mode 100755 index 000000000..ec59a7adf --- /dev/null +++ b/modules/graphics/macros/%h_load.sci @@ -0,0 +1,1601 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2004 - INRIA - Serge Steer +// Copyright (C) 2004-2006 - INRIA - Fabrice Leray +// Copyright (C) 2006 - INRIA - Jean-Baptiste Silvy +// Copyright (C) 2010 - DIGITEO - Manuel Juliachs +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +function h=%h_load(fd) + global init_immediate_drawing + init_immediate_drawing = 0; + + version=mget(4,"uc",fd) + // saving/loading character with 'c' is actually quite buggy + characterFormat = "uc"; + stringFormat = "il"; + + immediate_drawing=""; + + h=[]; + + if is_higher_than([3 1 0 1]) then // case 3 1 0 2 and after + hsize = mget(2,characterFormat,fd) + for i=1:hsize(1) + for j=1:hsize(2) + [htmp,immediate_drawing] = load_graphichandle(fd) + h = [h htmp]; + end + end + else + [h,immediate_drawing] = load_graphichandle(fd) // a single handle only can be loaded before 3 1 0 2 + end + f=gcf(); + f.immediate_drawing = immediate_drawing; + clearglobal init_immediate_drawing + clear init_immediate_drawing +endfunction + +function [h,immediate_drawing] = load_graphichandle(fd) + global init_immediate_drawing + typ=ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) + if typ<>"Figure" + f=gcf(); + if init_immediate_drawing == 0 + immediate_drawing = f.immediate_drawing; + f.immediate_drawing ="off"; + init_immediate_drawing = 1; + end + end + // mprintf('----------------------------- %s ----------------------\n',typ) + // Determines whether %h_load has been called by the xload macro + // in which case xload_mode is set to true + [lnums, fnames] = where(); + ind = grep(fnames, "xload"); + xload_mode = (ind ~= []); + + select typ + case "Figure" + if xload_mode then + h=gcf() + visible=toggle(mget(1,characterFormat,fd)); // visible + figure_position=mget(2,"sl",fd); // figure_position + figure_size=mget(2,"sl",fd); // figure_size + axes_size=mget(2,"sl",fd); //axes_size + if ( is_higher_than([4 1 2 0]) ) then + viewport = mget(2,"sl",fd) ; // viewport + if is_higher_than([5 4 0 0]) then + info_message = ascii(mget(mget(1,stringFormat,fd),characterFormat,fd)) ; // info_message + else + info_message = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) ; // info_message + end + tag = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) ; // tag + end + auto_resize=toggle(mget(1,characterFormat,fd)); // auto_resize + if is_higher_than([5 4 0 0]) then + figure_name=ascii(mget(mget(1,stringFormat,fd),characterFormat,fd)) // figure_name + else + figure_name=ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // figure_name + end + figure_id=mget(1,"sl",fd); // figure_id + h.color_map=matrix(mget(mget(1,"il",fd),"dl",fd),-1,3) // color_map + if ~is_higher_than([5 4 0 1]) then + pixmap=toggle(mget(1,characterFormat,fd)); // pixmap, removed from V5.5.0 on + end + pixel_drawing_mode=ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // pixel_drawing_mode + if (is_higher_than([5 1 0 0])) then + anti_aliasing=ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)); // anti_aliasing + end + immediate_drawing=toggle(mget(1,characterFormat,fd));// immediate drawing // init. global variable immediate_drawing + h.immediate_drawing = "off"; // set it to 'off' to pass useless redraw due to several 'set' calls + h.background=mget(1,"il",fd) // background + rotation_style=ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // rotation_style + else + visible=toggle(mget(1,characterFormat,fd)); // visible + figure_position=mget(2,"sl",fd); // figure_position + // if figure is iconified in old scilab version, its position is -32000, -32000] + figure_position = max(figure_position, [0,0]); + figure_size=mget(2,"sl",fd); // figure_size + axes_size=mget(2,"sl",fd); // axes_size + if ( is_higher_than([4 1 2 0]) ) then + viewport = mget(2,"sl",fd) ; // viewport + if is_higher_than([5 4 0 0]) then + info_message = ascii(mget(mget(1,stringFormat,fd),characterFormat,fd)) ; // info_message + else + info_message = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) ; // info_message + end + tag = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) ; // tag + end + auto_resize=toggle(mget(1,characterFormat,fd)); // auto_resize + if is_higher_than([5 4 0 0]) then + figure_name=ascii(mget(mget(1,stringFormat,fd),characterFormat,fd)) // figure_name + else + figure_name=ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // figure_name + end + figure_id=mget(1,"sl",fd); // figure_id + // create the figure + h=scf(figure_id); + h.visible=visible; // can be set now as we act on immediate_drawing everywhere else F.Leray 18.02.05 + h.figure_position=figure_position + // set auto_resize first otherwise viewport modification may not have any effect. + h.auto_resize = auto_resize; + h.figure_size = figure_size; + // set axes_size last because it's more important than figure_size + h.axes_size = axes_size; + + if ( is_higher_than([4 1 2 0]) ) then + h.viewport = viewport; + h.info_message = info_message ; + h.tag = tag ; + end + h.figure_name=figure_name + h.color_map=matrix(mget(mget(1,"il",fd),"dl",fd),-1,3) // color_map + if ~is_higher_than([5 4 0 1]) then + pixmap=toggle(mget(1,characterFormat,fd)); // pixmap, removed from V5.5.0 on + end + h.pixel_drawing_mode=ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // pixel_drawing_mode + if (is_higher_than([5 1 0 0])) then + h.anti_aliasing=ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)); // anti_aliasing + end + immediate_drawing=toggle(mget(1,characterFormat,fd)); // immediate_drawing // init. global variable immediate_drawing + h.immediate_drawing = "off"; // set it to 'off' to pass useless redraw due to several 'set' calls + h.background=mget(1,"il",fd); // background + h.rotation_style = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) ; // rotation_style + + end + + if ( is_higher_than([4 1 2 0]) ) then + h.event_handler = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) ; // event_handler + h.event_handler_enable = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) ; // event_handler_enable + end + + if ( is_higher_than([5 2 0 0]) ) then // Added in 5.4.0 version + h.resizefcn = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) ; // resizefcn + h.closerequestfcn = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) ; // closerequestfcn + end + + // children + n_axes=mget(1,"il",fd); + if n_axes==1 then + load_graphichandle(fd) + else + load_graphichandle(fd); + for k=2:n_axes + xsetech(wrect=[0 0 .1 .1]) + load_graphichandle(fd) + end + end + load_user_data(fd); // user_data + case "Axes" + // Hack to determine whether %h_load has been called by the %h_copy macro + // in which case a new Axes object is created + [lnums, fnames]=where(); + ind=grep(fnames, "%h_copy"); + + if(ind<>[]) then + newaxes(); + end; + + a=gca() ; + titl=a.title ; + x_label=a.x_label ; + y_label=a.y_label ; + set(a,"visible" , toggle(mget(1,characterFormat,fd))) // visible + if and(version==[3 0 0 0]) then // axes_visible + axes_visible= toggle(mget(1,characterFormat,fd)); + axes_visible=emptystr(1,3)+axes_visible + else + axes_visible= toggle(mget(mget(1,characterFormat,fd),characterFormat,fd)) ; + end + + if is_higher_than( [3 1 0 1] ) then // axes_reverse + axes_reverse = toggle(mget(mget(1,characterFormat,fd),characterFormat,fd)) ; + end + + set(a,"axes_visible", axes_visible) + set(a,"axes_reverse", axes_reverse) + set(a,"grid" , mget(mget(1,characterFormat,fd),"il",fd)) //grid + if (is_higher_than([5 0 3 0])) then + set(a,"grid_position",ascii(mget(mget(1,characterFormat,fd),characterFormat,fd))); // grid_position + else + set(a,"grid_position","background"); // grid_position + end + set(a,"x_location" , ascii(mget(mget(1,characterFormat,fd),characterFormat,fd))) // x_location + set(a,"y_location" , ascii(mget(mget(1,characterFormat,fd),characterFormat,fd))) // y_location + + view = ascii(mget(2,characterFormat,fd)); // view + + // title + set(titl,"visible" , toggle(mget(1,characterFormat,fd))) // title.visible + if is_higher_than( [4 1 2 0] ) then + set(titl, "text", load_text_matrix( fd ) ) ; + else + set(titl,"text" , ascii(mget(mget(1,characterFormat,fd),characterFormat,fd))) // title.text + end + if is_higher_than([4 1 2 0]) then + set(titl,"font_foreground", mget(1,"il",fd)); // title.font_foreground + set(titl,"fractional_font", toggle(mget(1,characterFormat,fd))); //title.fractional_font + end + set(titl,"foreground", mget(1,"il",fd)); // title.foreground + if is_higher_than([3 1 0 0]) then + set(titl,"background" , mget(1,"il",fd)); // title.background + set(titl,"fill_mode" , toggle(mget(1,characterFormat,fd))); //title.fill_mode + end + + set(titl,"font_style" , mget(1,characterFormat,fd)); // title.font_style + set(titl,"font_size" , mget(1,characterFormat,fd)); // title.font_size + + if is_higher_than([3 1 0 0]) then + auto_rotation = toggle(mget(1,characterFormat,fd)) ; // title.auto_rotation + set(titl,"font_angle" , mget(1,"dl",fd)); // title.font_angle + auto_position = toggle(mget(1,characterFormat,fd)) ; // title.auto_position + set(titl,"position" , mget(2,"dl",fd)); // title.position + set( titl, "auto_rotation", auto_rotation ) ; + set( titl, "auto_position", auto_position ) ; + end + + // x_label + set(x_label,"visible" , toggle(mget(1,characterFormat,fd))) // x_label.visible + if is_higher_than( [4 1 2 0] ) then + set(x_label, "text", load_text_matrix( fd ) ) ; + else + set(x_label,"text" , ascii(mget(mget(1,characterFormat,fd),characterFormat,fd))) // title.text + end + if is_higher_than([4 1 2 0]) then + set(x_label,"font_foreground", mget(1,"il",fd)); // x_label.font_foreground + set(x_label,"fractional_font", toggle(mget(1,characterFormat,fd))); //x_label.fractional_font + end + set(x_label,"foreground", mget(1,"il",fd)); // x_label.foreground + if is_higher_than([3 0 0 0]) then + set(x_label,"background" , mget(1,"il",fd)); // x_label.background + set(x_label,"fill_mode" , toggle(mget(1,characterFormat,fd))); // x_label.fill_mode + end + set(x_label,"font_style" , mget(1,characterFormat,fd)); // x_label.font_style + set(x_label,"font_size" , mget(1,characterFormat,fd)); // x_label.font_size + + if is_higher_than([3 0 0 0]) then + auto_rotation = toggle(mget(1,characterFormat,fd)) ; // x_label.auto_rotation + set(x_label,"font_angle" , mget(1,"dl",fd)); // x_label.font_angle + auto_position = toggle(mget(1,characterFormat,fd)) ; // x_label.auto_position + set( x_label,"position" , mget(2,"dl",fd)); // x_label.position + set( x_label, "auto_rotation", auto_rotation ) ; + set( x_label, "auto_position", auto_position ) ; + end + + // y_label + set(y_label,"visible" , toggle(mget(1,characterFormat,fd))) + if is_higher_than( [4 1 2 0] ) then + set(y_label, "text", load_text_matrix( fd ) ) ; + else + set(y_label,"text" , ascii(mget(mget(1,characterFormat,fd),characterFormat,fd))) // title.text + end + if is_higher_than([4 1 2 0]) then + set(y_label,"font_foreground", mget(1,"il",fd)); // y_label.font_foreground + set(y_label,"fractional_font", toggle(mget(1,characterFormat,fd))); //y_label.fractional_font + end + set(y_label,"foreground" , mget(1,"il",fd)); + if is_higher_than([3 0 0 0]) then + set(y_label,"background" , mget(1,"il",fd)); + set(y_label,"fill_mode" , toggle(mget(1,characterFormat,fd))); + end + set(y_label,"font_style" , mget(1,characterFormat,fd)); + set(y_label,"font_size" , mget(1,characterFormat,fd)); + + if is_higher_than([3 0 0 0]) then + auto_rotation = toggle(mget(1,characterFormat,fd)) ; // y_label.auto_rotation + set(y_label,"font_angle" , mget(1,"dl",fd)); // y_label.font_angle + auto_position = toggle(mget(1,characterFormat,fd)) ; // y_label.auto_position + set( y_label,"position" , mget(2,"dl",fd)); // y_label.position + set( y_label, "auto_rotation", auto_rotation ) ; + set( y_label, "auto_position", auto_position ) ; + end + + if view=="3d" then + // z_label + z_label=a.z_label + set(z_label,"visible" , toggle(mget(1,characterFormat,fd))) + if is_higher_than( [4 1 2 0] ) then + set(z_label, "text", load_text_matrix( fd ) ) ; + else + set(z_label,"text" , ascii(mget(mget(1,characterFormat,fd),characterFormat,fd))) // title.text + end + if is_higher_than([4 1 2 0]) then + set(z_label,"font_foreground", mget(1,"il",fd)); // z_label.font_foreground + set(z_label,"fractional_font", toggle(mget(1,characterFormat,fd))); //z_label.fractional_font + end + set(z_label,"foreground" , mget(1,"il",fd)); + if is_higher_than([3 0 0 0]) then + set(z_label,"background" , mget(1,"il",fd)); + set(z_label,"fill_mode" , toggle(mget(1,characterFormat,fd))); + end + set(z_label,"font_style" , mget(1,characterFormat,fd)); + set(z_label,"font_size" , mget(1,characterFormat,fd)); + + if is_higher_than([3 0 0 0]) then + auto_rotation = toggle(mget(1,characterFormat,fd)) ; // z_label.auto_rotation + set(z_label,"font_angle" , mget(1,"dl",fd)); // z_label.font_angle + auto_position = toggle(mget(1,characterFormat,fd)) ; // z_label.auto_position + set( z_label,"position" , mget(2,"dl",fd)); // z_label.position + set( z_label, "auto_rotation", auto_rotation ) ; + set( z_label, "auto_position", auto_position ) ; + end + end + + + if is_higher_than([3 0 0 0]) then + auto_ticks=toggle(mget(mget(1,characterFormat,fd),characterFormat,fd)); // auto_ticks + + ticks=["ticks","locations","labels"] + sz=mget(1,"sl",fd) // x_ticks.locations + if sz>0 then + x_ticks_locations=mget(sz,"dl",fd)' + lz=mget(sz,characterFormat,fd) // x_ticks.label + x_ticks_labels=[];for ks=1:sz,x_ticks_labels(ks)=ascii(mget(lz(ks),characterFormat,fd));end + set(a,"x_ticks",tlist(ticks,x_ticks_locations,x_ticks_labels)) + end + + sz=mget(1,"sl",fd) // y_ticks.locations + if sz>0 then + y_ticks_locations=mget(sz,"dl",fd)' + lz=mget(sz,characterFormat,fd) // y_ticks.label + y_ticks_labels=[];for ks=1:sz,y_ticks_labels(ks)=ascii(mget(lz(ks),characterFormat,fd));end + set(a,"y_ticks",tlist(ticks,y_ticks_locations,y_ticks_labels)) + end + + sz=mget(1,"sl",fd) // z_ticks.locations + if sz>0 then + z_ticks_locations=mget(sz,"dl",fd)' + lz=mget(sz,characterFormat,fd) // z_ticks.labels + z_ticks_labels=[];for ks=1:sz,z_ticks_labels(ks)=ascii(mget(lz(ks),characterFormat,fd));end + set(a,"z_ticks",tlist(ticks,z_ticks_locations,z_ticks_labels)) + end + set(a,"auto_ticks" , auto_ticks) + end + if is_higher_than([4 1 2 0]) then + // migth be now 'off','hidden_axis','back_half' or 'on' + boxtype = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) ; + set( a, "box", boxtype ) // box + set(a,"filled", toggle(mget(1,characterFormat,fd) )); // filled + else + set(a, "box", toggle(mget(1,characterFormat,fd) ) ) // box + end + + set(a,"sub_tics" , mget(mget(1,characterFormat,fd),characterFormat,fd)) // sub_tics + if ~(is_higher_than([3 1 0 1]) ) then + mget(1,"il",fd); // tics_color is removed F.Leray 15.03.05 + end + set(a,"font_style" , mget(1,characterFormat,fd)); // font_style + set(a,"font_size" , mget(1,characterFormat,fd)); // font_size + set(a,"font_color" , mget(1,"il",fd)); // font_color + if is_higher_than([4 1 2 0]) then + set(a,"fractional_font", toggle(mget(1,characterFormat,fd))); // fractional_font + end + set(a,"isoview" , toggle(mget(1,characterFormat,fd))) // isoview + + cube_scaling = toggle(mget(1,characterFormat,fd)) // cube_scaling + rotation_angles = mget(2,"dl",fd); // rotation_angles + + if a.view=="2d" then + set(a,"view" , view); + end + if a.view=="3d" then + set(a,"cube_scaling" , cube_scaling) + if view=="3d" then + set(a,"rotation_angles" , rotation_angles) + end + end + + if is_higher_than([3 0 0 0]) then // log_flags + log_flags= ascii(mget(3,characterFormat,fd)); + else + log_flags= ascii(mget(2,characterFormat,fd)); + end + + // tight_limits + if is_higher_than([5 5 0 0]) then + tight_limits=toggle(mget(mget(1,characterFormat,fd),characterFormat,fd)); + else + tight_limits=toggle(mget(1,characterFormat,fd)); + end + set(a,"tight_limits",tight_limits); + data_bounds = matrix(mget(mget(1,characterFormat,fd),"dl",fd),2,-1) // data_bounds + + + if view=="2d"& a.view=="3d" then + data_bounds(2,3)=0; + end + if xload_mode + // check if a had at least a child previously + // if not the axes is considered unused + // and we don't merge the data_bounds. + if a.children <> [] then + old_bounds=a.data_bounds; + for k=1:size(old_bounds,2) + data_bounds(1,k)=min(data_bounds(1,k),old_bounds(1,k)); + data_bounds(2,k)=max(data_bounds(2,k),old_bounds(2,k)); + end + end + end + if is_higher_than([3 0 0 0]) then + zoom_box_size = mget(1,characterFormat,fd); + if zoom_box_size<>0 then + set(a,"zoom_box" , mget(zoom_box_size,"dl",fd)) // zoom_box + end + end + if is_higher_than([3 1 0 1]) then + set(a,"margins" , mget(4,"dl",fd)) // margins + end + + set(a,"axes_bounds" , mget(4,"dl",fd)) // axes_bounds + set(a,"auto_clear" , toggle(mget(1,characterFormat,fd))) // auto_clear + set(a,"auto_scale" , toggle(mget(1,characterFormat,fd))) // auto_scale + + if is_higher_than([4 1 2 0] ) then // 4 0 0 0 and after + set(a,"hidden_axis_color", mget(1,"il",fd)) ; // hidden_axis_color + set(a, "arc_drawing_method", ascii(mget(mget(1,characterFormat,fd),characterFormat,fd))); // arc_drawing_method + else + set(a, "arc_drawing_method", "nurbs"); // default value, real circle + end + + set(a,"hiddencolor" , mget(1,"il",fd)), // hidden_color + set(a,"line_mode" , toggle(mget(1,characterFormat,fd))), // line_mode + line_style = mget(1,characterFormat,fd); + if line_style==0 then // 0 and 1 are equivalents and 0 is obsolete since Scilab 5.4.0 + line_style=1; + end + set(a,"line_style" , line_style) // line_style + set(a,"thickness" , mget(1,"sl",fd)), // thickness + set(a,"mark_mode" , toggle(mget(1,characterFormat,fd))), //mark_mode + set(a,"mark_style" , mget(1,characterFormat,fd)) // mark_style + set(a,"mark_size" , mget(1,characterFormat,fd)) // mark_size + if is_higher_than([3 0 0 0]) then + + if ascii(mget(1,characterFormat,fd))=="t" then // mark_size_unit + msu="tabulated" ; + else + msu="point"; + end + + set(a,"mark_size_unit" , msu) + set(a,"mark_foreground" , mget(1,"il",fd)) ; // mark_foreground + set(a,"mark_background" , mget(1,"il",fd)) ; // mark_background + else + set(a,"mark_size_unit" , "tabulated") + end + set(a,"foreground" , mget(1,"il",fd)), // foreground + set(a,"background" , mget(1,"il",fd)), // background + clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state + if clip_state=="on" then // clip_box + set(a,"clip_box",mget(4,"dl",fd)) ; + end + set(a,"clip_state" ,clip_state); + + // children + nbChildren = mget(1,"il",fd) ; + for k = 1 : nbChildren + load_graphichandle(fd) ; + end + //next lines because tools used to rebuild children change the + //data_bounds an axes_visible properties + set(a,"data_bounds" , data_bounds) ; + set(a,"log_flags" , log_flags); + + set(a,"axes_visible" , axes_visible) ; + if is_higher_than([4 1 2 0] ) then + set(a, "box", boxtype ) ; + end + + h=a; + load_user_data(fd) ; // user_data + global %LEG + + if %LEG<>[] then + //get handles from paths + links=get_links_from_path(a,%LEG.paths) + if links<>[] then + L=captions(links,%LEG.text) + L.visible = %LEG.visible + L.font_style = %LEG.font_style + L.font_size = %LEG.font_size + L.font_color = %LEG.font_color + L.fractional_font = %LEG.fractional_font + L.mark_mode = "off"; + L.legend_location = %LEG.legend_location + L.position = %LEG.position + L.line_mode = %LEG.line_mode + L.thickness = %LEG.thickness + L.foreground = %LEG.foreground + L.fill_mode = %LEG.fill_mode + L.background = %LEG.background + L.clip_state = %LEG.clip_state + if %LEG.clip_state=="on" then + L.clip_box = %LEG.clip_box + end + L.user_data = %LEG.user_data + else + warning(msprintf(_("%s: Legend does not fit with the current context. Skipped\n"),"load")); + end + end + clearglobal %LEG + + case "Polyline" + + visible=toggle(mget(1,characterFormat,fd)) // visible + sz=mget(2,"il",fd); // data + data=matrix(mget(prod(sz),"dl",fd),sz(1),-1); + if is_higher_than([3 1 0 0]) then + closed = toggle(mget(1,characterFormat,fd)) // closed + end + line_mode = toggle(mget(1,characterFormat,fd)) // line_mode + if is_higher_than([3 1 0 0]) then + fill_mode = toggle(mget(1,characterFormat,fd)) // fill_mode + end + line_style = mget(1,characterFormat,fd); // line_style + if line_style==0 then // 0 and 1 are equivalents and 0 is obsolete since Scilab 5.4.0 + line_style=1; + end + thickness = mget(1,"sl",fd); // thickness + if is_higher_than([3 1 0 1]) then + arrow_size_factor = mget(1,"sl",fd); // arrow_size_factor + end + polyline_style = mget(1,characterFormat,fd); // polyline_style + + if is_higher_than([3 1 0 1] ) then + size_interp_color = mget(1,"sl",fd) ; // interp_color_vector + interp_color_vector = mget( size_interp_color, "dl", fd ) ; + interp_color_mode = toggle( mget( 1, characterFormat, fd ) ) ; // interp_color_mode + end + + mark_mode = toggle(mget(1,characterFormat,fd)) // mark_mode + mark_style = mget(1,characterFormat,fd); // mark_style + mark_size = mget(1,characterFormat,fd); // mark_size + + msu="tabulated" + if is_higher_than([3 0 0 0]) then + if ascii(mget(1,characterFormat,fd))=="t" then // mark_size_unit + msu="tabulated" ; + else + msu="point"; + end + end + + foreground = mget(1,"il",fd); // foreground + + if is_higher_than([3 1 0 0]) then + background = mget(1,"il",fd); // background + end + + if is_higher_than([3 0 0 0]) then + mark_foreground=mget(1,"il",fd) // mark_foreground + mark_background=mget(1,"il",fd) // mark_background + end + + if is_higher_than([5 4 0 1]) then + mark_offset=mget(1,"il",fd) // mark_offset + mark_stride=mget(1,"il",fd) // mark_stride + end + + if is_higher_than([3 1 0 0]) then + sz_x_shift=mget(1,"sl",fd) // x_shift + x_shift=mget(sz_x_shift,"dl",fd)' + + sz_y_shift=mget(1,"sl",fd) // y_shift + y_shift=mget(sz_y_shift,"dl",fd)' + + sz_z_shift=mget(1,"sl",fd) // z_shift + z_shift=mget(sz_z_shift,"dl",fd)' + end + + if is_higher_than([3 1 0 1]) then + bar_width = mget( 1, "dl", fd ) ; // bar_width + end + + clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state + + if clip_state=="on" then + clip_box = mget(4,"dl",fd) ; // clip_box + else + clip_box = [] ; + end + // draw the polyline and set properties + xpoly(data(:,1),data(:,2)) + //plot2d( data(:,1),data(:,2)); + h=get("hdl") + set(h,"data",data) + set(h,"visible",visible) + set(h,"line_mode",line_mode), + set(h,"line_style",line_style) + set(h,"thickness",thickness) + set(h,"arrow_size_factor",arrow_size_factor); + set(h,"polyline_style",max(1,polyline_style)), + set(h,"mark_style",mark_style), + set(h,"mark_size",mark_size), + set(h,"mark_mode",mark_mode), + set(h,"foreground",foreground), + if is_higher_than([3 0 0 0]) then + set(h,"mark_size_unit",msu) + set(h,"mark_foreground",mark_foreground), + set(h,"mark_background",mark_background) + end + if is_higher_than([5 5 0 1]) then + set(h,"mark_offset",mark_offset) + set(h,"mark_stride",mark_stride) + end + if is_higher_than([3 1 0 0]) then + set(h,"background",background) + set(h,"fill_mode",fill_mode) + set(h,"closed",closed); + set(h,"x_shift",x_shift); + set(h,"y_shift",y_shift); + set(h,"z_shift",z_shift); + end + + if is_higher_than([3 1 0 1]) then + if interp_color_mode == "on" & interp_color_vector~=[] then + set(h,"interp_color_vector",interp_color_vector); + set(h,"interp_color_mode","on"); + else + if interp_color_vector~=[] + h.interp_color_vector = interp_color_vector + end + h.interp_color_mode = interp_color_mode + end + set(h,"bar_width",bar_width); + end + + if clip_state =="" then clip_state="clipgrf",end + if clip_state=="on" then set(h,"clip_box",clip_box),end + set(h,"clip_state",clip_state); + + load_user_data(fd) // user_data + + case "Datatip" + if is_higher_than([5 4 0 1]) then + visible=toggle(mget(1,characterFormat,fd)) // visible + sz = mget(2,characterFormat,fd) + tip_data = matrix(mget(prod(sz),"dl",fd),sz(1),-1) // data + tip_box_mode = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)); // box_mode + tip_label_mode = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)); // label_mode + tip_orientation = mget(1,characterFormat,fd); // orientation + tip_3component = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)); // z_component + tip_auto_orientation = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)); // auto_orientation + tip_interp_mode = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)); // interp_mode + tip_disp_function = load_text_matrix(fd); // display_function + mark_mode = toggle(mget(1,characterFormat,fd)) // mark_mode + mark_style = mget(1,characterFormat,fd); // mark_style + if ascii(mget(1,characterFormat,fd))=="t" then // mark_size_unit + msu="tabulated" + else + msu="point"; + end + mark_size = mget(1,characterFormat,fd); // mark_size + mark_foreground=mget(1,"il",fd) // mark_foreground + mark_background=mget(1,"il",fd) // mark_background + tag = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) ; // tag + + h=get("hdl"); + set(h, "font_foreground", mget(1, "il", fd)); // font_foreground + set(h,"foreground", mget(1,"il",fd)); // foreground + set(h, "background", mget(1, "il", fd)); // background + set(h,"mark_mode",mark_mode); // mark_mode + set(h,"mark_style",mark_style); // mark_style + set(h,"mark_size_unit",msu) // mark_size_unit + set(h,"mark_size",mark_size) // mark_size + set(h,"mark_foreground",mark_foreground) // mark_foreground + set(h,"mark_background",mark_background) // mark_background + + load_user_data(fd) // user_data + end + + case "Plot3d" then + visible=toggle(mget(1,characterFormat,fd)) // visible + surface_mode = toggle(mget(1,characterFormat,fd)) // surface_mode + foreground = mget(1,"il",fd); // foreground + thickness = mget(1,"sl",fd); // thickness + mark_mode = toggle(mget(1,characterFormat,fd)) // mark_mode + mark_style = mget(1,characterFormat,fd); // mark_style + mark_size = mget(1,characterFormat,fd); // mark_size + + if is_higher_than([3 0 0 0]) then + if ascii(mget(1,characterFormat,fd))=="t" then // mark_size_unit + msu="tabulated" ; + else + msu="point"; + end + mark_foreground=mget(1,"il",fd) // mark_foreground + mark_background=mget(1,"il",fd) // mark_background + else + msu="tabulated" + end + + if is_higher_than([5 1 1 0]) then + color_mode = mget(1,"il",fd); // color_mode + color_flag = mget(1,"il",fd); // color_flag + else + color_mode = mget(1,characterFormat,fd); + color_flag = mget(1,characterFormat,fd); + end + + sz=mget(2,"il",fd); // data.x + x=matrix(mget(prod(sz),"dl",fd),sz(1),-1); + sz=mget(2,"il",fd); // data.y + y=matrix(mget(prod(sz),"dl",fd),sz(1),-1); + sz=mget(2,"il",fd); // data.z + z=matrix(mget(prod(sz),"dl",fd),sz(1),-1); + + if or(color_flag==[2,5]) then + sz=mget(2,"il",fd); // data.color + clr=matrix(mget(prod(sz),"il",fd),sz(1),-1); + end + hiddencolor = mget(1,"il",fd); // hidden_color + + // plot3d modify the given rotation angles + // trick to force keeping the good rotation angles F.Leray 18.02.05 + // same issue with axes properties... B.Jofret 21.04.09 + a=gca(); + rotation_angles = a.rotation_angles; + axes_visible = a.axes_visible; + box = a.box; + margins = a.margins; + x_label_visible = a.x_label.visible; + y_label_visible = a.y_label.visible; + z_label_visible = a.z_label.visible; + x_label_text = a.x_label.text; + y_label_text = a.y_label.text; + z_label_text = a.z_label.text; + axes_isoview = a.isoview; + + + if or(color_flag==[2 5]) then + plot3d1(x,y,list(z,clr)) + else + plot3d(x,y,z) + end + + // Restore this properties after plot3d. + a.rotation_angles = rotation_angles; + a.axes_visible = axes_visible; + a.box = box; + a.margins = margins; + a.x_label.visible = x_label_visible; + a.y_label.visible = y_label_visible; + a.z_label.visible = z_label_visible; + a.x_label.text = x_label_text; + a.y_label.text = y_label_text; + a.z_label.text = z_label_text; + a.isoview = axes_isoview; + + + h=gce(); + set(h,"visible",visible) + set(h,"surface_mode",surface_mode) + set(h,"thickness",thickness) + set(h,"foreground",foreground), + set(h,"color_mode",color_mode), + set(h,"mark_style",mark_style), + set(h,"mark_size",mark_size), + if is_higher_than([3 0 0 0]) then + set(h,"mark_size_unit",msu), + set(h,"mark_foreground",mark_foreground), + set(h,"mark_background",mark_background) + end + set(h,"mark_mode",mark_mode) + set(h,"color_flag",color_flag), + set(h,"hiddencolor",hiddencolor), + + if is_higher_than([4 1 2 0]) + clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state + if clip_state=="on" then + set(h,"clip_box", mget(4,"dl",fd)) // clip_box + end + set(h,"clip_state",clip_state); + end + + load_user_data(fd) + + case "Fac3d" then + + visible=toggle(mget(1,characterFormat,fd)) // visible + surface_mode = toggle(mget(1,characterFormat,fd)) // surface_mode + foreground = mget(1,"il",fd); // foreground + thickness = mget(1,"sl",fd); // thickness + mark_mode = toggle(mget(1,characterFormat,fd)) // mark_mode + mark_style = mget(1,characterFormat,fd); // mark_style + mark_size = mget(1,characterFormat,fd); // mark_size + if is_higher_than([3 0 0 0]) then + if ascii(mget(1,characterFormat,fd))=="t" then // mark_size_unit + msu="tabulated"; + else + msu="point"; + end + mark_foreground=mget(1,"il",fd) ; // mark_foreground + mark_background=mget(1,"il",fd) ; // mark_background + end + if is_higher_than([5 1 1 0]) then + color_mode = mget(1,"il",fd); // color_mode + color_flag = mget(1,"il",fd); // color_flag + else + color_mode = mget(1,characterFormat,fd); + color_flag = mget(1,characterFormat,fd); + end + + sz=mget(2,"il",fd); // data.x + x=matrix(mget(prod(sz),"dl",fd),sz(1),-1); + sz=mget(2,"il",fd); // data.y + y=matrix(mget(prod(sz),"dl",fd),sz(1),-1); + sz=mget(2,"il",fd); // data.z + z=matrix(mget(prod(sz),"dl",fd),sz(1),-1); + + if is_higher_than([3 1 0 1]) & color_flag >= 2 then + sz=mget(2,"il",fd); // data.z + clr=matrix(mget(prod(sz),"il",fd),sz(1),-1); + + if ascii(mget(1,characterFormat,fd)) == "s" then // cdata_mapping + cdata_mapping = "scaled" ; + else + cdata_mapping = "direct" ; + end + + elseif or(color_flag==[2 5]) then + // compatibility with old version + sz=mget(2,"il",fd); // data.z + clr=matrix(mget(prod(sz),"il",fd),sz(1),-1); + end + hiddencolor = mget(1,"il",fd); // hiddencolor + + // plot3d modify the given rotation angles + // trick to force keeping the good rotation angles F.Leray 18.02.05 + // same issue with axes properties... B.Jofret 21.04.09 + // and labels text and isoview + a=gca(); + rotation_angles = a.rotation_angles; + axes_visible = a.axes_visible; + box = a.box; + margins = a.margins; + x_label_visible = a.x_label.visible; + y_label_visible = a.y_label.visible; + z_label_visible = a.z_label.visible; + x_label_text = a.x_label.text; + y_label_text = a.y_label.text; + z_label_text = a.z_label.text; + axes_isoview = a.isoview; + + if is_higher_than([3 1 0 1]) & color_flag >= 2 then + plot3d1(x,y,list(z,clr)) + elseif or(color_flag==[2 5]) then + plot3d1(x,y,list(z,clr)) + else + plot3d(x,y,z) + end + + // Restore this properties after plot3d. + a.rotation_angles = rotation_angles; + a.axes_visible = axes_visible; + a.box = box; + a.margins = margins; + a.x_label.visible = x_label_visible; + a.y_label.visible = y_label_visible; + a.z_label.visible = z_label_visible; + a.x_label.text = x_label_text; + a.y_label.text = y_label_text; + a.z_label.text = z_label_text; + a.isoview = axes_isoview; + + h=gce(); + set(h,"visible",visible) + set(h,"surface_mode",surface_mode) + set(h,"thickness",thickness) + set(h,"foreground",foreground), + set(h,"color_mode",color_mode), + set(h,"color_flag",color_flag), + set(h,"hiddencolor",hiddencolor), + set(h,"mark_style",mark_style), + set(h,"mark_size",mark_size), + set(h,"mark_mode",mark_mode) + if is_higher_than([3 0 0 0]) then + set(h,"mark_size_unit",msu), + set(h,"mark_foreground",mark_foreground), + set(h,"mark_background",mark_background) + end + + if is_higher_than([3 1 0 1]) & color_flag >= 2 then + set(h,"cdata_mapping",cdata_mapping); + end + + if is_higher_than([4 1 2 0]) + clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state + if clip_state=="on" then + set(h,"clip_box", mget(4,"dl",fd)) // clip_box + end + set(h,"clip_state",clip_state); + end + + load_user_data(fd) ; // user_data + + case "Compound" + // children + n=mget(1,"il",fd) + H=[] + for k=1:n + htmp = load_graphichandle(fd) + H=[htmp H] + end + h=glue(H) + if is_higher_than([3 1 0 1]) then // visible + h.visible = toggle(mget(1,characterFormat,fd)) ; + end + + load_user_data(fd) // user_data + + + case "Agregation" // for compatibility with old save + + // children + n=mget(1,"il",fd) + H=[] + for k=1:n + htmp = load_graphichandle(fd) + H=[htmp H] + end + h=glue(H) + + if is_higher_than([3 1 0 1]) then // visible + h.visible = toggle(mget(1,characterFormat,fd)) ; + end + + load_user_data(fd) // user_data + + case "Rectangle" + visible = toggle(mget(1,characterFormat,fd)) // visible + thickness = mget(1,"sl",fd); // thickness + mark_mode = toggle(mget(1,characterFormat,fd)) // mark_mode + mark_style = mget(1,characterFormat,fd); // mark_style + mark_size = mget(1,characterFormat,fd); // mark_size + if is_higher_than([3 0 0 0]) then + if ascii(mget(1,characterFormat,fd))=="t" then // mark_size_unit + msu="tabulated" ; + else + msu="point"; + end + mark_foreground=mget(1,"il",fd) // mark_foreground + mark_background=mget(1,"il",fd) // mark_background + else + msu="tabulated" + end + + line_mode = toggle(mget(1,characterFormat,fd)) ; // line_mode + line_style = mget(1,characterFormat,fd); // line_style + if line_style==0 then // 0 and 1 are equivalents and 0 is obsolete since Scilab 5.4.0 + line_style=1; + end + fill_mode = toggle(mget(1,characterFormat,fd)) ; // fill_mode + foreground = mget(1,"il",fd); // foreground + + if is_higher_than([3 1 0 1]) then + background = mget(1,"il",fd); // background + end + if (is_higher_than([5 0 3 0])) then + // data size might be 4 or 5 + data = mget(mget(1,"il",fd),"dl",fd); // data + else + parentAxes = gca(); + if (parentAxes.view == "2d") then + data = mget(4,"dl",fd); + else + data = mget(5,"dl",fd); + end + end + clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) ; // clip_stata + if clip_state=="on" then + clip_box = mget(4,"dl",fd) // clip_box + else + clip_box=[] + end + + // draw the rectangle + xrect(0,1,1,1); // create the rectangle with dummy values + h=get("hdl") + set(h,"data",data); + set(h,"visible",visible) + set(h,"thickness",thickness) + set(h,"mark_style",mark_style), + set(h,"mark_size",mark_size), + set(h,"mark_size_unit",msu), + if is_higher_than([3 0 0 0]) then + set(h,"mark_foreground",mark_foreground) ; + set(h,"mark_background",mark_background) ; + end + set(h,"mark_mode",mark_mode) + set(h,"line_style",line_style) + set(h,"fill_mode",fill_mode) + set(h,"foreground",foreground) ; + if is_higher_than([3 1 0 1]) then + set(h,"background",background) ; + end + set(h,"line_mode",line_mode) + if clip_state=="on" then set(h,"clip_box",clip_box),end + set(h,"clip_state",clip_state); + + load_user_data(fd) ; // user_data + + case "Arc" + visible = toggle(mget(1,characterFormat,fd)) // visible + thickness = mget(1,"sl",fd); // thickness + line_style = mget(1,characterFormat,fd); // line_style + if line_style==0 then // 0 and 1 are equivalents and 0 is obsolete since Scilab 5.4.0 + line_style=1; + end + + if is_higher_than([3 1 0 1]) + line_mode = toggle(mget(1,characterFormat,fd)) ; // line_mode + end + + fill_mode = toggle(mget(1,characterFormat,fd)) // fill_mode + foreground = mget(1,"il",fd); // foreground + + if is_higher_than([3 1 0 1]) then + background = mget(1,"il",fd) ; // background + end + + if (is_higher_than([5 0 3 0])) then + // data size might be 6 or 7 + data = mget(mget(1,"il",fd),"dl",fd); // data + else + parentAxes = gca(); + if (parentAxes.view == "2d") then + data = mget(6,"dl",fd); + else + data = mget(7,"dl",fd); + end + end + + if is_higher_than([4 1 2 0]) then + drawing_method = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)); // drawing_method + else + drawing_method = "nurbs"; + end + + clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state + if clip_state=="on" then + clip_box = mget(4,"dl",fd) // clip_box + else + clip_box=[] + end + xarc(0,1,1,1,0,360); // create the arc dummy values + h=get("hdl") + if ~is_higher_than([4 1 2 0]) then + // angle wass stored by 64th of degree + data($) = data($) / 64; + data($-1) = data($-1) / 64; + end + set(h,"data",data); + set(h,"visible",visible) + set(h,"thickness",thickness) + set(h,"line_style",line_style) + set(h,"line_mode",line_mode); + set(h,"fill_mode",fill_mode) + set(h,"foreground",foreground) ; + set(h,"background",background) ; + set(h,"arc_drawing_method", drawing_method) ; + if clip_state=="on" then set(h,"clip_box",clip_box),end + set(h,"clip_state",clip_state); + + load_user_data(fd) // user_data + + case "Champ" + visible = toggle(mget(1,characterFormat,fd)) // visible + sz=mget(2,"il",fd); // data.x + x=matrix(mget(prod(sz),"dl",fd),sz(1),-1); + sz=mget(2,"il",fd); // data.y + y=matrix(mget(prod(sz),"dl",fd),sz(1),-1); + sz=mget(2,"il",fd); // data.fx + fx=matrix(mget(prod(sz),"dl",fd),sz(1),-1); + sz=mget(2,"il",fd); // data.fy + fy=matrix(mget(prod(sz),"dl",fd),sz(1),-1); + + // draw the champ + champ(x,y,fx,fy); + h=gce(); + + set(h,"visible",visible); + line_style = mget(1,characterFormat,fd); + if line_style==0 then // 0 and 1 are equivalents and 0 is obsolete since Scilab 5.4.0 + line_style=1; + end + set(h,"line_style",line_style); // line_style + set(h,"thickness",mget(1,"sl",fd)) // thickness + set(h,"colored",toggle(mget(1,characterFormat,fd))) // colored + set(h,"arrow_size",mget(1,"dl",fd)) // arrow_size + + clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state + if clip_state=="on" then + set(h,"clip_box", mget(4,"dl",fd)) // clip_box + end + set(h,"clip_state",clip_state); + load_user_data(fd) // user_data + + case "Segs" + visible = toggle(mget(1,characterFormat,fd)) // visible + sz = mget(2,"il",fd) // data + data = matrix(mget(prod(sz),"dl",fd),sz(1),-1) + + // draw the segs + xsegs(data(:,1),data(:,2)) + h=gce() + if size(data,2)==3 then + h.data=data + end + set(h,"visible",visible); + set(h,"line_mode" ,toggle(mget(1,characterFormat,fd))) // line_mode + line_style = mget(1,characterFormat,fd); + if line_style==0 then // 0 and 1 are equivalents and 0 is obsolete since Scilab 5.4.0 + line_style=1; + end + set(h,"line_style",line_style); // line_style + set(h,"thickness",mget(1,"sl",fd)) // thickness + set(h,"arrow_size",mget(1,"dl",fd)) // arrow_size + + n=mget(1,"il",fd) // segs_color + set(h,"segs_color",mget(n,"il",fd)) + // it is needed to set it at the end, ut I don't know why + mark_mode = toggle(mget(1,characterFormat,fd)) ; // mark_mode + set(h,"mark_style" , mget(1,characterFormat,fd)) // mark_style + set(h,"mark_size" , mget(1,characterFormat,fd)) // mark_size + if is_higher_than([3 0 0 0]) then + if ascii(mget(1,characterFormat,fd))=="t" then // mark_size_unit + msu="tabulated" + else + msu="point"; + end + set(h,"mark_size_unit" , msu) ; + set(h,"mark_foreground" , mget(1,"il",fd)) ; // mark_foreground + set(h,"mark_background" , mget(1,"il",fd)) ; // mark_background + else + set(h,"mark_size_unit" , "tabulated") ; // mark_size_unit + end + + set(h,"mark_mode", mark_mode ) ; + + clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state + if clip_state=="on" then + set(h,"clip_box", mget(4,"dl",fd)) // clip_box + end + set(h,"clip_state",clip_state); + load_user_data(fd) // user_data + + case "Grayplot" + visible = toggle(mget(1,characterFormat,fd)) // visible + if is_higher_than([3 0 0 0]) then + sz=mget(2,"il",fd); // data.x + x=matrix(mget(prod(sz),"dl",fd),sz(1),-1); + sz=mget(2,"il",fd); // data.y + y=matrix(mget(prod(sz),"dl",fd),sz(1),-1); + sz=mget(2,"il",fd); // data.z + z=matrix(mget(prod(sz),"dl",fd),sz(1),-1); + else + sz = mget(2,"il",fd) // data + data = matrix(mget(prod(sz),"dl",fd),sz(1),-1) + end + + data_mapping = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // data_mapping + clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state + if clip_state=="on" then + clip_box = mget(4,"dl",fd) // clip_box + else + clip_box=[] + end + + // draw the grayplot + if is_higher_than([3 0 0 0]) then + grayplot(x,y,z) + else + grayplot(data(2:$,1),data(1,2:$),data(2:$,2:$)) + end + + h=get("hdl") + set(h,"visible",visible) + set(h,"data_mapping",data_mapping) + if clip_state=="on" then + set(h,"clip_box", clip_box) + end + set(h,"clip_state",clip_state); + + load_user_data(fd) // user_data + + case "Matplot" + visible = toggle(mget(1,characterFormat,fd)) // visible + sz=mget(2,"il",fd); // data + data=matrix(mget(prod(sz),"dl",fd),sz(1),-1); + // data_mapping = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) + clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state + if clip_state=="on" then + clip_box = mget(4,"dl",fd) // clip_box + else + clip_box=[] + end + + // draw the matplot + Matplot(data); + + h=get("hdl") + set(h,"visible",visible) + // set(h,"data_mapping",data_mapping) + if clip_state=="on" then + set(h,"clip_box", clip_box) + end + set(h,"clip_state",clip_state); + // user_data + load_user_data(fd) + + case "Fec" + visible = toggle(mget(1,characterFormat,fd)) // visible + sz = mget(2,"il",fd) // data + data = matrix(mget(prod(sz),"dl",fd),sz(1),-1) + sz = mget(2,"il",fd) // triangles + triangles = matrix(mget(prod(sz),"dl",fd),sz(1),-1) + z_bounds = mget(2,"dl",fd) // z_bounds + // draw the fec + fec(data(:,1),data(:,2),triangles,data(:,3)) + h=unglue(get("hdl")) + set(h,"visible",visible) + set(h,"z_bounds",z_bounds) + if is_higher_than( [5 0 3 0] ) then + set(h,"color_range",mget(2,"dl",fd)); // color_range + set(h,"outside_colors",mget(2,"dl",fd)); // color_range + set(h,"line_mode" ,toggle(mget(1,characterFormat,fd))) // line_mode + set(h,"foreground", mget(1,"il",fd)); // foreground + end + clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state + if clip_state=="on" then + set(h,"clip_box", mget(4,"dl",fd)) // clip_box + end + set(h,"clip_state",clip_state); + load_user_data(fd) // user_data + + case "Legend" + if is_higher_than( [5 0 0 0] ) then + global %LEG + %LEG=[]; + %LEG.visible = toggle(mget(1,characterFormat,fd)) // visible + %LEG.text = load_text_vector(fd); // text + %LEG.font_style = mget(1,characterFormat,fd); // font_style + %LEG.font_size = mget(1,characterFormat,fd); // font_size + %LEG.font_color = mget(1,"il",fd); // font_size + %LEG.fractional_font = toggle(mget(1,characterFormat,fd)); // fractional_font + nlegends = mget(1,characterFormat,fd); + paths = list() + for kl=1:nlegends + paths($+1) = mget(mget(1,"il",fd),"il",fd); + end + %LEG.paths = paths + %LEG.legend_location = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) + %LEG.position = mget(2,"dl",fd) + %LEG.line_mode = toggle(mget(1,characterFormat,fd)) + %LEG.thickness = mget(1,"sl",fd) + %LEG.foreground = mget(1,"il",fd) + %LEG.fill_mode = toggle(mget(1,characterFormat,fd)) + %LEG.background = mget(1,"il",fd) + + %LEG.clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state + if %LEG.clip_state=="on" then + %LEG.clip_box = mget(4,"dl",fd); // clip_box + end + %_load(fd,"user_data") + %LEG.user_data = user_data; + else + visible = toggle(mget(1,characterFormat,fd)) // visible + line_mode = toggle(mget(1,characterFormat,fd)) // line_mode + mark_mode = toggle(mget(1,characterFormat,fd)) // mark_mode + mark_foreground = mget(1,"il",fd) ; // mark_foreground + mark_background = mget(1,"il",fd) ; // mark_background + + //text=ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // text + + text = load_text_vector(fd); // text + + //create the legend + //get the number of lines of the legend + lineFeedPosition = strindex(text,"@") + nbLines = size( lineFeedPosition ) ; + nbLines = nbLines(2) + 1 + //create as many curves as lines in the text + nullVector = zeros(1,nbLines); + //draw the legend + plot2d(0,nullVector,leg=text) ; + H=unglue(get("hdl")); + h=H(1); + delete(H(2)); + + set(h,"visible",visible) + set(h,"line_mode",line_mode); + set(h,"mark_mode",mark_mode); + set(h,"mark_foreground",mark_foreground) ; + set(h,"mark_background",mark_background) ; + set(h,"foreground", mget(1,"il",fd)); // foreground + + set(h,"font_style", mget(1,characterFormat,fd)); // font_style + set(h,"font_size" , mget(1,characterFormat,fd)); // font_size + if is_higher_than( [4 1 2 0] ) then + set(h,"fractional_font" , toggle(mget(1,characterFormat,fd))); // fractional_font + end + clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state + if clip_state=="on" then + set(h,"clip_box",mget(4,"dl",fd)); // clip_box + end + set(h,"clip_state",clip_state); + end + + case "Text" + visible = toggle(mget(1,characterFormat,fd)) // visible + + if is_higher_than( [4 1 2 0] ) then + text = load_text_matrix( fd ) ; + else + text = load_text_vector(fd) // text + end + sz = mget(2,characterFormat,fd) + data = matrix(mget(prod(sz),"dl",fd),sz(1),-1) // data + text_box = mget(2,"dl",fd) // text_box + text_box_mode = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)); // text_box_mode + + // draw the text + if text_box_mode == "off" then + xstring(data(1),data(2),text) + else + xstringb(data(1),data(2),text,text_box(1),text_box(2)) + end + + h=get("hdl"); + set(h,"data",data); + set(h,"visible",visible) ; + set(h,"text_box_mode",text_box_mode) + set(h,"foreground" , mget(1,"il",fd)); // foreground + set(h,"font_style" , mget(1,characterFormat,fd)); // font_style + + if text_box_mode == "filled" then // font_size + mget(1,characterFormat,fd) ; + else + set(h,"font_size", mget(1,characterFormat,fd)); + end + + set(h,"font_angle" , mget(1,"dl",fd)); // font_angle + + //adding JB Silvy 28/11/05 + // box drawing + if is_higher_than([3 1 0 1]) then + set( h, "box" , toggle( mget( 1, characterFormat, fd ) ) ) ; // box + set( h, "line_mode", toggle( mget( 1, characterFormat, fd ) ) ) ; // line_mode + set( h, "fill_mode", toggle( mget( 1, characterFormat, fd ) ) ) ; // fill_mode + + set( h, "font_foreground", mget( 1, "il", fd ) ) ; // font_foreground + set( h, "background" , mget( 1, "il", fd ) ) ; // background + end + + if is_higher_than( [4 1 2 0] ) then + set( h, "alignment", ascii(mget(mget(1,characterFormat,fd),characterFormat,fd) ) ) ; // alignment + set( h, "fractional_font", toggle( mget( 1, characterFormat, fd ) ) ) ; // fractional_font + end + + clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state + if clip_state=="on" then + clip_box = mget(4,"dl",fd) // clip_box + set(h,"clip_box",clip_box) ; // clip_box + else + clip_box=[] + end + set(h,"clip_state",clip_state); + load_user_data(fd) // user_data + case "Axis" + if is_higher_than([3 1 0 0]) then + + visible = toggle(mget(1,characterFormat,fd)) // visible + n = mget(1,"il",fd) // tics_direction + tics_direction = ascii(mget(n,characterFormat,fd)); + nx = mget(1,"il",fd) // xtics_coord + xtics_coord = mget(nx,"dl",fd)' + ny = mget(1,"il",fd) // ytics_coord + ytics_coord = mget(ny,"dl",fd)' + + if tics_direction == "bottom" then axisdir="d"; + elseif tics_direction == "top" then axisdir="u"; + elseif tics_direction == "left" then axisdir="l"; + elseif tics_direction == "right" then axisdir="r"; + elseif nx>1 then axisdir="u"; + else axisdir="l"; + end + + drawaxis(x=xtics_coord,y=ytics_coord,dir=axisdir); + h=gce() + + h.tics_color = mget(1,"il",fd) // tics_color + h.tics_segment = toggle(mget(1,characterFormat,fd)) // tics_segment + h.tics_style = ascii(mget(1,characterFormat,fd)) // tics_style + h.sub_tics = mget(1,"il",fd) // sub_tics + h.tics_labels = load_text_vector(fd)' // tics_label + labelfontsize = mget(1,"il",fd); + // Bug fix: there was a bug in Scilab <=4.1.2 which used -1 as default value for labels_font_size + // Scilab 5 needs font size to be >= 0 so we change the value to avoid an error message due to a Scilab bug... + if labelfontsize == -1 then + //labelfontsize = 0; + end + h.labels_font_size = labelfontsize // label_font_size + h.labels_font_color= mget(1,"il",fd); // labels_font_color + if is_higher_than([5 4 0 1]) then + h.labels_font_style = mget(1,"il",fd); + end + if is_higher_than( [4 1 2 0] ) then + set( h, "fractional_font", toggle( mget( 1, characterFormat, fd ) ) ) ; // fractional_font + end + // h.tics_style=tics_style // jb Silvy apparently strange + + clip_state = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) // clip_state + if clip_state == "on" then + set(h,"clip_box",clip_box) + end + set(h,"clip_state",clip_state); + load_user_data(fd) // user_data + end + + case "uimenu" + if is_higher_than( [4 1 2 0] ) then + h = uimenu("parent", gcf()); + h.enable = toggle(mget(1,"c",fd)); // Enable + ncolors = mget(1,"il",fd); // Foregroundcolor (size) + h.foregroundcolor = mget(ncolors,"dl",fd); // ForegroundColor (data) + h.label = ascii(mget(mget(1,"c",fd),"c",fd)); // Label + h.visible = toggle(mget(1,"c",fd)); // Visible + if is_higher_than( [5 4 0 0] ) then + h.callback = ascii(mget(mget(1, stringFormat,fd),"c",fd)); // Callback + else + h.callback = ascii(mget(mget(1,"c",fd),"c",fd)); // Callback + end + h.callback_type = mget(1,"il",fd); // Callback Type + h.tag = ascii(mget(mget(1,"c",fd),"c",fd)); // Tag + end + if is_higher_than( [5 1 2 0] ) then // 5.2 and higher + h.checked = toggle(mget(1,"c",fd)); // Checked + end + if is_higher_than( [5 1 1 0] ) then // 5.1.2 and higher + // children + nbChildren = mget(1,"il",fd) ; + for k = 1 : nbChildren + htmp = load_graphichandle(fd) ; + set(htmp, "Parent", h); + end + end + + case "uicontextmenu" + h = uicontextmenu(); + // children + nbChildren = mget(1,"il",fd) ; + for k = 1 : nbChildren + htmp = load_graphichandle(fd) ; + set(htmp, "Parent", h); + end + + case "uicontrol" + if is_higher_than( [4 1 2 0] ) then + uistyle = ascii(mget(mget(1,"c",fd),"c",fd)); // Style + h = uicontrol("parent",gcf(), "style", uistyle); + ncolors = mget(1,"il",fd); // BackgroundColor (size) + h.backgroundcolor = mget(ncolors,"dl",fd); // BackgroundColor (data) + h.enable = toggle(mget(1,"c",fd)); // Enable + h.fontangle = ascii(mget(mget(1,"c",fd),"c",fd)); // FontAngle + h.fontname = ascii(mget(mget(1,"c",fd),"c",fd)); // FontName + fontsize_in_units = mget(1,"dl",fd); // FontSize + h.fontunits = ascii(mget(mget(1,"c",fd),"c",fd)); // FontUnits + h.fontsize = fontsize_in_units; // FontSize written after 'FontUnits' to avoid them to be computed again + h.fontweight = ascii(mget(mget(1,"c",fd),"c",fd)); // FontWeight + ncolors = mget(1,"il",fd); // Foregroundcolor (size) + h.foregroundcolor = mget(ncolors,"dl",fd); // ForegroundColor (data) + h.horizontalalignment = ascii(mget(mget(1,"c",fd),"c",fd)); // HorizontalAlignment + ndata = mget(1,"il",fd); // ListboxTop (size) + h.listboxtop = mget(ndata,"dl",fd); // ListboxTop (data) + h.max = mget(1,"dl",fd); // Max + h.min = mget(1,"dl",fd); // Min + ndata = mget(1,"il",fd); // Position (size) + position_in_units = mget(ndata,"dl",fd); // Position (data) + h.relief = ascii(mget(mget(1,"c",fd),"c",fd)); // Relief + ndata = mget(1,"il",fd); // SliderStep (size) + h.sliderstep = mget(ndata,"dl",fd); // SliderStep (data) + h.string = load_text_matrix(fd) ; // String + if ( is_higher_than([5 2 0 0]) ) then // Added in 5.4.0 version + h.tooltipstring = load_text_matrix(fd) ; // TooltipString + end + h.units = ascii(mget(mget(1,"c",fd),"c",fd)); // Units + h.position = position_in_units; // Position written after 'Units' to avoid them to be computed again + ndata = mget(1,"il",fd); // Value (size) + h.value = mget(ndata,"dl",fd); // Value (data) + h.verticalalignment = ascii(mget(mget(1,"c",fd),"c",fd)); // VerticalAlignment + h.visible = toggle(mget(1,"c",fd)); // Visible + if is_higher_than( [5 4 0 0] ) then + h.callback = ascii(mget(mget(1, stringFormat,fd),"c",fd)); // Callback + else + h.callback = ascii(mget(mget(1,"c",fd),"c",fd)); // Callback + end + h.callback_type = mget(1,"il",fd); // Callback Type + load_user_data(fd); // Userdata + h.tag = ascii(mget(mget(1,"c",fd),"c",fd)); // Tag + end + + else + warning("type " +typ+" unhandled"); + end + +endfunction + +function r=toggle(k) + r=emptystr(k)+"on" + r(k==0)="off" +endfunction + +function load_user_data(fd) + if is_higher_than([3 1 0 0]) then + h; //make a copy of the calling context h here + %_load(fd,"user_data") + if ~isempty(user_data) then + set(h, "user_data", user_data); + end + end +endfunction + +function r=is_higher_than(v) + //check if current version is strictly higher than the given one + r=%f + for k=1:4 + if version(k)>v(k) then r=%t,break,end + if version(k)<v(k) then r=%f,break,end + end +endfunction + +function text=load_text_vector(fd) + T=mget(mget(1,"il",fd),characterFormat,fd) + newline=[find(T==10) size(T,"*")+1]; + text=[] + p=1 + for k=1:size(newline,"*") + text=[text;ascii(T(p:newline(k)-1))]; + p=newline(k)+1 + end +endfunction + +// retrieve a string matrix saved by save_text_matrix +function strMat = load_text_matrix( fd ) + nbRow = mget( 1, "il", fd ) ; + nbCol = mget( 1, "il", fd ) ; + for i = 1:nbRow + for j = 1:nbCol + if is_higher_than([5 4 0 0]) then + strMat(i,j) = ascii(mget(mget(1,stringFormat,fd),characterFormat,fd)) ; + else + strMat(i,j) = ascii(mget(mget(1,characterFormat,fd),characterFormat,fd)) ; + end + end + end +endfunction + +function links=get_links_from_path(ax,paths) + // ax is a handle on an axes entity + // paths a list or row vector which gives the set of paths relative to + // the axes + links=[];ok=%t + for p=paths + e=ax; + p(1)=p(1)-1// the caption does not exists yet + for kp=1:size(p,"*"), + if or(e.type==["Axes","Compound"])&p(kp)<=size(e.children,"*") then + e=e.children(p(kp)), + else + ok=%f + break + end + end + if ~ok then break,end + links=[links,e] + end + if ~ok then links=[],end +endfunction diff --git a/modules/graphics/macros/%h_matrix.bin b/modules/graphics/macros/%h_matrix.bin Binary files differnew file mode 100755 index 000000000..fdf4cef7e --- /dev/null +++ b/modules/graphics/macros/%h_matrix.bin diff --git a/modules/graphics/macros/%h_matrix.sci b/modules/graphics/macros/%h_matrix.sci new file mode 100755 index 000000000..51c1df7c3 --- /dev/null +++ b/modules/graphics/macros/%h_matrix.sci @@ -0,0 +1,11 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function y=%h_matrix(a,varargin) + y=%hm_matrix(a,varargin(:)) +endfunction diff --git a/modules/graphics/macros/%h_p.bin b/modules/graphics/macros/%h_p.bin Binary files differnew file mode 100755 index 000000000..3101a8e9b --- /dev/null +++ b/modules/graphics/macros/%h_p.bin diff --git a/modules/graphics/macros/%h_p.sci b/modules/graphics/macros/%h_p.sci new file mode 100755 index 000000000..90428f846 --- /dev/null +++ b/modules/graphics/macros/%h_p.sci @@ -0,0 +1,1143 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function %h_p(h) + if size(h,"*")>1 then + T=matrix(h.type,size(h)) + t="" + for k=1:size(h,2) + t=t+part(T(:,k),1:max(length(T(:,k)))+1) + end + t1=string(size(h,1))+" by "+string(size(h,2))+" matrix of handles:" + t1=[t1;part("=",ones(1,length(t1)))] + t=[t1;t] + else + t="Handle of type """+h.type+""" with properties:" + t=[t;part("=",ones(1,length(t)))] + + select h.type + + // Polyline + // ===================================================================== + + case "Polyline" + + if size(h.data,"*") > 10 then + d="matrix "+strcat(string(size(h.data)),"x") + else + d=sci2exp(h.data,0) + if length(d)>70 then d="matrix "+strcat(string(size(h.data)),"x"),end + end + + if size(h.x_shift,"*") > 10 then + bxs="matrix "+strcat(string(size(h.x_shift)),"x") + else + bxs=sci2exp(h.x_shift,0) + if length(bxs)>70 then bxs="matrix "+strcat(string(size(h.x_shift)),"x"),end + end + + if size(h.y_shift,"*") > 10 then + bys="matrix "+strcat(string(size(h.y_shift)),"x") + else + bys=sci2exp(h.y_shift,0) + if length(bys)>70 then bys="matrix "+strcat(string(size(h.y_shift)),"x"),end + end + + if size(h.z_shift,"*") > 10 then + bzs="matrix "+strcat(string(size(h.z_shift)),"x") + else + bzs=sci2exp(h.z_shift,0) + if length(bzs)>70 then bzs="matrix "+strcat(string(size(h.z_shift)),"x"),end + end + + u=h.user_data; + t=[t; + "parent: "+h.parent.type + "children: "+fmtchildren(h.children) + "datatips: "+fmtchildren(h.datatips) + "display_function: "++sci2exp(h.display_function) + "display_function_data: "+fmtuser_data(h.display_function_data) + "visible = "+sci2exp(h.visible) + "data = "+d + "closed = "+sci2exp(h.closed) + "line_mode = "+sci2exp(h.line_mode) + "fill_mode = "+sci2exp(h.fill_mode) + "line_style = "+string(h.line_style) + "thickness = "+string(h.thickness) + "arrow_size_factor = "+string(h.arrow_size_factor) + "polyline_style = "+string(h.polyline_style) + "foreground = "+string(h.foreground) + "background = "+string(h.background) + "interp_color_vector = "+sci2exp(h.interp_color_vector) + "interp_color_mode = "+sci2exp(h.interp_color_mode) + "mark_mode = "+sci2exp(h.mark_mode) + "mark_style = "+sci2exp(h.mark_style) + "mark_size_unit = "+sci2exp(h.mark_size_unit) + "mark_size = "+string(h.mark_size) + "mark_foreground = "+string(h.mark_foreground) + "mark_background = "+string(h.mark_background) + "mark_offset = "+string(h.mark_offset) + "mark_stride = "+string(h.mark_stride) + "x_shift = "+bxs + "y_shift = "+bys + "z_shift = "+bzs + "bar_width = "+sci2exp(h.bar_width) + "clip_state = "+sci2exp(h.clip_state) + "clip_box = "+sci2exp(h.clip_box) + "user_data = "+fmtuser_data(u) + "tag = "+h.tag + ] + + // Compound + // ===================================================================== + + case "Compound" + u=h.user_data + t=[t; + "parent: "+h.parent.type + "children: "+fmtchildren(h.children) + "visible = "+sci2exp(h.visible) + "user_data = "+fmtuser_data(u) + "tag = "+h.tag + ] + + // Axes + // ===================================================================== + + case "Axes" + + T=h.x_ticks + if size(T.locations,"*")>9 then + locx="matrix "+strcat(string(size(T.locations)),"x") + labx="matrix "+strcat(string(size(T.labels)),"x") + else + locx=sci2exp(T.locations,0) + labx=sci2exp(T.labels,0) + if length(locx)>70 then locx="matrix "+strcat(string(size(T.locations)),"x"), end + if length(labx)>70 then labx="matrix "+strcat(string(size(T.labels)),"x"), end + end + + T=h.y_ticks + if size(T.locations,"*")>9 then + locy="matrix "+strcat(string(size(T.locations)),"x") + laby="matrix "+strcat(string(size(T.labels)),"x") + else + locy=sci2exp(T.locations,0) + laby=sci2exp(T.labels,0) + if length(locy)>70 then locx="matrix "+strcat(string(size(T.locations)),"x"), end + if length(laby)>70 then labx="matrix "+strcat(string(size(T.labels)),"x"), end + end + + T=h.z_ticks + if size(T.locations,"*")>9 then + locz="matrix "+strcat(string(size(T.locations)),"x") + labz="matrix "+strcat(string(size(T.labels)),"x") + else + locz=sci2exp(T.locations,0) + labz=sci2exp(T.labels,0) + if length(locz)>70 then locx="matrix "+strcat(string(size(T.locations)),"x"), end + if length(labz)>70 then labx="matrix "+strcat(string(size(T.labels)),"x"), end + end + + u=h.user_data + t=[t; + "parent: "+h.parent.type + "children: "+fmtchildren(h.children) + " " + "visible = "+sci2exp(h.visible) + "axes_visible = "+sci2exp(h.axes_visible) + "axes_reverse = "+sci2exp(h.axes_reverse) + "grid = "+sci2exp(h.grid,0) + "grid_position = "+sci2exp(h.grid_position) + "grid_thickness = "+sci2exp(h.grid_thickness,0) + "grid_style = "+sci2exp(h.grid_style,0) + "x_location = "+sci2exp(h.x_location) + "y_location = "+sci2exp(h.y_location) + "title: "+fmtchildren(h.title) + "x_label: "+fmtchildren(h.x_label) + "y_label: "+fmtchildren(h.y_label) + "z_label: "+fmtchildren(h.z_label) + "auto_ticks = "+sci2exp(h.auto_ticks) + "x_ticks.locations = "+locx + "y_ticks.locations = "+locy + "z_ticks.locations = "+locz + "x_ticks.labels = "+labx + "y_ticks.labels = "+laby + "z_ticks.labels = "+labz + "ticks_format = "+sci2exp(h.ticks_format) + "ticks_st = "+sci2exp(h.ticks_st, 0) + "box = "+sci2exp(h.box) + "filled = " + sci2exp(h.filled) + "sub_ticks = "+sci2exp(h.sub_ticks,0) + "font_style = "+string(h.font_style) + "font_size = "+string(h.font_size) + "font_color = "+string(h.font_color) + "fractional_font = " + sci2exp(h.fractional_font) + " " + "isoview = "+sci2exp(h.isoview) + "cube_scaling = "+sci2exp(h.cube_scaling) + "view = "+sci2exp(h.view) + "rotation_angles = "+sci2exp(h.rotation_angles,0) + "log_flags = "+sci2exp(h.log_flags) + "tight_limits = "+sci2exp(h.tight_limits) + "data_bounds = "+sci2exp(h.data_bounds,0) + "zoom_box = "+sci2exp(h.zoom_box,0) + "margins = "+sci2exp(h.margins,0) + "auto_margins = "+sci2exp(h.auto_margins) + "axes_bounds = "+sci2exp(h.axes_bounds,0) + " " + "auto_clear = "+sci2exp(h.auto_clear) + "auto_scale = "+sci2exp(h.auto_scale) + " " + "hidden_axis_color = " + string(h.hidden_axis_color); + "hiddencolor = "+string(h.hiddencolor) + "line_mode = "+sci2exp(h.line_mode) + "line_style = "+string(h.line_style) + "thickness = "+string(h.thickness) + "mark_mode = "+sci2exp(h.mark_mode) + "mark_style = "+sci2exp(h.mark_style,0) + "mark_size_unit = "+sci2exp(h.mark_size_unit) + "mark_size = "+sci2exp(h.mark_size,0) + "mark_foreground = "+string(h.mark_foreground) + "mark_background = "+string(h.mark_background) + "foreground = "+string(h.foreground) + "background = "+string(h.background) + "arc_drawing_method = " + sci2exp(h.arc_drawing_method) + "clip_state = "+sci2exp(h.clip_state) + "clip_box = "+sci2exp(h.clip_box,0) + "user_data = "+fmtuser_data(h.user_data) + "tag = "+h.tag + ] + + // Legend + // ===================================================================== + + case "Legend" + t=[t; + "parent: "+h.parent.type + "children: "+fmtchildren(h.children) + "visible = "+sci2exp(h.visible) + "text = "+sci2exp(h.text) + "font_style = "+string(h.font_style) + "font_size = "+string(h.font_size) + "font_color = "+string(h.font_color) + "fractional_font = " + sci2exp(h.fractional_font) + "links = " + fmtchildren(h.links) + "legend_location = " + sci2exp(h.legend_location) + "position = " + sci2exp(h.position) + "line_width = "+sci2exp(h.line_width) + "line_mode = "+sci2exp(h.line_mode) + "thickness = "+string(h.thickness) + "foreground = "+string(h.foreground) + "fill_mode = "+sci2exp(h.fill_mode) + "background = "+string(h.background) + "marks_count = "+sci2exp(h.marks_count) + "clip_state = "+sci2exp(h.clip_state) + "clip_box = "+sci2exp(h.clip_box,0) + "user_data = "+fmtuser_data(h.user_data) + "tag = "+h.tag + ] + + // Rectangle + // ===================================================================== + + case "Rectangle" + u=h.user_data + t=[t; + "parent: "+h.parent.type + "children: "+fmtchildren(h.children) + "mark_mode = "+sci2exp(h.mark_mode) + "mark_style = "+string(h.mark_style) + "mark_size_unit = "+sci2exp(h.mark_size_unit) + "mark_size = "+string(h.mark_size) + "mark_foreground = "+string(h.mark_foreground) + "mark_background = "+string(h.mark_background) + "line_mode = "+sci2exp(h.line_mode) + "fill_mode = "+sci2exp(h.fill_mode) + "line_style = "+string(h.line_style) + "thickness = "+string(h.thickness) + "foreground = "+string(h.foreground) + "background = "+string(h.background) + "data = "+sci2exp(h.data,0) + "visible = "+sci2exp(h.visible) + "clip_state = "+sci2exp(h.clip_state) + "clip_box = "+sci2exp(h.clip_box,0) + "user_data = "+fmtuser_data(u) + "tag = "+h.tag + ] + + // Arc + // ===================================================================== + + case "Arc" + u=h.user_data + t=[t; + "parent: "+h.parent.type + "children: "+fmtchildren(h.children) + "thickness = "+string(h.thickness) + "line_style = "+string(h.line_style) + "line_mode = "+sci2exp(h.line_mode) + "fill_mode = "+sci2exp(h.fill_mode) + "foreground = "+string(h.foreground) + "background = "+string(h.background) + "data = "+sci2exp(h.data,0) + "visible = "+sci2exp(h.visible) + "arc_drawing_method = " + sci2exp(h.arc_drawing_method) + "clip_state = "+sci2exp(h.clip_state) + "clip_box = "+sci2exp(h.clip_box,0) + "user_data = "+fmtuser_data(u) + "tag = "+h.tag + ] + + // Figure + // ===================================================================== + + case "Figure" + l = h.layout_options; + if type(l) == 16 then //tlist + l = l(1); + l = l(1); + end + u=h.user_data + t=[t; + "children: "+fmtchildren(h.children) + "figure_position = "+sci2exp(h.figure_position,0) + "figure_size = "+sci2exp(h.figure_size,0) + "axes_size = "+sci2exp(h.axes_size,0) + "auto_resize = "+sci2exp(h.auto_resize) + "viewport = "+sci2exp(h.viewport) + "figure_name = "+sci2exp(h.figure_name,0) + "figure_id = "+sci2exp(h.figure_id,0) + "info_message = "+sci2exp(h.info_message) + "color_map = matrix "+strcat(string(size(h.color_map)),"x") + "pixel_drawing_mode = "+sci2exp(h.pixel_drawing_mode,0) + "anti_aliasing = " + sci2exp(h.anti_aliasing) + "immediate_drawing = "+sci2exp(h.immediate_drawing) + "background = "+string(h.background) + "visible = "+sci2exp(h.visible) + "rotation_style = "+sci2exp(h.rotation_style) + "event_handler = " + sci2exp( h.event_handler ) ; + "event_handler_enable = " + sci2exp( h.event_handler_enable ) ; + "user_data = "+fmtuser_data(u) + "resizefcn = "+sci2exp(h.resizefcn) + "closerequestfcn = "+sci2exp(h.closerequestfcn) + "resize = "+sci2exp(h.resize) + "toolbar = "+sci2exp(h.toolbar) + "toolbar_visible = "+sci2exp(h.toolbar_visible) + "menubar = "+sci2exp(h.menubar) + "menubar_visible = "+sci2exp(h.menubar_visible) + "infobar_visible = "+sci2exp(h.infobar_visible) + "dockable = "+sci2exp(h.dockable) + "layout = "+sci2exp(h.layout) + "layout_options = "+sci2exp(l) + "default_axes = "+sci2exp(h.default_axes) + "icon = "+fmtuser_data(h.icon) + "tag = "+sci2exp(h.tag) + ] + + // Grayplot + // ===================================================================== + + case "Grayplot" + Data = h.data + if size(Data.x,"*") > 10 then + dx="matrix "+strcat(string(size(Data.x)),"x") + else + dx=sci2exp(Data.x,0) + if length(dx)>70 then d="matrix "+strcat(string(size(Data.x)),"x"),end + end + + if size(Data.y,"*") > 10 then + dy="matrix "+strcat(string(size(Data.y)),"x") + else + dy=sci2exp(Data.y,0) + if length(dy)>70 then d="matrix "+strcat(string(size(Data.y)),"x"),end + end + + if size(Data.z,"*") > 10 then + dz="matrix "+strcat(string(size(Data.z)),"x") + else + dz=sci2exp(Data.z,0) + if length(dz)>70 then d="matrix "+strcat(string(size(Data.z)),"x"),end + end + + u=h.user_data + t=[t; + "parent: "+h.parent.type + "children: "+fmtchildren(h.children) + "visible = "+sci2exp(h.visible) + "data.x = "+dx + "data.y = "+dy + "data.z = "+dz + "data_mapping = "+sci2exp(h.data_mapping) + "clip_state = "+sci2exp(h.clip_state) + "clip_box = "+sci2exp(h.clip_box,0) + "user_data = "+fmtuser_data(u) + "tag = "+h.tag + ] + + // Matplot + // ===================================================================== + + + case "Matplot" + if typeof(h.data) == "hypermat" then + d="matrix "+strcat(string(h.data.dims),"x") + elseif size(h.data,"*") > 10 then + d="matrix "+strcat(string(size(h.data)),"x") + else + d=sci2exp(h.data,0) + if length(d)>70 then d="matrix "+strcat(string(size(h.data)),"x"),end + end + u=h.user_data + t=[t; + "parent: "+h.parent.type + "children: "+fmtchildren(h.children) + "visible = "+sci2exp(h.visible) + "data = "+d + "rect = " + sci2exp(h.rect, 0) + "image_type = " + sci2exp(h.image_type) + "clip_state = "+sci2exp(h.clip_state) + "clip_box = "+sci2exp(h.clip_box,0) + "user_data = "+fmtuser_data(u) + "tag = "+h.tag + ] + + // Fec + // ===================================================================== + case "Fec" + u=h.user_data + if size(h.data,"*") > 10 then + d="matrix "+strcat(string(size(h.data)),"x") + else + d=sci2exp(h.data,0) + if length(d)>70 then d="matrix "+strcat(string(size(h.data)),"x"),end + end + + if size(h.triangles,"*") > 10 then + f="matrix "+strcat(string(size(h.triangles)),"x") + else + f=sci2exp(h.triangles,0) + if length(f)>70 then f="matrix "+strcat(string(size(h.triangles)),"x"),end + end + + t=[t; + "parent: "+h.parent.type + "children: "+fmtchildren(h.children) + "visible = "+sci2exp(h.visible) + "data = "+d + "triangles = "+f + "z_bounds = "+sci2exp(h.z_bounds,0) + "color_range = " + sci2exp(h.color_range, 0); + "outside_colors = " + sci2exp(h.outside_colors, 0); + "line_mode = " + sci2exp(h.line_mode); + "foreground = " + sci2exp(h.foreground); + "clip_state = "+sci2exp(h.clip_state) + "clip_box = "+sci2exp(h.clip_box,0) + "user_data = "+fmtuser_data(u) + "tag = "+h.tag + ] + + // Segs + // ===================================================================== + + case "Segs" + if size(h.data,"*") > 10 then + d="matrix "+strcat(string(size(h.data)),"x") + else + d=sci2exp(h.data,0) + if length(d)>70 then d="matrix "+strcat(string(size(h.data)),"x"),end + end + + if size(h.segs_color,"*") > 10 then + c="matrix "+strcat(string(size(h.segs_color)),"x") + else + c=sci2exp(h.segs_color,0) + if length(c)>70 then c="matrix "+strcat(string(size(h.segs_color)),"x"),end + end + + u=h.user_data + t=[t; + "parent: "+h.parent.type + "children: "+fmtchildren(h.children) + "visible = "+sci2exp(h.visible) + "data = "+d + "line_mode = "+sci2exp(h.line_mode) + "line_style = "+string(h.line_style) + "thickness = "+string(h.thickness) + "arrow_size = "+string(h.arrow_size) + "segs_color = "+c + "mark_mode = "+sci2exp(h.mark_mode) + "mark_style = "+sci2exp(h.mark_style) + "mark_size_unit = "+sci2exp(h.mark_size_unit) + "mark_size = "+string(h.mark_size) + "mark_foreground = "+string(h.mark_foreground) + "mark_background = "+string(h.mark_background) + "clip_state = "+sci2exp(h.clip_state) + "clip_box = "+sci2exp(h.clip_box,0) + "user_data = "+fmtuser_data(u) + "tag = "+h.tag + ] + + // Champ + // ===================================================================== + + case "Champ" + Data = h.data + if size(Data.x,"*") > 10 then + dx="matrix "+strcat(string(size(Data.x)),"x") + else + dx=sci2exp(Data.x,0) + if length(dx)>70 then d="matrix "+strcat(string(size(Data.x)),"x"),end + end + + if size(Data.y,"*") > 10 then + dy="matrix "+strcat(string(size(Data.y)),"x") + else + dy=sci2exp(Data.y,0) + if length(dy)>70 then d="matrix "+strcat(string(size(Data.y)),"x"),end + end + + if size(Data.fx,"*") > 10 then + dfx="matrix "+strcat(string(size(Data.fx)),"x") + else + dfx=sci2exp(Data.fx,0) + if length(dfx)>70 then d="matrix "+strcat(string(size(Data.fx)),"x"),end + end + + if size(Data.fy,"*") > 10 then + dfy="matrix "+strcat(string(size(Data.fy)),"x") + else + dfy=sci2exp(Data.fy,0) + if length(dfy)>70 then d="matrix "+strcat(string(size(Data.fy)),"x"),end + end + + u=h.user_data + t=[t; + "parent: "+h.parent.type + "children: "+fmtchildren(h.children) + "visible = "+sci2exp(h.visible) + "data.x = "+dx + "data.y = "+dy + "data.fx = "+dfx + "data.fy = "+dfy + "line_style = "+string(h.line_style) + "thickness = "+string(h.thickness) + "colored = "+sci2exp(h.colored) + "arrow_size = "+string(h.arrow_size) + "clip_state = "+sci2exp(h.clip_state) + "clip_box = "+sci2exp(h.clip_box,0) + "user_data = "+fmtuser_data(u) + "tag = "+h.tag + ] + + // Text + // ===================================================================== + + case "Text" + u=h.user_data + T=sci2exp(h.text,0) + if length(T)>70 then T="string array "+strcat(string(size(h.text)),"x"),end + t=[t; + "parent: "+h.parent.type + "children: "+fmtchildren(h.children) + "visible = "+sci2exp(h.visible) + "text = "+T + "alignment = "+sci2exp(h.alignment) ; + "data = "+sci2exp(h.data,0) + "box = "+sci2exp(h.box) + "line_mode = " + sci2exp(h.line_mode); + "fill_mode = " + sci2exp(h.fill_mode); + "text_box = "+sci2exp(h.text_box,0) + "text_box_mode = "+sci2exp(h.text_box_mode,0) + "font_foreground = "+string(h.font_foreground) + "foreground = "+string(h.foreground) + "background = "+string(h.background) + "font_style = "+string(h.font_style) + "font_size = "+string(h.font_size) + "fractional_font = " + sci2exp(h.fractional_font) + "auto_dimensionning = " + sci2exp(h.auto_dimensionning) + "font_angle = "+string(h.font_angle) + "clip_state = "+sci2exp(h.clip_state) + "clip_box = "+sci2exp(h.clip_box,0) + "user_data = "+fmtuser_data(u) + "tag = "+h.tag + ] + + // Datatip + // ===================================================================== + + case "Datatip" + u=h.user_data + t=[t; + "parent: "+h.parent.type + "children: "+fmtchildren(h.children) + "visible = "+sci2exp(h.visible) + "data = "+sci2exp(h.data) + "box_mode = "+sci2exp(h.box_mode) + "label_mode = "+sci2exp(h.label_mode) + "orientation = "+sci2exp(h.orientation) + "z_component = "+sci2exp(h.z_component) + "auto_orientation = "+sci2exp(h.auto_orientation) + "interp_mode = "+sci2exp(h.interp_mode) + "display_function = "+sci2exp(h.display_function) + "font_foreground = "+string(h.font_foreground) + "foreground = "+string(h.foreground) + "background = "+string(h.background) + "mark_mode = "+sci2exp(h.mark_mode) + "mark_style = "+sci2exp(h.mark_style) + "mark_size_unit = "+sci2exp(h.mark_size_unit) + "mark_size = "+string(h.mark_size) + "mark_foreground = "+string(h.mark_foreground) + "mark_background = "+string(h.mark_background) + "user_data = "+fmtuser_data(u) + "tag = "+h.tag + ] + + // Title + // ===================================================================== + + case "Title" + T=sci2exp(h.text,0) + if length(T)>70 then T="string array "+strcat(string(size(h.text)),"x"),end + t=[t; + "parent: "+h.parent.type + "children: "+fmtchildren(h.children) + "visible = "+sci2exp(h.visible) + "text = "+T + "foreground = "+string(h.foreground) + "font_style = "+string(h.font_style) + "font_size = "+string(h.font_size) + "fractional_font = " + sci2exp(h.fractional_font) + "font_angle = "+string(h.font_angle) + "tag = "+h.tag + ] + + // Label + // ===================================================================== + + case "Label" + T=sci2exp(h.text,0) + if length(T)>70 then T="string array "+strcat(string(size(h.text)),"x"),end + t=[t; + "parent: "+h.parent.type + "visible = "+sci2exp(h.visible) + "text = "+T; + "font_foreground = " + string(h.font_foreground) ; + "foreground = "+string(h.foreground) + "background = "+string(h.background) + "fill_mode = "+sci2exp(h.fill_mode) + "font_style = "+string(h.font_style) + "font_size = "+string(h.font_size) + "fractional_font = " + sci2exp(h.fractional_font) + "font_angle = "+string(h.font_angle) + "auto_position = "+sci2exp(h.auto_position) + "position = "+sci2exp(h.position,0) + "auto_rotation = "+sci2exp(h.auto_rotation) + "tag = "+h.tag + ] + + // Plot3d + // ===================================================================== + case "Plot3d" + Data = h.data + if size(Data.x,"*") > 10 then + dx="matrix "+strcat(string(size(Data.x)),"x") + else + dx=sci2exp(Data.x,0) + if length(dx)>70 then d="matrix "+strcat(string(size(Data.x)),"x"),end + end + + if size(Data.y,"*") > 10 then + dy="matrix "+strcat(string(size(Data.y)),"x") + else + dy=sci2exp(Data.y,0) + if length(dy)>70 then d="matrix "+strcat(string(size(Data.y)),"x"),end + end + + if size(Data.z,"*") > 10 then + dz="matrix "+strcat(string(size(Data.z)),"x") + else + dz=sci2exp(Data.z,0) + if length(dz)>70 then d="matrix "+strcat(string(size(Data.z)),"x"),end + end + + u=h.user_data + + if size(Data) == 5 then // There is a color + if size(Data.color,"*") > 10 then + dcolor="matrix "+strcat(string(size(Data.color)),"x") + else + dcolor=sci2exp(Data.color,0) + if length(dcolor)>70 then dcolor="matrix "+strcat(string(size(Data.color)),"x"),end + end + + t=[t; + "parent: "+h.parent.type + "children: "+fmtchildren(h.children) + "visible = "+sci2exp(h.visible) + "surface_mode = "+sci2exp(h.surface_mode) + "foreground = "+string(h.foreground) + "thickness = "+string(h.thickness) + "mark_mode = "+sci2exp(h.mark_mode) + "mark_style = "+sci2exp(h.mark_style) + "mark_size_unit = "+sci2exp(h.mark_size_unit) + "mark_size = "+string(h.mark_size) + "mark_foreground = "+string(h.mark_foreground) + "mark_background = "+string(h.mark_background) + "data.x = "+dx + "data.y = "+dy + "data.z "+dz + "data.color (not used) = "+dcolor + "color_mode = "+string(h.color_mode) + "color_flag = "+sci2exp(h.color_flag,0) + "hiddencolor = "+string(h.hiddencolor) + "clip_state = "+sci2exp(h.clip_state) + "clip_box = "+sci2exp(h.clip_box,0) + "ambient_color = "+sci2exp(h.ambient_color) + "diffuse_color = "+sci2exp(h.diffuse_color) + "specular_color = "+sci2exp(h.specular_color) + "use_color_material = "+sci2exp(h.use_color_material) + "material_shininess = "+sci2exp(h.material_shininess) + "user_data = "+fmtuser_data(u) + "tag = "+h.tag + ] + else + t=[t; + "parent: "+h.parent.type + "children: "+fmtchildren(h.children) + "visible = "+sci2exp(h.visible) + "surface_mode = "+sci2exp(h.surface_mode) + "foreground = "+string(h.foreground) + "thickness = "+string(h.thickness) + "mark_mode = "+sci2exp(h.mark_mode) + "mark_style = "+sci2exp(h.mark_style) + "mark_size_unit = "+sci2exp(h.mark_size_unit) + "mark_size = "+string(h.mark_size) + "mark_foreground = "+string(h.mark_foreground) + "mark_background = "+string(h.mark_background) + "data.x = "+dx + "data.y = "+dy + "data.z = "+dz + "color_mode = "+string(h.color_mode) + "color_flag = "+sci2exp(h.color_flag,0) + "hiddencolor = "+string(h.hiddencolor) + "clip_state = "+sci2exp(h.clip_state) + "clip_box = "+sci2exp(h.clip_box,0) + "ambient_color = "+sci2exp(h.ambient_color) + "diffuse_color = "+sci2exp(h.diffuse_color) + "specular_color = "+sci2exp(h.specular_color) + "use_color_material = "+sci2exp(h.use_color_material) + "material_shininess = "+sci2exp(h.material_shininess) + "user_data = "+fmtuser_data(u) + "tag = "+h.tag + ] + end + + // Fac3d + // ===================================================================== + + case "Fac3d" + Data = h.data + if size(Data.x,"*") > 10 then + dx="matrix "+strcat(string(size(Data.x)),"x") + else + dx=sci2exp(Data.x,0) + if length(dx)>70 then d="matrix "+strcat(string(size(Data.x)),"x"),end + end + + if size(Data.y,"*") > 10 then + dy="matrix "+strcat(string(size(Data.y)),"x") + else + dy=sci2exp(Data.y,0) + if length(dy)>70 then d="matrix "+strcat(string(size(Data.y)),"x"),end + end + + if size(Data.z,"*") > 10 then + dz="matrix "+strcat(string(size(Data.z)),"x") + else + dz=sci2exp(Data.z,0) + if length(dz)>70 then d="matrix "+strcat(string(size(Data.z)),"x"),end + end + + u=h.user_data; + + if size(Data) == 5 then // There is a color + if size(Data.color,"*") > 10 then + dcolor="matrix "+strcat(string(size(Data.color)),"x") + else + dcolor=sci2exp(Data.color,0) + if length(dcolor)>70 then dcolor="matrix "+strcat(string(size(Data.color)),"x"),end + end + + t=[t; + "parent: "+h.parent.type + "children: "+fmtchildren(h.children) + "visible = "+sci2exp(h.visible) + "surface_mode = "+sci2exp(h.surface_mode) + "foreground = "+string(h.foreground) + "thickness = "+string(h.thickness) + "mark_mode = "+sci2exp(h.mark_mode) + "mark_style = "+sci2exp(h.mark_style) + "mark_size_unit = "+sci2exp(h.mark_size_unit) + "mark_size = "+string(h.mark_size) + "mark_foreground = "+string(h.mark_foreground) + "mark_background = "+string(h.mark_background) + "data.x = "+dx + "data.y = "+dy + "data.z = "+dz + "data.color = "+dcolor + "color_mode = "+string(h.color_mode) + "color_flag = "+sci2exp(h.color_flag,0) + "cdata_mapping = "+sci2exp(h.cdata_mapping) + "hiddencolor = "+string(h.hiddencolor) + "clip_state = "+sci2exp(h.clip_state) + "clip_box = "+sci2exp(h.clip_box,0) + "ambient_color = "+sci2exp(h.ambient_color) + "diffuse_color = "+sci2exp(h.diffuse_color) + "specular_color = "+sci2exp(h.specular_color) + "use_color_material = "+sci2exp(h.use_color_material) + "material_shininess = "+sci2exp(h.material_shininess) + "user_data = "+fmtuser_data(u) + "tag = "+h.tag + ] + else + t=[t; + "parent: "+h.parent.type + "children: "+fmtchildren(h.children) + "visible = "+sci2exp(h.visible) + "surface_mode = "+sci2exp(h.surface_mode) + "foreground = "+string(h.foreground) + "thickness = "+string(h.thickness) + "mark_mode = "+sci2exp(h.mark_mode) + "mark_style = "+sci2exp(h.mark_style) + "mark_size_unit = "+sci2exp(h.mark_size_unit) + "mark_size = "+string(h.mark_size) + "mark_foreground = "+string(h.mark_foreground) + "mark_background = "+string(h.mark_background) + "data.x = "+dx + "data.y = "+dy + "data.z = "+dz + "color_mode = "+string(h.color_mode) + "color_flag = "+sci2exp(h.color_flag,0) + "hiddencolor = "+string(h.hiddencolor) + "clip_state = "+sci2exp(h.clip_state) + "clip_box = "+sci2exp(h.clip_box,0) + "ambient_color = "+sci2exp(h.ambient_color) + "diffuse_color = "+sci2exp(h.diffuse_color) + "specular_color = "+sci2exp(h.specular_color) + "usecolor_material = "+sci2exp(h.use_color_material) + "material_shininess = "+sci2exp(h.material_shininess) + "user_data = "+fmtuser_data(u) + "tag = "+h.tag + ] + end + + // Param3d + // ===================================================================== + + case "Param3d" + u=h.user_data; + if size(h.data,"*") > 10 then + d="matrix "+strcat(string(size(h.data)),"x") + else + d=sci2exp(h.data,0) + if length(d)>70 then d="matrix "+strcat(string(size(h.data)),"x"),end + end + + if size(h.surface_color,"*") > 10 then + c="matrix "+strcat(string(size(h.surface_color)),"x") + else + c=sci2exp(h.surface_color,0) + if length(c)>70 then c="matrix "+strcat(string(size(h.surface_color)),"x"),end + end + + t=[t; + "parent: "+h.parent.type + "children: "+fmtchildren(h.children) + "visible = "+sci2exp(h.visible) + "line_mode = "+sci2exp(h.line_mode) + "foreground = "+string(h.foreground) + "thickness = "+string(h.thickness) + "mark_mode = "+sci2exp(h.mark_mode) + "mark_style = "+sci2exp(h.mark_style) + "mark_size_unit = "+sci2exp(h.mark_size_unit) + "mark_size = "+string(h.mark_size) + "mark_foreground = "+string(h.mark_foreground) + "mark_background = "+string(h.mark_background) + "data = "+d + "clip_state = "+sci2exp(h.clip_state) + "clip_box = "+sci2exp(h.clip_box,0) + "color_mode = "+string(h.color_mode) + "surface_color = "+c + "user_data = "+fmtuser_data(u) + "tag = "+h.tag + ] + + // Axis + // ===================================================================== + + case "Axis" + u=h.user_data; + T=sci2exp(h.tics_labels,0) + if length(T)>70 then T="string array "+strcat(string(size(h.tics_labels)),"x"),end + t=[t; + "parent: "+h.parent.type + "visible = "+sci2exp(h.visible) + "tics_direction = "+sci2exp(h.tics_direction) + "xtics_coord = "+sci2exp(h.xtics_coord,0) + "ytics_coord = "+sci2exp(h.ytics_coord,0) + "tics_color = "+string(h.tics_color) + "tics_segment = "+sci2exp(h.tics_segment) + "tics_style = "+sci2exp(h.tics_style) + "sub_tics = "+string(h.sub_tics) + "tics_labels = "+T + "format_n = "+sci2exp(h.format_n) + "labels_font_size = "+string(h.labels_font_size) + "labels_font_color = "+string(h.labels_font_color) + "labels_font_style = "+string(h.labels_font_style) + "fractional_font = " + sci2exp(h.fractional_font) + "clip_state = "+sci2exp(h.clip_state) + "clip_box = "+sci2exp(h.clip_box,0) + "user_data = "+fmtuser_data(u) + "tag = "+h.tag + ] + + // waitbar + // ===================================================================== + + case "Waitbar" + u=h.user_data; + t=[t; + "Userdata = "+fmtuser_data(u) + "Tag = "+h.tag + ] + + // progressionbar + // ===================================================================== + + case "Progressionbar" + u=h.user_data; + t=[t; + "Userdata = "+fmtuser_data(u) + "Tag = "+h.tag + ] + + // uimenu + // ===================================================================== + + case "uimenu" + u=h.user_data; + t=[t; + "Parent: "+h.parent.type + "Children: "+fmtchildren(h.children) + "Enable = "+sci2exp(h.enable) + "Foregroundcolor = "+sci2exp(h.foregroundcolor,0) + "Label = "+h.label + "Handle_Visible = "+sci2exp(h.handle_visible) + "Visible = "+sci2exp(h.visible) + "Callback = "+h.callback + "Callback_Type = "+sci2exp(h.callback_type,0) + "Checked = "+sci2exp(h.checked) + "Icon = "+sci2exp(h.icon) + "Userdata = "+fmtuser_data(u) + "Tag = "+h.tag + ] + + // uicontextmenu + // ===================================================================== + + case "uicontextmenu" + if isempty(h.parent) then // For an uicontextmenu, parent can be empty + parent = ""; + else + parent = h.parent.type; + end + t=[t; + "Parent: "+parent + "Children: "+fmtchildren(h.children) + ] + + // uicontrol + // ===================================================================== + + case "uicontrol" + + u=h.user_data; + c = h.constraints; + if type(c) == 16 then //tlist + c = c(1); + c = c(1); + end + l = h.layout_options; + if type(l) == 16 then //tlist + l = l(1); + l = l(1); + end + b = h.border; + if type(b) == 16 then //tlist + b = b(1); + b = b(1); + end + + showHiddenProperties = get(get(0), "ShowHiddenProperties") == "on"; + t($ + 1) = "Parent: " + h.parent.type; + t($ + 1) = "Children: " + fmtchildren(h.children); + t($ + 1) = "Style = " + h.style; + if and(h.style <> ["popupmenu"]) | showHiddenProperties then + t($ + 1) = "BackgroundColor = " + sci2exp(h.backgroundcolor,0); + end + if h.style == "frame" | showHiddenProperties then + t($ + 1) = "Border = " + sci2exp(b); + end + if and(h.style <> ["frame", "layer", "text"]) | showHiddenProperties then + t($ + 1) = "Callback = " + h.callback; + t($ + 1) = "Callback_Type = " + sci2exp(h.callback_type,0); + end + t($ + 1) = "Constraints = " + sci2exp(c); + t($ + 1) = "Enable = " + sci2exp(h.enable); + if and(h.style <> ["image", "slider", "layer"]) | showHiddenProperties then + t($ + 1) = "FontAngle = " + h.fontangle; + t($ + 1) = "FontName = " + h.fontname; + t($ + 1) = "FontSize = " + sci2exp(h.fontsize); + t($ + 1) = "FontUnits = " + h.fontunits; + t($ + 1) = "FontWeight = " + h.fontweight; + end + if and(h.style <> ["frame", "layer", "tab", "slider", "image", "popupmenu"]) | showHiddenProperties then + t($ + 1) = "ForegroundColor = " + sci2exp(h.foregroundcolor,0); + end + if or(h.style == ["radiobutton", "checkbox"]) | showHiddenProperties then + t($ + 1) = "Groupname = " + sci2exp(h.groupname); + end + if and(h.style <> ["frame", "layer", "tab", "listbox", "popupmenu"]) | showHiddenProperties then + t($ + 1) = "HorizontalAlignment = " + h.horizontalalignment; + end + if or(h.style == ["text", "pushbutton", "frame"]) | showHiddenProperties then + t($ + 1) = "Icon = " + fmtuser_data(h.icon); + end + if h.style == "frame" | showHiddenProperties then + t($ + 1) = "Layout = " + sci2exp(h.layout); + t($ + 1) = "Layout_options = " + sci2exp(l); + end + if h.style == "listbox" | showHiddenProperties then + t($ + 1) = "ListboxTop = " + sci2exp(h.listboxtop,0); + end + t($ + 1) = "Margins = " + sci2exp(h.margins); + if or(h.style == ["checkbox", "radiobutton", "slider", "spinner", "listbox", "edit"]) | showHiddenProperties then + t($ + 1) = "Max = " + sci2exp(h.max); + t($ + 1) = "Min = " + sci2exp(h.min); + end + t($ + 1) = "Position = " + sci2exp(h.position,0); + t($ + 1) = "Relief = " + h.relief; + if or(h.style == ["frame", "edit"]) | showHiddenProperties then + t($ + 1) = "Scrollable = " + sci2exp(h.scrollable); + end + if or(h.style == ["slider", "spinner"]) | showHiddenProperties then + t($ + 1) = "SliderStep = " + sci2exp(h.sliderstep); + end + if h.style <> "slider" | showHiddenProperties then + t($ + 1) = "String = " + fmtuser_data(h.string); + end + t($ + 1) = "Tag = " + h.tag; + if h.style == "tab" | showHiddenProperties then + t($ + 1) = "Title_position = " + sci2exp(h.title_position); + t($ + 1) = "Title_scroll = " + sci2exp(h.title_scroll); + end + t($ + 1) = "TooltipString = " + fmtuser_data(h.tooltipstring); + t($ + 1) = "Units = " + h.units; + t($ + 1) = "Userdata = " + fmtuser_data(u); + if or(h.style == ["checkbox", "radiobutton", "slider", "spinner", "listbox", "edit", "layer", "tab", "popupmenu"]) | showHiddenProperties then + t($ + 1) = "Value = " + sci2exp(h.value,0); + end + + if and(h.style <> ["frame", "layer", "tab", "listbox", "popupmenu"]) | showHiddenProperties then + t($ + 1) = "VerticalAlignment = " + h.verticalalignment; + end + t($ + 1) = "Visible = " + sci2exp(h.visible); + + // Console + // ===================================================================== + + case "Console" + t=[t; + "Children: "+fmtchildren(h.children) + "ShowHiddenHandles = "+sci2exp(h.showhiddenhandles) + "ShowHiddenProperties = "+sci2exp(h.showhiddenproperties) + "UseDeprecatedSkin = "+sci2exp(h.usedeprecatedskin) + ] + // Light + // ===================================================================== + + case "Light" + t=[t; + "parent: "+h.parent.type + "visible = "+sci2exp(h.visible) + "light_type = "+sci2exp(h.light_type) + "position = "+sci2exp(h.position) + "direction = "+sci2exp(h.direction) + "ambient_color = "+sci2exp(h.ambient_color) + "diffuse_color = "+sci2exp(h.diffuse_color) + "specular_color= "+sci2exp(h.specular_color) + ] + end + end + write(%io(2),t) +endfunction + + + + +function t=fmtchildren(c) + if c==[] then + t="[]" + else + if size(c,"*")<10 then + t=sci2exp(c.type,0); + if length(t)>70 then t="matrix "+strcat(string(size(c)),"x"),end + else + t="matrix "+strcat(string(size(c)),"x") + end + end +endfunction + + +function t=fmtuser_data(d) + td= type(d) + if or(td==[1 2 3 4 8 10 15]) then + t=sci2exp(d,0) + if length(t)>70 then + if type(d) <> 15 then + t=typeof(d)+" "+strcat(string(size(d)),"x"); + else + t=typeof(d)+"("; + for i=1:length(d) + if type(d(i)) <> 9 then + t=t+typeof(d(i))+", "; + else + t=t+d(i).type +", "; + end + end + t=part(t,1:length(t)-2); + t=t+")"; + end + end + elseif or(td==16) then + t=typeof(d)+" "+strcat(string(size(d)),"x"), + elseif or(td==17) then + if typeof(d)=="ce" then + t="cell "+strcat(string(size(d)),"x"), + elseif typeof(d)=="st" then + T=getfield(1,d) + t="struct with fields: "+strcat(T(3:$)," "), + else + t=typeof(d) + end + else + t=typeof(d) + end +endfunction diff --git a/modules/graphics/macros/%h_save.bin b/modules/graphics/macros/%h_save.bin Binary files differnew file mode 100755 index 000000000..dd01b88c2 --- /dev/null +++ b/modules/graphics/macros/%h_save.bin diff --git a/modules/graphics/macros/%h_save.sci b/modules/graphics/macros/%h_save.sci new file mode 100755 index 000000000..f2cb05b56 --- /dev/null +++ b/modules/graphics/macros/%h_save.sci @@ -0,0 +1,759 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2004 - INRIA - Serge Steer +// Copyright (C) 2004-2006 - INRIA - Fabrice Leray +// Copyright (C) 2006 - INRIA - Jean-Baptiste Silvy +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +function %h_save(h,fd) + version=[5 5 2 0] + mput(version,"uc",fd) + + // There are issues when saving characters with 'c' format + // characterFormat format behave smoothly + characterFormat = "uc"; + stringFormat = "il"; + + hsize = size(h); + mput(hsize,characterFormat,fd); + // introduced in version 3 1 0 2 to handle + // the case where we have a matrix of handles to save + + if or(hsize>1) + for i=1:hsize(1) + for j=1:hsize(2) + save_graphichandle(h(i,j),fd) + end + end + else + save_graphichandle(h,fd) + end +endfunction + +function save_graphichandle(h,fd) + if ~is_handle_valid(h) then + warning(msprintf(gettext("%s: handle no more valid ignored.\n"),"save_graphichandle")); + return + end + typ=h.type + select h.type + + case "Figure" + mput( length(h.type),characterFormat,fd);mput(ascii(h.type),characterFormat,fd); // type + // handle => new style + mput(bool2s(h.visible=="on"),characterFormat,fd) // visible + mput(h.figure_position,"sl",fd) // figure_position + mput(h.figure_size,"sl",fd) // figure size + mput(h.axes_size,"sl",fd) // axes_size + mput(h.viewport,"sl",fd) // viewport + mput(length(ascii(h.info_message)),stringFormat,fd) ; // info_message + mput(ascii(h.info_message),characterFormat,fd) ; + mput(length(ascii(h.tag)),characterFormat,fd) ; // tag + mput(ascii(h.tag),characterFormat,fd) ; + mput(bool2s(h.auto_resize=="on"),characterFormat,fd) // auto_resize + mput(length(ascii(h.figure_name)),stringFormat,fd); // figure_name + mput(ascii(h.figure_name),characterFormat,fd); + mput(h.figure_id,"sl",fd); // figure_id + + mput(size(h.color_map,"*"),"il",fd); // color_map + mput(h.color_map,"dl",fd) ; + mput(length(h.pixel_drawing_mode),characterFormat,fd); // pixel_drawing_mode + mput(ascii(h.pixel_drawing_mode),characterFormat,fd); + mput(length(h.anti_aliasing),characterFormat,fd); // anti_aliasing + mput(ascii(h.anti_aliasing),characterFormat,fd); + mput(bool2s(h.immediate_drawing=="on"),characterFormat,fd) // immediate_drawing + mput(h.background,"il",fd) // background + mput(length(h.rotation_style),characterFormat,fd); // rotation style + mput(ascii(h.rotation_style),characterFormat,fd); + + mput(length(ascii(h.event_handler)),characterFormat,fd); // event_handler + mput(ascii(h.event_handler),characterFormat,fd); + mput(length(h.event_handler_enable),characterFormat,fd); // even_handler_enable + mput(ascii(h.event_handler_enable),characterFormat,fd); // need to be put after event_handler + + mput(length(ascii(h.resizefcn)),characterFormat,fd) ; // resizefcn + mput(ascii(h.resizefcn),characterFormat,fd) ; + mput(length(ascii(h.closerequestfcn)),characterFormat,fd) ; // closerequestfcn + mput(ascii(h.closerequestfcn),characterFormat,fd) ; + + // children + c=h.children; + n=size(c,"*") + mput(n,"il",fd) + for k=n:-1:1 + save_graphichandle(c(k),fd) + end + + user_data=h.user_data; // user_data + save(fd,user_data) ; + + + case "Axes" + mput(length(h.type),characterFormat,fd);mput(ascii(h.type),characterFormat,fd); // type + mput(bool2s(h.visible=="on"),characterFormat,fd) // visible + mput(size(h.axes_visible,"*"),characterFormat,fd); // axes_visible + mput(bool2s(h.axes_visible=="on"),characterFormat,fd) ; + mput(size(h.axes_reverse,"*"),characterFormat,fd); // axes_reverse + mput(bool2s(h.axes_reverse=="on"),characterFormat,fd) ; + mput(size(h.grid,"*"),characterFormat,fd); mput(h.grid,"il",fd); // grid + mput(length(h.grid_position),characterFormat,fd); // grid_position + mput(ascii(h.grid_position),characterFormat,fd); + mput(length(h.x_location),characterFormat,fd); // x_location + mput(ascii(h.x_location),characterFormat,fd); + mput(length(h.y_location),characterFormat,fd); // y_location + mput(ascii(h.y_location),characterFormat,fd); + mput(ascii(h.view),characterFormat,fd) ; // view + + // title + l=h.title; + mput(bool2s(l.visible=="on"),characterFormat,fd) ; // title.visible + save_text_matrix( l.text, fd ) ; + mput(l.font_foreground,"il",fd); // title_label.font_foreground + mput(bool2s(l.fractional_font=="on"),characterFormat,fd) // title.fractional_font + mput(l.foreground,"il",fd) // title.foreground + mput(l.background,"il",fd) // title.background + mput(bool2s(l.fill_mode=="on"),characterFormat,fd) // title.fill_mode + mput(l.font_style,characterFormat,fd) ; // title.font_style + mput(l.font_size,characterFormat,fd) ; // title.font_size + + mput(bool2s(l.auto_rotation=="on"),characterFormat,fd) // title.auto_rotation + mput(l.font_angle,"dl",fd) // title.font_angle + mput(bool2s(l.auto_position=="on"),characterFormat,fd) // title.auto_position + mput(l.position,"dl",fd) // title.position + + // x_label + l=h.x_label + mput(bool2s(l.visible=="on"),characterFormat,fd) // x_label.visible + save_text_matrix( l.text, fd ) ; + mput(l.font_foreground,"il",fd); // x_label.font_foreground + mput(bool2s(l.fractional_font=="on"),characterFormat,fd) // x_label.fractional_font + mput(l.foreground,"il",fd) // x_label.foreground + mput(l.background,"il",fd) // x_label.background + mput(bool2s(l.fill_mode=="on"),characterFormat,fd) // x_label.fill_mode + mput(l.font_style,characterFormat,fd) // x_label.font_style + mput(l.font_size,characterFormat,fd) // x_label.font_size + + mput(bool2s(l.auto_rotation=="on"),characterFormat,fd) // x_label.auto_rotation + mput(l.font_angle,"dl",fd) // x_label.font_angle + mput(bool2s(l.auto_position=="on"),characterFormat,fd) // x_label.auto_position + mput(l.position,"dl",fd) // x_label.position + + // y_label + l=h.y_label + mput(bool2s(l.visible=="on"),characterFormat,fd) // y_label.visible + save_text_matrix( l.text, fd ) ; + mput(l.font_foreground,"il",fd); // y_label.font_foreground + mput(bool2s(l.fractional_font=="on"),characterFormat,fd) // y_label.fractional_font + mput(l.foreground,"il",fd) // y_label.foreground + mput(l.background,"il",fd) // y_label.background + mput(bool2s(l.fill_mode=="on"),characterFormat,fd) // y_label.fill_mode + mput(l.font_style,characterFormat,fd) // y_label.font_style + mput(l.font_size,characterFormat,fd) // y_label.font_size + + mput(bool2s(l.auto_rotation=="on"),characterFormat,fd) // y_label.auto_rotation + mput(l.font_angle,"dl",fd) // y_label.font_angle + mput(bool2s(l.auto_position=="on"),characterFormat,fd) // y_label.auto_position + mput(l.position,"dl",fd) // y_label.position + + if h.view=="3d" then + // z_label + l=h.z_label + mput(bool2s(l.visible=="on"),characterFormat,fd) // z_label.visible + save_text_matrix( l.text, fd ) ; + mput(l.font_foreground,"il",fd); // z_label.font_foreground + mput(bool2s(l.fractional_font=="on"),characterFormat,fd) // z_label.fractional_font + mput(l.foreground,"il",fd) // z_label.foreground + mput(l.background,"il",fd) // z_label.background + mput(bool2s(l.fill_mode=="on"),characterFormat,fd) // z_label.fill_mode + mput(l.font_style,characterFormat,fd) // z_label.font_style + mput(l.font_size,characterFormat,fd) // z_label.font_size + mput(bool2s(l.auto_rotation=="on"),characterFormat,fd) // z_label.auto_rotation + mput(l.font_angle,"dl",fd) // z_label.font_angle + mput(bool2s(l.auto_position=="on"),characterFormat,fd) // z_label.auto_position + mput(l.position,"dl",fd) // z_label.position + end + + mput(size(h.auto_ticks,"*"),characterFormat,fd); // auto_ticks + mput(bool2s(h.auto_ticks=="on"),characterFormat,fd) + // x_ticks + sz=size(h.x_ticks.locations,"*"); + mput(sz,"sl",fd); + if sz>0 then + mput(h.x_ticks.locations,"dl",fd) + mput(length(h.x_ticks.labels),characterFormat,fd); // x_ticks.labels + mput(ascii(strcat(h.x_ticks.labels)),characterFormat,fd); + end + // y_ticks + sz=size(h.y_ticks.locations,"*"); + mput(sz,"sl",fd); + if sz>0 then + mput(h.y_ticks.locations,"dl",fd) + mput(length(h.y_ticks.labels),characterFormat,fd); // y_ticks.labels + mput(ascii(strcat(h.y_ticks.labels)),characterFormat,fd); + end + // z_ticks + sz=size(h.z_ticks.locations,"*"); + mput(sz,"sl",fd); + if sz>0 then + mput(h.z_ticks.locations,"dl",fd) + mput(length(h.z_ticks.labels),characterFormat,fd); // z_ticks.labels + mput(ascii(strcat(h.z_ticks.labels)),characterFormat,fd); + end + mput(length(h.box), characterFormat, fd ) ; // box + mput(ascii(h.box), characterFormat, fd ) ; + mput(bool2s(h.filled == "on"),characterFormat,fd); // filled + mput(size(h.sub_tics,"*"),characterFormat,fd);mput(h.sub_tics,characterFormat,fd); // sub_ticks + //mput(-1,'il',fd) // tics_color is removed F.Leray 15.03.05 + mput(h.font_style,characterFormat,fd) // font_style + mput(h.font_size,characterFormat,fd) //font_size + mput(h.font_color,"il",fd) // font_color + mput(bool2s(h.fractional_font=="on"),characterFormat,fd) // fractional_font + mput(bool2s(h.isoview=="on"),characterFormat,fd) // isoview + mput(bool2s(h.cube_scaling=="on"),characterFormat,fd) // cube_scaling + mput(h.rotation_angles,"dl",fd) // rotation_angles + mput(ascii(h.log_flags),characterFormat,fd) // log_flags + mput(size(h.tight_limits,"*"),characterFormat,fd); // tight_limits + mput(bool2s(h.tight_limits=="on"),characterFormat,fd); + mput(size(h.data_bounds,"*"),characterFormat,fd); // data_bounds + mput(h.data_bounds,"dl",fd); + mput(size(h.zoom_box,"*"),characterFormat,fd); // zoom_box + if size(h.zoom_box,"*")>0 then mput(h.zoom_box,"dl",fd);end + mput(h.margins,"dl",fd); // margins + mput(h.axes_bounds,"dl",fd); // axes_bounds + mput(bool2s(h.auto_clear=="on"),characterFormat,fd) // auto_clear + mput(bool2s(h.auto_scale=="on"),characterFormat,fd) // auto_scale + mput(h.hidden_axis_color,"il",fd); // hidden_axis_color + mput(length(h.arc_drawing_method),characterFormat,fd); // arc_drawing_method + mput(ascii(h.arc_drawing_method),characterFormat,fd); + mput(h.hiddencolor,"il",fd) // hidden_color + mput(bool2s(h.line_mode=="on"),characterFormat,fd) // line_mode + mput(h.line_style,characterFormat,fd) // line_style + mput(h.thickness,"sl",fd) // thickness + mput(bool2s(h.mark_mode=="on"),characterFormat,fd) // mark_mode + mput(h.mark_style,characterFormat,fd) // mark_style + mput(h.mark_size,characterFormat,fd) // mark_size + mput(ascii(part(h.mark_size_unit,1)),characterFormat,fd) // mark_size_unit + mput(h.mark_foreground,"il",fd) // mark_foreground + mput(h.mark_background,"il",fd) // mark_background + + mput(h.foreground,"il",fd) // foreground + mput(h.background,"il",fd) // background + + mput(length(h.clip_state),characterFormat,fd); // clip_state + mput(ascii(h.clip_state),characterFormat,fd); + if h.clip_state=="on" then + mput(h.clip_box,"dl",fd) // clip_box + end + + // children + c=h.children; + n=size(c,"*") + mput(n,"il",fd) + for k=n:-1:1 + save_graphichandle(c(k),fd) + end + + user_data=h.user_data;save(fd,user_data) // user_data + + case "Polyline" + mput(length(h.type),characterFormat,fd);mput(ascii(h.type),characterFormat,fd); // type + + mput(bool2s(h.visible=="on"),characterFormat,fd) ; // visible + mput(size(h.data),"il",fd);mput(h.data,"dl",fd) // data + mput(bool2s(h.closed=="on"),characterFormat,fd) // closed + mput(bool2s(h.line_mode=="on"),characterFormat,fd) // line_mode + mput(bool2s(h.fill_mode=="on"),characterFormat,fd) // fill_mode + mput(h.line_style,characterFormat,fd) // line_style + mput(h.thickness,"sl",fd) // thickness + mput(h.arrow_size_factor,"sl",fd) // arrow_size_factor + mput(max(1,h.polyline_style),characterFormat,fd) // ployline_style + + mput( size( h.interp_color_vector, "*" ), "sl", fd ) ; // interp_color_vector + mput( h.interp_color_vector, "dl", fd ) ; + mput( bool2s(h.interp_color_mode=="on"), characterFormat, fd ) ; // interp_color_mode + + mput(bool2s(h.mark_mode=="on"),characterFormat,fd) // mark_mode + mput(h.mark_style,characterFormat,fd) // mark_style + mput(h.mark_size,characterFormat,fd) // mark_size + mput(ascii(part(h.mark_size_unit,1)),characterFormat,fd) // mark_size_unit + mput(h.foreground,"il",fd) // foreground + mput(h.background,"il",fd) // background + mput(h.mark_foreground,"il",fd) // mark_foreground + mput(h.mark_background,"il",fd) // mark_background + mput(h.mark_offset,"il",fd) // mark_offset + mput(h.mark_stride,"il",fd) // mark_stride + + mput(size(h.x_shift,"*"),"sl",fd); mput(h.x_shift,"dl",fd); // x_shift + mput(size(h.y_shift,"*"),"sl",fd); mput(h.y_shift,"dl",fd); // y_shift + mput(size(h.z_shift,"*"),"sl",fd); mput(h.z_shift,"dl",fd); // z_shift + + mput( h.bar_width, "dl", fd ) ; // bar_width + mput(length(h.clip_state),characterFormat,fd); // clip_state + mput(ascii(h.clip_state),characterFormat,fd); + if h.clip_state=="on" then + mput(h.clip_box,"dl",fd) // clip_box + end + user_data=h.user_data;save(fd,user_data) // user_data + + case "Datatip" + mput(length(h.type),characterFormat,fd); // type + mput(ascii(h.type),characterFormat,fd); + mput(bool2s(h.visible=="on"),characterFormat,fd) // visible + mput(size(h.data),characterFormat,fd); // data + mput(h.data,"dl",fd); + mput(length(h.box_mode),characterFormat,fd); // box_mode + mput(ascii(h.box_mode),characterFormat,fd); + mput(length(h.label_mode),characterFormat,fd); // label_mode + mput(ascii(h.label_mode),characterFormat,fd); + mput(h.orientation,characterFormat,fd) // orientation + mput(bool2s(h.z_component=="on"),characterFormat,fd) // z_component + mput(bool2s(h.auto_orientation=="on"),characterFormat,fd) // auto_orientation + mput(bool2s(h.interp_mode=="on"),characterFormat,fd) // interp_mode + mput(length(ascii(h.display_function)),stringFormat,fd); // display_function + mput(h.font_foreground, "il", fd) ; // font_foreground + mput(h.foreground,"il",fd) // foreground + mput(h.background, "il", fd) ; // background + mput(bool2s(h.mark_mode=="on"),characterFormat,fd) // mark_mode + mput(h.mark_style,characterFormat,fd) // mark_style + mput(ascii(part(h.mark_size_unit,1)),characterFormat,fd) // mark_size_unit + mput(h.mark_size,characterFormat,fd) // mark_size + mput(h.mark_foreground,"il",fd) // mark_foreground + mput(h.mark_background,"il",fd) // mark_background + user_data=h.user_data;save(fd,user_data) // user_data + mput(length(h.tag),"c",fd); // tag + mput(ascii(h.tag),"c",fd); + + case "Plot3d"; + mput(length(h.type),characterFormat,fd);mput(ascii(h.type),characterFormat,fd); // type + mput(bool2s(h.visible=="on"),characterFormat,fd) // visible + mput(bool2s(h.surface_mode=="on"),characterFormat,fd) // surface_mode + mput(h.foreground,"il",fd) // foreground + mput(h.thickness,"sl",fd) // thickness + mput(bool2s(h.mark_mode=="on"),characterFormat,fd) // mark_mode + mput(h.mark_style,characterFormat,fd) // mark_style + mput(h.mark_size,characterFormat,fd) // mark_size + mput(ascii(part(h.mark_size_unit,1)),characterFormat,fd) // mark_size_unit + mput(h.mark_foreground,"il",fd) // mark_foreground + mput(h.mark_background,"il",fd) // mark_background + mput(h.color_mode,"il",fd) // color_mode + mput(h.color_flag,"il",fd) // color_flag + x=h.data.x;sz=size(x) + mput(sz,"il",fd) // data.x + mput(x,"dl",fd) + y=h.data.y;sz=size(y) + mput(sz,"il",fd) // data.y + mput(y,"dl",fd) + z=h.data.z;sz=size(z) + mput(sz,"il",fd) // data.z + mput(z,"dl",fd) + if or(h.color_flag==[2 5]) then + clr=h.data.color;sz=size(clr) + mput(sz,"il",fd) // data.color + mput(clr,"il",fd) + end + mput(h.hiddencolor,"il",fd) // hidden_color + mput(length(h.clip_state),characterFormat,fd); // clip_state + mput(ascii(h.clip_state),characterFormat,fd); + if h.clip_state=="on" then + mput(h.clip_box,"dl",fd) // clip_box + end + user_data=h.user_data;save(fd,user_data) // user_data + + case "Fac3d"; + mput(length(h.type),characterFormat,fd);mput(ascii(h.type),characterFormat,fd) ; // type + mput(bool2s(h.visible=="on"),characterFormat,fd) ; // visible + mput(bool2s(h.surface_mode=="on"),characterFormat,fd) // surface_mode + mput(h.foreground,"il",fd) // foreground + mput(h.thickness,"sl",fd) // thickness + mput(bool2s(h.mark_mode=="on"),characterFormat,fd) // mark_mode + mput(h.mark_style,characterFormat,fd) // mark_style + mput(h.mark_size,characterFormat,fd) // mark_size + mput(ascii(part(h.mark_size_unit,1)),characterFormat,fd) // mark_size_unit + mput(h.mark_foreground,"il",fd) // mark_foreground + mput(h.mark_background,"il",fd) // mark_background + mput(h.color_mode,"il",fd) // color_mode + mput(h.color_flag,"il",fd) // color_flag + x=h.data.x;sz=size(x) + mput(sz,"il",fd) // data.x + mput(x,"dl",fd) + y=h.data.y;sz=size(y) + mput(sz,"il",fd) // data.y + mput(y,"dl",fd) + z=h.data.z;sz=size(z) + mput(sz,"il",fd) // data.z + mput(z,"dl",fd) + if h.color_flag >=2 then + clr=h.data.color;sz=size(clr) // data.color + mput(sz,"il",fd) + mput(clr,"il",fd) + mput(ascii(part(h.cdata_mapping,1)),characterFormat,fd) ; // cdata_mapping + end + mput(h.hiddencolor,"il",fd) // hidden_color + mput(length(h.clip_state),characterFormat,fd); // clip_state + mput(ascii(h.clip_state),characterFormat,fd); + if h.clip_state=="on" then + mput(h.clip_box,"dl",fd) // clip_box + end + user_data=h.user_data;save(fd,user_data) // user_data + + case "Compound" + mput(length(h.type),characterFormat,fd);mput(ascii(h.type),characterFormat,fd); // type + + // children + children=h.children + n=size(children,"*") + mput(n,"il",fd) + for k=1:n + save_graphichandle(children(k),fd) + end + mput( bool2s( h.visible=="on"), characterFormat, fd ) ; // visible + + user_data=h.user_data;save(fd,user_data) // user_data + + case "Rectangle" + mput(length(h.type),characterFormat,fd);mput(ascii(h.type),characterFormat,fd); // type + mput(bool2s(h.visible=="on"),characterFormat,fd) // visible + mput(h.thickness,"sl",fd) // thickness + mput(bool2s(h.mark_mode=="on"),characterFormat,fd) // mark_mode + mput(h.mark_style,characterFormat,fd) // mark_style + mput(h.mark_size,characterFormat,fd) // mark_size + mput(ascii(part(h.mark_size_unit,1)),characterFormat,fd) // mark_size_unit + mput(h.mark_foreground,"il",fd) // mark_foreground + mput(h.mark_background,"il",fd) // mark_background + mput(bool2s(h.line_mode=="on"),characterFormat,fd) // line_mode + mput(h.line_style,characterFormat,fd) // line_style + mput(bool2s(h.fill_mode=="on"),characterFormat,fd) // fill_mode + mput(h.foreground,"il",fd) // foreground + mput(h.background,"il",fd) // background + mput(size(h.data, "*"), "il", fd); // data + mput(h.data,"dl",fd); + mput(length(h.clip_state),characterFormat,fd); // clip_state + mput(ascii(h.clip_state),characterFormat,fd); + if h.clip_state=="on" then + mput(h.clip_box,"dl",fd) // clip_box + end + + user_data=h.user_data;save(fd,user_data) ; // user_data + + case "Arc" + mput(length(h.type),characterFormat,fd);mput(ascii(h.type),characterFormat,fd); // type + mput(bool2s(h.visible=="on"),characterFormat,fd) // visible + mput(h.thickness,"sl",fd) // thickness + mput(h.line_style,characterFormat,fd) // line_style + mput(bool2s(h.line_mode=="on"),characterFormat,fd) ;// line_mode + mput(bool2s(h.fill_mode=="on"),characterFormat,fd) // fill_mode + mput(h.foreground,"il",fd) // foreground + mput(h.background,"il",fd) ; // background + mput(size(h.data, "*"), "il", fd); // data + mput(h.data,"dl",fd); + mput(length(h.arc_drawing_method),characterFormat,fd); // arc_drawing_method + mput(ascii(h.arc_drawing_method),characterFormat,fd); + mput(length(h.clip_state),characterFormat,fd); // clip_state + mput(ascii(h.clip_state),characterFormat,fd); + if h.clip_state=="on" then + mput(h.clip_box,"dl",fd) // clip_box + end + user_data=h.user_data;save(fd,user_data) // user_data + + case "Champ" + mput(length(h.type),characterFormat,fd);mput(ascii(h.type),characterFormat,fd); // type + mput(bool2s(h.visible=="on"),characterFormat,fd) // visible + x=h.data.x;sz=size(x) + mput(sz,"il",fd) // data.x + mput(x,"dl",fd) + y=h.data.y;sz=size(y) + mput(sz,"il",fd) // data.y + mput(y,"dl",fd) + fx=h.data.fx;sz=size(fx) + mput(sz,"il",fd) // data.fx + mput(fx,"dl",fd) + fy=h.data.fy;sz=size(fy) + mput(sz,"il",fd) // data.fz + mput(fy,"dl",fd) + mput(h.line_style,characterFormat,fd) // line_style + mput(h.thickness,"sl",fd) // thickness + mput(bool2s(h.colored=="on"),characterFormat,fd) // colored + mput(h.arrow_size,"dl",fd) // arrow_size + mput(length(h.clip_state),characterFormat,fd); // clip_state + mput(ascii(h.clip_state),characterFormat,fd); + if h.clip_state=="on" then + mput(h.clip_box,"dl",fd) // clip_box + end + user_data=h.user_data;save(fd,user_data) // user_data + + case "Segs" + mput(length(h.type),characterFormat,fd);mput(ascii(h.type),characterFormat,fd); // type + mput(bool2s(h.visible=="on"),characterFormat,fd) // visible + mput(size(h.data),"il",fd);mput(h.data,"dl",fd) // data + mput(bool2s(h.line_mode=="on"),characterFormat,fd) // line_mode + mput(h.line_style,characterFormat,fd) // line_style + mput(h.thickness,"sl",fd) // thickness + mput(h.arrow_size,"dl",fd) // arrow_size + mput(size(h.segs_color,"*"),"il",fd); // segs_color + mput(h.segs_color,"il",fd) + mput(bool2s(h.mark_mode=="on"),characterFormat,fd) // mark_mode + mput(h.mark_style,characterFormat,fd) // mark_style + mput(h.mark_size,characterFormat,fd) // mark_size + mput(ascii(part(h.mark_size_unit,1)),characterFormat,fd) // mark_size_unit + mput(h.mark_foreground,"il",fd) // mark_foreground + mput(h.mark_background,"il",fd) // mark_background + mput(length(h.clip_state),characterFormat,fd); // clip_state + mput(ascii(h.clip_state),characterFormat,fd); // clip_state + if h.clip_state=="on" then + mput(h.clip_box,"dl",fd) // clip_box + end + user_data=h.user_data;save(fd,user_data) // user_data + + case "Grayplot" + mput(length(h.type),characterFormat,fd);mput(ascii(h.type),characterFormat,fd); // type + mput(bool2s(h.visible=="on"),characterFormat,fd) // visible + x=h.data.x;sz=size(x) + mput(sz,"il",fd) // data.x + mput(x,"dl",fd) + y=h.data.y;sz=size(y) + mput(sz,"il",fd) // data.y + mput(y,"dl",fd) + z=h.data.z;sz=size(z) + mput(sz,"il",fd) // data.z + mput(z,"dl",fd) + mput(length(h.data_mapping),characterFormat,fd); // data_mapping + mput(ascii(h.data_mapping),characterFormat,fd); + mput(length(h.clip_state),characterFormat,fd); // clip_state + mput(ascii(h.clip_state),characterFormat,fd); + if h.clip_state=="on" then + mput(h.clip_box,"dl",fd) // clip_box + end + user_data=h.user_data;save(fd,user_data) // user_data + + case "Matplot" + mput(length(h.type),characterFormat,fd);mput(ascii(h.type),characterFormat,fd); // type + mput(bool2s(h.visible=="on"),characterFormat,fd) // visible + mput(size(h.data),"il",fd);mput(h.data,"dl",fd) // datat + // mput(length(h.data_mapping),characterFormat,fd);mput(ascii(h.data_mapping),characterFormat,fd); + mput(length(h.clip_state),characterFormat,fd); // clip_state + mput(ascii(h.clip_state),characterFormat,fd); + if h.clip_state=="on" then + mput(h.clip_box,"dl",fd) // clip_box + end + user_data=h.user_data;save(fd,user_data) // user_data + + case "Fec" + mput(length(h.type),characterFormat,fd);mput(ascii(h.type),characterFormat,fd); // type + mput(bool2s(h.visible=="on"),characterFormat,fd) // visible + mput(size(h.data),"il",fd);mput(h.data,"dl",fd) // data + mput(size(h.triangles),"il",fd);mput(h.triangles,"dl",fd) // triangles + mput(h.z_bounds,"dl",fd); // z_bounds + mput(h.color_range,"dl",fd); // color_range + mput(h.outside_colors,"dl",fd); // outside_colors + mput(bool2s(h.line_mode=="on"),characterFormat,fd) // line_mode + mput(h.foreground,"il",fd) // foreground + mput(length(h.clip_state),characterFormat,fd); // clip_state + mput(ascii(h.clip_state),characterFormat,fd); + if h.clip_state=="on" then + mput(h.clip_box,"dl",fd) // clip_box + end + user_data=h.user_data;save(fd,user_data) // user_data + + case "Legend" + mput(length(h.type),characterFormat,fd);mput(ascii(h.type),characterFormat,fd); //type + mput(bool2s(h.visible=="on"),characterFormat,fd) // visible + save_text_vector(h.text,fd); // text + mput(h.font_style,characterFormat,fd) // font_style + mput(h.font_size,characterFormat,fd) // font_size + mput(h.font_color,"il",fd) // font_color + mput(bool2s(h.fractional_font=="on"),characterFormat,fd) // fractional_font + //replace links by a path relative to the parent axes + links=h.links;nlegends=size(links,"*"); + mput(nlegends,characterFormat,fd) + for kl=1:nlegends + p=get_entity_path(links(kl)) + mput(size(p,"*"),"il",fd) + mput(p,"il",fd) + end + mput(length(h.legend_location),characterFormat,fd);mput(ascii(h.legend_location),characterFormat,fd); //legend_location + mput(h.position,"dl",fd); + mput(bool2s(h.line_mode=="on"),characterFormat,fd) // line_mode + mput(h.thickness,"sl",fd) // thickness + mput(h.foreground,"il",fd) // foreground + mput(bool2s(h.fill_mode=="on"),characterFormat,fd) // fill_mode + mput(h.background,"il",fd) ; // background + + mput(length(h.clip_state),characterFormat,fd); // clip_state + mput(ascii(h.clip_state),characterFormat,fd); + if h.clip_state=="on" then + mput(h.clip_box,"dl",fd) // clip_box + end + user_data=h.user_data;save(fd,user_data) // user_data + + case "Text" + mput(length(h.type),characterFormat,fd);mput(ascii(h.type),characterFormat,fd); // type + mput(bool2s(h.visible=="on"),characterFormat,fd) // visible + //save_text_vector(h.text,fd) // text + save_text_matrix( h.text, fd ) ; + mput(size(h.data),characterFormat,fd); // data // size could be 2 or 3 + mput(h.data,"dl",fd); + mput(h.text_box,"dl",fd); // text_box + mput(length(h.text_box_mode),characterFormat,fd); + mput(ascii(h.text_box_mode),characterFormat,fd); // text_box_mode + + mput(h.foreground,"il",fd) // foreground + mput(h.font_style,characterFormat,fd) // font_style + mput(h.font_size,characterFormat,fd) // font_size + mput(h.font_angle,"dl",fd) // font_angle + + //adding JB Silvy 28/11/05 + // box drawing + mput( bool2s( h.box == "on" ), characterFormat, fd ) ; // box + mput( bool2s( h.line_mode == "on" ), characterFormat, fd ) ; // line_mode + mput( bool2s( h.fill_mode == "on" ), characterFormat, fd ) ; // fill_mode + + mput( h.font_foreground, "il", fd ) ; // font_foreground + mput( h.background , "il", fd ) ; // background + + mput(length(h.alignment),characterFormat,fd); + mput(ascii(h.alignment),characterFormat,fd) ; // alignment + mput(bool2s(h.fractional_font=="on"),characterFormat,fd) // fractional_font + + mput(length(h.clip_state),characterFormat,fd); // clip_state + mput(ascii(h.clip_state),characterFormat,fd); + if h.clip_state=="on" then + mput(h.clip_box,"dl",fd) // clip_box + end + user_data=h.user_data;save(fd,user_data) // user_data + + case "Axis" + mput(length(h.type),characterFormat,fd);mput(ascii(h.type),characterFormat,fd); // type + mput(bool2s(h.visible=="on"),characterFormat,fd) // visible + mput(length(h.tics_direction),"il",fd); // ticks_direction + mput(ascii(h.tics_direction),characterFormat,fd); + mput(size(h.xtics_coord,"*"),"il",fd); // xtics_coord + mput(h.xtics_coord,"dl",fd) + mput(size(h.ytics_coord,"*"),"il",fd); // ytics_coord + mput(h.ytics_coord,"dl",fd) + mput(h.tics_color,"il",fd) // tics_color + mput(bool2s(h.tics_segment=="on"),characterFormat,fd) // tics_segment + mput(ascii(h.tics_style),characterFormat,fd) // tics_style + mput(h.sub_tics,"il",fd) // sub_tics + save_text_vector(h.tics_labels,fd) // tics_labels + mput(h.labels_font_size,"il",fd) // label_font_size + mput(h.labels_font_color,"il",fd) // labels_font_color + mput(h.labels_font_style,"il",fd) // labels_font_style + mput(bool2s(h.fractional_font=="on"),characterFormat,fd) // fractional_font + mput(length(h.clip_state),characterFormat,fd); // clip_state + mput(ascii(h.clip_state),characterFormat,fd); + if h.clip_state=="on" then + mput(h.clip_box,"dl",fd) // clip_box + end + user_data=h.user_data;save(fd,user_data) // user_data + + case "uimenu" + mput(length(h.type),"c",fd);mput(ascii(h.type),"c",fd); // Type + mput(bool2s(h.enable=="on"),"c",fd); // Enable + mput(size(h.foregroundcolor,"*"),"il",fd); // ForegroundColor (size) + mput(h.foregroundcolor,"dl",fd); // ForegroundColor (data) + mput(length(h.label),"c",fd);mput(ascii(h.label),"c",fd); // Label + mput(bool2s(h.visible=="on"),"c",fd); // Visible + mput(length(h.callback),stringFormat,fd);mput(ascii(h.callback),"c",fd); // Callback + mput(h.callback_type,"il",fd); // Callback Type + mput(length(h.tag),"c",fd);mput(ascii(h.tag),"c",fd); // Tag + mput(bool2s(h.checked=="on"),"c",fd); // Checked + // children + c=h.children; + n=size(c,"*") + mput(n,"il",fd) + for k=n:-1:1 + save_graphichandle(c(k),fd) + end + + case "uicontextmenu" + mput(length(h.type),"c",fd);mput(ascii(h.type),"c",fd); // Type + // children + c=h.children; + n=size(c,"*") + mput(n,"il",fd) + for k=n:-1:1 + save_graphichandle(c(k),fd) + end + + case "uicontrol" + mput(length(h.type),"c",fd);mput(ascii(h.type),"c",fd); // Type + mput(length(h.style),"c",fd);mput(ascii(h.style),"c",fd); // Style + mput(size(h.backgroundcolor,"*"),"il",fd); // BackgroundColor (size) + mput(h.backgroundcolor,"dl",fd); // BackgroundColor (data) + mput(bool2s(h.enable=="on"),"c",fd); // Enable + mput(length(h.fontangle),"c",fd);mput(ascii(h.fontangle),"c",fd); // FontAngle + mput(length(h.fontname),"c",fd);mput(ascii(h.fontname),"c",fd); // FontName + mput(h.fontsize,"dl",fd); // FontSize + mput(length(h.fontunits),"c",fd);mput(ascii(h.fontunits),"c",fd); // FontUnits + mput(length(h.fontweight),"c",fd);mput(ascii(h.fontweight),"c",fd); // FontWeight + mput(size(h.foregroundcolor,"*"),"il",fd); // ForegroundColor (size) + mput(h.foregroundcolor,"dl",fd); // ForegroundColor (data) + mput(length(h.horizontalalignment),"c",fd);mput(ascii(h.horizontalalignment),"c",fd); // HorizontalAlignment + mput(size(h.listboxtop,"*"),"il",fd); // ListboxTop (size) + mput(h.listboxtop,"dl",fd); // ListboxTop (data) + mput(h.max,"dl",fd); // Max + mput(h.min,"dl",fd); // Min + mput(size(h.position,"*"),"il",fd); // Position (size) + mput(h.position,"dl",fd); // Position (data) + mput(length(h.relief),"c",fd);mput(ascii(h.relief),"c",fd); // Relief + mput(size(h.sliderstep,"*"),"il",fd); // SliderStep (size) + mput(h.sliderstep,"dl",fd); // SliderStep (data) + save_text_matrix( h.string, fd ) ; // String + save_text_matrix( h.tooltipstring, fd ) ; // TooltipString + mput(length(h.units),"c",fd);mput(ascii(h.units),"c",fd); // Units + mput(size(h.value,"*"),"il",fd); // Value (size) + mput(h.value,"dl",fd); // Value (data) + mput(length(h.verticalalignment),"c",fd);mput(ascii(h.verticalalignment),"c",fd); // VerticalAlignment + mput(bool2s(h.visible=="on"),"c",fd); // Visible + mput(length(h.callback),stringFormat,fd);mput(ascii(h.callback),"c",fd); // Callback + mput(h.callback_type,"il",fd); // Callback Type + user_data=h.user_data;save(fd,user_data); // Userdata + mput(length(h.tag),"c",fd);mput(ascii(h.tag),"c",fd); // Tag + + else + warning("handle of type "+h.type+" unhandled") + end + +endfunction + +function save_text_vector(t,fd) + t=ascii(strcat(t,ascii(10))); + mput(length(t),"il",fd);mput(t,characterFormat,fd); +endfunction + +// save a text matrix +function save_text_matrix(strMat,fd) + // put nbRow and nbCol + nbRow = size( strMat, 1 ) ; + nbCol = size( strMat, 2 ) ; + mput( nbRow, "il", fd ) ; + mput( nbCol, "il", fd ) ; + for i = 1:nbRow + for j = 1:nbCol + mput(length(ascii(strMat(i,j))), stringFormat, fd) ; + mput(ascii(strMat(i,j)),characterFormat,fd) ; + end + end +endfunction + +function p=get_entity_path(e) + // given a handle e on an entity this function returns its path relative + // to its parent axes. + // the path is a vector of child index. + p=[];parent=e.parent; + + while %t + pos=find(parent.children==e,1) + if pos==[] then + error(msprintf(_("%s : Invalid entity %s\n"),"save","Legend")) + end + p=[pos p] + if parent.type=="Axes" then break,end + e=parent + parent=e.parent; + end +endfunction diff --git a/modules/graphics/macros/%h_set.bin b/modules/graphics/macros/%h_set.bin Binary files differnew file mode 100755 index 000000000..2596977cf --- /dev/null +++ b/modules/graphics/macros/%h_set.bin diff --git a/modules/graphics/macros/%h_set.sci b/modules/graphics/macros/%h_set.sci new file mode 100755 index 000000000..03b56bc6c --- /dev/null +++ b/modules/graphics/macros/%h_set.sci @@ -0,0 +1,26 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function hdl=%h_set(varargin) + if (lstsize(varargin) == 3) + hdl = varargin(1) + str = varargin(2) + val = varargin(3) + for i=1:size(hdl,"*") + set(hdl(i),str,val) + end, + + elseif (lstsize(varargin) == 2) + str = varargin(1) + val = varargin(2) + hdl=[] + set(str,val) + end, +endfunction + + diff --git a/modules/graphics/macros/ResetFigureDDM.bin b/modules/graphics/macros/ResetFigureDDM.bin Binary files differnew file mode 100755 index 000000000..866bfa90b --- /dev/null +++ b/modules/graphics/macros/ResetFigureDDM.bin diff --git a/modules/graphics/macros/ResetFigureDDM.sci b/modules/graphics/macros/ResetFigureDDM.sci new file mode 100755 index 000000000..dbec6b51b --- /dev/null +++ b/modules/graphics/macros/ResetFigureDDM.sci @@ -0,0 +1,25 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2004-2006 - INRIA - Fabrice Leray +// Copyright (C) 2008 - INRIA - Jean-Baptiste Silvy +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +// Reset the Default Drawing Mode (DDM) of the figure +// immediate_drawing is set to its input value. +// This function is intended to be private. +function ResetFigureDDM(cur_figure, cur_draw_mode) + + if type(cur_figure) == 9 + if cur_figure.type == "Figure" + cur_figure.immediate_drawing = cur_draw_mode; + else + warning(msprintf(gettext("%s: Wrong type for input argument #%d: figure graphic handle expected.\n"),"ResetFigureDDM",1)); + return; + end + end + +endfunction diff --git a/modules/graphics/macros/Sfgrayplot.bin b/modules/graphics/macros/Sfgrayplot.bin Binary files differnew file mode 100755 index 000000000..7c82e9284 --- /dev/null +++ b/modules/graphics/macros/Sfgrayplot.bin diff --git a/modules/graphics/macros/Sfgrayplot.sci b/modules/graphics/macros/Sfgrayplot.sci new file mode 100755 index 000000000..d283299ab --- /dev/null +++ b/modules/graphics/macros/Sfgrayplot.sci @@ -0,0 +1,67 @@ +function []=Sfgrayplot(x, y, f, strf, rect, nax, zminmax, colminmax, mesh, colout) + + // PURPOSE + // Like fgrayplot but the function fec is used to smooth the + // result assuming that the underlying function is linear on + // a set of triangles built from the grid (here with n1=5, n2=3): + // _____________ + // | /| /| /| /| + // |/_|/_|/_|/_| + // | /| /| /| /| + // |/_|/_|/_|/_| + // + // Copyright INRIA + // rewritten by Bruno Pincon (17 april 05) (based of my modifs of Sgrayplot) + + [lhs,rhs]=argn() + if rhs == 0 then // demo + deff("[z]=Surf(x,y)","z=x.^3+y"); + f=gcf(); + f.color_map = jetcolormap(64); + f.immediate_drawing = "off"; + colorbar(-2,2); + Sfgrayplot(-1:0.1:1,-1:0.1:1,Surf,strf="031",rect=[-1,-1,1,1]); + xtitle("$\Large f(x,y)=x^3+y$"); + f.immediate_drawing = "on"; + return + elseif rhs < 3 then + error(msprintf(gettext("%s: Wrong number of input arguments: %d to %d expected.\n"), "Sfgrayplot", 3, 10)); + end + + // some checks + if ~(type(x)==1 & isreal(x)) then + error(msprintf(gettext("%s: Input argument #%d must be real.\n"), "Sfgrayplot", 1)) + end + if ~(type(y)==1 & isreal(y)) then + error(msprintf(gettext("%s: Input argument #%d must be real.\n"), "Sfgrayplot", 2)) + end + if type(f)~=11 & type(f)~=13 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: function expected.\n"), "Sfgrayplot", 3)); + end + + p = length(x); q = length(y); + + // parsing the optional args + opt_arg_list = ["strf", "rect","nax","zminmax", "colminmax", "mesh", "colout"]; + opt_arg_seq = []; + for opt_arg = opt_arg_list + if exists(opt_arg,"local") then + opt_arg_seq = opt_arg_seq +","+ opt_arg + "=" + opt_arg; + end + end + + // build the data for fec + z = feval(x,y,f); + [noe_x,noe_y] = ndgrid(x,y) + nbtri = 2*(p-1)*(q-1) + num = (1:p*(q-1))'; num(p*(1:q-1)) = []; num1 = num+1 + connect =[(1:nbtri)' , [num num1 num+p;... + num1 num1+p num+p] , zeros(nbtri,1)] + + // then plot + if opt_arg_seq == [] then + fec(noe_x,noe_y,connect,z); + else + execstr("fec(noe_x,noe_y,connect,z"+opt_arg_seq+")"); + end +endfunction diff --git a/modules/graphics/macros/Sgrayplot.bin b/modules/graphics/macros/Sgrayplot.bin Binary files differnew file mode 100755 index 000000000..b69b43e7b --- /dev/null +++ b/modules/graphics/macros/Sgrayplot.bin diff --git a/modules/graphics/macros/Sgrayplot.sci b/modules/graphics/macros/Sgrayplot.sci new file mode 100755 index 000000000..792f9fe43 --- /dev/null +++ b/modules/graphics/macros/Sgrayplot.sci @@ -0,0 +1,80 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// Copyright (C) Bruno Pincon +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function []=Sgrayplot(x,y,z, strf, rect, nax, zminmax, colminmax, mesh, colout) + // + // PURPOSE + // Like grayplot but the function fec is used to smooth the + // result assuming that the underlying function is linear on + // a set of triangles built from the grid (here with n1=5, n2=3): + // _____________ + // | /| /| /| /| + // |/_|/_|/_|/_| + // | /| /| /| /| + // |/_|/_|/_|/_| + // + // Copyright INRIA + // Modified by Bruno Pincon (14 oct 04) to have named argument working + // Some new modifs (Bruno Pincon, Feb 2005, demo + some checking + cleaning + add + // mesh and colout optional args) + + [lhs,rhs] = argn(); + + if rhs == 0 then // demo + + t=-%pi:0.1:%pi; + m=sin(t)'*cos(t) + f=gcf(); + f.color_map = jetcolormap(64); + f.immediate_drawing = "off"; + colorbar(-1,1); + Sgrayplot(t,t,m,strf="041",zminmax=[-1,1]); + xtitle("Sgrayplot demo f(x,y)=sin(x)*cos(y) on [-pi,pi]x[-pi,pi]"); + f.immediate_drawing = "on"; + return + + elseif rhs < 3 then + error(msprintf(gettext("%s: Wrong number of input arguments: At least %d expected.\n"),"Sgrayplot",3)); + end + + // some checks + if ~(type(x)==1 & isreal(x) & type(y)==1 & isreal(y) & type(z)==1 & isreal(z)) then + error(msprintf(gettext("%s: Wrong type for input argument(s): Arguments #%d, #%d and #%d must be real.\n"), "Sgrayplot",1,2,3)); + end + nx = length(x); ny = length(y); [p,q] = size(z) + if p ~= nx then + error(msprintf(gettext("%s: Wrong size for input arguments #%d and #%d: The number of rows of argument #%d must be equal to the size of argument #%d.\n"),"Sgrayplot", 1, 3, 3, 1)); + elseif q~=ny then + error(msprintf(gettext("%s: Wrong size for input arguments #%d and #%d: The number of columns of argument #%d must be equal to the size of argument #%d.\n"),"Sgrayplot", 2, 3, 3, 2)); + end + + // parsing the optional args + opt_arg_list = ["strf", "rect","nax","zminmax", "colminmax", "mesh", "colout"] + opt_arg_seq = [] + for opt_arg = opt_arg_list + if exists(opt_arg,"local") then + opt_arg_seq = opt_arg_seq +","+ opt_arg + "=" + opt_arg + end + end + + // build the data for fec + [noe_x,noe_y] = ndgrid(x,y) + nbtri = 2*(p-1)*(q-1) + num = (1:p*(q-1))'; num(p*(1:q-1)) = []; num1 = num+1 + connect =[(1:nbtri)' , [num num1 num+p;... + num1 num1+p num+p] , zeros(nbtri,1)] + + // then plot + if opt_arg_seq == [] then + fec(noe_x,noe_y,connect,z) + else + execstr("fec(noe_x,noe_y,connect,z"+opt_arg_seq+")") + end +endfunction diff --git a/modules/graphics/macros/TitleLabel.bin b/modules/graphics/macros/TitleLabel.bin Binary files differnew file mode 100755 index 000000000..7be867ffe --- /dev/null +++ b/modules/graphics/macros/TitleLabel.bin diff --git a/modules/graphics/macros/TitleLabel.sci b/modules/graphics/macros/TitleLabel.sci new file mode 100755 index 000000000..9438f9ae8 --- /dev/null +++ b/modules/graphics/macros/TitleLabel.sci @@ -0,0 +1,96 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2004-2006 - INRIA - Farid Belahcene +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function TitleLabel(varargin) + // TITLELABEL function + // is used by the functions title, xlabel, ylabel, zlabel + + [lhs,rhs]=argn(0); + + //CurColor = 0; // current color used if no color specified via LineSpec + // nor PropertyName + + ListArg = varargin; + titlelabel = ListArg(1); + ListArg(1) = null(); // remove this parameter from the list + + //detect and set the current axes now: + if type(ListArg(1)) == 9 + hdle = ListArg(1); + if (hdle.type == "Axes") + sca(ListArg(1)); + ListArg(1) = null(); // remove this parameter from the list + else + warning(msprintf(gettext("%s: Wrong type for input argument #%d: Axes handle expected.\n"),"TitleLabel",1)); + return; + end + end + + monaxe = gca(); + + nv = size(ListArg); + // detect and set the string now: + if type(ListArg(1))== 10 & modulo(nv,2) == 1 then + st = ListArg(1); + execstr("monaxe."+ titlelabel +".text"+"=st") + ListArg(1) = null(); + nv=nv-1 + else + error(msprintf(gettext("%s: Wrong size or type for input argument #%d: A string expected.\n"),"TitleLabel",1)); + end + + T=[]; + + //given_data = 2; + + for k=1:nv + T(k,1) = type(ListArg(k)) + end + + given_data = 0; + P1 = 0; + + for i=1:nv + if T(i) == 1 + given_data = given_data +1; + else + P1 = i; // Position of the first PropertyName field + break; + end + end + + + // delay the drawing commands + // smart drawlater + current_figure=gcf(); + cur_draw_mode = current_figure.immediate_drawing; + current_figure.immediate_drawing = "off"; + + /////////////////////////////////// + //Global Property treatment // + //PropertyName and PropertyValue // + /////////////////////////////////// + + // P1 is the position of the first PropertyName field. + Property = P1; + + current_titlelabel=get(monaxe,titlelabel) + + while ((Property <> 0) & (Property <= nv-1)) + setTitleLabelProperty(ListArg(Property),ListArg(Property+1),current_titlelabel,current_figure,cur_draw_mode) + //setLabelProperty(ListArg(Property),ListArg(Property+1),monaxe.title,current_figure,cur_draw_mode) + Property = Property+2; + end + + //postponed drawings are done now ! + // smart drawnow + ResetFigureDDM(current_figure, cur_draw_mode); + + +endfunction + diff --git a/modules/graphics/macros/autumncolormap.bin b/modules/graphics/macros/autumncolormap.bin Binary files differnew file mode 100755 index 000000000..896935b47 --- /dev/null +++ b/modules/graphics/macros/autumncolormap.bin diff --git a/modules/graphics/macros/autumncolormap.sci b/modules/graphics/macros/autumncolormap.sci new file mode 100755 index 000000000..0ab5b358c --- /dev/null +++ b/modules/graphics/macros/autumncolormap.sci @@ -0,0 +1,35 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Pierre MARECHAL <pierre.marechal@scilab.org> +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +//autumncolormap : Orange to yellow. +function cmap = autumncolormap(varargin) + + // Check number of input argument + if size(varargin)<>1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "autumncolormap", 1)); + end + n=varargin(1); + + // Check type of input argument + // Check if input argument is real + if typeof(n)<>"constant" | ~isreal(n) then + error(msprintf(gettext("%s: Wrong type for input argument #%d: a real scalar expected.\n"), "autumncolormap", 1)); + end + + // Check size of input argument + if size(n,"*")<>1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: a real scalar expected.\n"), "autumncolormap", 1)); + end + + red = ones(n,1); + green = (0:n-1)'/max(n-1,1); + blue = zeros(n,1); + + cmap = [red green blue]; + +endfunction diff --git a/modules/graphics/macros/bar.bin b/modules/graphics/macros/bar.bin Binary files differnew file mode 100755 index 000000000..f7a3119d8 --- /dev/null +++ b/modules/graphics/macros/bar.bin diff --git a/modules/graphics/macros/bar.sci b/modules/graphics/macros/bar.sci new file mode 100755 index 000000000..3c5b9d922 --- /dev/null +++ b/modules/graphics/macros/bar.sci @@ -0,0 +1,255 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2005 - INRIA - Farid Belahcene +// Copyright (C) 2012 - Michael Baudin +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +function bar(varargin) + // bar(x,y,width,style,color) + // This function ... + // + // Input : + // x : a real scalar or a vector + // y : a real sclar, or a vector + // width : a double, the bar width, it's the percentage (0<width<1) of the width max of one bar which is wanted (default: width=0.8) + // style : a string 'grouped' or 'stacked' (default: style='grouped') + + if size(varargin)<1 | size(varargin)>5 then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d to %d expected.\n"), "bar", 1, 5)); + end + + styletab=["grouped","stacked"] + COLORBOOL=%f + STYLE="grouped" + + //Check RHS argument + ListArg = varargin; + + //detect and set the current axes now: + if type(ListArg(1)) == 9 + hdle = ListArg(1); + if (hdle.type == "Axes") + sca(ListArg(1)); + ListArg(1) = null(); // remove this parameter from the list + else + warning(msprintf(gettext("%s: Wrong type for input argument #%d: Axes handle expected.\n"),"bar",1)); + return; + end + end + + if size(ListArg) == 4 then + COLOR=ListArg(4); + if type(COLOR) <> 10 then + error(msprintf(gettext("%s: Wrong type for input arguments #%d: A string expected.\n"),"bar",4)); + end + end + if size(ListArg) == 5 then + STYLE=ListArg(5); + if type(STYLE) <> 10 then + error(msprintf(gettext("%s: Wrong type for input arguments #%d: A string expected.\n"),"bar",5)); + end + end + nv = size(ListArg) + + T=[]; + + // Number of inputs arguments < 6 + if size(ListArg)>5 then + error(msprintf(gettext("%s: Wrong number of input arguments: %d to %d expected.\n"),"bar",1,5)); + end + + for k=1:nv + T(k) = type(ListArg(k)) + end + + argdb=find(T==1) + argstr=find(T==10) + + if size(argdb,"*")<> argdb($) then + error(msprintf(gettext("%s: Wrong type for input arguments: Matrix expected for %s, %s and %s.\n"),"bar", "x", "y", "width")); + end + + if size(argstr,"*") <> nv-argdb($) then + error(msprintf(gettext("%s: Wrong type for input arguments: String expected for %s and %s.\n"),"bar", "color", "style")); + end + + //set the double argument : x,y,width + // bar(y,...) + if size(argdb,"*")==1 + Y=ListArg(1) + WIDTH=0.8 + if or(size(Y)==1) then + Y=Y(:) + end + X=1:size(Y,1) + end + + if size(argdb,"*")==2 + if size(ListArg(2),"*")==1 then + // bar(x,y,...) + if size(ListArg(1),"*")==1 then + WIDTH=0.8 + X=ListArg(1) + Y=ListArg(2) + else + //bar(y,width,...) + WIDTH=ListArg(2) + Y=ListArg(1) + if or(size(Y)==1) then + Y=Y(:) + end + X=1:size(Y,1) + end + else + // bar(x,y,...) + X=ListArg(1) + Y=ListArg(2) + if or(size(X)==1) then + if size(X,"*")<>1 then // X is a vector + if or(size(Y)==1) then // Y is a vector + Y=Y(:) + end + if size(X,"*")<>size(Y,1) // Y is a matrix + error(msprintf(gettext("%s: Wrong size for input arguments #%d and #%d: The number of rows of argument #%d must be equal to the size of argument #%d.\n"),"bar",1, 2, 2, 1)); + end + elseif size(Y,1)>1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: A scalar or a column vector expected.\n"),"bar",2)); + end + else + error(msprintf(gettext("%s: Wrong type for input argument #%d: A scalar or a vector expected.\n"),"bar",1)); + end + WIDTH=0.8 + end + end + + // bar(x,y,width,...) + if size(argdb,"*")==3 + X=ListArg(1) + Y=ListArg(2) + WIDTH=ListArg(3) + if size(WIDTH,"*")<>1 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: A scalar expected.\n"),"bar",3)); + elseif or(size(X)==1) then + if size(X,"*")<>1 then // X is a vector + if or(size(Y)==1) then // Y is a vector + Y=Y(:) + end + if size(X,"*")<>size(Y,1) + error(msprintf(gettext("%s: Wrong size for input arguments #%d and #%d: The number of rows of argument #%d must be equal to the size of argument #%d.\n"),"bar",1, 2, 2, 1)) + end + elseif size(Y,1)>1 then + error(msprintf(gettext("%s: Wrong size for input arguments #%d: A scalar or a column vector expected.\n"),"bar",2)); + end + else + error(msprintf(gettext("%s: Wrong type for input argument #%d: A scalar or a vector expected.\n"),"bar",1)); + end + end + X=X(:) + + // set the string argument + for i=1:size(argstr,"*") + // bar(...,style) + if or(ListArg(argstr(i))==styletab) then + STYLE=ListArg(argstr(i)) + else + COLOR=ListArg(argstr(i)) + COLORBOOL=%t + end + end + + // drawlater + curFig = gcf(); + immediate_drawing = curFig.immediate_drawing; + + wmode = warning("query"); + warning("off"); // See bug #13579 (some bar() calling sequences will lead to a plot() warning) + if COLORBOOL + plot(X,Y,COLOR); // plot manages immediate_drawing property itself to avoid flickering + else + plot(X,Y); // plot manages immediate_drawing property itself to avoid flickering + end + warning(wmode); + + curFig.immediate_drawing = "off"; + + bar_number=size(Y,2) + if size(X,"*")>1 then + Xtemp=gsort(X,"r","i") + inter=Xtemp(2)-Xtemp(1) + for i=2:size(Xtemp,"*")-1 + inter=min(Xtemp(i+1)-Xtemp(i),inter) + end + if bar_number>1 + inter=inter*0.9 + end + else + Xtemp=X + inter=1 + end + + wmax=inter/bar_number + + y_shift=zeros(size(X,"*"),1) + + bar_number= bar_number + + e=gce() + a=gca() + + a.sub_ticks(1) = 0; // bar (barh => a.sub_ticks(2) = 0;) + + for i=bar_number:-1:1 + + ei = e.children(i); + + // Perform x_shift + if modulo(bar_number,2)==0 then + x_shift=(-i+bar_number/2)*wmax+wmax/2 + elseif modulo(bar_number,2)==1 then + x_shift=(-i+1+floor(bar_number/2))*wmax + end + + // Perform y_shift + if i==bar_number then + y_shift=zeros(size(X,"*"),1) + else + y_shift=Y(:,bar_number-i)+y_shift + end + + // Udate the axes data bounds + if STYLE=="grouped" + xmin=min(a.data_bounds(1,1),min(X)+x_shift-0.4*wmax) + ymin=min(a.data_bounds(1,2),0,min(y_shift+Y(:,bar_number-i+1))) + xmax=max(a.data_bounds(2,1),max(X)+x_shift+0.4*wmax) + ymax=max(a.data_bounds(2,2),0) + ei.x_shift=x_shift*ones(size(X,"*"),1) + else + wmax=inter + xmin=min(a.data_bounds(1,1),min(X)-0.4*wmax) + ymin=min(a.data_bounds(1,2),min(y_shift+Y(:,bar_number-i+1))) + xmax=max(a.data_bounds(2,1),max(X)+0.4*wmax) + ymax=max(a.data_bounds(2,2),max(y_shift+Y(:,bar_number-i+1))) + ei.y_shift=y_shift + end + a.data_bounds=[xmin ymin; xmax ymax] + + a.x_ticks=tlist("ticks",Xtemp,string(Xtemp)) + + w=WIDTH*wmax + + ei.bar_width=w + ei.background=ei.foreground + ei.polyline_style=6; // bar type + ei.background=ei.foreground + ei.foreground = -1; // black by default + ei.line_mode="off"; + end + + // drawnow + curFig.immediate_drawing = immediate_drawing; + +endfunction diff --git a/modules/graphics/macros/barh.bin b/modules/graphics/macros/barh.bin Binary files differnew file mode 100755 index 000000000..c01e62d76 --- /dev/null +++ b/modules/graphics/macros/barh.bin diff --git a/modules/graphics/macros/barh.sci b/modules/graphics/macros/barh.sci new file mode 100755 index 000000000..8d6e43e11 --- /dev/null +++ b/modules/graphics/macros/barh.sci @@ -0,0 +1,281 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2005 - INRIA - Farid Belahcene +// Copyright (C) 2012 - Michael Baudin +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +function barh(varargin) + + // barh(x,y,width,style,color) + // Input : + // x : a scalar or a vector of reals + // y : a sclar, a vector or a matrix of reals + // width : a double, the bar width, it's the percentage (0<width<1) of the max width of one bar which is wanted (default: width=0.8) + // style : a string, 'grouped' or 'stacked' (default: style='grouped') + + if and(size(varargin)<>[1:5]) then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d to %d expected.\n"), "barh", 1, 5)); + end + + styletab=["grouped","stacked"] + COLORBOOL=%f + + // Default values + STYLE="grouped" + WIDTH=0.8 + COLORBOOL=%f + + // Check RHS arguments + ListArg = varargin; + + // Detect and set the current axes now: + if type(ListArg(1)) == 9 + hdle = ListArg(1); + if (hdle.type == "Axes") + sca(ListArg(1)); + ListArg(1) = null(); // remove this parameter from the list + else + warning(msprintf(gettext("%s: Wrong type for input argument #%d: Axes handle expected.\n"),"barh",1)); + return; + end + end + if size(ListArg) == 4 then + COLOR=ListArg(4); + if type(COLOR) <> 10 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: A string expected.\n"),"barh",4)); + end + end + if size(ListArg) == 5 then + STYLE=ListArg(5); + if type(STYLE) <> 10 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: A string expected.\n"),"barh",5)); + end + end + + nv = size(ListArg) + + T=[]; + + for k=1:nv + T(k) = type(ListArg(k)) + end + + argdb=find(T==1) + argstr=find(T==10) + + if size(argdb,"*")<> argdb($) then + error(msprintf(gettext("%s: Wrong type for input arguments: Matrix expected for %s, %s and %s.\n"),"barh", "x", "y", "width")); + end + + if size(argstr,"*") <> nv-argdb($) then + error(msprintf(gettext("%s: Wrong type for input arguments: String expected for %s and %s.\n"),"barh", "color", "style")); + end + + // Set the double argument : x,y,width + // barh(y,...) + if size(argdb,"*")==1 + Y=ListArg(1) + if or(size(Y)==1) then + Y=Y(:) + end + X=1:size(Y,1) + end + + if size(argdb,"*")==2 + if size(ListArg(2),"*")==1 then + // barh(x,y,...) + if size(ListArg(1),"*")==1 then + X=ListArg(1) + Y=ListArg(2) + else + //barh(y,width,...) + WIDTH=ListArg(2) + Y=ListArg(1) + if or(size(Y)==1) then + Y=Y(:) + end + X=1:size(Y,1) + end + else + // barh(x,y,...) + X=ListArg(1) + Y=ListArg(2) + if or(size(X)==1) then + if size(X,"*")<>1 then // X is a vector + if or(size(Y)==1) then // Y is a vector + Y=Y(:) + end + if size(X,"*")<>size(Y,1) + error(msprintf(gettext("%s: Wrong size for input arguments #%d and #%d: The number of rows of argument #%d must be equal to the size of argument #%d.\n"),"bar",1, 2, 2, 1)); + end + elseif size(Y,1)>1 then + error(msprintf(gettext("%s: Wrong size for input arguments #%d: A scalar or a column vector expected.\n"),"bar",2)); + end + else + error(msprintf(gettext("%s: Wrong type for input argument #%d: A scalar or a vector expected.\n"),"barh",1)); + end + end + end + + // barh(x,y,width,...) + if size(argdb,"*")==3 + X=ListArg(1) + Y=ListArg(2) + WIDTH=ListArg(3) + if size(WIDTH,"*")<>1 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: A scalar expected.\n"),"barh",3)); + elseif or(size(X)==1) then + if size(X,"*")<>1 then // X is a vector + if or(size(Y)==1) then // Y is a vector + Y=Y(:) + end + if size(X,"*")<>size(Y,1) + error(msprintf(gettext("%s: Wrong size for input arguments #%d and #%d: The number of rows of argument #%d must be equal to the size of argument #%d.\n"),"bar",1, 2, 2, 1)); + end + elseif size(Y,1)>1 then + error(msprintf(gettext("%s: Wrong size for input arguments #%d: A scalar or a column vector expected.\n"),"bar",2)); + end + else + error(msprintf(gettext("%s: Wrong type for input argument #%d: A scalar or a vector expected.\n"),"barh",1)); + end + end + + X=X(:) + + // Set the string argument + for i=1:size(argstr,"*") + // barh(...,style) + if or(ListArg(argstr(i))==styletab) then + STYLE=ListArg(argstr(i)) + else + COLOR=ListArg(argstr(i)) + COLORBOOL=%t + end + end + + // Verify if there are data bounds which are defined before creation the horizontal bars creation, in order to merge the data bounds + a=gca() + if size(a.children)<>0 then + gca_children_empty=%t + a_data_bounds=a.data_bounds + else + gca_children_empty=%f + end + + //drawlater + curFig = gcf(); + immediate_drawing = curFig.immediate_drawing; + + if COLORBOOL + plot(X,Y,COLOR); // plot manages immediate_drawing property itself to avoid flickering + else + plot(X,Y); // plot manages immediate_drawing property itself to avoid flickering + end + + curFig.immediate_drawing = "off"; + + barh_number=size(Y,2) + + if size(X,"*")>1 then + Xtemp=gsort(X,"r","i") + inter=Xtemp(2)-Xtemp(1) + for i=2:size(Xtemp,"*")-1 + inter=min(Xtemp(i+1)-Xtemp(i),inter) + end + if barh_number>1 + inter=inter*0.9 + end + else + inter=1 + end + + wmax=inter/barh_number + y_shift=zeros(size(X,"*"),1) + bar_number= size(Y,2) + e=gce() + a=gca() + a.sub_ticks(2) = 0 + + for i=bar_number:-1:1 + + ei = e.children(i) + + // Perform x_shift + if modulo(bar_number,2)==0 then + x_shift=(-i+bar_number/2)*wmax+0.4*wmax + elseif modulo(bar_number,2)==1 then + x_shift=(-i+1+floor(bar_number/2))*wmax + end + + // Perform y_shift + if i==bar_number then + y_shift=zeros(size(X,"*"),1) + else + y_shift=Y(:,bar_number-i)+y_shift + end + + // Update axes data bounds + // case 'grouped' + if STYLE=="grouped" + if i <> bar_number then + ymin=min(a.data_bounds(1,1),min(Y(:,bar_number-i+1)),0) + xmin=min(a.data_bounds(1,2),min(X)+x_shift-0.4*wmax) + ymax=max(a.data_bounds(2,1),max(Y(:,bar_number-i+1)),0) + xmax=max(a.data_bounds(2,2),max(X)+x_shift+0.4*wmax) + else + if ~gca_children_empty + ymin=min(min(Y(:,bar_number-i+1)),0) + xmin=min(X)+x_shift-0.4*wmax + ymax=max(max(Y(:,bar_number-i+1)),0) + xmax=max(X)+x_shift+0.4*wmax + else + ymin=min(a_data_bounds(1,1),min(Y(:,bar_number-i+1)),0) + xmin=min(a_data_bounds(1,2),min(X)+x_shift-0.4*wmax) + ymax=max(a_data_bounds(2,1),max(Y(:,bar_number-i+1)),0) + xmax=max(a_data_bounds(2,2),max(X)+x_shift+0.4*wmax) + end + end + a.data_bounds=[ymin xmin;ymax xmax] + ei.x_shift=x_shift*ones(size(X,"*"),1) + else // case 'stacked' + wmax=inter + if i <> bar_number then + ymin=min(a.data_bounds(1,1),min(Y(:,bar_number-i+1)+y_shift)) + xmin=min(a.data_bounds(1,2),0,min(X-0.4*wmax)) + ymax=max(a.data_bounds(2,1),max(Y(:,bar_number-i+1)+y_shift)) + xmax=max(a.data_bounds(2,2),0,max(X+0.4*wmax)) + else + if ~gca_children_empty + ymin=min(Y(:,bar_number-i+1)+y_shift) + xmin=min(0,min(X-0.4*wmax)) + ymax=max(Y(:,bar_number-i+1)+y_shift) + xmax=max(0,max(X+0.4*wmax)) + else + ymin=min(a_data_bounds(1,1),min(Y(:,bar_number-i+1)+y_shift)) + xmin=min(a_data_bounds(1,2),0,min(X-0.4*wmax)) + ymax=max(a_data_bounds(2,1),max(Y(:,bar_number-i+1)+y_shift)) + xmax=max(a_data_bounds(2,2),0,max(X+0.4*wmax)) + end + end + a.data_bounds=[ymin xmin; ymax xmax] + ei.y_shift=y_shift + end + + a.y_ticks=tlist("ticks",Xtemp,string(Xtemp)) + w=WIDTH*wmax + ei.bar_width=w + ei.background=ei.foreground + ei.polyline_style=7; // bar type + ei.background=ei.foreground + ei.foreground = -1; // black by default + ei.line_mode="off"; + end + + //drawnow + curFig.immediate_drawing = immediate_drawing; + +endfunction diff --git a/modules/graphics/macros/barhomogenize.bin b/modules/graphics/macros/barhomogenize.bin Binary files differnew file mode 100755 index 000000000..13f07855f --- /dev/null +++ b/modules/graphics/macros/barhomogenize.bin diff --git a/modules/graphics/macros/barhomogenize.sci b/modules/graphics/macros/barhomogenize.sci new file mode 100755 index 000000000..1a43e97f0 --- /dev/null +++ b/modules/graphics/macros/barhomogenize.sci @@ -0,0 +1,194 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2005 - INRIA - Farid Belahcene +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +function barhomogenize(varargin) + // barhomogenize(a,style,width) + // This function homogenizes the style and the widh of all the bars contained in the axes handle a (default is the handle of the current axes) + // + // Input : + // a : the handle of the axe containing the bares (default: a=gca()) + // style : a string, 'grouped' or 'stacked' (default: style='grouped') + // width : a double, the bar width, it's the percentage (0<width<1) of the width max of one bar which is wanted (default: width=0.8). + + if and(size(varargin)<>[0:3]) then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d to %d expected.\n"), "barhomogenize", 0, 3)); + end + + // Default values + a=gca() + STYLE="grouped" + WIDTH=0.8 + varlist=varargin + pos="v" + + if size(varargin)<>0 then + if or(varlist($)==["h";"v"]) then + pos=varlist($) + varlist($)=null() + end + end + // detect and set the handle axes, the style and the width + if size(varlist) == 1 + if type(varlist(1))==9 + var1=varlist(1) + if var1.type == "Axes" + a=var1 + else + error(msprintf(gettext("%s: Wrong type for input argument #%d: Axes handle expected.\n"),"barhomogenize",1)); + end + varlist(1).type == "Axes" + a=varlist(1) + elseif or(varlist(1) == ["grouped","stacked"]) + STYLE=varlist(1) + elseif type(varlist(1)) == 1 + WIDTH=varlist(1) + else + error(msprintf(gettext("%s: Wrong type for input argument #%d: A handle, a string or a scalar expected.\n"),"barhomogenize", 1)); + end + elseif size(varlist) == 2 then + if type(varlist(1))==9 then + var1=varlist(1) + if (var1.type == "Axes") & or(varlist(2)==["grouped","stacked"]) then + a=var1 + STYLE=varlist(2) + elseif var1.type == "Axes" & type(varlist(2)) == 1 then + a=var1 + WIDTH=varlist(2) + else + error(msprintf(gettext("%s: Wrong type for input argument #%d: A string or a scalar expected.\n"),"barhomogenize", 2)); + end + elseif or(varlist(1) == ["grouped","stacked"]) & (type(varlist(2)) == 1) + STYLE=varlist(1) + WIDTH=varlist(2) + else + error(msprintf(gettext("%s: Wrong type for input arguments #%d and #%d: If argument #%d is a handle or a string, argument #%d must be a string or a scalar.\n"),"barhomogenize", 1, 2, 1, 2)); + end + elseif size(varlist) == 3 + if type(varlist(1))==9 then + var1 = varlist(1) + if var1.type == "Axes" & or(varlist(2)==["grouped","stacked"]) & (type(varlist(3)) == 1) + a=var1 + STYLE=varlist(2) + WIDTH=varlist(3) + end + end + end + + if ~isreal(WIDTH) + error(msprintf(gettext("%s: Wrong type for input argument #%d: A real expected for %s.\n"),"barhomogenize", length(varlist), "width")); + end + + hbarlist=[]; + + for i=1:size(a.children,"*") + hbarlist=searchbarhandle(a.children(i),hbarlist) + end + + + nbarhandle=size(hbarlist,"*") + if hbarlist<>[] then + X=hbarlist(1).data(:,1) + + for i=2:nbarhandle + if or(hbarlist(i).data(:,1) <> X) + error(msprintf(gettext("%s: The bars must have the same x data.\n"),"barhomogenize")); + end + end + else + error(msprintf(gettext("%s: Could not find any bar in the current graphic.\n"),"barhomogenize")); + end + + // Determinate the max width + if size(X,"*")>1 then + Xtemp=gsort(X,"r","i") + inter=Xtemp(2)-Xtemp(1) + for i=2:size(Xtemp,"*")-1 + inter=min(Xtemp(i+1)-Xtemp(i),inter) + end + if nbarhandle>1 + inter=inter*0.9 + end + else + inter=1 + end + + // Perform the x_shift + wmax=inter/nbarhandle + + + for i=1:nbarhandle + if modulo(nbarhandle,2)==0 then + x_shift=(i-1-nbarhandle/2)*wmax+wmax/2 + elseif modulo(nbarhandle,2)==1 then + x_shift=(i-1-floor(nbarhandle/2))*wmax + end + + // Perform the y_shift + if i==1 then + y_shift=zeros(size(X,"*"),1) + else + y_shift=hbarlist(i-1).data(:,2)+y_shift + end + + // Update axes data bounds + if pos=="v" + + if STYLE=="grouped" + a.data_bounds=[min(a.data_bounds(1,1),min(X)+x_shift-wmax/2) min(a.data_bounds(1,2),0,min(hbarlist(i).data(:,2))); max(a.data_bounds(2,1),max(X)+x_shift+wmax/2) max(a.data_bounds(2,2),0,max(hbarlist(i).data(:,2)))] + hbarlist(i).x_shift=x_shift*ones(size(X,"*"),1) + hbarlist(i).y_shift=zeros(size(X,"*"),1) + else + wmax=inter + a.data_bounds=[min(a.data_bounds(1,1),min(X)-wmax/2) min(a.data_bounds(1,2),0,min(y_shift+hbarlist(i).data(:,2))); max(a.data_bounds(2,1),max(X)+wmax/2) max(a.data_bounds(2,2),0,max(y_shift+hbarlist(i).data(:,2)))] + hbarlist(i).x_shift=zeros(size(X,"*"),1) + hbarlist(i).y_shift=y_shift + end + a.auto_ticks(2) = "on"; + a.x_ticks=tlist("ticks",Xtemp,string(Xtemp)) + hbarlist(i).polyline_style=6; + elseif pos=="h" then + if STYLE=="grouped" + a.data_bounds=[min(a.data_bounds(1,2),min(X)+x_shift-wmax/2) min(a.data_bounds(1,1),0,min(hbarlist(i).data(:,2))); max(a.data_bounds(2,2),max(X)+x_shift+wmax/2) max(a.data_bounds(2,1),0,max(hbarlist(i).data(:,2)))] + hbarlist(i).x_shift=x_shift*ones(size(X,"*"),1) + hbarlist(i).y_shift=zeros(size(X,"*"),1) + else + wmax=inter + a.data_bounds=[min(a.data_bounds(1,2),min(X)-wmax/2) min(a.data_bounds(1,1),0,min(y_shift+hbarlist(i).data(:,2))); max(a.data_bounds(2,1),max(y_shift+hbarlist(i).data(:,2))) max(a.data_bounds(2,2),0,max(X+x_shift)+wmax/2)] + hbarlist(i).x_shift=zeros(size(X,"*"),1) + hbarlist(i).y_shift=y_shift + end + a.auto_ticks(1) = "on"; + a.sub_ticks(2) = 0; + a.y_ticks=tlist("ticks",Xtemp,string(Xtemp)) + hbarlist(i).polyline_style=7; + end + + w=WIDTH*wmax + if hbarlist(i).background == -2 + hbarlist(i).background=hbarlist(i).foreground + end + hbarlist(i).bar_width=w + hbarlist(i).line_mode="off"; + end +endfunction + +function hbarlist=searchbarhandle(h,hbarlist) + // This function searches all the bares contained in an axes handle + // output : + // hbarlist: a list which contains the bars handles + if h.type=="Compound" then + for j=1:size(h.children,"*") + hbarlist=searchbarhandle(h.children(j),hbarlist) + end + elseif h.type == "Polyline" then + if h.polyline_style == 6 | h.polyline_style == 7 then + hbarlist = [hbarlist h]; + end + end +endfunction diff --git a/modules/graphics/macros/bonecolormap.bin b/modules/graphics/macros/bonecolormap.bin Binary files differnew file mode 100755 index 000000000..203d8921c --- /dev/null +++ b/modules/graphics/macros/bonecolormap.bin diff --git a/modules/graphics/macros/bonecolormap.sci b/modules/graphics/macros/bonecolormap.sci new file mode 100755 index 000000000..f272a89ac --- /dev/null +++ b/modules/graphics/macros/bonecolormap.sci @@ -0,0 +1,44 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Pierre MARECHAL <pierre.marechal@scilab.org> +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function cmap = bonecolormap(varargin) + + //bonecolormap : Gray colormap with a light blue tone. + + // Check number of input argument + if size(varargin)<>1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "bonecolormap", 1)); + end + n=varargin(1); + + // Check type of input argument + // Check if input argument is real + if typeof(n)<>"constant" | ~isreal(n) then + error(msprintf(gettext("%s: Wrong type for input argument #%d: a real scalar expected.\n"), "bonecolormap", 1)); + end + + // Check size of input argument + if size(n,"*")<>1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: a real scalar expected.\n"), "bonecolormap", 1)); + end + + red_1 = (0:n-1)'/max(n-1,1); + green_1 = (0:n-1)'/max(n-1,1); + blue_1 = (0:n-1)'/max(n-1,1); + + n1 = fix(3/8*n); + n2 = n1; + n3 = n-(n1+n2); + + red_2 = [zeros(n1,1) ; zeros(n2,1) ; (1:n3)'/(n3)]; + green_2 = [zeros(n1,1) ; (1:n2)'/n2 ; ones(n3,1)]; + blue_2 = [(1:n1)'/n1 ; ones(n2,1) ; ones(n3,1)]; + + cmap = [ ((7*red_1) + red_2)/8 ((7*green_1) + green_2)/8 ((7*blue_1) + blue_2)/8 ]; + +endfunction diff --git a/modules/graphics/macros/buildmacros.bat b/modules/graphics/macros/buildmacros.bat new file mode 100755 index 000000000..c4e35ec40 --- /dev/null +++ b/modules/graphics/macros/buildmacros.bat @@ -0,0 +1 @@ +@..\..\..\bin\scilex -nwni -ns -e exec('buildmacros.sce');quit;
\ No newline at end of file diff --git a/modules/graphics/macros/buildmacros.sce b/modules/graphics/macros/buildmacros.sce new file mode 100755 index 000000000..a3f9c837f --- /dev/null +++ b/modules/graphics/macros/buildmacros.sce @@ -0,0 +1,15 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2005 - INRIA - Allan Cornet +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +if (isdef("genlib") == %f) then + exec(SCI+"/modules/functions/scripts/buildmacros/loadgenlib.sce"); +end + +genlib("graphicslib","SCI/modules/graphics/macros",%f,%t); +genlib("datatipslib","SCI/modules/graphics/macros/datatips",%f,%t); diff --git a/modules/graphics/macros/check2dFun.bin b/modules/graphics/macros/check2dFun.bin Binary files differnew file mode 100755 index 000000000..0b86db133 --- /dev/null +++ b/modules/graphics/macros/check2dFun.bin diff --git a/modules/graphics/macros/check2dFun.sci b/modules/graphics/macros/check2dFun.sci new file mode 100755 index 000000000..36d7569f0 --- /dev/null +++ b/modules/graphics/macros/check2dFun.sci @@ -0,0 +1,64 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +function [nArgOut,vectInput]=check2dFun(funName,func,X,current_figure,cur_draw_mode) + + // In this function we determine wether the function 'func' + // has the syntax [y]=func(x) or [x,y]=func(t). + // We also test if the function accepts vector input + // arguments. + // + // This allow to understand in a 2d plot function (plot) + // if the user has requested a 2d plot of a parametric or + // non-parametric curve. + + // First We get the two strings in and out containing the + // names of input and output arguments : + + [out,in,text]=string(func); + + nArgOut=max(size(out)); + nArgIn=max(size(in)) + + if nArgIn~=1 + warning(sprintf("%s : function must accept two input arguments",funName)); + ResetFigureDDM(current_figure, cur_draw_mode) + return; + end + + if nArgOut~=1 & nArgOut~=2 + warning(sprintf("%s : function must have 1 or 2 output arguments",funName)); + ResetFigureDDM(current_figure, cur_draw_mode) + return; + end + + // Now we test if func accepts vector inputs (we test with the X,Y + // pair provided by the user) + + if nArgOut==1; + + ierr=execstr("yf=func(X)","errcatch"); + if ierr==0 + vectInput=(and(size(yf)==size(X))); + else + vectInput=%F; + end + + elseif nArgOut==2 + + // now we test if func accepts vector inputs (as above) + + xf=[];yf=[]; + ierr=execstr("[xf,yf]=func(X)","errcatch"); + + vectInput=(ierr==0 & and([size(xf)==size(yf) ... + size(yf)==size(X)])); + end + +endfunction diff --git a/modules/graphics/macros/checkXYPair.bin b/modules/graphics/macros/checkXYPair.bin Binary files differnew file mode 100755 index 000000000..d83ca9371 --- /dev/null +++ b/modules/graphics/macros/checkXYPair.bin diff --git a/modules/graphics/macros/checkXYPair.sci b/modules/graphics/macros/checkXYPair.sci new file mode 100755 index 000000000..d5b26ab47 --- /dev/null +++ b/modules/graphics/macros/checkXYPair.sci @@ -0,0 +1,165 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +function [X,Y]=checkXYPair(typeOfPlot,x,y,current_figure,cur_draw_mode) + + ok=%F; + + if type(y)==13 // If y is a function + f=y; + if and(size(x)~=1) // then x *must* be a vector + ResetFigureDDM(current_figure, cur_draw_mode) + error(msprintf(gettext("%s: Wrong size for input argument #%d: A vector expected.\n"),typeOfPlot, 2)); + + return; + end + + t=x(:); // to ensure that t is a column vector + + [nArgOut,vectInput]=check2dFun(typeOfPlot,f,t,current_figure,cur_draw_mode); + + if nArgOut==1 + X=t; + if vectInput + Y=f(t); + else + Y=zeros(length(t),1); + for i=1:length(t) + Y(i)=f(t(i)); + end + end + elseif nArgOut==2 + if vectInput + [X,Y]=f(t); + else + X=zeros(length(t),1); + Y=zeros(length(t),1); + for i=1:length(t) + + // CANNOT DO THE SAME WITH X(i) and Y(i) + // instead of xt and yt (scilab parser sees the stuff + // as a comparison) + + [xt,yt]=f(t(i)); + X(i)=xt;Y(i)=yt; + end + end + end + + else // "classical" case + + X=x; + Y=y; + + XScal = isscalar(X); + YScal = isscalar(Y); + + transposeX = %f; + transposeY = %f; + + if size(X,1)==1 & ~XScal, X=X', transposeX = %t; end; // Transpose the row vectors, + if size(Y,1)==1 & ~YScal, Y=Y', transposeY = %t; end; // but no need to transpose scalars. + + if transposeX == ~transposeY then + if transposeX == %t then + warning(_("Transposing row vector X to get compatible dimensions")); + else + warning(_("Transposing row vector Y to get compatible dimensions")); + end + end + + if (size(X)==[0 0]) + ok=%F + ResetFigureDDM(current_figure, cur_draw_mode) + error(msprintf(gettext("%s: Wrong size for input argument #%d: A non empty matrix expected.\n"),typeOfPlot, 2)); + return; + end + + if (size(Y)==[0 0]) + ok=%F + ResetFigureDDM(current_figure, cur_draw_mode) + error(msprintf(gettext("%s: Wrong size for input argument #%d: A non empty matrix expected.\n"),typeOfPlot, 3)); + return; + end + + if and(size(X)==size(Y)) then + // same size for X and Y + ok=%T; + + return; + end + + if (size(X,2)==1) & (size(Y,1)==size(X,1)) + // X is a vector + ok=%T; + + return; + end + if (size(X,2)==1) & (size(Y,2)==size(X,1)) + // X is a column vector and Y has as many columns as X has rows. + // Y cannot be a square matrix here, because it would have fallen in the previous case (above) and returned. + if ~YScal then + warning(_("Transposing data matrix Y to get compatible dimensions")); + Y=Y'; + end + ok=%T; + + return; + end + + if (size(X,2) == 1) & (size(Y,2) == 1) & (size(Y,1) <> size(X,1)) ... + & (size(Y,1) ~= 1) then + // X and Y are vectors but not of same size + ResetFigureDDM(current_figure, cur_draw_mode) + error(msprintf(gettext("%s: Wrong size for input arguments #%d and #%d: Incompatible dimensions.\n"),typeOfPlot, 2, 3)); + return; + end + + // new case : plot(MAT4x4,[1 2 3 4]) HERE Y is a vector and X a matrix + // Here Y is always a column vector + // extend y to be a 4x4 matrix defined as [1 1 1 1;2 2 2 2;3 3 3 3;4 4 4 4] + if or(size(Y) == 1) then + if size(X,1) == size(Y,1) then + y=Y; + elseif size(X,1) == size(Y,2) & ~YScal then + // Y has as many columns as X has rows. Transpose Y to fit X. + warning(_("Transposing data matrix Y to get compatible dimensions")); + y=Y(:); + elseif size(X,2) == size(Y,1) & ~YScal & ~XScal then + // Y has as many rows as X has columns. Transpose X to fit Y. + warning(_("Transposing column vector X to get row vector")); + X=X'; + y=Y(:); + elseif size(X,2) == size(Y,2) then + y=Y; + else + ResetFigureDDM(current_figure, cur_draw_mode) + error(msprintf(gettext("%s: Wrong size for input arguments #%d and #%d: Incompatible dimensions.\n"),typeOfPlot,2, 3)); + return; + end + + // concatenante y in columns + Y=y(:,ones(1,size(X,2))); + + ok=%T; + return; + end + + if ~ok + ResetFigureDDM(current_figure, cur_draw_mode) + error(msprintf(gettext("%s: Wrong size for input arguments #%d and #%d: Incompatible dimensions.\n"),typeOfPlot, 2, 3)); + return; + end + + + end + + // end of checkXYPair +endfunction + diff --git a/modules/graphics/macros/cleanmacros.bat b/modules/graphics/macros/cleanmacros.bat new file mode 100755 index 000000000..c06efbd1f --- /dev/null +++ b/modules/graphics/macros/cleanmacros.bat @@ -0,0 +1,3 @@ +@del /s *.bin 2>NUL +@del /s lib 2>NUL +@del /s names 2>NUL diff --git a/modules/graphics/macros/clf.bin b/modules/graphics/macros/clf.bin Binary files differnew file mode 100755 index 000000000..aeb298df9 --- /dev/null +++ b/modules/graphics/macros/clf.bin diff --git a/modules/graphics/macros/clf.sci b/modules/graphics/macros/clf.sci new file mode 100755 index 000000000..ee46c74f3 --- /dev/null +++ b/modules/graphics/macros/clf.sci @@ -0,0 +1,137 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function clf(varargin) + + nbArg = size(varargin); + + if nbArg==0 then + h=gcf() + job="clear" + elseif nbArg==1 then + if type(varargin(1))==1 then // win num given + num=varargin(1) + + h=[];for k=1:size(num,"*"),h=[h;get_figure_handle(num(k))];end + + job="clear" + elseif type(varargin(1))==9 then // handle given + h=varargin(1);job="clear" + elseif type(varargin(1))==10 then // job given + h=gcf() + job=varargin(1) + end + elseif nbArg==2 then + if type(varargin(1))==1 then // win num given + num=varargin(1) + + h=[];for k=1:size(num,"*"),h=[h;get_figure_handle(num(k))];end + + elseif type(varargin(1))==9 then // handle given + h=varargin(1); + end + job=varargin(2); + else + error(msprintf(gettext("%s: Wrong number of input argument(s): %d to %d expected."), "clf", 0, 2)); + end + + if and(job<>["clear","reset"]) then + error(msprintf(gettext("%s: Wrong value for input argument #%d: ''clear'' or ''reset'' expected."), "clf", nbArg)); + end + + nbHandles = size(h,"*"); + + if nbHandles == 0 then + return; + end + + // check that all the handles are figures + for k=1:nbHandles + curFig = h(k); + if curFig.type <> "Figure" & (curFig.type <> "uicontrol" | curFig.style <> "frame") then + error(msprintf(gettext("%s: Wrong type for input argument #%d: A vector of ''Figure'' or ''Frame'' handle expected."), "clf", 1)); + end + end + + // delete childrens + for k=1:nbHandles + curFig = h(k) + if curFig.type == "uicontrol" then + haveAxes = %F; + for kChild = 1:size(curFig.children, "*") + if curFig.children(kChild).type=="Axes" then + haveAxes = %T; + break + end + end + delete(curFig.children); + if haveAxes then + newaxes(curFig); + end + else + // drawlater + immediateMode = curFig.immediate_drawing; + curFig.immediate_drawing = "off"; + + delete(curFig.children); + + // drawnow + curFig.immediate_drawing = immediateMode; + + curFig.info_message = ""; + end + end + + + // reset figures to default values if needed + if (job == "reset") then + defaultFig = gdf(); + for k = 1: nbHandles + curFig = h(k); + if curFig.type == "uicontrol" then + continue; + end + + // drawlater + immediateMode = curFig.immediate_drawing; + curFig.immediate_drawing = "off"; + + // properties to set + defaultProps=["figure_position", + "axes_size", + "auto_resize", + "viewport", + "figure_name", + "color_map", + "info_message", + "pixel_drawing_mode", + "immediate_drawing", + "background", + "visible", + "rotation_style", + "event_handler", + "event_handler_enable", + "user_data", + "tag"]; + + for i = 1:size(defaultProps,"*") + defaultValue = get(defaultFig, defaultProps(i)); + if (defaultProps(i) <> "figure_position" | defaultValue <> [-1,-1]) then + // don't reset figure pos is defaultValue is [-1,-1] + set(curFig, defaultProps(i), defaultValue); + end + + end + + // drawnow + curFig.immediate_drawing = immediateMode; + end + end + +endfunction + diff --git a/modules/graphics/macros/colorbar.bin b/modules/graphics/macros/colorbar.bin Binary files differnew file mode 100755 index 000000000..7267fa3a3 --- /dev/null +++ b/modules/graphics/macros/colorbar.bin diff --git a/modules/graphics/macros/colorbar.sci b/modules/graphics/macros/colorbar.sci new file mode 100755 index 000000000..684ac1bde --- /dev/null +++ b/modules/graphics/macros/colorbar.sci @@ -0,0 +1,106 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) Bruno Pincon +// Copyright (C) Serge Steer (adaptation to new graphic system) +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function colorbar(umin, umax, colminmax, fmt) + + // PURPOSE + // Draw a colorbar for a plot3d, fec, Sgrayplot, etc... + // + // PARAMETERS + // umin : min value of the plot + // umax : max value of the plot + // colminmax : (optional) a vector with 2 integer components + // the first is the color number (of the current + // colormap) associated with umin + // the second the max color number .... + // default : [1 nb_colors] where nb_colors is + // the number of colors of the current colormap. + // May be useful to deal with a part of the colormap + // (for instance using fec or plot3d) + // fmt : optional, a C format to display colorbar graduations + // + // CAUTION + // this function may be used BEFORE a plot3d, fec, Sgrayplot, ... + // It is important because this function set and change the + // frame for the plot. This way the colorbar is not part of + // the "associated" plot and so is not modified by a zoom or + // a rotation of the plot. + // + // + // EXAMPLES + // see the help page + + // Check number of input argument + [lhs, rhs] = argn(); + if rhs < 2 then + error(msprintf(gettext("%s: Wrong number of input arguments: %d to %d expected.\n"), "colorbar", 2, 4)); + end + nb_grad = 5 + if ~exists("fmt","local") then + fmt="%-5.2g"; + else + if type(fmt)<>10|size(fmt,"*")<>1 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: %s data structure expected.\n"), "colorbar", 4, "string (containing a C format)")); + end + end + + f=gcf(); + if ~exists("colminmax","local") then + nb_colors = size(f.color_map,1) + colminmax = [1 nb_colors] + else + nb_colors = colminmax(2) - colminmax(1) + 1 + end + + //defer the drawing to avoid binking + id=f.immediate_drawing=="on"; + if id then f.immediate_drawing=="off",end + // get current axes and properties + a=gca(); + fg_color=a.foreground + wr=a.axes_bounds; //get the rectangle of the current axes + + // modify the orginal axes to let space for the colorbar + a_pl=a; + a_pl.axes_bounds=[wr(1) , wr(2) , 0.85*wr(3) , wr(4)] + + // create a new axes for the colorbar et set its properties + a_cb=newaxes(); + a_cb.axes_bounds=[wr(1)+0.83*wr(3) , wr(2)+wr(4)*0.2 , 0.2*wr(3) , wr(4)*0.6]; + a_cb.data_bounds=[0 umin;1 umax]; + a_cb.foreground=a.foreground; + a_cb.background=f.background; + a_cb.axes_visible="on"; + a_cb.y_location = "right"; + a_cb.tight_limits ="on"; + + //It is not possible to set no ticks for x (should be fixed) + a_cb.x_ticks=tlist(["ticks","locations","labels"],-1,""); + ytics = linspace(umin, umax, nb_grad); + a_cb.y_ticks=tlist(["ticks","locations","labels"],ytics', " "+msprintf(fmt+"\n",ytics')); + a_cb.auto_ticks = ["off","off","on"]; + a_cb.box = "on"; + a_cb.margins=[0 0.75 0 0]; + + //draw the colorbar + y = linspace(umin,umax,nb_colors) + col=[colminmax(1):colminmax(2)] + Sgrayplot([0 1],y,[col;col],colminmax=colminmax) + + //reset the initial values + sca(a_pl) //current axes + if id then f.immediate_drawing="on",end //drawing mode + +endfunction + + + + + + diff --git a/modules/graphics/macros/colordef.bin b/modules/graphics/macros/colordef.bin Binary files differnew file mode 100755 index 000000000..54dc484d5 --- /dev/null +++ b/modules/graphics/macros/colordef.bin diff --git a/modules/graphics/macros/colordef.sci b/modules/graphics/macros/colordef.sci new file mode 100755 index 000000000..be176fc07 --- /dev/null +++ b/modules/graphics/macros/colordef.sci @@ -0,0 +1,74 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function colordef(varargin) + //Set default color values to display different color schemes + + if size(varargin)<1 | size(varargin)>2 then + error(msprintf(gettext("%s: Wrong number of input arguments: %d to %d expected.\n"), "colordef", 1, 2)); + end + a1=varargin(1); + if size(varargin) == 1 then //Only one argument + if type(a1)<>10 then //the first argument should be a string + error(msprintf(gettext("%s: Wrong type for input argument #%d: String array expected.\n"), "colordef", 1)); + end + f=gdf(); a=gda(); + end + + if size(varargin) == 2 then //Two arguments + a2=varargin(2); + if type(a2)<>10 then //the second argument should be a string + error(msprintf(gettext("%s: Wrong type for input argument #%d: String array expected.\n"), "colordef", 2)); + end + + if type(a1)==9 then //First argument is an handle + f=a1; + a1=a2; + if f.type<>"Figure" then + error(msprintf(gettext("%s: Wrong value for input argument #%d: Must be in the set {%s}.\n"), "colordef", 1,"handle on a figure, ""new""")); + end + scf(f); + a=gca(); + elseif a1=="new" then //First argument is "new" + n=winsid(); + if n==[] then + n=0; + else + n=max(n+1); + end + f=scf(n); + a=gca();a1=a2; + else //First argument is NOT an handle and is not "new" + error(msprintf(gettext("%s: Wrong value for input argument #%d: Must be in the set {%s}.\n"), "colordef", 1,"handle on a figure, ""new""")); + end + end + + select convstr(a1) + case "white" + f.color_map=[jetcolormap(64);[1 1 1]*0.8]; + f.background=65; + a.background=-2;a.foreground=-1; + a.font_color=a.foreground; + a.mark_foreground=a.foreground; + case "black" + if getos() == "Windows" then c=0.2, else c=0.35,end + f.color_map=[jetcolormap(64);[1 1 1]*c]; + f.background=65; + a.background=-1;a.foreground=-2; + a.font_color=a.foreground; + a.mark_foreground=a.foreground; + case "none" + f.color_map=[hsvcolormap(64)]; + f.background=-1; + a.background=-1;a.foreground=-2; + a.font_color=a.foreground; + a.mark_foreground=a.foreground; + else + error(msprintf(gettext("%s: Wrong value for input argument #%d: Must be in the set {%s}.\n"), "colordef", size(varargin),"""white"", ""black"", ""none""")); + end +endfunction diff --git a/modules/graphics/macros/comet.bin b/modules/graphics/macros/comet.bin Binary files differnew file mode 100755 index 000000000..6c743892b --- /dev/null +++ b/modules/graphics/macros/comet.bin diff --git a/modules/graphics/macros/comet.sci b/modules/graphics/macros/comet.sci new file mode 100755 index 000000000..e61005b72 --- /dev/null +++ b/modules/graphics/macros/comet.sci @@ -0,0 +1,172 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at; +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function comet(varargin) + //Comet-like trajectory. + // comet(y) displays an animated comet plot of the vector y. + // comet(x,y) displays an animated comet plot of vector y vs. x. + // comet(x,y,p) uses a comet of length p*size(y,'*'). Default is p = 0.1. + + // Example: + // t = linspace(0,10*%pi,500); + // clf();comet(t.*sin(t),t.*cos(t)) + // + // function y=traj(x),y=1.5*sin(x^2),endfunction + // clf();comet(linspace(0,5,500),traj) + // + // clf();comet(linspace(-2,4,500),(%s-3)/(%s^3+2*%s^2+1)) + + nv=size(varargin) + if nv>=3&varargin(nv-1)=="colors" then + c=round(varargin(nv)) + if type(c)<>1|~isreal(c) then + error(msprintf(_("%s: Wrong type for argument #%d: Real vector expected.\n"),"comet",nv)) + end + varargin=list(varargin(1:$-2)) + else + c=[] + end + select size(varargin) + case 1 then //y + y=varargin(1) + if or(size(y)==1) then + x=1:size(y,"*") + else + x=1:size(y,1) + end + p=0.1 + case 2 then //x,y + [x,y]=varargin(1:2) + p=0.1 + case 3 then //x,y,p + [x,y,p]=varargin(1:3) + else + error(msprintf(_("%s: Wrong number of input arguments: %d to %d expected.\n"),"comet",1,3)) + end + if type(x)<>1|~isreal(x) then + error(msprintf(_("%s: Wrong type for argument #%d: Real vector expected.\n"),"comet",1)) + end + if or(type(y)==[11 13]) then //a function + prot=funcprot();funcprot(0) + y=feval(x,y) + funcprot(prot) + elseif type(y)==2 then //a polynomial + y=horner(y,x) + elseif typeof(y)=="rational" then //a rational fraction + y=horner(y,x) + end + if type(y)<>1|~isreal(y) then + error(msprintf(_("%s: Wrong type for argument #%d: Real vector expected.\n"),"comet",2)) + end + if type(p)<>1|~isreal(p)|size(p,"*")>1 then + error(msprintf(_("%s: Wrong type for argument #%d: Real scalar expected.\n"),"comet",3)) + end + if p<0|p>=1 then + error(msprintf(_("%s: Wrong value for input argument #%d: Must be in the interval %s.\n"),"comet",3,"[0 1[")) + end + + if or(size(x)==1) then + x=x(:) + n=size(x,1) + if or(size(y)==1) then + if n<>size(y,"*") then + error(msprintf(_("%s: Incompatible input arguments #%d and #%d: Same sizes expected.\n"),"comet",1,2)) + end + y=y(:) + m=1 + else + m=size(y,2) + if size(y,1)<>n then + error(msprintf(_("%s: Incompatible input arguments #%d and #%d: Same number of rows expected.\n"),"comet",1,2)) + end + x=x*ones(1,m) + end + else + n=size(x,1) + m=size(x,2) + if or(size(y)<>size(x)) then + error(msprintf(_("%s: Incompatible input arguments #%d and #%d: Same sizes expected.\n"),"comet",1,2)) + end + end + fig=gcf(); + if c==[] then + c=1:m + else + if size(c,"*")<>m then + error(msprintf(_("%s: Wrong size for argument #%d: %d expected.\n"),"comet",nv,m)) + end + if min(c)<1|max(c)>size(fig.color_map,1) then + error(msprintf(_( "%s: Wrong value for input argument #%d: Must be in the set {%s}.\n"),"comet",nv,"1,...,"+string(size(fig.color_map,1)))) + end + end + axes=gca(); + + if axes.children==[] then + axes.data_bounds=[min(x) min(y);max(x) max(y)]; + axes.axes_visible="on"; + else + axes.data_bounds=[min(axes.data_bounds(1,:), [min(x) min(y)]); + max(axes.data_bounds(2,:), [max(x) max(y)])]; + end + //create the head, body and tail polylines + drawlater() + tail=[];body=[];head=[]; + for l=1:m + xpoly([],[]);tail(l)=gce(); + tail(l).foreground=c(l); + xpoly([],[]);body(l)=gce(); + body(l).foreground=c(l); + body(l).thickness=2; + xpoly([],[],"marks");head(l)=gce(); + head(l).mark_size_unit="point"; + head(l).mark_size=6; + head(l).mark_style=9; + head(l).mark_foreground=c(l); + end + show_window(); + + + function anim() + //animation loop + k = round(p*n); + step=ceil(n/200); //used to speed up the drawing + + for i=1:n + for l=1:m + head(l).data=[x(i,l),y(i,l)]; + if i<=k then + body(l).data= [body(l).data;[x(i,l),y(i,l)]]; + else + body(l).data= [body(l).data(2:$,:);[x(i,l),y(i,l)]]; + tail(l).data=[ tail(l).data;[x(i-k+1,l),y(i-k+1,l)]]; + end + end + if modulo(i,step)==0 then + fig.immediate_drawing = "on" + fig.immediate_drawing = "off" + end + end + fig.immediate_drawing = "on" + fig.immediate_drawing = "off" + for i=1:k + for l=1:m + body(l).data= body(l).data(2:$,:); + tail(l).data=[tail(l).data;[x(n-k+i,l),y(n-k+i,l)]]; + end + if modulo(i,step)==0 then + fig.immediate_drawing = "on" + fig.immediate_drawing = "off" + end + end + fig.immediate_drawing = "on" + delete(body) + endfunction + //not to generate an error message if the window is closed + exec(anim, "errcatch", -1); +endfunction diff --git a/modules/graphics/macros/comet3d.bin b/modules/graphics/macros/comet3d.bin Binary files differnew file mode 100755 index 000000000..86ba8c113 --- /dev/null +++ b/modules/graphics/macros/comet3d.bin diff --git a/modules/graphics/macros/comet3d.sci b/modules/graphics/macros/comet3d.sci new file mode 100755 index 000000000..f5f9aa9f3 --- /dev/null +++ b/modules/graphics/macros/comet3d.sci @@ -0,0 +1,197 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at; +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function comet3d(varargin) + //Comet-like trajectory. + // comet(y) displays an animated comet plot of the vector y. + // comet(x,y) displays an animated comet plot of vector y vs. x. + // comet(x,y,p) uses a comet of length p*size(y,'*'). Default is p = 0.1. + + // Example: + // t = linspace(-%pi,%pi,500); + // clf();comet3d(sin(5*t),sin(t),t^2) + // + // function z=traj(x,y),z=1.5*sin(x^2)*cos(y),endfunction + // clf();comet3d(cos(t),sin(t),traj) + // + nv=size(varargin) + if nv>=3&varargin(nv-1)=="colors" then + c=round(varargin(nv)) + if type(c)<>1|~isreal(c) then + error(msprintf(_("%s: Wrong type for argument #%d: Real vector expected.\n"),"comet3d",nv)) + end + varargin=list(varargin(1:$-2)) + else + c=[] + end + select size(varargin) + + case 1 then //z + z=varargin(1) + if or(size(z)==1) then + x=1:size(z,"*") + else + x=1:size(z,1) + end + y=x + p=0.1 + case 3 then //x,y,z + [x,y,z]=varargin(1:3) + p=0.1 + case 4 then //x,y,z,p + [x,y,z,p]=varargin(1:4) + else + error(msprintf(_("%s: Wrong number of input arguments: %d or %d to %d expected.\n"),"comet3d",1,3,4)) + end + + + if type(x)<>1|~isreal(x) then + error(msprintf(_("%s: Wrong type for argument #%d: Real vector expected.\n"),"comet3d",1)) + end + if type(y)<>1|~isreal(x) then + error(msprintf(_("%s: Wrong type for argument #%d: Real vector expected.\n"),"comet3d",1)) + end + + if (type(z)<>1|~isreal(z))&and(type(z)<>[11 13]) then + error(msprintf(_("%s: Wrong type for argument #%d: Real vector expected.\n"),"comet3d",3)) + end + + + if or(type(z)==[11 13]) then + x=x(:);y=y(:) + n=size(x,"*") + m=1 + if n<>size(y,"*") then + error(msprintf(_("%s: Incompatible input arguments #%d and #%d: Same sizes expected.\n"),"comet3d",1,2)) + end + prot=funcprot();funcprot(0) + zz=z; + z=zeros(n,1); + for i=1:n + z(i)=zz(x(i),y(i)) + end + funcprot(prot) + else + if or(size(z)==1) then + m=1 + z=z(:) + n=size(z,"*") + else + [n,m]=size(z) + end + if or(size(x)==1) then + x=x(:) + if size(x,"*")<>n then + error(msprintf(_("%s: Wrong size for argument #%d: %d expected.\n"),"comet3d",1,n)) + end + x=x*ones(1,m) + else + if or(size(x)<>size(z)) then + error(msprintf(_("%s: Incompatible input arguments #%d and #%d: Same sizes expected.\n"),"comet3d",1,3)) + end + end + if or(size(y)==1) then + y=y(:) + if size(y,"*")<>n then + error(msprintf(_("%s: Wrong size for argument #%d: %d expected.\n"),"comet3d",2,n)) + end + y=y*ones(1,m) + else + if or(size(y)<>size(z)) then + error(msprintf(_("%s: Incompatible input arguments #%d and #%d: Same sizes expected.\n"),"comet3d",2,3)) + end + + end + end + + + if type(p)<>1|~isreal(p)|size(p,"*")>1 then + error(msprintf(_("%s: Wrong type for argument #%d: Real scalar expected.\n"),"comet3d",3)) + end + if p<0|p>=1 then + error(msprintf(_("%s: Wrong value for input argument #%d: Must be in the interval %s.\n"),"comet3d",3,"[0 1[")) + end + fig=gcf(); + if c==[] then + c=1:m + else + if size(c,"*")<>m then + error(msprintf(_("%s: Wrong size for argument #%d: %d expected.\n"),"comet",nv,m)) + end + if min(c)<1|max(c)>size(fig.color_map,1) then + error(msprintf(_( "%s: Wrong value for input argument #%d: Must be in the set {%s}.\n"),"comet",nv,"1,...,"+string(size(fig.color_map,1)))) + end + end + axes=gca(); + axes.view="3d" + + + if axes.children==[] then + axes.data_bounds=[min(x) min(y) min(z);max(x) max(y) max(z)]; + axes.axes_visible="on"; + axes.box="on"; + else + axes.data_bounds=[min(axes.data_bounds(1,:), [min(x) min(y) min(z)]); + max(axes.data_bounds(2,:), [max(x) max(y) max(z)])]; + end + //create the head, body and tail polylines + drawlater() + for l=1:m + xpoly([],[]);tail(l)=gce(); + tail(l).foreground=c(l); + + xpoly([],[]);body(l)=gce(); + body(l).foreground=c(l); body(l).thickness=2; + xpoly([],[],"marks");head(l)=gce(); + head(l).mark_size_unit="point"; + head(l).mark_size=6; + head(l).mark_style=9; + head(l).mark_foreground=c(l); + end + show_window(); + + function anim() + //animation loop + k = round(p*n); + step=ceil(n/200); //used to speed up the drawing + + for i=1:n + for l=1:m + head(l).data=[x(i,l),y(i,l),z(i,l)]; + if i<=k then + body(l).data= [body(l).data;[x(i,l),y(i,l),z(i,l)]]; + else + body(l).data= [body(l).data(2:$,:);[x(i,l),y(i,l),z(i,l)]]; + tail(l).data=[ tail(l).data;[x(i-k,l),y(i-k,l),z(i-k,l)]]; + end + end + if modulo(i,step)==0 then + fig.immediate_drawing = "on" + fig.immediate_drawing = "off" + end + end + drawnow(),drawlater() + + for i=n:n+k + for l=1:m + body(l).data= body(l).data(2:$,:); + tail(l).data=[ tail(l).data;[x(i-k,l),y(i-k,l),z(i-k,l)]]; + end + if modulo(i,step)==0 then + fig.immediate_drawing = "on" + fig.immediate_drawing = "off" + end + end + delete(body) + drawnow() + endfunction + //not to generate an error message if the window is closed + exec(anim, "errcatch", -1) + //exec(anim,-1) +endfunction diff --git a/modules/graphics/macros/contour.bin b/modules/graphics/macros/contour.bin Binary files differnew file mode 100755 index 000000000..d701b84f3 --- /dev/null +++ b/modules/graphics/macros/contour.bin diff --git a/modules/graphics/macros/contour.sci b/modules/graphics/macros/contour.sci new file mode 100755 index 000000000..840bc8e62 --- /dev/null +++ b/modules/graphics/macros/contour.sci @@ -0,0 +1,188 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// Copyright (C) 2011 - DIGITEO - Michael Baudin +// Copyright (C) 2012 - DIGITEO - Allan CORNET +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function contour(x, y, z, nz, theta, alpha, leg, flag, ebox, zlev) + + function contour_demo() + function z = Surf1(x, y) + z = x.^2 + y.^3; + endfunction + + function z = Surf2(x, y) + z = x.^2 + y.^2; + endfunction + + x = -1:0.1:1; + y = x; + z = eval3d(Surf2, x, y) + + //scf(); + subplot(211); + contour(x, y, Surf1, 10); + subplot(212); + plot3d(x, y, z); + contour(x, y, z + 0.1, 10, flag = [0 2 4]); + endfunction + + rhs = argn(2); + + // demo + if rhs == 0 then + contour_demo(); + return + end + + if rhs < 4 then + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"), "contour", 4)); + end + + if type(x) <> 1 then + error(999, msprintf(gettext("%s: Wrong type for input argument #%d: Real vector expected.\n"), "contour", 1)); + end + + if type(y) <> 1 then + error(999, msprintf(gettext("%s: Wrong type for input argument #%d: Real vector expected.\n"), "contour", 2)); + end + + if type(z) <> 1 & type(z) <> 13 then + error(999, msprintf(gettext("%s: Wrong type for input argument #%d: Real matrix or Scilab function expected.\n"), "contour", 3)); + end + + if type(nz) <> 1 then + error(999, msprintf(gettext("%s: Wrong type for input argument #%d: Real matrix expected.\n"), "contour", 4)); + end + + if ~isvector(x) then + error(999, msprintf(gettext("%s: Wrong size for input argument #%d: Real vector expected.\n"), "contour", 1)); + end + + if ~isvector(y) then + error(999, msprintf(gettext("%s: Wrong size for input argument #%d: Real vector expected.\n"), "contour", 2)); + end + + levels = []; + + opts = []; + if exists("theta", "local") == 1 then + opts = [opts, "theta=theta"]; + end + if exists("alpha", "local") == 1 then + opts = [opts, "alpha=alpha"]; + end + if exists("leg" , "local") == 1 then + opts = [opts, "leg=leg"]; + end + if exists("ebox" , "local") == 1 then + opts = [opts, "ebox=ebox"]; + end + if exists("flag" , "local") == 0 then + flag = [2 2 3]; + end + if exists("zlev" , "local") == 0 then + zlev = 0; + end + + if or(type(z) == [11 13]) then + fun = z; + clear z //to avoid redfinition warning + if type(fun) == 11 then + comp(fun); + end + z = feval(x, y, fun); + end + + job = flag(1); + if rhs == 4 | job == 2 then + contour2d(x, y, z, nz); + return; + end + + if size(nz, "*") == 1 then + style = 1:nz; + else + style = 1:size(nz, "*"); + end + + opts = strcat([opts, "flag=flag(2:3)"], ","); + + [xc, yc] = contour2di(x, y, z, nz); + + fig = gcf(); + a = gca(); + fg = a.foreground; + v = fig.immediate_drawing; + fig.immediate_drawing = "off"; + cnt = 0; + + fpf = xget("fpf"); + if fpf == "" then + fpf = "%.2g"; + end + k = 1; + n = yc(k); + c = 0; + level = %inf; + while k < length(xc) + n = yc(k) + if xc(k) ~= level then + c = c+1; + level = xc(k); + levels = [level levels]; + a.foreground = c; + if cnt > 0 then + glue(a.children(1:cnt)); + cnt = 0; + end + end + + if job == 1 then + zz = zlev; + else + zz = level; + end + execstr("param3d(xc(k + (1:n)), yc(k + (1:n)), zz * ones(1, n), " + opts + ")"); + + cnt = cnt + 1; + if stripblanks(fpf) <> "" then + // don't clip as in contour2d since we are in 3D here + // and stringbox gives data in 2D + xstring(xc(k + 1 + n / 2), yc(k + 1 + n/2), " " + msprintf(fpf, level)); + e = gce(); + e.data(3) = zz; + e.clip_state = "off"; + cnt = cnt + 1; + end + k = k + n + 1; + end + if cnt > 0 then + glue(a.children(1:cnt)); + cnt = 0; + end + set("current_entity", a); + a.foreground = fg; + if flag(3) == 0 then + a.axes_visible = "off"; + a.box = "off"; + elseif flag(3) == 1 then + a.axes_visible = "off"; + a.box = "off"; + elseif flag(3) == 2 then + a.axes_visible = "off"; + a.box = "back_half"; + elseif flag(3) == 3 then + a.axes_visible = "off"; + a.box = "on"; + elseif flag(3) >= 4 then + a.axes_visible = "on"; + a.box = "on"; + end + fig.immediate_drawing = v; +endfunction + diff --git a/modules/graphics/macros/contour2d.bin b/modules/graphics/macros/contour2d.bin Binary files differnew file mode 100755 index 000000000..ca23aeaf6 --- /dev/null +++ b/modules/graphics/macros/contour2d.bin diff --git a/modules/graphics/macros/contour2d.sci b/modules/graphics/macros/contour2d.sci new file mode 100755 index 000000000..87d9992f5 --- /dev/null +++ b/modules/graphics/macros/contour2d.sci @@ -0,0 +1,195 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// Copyright (C) 2011 - DIGITEO - Michael Baudin +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function levels = contour2d(x, y, z, nz, style, strf, leg, rect, nax, void) + + [lhs, rhs] = argn(0); + + if rhs == 0 then + scf(); + levels = contour2d(1:10, 1:10, rand(10,10), 5, rect = [0, 0, 11, 11]); + return; + end + + if rhs < 4 then + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"), "contour2d", 4)); + end + + if type(x) <> 1 then + error(999, msprintf(gettext("%s: Wrong type for input argument #%d: Real vector expected.\n"), "contour2d", 1)); + end + + if type(y) <> 1 then + error(999, msprintf(gettext("%s: Wrong type for input argument #%d: Real vector expected.\n"), "contour2d", 2)); + end + + if type(z) <> 1 & type(z) <> 13 then + error(999, msprintf(gettext("%s: Wrong type for input argument #%d: Real matrix or Scilab function expected.\n"), "contour2d", 3)); + end + + if type(nz) <> 1 then + error(999, msprintf(gettext("%s: Wrong type for input argument #%d: Real matrix expected.\n"), "contour2d", 4)); + end + + if ~isvector(x) then + error(999, msprintf(gettext("%s: Wrong size for input argument #%d: Real vector expected.\n"), "contour2d", 1)); + end + + if ~isvector(y) then + error(999, msprintf(gettext("%s: Wrong size for input argument #%d: Real vector expected.\n"), "contour2d", 2)); + end + + opts = []; + levels = []; + + if ~exists("style", "local") then + if size(nz, "*") == 1 then + style = 1:nz; + else + style = 1:size(nz, "*"); + end + end + + if exists("strf", "local") then + yflag = part(strf, 2); + if or(yflag == ["2" "4" "6" "8"]) then + rect = [min(x), min(y), max(x), max(y)]; + yflag = string(evstr(yflag) - 1); + strf = part(strf, 1) + yflag + part(strf, 3); + end + opts = [opts,"strf=strf"]; + end + + if exists("leg", "local") then + opts = [opts, "leg=leg"]; + end + rectSpecified = %f; + if exists("rect","local") then + opts = [opts, "rect=rect"]; + rectSpecified = %t; + end + if exists("nax","local") then + opts = [opts, "nax=nax"]; + end + if exists("logflag","local") then + opts = [opts, "logflag=logflag"]; + end + if exists("frameflag","local") then + opts = [opts,"frameflag=frameflag"]; + else + frameflag = []; + end + if exists("axesflag","local") then + opts = [opts, "axesflag=axesflag"]; + end + opts = strcat([opts, "style=style(c)"], ","); + + if or(type(z) == [11 13]) then + fun = z; + //to avoid redfinition warning + clear z + if type(fun) == 11 then + comp(fun); + end + z = feval(x, y, fun); + end + + [xc, yc] = contour2di(x, y, z, nz); + fpf = xget("fpf"); + if fpf == "" then + fpf = "%.3g"; + end + + fig = gcf(); + a = gca(); + autoc = a.auto_clear; + if autoc == "on" then + if ~isempty(a.children) then + delete(a.children); + end + end + v = fig.immediate_drawing; + fig.immediate_drawing = "off"; + a.auto_clear = "off"; + cnt = 0; + + + // we draw the contour with call to plot2d for each level line + // however the data_bounds will be always reset after each plot + // so we must compute before the bounding rectangle (xmin,ymin,xmax,ymax) + // and give it to each plot2d. This is useful for frameflag = (2,4,6,8) + // since the data_bounds are given by the extrema of x and y + if ( frameflag == 2 | frameflag == 4 | frameflag == 6 | frameflag == 8 ) + // get the bounding rectangle + rect = [min(x), min(y), max(x), max(y)]; + // set the option accordingly + if ~rectSpecified then + opts = strcat([opts, "rect=rect"], ","); + end + // the rect will be taken into account + frameflag = frameflag - 1 ; + elseif (~rectSpecified) then + // get rect any way for clipping + rect = [min(x), min(y), max(x), max(y)]; + end + + k = 1; + n = yc(k); + c = 0; + level = %inf; + while k < length(xc) + n = yc(k); + if xc(k) ~= level then + c = c + 1; + level = xc(k); + levels = [level levels]; + if cnt>0 then + glue(a.children(1:cnt)); + cnt = 0; + end + end + err = execstr("plot2d(xc(k + (1:n)), yc(k + (1:n))," + opts + ")", "errcatch", "m"); + frameflag = 0; + + // add a test to see if plot2d call succeed + // and, if not, restore good figure property values before exiting + if err <> 0 + mprintf(gettext("Error %d : in plot2d called by contour2d"), err); + fig.immediate_drawing = v; + a.auto_clear = autoc; + return; + end + + unglue(a.children(1)) + cnt = cnt + 1; + + if stripblanks(fpf) <> "" then + labelText = " " + msprintf(fpf, level); + labelPos = [xc(k + 1 + n/2), yc(k + 1 + n/2)]; + labelBox = stringbox(labelText, labelPos(1), labelPos(2)); + // check that the text is not outside the box + // better than clipping to avoid half cut strings + if labelBox(1,1) > rect(1) & labelBox(2,1) > rect(2) & .. + labelBox(1,3) < rect(3) & labelBox(2,3) < rect(4) then + xstring(labelPos(1), labelPos(2), labelText) + e = gce(); + e.clip_state = "off"; + cnt = cnt + 1; + end + end + k = k + n + 1; + end + + if cnt > 0 then + glue(a.children(1:cnt)); + cnt = 0; + end + set("current_entity", a); + fig.immediate_drawing = v; +endfunction diff --git a/modules/graphics/macros/contourf.bin b/modules/graphics/macros/contourf.bin Binary files differnew file mode 100755 index 000000000..0f17217c2 --- /dev/null +++ b/modules/graphics/macros/contourf.bin diff --git a/modules/graphics/macros/contourf.sci b/modules/graphics/macros/contourf.sci new file mode 100755 index 000000000..49dc0dd77 --- /dev/null +++ b/modules/graphics/macros/contourf.sci @@ -0,0 +1,214 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// Copyright (C) DIGITEO - 2012 - Allan CORNET +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function contourf(x, y, z, nv, style, strf, leg, rect, nax) + + [nout, nin] = argn(0); + + if nin == 0 then // demo + t = -%pi:0.1:%pi; + m = sin(t)' * cos(t); + contourf(t,t,m); + return; + end + + if nin <= 0 then + x=1:10; + end + if nin <= 1 then + y=1:10; + end + if nin <= 2 then + z=rand(size(x,"*"), size(y,"*")); + end + if nin <= 3 then + zmin=min(z); + zmax=max(z); + nv = zmin + (1:10) * (zmax-zmin)/(11); + end + if nin <= 5 then + strf="021"; + end + if nin <= 6 then + leg=" "; + end + if nin <= 7 then + rect=[0,0,1,1]; + end + if nin <= 8 then + nax=[1,10,1,10]; + end + if x==[] then + x=1:size(z,"r"); + end + if y==[] then + y=1:size(z,"c"); + end + + if type(x) <> 1 then + error(999, msprintf(gettext("%s: Wrong type for input argument #%d: Real vector expected.\n"), "contourf", 1)); + end + + if type(y) <> 1 then + error(999, msprintf(gettext("%s: Wrong type for input argument #%d: Real vector expected.\n"), "contourf", 2)); + end + + if type(z) <> 1 then + error(999, msprintf(gettext("%s: Wrong type for input argument #%d: Real matrix expected.\n"), "contourf", 3)); + end + + if type(nv) <> 1 then + error(999, msprintf(gettext("%s: Wrong type for input argument #%d: Real matrix expected.\n"), "contourf", 4)); + end + + if type(strf) <> 10 then + error(999, msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"), "contourf", 6)); + end + + if type(leg) <> 10 then + error(999, msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"), "contourf", 7)); + end + + if type(rect) <> 1 then + error(999, msprintf(gettext("%s: Wrong type for input argument #%d: Real matrix expected.\n"), "contourf", 8)); + end + + if type(nax) <> 1 then + error(999, msprintf(gettext("%s: Wrong type for input argument #%d: Real matrix expected.\n"), "contourf", 9)); + end + + + nvs=size(nv,"*") ; + if nvs==1 then + nvs=nv; + zmin=min(z); + zmax=max(z); + nv = zmin + (1:nvs)*(zmax-zmin)/(nvs+1); + end; + + if nin <= 4 then + style = -1*ones(1, nvs); + end + + if type(style) <> 1 then + error(999, msprintf(gettext("%s: Wrong type for input argument #%d: Real matrix expected.\n"), "contourf", 5)); + end + + if nin <= 7 then + rect=[min(x), min(y), max(x), max(y)]; + end + + if ~isvector(x) then + error(999, msprintf(gettext("%s: Wrong size for input argument #%d: Real vector expected.\n"), "contourf", 1)); + end + + if ~isvector(y) then + error(999, msprintf(gettext("%s: Wrong size for input argument #%d: Real vector expected.\n"), "contourf", 2)); + end + + if size(strf, "*") <> 1 then + error(999, msprintf(gettext("%s: Wrong size for input argument #%d: A string expected.\n"), "contourf", 6)); + end + + if size(leg, "*") <> 1 then + error(999, msprintf(gettext("%s: Wrong size for input argument #%d: A string expected.\n"), "contourf", 7)); + end + + nv1 = nv; + [mz,nz] = size(z); + minz = min(z); + maxz = max(z); + + // Surround the matrix by a very low region to get closed contours, and + // replace any NaN with low numbers as well. + zz=[ %nan * ones(1,nz+2) + %nan; + %nan * ones(mz,1) + %nan, z, %nan * ones(mz,1) + %nan; + %nan * ones(1,nz+2) + %nan]; + + kk=find(isnan(zz(:))); + + zz(kk)=minz-1e4*(maxz-minz)+zeros(kk); + + xx = [2 * x(1) - x(2); x(:); 2 * x(mz) - x(mz - 1)]; + yy = [2 * y(1) - y(2); y(:); 2 * y(nz) - y(nz - 1)]; + + // Internal call to get the contours + [x1,y1]=contour2di(xx,yy,zz,nv); + CS=[x1;y1]; + // Find the indices of the curves in the c matrix, and get the + // area of closed curves in order to draw patches correctly. + ii = 1; + ncurves = 0; + I = []; + Area=[]; + + while (ii < size(CS,2)), + nl=CS(2,ii); + ncurves = ncurves + 1; + I(ncurves) = ii; + xp=CS(1,ii+(1:nl)); // First patch + yp=CS(2,ii+(1:nl)); + Area(ncurves)=sum(diff(xp).*(yp(1:nl-1)+yp(2:nl))/2); + ii = ii + nl + 1; + end + + lp=xget("lastpattern"); + + if size(nv,"*") > 1 // case where nv is a vector defining the level curve values + if size(nv,"*") > lp + error(msprintf(gettext("%s: Colormap too small"),"contourf")); + end + else + if nv > lp + error(msprintf(gettext("%s: Colormap too small"),"contourf")); + return ; + end + end + + min_nv=min(nv); + max_nv=max(nv); + + plot2d([min(xx);max(xx)],[min(yy);max(yy)],0,strf,leg,rect,nax); + + // Plot patches in order of decreasing size. This makes sure that + // all the lev1es get drawn, not matter if we are going up a hill or + // down into a hole. When going down we shift levels though, you can + // tell whether we are going up or down by checking the sign of the + // area (since curves are oriented so that the high side is always + // the same side). Lowest curve is largest and encloses higher data + // always. + + draw_min=1; + H=[]; + [FA,IA]=gsort(abs(Area)); + + drawlater(); // postpon the drawing here + a=gca(); + old_foreground = a.foreground; + pat=xget("pattern"); + for jj=IA', + nl=CS(2,I(jj)); + lev1=CS(1,I(jj)); + if (lev1 ~= minz | draw_min) then + xp=CS(1,I(jj)+(1:nl)); + yp=CS(2,I(jj)+(1:nl)); + pat=size(find( nv <= lev1),"*"); + xset("pattern",pat); + xfpoly(xp,yp) + end + end + + if style(1)<>-1 then + contour2d(xx,yy,zz,nv,style,"000",leg,rect,nax); + end + a.foreground = old_foreground; + drawnow(); // draw all now! + +endfunction + diff --git a/modules/graphics/macros/coolcolormap.bin b/modules/graphics/macros/coolcolormap.bin Binary files differnew file mode 100755 index 000000000..5ea08973b --- /dev/null +++ b/modules/graphics/macros/coolcolormap.bin diff --git a/modules/graphics/macros/coolcolormap.sci b/modules/graphics/macros/coolcolormap.sci new file mode 100755 index 000000000..a9ae05e29 --- /dev/null +++ b/modules/graphics/macros/coolcolormap.sci @@ -0,0 +1,41 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Pierre MARECHAL <pierre.marechal@scilab.org> +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function cmap = coolcolormap(varargin) + + //coolcolormap : consists of colors that are shades of blue and green. + + // Check number of input argument + if size(varargin)<>1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "coolcolormap", 1)); + end + n=varargin(1); + + // Check type of input argument + // Check if input argument is real + if typeof(n)<>"constant" | ~isreal(n) then + error(msprintf(gettext("%s: Wrong type for input argument #%d: a real scalar expected.\n"), "coolcolormap", 1)); + end + + // Check size of input argument + if size(n,"*")<>1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: a real scalar expected.\n"), "coolcolormap", 1)); + end + + if n==0 then + cmap = []; + return + end + + red = (0:n-1)'/max(n-1,1); + green = 1-red; + blue = ones(n,1); + + cmap = [red green blue]; + +endfunction diff --git a/modules/graphics/macros/coppercolormap.bin b/modules/graphics/macros/coppercolormap.bin Binary files differnew file mode 100755 index 000000000..bea186b53 --- /dev/null +++ b/modules/graphics/macros/coppercolormap.bin diff --git a/modules/graphics/macros/coppercolormap.sci b/modules/graphics/macros/coppercolormap.sci new file mode 100755 index 000000000..489373840 --- /dev/null +++ b/modules/graphics/macros/coppercolormap.sci @@ -0,0 +1,43 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Pierre MARECHAL <pierre.marechal@scilab.org> +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function cmap = coppercolormap(varargin) + + //coppercolormap : Black to a light copper tone. + + // Check number of input argument + if size(varargin)<>1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "coppercolormap", 1)); + end + n=varargin(1); + + // Check type of input argument + // Check if input argument is real + if typeof(n)<>"constant" | ~isreal(n) then + error(msprintf(gettext("%s: Wrong type for input argument #%d: a real scalar expected.\n"), "coppercolormap", 1)); + end + + // Check size of input argument + if size(n,"*")<>1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: a real scalar expected.\n"), "coppercolormap", 1)); + end + + if n==0 then + cmap = []; + return + end + + x = linspace (0, 1, n)'; + + red = (x<0.8) .* (1.25*x) + (x >= 0.8); + green = 0.8 * x; + blue = 0.5 * x; + + cmap = [red green blue]; + +endfunction diff --git a/modules/graphics/macros/createConstraints.bin b/modules/graphics/macros/createConstraints.bin Binary files differnew file mode 100755 index 000000000..c7ee91e11 --- /dev/null +++ b/modules/graphics/macros/createConstraints.bin diff --git a/modules/graphics/macros/createConstraints.sci b/modules/graphics/macros/createConstraints.sci new file mode 100755 index 000000000..66b9f6ff0 --- /dev/null +++ b/modules/graphics/macros/createConstraints.sci @@ -0,0 +1,102 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +// +// + +function ret = createConstraints(constType, varargin) + [lhs,rhs]=argn(0) + + if rhs < 1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected."), "createConstraints", 1)); + end + + ret = []; + if constType == "nolayout" | constType == "none" then + ret = tlist(["NoLayoutConstraint"]); + elseif constType == "grid" then + ret = tlist(["GridConstraints"]); + elseif constType == "border" then + arg1 = "center" + arg2 = [-1 -1]; + + if size(varargin) <> [1 2] then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d to %d expected."), "createConstraints", 2, 3)); + end + + arg1 = varargin(1); + if typeof(arg1) <> "string" | size(arg1, "*") <> 1 then + error(999, msprintf(_("%s: Wrong type for input argument #%d: A string expected.\n"), "createConstraints", 2)); + end + + if size(varargin) > 1 then + arg2 = varargin(2); + if typeof(arg2) <> "constant" | size(arg2, "*") <> 2 then + error(999, msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "createConstraints", 3)); + end + end + + ret = tlist(["BorderConstraint","position", "preferredsize"], arg1, arg2); + elseif constType == "gridbag" then + arg1 = [0 0 0 0]; + arg2 = [0 0]; + arg3 = "none"; + arg4 = "center"; + arg5 = [0 0]; + arg6 = [-1 -1]; + + if size(varargin) <> [1:6] then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d to %d expected."), "createConstraints", 2, 7)); + end + + arg1 = varargin(1); + if typeof(arg1) <> "constant" | size(arg1, "*") <> 4 then + error(999, msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "createConstraints", 2)); + end + + if size(varargin) > 1 then + arg2 = varargin(2); + if typeof(arg2) <> "constant" | size(arg2, "*") <> 2 then + error(999, msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "createConstraints", 3)); + end + end + + if size(varargin) > 2 then + arg3 = varargin(3); + if typeof(arg3) <> "string" | size(arg3, "*") <> 1 then + error(999, msprintf(_("%s: Wrong type for input argument #%d: A string expected.\n"), "createConstraints", 4)); + end + end + + if size(varargin) > 3 then + arg4 = varargin(4); + if typeof(arg4) <> "string" | size(arg4, "*") <> 1 then + error(999, msprintf(_("%s: Wrong type for input argument #%d: A string expected.\n"), "createConstraints", 5)); + end + end + + if size(varargin) > 4 then + arg5 = varargin(5); + if typeof(arg5) <> "constant" | size(arg5, "*") <> 2 then + error(999, msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "createConstraints", 6)); + end + end + + if size(varargin) > 5 then + arg6 = varargin(6); + if typeof(arg6) <> "constant" | size(arg6, "*") <> 2 then + error(999, msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "createConstraints", 7)); + end + end + + ret = tlist(["GridBagConstraints","grid","weight","fill","anchor","padding","preferredsize"], arg1, arg2, arg3, arg4, arg5, arg6); + else + error(999, msprintf(_("%s: Wrong value for input argument #%d: Must be in the set {%s}.\n"), "createConstraints", 1, "none/nolayout, border, grid, gridbag")); + end +endfunction diff --git a/modules/graphics/macros/createLayoutOptions.bin b/modules/graphics/macros/createLayoutOptions.bin Binary files differnew file mode 100755 index 000000000..d8b8c3f6a --- /dev/null +++ b/modules/graphics/macros/createLayoutOptions.bin diff --git a/modules/graphics/macros/createLayoutOptions.sci b/modules/graphics/macros/createLayoutOptions.sci new file mode 100755 index 000000000..079fa5178 --- /dev/null +++ b/modules/graphics/macros/createLayoutOptions.sci @@ -0,0 +1,58 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +// +// + +function ret = createLayoutOptions(constType, varargin) + [lhs,rhs]=argn(0) + + if rhs < 1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected."), "createLayoutOptions", 1)); + end + + ret = []; + if constType == "nolayout" | constType == "none" then + ret = tlist(["OptNoLayout"]); + elseif constType == "border" then + arg1 = [0 0] + + //hpad, vpad + if size(varargin) > 0 then + arg1 = varargin(1); + if typeof(arg1) <> "constant" | size(arg1, "*") <> 2 then + error(999, msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "createLayoutOptions", 2)); + end + end + + ret = tlist(["OptBorder","padding"], arg1); + elseif constType == "grid" then + arg1 = [0 0]; + arg2 = [0 0]; + + if size(varargin) > 0 then + arg1 = varargin(1); + if typeof(arg1) <> "constant" | size(arg1, "*") <> 2 then + error(999, msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "createLayoutOptions", 2)); + end + end + + if size(varargin) > 1 then + arg2 = varargin(2); + if typeof(arg2) <> "constant" | size(arg2, "*") <> 2 then + error(999, msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "createLayoutOptions", 3)); + end + end + ret = tlist(["OptGrid","grid","padding"], arg1, arg2); + elseif constType == "gridbag" then + ret = tlist(["OptGridBag"]); + else + error(999, msprintf(_("%s: Wrong value for input argument #%d: Must be in the set {%s}.\n"), "createLayoutOptions", 1, "none/nolayout, border, grid, gridbag")); + end +endfunction diff --git a/modules/graphics/macros/datatips/%datatips_p.bin b/modules/graphics/macros/datatips/%datatips_p.bin Binary files differnew file mode 100755 index 000000000..d737eaf86 --- /dev/null +++ b/modules/graphics/macros/datatips/%datatips_p.bin diff --git a/modules/graphics/macros/datatips/%datatips_p.sci b/modules/graphics/macros/datatips/%datatips_p.sci new file mode 100755 index 000000000..9b5094bc9 --- /dev/null +++ b/modules/graphics/macros/datatips/%datatips_p.sci @@ -0,0 +1,38 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at; +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function %datatips_p(d) + fun=fun2string(d.formatfunction) + + F=getfield(1,d); + txt=[]; + L=max(length(F(2:$))) + for k=2:size(F,"*") + f=F(k) + if f=="interpolate" then + txt=[txt; + part(f,1:L+1)+"= "+sci2exp(d.interpolate)] + elseif f=="replace" then + txt=[txt; + part(f,1:L+1)+"= "+sci2exp(d.replace)] + elseif f=="formatfunction" then + txt=[txt; + part(f,1:L+1)+": " + " "+fun2string(d.formatfunction)] + elseif f=="tips" then + txt=[txt; + part(f,1:L+1)+": "+string(size(d.tips,"*"))+ " tip handles" ] + else + txt=[txt + part(f,1:L+1)+": "+"["+strcat(string(size(d(f))),"x")+" "+typeof(d(f))+"]"] + end + end + mprintf(" %s\n",txt) +endfunction + diff --git a/modules/graphics/macros/datatips/datatipCreatePopupMenu.bin b/modules/graphics/macros/datatips/datatipCreatePopupMenu.bin Binary files differnew file mode 100755 index 000000000..fa38575b0 --- /dev/null +++ b/modules/graphics/macros/datatips/datatipCreatePopupMenu.bin diff --git a/modules/graphics/macros/datatips/datatipCreatePopupMenu.sci b/modules/graphics/macros/datatips/datatipCreatePopupMenu.sci new file mode 100755 index 000000000..d8181c805 --- /dev/null +++ b/modules/graphics/macros/datatips/datatipCreatePopupMenu.sci @@ -0,0 +1,44 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +// Create a popupmenu and waits for a user input +function h = datatipCreatePopupMenu(listOfMenus) + //datatip utility function + // Create a contextmenu + h = uicontextmenu(); + + // Create its items + createPopupItems(h, listOfMenus); + + // Display and wait for a user answer + Cmenu = uiwait(h); + +endfunction + +function createPopupItems(parent, listOfMenus) + + for menu=listOfMenus + if type(menu) == 10 then + if size(menu,"*")==1 then + h1 = uimenu("Parent", parent, "label", menu); + else + h1 = uimenu("Parent", parent, "label", menu(1), "callback", ... + menu(2)); + end + else + if length(menu) >= 2 + h1 = uimenu("Parent", parent, "label", menu(1)); + menu(1)=null(); + createPopupItems(h1, menu); + else + error(gettext("createPopupItems: found an empty cascading menu.")); + end + end + end +endfunction diff --git a/modules/graphics/macros/datatips/datatipDefaultDisplay.bin b/modules/graphics/macros/datatips/datatipDefaultDisplay.bin Binary files differnew file mode 100755 index 000000000..91329e4ae --- /dev/null +++ b/modules/graphics/macros/datatips/datatipDefaultDisplay.bin diff --git a/modules/graphics/macros/datatips/datatipDefaultDisplay.sci b/modules/graphics/macros/datatips/datatipDefaultDisplay.sci new file mode 100755 index 000000000..2c7c90440 --- /dev/null +++ b/modules/graphics/macros/datatips/datatipDefaultDisplay.sci @@ -0,0 +1,16 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at; +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function str=datatipDefaultDisplay(curve,pt,index) + if size(pt,"c")==2 then + str=msprintf("X: %.2g\nY: %.2g", pt(1,1),pt(1,2)) + else + str=msprintf("X: %.2g\nY: %.2g\nZ: %.2g", pt(1,1),pt(1,2),pt(1,3)) + end +endfunction diff --git a/modules/graphics/macros/datatips/datatipDeleteSelected.bin b/modules/graphics/macros/datatips/datatipDeleteSelected.bin Binary files differnew file mode 100755 index 000000000..5fd2dd7a8 --- /dev/null +++ b/modules/graphics/macros/datatips/datatipDeleteSelected.bin diff --git a/modules/graphics/macros/datatips/datatipDeleteSelected.sci b/modules/graphics/macros/datatips/datatipDeleteSelected.sci new file mode 100755 index 000000000..79e45dc9f --- /dev/null +++ b/modules/graphics/macros/datatips/datatipDeleteSelected.sci @@ -0,0 +1,19 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at; +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function datatipDeleteSelected(curve_handles) + //datatip utility function + //set the selected datatip(s) + + [curve,ind]=datatipGetSelected(curve_handles) + if ind<>[] then + datatipRemove(curve,ind) + end +endfunction + diff --git a/modules/graphics/macros/datatips/datatipGUIEventHandler.bin b/modules/graphics/macros/datatips/datatipGUIEventHandler.bin Binary files differnew file mode 100755 index 000000000..154b73cf7 --- /dev/null +++ b/modules/graphics/macros/datatips/datatipGUIEventHandler.bin diff --git a/modules/graphics/macros/datatips/datatipGUIEventHandler.sci b/modules/graphics/macros/datatips/datatipGUIEventHandler.sci new file mode 100755 index 000000000..dc9bca377 --- /dev/null +++ b/modules/graphics/macros/datatips/datatipGUIEventHandler.sci @@ -0,0 +1,13 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at; +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function datatipGUIEventHandler(win,x,y,ibut) + if ibut==-1000 then + clearglobal datatipGUIHandles datatipGUICurve datatipGUIwin + end +endfunction diff --git a/modules/graphics/macros/datatips/datatipGetEntities.bin b/modules/graphics/macros/datatips/datatipGetEntities.bin Binary files differnew file mode 100755 index 000000000..cd68a4b71 --- /dev/null +++ b/modules/graphics/macros/datatips/datatipGetEntities.bin diff --git a/modules/graphics/macros/datatips/datatipGetEntities.sci b/modules/graphics/macros/datatips/datatipGetEntities.sci new file mode 100755 index 000000000..8f2b7473c --- /dev/null +++ b/modules/graphics/macros/datatips/datatipGetEntities.sci @@ -0,0 +1,57 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Gustavo Barbosa Libotte <gustavolibotte@gmail.com> +// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at; +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function curve_handles=datatipGetEntities(ax) + curve_handles=[]; + if argn(2)<1 then + ax=gca() + fig = ax.parent; + for k=1:size(fig.children,"*") + fc=fig.children(k); + select fc.type + case "Axes" then + axes=fc; + for j=1:size(axes.children,"*") + ac=axes.children(j); + select ac.type + case "Compound" then + compound=ac; + for i=1:size(compound.children,"*") + cc=compound.children(i); + select cc.type + case "Polyline" then + curve_handles=[curve_handles cc]; + end + end + end + end + end + end + else + if type(ax)<>9|size(ax,"*")<>1|and(ax.type<>["Axes" "Compound"]) then + error(msprintf(_("%s: Wrong type for input argument #%d: A ''%s'' handle expected.\n"),"datatipGetEntities",1,"Axes")) + else + for j=1:size(ax.children,"*") + ac=ax.children(j); + select ac.type + case "Compound" then + compound=ac; + for i=1:size(compound.children,"*") + cc=compound.children(i); + select cc.type + case "Polyline" then + curve_handles=[curve_handles cc]; + end + end + end + end + end + end +endfunction diff --git a/modules/graphics/macros/datatips/datatipGetSelected.bin b/modules/graphics/macros/datatips/datatipGetSelected.bin Binary files differnew file mode 100755 index 000000000..6e1cd2b87 --- /dev/null +++ b/modules/graphics/macros/datatips/datatipGetSelected.bin diff --git a/modules/graphics/macros/datatips/datatipGetSelected.sci b/modules/graphics/macros/datatips/datatipGetSelected.sci new file mode 100755 index 000000000..df91e3215 --- /dev/null +++ b/modules/graphics/macros/datatips/datatipGetSelected.sci @@ -0,0 +1,22 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at; +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [curve,ind]=datatipGetSelected(curve_handles) + //datatip utility function + //get the selected datatip(s) + ind=[] + for kc=1:size(curve_handles,"*") + curve=curve_handles(kc); + ud=datatipGetStruct(curve); + sel=ud.selected + if sel>0 then ind=sel,break,end + end + if ind==[] then curve=[],end +endfunction + diff --git a/modules/graphics/macros/datatips/datatipGetStruct.bin b/modules/graphics/macros/datatips/datatipGetStruct.bin Binary files differnew file mode 100755 index 000000000..b5a0c40ce --- /dev/null +++ b/modules/graphics/macros/datatips/datatipGetStruct.bin diff --git a/modules/graphics/macros/datatips/datatipGetStruct.sci b/modules/graphics/macros/datatips/datatipGetStruct.sci new file mode 100755 index 000000000..b0f947368 --- /dev/null +++ b/modules/graphics/macros/datatips/datatipGetStruct.sci @@ -0,0 +1,19 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at; +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function t=datatipGetStruct(curve) + + warnobsolete(_("''datatips'' property"), "5.5.1") + + if type(curve)<>9|size(curve,"*")<>1 then + error(msprintf(_("%s: Wrong type for input argument #%d: Graphic handle expected.\n"),"datatipGetStruct",1)) + end + + t = curve.datatips; +endfunction diff --git a/modules/graphics/macros/datatips/datatipHilite.bin b/modules/graphics/macros/datatips/datatipHilite.bin Binary files differnew file mode 100755 index 000000000..6aa3e8b12 --- /dev/null +++ b/modules/graphics/macros/datatips/datatipHilite.bin diff --git a/modules/graphics/macros/datatips/datatipHilite.sci b/modules/graphics/macros/datatips/datatipHilite.sci new file mode 100755 index 000000000..01451747b --- /dev/null +++ b/modules/graphics/macros/datatips/datatipHilite.sci @@ -0,0 +1,29 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at; +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function datatipHilite(datatip_handle) + //datatip utility function + point_handle=datatip_handle.children(1) + string_handle=datatip_handle.children(2) + style=string_handle.user_data(2); + if style(1)==1 then + if point_handle.mark_background==point_handle.mark_foreground then + point_handle.mark_background=addcolor([255 255 238]/255); + else + point_handle.mark_background=point_handle.mark_foreground; + end + else + if point_handle.mark_mode=="on" then + point_handle.mark_mode="off" + else + point_handle.mark_mode="on" + end + + end +endfunction diff --git a/modules/graphics/macros/datatips/datatipManagerMode.bin b/modules/graphics/macros/datatips/datatipManagerMode.bin Binary files differnew file mode 100755 index 000000000..8ebcdba2d --- /dev/null +++ b/modules/graphics/macros/datatips/datatipManagerMode.bin diff --git a/modules/graphics/macros/datatips/datatipManagerMode.sci b/modules/graphics/macros/datatips/datatipManagerMode.sci new file mode 100755 index 000000000..cb2af5635 --- /dev/null +++ b/modules/graphics/macros/datatips/datatipManagerMode.sci @@ -0,0 +1,90 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at; +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function datatipManagerMode(varargin) + //Toggle or sets the interactive mode for datatips edition.; + // This function is called by the datatips menu callbacks.; + global datatipAngles; //to be able to detect that a rotation occurred + old=[] //to preserve current figure + if winsid()<>[] then old=gcf();end + select size(varargin) + case 0 then //toggle mode + fig=gcf() + action="toggle" + case 1 then + if type(varargin(1))==10 then + action=varargin(1) + fig=gcf() + elseif type(varargin(1))==9 then + fig=varargin(1) + action="toggle" + elseif type(varargin(1))==1 then + fig=scf(varargin(1)) + if old<>[] then scf(old),end + action="toggle" + end + case 2 then + if type(varargin(1))==10 then + action=varargin(1) + fig=varargin(2) + elseif type(varargin(1))==9 then + fig=varargin(1) + action=varargin(2) + elseif type(varargin(1))==1 then + fig=scf(varargin(1)) + if old<>[] then scf(old),end + action=varargin(2) + end + else + error(msprintf(_("%s: too many input arguments"),"datatipManagerMode")) + end + fig_ud=get(fig,"user_data") + if action =="toggle" then + if fig.event_handler <> "datatipEventhandler" then + action="on" + elseif fig.event_handler_enable == "on" + action="off" + else + action="on" + end + end + select action + case "on" + if fig.event_handler<>""& fig.event_handler<>"datatipEventhandler" then + //push current event handler in fig user data if possible + if fig_ud==[] then fig_ud=struct();end + if typeof(fig_ud)=="st" then + if ~isfield(fig_ud,"handlers") then fig_ud.handlers=[],end + fig_ud.handlers=[fig_ud.handlers; + fig.event_handler fig.event_handler_enable] + set(fig,"user_data",fig_ud) + else + warning(_("Datatip manager cannot be enabled, user data figure field is already used" )) + return + end + end + fig.event_handler_enable = "off" //to prevent against bug 7855 + fig.event_handler = "datatipEventhandler" + fig.event_handler_enable = "on" + xinfo(_("Left click on a curve to create a datatip, right opens contextual menu")) + show_window(fig) + case "off" + fig.event_handler_enable = "off" + if typeof(fig_ud)=="st"&isfield(fig_ud,"handlers")&fig_ud.handlers<>[] then + fig.event_handler=fig_ud.handlers($,1) + fig.event_handler_enable=fig_ud.handlers($,2) + fig_ud.handlers= fig_ud.handlers(1:$-1,:) + set(fig,"user_data",fig_ud) + else + fig.event_handler_enable = "off" + end + clearglobal datatipAngles + xinfo("") + end +endfunction diff --git a/modules/graphics/macros/datatips/datatipMove.bin b/modules/graphics/macros/datatips/datatipMove.bin Binary files differnew file mode 100755 index 000000000..9f7e73d37 --- /dev/null +++ b/modules/graphics/macros/datatips/datatipMove.bin diff --git a/modules/graphics/macros/datatips/datatipMove.sci b/modules/graphics/macros/datatips/datatipMove.sci new file mode 100755 index 000000000..b3cd116ad --- /dev/null +++ b/modules/graphics/macros/datatips/datatipMove.sci @@ -0,0 +1,60 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at; +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function datatipMove(tip_handle,ax) + //moves a datatip along the associated curve + // tip_handle : handle on the given datatip compound; + if argn(2)<1 then + error(msprintf(_("%s: Wrong number of input argument(s): At least %d expected.\n"),"datatipMove",1)) + end + + if type(tip_handle)<>9|size(tip_handle,"*")<>1|or(tip_handle.type<>"Compound") then + error(msprintf(_("%s: Wrong type for input argument #%d: A ''%s'' handle expected.\n"),"datatipMove",1,"datatip")) + end + + if argn(2)==1 then + ax=tip_handle.parent + while ax.type<>"Axes" then ax=ax.parent,end + else + if type(ax)<>9|size(ax,"*")<>1|or(ax.type<>"Axes") then + error(msprintf(_( "%s: Wrong type for input argument #%d: A ''%s'' handle expected.\n"),"datatipMove",2,"Axes")) + end + end + curve_handle=tip_handle.children(1).user_data(1) + data=curve_handle.data //the curve data points + ud=datatipGetStruct(curve_handle); + + if ax.view=="3d"&curve_handle.type=="Polyline" then + [xx,yy]=geom3d(data(:,1),data(:,2),data(:,3)) + data=[xx,yy] + end + + rep=[0 0 -1]; + if ~ud.interpolate then //position restricted to knots + np=size(data,1) + while rep(3)==-1 + rep=xgetmouse([%t %t]) + //find data point which is at minimum distance to the pointer + [m,k]=min(sum((data-ones(np,1).*.rep(1:2)).^2,2)) + datatipSetTipPosition(ud,tip_handle,curve_handle.data(k,:),k) + end + else //interpolated position + while rep(3)==-1 + rep=xgetmouse([%t %t]) + //find data point which is at minimum distance to the pointer + [d,pt,k,c]=orthProj(data,rep(1:2)) + if pt<>[] then + if ax.view=="3d"&curve_handle.type=="Polyline" then + pt=curve_handle.data(k,:)+c*(curve_handle.data(k+1,:)-curve_handle.data(k,:)) + end + datatipSetTipPosition(ud,tip_handle,pt,k) + end + end + end +endfunction diff --git a/modules/graphics/macros/datatips/datatipRadioCallback.bin b/modules/graphics/macros/datatips/datatipRadioCallback.bin Binary files differnew file mode 100755 index 000000000..4f014c3c5 --- /dev/null +++ b/modules/graphics/macros/datatips/datatipRadioCallback.bin diff --git a/modules/graphics/macros/datatips/datatipRadioCallback.sci b/modules/graphics/macros/datatips/datatipRadioCallback.sci new file mode 100755 index 000000000..7d8653842 --- /dev/null +++ b/modules/graphics/macros/datatips/datatipRadioCallback.sci @@ -0,0 +1,50 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at; +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function datatipRadioCallback(key,v) + global datatipGUIHandles datatipGUICurve + Keys=["sty" "lab" "box" "pos" "mul"] + i=find(key==Keys) + if v then + datatipGUIHandles(i,1).value=1 + datatipGUIHandles(i,2).value=0 + else + datatipGUIHandles(i,1).value=0 + datatipGUIHandles(i,2).value=1 + end + if i<=3 then + ud=datatipGetStruct(datatipGUICurve) + style=ud.style + end + select key + case "sty" + style(1)=bool2s(~v)+1 + case "lab" + style(3)=bool2s(v) + case "box" + style(2)=bool2s(v) + case "pos" + datatipSetInterp(datatipGUICurve,~v); + case "mul" + datatipSetReplaceMode(datatipGUICurve,~v); + end + + if i<=3 then + ud.style=style + datatipSetStruct(datatipGUICurve,ud) + fig=datatipGUICurve.parent + while fig.type<>"Figure" then fig=fig.parent,end + id=fig.immediate_drawing; + fig.immediate_drawing="off" + for i=1:size(ud.tips.children,"*") + datatipSetTipStyle(ud.tips.children(i),style) + end + fig.immediate_drawing=id + end +endfunction diff --git a/modules/graphics/macros/datatips/datatipRemoveAll.bin b/modules/graphics/macros/datatips/datatipRemoveAll.bin Binary files differnew file mode 100755 index 000000000..3bec233f6 --- /dev/null +++ b/modules/graphics/macros/datatips/datatipRemoveAll.bin diff --git a/modules/graphics/macros/datatips/datatipRemoveAll.sci b/modules/graphics/macros/datatips/datatipRemoveAll.sci new file mode 100755 index 000000000..eb98cf5ea --- /dev/null +++ b/modules/graphics/macros/datatips/datatipRemoveAll.sci @@ -0,0 +1,53 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at; +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function datatipRemoveAll(curve_handles) + //remove all the datatips for the given curves + if argn(2)<>1 then //search for curves in the current axes + ax=gca() + curve_handles=datatipGetEntities(ax) + elseif type(curve_handles)<>9 then + error(msprintf(_("%s: Wrong type for input argument #%d: an array of graphic handle expected.\n"),"datatipRemoveAll",1)) + elseif size(curve_handles,"*")==1&curve_handles.type=="Axes" then + //the argument is a handle on an axes, search for curves in it + ax=curve_handles + curve_handles=datatipGetEntities(ax) + elseif and(curve_handles<>"Figure") then + //check for a common axes entity for parent + ax=[] + for k=1:size(curve_handles,"*") + a=curve_handles(k) + while a.type<>"Axes" then a=a.parent,end + if ax<>[]&a<>ax then + error(msprintf(_("%s: Wrong value for input argument #%d: the handles must have the same parent.\n"),"datatipRemoveAll",1)) + end + ax=a + end + else + error(msprintf(_("%s: Wrong type for input argument #%d: handle on axes or axes children expected.\n"),"datatipRemoveAll",1)) + end + + fig=ax.parent + id=fig.immediate_drawing; + fig.immediate_drawing="off" + for k=1:size(curve_handles,"*") + ck=curve_handles(k); + + num = 1; + for t=1:size(ck.children,"*") + tip = ck.children(num); + if tip.type == "Datatip" then + datatipRemove(tip); + else + num = num + 1; + end + end + end + fig.immediate_drawing=id +endfunction diff --git a/modules/graphics/macros/datatips/datatipRemoveNearest.bin b/modules/graphics/macros/datatips/datatipRemoveNearest.bin Binary files differnew file mode 100755 index 000000000..b38978644 --- /dev/null +++ b/modules/graphics/macros/datatips/datatipRemoveNearest.bin diff --git a/modules/graphics/macros/datatips/datatipRemoveNearest.sci b/modules/graphics/macros/datatips/datatipRemoveNearest.sci new file mode 100755 index 000000000..9a042679f --- /dev/null +++ b/modules/graphics/macros/datatips/datatipRemoveNearest.sci @@ -0,0 +1,27 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at; +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function datatipRemoveNearest(curve,pt) + //datatip utility function + ud=datatipGetStruct(curve) + if typeof(ud)=="datatips" then + tips=ud.tips.children + dmin=%inf;l=[]; + pt=pt(:); + for tip_index=1:size(tips,"*") + d=norm(tips(tip_index).children(1).data(1:2)-pt(1:2)) + if d<dmin then + l=tip_index;dmin=d; + end + end + if l<>[] then + datatipRemove(curve,l); + end + end +endfunction diff --git a/modules/graphics/macros/datatips/datatipSetGUI.bin b/modules/graphics/macros/datatips/datatipSetGUI.bin Binary files differnew file mode 100755 index 000000000..9f625692e --- /dev/null +++ b/modules/graphics/macros/datatips/datatipSetGUI.bin diff --git a/modules/graphics/macros/datatips/datatipSetGUI.sci b/modules/graphics/macros/datatips/datatipSetGUI.sci new file mode 100755 index 000000000..4a936f53e --- /dev/null +++ b/modules/graphics/macros/datatips/datatipSetGUI.sci @@ -0,0 +1,56 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at; +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +function datatipSetGUI() + global datatipGUIwin + if datatipGUIwin==[] then return,end + global datatipGUIHandles datatipGUICurve + ud=datatipGetStruct(datatipGUICurve) + if typeof(ud)<>"datatips" then + //no datatips structure yet, initialize it + ud=datatipGetStruct(curve) + end + style=ud.style + if style(1)==1 then + datatipGUIHandles(1,1).value=1 + datatipGUIHandles(1,2).value=0 + else + datatipGUIHandles(1,1).value=0 + datatipGUIHandles(1,2).value=1 + end + if style(3)==1 then + datatipGUIHandles(2,1).value=1 + datatipGUIHandles(2,2).value=0 + else + datatipGUIHandles(2,1).value=0 + datatipGUIHandles(2,2).value=1 + end + if style(2)==1 then + datatipGUIHandles(3,1).value=1 + datatipGUIHandles(3,2).value=0 + else + datatipGUIHandles(3,1).value=0 + datatipGUIHandles(3,2).value=1 + end + if ~ud.interpolate then + datatipGUIHandles(4,1).value=1 + datatipGUIHandles(4,2).value=0 + else + datatipGUIHandles(4,1).value=0 + datatipGUIHandles(4,2).value=1 + end + if ~ud.replace then + datatipGUIHandles(5,1).value=1 + datatipGUIHandles(5,2).value=0 + else + datatipGUIHandles(5,1).value=0 + datatipGUIHandles(5,2).value=1 + end +endfunction + + diff --git a/modules/graphics/macros/datatips/datatipSetOrientation.bin b/modules/graphics/macros/datatips/datatipSetOrientation.bin Binary files differnew file mode 100755 index 000000000..7c550c379 --- /dev/null +++ b/modules/graphics/macros/datatips/datatipSetOrientation.bin diff --git a/modules/graphics/macros/datatips/datatipSetOrientation.sci b/modules/graphics/macros/datatips/datatipSetOrientation.sci new file mode 100755 index 000000000..241089d1d --- /dev/null +++ b/modules/graphics/macros/datatips/datatipSetOrientation.sci @@ -0,0 +1,30 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at; +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function datatipSetOrientation(tip_handle,o) + if argn(2)<>2 then + error(msprintf(_("%s: Wrong number of input argument(s): %d expected.\n"),... + "datatipSetOrientation",2)) + end + orientations=["automatic" "upper left" "upper right", "lower left","lower right"] + if type(tip_handle)<>9|size(tip_handle,"*")<>1|or(tip_handle.type<>"Compound") then + error(msprintf(_("%s: Wrong type for input argument #%d: A ''%s'' handle expected.\n"),... + "datatipSetOrientation",1,"datatip")) + end + + if o == "upper left" then + tip_handle.orientation = 0; + elseif o == "upper right" then + tip_handle.orientation = 1; + elseif o == "lower left" then + tip_handle.orientation = 2; + elseif o == "lower right" then + tip_handle.orientation = 3; + end +endfunction diff --git a/modules/graphics/macros/datatips/datatipSetSelected.bin b/modules/graphics/macros/datatips/datatipSetSelected.bin Binary files differnew file mode 100755 index 000000000..9a33d22b7 --- /dev/null +++ b/modules/graphics/macros/datatips/datatipSetSelected.bin diff --git a/modules/graphics/macros/datatips/datatipSetSelected.sci b/modules/graphics/macros/datatips/datatipSetSelected.sci new file mode 100755 index 000000000..2fbccc256 --- /dev/null +++ b/modules/graphics/macros/datatips/datatipSetSelected.sci @@ -0,0 +1,38 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at; +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function datatipSetSelected(curve_handles,tip_indices) + //datatip utility function + //set the selected datatip(s) + + [curve,ind]=datatipGetSelected(curve_handles) + //unselect the current datatip if any + if ind<>[] then + ud=datatipGetStruct(curve); + tips=ud.tips.children + tip_handle=tips(ind); + datatipHilite(tip_handle) //unhilite + ud.selected=0 + datatipSetStruct(curve,ud); + end + + //select the new one + if tip_indices<>[] then + k=tip_indices(1); + l=tip_indices(2); + curve=curve_handles(k); + ud=datatipGetStruct(curve); + tips=ud.tips.children + tip_handle=tips(l); + datatipHilite(tip_handle) //hilite + ud.selected=l + datatipSetStruct(curve,ud); + end +endfunction + diff --git a/modules/graphics/macros/datatips/datatipSetStruct.bin b/modules/graphics/macros/datatips/datatipSetStruct.bin Binary files differnew file mode 100755 index 000000000..5af97655d --- /dev/null +++ b/modules/graphics/macros/datatips/datatipSetStruct.bin diff --git a/modules/graphics/macros/datatips/datatipSetStruct.sci b/modules/graphics/macros/datatips/datatipSetStruct.sci new file mode 100755 index 000000000..7e2cab2dc --- /dev/null +++ b/modules/graphics/macros/datatips/datatipSetStruct.sci @@ -0,0 +1,39 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at; +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function ok=datatipSetStruct(curve,t) + if argn(2)<>2 then + error(msprintf(_("%s: Wrong number of input argument(s): %d expected.\n"),... + "datatipSetStruct",2)) + end + if type(curve)<>9|size(curve,"*")<>1|or(curve.type<>"Polyline") then + error(msprintf(_("%s: Wrong type for input argument #%d: A ''%s'' handle expected.\n"),... + "datatipSetType",1,"Polyline")) + end + + ok=%t + %datatips_i_s=generic_i_s + %datatips_i_st=generic_i_st + u_d=get(curve,"user_data") + if u_d==[] then + u_d.datatips=t + else + if typeof(u_d)=="st" then + u_d.datatips=t + elseif typeof(u_d)=="datatips" //for compatibilty + u.datatips=u_d + u_d=u + else + ok=%f + warning(msprintf(_("%s: Wrong type for curve user_data field: a struct expected.\n"),... + "datatipSetStruct")) + end + end + set(curve,"user_data",u_d) +endfunction diff --git a/modules/graphics/macros/datatips/datatipSetStyle.bin b/modules/graphics/macros/datatips/datatipSetStyle.bin Binary files differnew file mode 100755 index 000000000..91338cdd0 --- /dev/null +++ b/modules/graphics/macros/datatips/datatipSetStyle.bin diff --git a/modules/graphics/macros/datatips/datatipSetStyle.sci b/modules/graphics/macros/datatips/datatipSetStyle.sci new file mode 100755 index 000000000..eb9eda2fa --- /dev/null +++ b/modules/graphics/macros/datatips/datatipSetStyle.sci @@ -0,0 +1,81 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at; +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function datatipSetStyle(curve_handle,t,boxed,labeled) + //changes the tips interpolation modes for a given curve + // curve_handle : a handle on a polyline + // t : 1 "square mark" or 2 "Directional arrow" + // boxed : a boolean + // labeled : a boolean + if argn(2)<1 then + error(msprintf(_("%s: Wrong number of input argument(s): At least %d expected.\n"),... + "datatipSetType",1)) + end + if argn(2)<4 then labeled=%t,end + if argn(2)<3 then boxed=%t,end + + if type(curve_handle)<>9|size(curve_handle,"*")<>1|or(curve_handle.type<>"Polyline") then + error(msprintf(_("%s: Wrong type for input argument #%d: A ''%s'' handle expected.\n"),... + "datatipSetType",1,"Polyline")) + end + + if argn(2)==1 then + items=[_("Square mark, boxed label") + _("Square mark, simple label") + _("Square mark, no label") + _("Directional arrow, boxed label") + _("Directional arrow, simple label") + _("Directional arrow, no label") + ]; + sel=x_choose(items,_("Select tip style")) + if sel==0 then return,end + t=floor(sel/3)+1 + boxed=(modulo(sel,3)==1) + labeled=~(modulo(sel,3)==0) + else + if type(t)<>1|size(t,"*")<>1 then + error(msprintf(_("%s: Wrong type for input argument #%d: A scalar expected.\n"),... + "datatipSetType",2)) + end + if and(t<>[1 2]) then + error(msprintf(_("%s: Wrong value for input argument #%d: Must be in the set {%s}.\n"),... + "datatipSetType",2,"1,2")) + end + if type(boxed)<>4 |size(t,"*")<>1 then + error(msprintf(_("%s: Wrong type for input argument #%d: A boolean scalar expected.\n"),... + "datatipSetType",3)) + end + if type(labeled)<>4 |size(labeled,"*")<>1 then + error(msprintf(_("%s: Wrong type for input argument #%d: A boolean scalar expected.\n"),... + "datatipSetType",4)) + end + + end + style=[t bool2s(boxed) bool2s(labeled)] + + ud=datatipGetStruct(curve_handle) + if typeof(ud)<>"datatips" then; + ud=datatipGetStruct(curve_handle) + end + if or(ud.style<>style) then + + fig=curve_handle.parent + while fig.type<>"Figure" then fig=fig.parent,end + id=fig.immediate_drawing; + fig.immediate_drawing="off" + tips=ud.tips.children + for i=1:size(tips,"*") + datatipSetTipStyle(tips(i),style) + end + fig.immediate_drawing=id + ud.style=style + datatipSetStruct(curve_handle,ud) + end + +endfunction diff --git a/modules/graphics/macros/datatips/datatipSetTipPosition.bin b/modules/graphics/macros/datatips/datatipSetTipPosition.bin Binary files differnew file mode 100755 index 000000000..2bfe02ae7 --- /dev/null +++ b/modules/graphics/macros/datatips/datatipSetTipPosition.bin diff --git a/modules/graphics/macros/datatips/datatipSetTipPosition.sci b/modules/graphics/macros/datatips/datatipSetTipPosition.sci new file mode 100755 index 000000000..4c0924e42 --- /dev/null +++ b/modules/graphics/macros/datatips/datatipSetTipPosition.sci @@ -0,0 +1,35 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at; +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function datatipSetTipPosition(ud,tip_handle,pt,k) + //datatip utility function + point_handle=tip_handle.children(1) + string_handle=tip_handle.children(2) + + tip_refs=point_handle.user_data + [curve_handle,point_index]=tip_refs(:) + formatfunction=ud.formatfunction + + if ud.style==0 | size(curve_handle.data,1) == 1 then + point_handle.data=pt + else + if k<size(curve_handle.data,1) + dxy=curve_handle.data(k+1,:)-pt; + else + dxy=pt-curve_handle.data(k-1,:); + end + dxy=dxy/norm(dxy)/10000; + point_handle.data=[pt;pt+dxy] + end + tip_refs(2)=k; + point_handle.user_data=tip_refs + string_handle.text=formatfunction(curve_handle,pt,k) + setStringPosition(tip_handle,pt) + +endfunction diff --git a/modules/graphics/macros/datatips/datatipSetTipStyle.bin b/modules/graphics/macros/datatips/datatipSetTipStyle.bin Binary files differnew file mode 100755 index 000000000..a725f4447 --- /dev/null +++ b/modules/graphics/macros/datatips/datatipSetTipStyle.bin diff --git a/modules/graphics/macros/datatips/datatipSetTipStyle.sci b/modules/graphics/macros/datatips/datatipSetTipStyle.sci new file mode 100755 index 000000000..0d0b08051 --- /dev/null +++ b/modules/graphics/macros/datatips/datatipSetTipStyle.sci @@ -0,0 +1,76 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at; +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function datatipSetTipStyle(tip_handle,style) + //datatip utility function + point_handle=tip_handle.children(1) + string_handle=tip_handle.children(2) + bg=addcolor([255 255 238]/255); + tip_refs=point_handle.user_data + [curve_handle,k]=tip_refs(1:2) + + pt=point_handle.data(1,:) + + //label + if style(3)==0 then //no label + string_handle.visible="off" + else + string_handle.visible="on" + end + if style(2)==1 then //boxed + string_handle.background=bg; + string_handle.box="on"; + string_handle.fill_mode="on"; + string_handle.font_foreground=curve_handle.foreground; + else + string_handle.box="off" + string_handle.foreground=color("gray"); + string_handle.fill_mode="off"; + string_handle.font_foreground=curve_handle.foreground; + end + string_handle.clip_state="off"; + if string_handle.user_data<>[] then //preserve orientation if any + orient=string_handle.user_data(1) + else + orient=0; + end + string_handle.user_data=[orient style(2)] + + //marker + point_handle.mark_style=11; + point_handle.mark_size_unit="point"; + point_handle.mark_size=6; + select style(1) + case 1 then //square marker + point_handle.data= pt + point_handle.mark_mode="on"; + point_handle.mark_background=bg; + point_handle.mark_foreground=curve_handle.foreground; + point_handle.arrow_size_factor = 0; + case 2 then //directional arrow marker + + //compute tangeant + tip_refs=point_handle.user_data + [curve_handle,k]=tip_refs(1:2) + if k<size(curve_handle.data,1) + dxy=(curve_handle.data(k+1,:)-pt)/100000; + else + dxy=(pt-curve_handle.data(k-1,:))/100000; + end + point_handle.data=[pt;pt+dxy] + //set properties + point_handle.mark_background=curve_handle.foreground; + point_handle.mark_foreground=curve_handle.foreground; + point_handle.mark_mode="off"; + point_handle.arrow_size_factor = 1.5; + point_handle.polyline_style = 4; + point_handle.foreground=curve_handle.foreground; + end + if style(3)<>0 then setStringPosition(tip_handle,pt),end +endfunction diff --git a/modules/graphics/macros/datatips/datatipsGUI.bin b/modules/graphics/macros/datatips/datatipsGUI.bin Binary files differnew file mode 100755 index 000000000..37365c4d0 --- /dev/null +++ b/modules/graphics/macros/datatips/datatipsGUI.bin diff --git a/modules/graphics/macros/datatips/datatipsGUI.sci b/modules/graphics/macros/datatips/datatipsGUI.sci new file mode 100755 index 000000000..ca45db052 --- /dev/null +++ b/modules/graphics/macros/datatips/datatipsGUI.sci @@ -0,0 +1,413 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at; +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function datatipsGUI(curve_handle) + global datatipGUIwin + if datatipGUIwin<>[]&or(datatipGUIwin==winsid()) then //the gui window is already opened + global datatipGUICurve + datatipGUICurve= curve_handle + datatipSetGUI() + return + end + + + global datatipGUIHandles datatipGUICurve datatipGUIwin + margin_x = 5; // Horizontal margin between each elements + margin_y = 5; // Vertical margin between each elements + button_w = 150; + button_h = 25; + label_h = 20; + label_w = 160; + slabel_w = 80; + editor_h = 120; + axes_w = 3*margin_x+label_w+2*(slabel_w+4*margin_x+label_h); + editor_w = axes_w-2*margin_x; + axes_h = 4*margin_y+6*(label_h+margin_y)+ button_h; + defaultfont = "arial"; // Default Font + datatipGUICurve= curve_handle + ud=datatipGetStruct(datatipGUICurve) + if typeof(ud)<>"datatips" then + //no datatips structure yet, initialize it + ud=datatipGetStruct(curve) + end + style=ud.style + + datatipGUIwin=max(winsid())+1 + + fig_id=datatipGUIwin + fig = scf(fig_id) + fig.event_handler="datatipGUIEventHandler" + fig.event_handler_enable="on" + + // Remove Scilab graphics menus & toolbar + // drawlater (bug) + delmenu(fig.figure_id, gettext("&File")); + delmenu(fig.figure_id, gettext("&Tools")); + delmenu(fig.figure_id, gettext("&Edit")); + delmenu(fig.figure_id, gettext("&?")); + toolbar(fig.figure_id, "off"); + fig.axes_size = [axes_w axes_h]; + + + fig.background = addcolor([0.8 0.8 0.8]); + fig.figure_name = _("Datatips style"); + ax=fig.children; + ax.background= fig.background ; + gui=uicontrol( ... + "parent" , fig,... + "style" , "frame",... + "units" , "pixels",... + "position" , [0 0 axes_w axes_h],... + "background" , [1 1 1]*0.8, ... + "visible" , "on"); + + yo=axes_h-margin_y-label_h; + xo=margin_x; + H=[] + //Datatips positionning + x=xo; + y=yo; + uicontrol( ... + "parent" , gui,... + "style" , "text",... + "string" , _("Marker style:"),... + "units" , "pixels",... + "position" , [x y label_w label_h],.... + "fontname" , defaultfont,... + "fontunits" , "points",... + "fontsize" , 12,... + "fontweight" , "bold", ... + "horizontalalignment" , "left", ... + "background" , [1 1 1]*0.8, ... + "visible" , "on"); + x=x+label_w+margin_x; + uicontrol( ... + "parent" , gui,... + "style" , "text",... + "string" , _("Square"),... + "units" , "pixels",... + "position" , [x y slabel_w label_h],... + "HorizontalAlignment" , "right",... + "fontname" , defaultfont,... + "fontunits" , "points",... + "fontsize" , 12,... + "background" , [1 1 1]*0.8, ... + "visible" , "on"); + x=x+slabel_w+margin_x + r1= uicontrol( ... + "parent" , gui,... + "style" , "radiobutton",... + "value" , 1,... + "units" , "pixels",... + "position" , [x y label_h label_h],.... + "background" , [1 1 1]*0.8, ... + "callback" , "datatipRadioCallback(""sty"",%t)",... + "visible" , "on"); + x=x+label_h+4*margin_x; + uicontrol( ... + "parent" , gui,... + "style" , "text",... + "string" , _("Arrow"),... + "units" , "pixels",... + "position" , [x y slabel_w label_h],.... + "HorizontalAlignment" , "right",... + "fontname" , defaultfont,... + "fontunits" , "points",... + "fontsize" , 12,... + "background" , [1 1 1]*0.8, ... + "visible" , "on"); + + x=x+slabel_w+margin_x; + r2= uicontrol( ... + "parent" , gui,... + "style" , "radiobutton",... + "value" , 0,... + "units" , "pixels",... + "position" , [x y label_h label_h],.... + "background" , [1 1 1]*0.8, ... + "callback" , "datatipRadioCallback(""sty"",%f)",... + "visible" , "on"); + H=[H;r1 r2] + //Datatips Label + x=xo; + y=y-margin_y-label_h; + uicontrol( ... + "parent" , gui,... + "style" , "text",... + "string" , _("Labeled?"),... + "units" , "pixels",... + "position" , [x y label_w label_h],.... + "fontname" , defaultfont,... + "fontunits" , "points",... + "fontsize" , 12,... + "fontweight" , "bold", ... + "horizontalalignment" , "left", ... + "background" , [1 1 1]*0.8, ... + "visible" , "on"); + x=x+label_w+margin_x; + uicontrol( ... + "parent" , gui,... + "style" , "text",... + "string" , _("Yes"),... + "units" , "pixels",... + "position" , [x y slabel_w label_h],.... + "fontname" , defaultfont,... + "fontunits" , "points",... + "fontsize" , 12,... + "horizontalalignment" , "right", ... + "background" , [1 1 1]*0.8, ... + "visible" , "on"); + x=x+slabel_w+margin_x + r1= uicontrol( ... + "parent" , gui,... + "style" , "radiobutton",... + "value" , 1,... + "units" , "pixels",... + "position" , [x y label_h label_h],.... + "background" , [1 1 1]*0.8, ... + "callback" , "datatipRadioCallback(""lab"",%t)",... + "visible" , "on"); + x=x+label_h+4*margin_x; + uicontrol( ... + "parent" , gui,... + "style" , "text",... + "string" , _("No"),... + "units" , "pixels",... + "position" , [x y slabel_w label_h],.... + "fontname" , defaultfont,... + "fontunits" , "points",... + "fontsize" , 12,... + "horizontalalignment" , "right", ... + "background" , [1 1 1]*0.8, ... + "visible" , "on"); + + x=x+slabel_w+margin_x; + r2= uicontrol( ... + "parent" , gui,... + "style" , "radiobutton",... + "value" , 0,... + "units" , "pixels",... + "position" , [x y label_h label_h],.... + "background" , [1 1 1]*0.8, ... + "callback" , "datatipRadioCallback(""lab"",%f)",... + "visible" , "on"); + H=[H;r1 r2] + + //Datatips box + x=xo; + y=y-margin_y-label_h; + uicontrol( ... + "parent" , gui,... + "style" , "text",... + "string" , _("Boxed?"),... + "units" , "pixels",... + "position" , [x y label_w label_h],.... + "fontname" , defaultfont,... + "fontunits" , "points",... + "fontsize" , 12,... + "fontweight" , "bold", ... + "horizontalalignment" , "left", ... + "background" , [1 1 1]*0.8, ... + "visible" , "on"); + x=x+label_w+margin_x; + uicontrol( ... + "parent" , gui,... + "style" , "text",... + "string" , _("Yes"),... + "units" , "pixels",... + "position" , [x y slabel_w label_h],.... + "fontname" , defaultfont,... + "fontunits" , "points",... + "fontsize" , 12,... + "horizontalalignment" , "right", ... + "background" , [1 1 1]*0.8, ... + "visible" , "on"); + x=x+slabel_w+margin_x; + r1= uicontrol( ... + "parent" , gui,... + "style" , "radiobutton",... + "value" , 1,... + "units" , "pixels",... + "position" , [x y label_h label_h],.... + "background" , [1 1 1]*0.8, ... + "callback" , "datatipRadioCallback(""box"",%t)",... + "visible" , "on"); + x=x+label_h+4*margin_x; + uicontrol( ... + "parent" , gui,... + "style" , "text",... + "string" , _("No"),... + "units" , "pixels",... + "position" , [x y slabel_w label_h],.... + "fontname" , defaultfont,... + "fontunits" , "points",... + "fontsize" , 12,... + "horizontalalignment" , "right", ... + "background" , [1 1 1]*0.8, ... + "visible" , "on"); + + x=x+slabel_w+margin_x; + r2= uicontrol( ... + "parent" , gui,... + "style" , "radiobutton",... + "value" , 0,... + "units" , "pixels",... + "position" , [x y label_h label_h],.... + "background" , [1 1 1]*0.8, ... + "callback" , "datatipRadioCallback(""box"",%f)",... + "visible" , "on"); + H=[H;r1 r2] + //marker position + x=xo; + y=y-margin_y-label_h; + uicontrol( ... + "parent" , gui,... + "style" , "text",... + "string" , _("Positionning?"),... + "units" , "pixels",... + "position" , [x y label_w label_h],.... + "fontname" , defaultfont,... + "fontunits" , "points",... + "fontsize" , 12,... + "fontweight" , "bold", ... + "horizontalalignment" , "left", ... + "background" , [1 1 1]*0.8, ... + "visible" , "on"); + x=x+label_w+margin_x; + uicontrol( ... + "parent" , gui,... + "style" , "text",... + "string" , _("Knots"),... + "units" , "pixels",... + "position" , [x y slabel_w label_h],.... + "fontname" , defaultfont,... + "fontunits" , "points",... + "fontsize" , 12,... + "horizontalalignment" , "right", ... + "background" , [1 1 1]*0.8, ... + "visible" , "on"); + x=x+slabel_w+margin_x; + r1= uicontrol( ... + "parent" , gui,... + "style" , "radiobutton",... + "value" , 1,... + "units" , "pixels",... + "position" , [x y label_h label_h],.... + "background" , [1 1 1]*0.8, ... + "callback" , "datatipRadioCallback(""pos"",%t)",... + "visible" , "on"); + x=x+label_h+4*margin_x; + uicontrol( ... + "parent" , gui,... + "style" , "text",... + "string" , _("Interpolated"),... + "units" , "pixels",... + "position" , [x y slabel_w label_h],.... + "fontname" , defaultfont,... + "fontunits" , "points",... + "fontsize" , 12,... + "horizontalalignment" , "right", ... + "background" , [1 1 1]*0.8, ... + "visible" , "on"); + + x=x+slabel_w+margin_x; + r2= uicontrol( ... + "parent" , gui,... + "style" , "radiobutton",... + "value" , 0,... + "units" , "pixels",... + "position" , [x y label_h label_h],.... + "background" , [1 1 1]*0.8, ... + "callback" , "datatipRadioCallback(""pos"",%f)",... + "visible" , "on"); + H=[H;r1 r2] + //Multiple datatips + x=xo; + y=y-margin_y-label_h; + uicontrol( ... + "parent" , gui,... + "style" , "text",... + "string" , _("Allow multiple datatips?"),... + "units" , "pixels",... + "position" , [x y label_w label_h],.... + "fontname" , defaultfont,... + "fontunits" , "points",... + "fontsize" , 12,... + "fontweight" , "bold", ... + "horizontalalignment" , "left", ... + "background" , [1 1 1]*0.8, ... + "visible" , "on"); + x=x+label_w+margin_x; + uicontrol( ... + "parent" , gui,... + "style" , "text",... + "string" , _("Yes"),... + "units" , "pixels",... + "position" , [x y slabel_w label_h],.... + "fontname" , defaultfont,... + "fontunits" , "points",... + "fontsize" , 12,... + "horizontalalignment" , "right", ... + "background" , [1 1 1]*0.8, ... + "visible" , "on"); + x=x+slabel_w+margin_x; + r1= uicontrol( ... + "parent" , gui,... + "style" , "radiobutton",... + "value" , 1,... + "units" , "pixels",... + "position" , [x y label_h label_h],.... + "background" , [1 1 1]*0.8, ... + "callback" , "datatipRadioCallback(""mul"",%t)",... + "visible" , "on"); + x=x+label_h+4*margin_x; + uicontrol( ... + "parent" , gui,... + "style" , "text",... + "string" , _("No"),... + "units" , "pixels",... + "position" , [x y slabel_w label_h],.... + "fontname" , defaultfont,... + "fontunits" , "points",... + "fontsize" , 12,... + "horizontalalignment" , "right", ... + "background" , [1 1 1]*0.8, ... + "visible" , "on"); + + x=x+slabel_w+margin_x; + r2= uicontrol( ... + "parent" , gui,... + "style" , "radiobutton",... + "value" , 0,... + "units" , "pixels",... + "position" , [x y label_h label_h],.... + "background" , [1 1 1]*0.8, ... + "callback" , "datatipRadioCallback(""mul"",%f)",... + "visible" , "on"); + H=[H;r1 r2] + //label edition function + x=xo; + y=y-2*margin_y-button_h; + + E= uicontrol( ... + "parent" , gui, ... + "style" , "pushbutton", ... + "string" , _("Edit label generator"), ... + "units" , "pixels",... + "position" , [x y button_w button_h], ... + "fontname" , defaultfont, ... + "fontunits" , "points", ... + "fontsize" , 12, ... + "callback" , "global datatipGUICurve;datatipSetDisplay(datatipGUICurve)", ... + "visible" , "on"); + + + datatipGUIHandles=H + datatipSetGUI() +endfunction diff --git a/modules/graphics/macros/datatips/lib b/modules/graphics/macros/datatips/lib Binary files differnew file mode 100755 index 000000000..883e2c827 --- /dev/null +++ b/modules/graphics/macros/datatips/lib diff --git a/modules/graphics/macros/datatips/names b/modules/graphics/macros/datatips/names new file mode 100755 index 000000000..105d30093 --- /dev/null +++ b/modules/graphics/macros/datatips/names @@ -0,0 +1,25 @@ +%datatips_p +datatipCreatePopupMenu +datatipDefaultDisplay +datatipDeleteSelected +datatipGUIEventHandler +datatipGetEntities +datatipGetSelected +datatipGetStruct +datatipHilite +datatipManagerMode +datatipMove +datatipRadioCallback +datatipRemoveAll +datatipRemoveNearest +datatipSetGUI +datatipSetOrientation +datatipSetSelected +datatipSetStruct +datatipSetStyle +datatipSetTipPosition +datatipSetTipStyle +datatipsGUI +orthProj +pixDist +setStringPosition diff --git a/modules/graphics/macros/datatips/orthProj.bin b/modules/graphics/macros/datatips/orthProj.bin Binary files differnew file mode 100755 index 000000000..305eb662a --- /dev/null +++ b/modules/graphics/macros/datatips/orthProj.bin diff --git a/modules/graphics/macros/datatips/orthProj.sci b/modules/graphics/macros/datatips/orthProj.sci new file mode 100755 index 000000000..d51816988 --- /dev/null +++ b/modules/graphics/macros/datatips/orthProj.sci @@ -0,0 +1,49 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at; +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [d,ptp,ind,c]=orthProj(data,pt) + // computes minimum distance from a point to a polyline + //d minimum distance of the point to the nearest polyline data point + //ptp projected point coordiantes + //ind projection lies on segment [ind ind+1] + //c orthogonal projection coefficient + if argn(2)<>2 then + error(msprintf(_("%s: Wrong number of input argument(s): %d expected.\n"),"orthProj",2)) + end + + + d = [];ptp = [];ind = [],c = [] + [n,m] = size(data) + pt = matrix(pt,1,-1) //make pt a row vector + if n<2 then return,end + //the orthogonal projection coefficient of the vector y on the vector x; + //is given by <x,y>/||x||^2 + //shift origin to (0,0) for each segment defined by data + X = (data(2:$,:)-data(1:$-1,:)) + //apply similar origin transformation to the given point + Y = ones(n-1,1)*pt-data(1:$-1,:) ; + //compute the orthogonal projection coefficients relative to each segments + //first remove zero length segements; + L = sum(X.*X,2); //segment lengths + nz = find(L>0) + X = X(nz,:); Y = Y(nz,:); + P = sum(X.*Y,2)./L(nz); + //the projected point lies in the segment nz(i) if 0 <= P(i)<1 + i_in = find(P >= 0 & P<1); //find segments the projected point falls in + + if i_in<>[] then + //find the segment that realizes the min distance + [d,k] = min(sum((X(i_in,:).*(P(i_in)*ones(1,m))-Y(i_in,:)).^2,2)) + d = sqrt(d) //the mini distance between the given point and the curve + i_in = i_in(k) //index of the first bound of the segment in data + c = P(i_in) // the orthogonal projection coefficient + ind = nz(i_in) //make i_in relative to the initial data + ptp = data(ind,:)+(data(ind+1,:)-data(ind,:))*c //the projected point + end +endfunction diff --git a/modules/graphics/macros/datatips/pixDist.bin b/modules/graphics/macros/datatips/pixDist.bin Binary files differnew file mode 100755 index 000000000..6a68e299d --- /dev/null +++ b/modules/graphics/macros/datatips/pixDist.bin diff --git a/modules/graphics/macros/datatips/pixDist.sci b/modules/graphics/macros/datatips/pixDist.sci new file mode 100755 index 000000000..c735d2e30 --- /dev/null +++ b/modules/graphics/macros/datatips/pixDist.sci @@ -0,0 +1,14 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at; +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function d=pixDist(p1,p2) + //computes the distance in pixels of two points + [x1,y1]=xchange([p1(1) p2(1)],[p1(2) p2(2)],"f2i") + d=max(abs([x1(2)-x1(1),y1(2)-y1(1)])) +endfunction diff --git a/modules/graphics/macros/datatips/setStringPosition.bin b/modules/graphics/macros/datatips/setStringPosition.bin Binary files differnew file mode 100755 index 000000000..e73c82ab6 --- /dev/null +++ b/modules/graphics/macros/datatips/setStringPosition.bin diff --git a/modules/graphics/macros/datatips/setStringPosition.sci b/modules/graphics/macros/datatips/setStringPosition.sci new file mode 100755 index 000000000..7d544d416 --- /dev/null +++ b/modules/graphics/macros/datatips/setStringPosition.sci @@ -0,0 +1,138 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010-2011 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at; +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function setStringPosition(tip_handle,pt) + //Computes the position of the lower left corner of the string box. + // + //These coordinates must be expressed in user coordinates units but their + //computation takes into account the pixel dimensions of the text boxes + //when they are not located in the upper right position + ax=tip_handle.parent + while ax.type<>"Axes" then ax=ax.parent,end + string_handle=tip_handle.children(2); + point_handle=tip_handle.children(1); + + + params=string_handle.user_data + orient=params(1); + if size(params,"*")>1 then //for compatibility + style=params(2) + else + style=1 + end + pt=pt(1,:) + + r=xstringl(0,0,string_handle.text);r=r(3:4)'; + if style==1 then + d=mark_usersize(point_handle); + else + d=[0 0] + end + orient=string_handle.user_data(1); + if orient==0 then //automatic + + //compute the slope and curvature at the tip point + curve_handle=point_handle.user_data(1) + k=point_handle.user_data(2) + np=size(curve_handle.data,1) + T=curve_handle.data([max(k-1,1) k min(np,k+1)],:) + + + if size(T,2)==3 then + [Tx,Ty]=geom3d(T(:,1),T(:,2),T(:,3)) + T=[Tx Ty]; + end + d1=sum(diff(T,1,1),1)/2; + d2=diff(T,2,1); + c=(d1(1)*d2(2)-d1(2)*d2(1)) + + //set position according to the slope and curvature sign + if d1(1)>0 then + if d1(2)>0 then + if c<0 then//upper left + orient=1 + else //lower right + orient=4 + end + else + if c<0 then//upper right + orient=2 + else //lower left + orient=3 + end + end + else + if d1(2)>0 then + if c>0 then //upper right + orient=2 + else //lower left + orient=3 + end + else + if c>0 then//upper left + orient=1 + else //lower right + orient=4 + end + + end + end + // mprintf("d1=[%f %f], c=%f, orient=%d\n",d1(1),d1(2),c,orient) + if ax.zoom_box==[] + box=ax.data_bounds + else + box=[ax.zoom_box(1:2);ax.zoom_box(3:4)]; + end + //take care of the plot boundaries + // mprintf("Y:%f< [%f %f]<%f\n",box(1,2),pt(2)-r(2),pt(2)+r(2),box(2,2)) + // mprintf("X:%f< [%f %f]<%f\n",box(1,1),pt(1)-r(1),pt(1)+r(1),box(2,1)) + if or(orient==[1 2])&pt(2)+r(2)>box(2,2) then//upper bound on Y + orient=5-orient + end + if or(orient==[3 4])&pt(2)-r(2)<box(1,2) then//lower bound on Y + orient=5-orient + end + if or(orient==[2 4])&pt(1)+r(1)>box(2,1) then//right bound on X + orient=orient-1 + end + if or(orient==[1 3])&pt(1)-r(1)<box(1,1) then//left bound on X + orient=orient+1 + end + end + select orient + case 1 then //upper left + dx=-d(1)-r(1);dy=d(2); + case 2 then //upper right + dx=d(1);dy=d(2) + case 3 then //lower left + dx=-d(1)-r(1);dy=-d(2)-r(2) + case 4 then //lower right + dx=d(1);dy=-d(2)-r(2) + end + + if ax.view=="3d" then + angles=ax.rotation_angles*%pi/180; + t=angles(2);a=angles(1); + st=sin(t);ct=cos(t);sa=sin(a);ca=cos(a) + c=sum(ax.data_bounds,1)/2 + x=pt(1)-c(1) + y=pt(2)-c(2) + z=pt(3)-c(3) + pos=c+[(st*x-ct*y-dx)/st,0,(st*dy+st*sa*z-ca*y-ct*ca*dx)/(sa*st)] + else + pos=pt+[dx dy] + + end + string_handle.data=pos +endfunction +function usize=mark_usersize(m) + pix_size=10*(m.mark_size+1) + [x1,y1]=xchange([0 pix_size],[0 pix_size],"i2f"); + usize=abs([x1(2)-x1(1) y1(2)-y1(1)])/20; +endfunction diff --git a/modules/graphics/macros/dragrect.bin b/modules/graphics/macros/dragrect.bin Binary files differnew file mode 100755 index 000000000..26904714c --- /dev/null +++ b/modules/graphics/macros/dragrect.bin diff --git a/modules/graphics/macros/dragrect.sci b/modules/graphics/macros/dragrect.sci new file mode 100755 index 000000000..ae417afb1 --- /dev/null +++ b/modules/graphics/macros/dragrect.sci @@ -0,0 +1,38 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [rects,btn]=dragrect(varargin) + + // Check number of input argument + if size(varargin)<>1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "dragrect", 1)); + end + rects=varargin(1); + + if size(rects,1)==1 then rects=rects(:),end + n=size(rects,2) + f=gcf(); + a=gca(); + db = a.data_bounds; + xrects(rects) + a.data_bounds = db; + R=gce(); //Compound of rectangles + rep=[rects(1),rects(2),-1] + while rep(3)==-1 then + repn=xgetmouse() + if repn(3)==-100 then //window has been closed + btn=repn(3) + return + end + rects(1:2,:)=rects(1:2,:)+(repn(1:2)-rep(1:2))'*ones(1,n); + move(R,repn(1:2)-rep(1:2)) + rep=repn + end + delete(R) + btn=rep(3) +endfunction diff --git a/modules/graphics/macros/edit_curv.bin b/modules/graphics/macros/edit_curv.bin Binary files differnew file mode 100755 index 000000000..8f109a181 --- /dev/null +++ b/modules/graphics/macros/edit_curv.bin diff --git a/modules/graphics/macros/edit_curv.sci b/modules/graphics/macros/edit_curv.sci new file mode 100755 index 000000000..6164fd3cd --- /dev/null +++ b/modules/graphics/macros/edit_curv.sci @@ -0,0 +1,478 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 1993 - INRIA - Serge Steer +// Copyright (C) 1993 - INRIA - Habib Jreij +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [x,y,ok,gc]=edit_curv(x,y,job,tit,gc) + // mod_curv - Edition de courbe interactive + //%Syntaxe + // [x,y,ok]=mod_curv(xd,yd,job,tit) + //%Parametres + // xd : vecteur des abscisses donnees (eventuellement []) + // yd : vecteur des ordonnees donnees (eventuellement []) + // job : chaine de 3 caracteres specifiant les operations + // permises: + // - Si la chaine contient le caractere 'a', il est + // possible d'ajouter des points aux donnees, sinon + // il est seulement possible de les deplacer + // - Si la chaine contient le caractere 'x', il est + // possible de deplacer les points horizontalement + // - Si la chaine contient le caractere 'y', il est + // possible de deplacer les points verticalement + // tit : liste de trois chaines de caracteres + // tit(1) : titre de la courbe (peut etre un vecteur colonne) + // tit(2) : label de l'axe des abscisses + // tit(3) : label de l'axe des ordonnees + // x : vecteur des abscisses resultat + // y : vecteur des ordonnees resultat + // ok : vaut %t si la sortie as ete demandee par le menu Ok + // et %f si la sortie as ete demandee par le menu Abort + //%menus + // Ok : sortie de l'editeur et retour de la courbe editee + // Abort : sortie de l'editeur et retour au donnes initiales + // Undo : annulation de la derniere modification + // Size : changement des bornes du graphique + // Grids : changement des graduations du graphique + // Clear : effacement de la courbe (x=[] et y=[]) (sans quitter l'editeur) + // Read : lecture de la courbe a partir d'un fichier d'extension .xy + // Save : sauvegarde binaire (sur un fichier d'extension .xy) de + // la courbe + //! + [lhs,rhs]=argn(0) + + ok = %t; + if rhs==0 then x=[]; y=[],end; + if rhs==1 then y=x;x=(1:size(y,"*"))',end + if rhs<3 then job="axy",end + if rhs<4 then tit=[" "," "," "],end + if size(tit,"*")<3 then tit(3)=" ",end + // + + [mx,nx] = size(x); x=x(:) + [my,ny] = size(y); y=y(:) + n = min(mx*nx,my*ny) + x= x(1:n);y=y(1:n); + xsav=x; ysav=y; xs=x; ys=y; + // + lj = length(job) + add=0;modx=0;mody=0 + for k=1:lj + jk = part(job,k) + select jk + case "a" then add = 1, + case "x" then modx= 1 + case "y" then mody= 1 + else error(msprintf(gettext("%s: Wrong value for input argument #%d: Must be in the set {%s}.\n"), "edit_curv", 3, "a, x, y")); + end + end + eps = 0.03 + symbsiz = 0.2 + // bornes initiales du graphique + if rhs<5 then + if mx<>0 then + xmx = max(x); xmn = min(x) + ymx = max(y); ymn = min(y) + dx = xmx-xmn; dy = ymx-ymn + if dx==0 then dx=max(xmx/2,1),end + xmn=xmn-dx/10;xmx=xmx+dx/10 + if dy==0 then dy=max(ymx/2,1),end; + ymn=ymn-dy/10;ymx=ymx+dy/10; + else + xmn=0;ymn=0;xmx=1;ymx=1;dx=1;dy=1 + end + rect=[xmn,ymn,xmx,ymx]; + axisdata=[2 10 2 10]; + gc = list(rect,axisdata); + else //** rhs=5 as in Scicos ;) + [rect,axisdata] = gc(1:2) + xmn = rect(1); + ymn = rect(2); + xmx = rect(3); + ymx = rect(4); + dx = xmx-xmn; + dy = ymx-ymn; + end + + // Set menus and callbacks + menu_d = ["Read","Save","Clear"] + menu_e = ["Undo","Size","Replot","Ok","Abort"] + menus = list(["Edit","Data"],menu_e,menu_d) + w="menus(2)(";rpar=")" + Edit=w(ones(menu_e))+string(1:size(menu_e,"*"))+rpar(ones(menu_e)) + w="menus(3)(";rpar=")" + Data=w(ones(menu_d))+string(1:size(menu_d,"*"))+rpar(ones(menu_d)) + + curwin = max(winsid())+1; + scf(curwin) ; + + // Disable the menus and toolbars + toolbar(curwin,"off"); + delmenu(curwin,gettext("File")); + delmenu(curwin,gettext("Tools")); + delmenu(curwin,gettext("Edit"));; + delmenu(curwin,"?"); + + execstr("Edit_"+string(curwin)+"=Edit"); + execstr("Data_"+string(curwin)+"=Data"); + menubar(curwin,menus) + // + edit_curv_figure = gcf(); + edit_curv_figure.figure_name = "edit_curv"; + + edit_curv_axes = gca(); + edit_curv_axes.data_bounds = [rect(1),rect(2);rect(3),rect(4)] + edit_curv_axes.axes_visible="on"; + edit_curv_axes.grid=[4 4]; + if x<>[] then + xpolys(x*[1 1],y*[1 1],[1,-1]) + hdl=edit_curv_axes.children.children + else + hdl=[] + end + + xtitle(tit(1),tit(2),tit(3)); + + + // -- boucle principale + while %t then + [n1,n2] = size(x); + npt = n1*n2 ; + + [btn,xc,yc,win,Cmenu] = get_click(); + + //** disp([btn,xc,yc,win]); //** DEBUG only + + c1 = [xc,yc]; + + if Cmenu=="Quit" then Cmenu="Abort",end + if Cmenu==[] then Cmenu="edit",end + if Cmenu=="Exit" then Cmenu="Ok",end + + select Cmenu + case [] then + // ce n est pas un menu + break + + case "Ok" then // -- ok menu + rect = matrix(edit_curv_axes.data_bounds',1,4); + gc = list(rect,axisdata); + delete(edit_curv_figure) + return; + + case "Abort" then // -- abort menu + x = xsav + y = ysav + delete(edit_curv_figure) + ok = %f; + return + + case "XClose" then //** the user manually close the win + x = xsav + y = ysav + ok = %f; + return + + case "Undo" then + x=xs;y=ys + if x<>[] then hdl.data=[x y]; end + + case "Size" then + while %t + [ok,xmn,xmx,ymn,ymx]=getvalue("Please input new limits",.. + ["xmin";"xmax";"ymin";"ymax"],.. + list("vec",1,"vec",1,"vec",1,"vec",1),.. + string([xmn;xmx;ymn;ymx])) + if ~ok then break,end + if xmn>xmx|ymn>ymx then + messagebox("Limits are not accettable","modal"); + else + break + end + end + if ok then + dx=xmx-xmn;dy=ymx-ymn + if dx==0 then dx=max(xmx/2,1),xmn=xmn-dx/10;xmx=xmx+dx/10;end + if dy==0 then dy=max(ymx/2,1),ymn=ymn-dy/5;ymx=ymx+dy/10;end + rect=[xmn,ymn,xmx,ymx]; + edit_curv_axes.data_bounds=[rect(1),rect(2);rect(3),rect(4)] + end + + case "Clear" then + if hdl<>[] then delete(hdl),hdl=[];end + x=[];y=[]; + + case "Read" then + [x,y]=readxy() + mx=min(prod(size(x)),prod(size(y))) + if mx<>0 then + xmx=max(x);xmn=min(x) + ymx=max(y);ymn=min(y) + dx=xmx-xmn;dy=ymx-ymn + if dx==0 then dx=max(xmx/2,1),xmn=xmn-dx/10;xmx=xmx+dx/10;end + if dy==0 then dy=max(ymx/2,1),ymn=ymn-dy/5;ymx=ymx+dy/10;end + else + xmn=0;ymn=0;xmx=1;ymx=1;dx=1;dy=1 + end + rect=[xmn,ymn,xmx,ymx]; + edit_curv_axes.data_bounds=[rect(1),rect(2);rect(3),rect(4)] + if x<>[]&y<>[] then + if hdl==[] then + xpolys(x(1)*[1 1],y(1)*[1 1],[1,-1]) + hdl=gce();hdl=hdl.children + end + hdl.data=[x y]; + else + if hdl<>[] then delete(hdl),end + x=[];y=[]; + end + + case "Save" then + savexy(x,y) + + case "Replot" then + // for compatibility only, perform nothing on purpose + + case "edit" then + npt=prod(size(x)) + if npt<>0 then + dist=((x-ones(npt,1)*c1(1))/dx).^2+((y-ones(npt,1)*c1(2))/dy).^2 + [m,k]=min(dist);m=sqrt(m) + else + m=3*eps + end + if m<eps then //on deplace le point + xs=x;ys=y + [x,y]=movept(x,y) + else + if add==1 then + xs=x;ys=y //on rajoute un point de cassure + [x,y]=addpt(c1,x,y) + end + end + end + end +endfunction + + +function [btn,xc,yc,win,Cmenu] = get_click(flag) + //** 05/01/09 : update for Scilab 5.1: (close code is now -1000) + + if ~or(winsid()==curwin) then + Cmenu = "Quit"; + return ; + end + + if argn(2) == 1 then + [btn, xc, yc, win, str] = xclick(flag); + else + [btn, xc, yc, win, str] = xclick(); + end + + if btn == -1000 then //** user close the window [X] + if win == curwin then + Cmenu = "XClose"; + else + Cmenu = "Open/Set"; + end + return ; + end + + if btn == -2 then //** user select a dynamic menu + xc = 0; yc = 0; + execstr("Cmenu=" + part(str, 9:length(str) - 1) ); + execstr("Cmenu=" + Cmenu); + return; + end + + Cmenu = []; + +endfunction + + +function [x,y] = addpt(c1,x,y) + // permet de rajouter un point de cassure + npt = prod(size(x)) + c1 = c1' + if hdl==[] then + x = c1(1); + y = c1(2); + xpolys(x*[1 1],y*[1 1],[1,-1]); + hdl = resume(edit_curv_axes.children(1).children) + end + //recherche des intervalles en x contenant l'abscisse designee + kk=[] + if npt>1 then + kk=find((x(1:npt-1)-c1(1)*ones(x(1:npt-1))).. + .*(x(2:npt)-c1(1)*ones(x(2:npt)))<=0) + end + if kk<>[] then + // recherche du segment sur le quel on a designe un point + pp=[];d=[];i=0 + for k=kk + i=i+1 + pr=projaff(x(k:k+1),y(k:k+1),c1) + if (x(k)-pr(1))*(x(k+1)-pr(1))<=0 then + pp=[pp pr] + d1=rect(3)-rect(1) + d2=rect(4)-rect(2) + d=[d norm([d1;d2].\(pr-c1))] + end + end + if d<>[] then + [m,i]=min(d) + if m<eps + k=kk(i) + pp=pp(:,i) + x=x([1:k k:npt]);x(k+1)=pp(1); + y=y([1:k k:npt]);y(k+1)=pp(2); + hdl.data=[x y]; + return + end + end + end + d1=rect(3)-rect(1) + d2=rect(4)-rect(2) + if norm([d1;d2].\([x(1);y(1)]-c1))<norm([d1;d2].\([x(npt);y(npt)]-c1)) then + // -- mise a jour de x et y + x(2:npt+1)=x;x(1)=c1(1) + y(2:npt+1)=y;y(1)=c1(2) + else + // -- mise a jour de x et y + x(npt+1)=c1(1) + y(npt+1)=c1(2) + end + hdl.data=[x y]; +endfunction + +function [x,y]=movept(x,y) + //on bouge un point existant + hdl; + rep(3)=-1 + while rep(3)==-1 do + rep = xgetmouse(); + xc=rep(1);yc=rep(2);c2=[xc;yc] + if modx==0 then c2(1)=x(k);end + if mody==0 then c2(2)=y(k);end + x(k)=c2(1);y(k)=c2(2) + hdl.data=[x,y]; + end +endfunction + + +function [x,y] = readxy() + + function xy = findPolyline(children) + xy = []; + for i = 1:length(children) + select children(i).type, + case "Polyline" then + xy = children(i).data; + return + case "Axes" then + xy = findPolyline(children(i).children); + return + case "Compound" then + xy = findPolyline(children(i).children); + return + end + end + endfunction + + fn=uigetfile(["*.scg";"*.sod";"*.xy"], "", _("Select a file to load")); + if fn <> "" then + [pth, fnm, ext] = fileparts(fn); + flname = fnm + ext; + + select ext + case ".scg" then + loaded_figure=figure("visible", "off"); + if execstr("xload(fn, loaded_figure.figure_id)","errcatch") == 0 then + loaded_figure.visible = "off"; + scf(edit_curv_figure); + xy = findPolyline(loaded_figure.children); + delete(loaded_figure); + if xy <> [] then + x=xy(:,1);y=xy(:,2); + else + messagebox(msprintf(_("%s: The file "'%s"' does not " +.. + "contains any "'Polyline"' graphic entity.\n"), "edit_curve", flname)); + return + end + else + messagebox(msprintf(_("%s: Cannot open file "'%s"' " +.. + "for reading.\n"), "edit_curv", flname), "modal"); + return + end + case ".xy" then + if execstr("xy = read(fn,-1,2)","errcatch") == 0 then + x=xy(:,1);y=xy(:,2); + else + messagebox(msprintf(_("%s: Cannot open file "'%s"' " +.. + "for reading.\n"), "edit_curv", flname), "modal"); + return + end + case ".sod" then + if execstr("load(fn)","errcatch") == 0 then + x=xy(:,1);y=xy(:,2); + else + messagebox(msprintf(_("%s: Cannot open file "'%s"' " +.. + "for reading.\n"), "edit_curv", flname), "modal"); + return + end + else + messagebox(_("Error in file format."), "modal"); + return + end + else + x=x + y=y + end +endfunction + + +function savexy(x,y) + fn=uiputfile(["*.sod";"*.xy"], "", _("Select a file to write")); + if fn <> "" then + [pth, fnm, ext] = fileparts(fn); + flname = fnm + ext; + xy = [x y]; + fil = fn; + + select ext + case "" then + fil = fil + ".xy"; + ext = ".xy"; + case ".xy" then + // empty case fil = fn + case ".sod" then + // empty case fil = fn + else + fil = pth + fnm + ".xy"; + ext = ".xy"; + end + + select ext + case ".sod" then + if execstr("save(fil,""xy"")","errcatch")<>0 then + messagebox(msprintf(_("%s: The file "'%s"' " +.. + "cannot be written.\n"), "edit_curv", flname), "modal"); + return + end + case ".xy" then + isErr = execstr("write(fil,xy)","errcatch") + if isErr == 240 then + mdelete(fil); // write cannot overwrite an existing file + isErr = execstr("write(fil,xy)","errcatch"); + end + if isErr <> 0 then + messagebox(msprintf(_("%s: The file "'%s"' " +.. + "cannot be written.\n"), "edit_curv", flname), "modal"); + return + end + end + end +endfunction diff --git a/modules/graphics/macros/errbar.bin b/modules/graphics/macros/errbar.bin Binary files differnew file mode 100755 index 000000000..a568e3dfd --- /dev/null +++ b/modules/graphics/macros/errbar.bin diff --git a/modules/graphics/macros/errbar.sci b/modules/graphics/macros/errbar.sci new file mode 100755 index 000000000..dd53e40c7 --- /dev/null +++ b/modules/graphics/macros/errbar.sci @@ -0,0 +1,46 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function []=errbar(x,y,em,ep) + + // Rajoute des barres d'erreur sur un graphique 2D + // x et y decrivent les courbes (voir plot2d) + // em et ep sont deux matrices la barre d'erreur au point + // <x(i,j),y(i,j)> va de <x(i,j),y(i,j)-em(i,j)> a <x(i,j),y(i,j)+em(i,j)> + // x,y,em et ep sont donc des matrices (p,q), q courbes contenant chacunes + // p points. + // Exemple : taper errbar() + // x=0:0.1:2*%pi; + // y=<sin(x);cos(x)>';x=<x;x>';plot2d(x,y); + // errbar(x,y,0.05*ones(x),0.03*ones(x)); + + [lhs,rhs]=argn(0) + + if rhs == 0 then // demo + x = 0:0.1:2*%pi; + y = [sin(x);cos(x)]'; + x = [x;x]'; + plot2d(x,y); + errbar(x,y,0.05*ones(x),0.03*ones(x)); + return; + else + if rhs<4 then + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"), "errbar", 4)); + end + end + + show_window(); + [n1,n2] = size(x); + y1 = matrix(y-em,1,n1*n2); + x1 = matrix(x,1,n1*n2); + y2 = matrix(y+ep,1,n1*n2); + xsegs([x1;x1],[y1;y2]); + my_axe = gca(); + my_axe.clip_state = "clipgrf"; + +endfunction diff --git a/modules/graphics/macros/eval3d.bin b/modules/graphics/macros/eval3d.bin Binary files differnew file mode 100755 index 000000000..42a862c47 --- /dev/null +++ b/modules/graphics/macros/eval3d.bin diff --git a/modules/graphics/macros/eval3d.sci b/modules/graphics/macros/eval3d.sci new file mode 100755 index 000000000..493cbcf64 --- /dev/null +++ b/modules/graphics/macros/eval3d.sci @@ -0,0 +1,28 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [z]=eval3d(fun,x,y) + //Etant donnee une discretisation des abscisses (x) et des ordonnees (y) + // eval3d(fun,x [,y]) retourne la matrice [fun(x(i),y(j))] des valeurs de la + // fonction decrite par la macro fun aux points (x(i),y(j)). + //Attention fun doit savoir gerer des arguments x et y vectoriels. + // Si fun ne sait pas gerer des arguments vectoriels, utiliser + // feval(x,y,fun) + //Si y n'est pas fourni il est suppose identique a x + //! + [lhs,rhs]=argn(0) + if rhs==3 then + nx=prod(size(x));ny=prod(size(y)) + z=matrix(fun(ones(1,ny).*.matrix(x,1,nx),matrix(y,1,ny).*.ones(1,nx)),nx,ny) + elseif rhs==2 then + nx=prod(size(x)) + z=matrix(fun(ones(1,nx).*.matrix(x,1,nx),matrix(x,1,nx).*.ones(1,nx)),nx,nx) + else + error(msprintf(gettext("%s: Wrong number of input arguments: %d or %d expected.\n"), "eval3d", 2, 3)); + end +endfunction diff --git a/modules/graphics/macros/eval3dp.bin b/modules/graphics/macros/eval3dp.bin Binary files differnew file mode 100755 index 000000000..bbcf6c381 --- /dev/null +++ b/modules/graphics/macros/eval3dp.bin diff --git a/modules/graphics/macros/eval3dp.sci b/modules/graphics/macros/eval3dp.sci new file mode 100755 index 000000000..0793b07f6 --- /dev/null +++ b/modules/graphics/macros/eval3dp.sci @@ -0,0 +1,61 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 1990 - INRIA - Serge Steer +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [x,y,z]=eval3dp(fun,p1,p2) + // eval3d - retourne une representation par facettes d'une fonction z=f(u,v) + //%Syntaxe + // [x,y,z]=eval3dp(fun,p1,p2) + //%Parametres + // fun : macro (de syntaxe : [x,y,z]=fun(p1,p2) ) definissant la + // fonction f . + // Attention lors de l'appel de fun p1 et p2 sont des vecteurs + // et la macro doit retourner x,y,z tels que : + // [x(i),y(i),z(i)]=f(p1(i),p2(i)) + // + // p1 : vecteur reel donnant la discretisation des valeurs du + // parametre u + // p2 : vecteur reel donnant la discretisation des valeurs du + // parametre v + // x : matrice 4xn dont chaque colonne contient les abscisses + // d'une facette + // y : matrice 4xn dont chaque colonne contient les ordonnees + // d'une facette + // z : matrice 4xn dont chaque colonne contient les cotes + // d'une facette + //%Exemple + // deff('[x,y,z]=scp(p1,p2)',['x=p1.*sin(p1).*cos(p2)'; + // 'y=p1.*cos(p1).*cos(p2)'; + // 'z=p1.*sin(p2)']) + // [x,y,z]=eval3dp(scp,0:0.3:2*%pi,-%pi:0.3:%pi); + // fac3d(x,y,z,35,45,'x@y@z') + //%Voir aussi + // plot3d eval3d fac3d + //! + + [lhs,rhs]=argn(0) + if rhs<3 then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "eval3dp", 3)); + end + + n1=prod(size(p1)) + n2=prod(size(p2)) + //on calcule la valeur de la fonction en tous le couples (p1(i),p2(j)) + [vx,vy,vz]=fun(ones(1,n2).*.matrix(p1,1,n1),matrix(p2,1,n2).*.ones(1,n1)) + p1=[];p2=[]; + + //on genere les facettes + ind=ones(1,n1-1).*.[0 1 n1+1 n1]+ (1:n1-1).*.[1 1 1 1]; + // ind=[1,2,n1+2,n1+1 , 2,3,n1+3,n1+2, .... ,n1-1,n1,2n1,2n1-1 + + ind2=ones(1,n2-1).*.ind+((0:n2-2)*n1).*.ones(ind); + + nx=prod(size(ind2)) + x=matrix(vx(ind2),4,nx/4); + y=matrix(vy(ind2),4,nx/4); + z=matrix(vz(ind2),4,nx/4); +endfunction diff --git a/modules/graphics/macros/fac3d.bin b/modules/graphics/macros/fac3d.bin Binary files differnew file mode 100755 index 000000000..72965d103 --- /dev/null +++ b/modules/graphics/macros/fac3d.bin diff --git a/modules/graphics/macros/fac3d.sci b/modules/graphics/macros/fac3d.sci new file mode 100755 index 000000000..45417d07b --- /dev/null +++ b/modules/graphics/macros/fac3d.sci @@ -0,0 +1,43 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function fac3d(x,y,z,T,A,leg,flags,ebox) + + // Copyright INRIA + + [lhs,rhs]=argn(0) + if rhs <= 0 then // demo + deff("[x,y,z]=sph(alp,tet)",["x=r*cos(alp).*cos(tet)+orig(1)*ones(tet)"; .. + "y=r*cos(alp).*sin(tet)+orig(2)*ones(tet)"; .. + "z=r*sin(alp)+orig(3)*ones(tet)"]); + r=1; + orig=[0 0 0]; + [x1,y1,z1]=eval3dp(sph,linspace(-%pi/2,%pi/2,40),linspace(0,%pi*2,20)); + [n1,m1]=size(x1); + r=1/2;orig=[-1 0 0]; + [x2,y2,z2]=eval3dp(sph,linspace(-%pi/2,%pi/2,40),linspace(0,%pi*2,20)); + [n2,m2]=size(x2); + x=[x1 x2]; + y=[y1 y2]; + z=[z1 z2]; + plot3d(x,y,z); + return + end + + write(%io(2),"WARNING : fac3d1 is obsolete see plot3d plot3d1 instead"); + + select rhs + case 3 then plot3d(x,y,z) + case 4 then plot3d(x,y,z,T) + case 5 then plot3d(x,y,z,T,A) + case 6 then plot3d(x,y,z,T,A,leg) + case 7 then plot3d(x,y,z,T,A,leg,flags) + case 8 then plot3d(x,y,z,T,A,leg,flags,ebox) + else error(msprintf(gettext("%s: Wrong number of input arguments: %d to %d expected.\n"), "fac3d", 3, 8)); + end +endfunction diff --git a/modules/graphics/macros/fac3d1.bin b/modules/graphics/macros/fac3d1.bin Binary files differnew file mode 100755 index 000000000..f899127c1 --- /dev/null +++ b/modules/graphics/macros/fac3d1.bin diff --git a/modules/graphics/macros/fac3d1.sci b/modules/graphics/macros/fac3d1.sci new file mode 100755 index 000000000..918583d76 --- /dev/null +++ b/modules/graphics/macros/fac3d1.sci @@ -0,0 +1,46 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function fac3d1(x,y,z,T,A,leg,flags,ebox) + + // Copyright INRIA + + [lhs,rhs]=argn(0); + + write(%io(2),"WARNING : fac3d1 is obsolete see plot3d plot3d1 instead"); + + if rhs <= 0 then // demo + deff("[x,y,z]=sph(alp,tet)",["x=r*cos(alp).*cos(tet)+orig(1)*ones(tet)"; .. + "y=r*cos(alp).*sin(tet)+orig(2)*ones(tet)"; .. + "z=r*sin(alp)+orig(3)*ones(tet)"]); + r=1; + orig=[0 0 0]; + [x1,y1,z1]=eval3dp(sph,linspace(-%pi/2,%pi/2,40),linspace(0,%pi*2,20)); + [n1,m1]=size(x1); + r=1/2; + orig=[-1 0 0]; + [x2,y2,z2]=eval3dp(sph,linspace(-%pi/2,%pi/2,40),linspace(0,%pi*2,20)); + [n2,m2]=size(x2); + x=[x1 x2]; + y=[y1 y2]; + z=[z1 z2]; + plot3d1(x,y,z); + return + end + + select rhs + case 3 then plot3d1(x,y,z) + case 4 then plot3d1(x,y,z,T) + case 5 then plot3d1(x,y,z,T,A) + case 6 then plot3d1(x,y,z,T,A,leg) + case 7 then plot3d1(x,y,z,T,A,leg,flags) + case 8 then plot3d1(x,y,z,T,A,leg,flags,ebox) + else error(msprintf(gettext("%s: Wrong number of input arguments: %d to %d expected.\n"), "fac3d1", 3, 8)); + end + +endfunction diff --git a/modules/graphics/macros/fchamp.bin b/modules/graphics/macros/fchamp.bin Binary files differnew file mode 100755 index 000000000..7ff26d01d --- /dev/null +++ b/modules/graphics/macros/fchamp.bin diff --git a/modules/graphics/macros/fchamp.sci b/modules/graphics/macros/fchamp.sci new file mode 100755 index 000000000..368b6c654 --- /dev/null +++ b/modules/graphics/macros/fchamp.sci @@ -0,0 +1,55 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function []=fchamp(macr_f,fch_t,fch_xr,fch_yr,arfact,rect,strf) + // Draw vector field in R^2, + // Vector field defined by: + // y=f(x,t,[u]), for compatibility with ode function + // f : vector field. CAn be either : + // a function y=f(t,x,[u]) + // a list such as list(f1,u1) with f1 a function + // y=f1(t,x,u) and u1=current value of u + // t : instants vector + // xr,yr: two vectors defining the gridding + // arfact : optional arg to control size of arrow heads, + // strf : string ( same as plot2d ) + //Example : enter fchamp() + //! + + [lhs,rhs]=argn(0) + if rhs <= 0 then // demo + deff("[xdot] = derpol(t,x)",["xd1 = x(2)"; .. + "xd2 = -x(1) + (1 - x(1)**2)*x(2)"; .. + "xdot = [ xd1 ; xd2 ]"]); + fchamp(derpol,0,-1:0.1:1,-1:0.1:1,1); + return + end + + if rhs <= 1,fch_t=0;end + if rhs <= 2,fch_xr=-1:0.1:1;end + if rhs <= 3,fch_yr=-1:0.1:1;end + + opts=[] + if exists("arfact","local")==1 then opts=[opts,"arfact=arfact"],end + if exists("rect","local")==1 then opts=[opts,"rect=rect"],end + if exists("strf","local")==1 then opts=[opts,"strf=strf"],end + + if type(macr_f) <> 15, + if type(macr_f)==11 then comp(macr_f),end; + deff("[yy]=mmm(x1,x2)",["xx=macr_f(fch_t,[x1;x2])";"yy=xx(1)+%i*xx(2);"]); + else + mmm1=macr_f(1) + if type(mmm1)==11 then comp(mmm1),end; + deff("[yy]=mmm(x1,x2)",["xx=mmm1(fch_t,[x1;x2],macr_f(2));"; + "yy=xx(1)+%i*xx(2);"]); + end + fch_v=feval(fch_xr,fch_yr,mmm); + + + execstr("champ(fch_xr,fch_yr,real(fch_v),imag(fch_v),"+strcat(opts,",")+")") +endfunction diff --git a/modules/graphics/macros/fcontour.bin b/modules/graphics/macros/fcontour.bin Binary files differnew file mode 100755 index 000000000..f3c1059a2 --- /dev/null +++ b/modules/graphics/macros/fcontour.bin diff --git a/modules/graphics/macros/fcontour.sci b/modules/graphics/macros/fcontour.sci new file mode 100755 index 000000000..aeb8c1dcf --- /dev/null +++ b/modules/graphics/macros/fcontour.sci @@ -0,0 +1,65 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function fcontour(xr,yr,f,nz,teta,alpha,leg,flag,ebox,zlev) + //fcontour(xr,yr,f,nz,[teta,alpha,leg,flag,ebox,zlev]) + // Trace des courbes de niveau de la surface + // d\'efinie par un external f ( ex macro [y]=f(x)) + // on calcule d'abord f sur la grille definie par xr.yr + // xr et yr sont des vecteurs implicites donnant les + // abscisses et les ordonn\'ees des points de la grille + // - x est une matrice de taille (1,n1) + // - y est une matrice de taille (1,n2) + // nz : permet de specifier les niveaux cherches + // si nz est un nombre c'est le nombre de courbes de niveau demandees + // regulierement espacees entre zmin et zmax + // si est un vecteur, il specifie les valeurs de z pour lesquelles + // on veut les courbes de niveau + // + // Les arguments suivants sont optionnels et sont identiques a ceux de + // plot3d (sauf zlev), il permettent de dessiner des courbes de niveau + // sur un graphique 3d. + // Seule la signification de flag(1) est differente : + // flag(1)=0, les courbes de niveaux sont dessinees + // sur un graphique 3d, sur la surface definie par (x,y,z) + // flag(1)=1, les courbes de biveaux sont dessinees + // sur un graphique 3d, sur le plan defini par z=zlev + // flag(1)=2, les courbes de biveaux sont dessinees + // sur un graphique 2d. + // Exemple : taper fcontour() pour voir un exemple . + // deff('[z]=Surf(x,y)','z=x**2+y**2'); + // fcontour(Surf,-1:0.1:1,-1:0.1:1,10); + // + //! + + [lhs,rhs]=argn(0) + + if rhs == 0 then // demo + deff("[z]=Surf(x,y)","z=x**2+y**2"); + fcontour(-1:0.1:1,-1:0.1:1,Surf,10); + return + end + + if rhs<3, + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"), "fcontour", 3)); + end + opts=[] + if rhs<4, + nz=10, + else + if exists("theta","local")==1 then opts=[opts,"theta=theta"],end + if exists("alpha","local")==1 then opts=[opts,"alpha=alpha"],end + if exists("leg" ,"local")==1 then opts=[opts,"leg=leg"] ,end + if exists("flag" ,"local")==1 then opts=[opts,"flag=flag"] ,end + if exists("ebox" ,"local")==1 then opts=[opts,"ebox=ebox"] ,end + if exists("zlev" ,"local")==1 then opts=[opts,"zlev=zlev"] ,end + end; + + if type(f)==11 then comp(f),end; + execstr("contour(xr,yr,feval(xr,yr,f),nz,"+strcat(opts,",")+")") +endfunction diff --git a/modules/graphics/macros/fcontour2d.bin b/modules/graphics/macros/fcontour2d.bin Binary files differnew file mode 100755 index 000000000..cca41ff2d --- /dev/null +++ b/modules/graphics/macros/fcontour2d.bin diff --git a/modules/graphics/macros/fcontour2d.sci b/modules/graphics/macros/fcontour2d.sci new file mode 100755 index 000000000..6d6cd44a7 --- /dev/null +++ b/modules/graphics/macros/fcontour2d.sci @@ -0,0 +1,39 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function fcontour2d(xr,yr,f,nz,style,strf,leg,rect,nax,void) + + // deff('[z]=Surf(x,y)','z=x**2+y**2'); + // fcontour(Surf,-1:0.1:1,-1:0.1:1,10); + + + [lhs,rhs]=argn(0); + + if rhs == 0 then // demo + deff("[z]=Surf(x,y)","z=x**3+y"); + fcontour2d(-1:0.1:1,-1:0.1:1,Surf,10,style=1:10,rect=[-1,-1,1,1]*1.5,strf="011"); + return + end + + if rhs<3, + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"), "fcontour2d", 3)); + end + + opts=[] + if exists("nz","local")==0 then nz=10,rhs=rhs+1,end + if exists("style","local")==1 then opts=[opts,"style=style"],end + if exists("strf","local")==1 then opts=[opts,"strf=strf"],end + if exists("leg","local")==1 then opts=[opts,"leg=leg"],end + if exists("rect","local")==1 then opts=[opts,"rect=rect"],end + if exists("nax","local")==1 then opts=[opts,"nax=nax"],end + if exists("frameflag","local")==1 then opts=[opts,"frameflag=frameflag"],end + if exists("axesflag","local")==1 then opts=[opts,"axesflag=axesflag"],end + + if type(f)==11 then comp(f),end; + execstr("contour2d(xr,yr,feval(xr,yr,f),nz,"+strcat(opts,",")+")") +endfunction diff --git a/modules/graphics/macros/fgrayplot.bin b/modules/graphics/macros/fgrayplot.bin Binary files differnew file mode 100755 index 000000000..232c0acd8 --- /dev/null +++ b/modules/graphics/macros/fgrayplot.bin diff --git a/modules/graphics/macros/fgrayplot.sci b/modules/graphics/macros/fgrayplot.sci new file mode 100755 index 000000000..9a608378e --- /dev/null +++ b/modules/graphics/macros/fgrayplot.sci @@ -0,0 +1,49 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function []=fgrayplot(x,y,f,strf,rect,nax,void) + //[]=fgrayplot(x,y,f) + // Trace en niveau de gris une surface + // z=f(x,y) d\'efinie par un external f ( ex macro [y]=f(x)) + // on calcule d'abord f sur la grille definie par x.y + // x et y sont des vecteurs implicites donnant les + // abscisses et les ordonn\'ees des points de la grille + // le niveau de gris choisi sur chaque maillage depend de la valeur + // moyenne de z dans le maillage. + // Exemple : taper fgrayplot() pour voir un exemple . + // deff('[z]=Surf(x,y)','z=x**2+y**2'); + // fgrayplot(-1:0.1:1,-1:0.1:1,Surf); + //! + + [lhs,rhs]=argn(0); + + if rhs <= 0 then // demo + deff("[z]=Surf(x,y)","z=cos(x).^2+sin(y).^2"); + fgrayplot(-%pi:0.1:%pi,-%pi:0.1:%pi, Surf); + f = gcf(); + f.color_map = coolcolormap(100); + return + end + + + if rhs<3, + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"), "fgrayplot", 3)); + end + + + opts=[] + if exists("style","local")==1 then opts=[opts,"style=style"],end + if exists("strf","local")==1 then opts=[opts,"strf=strf"],end + if exists("rect","local")==1 then opts=[opts,"rect=rect"],end + if exists("nax","local")==1 then opts=[opts,"nax=nax"],end + if exists("frameflag","local")==1 then opts=[opts,"frameflag=frameflag"],end + if exists("axesflag","local")==1 then opts=[opts,"axesflag=axesflag"],end + + if type(f)==11 then comp(f),end; + execstr("grayplot(x,y,feval(x,y,f),"+strcat(opts,",")+")") +endfunction diff --git a/modules/graphics/macros/fplot2d.bin b/modules/graphics/macros/fplot2d.bin Binary files differnew file mode 100755 index 000000000..e83ba48ab --- /dev/null +++ b/modules/graphics/macros/fplot2d.bin diff --git a/modules/graphics/macros/fplot2d.sci b/modules/graphics/macros/fplot2d.sci new file mode 100755 index 000000000..bb6064174 --- /dev/null +++ b/modules/graphics/macros/fplot2d.sci @@ -0,0 +1,46 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function []=fplot2d(xr,f,style,strf,leg,rect,nax,void) + // 2D plot of function f : a Scilab function or the name (as a string) + // of a dynamically linked function. + // Enter fplot2d() for an example. + // deff('<y>=f(x)','y=sin(x)+cos(x)'); + // fplot2d(f,0:0.1:%pi); + //! + + [lhs,rhs]=argn(0) + if rhs <= 0 then // demo + deff("[y]=f(x)","y=sin(x)+cos(x)"); + fplot2d(0:0.1:%pi,f); + return + end + + if type(xr)=="10" then // logflag passed first + error(msprintf(gettext("%s: Wrong size for input argument #%d: A vector expected.\n"), "fplot2d", 1)); + elseif rhs < 2 then + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"), "fplot2d", 2)); + end + //handling optional arguments + + opts=[] + + if exists("style","local")==1 then opts=[opts,"style=style"],end + if exists("strf","local")==1 then opts=[opts,"strf=strf"],end + if exists("leg","local")==1 then opts=[opts,"leg=leg"],end + if exists("rect","local")==1 then opts=[opts,"rect=rect"],end + if exists("nax","local")==1 then opts=[opts,"nax=nax"],end + if exists("logflag","local")==1 then opts=[opts,"logflag=logflag"],end + if exists("frameflag","local")==1 then opts=[opts,"frameflag=frameflag"],end + if exists("axesflag","local")==1 then opts=[opts,"axesflag=axesflag"],end + if size(opts,2)<rhs-2 then + error(msprintf(gettext("%s: Wrong value for input argument: ''%s'', ''%s'', ''%s'', ''%s'', ''%s'', ''%s'', ''%s'' or ''%s'' expected.\n"),"fplot2d","style","strf","leg","rect","nax","logflag","frameflag","axesflag")); + end + execstr("plot2d(xr,feval(xr,f),"+strcat(opts,",")+")") + +endfunction diff --git a/modules/graphics/macros/fplot3d.bin b/modules/graphics/macros/fplot3d.bin Binary files differnew file mode 100755 index 000000000..2c16dd83d --- /dev/null +++ b/modules/graphics/macros/fplot3d.bin diff --git a/modules/graphics/macros/fplot3d.sci b/modules/graphics/macros/fplot3d.sci new file mode 100755 index 000000000..63fed9e2b --- /dev/null +++ b/modules/graphics/macros/fplot3d.sci @@ -0,0 +1,42 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function fplot3d(xr,yr,f,theta,alpha,leg,flag,ebox) + // fplot3d(xr,yr,f,teta,alpha,leg,[flag,ebox]) + // Trace la surface d\'efinie par un external f ( ex macro [z]=f(x,y)) + // on calcule d'abord f sur la grille definie par xr.yr + // xr et yr sont des vecteurs implicites donnant les + // abscisses et les ordonn\'ees des points de la grille + // -teta, alpha : sont les angles en coordonn\'ees spheriques du + // point d'observation + // -flag et ebox (voir plot3d) + // Exemple : taper fplot3d() pour voir un exemple + //! + + [lhs,rhs]=argn(0) + if rhs <= 0 then // demo + deff("[z]=Surf(x,y)","z=sin(x)*cos(y)"); + t=-%pi:0.3:%pi; + fplot3d(t,t,Surf,35,45,"X@Y@Z"); + return + end + + if rhs<3 then + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"), "fplot3d", 3)); + end; + + opts=[] + if exists("theta","local")==1 then opts=[opts,"theta=theta"],end + if exists("alpha","local")==1 then opts=[opts,"alpha=alpha"],end + if exists("leg" ,"local")==1 then opts=[opts,"leg=leg"] ,end + if exists("flag" ,"local")==1 then opts=[opts,"flag=flag"] ,end + if exists("ebox" ,"local")==1 then opts=[opts,"ebox=ebox"] ,end + if type(f)==11 then comp(f),end; + + execstr("plot3d(xr,yr,feval(xr,yr,f),"+strcat(opts,",")+")") +endfunction diff --git a/modules/graphics/macros/fplot3d1.bin b/modules/graphics/macros/fplot3d1.bin Binary files differnew file mode 100755 index 000000000..932033ca2 --- /dev/null +++ b/modules/graphics/macros/fplot3d1.bin diff --git a/modules/graphics/macros/fplot3d1.sci b/modules/graphics/macros/fplot3d1.sci new file mode 100755 index 000000000..3c64a0d3c --- /dev/null +++ b/modules/graphics/macros/fplot3d1.sci @@ -0,0 +1,44 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function []=fplot3d1(xr,yr,f,theta,alpha,leg,flag,ebox) + // Trace la surface d\'efinie par un external f ( ex macro [z]=f(x,y)) + // on calcule d'abord f sur la grille definie par xr.yr + // xr et yr sont des vecteurs implicites donnant les + // abscisses et les ordonn\'ees des points de la grille + // -theta, alpha : sont les angles en coordonn\'ees spheriques du + // point d'observation + // -flag et ebox (voir plot3d1) + // Exemple : taper fplot3d1() pour voir un exemple + // deff('<z>=Surf(x,y)','z=x**2+y**2'); + // res=fplot3d1(Surf,-1:0.1:1,-1:0.1:1,35,45,"X@Y@Z"); + //! + + + [lhs,rhs]=argn(0) + if rhs <= 0 then // demo + deff("[z]=Surf(x,y)","z=sin(x)*cos(y)"); + t=-%pi:0.3:%pi; + fplot3d1(t,t,Surf,35,45,"X@Y@Z"); + return + end + + if rhs<3 then + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"), "fplot3d1", 3)); + end; + + opts=[] + if exists("theta","local")==1 then opts=[opts,"theta=theta"],end + if exists("alpha","local")==1 then opts=[opts,"alpha=alpha"],end + if exists("leg" ,"local")==1 then opts=[opts,"leg=leg"] ,end + if exists("flag" ,"local")==1 then opts=[opts,"flag=flag"] ,end + if exists("ebox" ,"local")==1 then opts=[opts,"ebox=ebox"] ,end + if type(f)==11 then comp(f),end; + + execstr("plot3d1(xr,yr,feval(xr,yr,f),"+strcat(opts,",")+")") +endfunction diff --git a/modules/graphics/macros/gca.bin b/modules/graphics/macros/gca.bin Binary files differnew file mode 100755 index 000000000..5322188a1 --- /dev/null +++ b/modules/graphics/macros/gca.bin diff --git a/modules/graphics/macros/gca.sci b/modules/graphics/macros/gca.sci new file mode 100755 index 000000000..694cb749e --- /dev/null +++ b/modules/graphics/macros/gca.sci @@ -0,0 +1,11 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [a]=gca() + a=get("current_axes"); +endfunction diff --git a/modules/graphics/macros/gce.bin b/modules/graphics/macros/gce.bin Binary files differnew file mode 100755 index 000000000..2658d5e9b --- /dev/null +++ b/modules/graphics/macros/gce.bin diff --git a/modules/graphics/macros/gce.sci b/modules/graphics/macros/gce.sci new file mode 100755 index 000000000..188fb19c6 --- /dev/null +++ b/modules/graphics/macros/gce.sci @@ -0,0 +1,11 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [a]=gce() + a=get("hdl"); +endfunction diff --git a/modules/graphics/macros/gcf.bin b/modules/graphics/macros/gcf.bin Binary files differnew file mode 100755 index 000000000..3fb25cc31 --- /dev/null +++ b/modules/graphics/macros/gcf.bin diff --git a/modules/graphics/macros/gcf.sci b/modules/graphics/macros/gcf.sci new file mode 100755 index 000000000..dc3d510d1 --- /dev/null +++ b/modules/graphics/macros/gcf.sci @@ -0,0 +1,11 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [f]=gcf() + f=get("current_figure"); +endfunction diff --git a/modules/graphics/macros/gda.bin b/modules/graphics/macros/gda.bin Binary files differnew file mode 100755 index 000000000..79403868f --- /dev/null +++ b/modules/graphics/macros/gda.bin diff --git a/modules/graphics/macros/gda.sci b/modules/graphics/macros/gda.sci new file mode 100755 index 000000000..944c6d55d --- /dev/null +++ b/modules/graphics/macros/gda.sci @@ -0,0 +1,11 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [a]=gda() + a=get("default_axes"); +endfunction diff --git a/modules/graphics/macros/gdf.bin b/modules/graphics/macros/gdf.bin Binary files differnew file mode 100755 index 000000000..d6fd68542 --- /dev/null +++ b/modules/graphics/macros/gdf.bin diff --git a/modules/graphics/macros/gdf.sci b/modules/graphics/macros/gdf.sci new file mode 100755 index 000000000..2fd0ea51b --- /dev/null +++ b/modules/graphics/macros/gdf.sci @@ -0,0 +1,11 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [a]=gdf() + a=get("default_figure"); +endfunction diff --git a/modules/graphics/macros/ged.bin b/modules/graphics/macros/ged.bin Binary files differnew file mode 100755 index 000000000..d379adae7 --- /dev/null +++ b/modules/graphics/macros/ged.bin diff --git a/modules/graphics/macros/ged.sci b/modules/graphics/macros/ged.sci new file mode 100755 index 000000000..1cc533fb0 --- /dev/null +++ b/modules/graphics/macros/ged.sci @@ -0,0 +1,2506 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function ged(k,win) + + if ~%tk then + warning(msprintf(gettext("Tcl/Tk interface not installed."))); + return + end + + // Check number of arguments + if argn(2) ==1 then + win=get(gcf(),"figure_id") + elseif argn(2)<>2 then + error(msprintf(gettext("%s: Wrong number of input arguments: %d expected.\n"), "ged", 2)); + end + + // Check argument #1 + if typeof(k) <> "constant" then + error(msprintf(gettext("%s: Wrong type for input argument #%d: A Real expected.\n"), "ged", 1)); + end + if size(k, "*") <> 1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: A Real expected.\n"), "ged", 1)); + end + + // Check argument #2 + if typeof(win) <> "constant" then + error(msprintf(gettext("%s: Wrong type for input argument #%d: A Real expected.\n"), "ged", 2)); + end + if size(win, "*") <> 1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: A Real expected.\n"), "ged", 2)); + end + + global ged_current_figure + global ged_cur_fig_handle + + ged_current_figure=gcf(); //Preserve current figure + + ged_cur_fig_handle=scf(win); + show_window(ged_cur_fig_handle); + + // for TCL input args built with string(). See bug http://bugzilla.scilab.org/2479 + initFormat = format() + format("v",18) // To be restored with initFormat before leaving + + if k>3 then + TCL_EvalStr("set isgedinterp [interp exists ged]") + if ~TCL_ExistInterp( "ged" ) then + TCL_CreateSlave( "ged" ) ; + end + + end + + select k + case 1 then //Select (make it current) + format(initFormat(2),initFormat(1)) + return + case 2 then //redraw + // nothing to do in new graphic mode + case 3 then //erase + clf() + case 4 then //copy + ged_copy_entity() + case 5 then //past + ged_paste_entity() + case 6 then //move + ged_move_entity() + case 7 then //Delete Entity + ged_delete_entity() + + case 8 then //edit current figure properties + + // hierarchical viewer + TK_send_handles_list(ged_cur_fig_handle) + TCL_SetVar("curgedindex",string(Get_handle_pos_in_list(ged_cur_fig_handle))) + + //color_map array for color sample display + f=ged_cur_fig_handle; + for i=1:size(f.color_map,1) + redname= "RED("+string(i)+")"; + TCL_EvalStr("set "+redname+" "+string(f.color_map(i,1))); + grename= "GREEN("+string(i)+")"; + TCL_EvalStr("set "+grename+" "+string(f.color_map(i,2))); + bluname= "BLUE("+string(i)+")"; + TCL_EvalStr("set "+bluname+" "+string(f.color_map(i,3))); + end + + TCL_SetVar("msdos",string(getos() == "Windows")) // to know the OS + + // get the number of the window associated with ged + TCL_SetVar("sciGedIsAlive",string(ged_cur_fig_handle.figure_id)) ; + TCL_SetVar("SCIHOME", SCIHOME) // to know the home directory to put temporary files + + ged_figure(ged_cur_fig_handle) + case 9 then //edit current axes + + // hierarchical viewer + TK_send_handles_list(ged_cur_fig_handle) + TCL_SetVar("curgedindex",string(Get_handle_pos_in_list(gca()))) + + //color_map array for color sample display + f=ged_cur_fig_handle; + for i=1:size(f.color_map,1) + redname= "RED("+string(i)+")"; + TCL_EvalStr("set "+redname+" "+string(f.color_map(i,1))); + grename= "GREEN("+string(i)+")"; + TCL_EvalStr("set "+grename+" "+string(f.color_map(i,2))); + bluname= "BLUE("+string(i)+")"; + TCL_EvalStr("set "+bluname+" "+string(f.color_map(i,3))); + end + + TCL_SetVar("msdos",string(getos() == "Windows")) // to know the OS + + // get the number of the window associated with ged + TCL_SetVar("sciGedIsAlive",string(ged_cur_fig_handle.figure_id)) ; + TCL_SetVar("SCIHOME", SCIHOME) // to know the home directory to put temporary files + + ged_axes(gca()) + case 10 then //start Entity picker + fig=ged_cur_fig_handle + fig_ud=get(fig,"user_data") + if fig.event_handler<>""& fig.event_handler<>"ged_eventhandler" then + //push current event handler in fig user data if possible + if fig_ud==[] then fig_ud=struct();end + if typeof(fig_ud)=="st" then + if ~isfield(fig_ud,"handlers") then fig_ud.handlers=[],end + fig_ud.handlers=[fig_ud.handlers; + fig.event_handler fig.event_handler_enable] + set(fig,"user_data",fig_ud) + else + warning(_("Entity picker cannot be enabled, user data figure field is already used" )) + return + end + fig.event_handler_enable = "off" //to prevent against bug 7855 + fig.event_handler="ged_eventhandler" + fig.event_handler_enable="on" + end + ged_cur_fig_handle.info_message=_("Left click on a graphic entity to open its property editor"); + case 11 then //stop Entity picker + fig=ged_cur_fig_handle + fig_ud=get(fig,"user_data") + seteventhandler("") + fig.event_handler_enable = "off" + if typeof(fig_ud)=="st"&isfield(fig_ud,"handlers")&fig_ud.handlers<>[] then + fig.event_handler=fig_ud.handlers($,1) + fig.event_handler_enable=fig_ud.handlers($,2) + fig_ud.handlers= fig_ud.handlers(1:$-1,:) + set(fig,"user_data",fig_ud) + else + fig.event_handler_enable = "off" + end + end + scf(ged_current_figure) + format(initFormat(2), initFormat(1)) +endfunction + + +function curgedindex_ = Get_handle_pos_in_list(h) + global ged_cur_fig_handle + + curgedindex_ = []; + + handles = Get_handles_list(ged_cur_fig_handle) + for i=1:size(handles,1) + if (h==handles(i)) + curgedindex_ = i; + end + end + + // Other case : + // a label has been selected (and for now they are included inside the Axes) + if (curgedindex_==[]) + if h.type == "Label" + h = h.parent; + for i=1:size(handles,1) + if (h==handles(i)) + curgedindex_ = i; + end + end + end + end + +endfunction + + +// Search the depth level for each handle +// Usefull for new hierarchical graphic tree. +function ged_levels = Get_levels(handles); + + ged_levels = 1; // for Figure, always 1 + + f = handles(1); + + for i=2:size(handles,1) + ged_levels(i) = Get_Depth(f,handles(i)); + end + + //disp("les levels sont:")xb + + //disp(ged_levels); + +endfunction + +function depth = Get_Depth(f,h) + + depth = 2; + + while h.parent <> f + h = h.parent; + depth = depth + 1; + end + +endfunction + + + +function TK_send_handles_list(h) + iFig = 0; + iUim = 0; // uimenu + iUic = 0; // uicontrol + iAxe = 0; // <=> subwindow in C code + iAgr = 0; + iPol = 0; + iPl3 = 0; + iFac = 0; + iRec = 0; + iTex = 0; + iLeg = 0; + iArc = 0; + iSeg = 0; + iCha = 0; // Champ + iFec = 0; + iGra = 0; + iMat = 0; // forgotten object F.Leray 22.10.04 + iAxi = 0; // axis : entity created when using drawaxis method for example + iLab = 0; + + f=getparfig(h); + handles = Get_handles_list(f) + + ged_levels = Get_levels(handles); + + TCL_SetVar("ged_handle_list_size",string(size(handles,1))); + + for i=1:size(handles,1) + SelObject="LEVELS("+string(i)+")"; + TCL_EvalStr("set "+SelObject+" "+string(ged_levels(i))); + end + + + for i=1:size(handles,1) + SelObject="SELOBJECT("+string(i)+")"; + hand = handles(i); + select hand.type + case "Figure" + iFig = iFig+1; + figname= "Figure("+string(iFig)+")"; + TCL_EvalStr("set "+SelObject+" "+figname); + case "uimenu" + iUim = iUim+1; + uimname= "Uimenu("+string(iUim)+")"; + TCL_EvalStr("set "+SelObject+" "+uimname); + case "uicontrol" + iUic = iUic+1; + uicname= "Uicontrol("+string(iUic)+")"; + TCL_EvalStr("set "+SelObject+" "+uicname); + case "Axes" + iAxe = iAxe+1; + axename= "Axes("+string(iAxe)+")"; + TCL_EvalStr("set "+SelObject+" "+axename); + // case "Label" // to see later: have labels at the same level than Axes (to have a better visibility) + // iLab = iLab+1; + // labname= "Label("+string(iLab)+")"; + // TCL_EvalStr('set '+SelObject+" "+labname); + case "Compound" + iAgr = iAgr+1; + agrname= "Compound("+string(iAgr)+")"; + TCL_EvalStr("set "+SelObject+" "+agrname); + case "Polyline" + iPol = iPol+1; + polname= "Polyline("+string(iPol)+")"; + TCL_EvalStr("set "+SelObject+" "+polname); + case "Plot3d" + iPl3 = iPl3+1; + pl3name= "Plot3d("+string(iPl3)+")"; + TCL_EvalStr("set "+SelObject+" "+pl3name); + case "Fac3d" + iFac = iFac+1; + Facname= "Fac3d("+string(iFac)+")"; + TCL_EvalStr("set "+SelObject+" "+Facname); + case "Rectangle" + iRec = iRec+1; + Recname= "Rectangle("+string(iRec)+")"; + TCL_EvalStr("set "+SelObject+" "+Recname); + case "Text" + iTex = iTex+1; + Texname= "Text("+string(iTex)+")"; + TCL_EvalStr("set "+SelObject+" "+Texname); + case "Legend" + iLeg = iLeg+1; + Legname= "Legend("+string(iLeg)+")"; + TCL_EvalStr("set "+SelObject+" "+Legname); + case "Arc" + iArc = iArc+1; + Arcname= "Arc("+string(iArc)+")"; + TCL_EvalStr("set "+SelObject+" "+Arcname); + case "Segs" + iSeg = iSeg+1; + Segname= "Segs("+string(iSeg)+")"; + TCL_EvalStr("set "+SelObject+" "+Segname); + case "Champ" + iCha = iCha+1; + Chaname= "Champ("+string(iCha)+")"; + TCL_EvalStr("set "+SelObject+" "+Chaname); + case "Fec" + iFec = iFec+1; + Fecname= "Fec("+string(iFec)+")"; + TCL_EvalStr("set "+SelObject+" "+Fecname); + case "Grayplot" + iGra = iGra+1; + Graname= "Grayplot("+string(iGra)+")"; + TCL_EvalStr("set "+SelObject+" "+Graname); + case "Matplot" + iMat = iMat+1; + Matname= "Matplot("+string(iMat)+")"; + TCL_EvalStr("set "+SelObject+" "+Matname); + case "Axis" + iAxi = iAxi+1; + Axiname= "Axis("+string(iAxi)+")"; + TCL_EvalStr("set "+SelObject+" "+Axiname); + else + error( hand.type + " not handled"); + end + end +endfunction + + +//function h=Get_handle_from_index(index) +function Get_handle_from_index(index) + global ged_handle; + global ged_cur_fig_handle + + hl = Get_handles_list(ged_cur_fig_handle); + + ged_handle = hl(index); + // h=ged_handle; + tkged(); + +endfunction + + +//////////////////////////////////////////// +function hfig= getparfig( h ) + + htmp = h; + hfig= [] + + while htmp.type<>"Figure" do + htmp=htmp.parent + end + + hfig = htmp; +endfunction + + +function h_out_list=Get_handles_list(h); + + global ged_handle_out; + + f=getparfig(h); + ged_handle_out=[f]; + + List_handles(f); + + //disp(ged_handle_out); + + h_out_list=ged_handle_out; + +endfunction + + +function List_handles(h) + global ged_handle_out; + + i = 1; + //if h.type=="Axes" then + // ged_handle_out = [ged_handle_out;h.x_label;h.y_label;h.z_label;h.title]; + //end + psonstmp = h.children; + if psonstmp <> [] then + psonstmp = h.children(1); + end + + while ((psonstmp <>[]) & ((i) <=size(psonstmp.parent.children,1))) + i = i+1; + ged_handle_out = [ged_handle_out; psonstmp]; + List_handles(psonstmp); + + if ((i) <=size(psonstmp.parent.children,1)) then + psonstmp = psonstmp.parent.children(i); + else + psonstmp=[]; + end + + end + +endfunction + + + +function ged_Compound(h) + global ged_handle;ged_handle=h; + TCL_SetVar("curvis",h.visible) + TCL_EvalFile(SCI+"/modules/graphics/tcl/ged/Compound.tcl") +endfunction + + +function ged_figure(h) + global ged_handle;ged_handle=h; + TCL_SetVar("background",string(h.background)) + TCL_SetVar("rotation_style",h.rotation_style) + TCL_SetVar("figure_name",h.figure_name) + TCL_SetVar("figure_id",string(h.figure_id)) + TCL_SetVar("figure_xposition",string(h.figure_position(1))) + TCL_SetVar("figure_yposition",string(h.figure_position(2))) + TCL_SetVar("figure_xsiz",string(h.figure_size(1))) + TCL_SetVar("figure_ysiz",string(h.figure_size(2))) + TCL_SetVar("figure_xaxesiz",string(h.axes_size(1))) + TCL_SetVar("figure_yaxesiz",string(h.axes_size(2))) + TCL_SetVar("bcolor",string(h.background)) + TCL_SetVar("ncolors",string(size(h.color_map,1))) + TCL_SetVar("curvis",h.visible) + TCL_SetVar("curpdm",h.pixel_drawing_mode) + TCL_SetVar("curautoresize",h.auto_resize) + TCL_SetVar("currotation_style",h.rotation_style) + TCL_EvalFile(SCI+"/modules/graphics/tcl/ged/Figure.tcl") +endfunction + + +function ged_axes(h) + global ged_handle;ged_handle=h; + + LoadTicks2TCL(h); + + TCL_SetVar("Xaxes_reverseToggle",h.axes_reverse(1)) + TCL_SetVar("Yaxes_reverseToggle",h.axes_reverse(2)) + TCL_SetVar("Zaxes_reverseToggle",h.axes_reverse(3)) + + // forgotten axes bounds info. + TCL_SetVar("axes_boundsL",string(h.axes_bounds(1,1))) + TCL_SetVar("axes_boundsU",string(h.axes_bounds(1,2))) + TCL_SetVar("axes_boundsW",string(h.axes_bounds(1,3))) + TCL_SetVar("axes_boundsH",string(h.axes_bounds(1,4))) + + // forgotten visibility info. + TCL_SetVar("xlabel_visibility",string(h.x_label.visible)) + TCL_SetVar("ylabel_visibility",string(h.y_label.visible)) + TCL_SetVar("zlabel_visibility",string(h.z_label.visible)) + TCL_SetVar("titlelabel_visibility",string(h.title.visible)) + + TCL_SetVar("Lmargins",string(h.margins(1))); + TCL_SetVar("Rmargins",string(h.margins(2))); + TCL_SetVar("Tmargins",string(h.margins(3))); + TCL_SetVar("Bmargins",string(h.margins(4))); + ged_linestylearray=["solid" "dash" "dash dot" "longdash dot" "bigdash dot" "bigdash longdash" "dot" "double dot"]; + TCL_SetVar("curlinestyle",ged_linestylearray(max(h.line_style,1))) + if (h.clip_box==[]) + TCL_SetVar("old_Xclipbox","") + TCL_SetVar("old_Yclipbox","") + TCL_SetVar("old_Wclipbox","") + TCL_SetVar("old_Hclipbox","") + TCL_SetVar("Xclipbox","") + TCL_SetVar("Yclipbox","") + TCL_SetVar("Wclipbox","") + TCL_SetVar("Hclipbox","") + else + TCL_SetVar("old_Xclipbox",string(h.clip_box(1))) + TCL_SetVar("old_Yclipbox",string(h.clip_box(2))) + TCL_SetVar("old_Wclipbox",string(h.clip_box(3))) + TCL_SetVar("old_Hclipbox",string(h.clip_box(4))) + TCL_SetVar("Xclipbox",string(h.clip_box(1))) + TCL_SetVar("Yclipbox",string(h.clip_box(2))) + TCL_SetVar("Wclipbox",string(h.clip_box(3))) + TCL_SetVar("Hclipbox",string(h.clip_box(4))) + end + TCL_SetVar("curclipstate",h.clip_state); + TCL_SetVar("curautoclear",h.auto_clear); + TCL_SetVar("curautoscale",h.auto_scale); + //TCL_SetVar("curfillmode",h.fill_mode); + TCL_SetVar("curalpharotation",string(h.rotation_angles(1))) + TCL_SetVar("curthetarotation",string(h.rotation_angles(2))) + ged_fontarray = ["Monospaced" "Symbol" "Serif",.. + "Serif Italic" "Serif Bold" "Serif Bold Italic" ,.. + "SansSerif" "SansSerif Italic" "SansSerif Bold",.. + "SansSerif Bold Italic"]; + TCL_SetVar("Xlabelpos",h.x_location) + TCL_SetVar("Ylabelpos",h.y_location) + TCL_SetVar("Xlabelfontstyle",ged_fontarray(h.x_label.font_style+1)) + TCL_SetVar("Ylabelfontstyle",ged_fontarray(h.y_label.font_style+1)) + TCL_SetVar("Zlabelfontstyle",ged_fontarray(h.z_label.font_style+1)) + TCL_SetVar("TITLEfontstyle",ged_fontarray(h.title.font_style+1)) + TCL_SetVar("fontstyle",ged_fontarray(h.font_style+1)) + + // label texts + if size(h.x_label.text,"*") == 1 then + txt = """" + h.x_label.text + """" ; + else + // an array of strings + txt = "["+strcat(string(size(h.x_label.text)),"x")+" string array]" ; + end + TCL_SetVar("xlabel", txt ); + + if size(h.y_label.text,"*") == 1 then + txt = """" + h.y_label.text + """" ; + else + // an array of strings + txt = "["+strcat(string(size(h.y_label.text)),"x")+" string array]" ; + end + TCL_SetVar("ylabel", txt ); + + if size(h.z_label.text,"*") == 1 then + txt = """" + h.z_label.text + """" ; + else + // an array of strings + txt = "["+strcat(string(size(h.z_label.text)),"x")+" string array]" ; + end + TCL_SetVar("zlabel", txt ); + + if size(h.title.text,"*") == 1 then + txt = """" + h.title.text + """" ; + else + // an array of strings + txt = "["+strcat(string(size(h.title.text)),"x")+" string array]" ; + end + TCL_SetVar("tlabel", txt ); + + TCL_SetVar("xlabel_fontforeground",string(h.x_label.font_foreground)) + TCL_SetVar("ylabel_fontforeground",string(h.y_label.font_foreground)) + TCL_SetVar("zlabel_fontforeground",string(h.z_label.font_foreground)) + TCL_SetVar("titlelabel_fontforg",string(h.title.font_foreground)) + TCL_SetVar("xlabel_foreground",string(h.x_label.foreground)) + TCL_SetVar("ylabel_foreground",string(h.y_label.foreground)) + TCL_SetVar("zlabel_foreground",string(h.z_label.foreground)) + TCL_SetVar("titlelabel_foreground",string(h.title.foreground)) + TCL_SetVar("xlabel_background",string(h.x_label.background)) + TCL_SetVar("ylabel_background",string(h.y_label.background)) + TCL_SetVar("zlabel_background",string(h.z_label.background)) + TCL_SetVar("titlelabel_background",string(h.title.background)) + TCL_SetVar("x_position",sci2exp(h.x_label.position,0)) + TCL_SetVar("y_position",sci2exp(h.y_label.position,0)) + TCL_SetVar("z_position",sci2exp(h.z_label.position,0)) + TCL_SetVar("title_position",sci2exp(h.title.position,0)) + TCL_SetVar("xauto_position",h.x_label.auto_position) + TCL_SetVar("yauto_position",h.y_label.auto_position) + TCL_SetVar("zauto_position",h.z_label.auto_position) + TCL_SetVar("titleauto_position",h.title.auto_position) + TCL_SetVar("xauto_rotation",h.x_label.auto_rotation) + TCL_SetVar("yauto_rotation",h.y_label.auto_rotation) + TCL_SetVar("zauto_rotation",h.z_label.auto_rotation) + TCL_SetVar("titleauto_rotation",h.title.auto_rotation) + TCL_SetVar("Xfillmode",h.x_label.fill_mode) + TCL_SetVar("Yfillmode",h.y_label.fill_mode) + TCL_SetVar("Zfillmode",h.z_label.fill_mode) + TCL_SetVar("Titlefillmode",h.title.fill_mode) + TCL_SetVar("xlabel_fontsize",string(h.x_label.font_size)) + TCL_SetVar("ylabel_fontsize",string(h.y_label.font_size)) + TCL_SetVar("zlabel_fontsize",string(h.z_label.font_size)) + TCL_SetVar("titlelabel_fontsize",string(h.title.font_size)) + TCL_SetVar("ncolors",string(size(f.color_map,1))) + TCL_SetVar("fcolor",string(h.foreground)) + TCL_SetVar("bcolor",string(h.background)) + TCL_SetVar("curthick",string(h.thickness)) + TCL_SetVar("curvis",h.visible) + TCL_SetVar("curfontsize",string(h.font_size)) + TCL_SetVar("curfontcolor",string(h.font_color)) + TCL_SetVar("limToggle",h.tight_limits(1)) + TCL_SetVar("isoToggle",h.isoview) + TCL_SetVar("cubToggle",h.cube_scaling) + TCL_SetVar("viewToggle",h.view) + TCL_SetVar("curBoxState",h.box) + TCL_SetVar("xToggle",part(h.log_flags,1)) + TCL_SetVar("yToggle",part(h.log_flags,2)) + TCL_SetVar("zToggle",part(h.log_flags,3)) + TCL_SetVar("xGrid",string(h.grid(1))) + TCL_SetVar("yGrid",string(h.grid(2))) + + TCL_SetVar("hiddenAxisColor",h.hidden_axis_color) + TCL_SetVar("curfontangle_x",string(h.x_label.font_angle)) + TCL_SetVar("curfontangle_y",string(h.y_label.font_angle)) + TCL_SetVar("curfontangle_z",string(h.z_label.font_angle)) + TCL_SetVar("curfontangle_title",string(h.title.font_angle)) + + + select h.view + case "2d" + drawlater(); + h.view="3d" + TCL_SetVar("old_curalpharotation",string(h.rotation_angles(1))) + TCL_SetVar("old_curthetarotation",string(h.rotation_angles(2))) + TCL_SetVar("zGrid",string(h.grid(3))) + TCL_SetVar("zGrid_initial",string(h.grid(3))) //to avoid useless redraw (see Axes.tcl) + TCL_SetVar("dbxmin",string(h.data_bounds(1,1))) + TCL_SetVar("dbymin",string(h.data_bounds(1,2))) + TCL_SetVar("dbzmin",string(h.data_bounds(1,3))) + TCL_SetVar("dbxmax",string(h.data_bounds(2,1))) + TCL_SetVar("dbymax",string(h.data_bounds(2,2))) + TCL_SetVar("dbzmax",string(h.data_bounds(2,3))) + h.view="2d" + drawnow(); + case "3d" + TCL_SetVar("zGrid",string(h.grid(3))) + TCL_SetVar("zGrid_initial",string(h.grid(3))) //to avoid useless redraw (see Axes.tcl) + TCL_SetVar("dbxmin",string(h.data_bounds(1,1))) + TCL_SetVar("dbymin",string(h.data_bounds(1,2))) + TCL_SetVar("dbzmin",string(h.data_bounds(1,3))) + TCL_SetVar("dbxmax",string(h.data_bounds(2,1))) + TCL_SetVar("dbymax",string(h.data_bounds(2,2))) + TCL_SetVar("dbzmax",string(h.data_bounds(2,3))) + end + + TCL_EvalFile(SCI+"/modules/graphics/tcl/ged/Axes.tcl") +endfunction + +function ged_rectangle(h) + global ged_handle; ged_handle=h + if (h.clip_box==[]) + TCL_SetVar("old_Xclipbox","") + TCL_SetVar("old_Yclipbox","") + TCL_SetVar("old_Wclipbox","") + TCL_SetVar("old_Hclipbox","") + TCL_SetVar("Xclipbox","") + TCL_SetVar("Yclipbox","") + TCL_SetVar("Wclipbox","") + TCL_SetVar("Hclipbox","") + else + TCL_SetVar("old_Xclipbox",string(h.clip_box(1))) + TCL_SetVar("old_Yclipbox",string(h.clip_box(2))) + TCL_SetVar("old_Wclipbox",string(h.clip_box(3))) + TCL_SetVar("old_Hclipbox",string(h.clip_box(4))) + TCL_SetVar("Xclipbox",string(h.clip_box(1))) + TCL_SetVar("Yclipbox",string(h.clip_box(2))) + TCL_SetVar("Wclipbox",string(h.clip_box(3))) + TCL_SetVar("Hclipbox",string(h.clip_box(4))) + end + TCL_SetVar("curclipstate",h.clip_state); + + f=h;while stripblanks(f.type)<>"Figure" then f=f.parent,end + ax=h;while stripblanks(ax.type)<>"Axes" then ax=ax.parent,end + TCL_SetVar("ncolors",string(size(f.color_map,1))) + TCL_SetVar("curcolor",string(h.foreground)) + TCL_SetVar("curback",string(h.background)) + TCL_SetVar("curthick",string(h.thickness)) + TCL_SetVar("curvis",h.visible) + ged_linestylearray=["solid" "dash" "dash dot" "longdash dot" "bigdash dot" "bigdash longdash" "dot" "double dot"]; + TCL_SetVar("curlinestyle",ged_linestylearray(max(h.line_style,1))) + ged_markstylearray=["dot" "plus" "cross" "star" "filled diamond" .. + "diamond" "triangle up" "triangle down" "diamond plus" "circle" .. + "asterisk" "square" "triangle right" "triangle left" "pentagram"]; + TCL_SetVar("curmarkstyle",ged_markstylearray(abs(h.mark_style)+1)) + TCL_SetVar("curmarkmode",h.mark_mode) + TCL_SetVar("curmarksize",string(h.mark_size)) + TCL_SetVar("curmarksizeunit",h.mark_size_unit); + TCL_SetVar("curmarkforeground",string(h.mark_foreground)) + TCL_SetVar("curmarkbackground",string(h.mark_background)) + + + TCL_SetVar("curlinemode",h.line_mode) + TCL_SetVar("curfillmode",h.fill_mode) + // Rectangle data + select ax.view + case "2d" + drawlater(); + ax.view="3d" + TCL_SetVar("Xval",string(h.data(1))) + TCL_SetVar("Yval",string(h.data(2))) + TCL_SetVar("Zval",string(h.data(3))) + TCL_SetVar("Wval",string(h.data(4))) + TCL_SetVar("Hval",string(h.data(5))) + ax.view="2d" + drawnow(); + case "3d" + TCL_SetVar("Xval",string(h.data(1))) + TCL_SetVar("Yval",string(h.data(2))) + TCL_SetVar("Zval",string(h.data(3))) + TCL_SetVar("Wval",string(h.data(4))) + TCL_SetVar("Hval",string(h.data(5))) + end + TCL_EvalFile(SCI+"/modules/graphics/tcl/ged/Rectangle.tcl") +endfunction + +function ged_polyline(h) + global ged_handle; ged_handle=h + + if (h.clip_box==[]) + TCL_SetVar("old_Xclipbox","") + TCL_SetVar("old_Yclipbox","") + TCL_SetVar("old_Wclipbox","") + TCL_SetVar("old_Hclipbox","") + TCL_SetVar("Xclipbox","") + TCL_SetVar("Yclipbox","") + TCL_SetVar("Wclipbox","") + TCL_SetVar("Hclipbox","") + else + TCL_SetVar("old_Xclipbox",string(h.clip_box(1))) + TCL_SetVar("old_Yclipbox",string(h.clip_box(2))) + TCL_SetVar("old_Wclipbox",string(h.clip_box(3))) + TCL_SetVar("old_Hclipbox",string(h.clip_box(4))) + TCL_SetVar("Xclipbox",string(h.clip_box(1))) + TCL_SetVar("Yclipbox",string(h.clip_box(2))) + TCL_SetVar("Wclipbox",string(h.clip_box(3))) + TCL_SetVar("Hclipbox",string(h.clip_box(4))) + end + TCL_SetVar("curclipstate",h.clip_state); + + f=h;while stripblanks(f.type)<>"Figure" then f=f.parent,end + TCL_SetVar("ncolors",string(size(f.color_map,1))) + TCL_SetVar("curcolor",string(h.foreground)) + TCL_SetVar("curback",string(h.background)) + TCL_SetVar("curthick",string(h.thickness)) + TCL_SetVar("curarrowsizefactor",string(h.arrow_size_factor)) + TCL_SetVar("curvis",h.visible) + + ged_polylinestylearray=["interpolated" "staircase" "barplot" "arrowed" "filled" "bar"]; + TCL_SetVar("curpolylinestyle",ged_polylinestylearray(max(h.polyline_style,1))) + ged_linestylearray=["solid" "dash" "dash dot" "longdash dot" "bigdash dot" "bigdash longdash" "dot" "double dot"]; + TCL_SetVar("curlinestyle",ged_linestylearray(max(h.line_style,1))) + ged_markstylearray=["dot" "plus" "cross" "star" "filled diamond" .. + "diamond" "triangle up" "triangle down" "diamond plus" "circle" .. + "asterisk" "square" "triangle right" "triangle left" "pentagram"]; + + TCL_SetVar("curmarkstyle",ged_markstylearray(abs(h.mark_style)+1)) + TCL_SetVar("curmarkmode",h.mark_mode) + TCL_SetVar("curmarksize",string(h.mark_size)) + TCL_SetVar("curmarksizeunit",h.mark_size_unit); + TCL_SetVar("curmarkforeground",string(h.mark_foreground)) + TCL_SetVar("curmarkbackground",string(h.mark_background)) + + TCL_SetVar("curlinemode",h.line_mode) + TCL_SetVar("curclosedmode",h.closed) + TCL_SetVar("curfillmode",h.fill_mode) + TCL_SetVar("curinterpcolormode",h.interp_color_mode) + TCL_SetVar("curinterpcolorvector",sci2exp(h.interp_color_vector,0)) + + d="["+strcat(string(size(h.data)),"x")+" double array]" + TCL_SetVar("curdata",d); + + select get(getparaxe(h),"view") + case "2d" + TCL_SetVar("nbcol",string(2)); + case "3d" + TCL_SetVar("nbcol",string(3)); + end + TCL_EvalFile(SCI+"/modules/graphics/tcl/ged/Polyline.tcl") +endfunction + + +function ged_plot3d(h) + global ged_handle; ged_handle=h + + // if (h.clip_box==[]) + // TCL_SetVar("old_Xclipbox","") + // TCL_SetVar("old_Yclipbox","") + // TCL_SetVar("old_Wclipbox","") + // TCL_SetVar("old_Hclipbox","") + // TCL_SetVar("Xclipbox","") + // TCL_SetVar("Yclipbox","") + // TCL_SetVar("Wclipbox","") + // TCL_SetVar("Hclipbox","") + // else + // TCL_SetVar("old_Xclipbox",string(h.clip_box(1))) + // TCL_SetVar("old_Yclipbox",string(h.clip_box(2))) + // TCL_SetVar("old_Wclipbox",string(h.clip_box(3))) + // TCL_SetVar("old_Hclipbox",string(h.clip_box(4))) + // TCL_SetVar("Xclipbox",string(h.clip_box(1))) + // TCL_SetVar("Yclipbox",string(h.clip_box(2))) + // TCL_SetVar("Wclipbox",string(h.clip_box(3))) + // TCL_SetVar("Hclipbox",string(h.clip_box(4))) + // end + // TCL_SetVar("curclipstate",h.clip_state); + + TCL_SetVar("curvis",h.visible) + TCL_SetVar("curcolormode",string(h.color_mode)) + TCL_SetVar("colorflagToggle",string(h.color_flag)) + TCL_SetVar("curforeground",string(h.foreground)) + TCL_SetVar("curhiddencolor",string(h.hiddencolor)) + TCL_SetVar("curthick",string(h.thickness)) + + ged_markstylearray=["dot" "plus" "cross" "star" "filled diamond" .. + "diamond" "triangle up" "triangle down" "diamond plus" "circle" .. + "asterisk" "square" "triangle right" "triangle left" "pentagram"]; + + TCL_SetVar("curmarkstyle",ged_markstylearray(abs(h.mark_style)+1)) + TCL_SetVar("curmarkmode",h.mark_mode) + TCL_SetVar("curmarksize",string(h.mark_size)) + TCL_SetVar("curmarksizeunit",h.mark_size_unit); + TCL_SetVar("curmarkforeground",string(h.mark_foreground)) + TCL_SetVar("curmarkbackground",string(h.mark_background)) + TCL_SetVar("curlinemode",h.surface_mode) + + + d="["+strcat(string(size(h.data.x)),"x")+" double array]" + TCL_SetVar("curdata_x",d); + d="["+strcat(string(size(h.data.y)),"x")+" double array]" + TCL_SetVar("curdata_y",d); + d="["+strcat(string(size(h.data.z)),"x")+" double array]" + TCL_SetVar("curdata_z",d); + + TCL_EvalStr("set flagCOLOR 0") + if(h.data(1)==["3d" "x" "y" "z" "color"]) + TCL_EvalStr("set flagCOLOR 1") + d="["+strcat(string(size(h.data.color)),"x")+" integer array]" + TCL_SetVar("curdata_color",d); + end + TCL_EvalFile(SCI+"/modules/graphics/tcl/ged/Plot3d.tcl") +endfunction + + +function ged_fac3d(h) + global ged_handle; ged_handle=h + + // if (h.clip_box==[]) + // TCL_SetVar("old_Xclipbox","") + // TCL_SetVar("old_Yclipbox","") + // TCL_SetVar("old_Wclipbox","") + // TCL_SetVar("old_Hclipbox","") + // TCL_SetVar("Xclipbox","") + // TCL_SetVar("Yclipbox","") + // TCL_SetVar("Wclipbox","") + // TCL_SetVar("Hclipbox","") + // else + // TCL_SetVar("old_Xclipbox",string(h.clip_box(1))) + // TCL_SetVar("old_Yclipbox",string(h.clip_box(2))) + // TCL_SetVar("old_Wclipbox",string(h.clip_box(3))) + // TCL_SetVar("old_Hclipbox",string(h.clip_box(4))) + // TCL_SetVar("Xclipbox",string(h.clip_box(1))) + // TCL_SetVar("Yclipbox",string(h.clip_box(2))) + // TCL_SetVar("Wclipbox",string(h.clip_box(3))) + // TCL_SetVar("Hclipbox",string(h.clip_box(4))) + // end + // TCL_SetVar("curclipstate",h.clip_state); + + TCL_SetVar("curvis",h.visible) + TCL_SetVar("curcolormode",string(h.color_mode)) + TCL_SetVar("colorflagToggle",string(h.color_flag)) + TCL_SetVar("curforeground",string(h.foreground)) + TCL_SetVar("curhiddencolor",string(h.hiddencolor)) + TCL_SetVar("curthick",string(h.thickness)) + + ged_markstylearray=["dot" "plus" "cross" "star" "filled diamond" .. + "diamond" "triangle up" "triangle down" "diamond plus" "circle" .. + "asterisk" "square" "triangle right" "triangle left" "pentagram"]; + + TCL_SetVar("curmarkstyle",ged_markstylearray(abs(h.mark_style)+1)) + TCL_SetVar("curmarkmode",h.mark_mode) + TCL_SetVar("curmarksize",string(h.mark_size)) + TCL_SetVar("curmarksizeunit",h.mark_size_unit); + TCL_SetVar("curmarkforeground",string(h.mark_foreground)) + TCL_SetVar("curmarkbackground",string(h.mark_background)) + TCL_SetVar("curlinemode",h.surface_mode) + + + d="["+strcat(string(size(h.data.x)),"x")+" double array]" + TCL_SetVar("curdata_x",d); + d="["+strcat(string(size(h.data.y)),"x")+" double array]" + TCL_SetVar("curdata_y",d); + d="["+strcat(string(size(h.data.z)),"x")+" double array]" + TCL_SetVar("curdata_z",d); + + TCL_EvalStr("set flagCOLOR 0") + if(h.data(1)==["3d" "x" "y" "z" "color"]) + TCL_EvalStr("set flagCOLOR 1") + d="["+strcat(string(size(h.data.color)),"x")+" integer array]" + TCL_SetVar("curdata_color",d); + end + + + TCL_EvalFile(SCI+"/modules/graphics/tcl/ged/Fac3d.tcl") +endfunction + + +function ged_text(h) + global ged_handle; ged_handle=h + f=h;while stripblanks(f.type)<>"Figure" then f=f.parent,end + TCL_SetVar("curvis",h.visible) + TCL_SetVar("ncolors",string(size(f.color_map,1))) + TCL_SetVar("curfontforeground",string(h.font_foreground)) + ged_fontarray = ["Monospaced" "Symbol" "Serif",.. + "Serif Italic" "Serif Bold" "Serif Bold Italic" ,.. + "SansSerif" "SansSerif Italic" "SansSerif Bold",.. + "SansSerif Bold Italic"]; + TCL_SetVar("curfontstyle",ged_fontarray(h.font_style+1)) + TCL_SetVar("curfontsize",string(h.font_size)) + TCL_SetVar("curfontangle",string(h.font_angle)) + TCL_SetVar("curtextboxmode",h.text_box_mode) + TCL_SetVar("curtext",h.text) + TCL_SetVar("curforeground",string(h.foreground)) + TCL_SetVar("curbackground",string(h.background)) + TCL_SetVar("curboxmode",h.box) + TCL_SetVar("curlinemode",h.line_mode); + TCL_SetVar("curfillmode",h.fill_mode); + //TCL_SetVar("curPosition",h.data) ; + + if (h.clip_box==[]) + TCL_SetVar("old_Xclipbox","") + TCL_SetVar("old_Yclipbox","") + TCL_SetVar("old_Wclipbox","") + TCL_SetVar("old_Hclipbox","") + TCL_SetVar("Xclipbox","") + TCL_SetVar("Yclipbox","") + TCL_SetVar("Wclipbox","") + TCL_SetVar("Hclipbox","") + else + TCL_SetVar("old_Xclipbox",string(h.clip_box(1))) + TCL_SetVar("old_Yclipbox",string(h.clip_box(2))) + TCL_SetVar("old_Wclipbox",string(h.clip_box(3))) + TCL_SetVar("old_Hclipbox",string(h.clip_box(4))) + TCL_SetVar("Xclipbox",string(h.clip_box(1))) + TCL_SetVar("Yclipbox",string(h.clip_box(2))) + TCL_SetVar("Wclipbox",string(h.clip_box(3))) + TCL_SetVar("Hclipbox",string(h.clip_box(4))) + end + TCL_SetVar("curclipstate",h.clip_state); + + if size(h.text,"*") == 1 then + txt =""""+ h.text +"""" ; // one double quote at each side + else + txt = "["+strcat(string(size(h.text)),"x")+" string array]" + end + TCL_SetVar("curtext", txt ); + TCL_SetVar( "textBoxWidth", string( h.text_box(1) ) ) ; + TCL_SetVar("textBoxHeight", string( h.text_box(2) ) ) ; + TCL_SetVar("curAlignment",string(h.alignment) ) ; + + TCL_EvalFile(SCI+"/modules/graphics/tcl/ged/Text.tcl") +endfunction + + +function ged_legend(h) + global ged_handle; ged_handle=h + TCL_SetVar("curvis",h.visible) + TCL_SetVar("ncolors",string(size(f.color_map,1))) + TCL_SetVar("curforeground",string(h.foreground)) + ged_fontarray = ["Monospaced" "Symbol" "Serif",.. + "Serif Italic" "Serif Bold" "Serif Bold Italic" ,.. + "SansSerif" "SansSerif Italic" "SansSerif Bold",.. + "SansSerif Bold Italic"]; + TCL_SetVar("curfontstyle",ged_fontarray(h.font_style+1)) + TCL_SetVar("curfontsize",string(h.font_size)) + TCL_SetVar("curtext",h.text) + + TCL_EvalFile(SCI+"/modules/graphics/tcl/ged/Legend.tcl") +endfunction + + +function ged_arc(h) + global ged_handle; ged_handle=h + + if (h.clip_box==[]) + TCL_SetVar("old_Xclipbox","") + TCL_SetVar("old_Yclipbox","") + TCL_SetVar("old_Wclipbox","") + TCL_SetVar("old_Hclipbox","") + TCL_SetVar("Xclipbox","") + TCL_SetVar("Yclipbox","") + TCL_SetVar("Wclipbox","") + TCL_SetVar("Hclipbox","") + else + TCL_SetVar("old_Xclipbox",string(h.clip_box(1))) + TCL_SetVar("old_Yclipbox",string(h.clip_box(2))) + TCL_SetVar("old_Wclipbox",string(h.clip_box(3))) + TCL_SetVar("old_Hclipbox",string(h.clip_box(4))) + TCL_SetVar("Xclipbox",string(h.clip_box(1))) + TCL_SetVar("Yclipbox",string(h.clip_box(2))) + TCL_SetVar("Wclipbox",string(h.clip_box(3))) + TCL_SetVar("Hclipbox",string(h.clip_box(4))) + end + TCL_SetVar("curclipstate",h.clip_state); + ged_linestylearray=["solid" "dash" "dash dot" "longdash dot" "bigdash dot" "bigdash longdash" "dot" "double dot"]; + TCL_SetVar("curlinestyle",ged_linestylearray(max(h.line_style,1))) + TCL_SetVar("nbcol",string(size(h.data,2))) + for i=1:size(h.data,2) + val= "arcVAL("+string(i)+")"; + TCL_EvalStr("set "+val+" "+string(h.data(2))); + end + f=h;while stripblanks(f.type)<>"Figure" then f=f.parent,end + TCL_SetVar("ncolors",string(size(f.color_map,1))) + TCL_SetVar("curcolor",string(h.foreground)) + TCL_SetVar("curback",string(h.background)) + TCL_SetVar("curvis",h.visible) + TCL_SetVar("curlinemode",h.line_mode) + TCL_SetVar("curfillmode",h.fill_mode) + TCL_SetVar("curthick",string(h.thickness)) + + ax=getparaxe(h); + // Arc data + select ax.view + case "2d" + drawlater(); + ax.view="3d" //strange behavior in 3D... seems to be bugged!! + TCL_SetVar("Xval",string(h.data(1))) + TCL_SetVar("Yval",string(h.data(2))) + TCL_SetVar("Zval",string(h.data(3))) + TCL_SetVar("Wval",string(h.data(4))) + TCL_SetVar("Hval",string(h.data(5))) + TCL_SetVar("A1val",string(h.data(6))) + TCL_SetVar("A2val",string(h.data(7))) + ax.view="2d" + drawnow(); + case "3d" + TCL_SetVar("Xval",string(h.data(1))) + TCL_SetVar("Yval",string(h.data(2))) + TCL_SetVar("Zval",string(h.data(3))) + TCL_SetVar("Wval",string(h.data(4))) + TCL_SetVar("Hval",string(h.data(5))) + TCL_SetVar("A1val",string(h.data(6))) + TCL_SetVar("A2val",string(h.data(7))) + end + TCL_EvalFile(SCI+"/modules/graphics/tcl/ged/Arc.tcl") +endfunction + + +function ged_segs(h) + global ged_handle; ged_handle=h + TCL_SetVar("curvis",h.visible) + TCL_SetVar("ncolors",string(size(f.color_map,1))) + TCL_SetVar("curarrowsize",string(h.arrow_size)) + TCL_SetVar("curthick",string(h.thickness)) + ged_linestylearray=["solid" "dash" "dash dot" "longdash dot" "bigdash dot" "bigdash longdash" "dot" "double dot"]; + TCL_SetVar("curlinestyle",ged_linestylearray(max(h.line_style,1))) + + ged_markstylearray=["dot" "plus" "cross" "star" "filled diamond" .. + "diamond" "triangle up" "triangle down" "diamond plus" "circle" .. + "asterisk" "square" "triangle right" "triangle left" "pentagram"]; + + TCL_SetVar("curmarkstyle",ged_markstylearray(abs(h.mark_style)+1)) + TCL_SetVar("curmarkmode",h.mark_mode) + TCL_SetVar("curmarksize",string(h.mark_size)) + TCL_SetVar("curmarksizeunit",h.mark_size_unit); + TCL_SetVar("curmarkforeground",string(h.mark_foreground)) + TCL_SetVar("curmarkbackground",string(h.mark_background)) + TCL_SetVar("curlinemode",h.line_mode) + + TCL_SetVar("nbrow",string(size(h.data,1))) + + d="["+strcat(string(size(h.data)),"x")+" double array]" + TCL_SetVar("curdata",d); + + TCL_SetVar("nbcolsegscolor",string(size(h.segs_color,2))) + for i=1:size(h.segs_color,2) + val= "segscolorVAL("+string(i)+")"; + TCL_EvalStr("set "+val+" "+string(h.segs_color(i))); + end + + if (h.clip_box==[]) + TCL_SetVar("old_Xclipbox","") + TCL_SetVar("old_Yclipbox","") + TCL_SetVar("old_Wclipbox","") + TCL_SetVar("old_Hclipbox","") + TCL_SetVar("Xclipbox","") + TCL_SetVar("Yclipbox","") + TCL_SetVar("Wclipbox","") + TCL_SetVar("Hclipbox","") + else + TCL_SetVar("old_Xclipbox",string(h.clip_box(1))) + TCL_SetVar("old_Yclipbox",string(h.clip_box(2))) + TCL_SetVar("old_Wclipbox",string(h.clip_box(3))) + TCL_SetVar("old_Hclipbox",string(h.clip_box(4))) + TCL_SetVar("Xclipbox",string(h.clip_box(1))) + TCL_SetVar("Yclipbox",string(h.clip_box(2))) + TCL_SetVar("Wclipbox",string(h.clip_box(3))) + TCL_SetVar("Hclipbox",string(h.clip_box(4))) + end + TCL_SetVar("curclipstate",h.clip_state); + + TCL_EvalFile(SCI+"/modules/graphics/tcl/ged/Segs.tcl") +endfunction + + +function ged_champ(h) + global ged_handle; ged_handle=h + TCL_SetVar("curvis",h.visible) + TCL_SetVar("curcolored",h.colored) + TCL_SetVar("ncolors",string(size(f.color_map,1))) + TCL_SetVar("curarrowsize",string(h.arrow_size)) + TCL_SetVar("curthick",string(h.thickness)) + ged_linestylearray=["solid" "dash" "dash dot" "longdash dot" "bigdash dot" "bigdash longdash" "dot" "double dot"]; + TCL_SetVar("curlinestyle",ged_linestylearray(max(h.line_style,1))) + + d="["+strcat(string(size(h.data.x)),"x")+" double array]" + TCL_SetVar("curdata_x",d); + d="["+strcat(string(size(h.data.y)),"x")+" double array]" + TCL_SetVar("curdata_y",d); + d="["+strcat(string(size(h.data.fx)),"x")+" double array]" + TCL_SetVar("curdata_fx",d); + d="["+strcat(string(size(h.data.fy)),"x")+" double array]" + TCL_SetVar("curdata_fy",d); + + if (h.clip_box==[]) + TCL_SetVar("old_Xclipbox","") + TCL_SetVar("old_Yclipbox","") + TCL_SetVar("old_Wclipbox","") + TCL_SetVar("old_Hclipbox","") + TCL_SetVar("Xclipbox","") + TCL_SetVar("Yclipbox","") + TCL_SetVar("Wclipbox","") + TCL_SetVar("Hclipbox","") + else + TCL_SetVar("old_Xclipbox",string(h.clip_box(1))) + TCL_SetVar("old_Yclipbox",string(h.clip_box(2))) + TCL_SetVar("old_Wclipbox",string(h.clip_box(3))) + TCL_SetVar("old_Hclipbox",string(h.clip_box(4))) + TCL_SetVar("Xclipbox",string(h.clip_box(1))) + TCL_SetVar("Yclipbox",string(h.clip_box(2))) + TCL_SetVar("Wclipbox",string(h.clip_box(3))) + TCL_SetVar("Hclipbox",string(h.clip_box(4))) + end + TCL_SetVar("curclipstate",h.clip_state); + + TCL_EvalFile(SCI+"/modules/graphics/tcl/ged/Champ.tcl") +endfunction + +function ged_fec(h) + global ged_handle; ged_handle=h + TCL_SetVar("curvis",h.visible) + TCL_SetVar("zbmin",string(h.z_bounds(1))) + TCL_SetVar("zbmax",string(h.z_bounds(2))) + // TCL_SetVar("nbrow",string(size(h.data,1))) + // TCL_SetVar("nbcol",string(size(h.data,2))) + // TCL_SetVar("nbrowTri",string(size(h.triangles,1))) + // TCL_SetVar("nbcolTri",string(size(h.triangles,2))) + + d="["+strcat(string(size(h.data)),"x")+" double array]" + TCL_SetVar("curdata_data",d); + d="["+strcat(string(size(h.triangles)),"x")+" double array]" + TCL_SetVar("curdata_triangles",d); + + // if (h.clip_box==[]) + // TCL_SetVar("old_Xclipbox","") + // TCL_SetVar("old_Yclipbox","") + // TCL_SetVar("old_Wclipbox","") + // TCL_SetVar("old_Hclipbox","") + // TCL_SetVar("Xclipbox","") + // TCL_SetVar("Yclipbox","") + // TCL_SetVar("Wclipbox","") + // TCL_SetVar("Hclipbox","") + // else + // TCL_SetVar("old_Xclipbox",string(h.clip_box(1))) + // TCL_SetVar("old_Yclipbox",string(h.clip_box(2))) + // TCL_SetVar("old_Wclipbox",string(h.clip_box(3))) + // TCL_SetVar("old_Hclipbox",string(h.clip_box(4))) + // TCL_SetVar("Xclipbox",string(h.clip_box(1))) + // TCL_SetVar("Yclipbox",string(h.clip_box(2))) + // TCL_SetVar("Wclipbox",string(h.clip_box(3))) + // TCL_SetVar("Hclipbox",string(h.clip_box(4))) + // end + // TCL_SetVar("curclipstate",h.clip_state); + + TCL_EvalFile(SCI+"/modules/graphics/tcl/ged/Fec.tcl") +endfunction + + +function ged_grayplot(h) + global ged_handle; ged_handle=h + TCL_SetVar("curvis",h.visible) + TCL_SetVar("curdatamapping",h.data_mapping) + + + d="["+strcat(string(size(h.data.x)),"x")+" double array]" + TCL_SetVar("curdata_x",d); + d="["+strcat(string(size(h.data.y)),"x")+" double array]" + TCL_SetVar("curdata_y",d); + d="["+strcat(string(size(h.data.z)),"x")+" double array]" + TCL_SetVar("curdata_z",d); + + TCL_EvalFile(SCI+"/modules/graphics/tcl/ged/Grayplot.tcl") + +endfunction + +function ged_matplot(h) + global ged_handle; ged_handle=h + TCL_SetVar("curvis",h.visible) + + d="["+strcat(string(size(h.data)),"x")+" double array]" + TCL_SetVar("curdata",d); + + TCL_EvalFile(SCI+"/modules/graphics/tcl/ged/Matplot.tcl") + +endfunction + + +function ged_axis(h) + global ged_handle; ged_handle=h + TCL_SetVar("curvis",h.visible) + TCL_SetVar("curseg",h.tics_segment) + TCL_SetVar("curcolor",string(h.tics_color)) + TCL_SetVar("curticsstyle",h.tics_style) + TCL_SetVar("curfontcolor",string(h.labels_font_color)) + TCL_SetVar("curfontsize",string(h.labels_font_size)) + TCL_SetVar("nbcolX",string(size(h.xtics_coord,2))) + TCL_SetVar("nbcolY",string(size(h.ytics_coord,2))) + TCL_SetVar("xticscoord",sci2exp(h.xtics_coord,0)) + TCL_SetVar("yticscoord",sci2exp(h.ytics_coord,0)) + TCL_SetVar("cursubtics",string(h.sub_tics)) + TCL_SetVar("curticslabel",sci2exp(h.tics_labels,0)) + TCL_SetVar("curticsdir",string(h.tics_direction)) + + if (h.clip_box==[]) + TCL_SetVar("old_Xclipbox","") + TCL_SetVar("old_Yclipbox","") + TCL_SetVar("old_Wclipbox","") + TCL_SetVar("old_Hclipbox","") + TCL_SetVar("Xclipbox","") + TCL_SetVar("Yclipbox","") + TCL_SetVar("Wclipbox","") + TCL_SetVar("Hclipbox","") + else + TCL_SetVar("old_Xclipbox",string(h.clip_box(1))) + TCL_SetVar("old_Yclipbox",string(h.clip_box(2))) + TCL_SetVar("old_Wclipbox",string(h.clip_box(3))) + TCL_SetVar("old_Hclipbox",string(h.clip_box(4))) + TCL_SetVar("Xclipbox",string(h.clip_box(1))) + TCL_SetVar("Yclipbox",string(h.clip_box(2))) + TCL_SetVar("Wclipbox",string(h.clip_box(3))) + TCL_SetVar("Hclipbox",string(h.clip_box(4))) + end + TCL_SetVar("curclipstate",h.clip_state); + + TCL_EvalFile(SCI+"/modules/graphics/tcl/ged/Axis.tcl") +endfunction + + +function [h,Axes]=ged_getobject(pt) + h=[];Axes=[]; + f=get("current_figure"); + aold=get("current_axes") + axes_array=f.children + //retains only the entities of type Axes (remove uimenus) + axes_array(axes_array.type<>"Axes")=[]; + // assume that the lastly created objects + // are at the beginning of the arrays of children + // We can then select the last object + // first in the loop. + for k=1:size(axes_array,"*") + Axes=axes_array(k) + set("current_axes",Axes) + h=ged_loop(Axes,pt) + if h<>[] then break,end + end + set("current_axes",aold) +endfunction + +function h=ged_loop(a,pt) + + h=[] + minDist = 0.01 ; + minPixDist = 3 ; + + for ka=1:size(a,"*") + ck=a(ka) ; + select ck.type + + case "Polyline" + xy=ck.data; + d=Dist2polyline((xy(:,1)-Xmin)/Dx,(xy(:,2)-Ymin)/Dy,pts) + if d < minDist then h=ck,return,end + + case "Rectangle" + xy=ck.data; + x0=xy(1);y0=xy(2);W=xy(3);H=xy(4); + d=Dist2polyline((x0+[0,W,W,0]-Xmin)/Dx,(y0+[0,0,-H,-H]-Ymin)/Dy,pts) + if d < minDist then h=ck,return,end + + case "Arc" + xy=ck.data; + [xp,yp]=xchange(pt(1),pt(2),"i2f") + //[dist, toto] = dist2Arc( [xp,yp] ./ [Dx,Dy], xy(1:2)./[Dx,Dy], xy(3)/Dx, xy(4)/Dy, xy(5) / 64., xy(6) / 64. ) ; + dist = pixDist2Arc( [xp,yp], xy(1:2), xy(3), xy(4), xy(5) / 64., xy(6) / 64. ) ; + if dist <= minPixDist then + h=ck; + return; + end + + case "Segs" + xy=ck.data; + xv=(matrix(xy(:,1),2,-1)-Xmin)/Dx + yv=(matrix(xy(:,2),2,-1)-Ymin)/Dy + for ks=1:size(xv,2) + d=Dist2polyline(xv(:,ks),yv(:,ks),pts) + if d < minDist then h=ck,return,end + end + case "Compound" + h=ged_loop(ck.children,pt) + if h<>[] then return,end + + case "Axes" + xy=ck.data_bounds; + [xp,yp]=xchange(pt(1),pt(2),"i2f") + Xmin=xy(1,1);Ymin=xy(1,2),Dx=xy(2,1)-xy(1,1);Dy=xy(2,2)-xy(1,2); + pts=[(xp-Xmin)/Dx (yp-Ymin)/Dy] + d=Dist2polyline([0,1,1,0],[0,0,1,1],pts) + if d < minDist then h=ck,return,end + h=ged_loop([a.children(:);ck.x_label;ck.y_label;ck.z_label;ck.title],pt) + if h<>[] then return,end + + case "Text" + if is_in_text(ck,[xp;yp]) then + h=ck, + return, + end + + case "Label" + if is_in_text(ck,[xp;yp]) then + h=ck + return, + end + + end + end +endfunction + +function r=is_in_text(h,xy) + if h.Type == "Text" & h.text_box_mode=="filled" then + r=(xy(1)>h.data(1)&xy(1)<h.data(1)+h.text_box(1))&(xy(2)>h.data(2)&xy(2)<h.data(2)+h.text_box(2)) + else + r = stringbox(h); + r=[r r(:,1)]; + r=and([xy(2) -xy(1)]*diff(r,1,2)+(r(1,1:$-1).*r(2,2:$)-r(1,2:$).*r(2,1:$-1))<0) + end +endfunction + +// compute the square of distance between a point and the ellipse +// in 2D included in an axis aligned rectangle whose upper left +// corner is upperLeft and its wifth and heigth is defined. +function [dist] = dist2Ellipse( point, upperLeft, width, heigth ) + width2 = width / 2. ; + heigth2 = heigth / 2. ; + centerC = [ upperLeft(1) + width2, upperLeft(2) - heigth2 ] ; // center of the ellipse + + // clicked point in the circle frame + pointC = [ (point(1) - centerC(1)) / width2, (point(2) - centerC(2)) / heigth2 ] ; + + // get the vector between the point and the closest on the circle + diffclose = ( 1 - 1 / norm( pointC ) ) * pointC ; + //closest = pointC / sqrt( pointC(1) * pointC(1) + pointC(2) * pointC(2) ) ; + + // get the difference between the two + //ffclose = pointC - closest ; + + // bring it back to the current frame value + diffclose(1) = diffclose(1) * width2 ; + diffclose(2) = diffclose(2) * heigth2 ; + + // get the distance with the closest point + dist = norm( diffclose ) ; + +endfunction + +// compute the distance between a point and the arc +// in 2D included in an axis aligned rectangle whose upper left +// corner is upperLeft and its wifth and heigth is defined. +function [dist,diffClose] = dist2Arc( point, upperLeft, width, heigth, sector1, sector2 ) + + + if ( width == 0 | heigth == 0 ) then + dist = %inf ; + diffClose = [%inf,%inf]; + return ; + end + + // convert the sector into radiant angle + angle1 = sector1 * %pi / 180. ; + angle2 = (sector1 + sector2) * %pi / 180. ; + + width2 = width / 2. ; + heigth2 = heigth / 2. ; + centerC = [ upperLeft(1) + width2, upperLeft(2) - heigth2 ] ; // center of the ellipse + + // clicked point in the circle frame + pointC = [ (point(1) - centerC(1)) / width2, (point(2) - centerC(2)) / heigth2 ] ; + + // get the projection of the clicked point on the circle + closest = pointC / norm( pointC ) ; + + // now a quite tricky part. The aim is to find + // if the closest point is in the drawing sector + // ie if it is between bound1 and bound2 on the circle + // maybe a eayer solution exists. + + // get the boundaries of the displayed angle + // the closest point is not on the arc it is one of the two + // boundaries + bound1 = [cos(angle1),sin(angle1)] ; + bound2 = [cos(angle2),sin(angle2)] ; + + // now get the vector of bissecting line between the two bounds + // with the orientation toward the arc + b2b1 = bound1 - bound2 ; + bissect(1) = -b2b1(2) ; + bissect(2) = b2b1(1) ; + + // get the position of the point along this axis + side = closest(1) * bissect(1) + closest(2) * bissect(2) ; + + // get the position of one of the bound (same value for both) + boundPos = bound1(1) * bissect(1) + bound1(2) * bissect(2) ; + + if side > boundPos then + // the closest point is on the arc + diffClose = ( pointC - closest ) .* [width2,heigth2] ; + // bring it back to the current frame value + //diffclose = diffclose .* [width2,heigth2] ; + + // get the distance with the closest point + dist = norm( diffClose ) ; + + else + // the closest point is one of the bounds + // return back to the real coordinates + bound1 = centerC + bound1 .* [width2,heigth2]; + bound2 = centerC + bound2 .* [width2,heigth2]; + + // get the minimum distance + dist = norm( bound1 - point ) ; + dist2 = norm( bound2 - point ) ; + if dist > dist2 then + diffClose = bound1 - point ; + else + dist = dist2 ; + diffClose = bound2 - point ; + end + //dist = min( norm( bound1 - point ), norm( bound2 - point ) ) ; + end + +endfunction + +// same as before but return the value in pixels +function dist = pixDist2Arc( point, upperLeft, width, heigth, sector1, sector2 ) + + [dist, difference] = dist2Arc( point, upperLeft, width, heigth, sector1, sector2 ) ; + // convert to pixels + // get the length of the difference vector + // we construct it by getting two points + [origin(1),origin(2)] = xchange(0,0,"f2i"); + [extremity(1),extremity(2)] = xchange(difference(1),difference(2),"f2i"); + dist = norm( extremity - origin ) ; + +endfunction + +function [d,pt,ind]=Dist2polyline(xp,yp,pt) + // computes minimum distance from a point to a polyline + //d minimum distance to polyline + //pt coordinate of the polyline closest point + //ind + // if negative polyline closest point is a polyline corner:pt=[xp(-ind) yp(-ind)] + // if positive pt lies on segment [ind ind+1] + + // Copyright INRIA + x=pt(1) + y=pt(2) + xp=xp(:);yp=yp(:) + cr=4*sign((xp(1:$-1)-x).*(xp(1:$-1)-xp(2:$))+.. + (yp(1:$-1)-y).*(yp(1:$-1)-yp(2:$)))+.. + sign((xp(2:$)-x).*(xp(2:$)-xp(1:$-1))+.. + (yp(2:$)-y).*(yp(2:$)-yp(1:$-1))) + + ki=find(cr==5) // index of segments for which projection fall inside + np=size(xp,"*") + if ki<>[] then + //projection on segments + x=[xp(ki) xp(ki+1)] + y=[yp(ki) yp(ki+1)] + dx=x(:,2)-x(:,1) + dy=y(:,2)-y(:,1) + d_d=dx.^2+dy.^2 + d_x=( dy.*(-x(:,2).*y(:,1)+x(:,1).*y(:,2))+dx.*(dx*pt(1)+dy*pt(2)))./d_d + d_y=(-dx.*(-x(:,2).*y(:,1)+x(:,1).*y(:,2))+dy.*(dx*pt(1)+dy*pt(2)))./d_d + xp=[xp;d_x] + yp=[yp;d_y] + end + [d,k]=min(((xp-pt(1))).^2+((yp-pt(2))).^2) //distance with all points + d=sqrt(d) + pt(1)=xp(k) + pt(2)=yp(k) + if k>np then ind=ki(k-np),else ind=-k,end +endfunction + +function ged_eventhandler(win,x,y,ibut) + //Copyright INRIA + //Author : Serge Steer 2002 + if ibut==-1 then return,end //ignore move + if and(win<>winsid())| ibut==-1000 then + //window has been deleted by the user + return + end + cur=gcf(); //preserve current figure + fig=scf(win) //make the window associated to the event active + + //disable the event handler not to execute new event before finishing this one + fig.event_handler_enable = "off"; + + + global ged_handle;ged_handle=[] + ged_handle=ged_getobject([x,y]) + + if ged_handle~=[] then + if or(ibut==[0 3 10]) then //left button --> edit properties + tkged() + elseif or(ibut==[2 5 12]) then //right button -->move + [x,y]=xchange(x,y,"i2f") + pos=[x,y] + while %t then + rep=xgetmouse([%t %t]) + if rep(3)>0 then break,end + move(ged_handle,rep(1:2)-pos) + pos=rep(1:2) + end + end + end + fig.event_handler_enable = "on"; + scf(cur) //reset current window +endfunction + + +function [ini,typs]=build_args(labels) + n=size(labels,"*") + ini=[] + typs=list() + for k=1:n + typ=type(h(labels(k))) + execstr(["if typ==10 then" + " w=h."+labels(k) + "else" + " w=sci2exp(h."+labels(k)+",0)" + "end"]) + ini=[ini;w] + if typ==10 then + typs($+1)="str";typs($+1)=-1 + else + typs($+1)="vec";typs($+1)=1 + end + end +endfunction + +function GetSetValue(h) + n=size(labels,"*") + lhs="[ok,"+strcat("x"+string(1:n),",")+"]" + execstr(lhs+"=getvalue(t,labels,typs,ini)") + if ok then + for k=1:n + execstr("if x"+string(k)+"<>h."+labels(k)+" then h."+.. + labels(k)+"=x"+string(k)+",end") + end + end +endfunction + + + +function tkged() + global ged_handle + global ged_cur_fig_handle + + h=ged_handle + + // hierarchical viewer + TK_send_handles_list(ged_cur_fig_handle) + TCL_SetVar("curgedindex",string(Get_handle_pos_in_list(h))) + + //color_map array for color sample display + f=getparfig(h); + for i=1:size(f.color_map,1) + redname= "RED("+string(i)+")"; + TCL_EvalStr("set "+redname+" "+string(f.color_map(i,1))); + grename= "GREEN("+string(i)+")"; + TCL_EvalStr("set "+grename+" "+string(f.color_map(i,2))); + bluname= "BLUE("+string(i)+")"; + TCL_EvalStr("set "+bluname+" "+string(f.color_map(i,3))); + end + + TCL_SetVar("msdos",string(getos() == "Windows")) // to know the OS + + // get the number of the window associated with ged + TCL_SetVar("sciGedIsAlive",string(ged_cur_fig_handle.figure_id)) ; + TCL_SetVar("SCIHOME", SCIHOME) // to know the home directory to put temporary files + + select h.type + case "Polyline" + ged_polyline(h) + case "Rectangle" + ged_rectangle(h) + case "Axes" + ged_axes(h) + case "Label" // for now the labels are inside the axes (F.Leray 06.12.05) + ged_axes(h.parent) + if (h == h.parent.x_label) + TCL_EvalStr("Notebook:raise $uf.n X"); + elseif (h == h.parent.y_label) + TCL_EvalStr("Notebook:raise $uf.n Y"); + elseif (h == h.parent.z_label) + TCL_EvalStr("Notebook:raise $uf.n Z"); + elseif (h == h.parent.title) + TCL_EvalStr("Notebook:raise $uf.n Title"); + end + case "Figure" + ged_figure(h) + case "Compound" + ged_Compound(h) + + case "Plot3d" + ged_plot3d(h) + case "Fac3d" + ged_fac3d(h) + case "Text" + ged_text(h) + case "Legend" + ged_legend(h) + case "Arc" + ged_arc(h) + case "Segs" + ged_segs(h) + case "Champ" + ged_champ(h) + case "Fec" + ged_fec(h) + case "Grayplot" + ged_grayplot(h) + case "Matplot" + ged_matplot(h) + case "Axis" + ged_axis(h) + end +endfunction + +function setStyle(sty) + global ged_handle; h=ged_handle + h.polyline_style=find(sty==["interpolated","staircase", ... + "barplot","arrowed","filled" "bar"]) +endfunction +function setLineStyle(sty) + global ged_handle; h=ged_handle + h.line_style=find(sty==[ "solid" "dash" "dash dot" "longdash dot" .. + "bigdash dot" "bigdash longdash" "dot" "double dot"]) + +endfunction +function setMarkStyle(sty) + global ged_handle; h=ged_handle + h.mark_style=find(sty==["dot" "plus" "cross" "star" "filled diamond" .. + "diamond" "triangle up" "triangle down" "diamond plus" "circle" .. + "asterisk" "square" "triangle right" "triangle left" "pentagram"])-1 +endfunction +function setFontStyle(ftn) + global ged_handle; h=ged_handle + h.font_style=find(ftn==["Monospaced" "Symbol" "Serif",.. + "Serif Italic" "Serif Bold" "Serif Bold Italic" ,.. + "SansSerif" "SansSerif Italic" "SansSerif Bold",.. + "SansSerif Bold Italic"])-1; +endfunction + +function setLabelsFontStyle(label,ftn) + global ged_handle; h=ged_handle + select label + case "t" + TCL_EvalStr("Notebook:raise $uf.n Z"); + h.title.font_style=find(ftn==["Monospaced" "Symbol" "Serif",.. + "Serif Italic" "Serif Bold" "Serif Bold Italic" ,.. + "SansSerif" "SansSerif Italic" "SansSerif Bold",.. + "SansSerif Bold Italic"])-1; + case "x" + h.x_label.font_style=find(ftn==["Monospaced" "Symbol" "Serif",.. + "Serif Italic" "Serif Bold" "Serif Bold Italic" ,.. + "SansSerif" "SansSerif Italic" "SansSerif Bold",.. + "SansSerif Bold Italic"])-1; + case "y" + h.y_label.font_style=find(ftn==["Monospaced" "Symbol" "Serif",.. + "Serif Italic" "Serif Bold" "Serif Bold Italic" ,.. + "SansSerif" "SansSerif Italic" "SansSerif Bold",.. + "SansSerif Bold Italic"])-1; + case "z" + h.z_label.font_style=find(ftn==["Monospaced" "Symbol" "Serif",.. + "Serif Italic" "Serif Bold" "Serif Bold Italic" ,.. + "SansSerif" "SansSerif Italic" "SansSerif Bold",.. + "SansSerif Bold Italic"])-1; + end; +endfunction + + +// Axes data (data_bounds) +function setXdb(xmin, xmax) + global ged_handle; h=ged_handle + tmp=h.data_bounds; + tmp(1,1)=xmin; + tmp(2,1)=xmax; + h.data_bounds=tmp; + // tst=execstr('h.data_bounds=tmp','errcatch','n'); + // if tst<>0 then + // disp 'Warning: X data_bounds must contain double' + // end +endfunction + + +function setYdb(ymin, ymax) + global ged_handle; h=ged_handle + tmp=h.data_bounds; + tmp(1,2)=ymin; + tmp(2,2)=ymax; + h.data_bounds=tmp; + // tst=execstr('h.data_bounds=tmp','errcatch','n'); + // if tst<>0 then + // disp 'Warning: Y data_bounds must contain double' + // end +endfunction + +function setZdb(zmin, zmax) + global ged_handle; h=ged_handle + select h.view + case "2d" + drawlater(); + h.view="3d"; + tmp=h.data_bounds; + tmp(1,3)=zmin; + tmp(2,3)=zmax; + h.data_bounds=tmp; + h.view="2d"; + drawnow(); + // tst=execstr('h.data_bounds=tmp','errcatch','n'); + // h.view='2d'; + // if tst<>0 then + // disp 'Warning: Z data_bounds must contain double' + // end + case "3d" + tmp=h.data_bounds; + tmp(1,3)=zmin; + tmp(2,3)=zmax; + h.data_bounds=tmp; + // tst=execstr('h.data_bounds=tmp','errcatch','n'); + // if tst<>0 then + // disp 'Warning: Z data_bounds must contain double' + // end + end +endfunction + + +function LogtoggleX( tog) + global ged_handle; h=ged_handle + + h.log_flags=tog+part(h.log_flags,2); + + + //tst=execstr("global h;h.log_flags=tog+part(h.log_flags,2)",'errcatch','n'); + + //if tst<>0 then + // disp 'Warning: X bounds must be strictly positive' + //end +endfunction + +function LogtoggleY( tog) + global ged_handle; h=ged_handle + + h.log_flags=part(h.log_flags,1)+tog; + + + //tst=execstr("global h;h.log_flags=part(h.log_flags,1)+tog",'errcatch','n'); + + //if tst<>0 then + // disp 'Warning: Y bounds must be strictly positive' + //end + +endfunction + + +function LogtoggleZ( tog) + global ged_handle; h=ged_handle + + h.log_flags=part(h.log_flags,1)+part(h.log_flags,2)+tog; + + + //tst=execstr("global h;h.log_flags=part(h.log_flags,1)+tog",'errcatch','n'); + + //if tst<>0 then + // disp 'Warning: Z bounds must be strictly positive' + //end + +endfunction + + + +function [haxe] = getparaxe( h ) + + htmp = h; + haxe = []; + while htmp.type<>"Axes" do + htmp = htmp.parent + end + + haxe = htmp; +endfunction + + + + +// Rectangle data +function setXval(val) + global ged_handle; h=ged_handle + tmp=h.data; + tmp(1)=val; + tst=execstr("h.data=tmp","errcatch","n"); + if tst<>0 then + disp "Warning: Y data must contain double" + end +endfunction + +function setYval(val) + global ged_handle; h=ged_handle + tmp=h.data; + tmp(2)=val; + tst=execstr("h.data=tmp","errcatch","n"); + if tst<>0 then + disp "Warning: Y data must contain double" + end +endfunction + +function setZval(val) + global ged_handle; h=ged_handle + ax=getparaxe(h); + select ax.view + case "2d" + drawlater(); + ax.view="3d"; + tmp=h.data; + tmp(3)=val; + tst=execstr("h.data=tmp","errcatch","n"); + ax.view="2d"; + drawnow(); + if tst<>0 then + disp "Warning: Z data must contain double" + end + case "3d" + tmp=h.data; + tmp(3)=val; + tst=execstr("h.data=tmp","errcatch","n"); + if tst<>0 then + disp "Warning: Z data must contain double" + end + end +endfunction + + +function setWval(val) + global ged_handle; h=ged_handle + ax=getparaxe(h); + select ax.view + case "2d" + drawlater(); + ax.view="3d"; + tmp=h.data; + tmp(4)=val; + tst=execstr("h.data=tmp","errcatch","n"); + ax.view="2d"; + drawnow(); + if tst<>0 then + disp "Warning: Width data must contain double" + end + case "3d" + tmp=h.data; + tmp(4)=val; + tst=execstr("h.data=tmp","errcatch","n"); + if tst<>0 then + disp "Warning: Width data must contain double" + end + end +endfunction + + +function setHval(val) + global ged_handle; h=ged_handle + ax=getparaxe(h); + select ax.view + case "2d" + drawlater(); + ax.view="3d"; + tmp=h.data; + tmp(5)=val; + tst=execstr("h.data=tmp","errcatch","n"); + ax.view="2d"; + drawnow(); + if tst<>0 then + disp "Warning: Height data must contain double" + end + case "3d" + tmp=h.data; + tmp(5)=val; + tst=execstr("h.data=tmp","errcatch","n"); + if tst<>0 then + disp "Warning: Height data must contain double" + end + end +endfunction + + +// complement for Arc entity +function setA1val(val) + global ged_handle; h=ged_handle + ax=getparaxe(h); + select ax.view + case "2d" + drawlater(); + ax.view="3d"; + tmp=h.data; + tmp(6)=val; + tst=execstr("h.data=tmp","errcatch","n"); + ax.view="2d"; + drawnow(); + if tst<>0 then + disp "Warning: Width data must contain double" + end + case "3d" + tmp=h.data; + tmp(6)=val; + tst=execstr("h.data=tmp","errcatch","n"); + if tst<>0 then + disp "Warning: a1 data must contain double" + end + end +endfunction + +function setA2val(val) + global ged_handle; h=ged_handle + ax=getparaxe(h); + select ax.view + case "2d" + drawlater(); + ax.view="3d"; + tmp=h.data; + tmp(7)=val; + tst=execstr("h.data=tmp","errcatch","n"); + ax.view="2d"; + drawnow(); + if tst<>0 then + disp "Warning: Width data must contain double" + end + case "3d" + tmp=h.data; + tmp(7)=val; + tst=execstr("h.data=tmp","errcatch","n"); + if tst<>0 then + disp "Warning: a2 data must contain double" + end + end +endfunction + + +//Fec +function setZb(min, max) + global ged_handle; h=ged_handle + tmp=h.z_bounds; + tmp(1,1)=min; + tmp(1,2)=max; + tst=execstr("h.z_bounds=tmp","errcatch","n"); + if tst<>0 then + disp "Warning: X data_bounds must contain double" + end +endfunction + + + +//////////////////////////////// +// Scilab Command Interface //// +//////////////////////////////// +//Plot3d +function set3dtlistXYZ (X,Y,Z) + global ged_handle; h=ged_handle + ged_tmp_tlist = tlist(["3d","x","y","z"],X,Y,Z) + h.data=ged_tmp_tlist; + clear ged_tmp_tlist; +endfunction + +function set3dtlistXYZC (X,Y,Z,COLOR) + global ged_handle; h=ged_handle + ged_tmp_tlist = tlist(["3d","x","y","z","color"],X,Y,Z,COLOR) + h.data=ged_tmp_tlist; + clear ged_tmp_tlist; +endfunction + +function setGrayplottlist(X,Y,Z) + global ged_handle; h=ged_handle + ged_tmp_tlist = tlist(["grayplotdata","x","y","z"],X,Y,Z) + h.data=ged_tmp_tlist; + clear ged_tmp_tlist; +endfunction + +//Champ +function setchamptlistXYFXFY (X,Y,FX,FY) + global ged_handle; h=ged_handle + ged_tmp_tlist = tlist(["champdata","x","y","fx","fy"],X,Y,FX,FY) + h.data=ged_tmp_tlist; + clear ged_tmp_tlist; +endfunction + + +/////////////////////////////// +// Edit Data using sciGUI ///// +/////////////////////////////// + +function EditData(TheData,datastring) + // TheData must be a real scalar or matrix + global ged_handle; h=ged_handle + + // I declare ged_tmp ged_tmp_string WINDOW as global + global ged_tmp; + global ged_tmp_string; + global WINDOW; + + ged_tmp_string = datastring; + + ged_tmp=TheData; + + WINDOW = GEDeditvar("ged_tmp") + +endfunction + + +function CloseEditorSaveData() + // Called when closing data editor + + global ged_handle; // To leave here because used when doing execstr(ged_tmp_string... + global ged_tmp; + global ged_tmp_string; + global WINDOW; + + Nan = %nan // to avoid error message because of special Nan display + + ged_tmp=GEDeditvar_get(WINDOW); + + execstr(ged_tmp_string+"= ged_tmp"); + + clearglobal ged_tmp ged_tmp_string WINDOW + clear ged_tmp ged_tmp_string WINDOW + +endfunction + + +function outvar=GEDeditvar_get(winId) + // Simple variable editor - import data + // This file is part of sciGUI toolbox + // Copyright (C) 2004 Jaime Urzua Grez + // mailto:jaime_urzua@yahoo.com + // rev. 0.1 + // + // 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. + + //disp("Please wait..."); + outvar=[]; + base="sciGUITable(win,"+string(winId)+",data"; + varType=evstr(TCL_GetVar(base+",type)")); + varni=evstr(TCL_GetVar(base+",ni)")); + varnj=evstr(TCL_GetVar(base+",nj)")); + for j=1:varnj, + ww=[]; + for i=1:varni, + q=TCL_GetVar(base+","+string(i)+","+string(j)+")"); + if (varType~=10) then + if (varType==4) then + if ((q=="T")|(q=="t")) then + ww=[ww;%t]; + else + ww=[ww;%f]; + end + else + ww=[ww;evstr(q)]; + end + else + ww=[ww;q]; + end + end + outvar=[outvar ww]; + end +endfunction + +function [WINID] = GEDeditvar(varargin) + // Simple Variable Editor + // This file is part of sciGUI toolbox + // Copyright (C) 2004 Jaime Urzua Grez + // mailto:jaime_urzua@yahoo.com + // rev. 0.2 2004/06/24 + // + // 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. + + sciGUI_init() + + [%_nams]=who("get"); + %_loc_type=type(varargin(1)) + if (%_loc_type~=10) then error(42), end + %_in_list=find(%_nams==varargin(1)); + if (%_in_list==[]) then error(42), end + execstr("%_loc_var="+varargin(1)); + %_loc_type=type(%_loc_var); + %_allo=find([1;4;10]==%_loc_type); + if (%_allo==[]) then error(42), end + + //disp("Please wait..."); + %_loc_nam=varargin(1); + %_loc_ni=size(%_loc_var,1); + %_loc_nj=size(%_loc_var,2); + %_loc_type=string(%_loc_type); + + TCL_EvalStr("set EdVarLoc [GEDsciGUIEditVar -1]"); + + %_winId=TCL_GetVar("EdVarLoc"); + + TCL_SetVar("sciGUITable(win,"+%_winId+",data,name)",%_loc_nam); + TCL_SetVar("sciGUITable(win,"+%_winId+",data,type)",string(%_loc_type)); + TCL_SetVar("sciGUITable(win,"+%_winId+",data,ni)",string(%_loc_ni)); + TCL_SetVar("sciGUITable(win,"+%_winId+",data,nj)",string(%_loc_nj)); + + // + // This is a slow manner to move the data ... + // Anyone have a faster method than TCL_SetVar + // I would like set some tcl variable like varname(pos_i,pos_j) + // + Nb_data=(%_loc_nj)*(%_loc_ni) + // disp("Nb_data=") + // disp(Nb_data); + // winWB=waitbar('Loading data...'); + // tmp = 0; + // waitbar(tmp,winWB); + + + for %_j=1:%_loc_nj, + for %_i=1:%_loc_ni, + %_value=string(%_loc_var(%_i,%_j)); + %_varname="sciGUITable(win,"+%_winId+",data,"+string(%_i)+","+string(%_j)+")"; + TCL_SetVar(%_varname,%_value); + end + + //tmp = ((%_j)*(%_loc_ni)) / Nb_data; + //tmp = tmp *100; tmp = int(tmp); tmp = tmp /100; + //disp("tmp dans for=") + //disp(tmp) + //waitbar(tmp,winWB); + end + + + // disp("%_winId="); + // disp(%_winId); + // disp("type(%_winId)="); + // disp(type(%_winId)); + // disp("winWB="); + // disp(winWB); + // disp("type(winWB)="); + // disp(type(winWB)); + // disp("AVANT DrawGrid"); + + + TCL_EvalStr("GEDsciGUIEditVarDrawGrid "+%_winId) + + WINID = %_winId; + +endfunction + + +// for the ticks arrays Locations and Labels (inside TLIST) + +function ged_tablo=GetTab(val,index) + //disp("ICI") + ged_tablo(index) =val +endfunction + + +function ged_tablo=GetTab2(val,index,ged_tablo) + //disp("ICI") + ged_tablo(index) =val +endfunction + +function setTicksTList(XYZ,locations,labels) + global ged_handle;h= ged_handle; + + TL=tlist(["ticks","locations","labels"],locations,labels); + + if XYZ=="X" + h.x_ticks=TL; + elseif XYZ=="Y" + h.y_ticks=TL; + elseif XYZ=="Z" + h.z_ticks=TL; + end + +endfunction + + +// Is called by ged_axes + +function LoadTicks2TCL(h) + global ged_handle;ged_handle=h; + + TCL_SetVar("Xaxes_visibleToggle",h.axes_visible(1)) + TCL_SetVar("Yaxes_visibleToggle",h.axes_visible(2)) + TCL_SetVar("Zaxes_visibleToggle",h.axes_visible(3)) + + TCL_SetVar("SubticksEntryX",string(h.sub_ticks(1))) + TCL_GetVar("SubticksEntryX") + + // disp("h.sub_ticks(1) =") + // disp(h.sub_ticks(1)); + + TCL_SetVar("SubticksEntryY",string(h.sub_ticks(2))) + + select h.view + case "2d" + drawlater(); // postpon the drawings due to switching from 2d to 3d mode (for example) + // in order to know the complete data set (z data for axes...) + h.view="3d" + + TCL_SetVar("SubticksEntryZ",string(h.sub_ticks(3))) + h.view="2d" + drawnow(); + case "3d" + TCL_SetVar("SubticksEntryZ",string(h.sub_ticks(3))) + end + + TCL_SetVar("XautoticksToggle",h.auto_ticks(1)) + TCL_SetVar("YautoticksToggle",h.auto_ticks(2)) + TCL_SetVar("ZautoticksToggle",h.auto_ticks(3)) + + //ticks value: X axis + ticks = h.x_ticks; + sizeticks = size(ticks.locations,1); + TCL_SetVar("nbticks_x",string(sizeticks)); + for i=1:sizeticks + val= "LOCATIONS_X("+string(i)+")"; + TCL_EvalStr("set "+val+" "+string(ticks.locations(i))); + val= "LABELS_X("+string(i)+")"; + TCL_EvalStr("set "+val+" {"+ticks.labels(i)+"}"); + end + + //ticks value: Y axis + ticks = h.y_ticks; + sizeticks = size(ticks.locations,1); + TCL_SetVar("nbticks_y",string(sizeticks)); + for i=1:sizeticks + val= "LOCATIONS_Y("+string(i)+")"; + TCL_EvalStr("set "+val+" "+string(ticks.locations(i))); + val= "LABELS_Y("+string(i)+")"; + TCL_EvalStr("set "+val+" {"+ticks.labels(i)+"}"); + end + + //ticks value: Z axis + ticks = h.z_ticks; + sizeticks = size(ticks.locations,1); + TCL_SetVar("nbticks_z",string(sizeticks)); + for i=1:sizeticks + val= "LOCATIONS_Z("+string(i)+")"; + TCL_EvalStr("set "+val+" "+string(ticks.locations(i))); + val= "LABELS_Z("+string(i)+")"; + TCL_EvalStr("set "+val+" {"+ticks.labels(i)+"}"); + end + +endfunction + + + +function Subtickstoggle( tog, index) + global ged_handle; h=ged_handle + + subticks=h.sub_ticks; + subticks(index)=tog; + //disp("subticks vaut:") + //disp(subticks) + + h.sub_ticks = subticks; +endfunction + + +// when clicking on Ticks button : REload ticks is called + +function ReLoadTicks2TCL(h) + global ged_handle;ged_handle=h; + + TCL_SetVar("Xaxes_visibleToggle",h.axes_visible(1)) + TCL_SetVar("Yaxes_visibleToggle",h.axes_visible(2)) + TCL_SetVar("Zaxes_visibleToggle",h.axes_visible(3)) + + ticks = h.x_ticks; + sizeticks = size(ticks.locations,1); + if (sizeticks <> 0) + TCL_EvalStr("unset LOCATIONS_X"); + TCL_EvalStr("unset LABELS_X"); + end + + ticks = h.y_ticks; + sizeticks = size(ticks.locations,1); + if (sizeticks <> 0) + TCL_EvalStr("unset LOCATIONS_Y"); + TCL_EvalStr("unset LABELS_Y"); + end + + ticks = h.z_ticks; + sizeticks = size(ticks.locations,1); + if (sizeticks <> 0) + TCL_EvalStr("unset LOCATIONS_Z"); + TCL_EvalStr("unset LABELS_Z"); + end + + TCL_SetVar("SubticksEntryX",string(h.sub_ticks(1))) + // TCL_GetVar("SubticksEntryX") + + // disp("h.sub_ticks(1) =") + // disp(h.sub_ticks(1)); + + TCL_SetVar("SubticksEntryY",string(h.sub_ticks(2))) + + select h.view + case "2d" + drawlater(); + h.view="3d" + TCL_SetVar("SubticksEntryZ",string(h.sub_ticks(3))) + h.view="2d" + drawnow(); + case "3d" + TCL_SetVar("SubticksEntryZ",string(h.sub_ticks(3))) + end + + TCL_SetVar("XautoticksToggle",h.auto_ticks(1)) + TCL_SetVar("YautoticksToggle",h.auto_ticks(2)) + TCL_SetVar("ZautoticksToggle",h.auto_ticks(3)) + + //ticks value: X axis + ticks = h.x_ticks; + + sizeticks = size(ticks.locations,1); + TCL_SetVar("nbticks_x",string(sizeticks)); + for i=1:sizeticks + val= "LOCATIONS_X("+string(i)+")"; + TCL_EvalStr("set "+val+" "+string(ticks.locations(i))); + // disp("i vaut:"); + // disp(i); + val= "LABELS_X("+string(i)+")"; + TCL_EvalStr("set "+val+" {"+ticks.labels(i)+"}"); + end + + //ticks value: Y axis + ticks = h.y_ticks; + sizeticks = size(ticks.locations,1); + TCL_SetVar("nbticks_y",string(sizeticks)); + for i=1:sizeticks + val= "LOCATIONS_Y("+string(i)+")"; + TCL_EvalStr("set "+val+" "+string(ticks.locations(i))); + val= "LABELS_Y("+string(i)+")"; + TCL_EvalStr("set "+val+" {"+ticks.labels(i)+"}"); + end + + //ticks value: Z axis + ticks = h.z_ticks; + sizeticks = size(ticks.locations,1); + TCL_SetVar("nbticks_z",string(sizeticks)); + for i=1:sizeticks + val= "LOCATIONS_Z("+string(i)+")"; + TCL_EvalStr("set "+val+" "+string(ticks.locations(i))); + val= "LABELS_Z("+string(i)+")"; + TCL_EvalStr("set "+val+" {"+ticks.labels(i)+"}"); + end + +endfunction + + + +function DestroyGlobals() + global ged_current_figure + + if ~isempty(winsid()) & ~isempty(find(ged_current_figure==winsid())) then + scf(ged_current_figure) + end + + // ged is closed + TCL_UnsetVar("sciGedIsAlive"); + + clearglobal ged_current_figure + clear ged_current_figure + + // disp("PASSE PAR DestroyGlobals Scilab"); +endfunction + + +function ged_delete_entity() + [btn,xc,yc]=xclick() + [xc,yc]=xchange(xc,yc,"f2i") + h=ged_getobject([xc,yc]) + if h<>[] then delete(h),end +endfunction + +function ged_move_entity() + [btn,xc,yc]=xclick() + pos=[xc,yc] + [xc,yc]=xchange(xc,yc,"f2i") + [r,ax]=ged_getobject([xc,yc]) + cur_ax=gca(),sca(ax) + [xc,yc]=xchange(xc,yc,"i2f");pos=[xc,yc] + if r==[] return,end + drawlater(); + rep(3)=-1 + select r.type + case "Rectangle" then + while rep(3)==-1 do + rep=xgetmouse([%t %t]) + r.data(1:2)= r.data(1:2)+(rep(1:2)-pos) + pos=rep(1:2) + drawnow(); + end + case "Segs" then //Segment + while rep(3)==-1 do + rep=xgetmouse([%t %t]) + r.data=r.data+ones(2,1)*(rep(1:2)-pos) + pos=rep(1:2) + drawnow(); + end + case "Polyline" then //Polyline + while rep(3)==-1 do + rep=xgetmouse([%t %t]) + r.data(:,1:2)=r.data(:,1:2)+ones(r.data(:,1))*(rep(1:2)-pos) + pos=rep(1:2) + drawnow(); + end + case "Arc" then //Circle + while rep(3)==-1 do + rep=xgetmouse([%t %t]) + r.data(1:2)= r.data(1:2)+(rep(1:2)-pos) + pos=rep(1:2) + drawnow(); + end + case "Text" then + while rep(3)==-1 do + rep=xgetmouse([%t %t]) + r.data(1:2)= r.data(1:2)+(rep(1:2)-pos) + pos=rep(1:2) + drawnow(); + end + case "Label" then + while rep(3)==-1 do + rep=xgetmouse([%t %t]) + r.position= r.position+(rep(1:2)-pos) + r.auto_position = "off" + pos=rep(1:2) + drawnow(); + end + + end + sca(cur_ax) +endfunction + +function ged_copy_entity() + [btn,xc,yc]=xclick() + [xc,yc]=xchange(xc,yc,"f2i") + r=ged_getobject([xc,yc]) + if r==[] return,end + twinkle(r,1); + save(TMPDIR+"/G_Clipboard",r) + //make the axes containning the clicked point the current one + sca(ged_select_axes(xc,yc)) +endfunction + + +function ged_paste_entity() + + // check the file + [info,err] = fileinfo(TMPDIR + "/G_Clipboard" ) ; + + if err <> 0 then + return ; + end + + // create the saved object + load(TMPDIR+"/G_Clipboard") ; + + // a=gca();b=a.data_bounds; + // move(r,[-1 1]*a.data_bounds/20) +endfunction + +function axes = ged_select_axes(x,y) + // x and y are pixel coord. + f=gcf() + nb_axes = size(f.children,"*") // for now Iconsider that children of a figure are of type Axes + axes_size = f.axes_size // given in pixels + axes_size = [axes_size axes_size]; + + for i=1:nb_axes + axes = f.children(i); + cur_axes_bounds = axes.axes_bounds; + rect = cur_axes_bounds.*axes_size; // rectangle in pixels (margins inside) + + rect(3) = rect(3) + rect(1); + rect(4) = rect(4) + rect(2); + if (x>rect(1) & x<rect(3) & y>rect(2) & y<rect(4)) then + return + end + end + axes=[] +endfunction diff --git a/modules/graphics/macros/ged_insert.bin b/modules/graphics/macros/ged_insert.bin Binary files differnew file mode 100755 index 000000000..22c12a5ab --- /dev/null +++ b/modules/graphics/macros/ged_insert.bin diff --git a/modules/graphics/macros/ged_insert.sci b/modules/graphics/macros/ged_insert.sci new file mode 100755 index 000000000..467f55789 --- /dev/null +++ b/modules/graphics/macros/ged_insert.sci @@ -0,0 +1,229 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function ged_insert(k,win) + //xset, xget used because ged should handle both old and new style + + [lhs,rhs]=argn(0); + + if rhs<2, + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"), "ged_insert", 2)); + end + + global active men + + //check if user changes is mind + active=active+1;men=k + if active>1 then return,end + + ged_current_figure=xget("window") + xset("window",win) + + scf(win); + ged_cur_fig_handle=gcf(); + + mess1 = "Press the right mouse button (during a while) to stop the line creation"; + mess2 = "Press any mouse button to complete the object drawing" + entities=["Rectangle","Segment","Polyline","Arrow","Double Arrow", ... + "Text","Circle"] + + default_axes = gca(); // get the default axes where we start + f=gcf(); + job="annotation" + if job=="annotation" then axes = get_insertion_axes(job,f),end + + [k,xc,yc]=ged_click() + + drawlater(); + default_axes = gca(); // get the default axes where we start + rep(3)=-1 + select k + case -100 then //window has been closed + ged_insert_end(),return + case 1 then //Single Line + axes = get_insertion_axes(job,f,default_axes,xc,yc) + [xc,yc] = xchange(xc,yc,"f2i"); // I pass to pixel + sca(axes); // I change axes and therefore change the scale + [xc,yc] = xchange(xc,yc,"i2f"); // in the new scale I recompute the corresponding pixel values + xpoly([xc;xc],[yc;yc]) + drawnow(); + r=gce();r.foreground=-1; + r.clip_state="off"; + xinfo(mess2) + while rep(3)==-1 do + rep=xgetmouse(0,[%t %t]) + r.data=[xc,yc;rep(1),rep(2)] + xinfo(mess2) + end + case 2 then //Polyline (stroken line) + axes = get_insertion_axes(job,f,default_axes,xc,yc) + [xc,yc] = xchange(xc,yc,"f2i"); + sca(axes); + [xc,yc] = xchange(xc,yc,"i2f"); + xpoly([xc;xc],[yc;yc]) + drawnow(); + r=gce();r.foreground=-1; + r.data(:,3)=0.; + r.clip_state="off"; + xinfo(mess1) + while %t + rep(3)=-1; + while rep(3)==-1 do + rep=xgetmouse(0) + r.data($,:)= [rep(1),rep(2),0] + xinfo(mess1) + end + if or(rep(3)==[2 5 -100]) then break,end + r.data=[r.data;r.data($,:)] + end + case 3 // Arrow (single arrow) + axes = get_insertion_axes(job,f,default_axes,xc,yc) + [xc,yc] = xchange(xc,yc,"f2i"); + sca(axes); + [xc,yc] = xchange(xc,yc,"i2f"); + xpoly([xc;xc],[yc;yc]) + drawnow(); + r=gce();r.foreground=-1; + r.data(:,3)=0.; + r.polyline_style = 4; + r.arrow_size_factor=10; // change the factor to have a nice arrow + r.clip_state="off"; + xinfo(mess2) + yc = []; + while rep(3)==-1 do + rep=xgetmouse(0,[%t %t]) + r.data($,:)= [rep(1),rep(2),0] + xinfo(mess2) + end + // case 4 // Double Arrow + // axes = get_insertion_axes(job,f,default_axes,xc,yc) + // [xc,yc] = xchange(xc,yc,'f2i'); + // sca(axes); + // [xc,yc] = xchange(xc,yc,'i2f'); + // xpoly([xc;xc],[yc;yc]) + // r1=gce();r.foreground=-1; + // r1.data(:,3)=0.; + // r1.polyline_style = 4; + // r1.arrow_size_factor=5; // change the factor to have a nice arrow + // r1.clip_state='off'; + // + // // second polyline (for the seconf arrow from end to origin) + // xpoly([xc;xc],[yc;yc]) + // //xpoly([r.data(2,1);r.data(1,1)],[r.data(2,2);r.data(1,2)]) + // r2=gce();r.foreground=-1; + // r2.data(:,3)=0.; + // r2.polyline_style = 4; + // r2.arrow_size_factor=5; // change the factor to have a nice arrow + // r2.clip_state='off'; + // + // xinfo(mess2) + // while rep(3)==-1 do + // rep=xgetmouse(0,[%t %t]) + // drawlater(); + // r1.data($,:)= [rep(1),rep(2),0] + // r2.data(1,:)= [rep(1),rep(2),0] + // drawnow(); + // xinfo(mess2) + // end + + case 4 then //Text + // open a dialog to enter the text + text = x_dialog("Enter the new text here.","") ; + if ( text <> [] & text <> "" ) then + // do nothing if cancel button has been pressed or no text entered + // get the position of the text + xstring( xc, yc, text ) ; + end + drawnow(); + case 5 then //Rectangle + axes = get_insertion_axes(job,f,default_axes,xc,yc) + [xc,yc] = xchange(xc,yc,"f2i"); + sca(axes); + [xc,yc] = xchange(xc,yc,"i2f"); + xrect(xc,yc,0,0) + drawnow(); + r=gce();r.foreground=-1; + r.clip_state="off"; + xinfo(mess2) + while rep(3)==-1 do + rep=xgetmouse(0,[%t %t]) + r.data=[min(xc,rep(1)),max(yc,rep(2)),abs(xc-rep(1)),abs(yc-rep(2))] + xinfo(mess2) + end + case 6 then //Circle + axes = get_insertion_axes(job,f,default_axes,xc,yc) + [xc,yc] = xchange(xc,yc,"f2i"); + sca(axes); + [xc,yc] = xchange(xc,yc,"i2f"); + xarc(xc,yc,0,0,0,64*360) + drawnow(); + r=gce();r.foreground=-1; + r.clip_state="off"; + xinfo(mess2) + while rep(3)==-1 do + rep=xgetmouse(0,[%t %t]) + r.data=[min(xc,rep(1)),max(yc,rep(2)),abs(xc-rep(1)),abs(yc-rep(2)),0,64*360] + xinfo(mess2) + end + end + ged_insert_end() +endfunction + + + +function axes = get_insertion_axes(job,f,default_axes,xc,yc) + if job=="annotation" then //special axes used + axes=f.children(1) + if axes.user_data=="annotation" then return,end + // create a new specialized axes at left bottom of the window + //it should be better if the annotation axes be directly attached to + //the figure (to be done) + axes=newaxes(); + axes.user_data="annotation" + axes.axes_bounds=[0,1,0.15,0.15]; + axes.margins=[0 0 0 0]; + axes.axes_visible = ["off","off","off"] + axes.background=f.background; + else //get the axes containing the point xc,yc + //the point xc,yc is given in user coordinate relative to the + //default_axes axes entity. + nb_axes = size(f.children,"*") + // for now I consider that all children of a figure are of type Axes + axes_size = f.axes_size // given in pixels + axes_size = [axes_size axes_size]; + [x,y]=xchange(xc,yc,"f2i") + found=%f + for i=1:nb_axes + axes = f.children(i); + cur_axes_bounds = axes.axes_bounds; + rect = cur_axes_bounds.*axes_size; // rectangle in pixels (margins inside) + rect(3) = rect(3) + rect(1); + rect(4) = rect(4) + rect(2); + if (x>rect(1) & x<rect(3) & y>rect(2) & y<rect(4)) then found=%t,break,end + end + if ~found then axes=[],end + end +endfunction + +function ged_insert_end() + if or(win==winsid()) then // the window still exists + sca(default_axes); // resume the default axes + f=gcf() + clearglobal active men + end + if win<>ged_current_figure then xset("window",ged_current_figure),end + +endfunction +function [men,xc,yc]=ged_click() + global men + [btn,xc,yc]=xclick() + if btn==-100 then men=-100,end + for k=1:3,end + job=men +endfunction + diff --git a/modules/graphics/macros/genfac3d.bin b/modules/graphics/macros/genfac3d.bin Binary files differnew file mode 100755 index 000000000..f04e2e05e --- /dev/null +++ b/modules/graphics/macros/genfac3d.bin diff --git a/modules/graphics/macros/genfac3d.sci b/modules/graphics/macros/genfac3d.sci new file mode 100755 index 000000000..d97817f84 --- /dev/null +++ b/modules/graphics/macros/genfac3d.sci @@ -0,0 +1,58 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [xx,yy,zz]=genfac3d(x,y,zmat,mask) + + // genfac - transforms standard 3d data to four sides facets representation + //%Syntax + // [xx,yy,zz]=genfac3d(x,y,zmat,mask) + //%Parameters + // zmat : matrix , zmat(i,j)= F(x(j),y(i)) + // x : x axis coordinates vector + // y : y axis coordinates vector + // mask : boolean optional matrix with same size as zmat used to select + // entries of zmat to be represented by facets + // xx,yy,zz :4xn matrices. xx(:,i),yy(:,i),zz(:,i) are respectively the + // x-axis,y-axis and z-axis coordinates of the ith facet + //%Examples + // genfac3d() + //! + + [lhs,rhs]=argn(0) + + if rhs <= 0 then // demo + t=(0:10)'*%pi/5; + zmat=sin(t)*cos(t'); + [xx,yy,zz]=genfac3d(t,t,zmat,zmat>=0); + plot3d(xx,yy,zz); + return + end + + if rhs<3 then + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"), "genfac3d", 3)); + end + + [nr,nc]=size(zmat) + indy=(ones(1,nc-1).*.[0;1;1;0]+(1:nc-1).*.[1;1;1;1]).*.ones(1,nr-1); + indx=ones(1,nc-1).*.(ones(1,nr-1).*.[0;0;1;1]+(1:nr-1).*.[1;1;1;1]); + [nrl,nrc]=size(indx) + indx=matrix(indx,nrl*nrc,1); + indy=matrix(indy,nrl*nrc,1); + indz=indx+(nr)*(indy-1*ones(indy)); + [nrl,nrc]=size(indx); + xx=matrix(x(indx),4,nrl*nrc/4); + yy=matrix(y(indy),4,nrl*nrc/4); + zz=matrix(zmat(indz),4,nrl*nrc/4); + if rhs==4 then + zl=matrix(mask(indz),4,nrl*nrc/4); + [xin,yin]=find(zl); + zz=zz(:,yin); + xx=xx(:,yin); + yy=yy(:,yin); + end +endfunction diff --git a/modules/graphics/macros/getColorIndex.bin b/modules/graphics/macros/getColorIndex.bin Binary files differnew file mode 100755 index 000000000..f4ab153c5 --- /dev/null +++ b/modules/graphics/macros/getColorIndex.bin diff --git a/modules/graphics/macros/getColorIndex.sci b/modules/graphics/macros/getColorIndex.sci new file mode 100755 index 000000000..1b8f4069c --- /dev/null +++ b/modules/graphics/macros/getColorIndex.sci @@ -0,0 +1,81 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2004-2006 - INRIA - Fabrice Leray +// Copyright (C) 2010 - DIGITEO - Pierre Lando <pierre.lando@scilab.org> +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function opt1 = getColorIndex(ColorString) + + [lhs,rhs]=argn(0) + + if rhs<>1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "getColorIndex", 1)); + end + + if type(ColorString)<>10 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: A string expected.\n"), "getColorIndex", 1)); + end + + opt1=-1; + str = convstr(ColorString); + + // 1) COLORS + + //Colors + Table = ["red" "green" "blue" "cyan" "magenta" "yellow" "black" .. + "k" "white" "none" "auto" "flat" "interp"] + //ColorVal = ['red' 'green' 'blue' 'cyan' 'magenta' 'yellow' 'black' .. + // 'black' 'white' 'none' 'auto' 'flat' 'interp'] + // | | + // only used with 'surf' command + + //color management + //difficulty here since we have to allow every kind of writings: + //i.e: + //magenta can be set by: 'm' 'ma' 'mag' 'mage' 'magen' 'magent' or at least 'magenta' + // + + k=find(part(Table,1:length(str))==str); + + c1 = part(str,1); // We get the first character + + if (k == [] | (size(k,"*") > 1 & c1 <> "b")) + warning(msprintf(gettext("%s: Wrong value for input argument #%d: A color of the colormap expected.\n"),"getColorIndex", 1)); + return; + end + + if c1=="b" // special case here : we have to distinguish between black and blue colors + c2 = part(str,2); + if (c2 == "l") + c3 = part(str,3); + if (c3 == "a") + k=7; // k is set to black color + else + k=3; // k is set to blue color + end + else + k=3; // k is set to blue color + end + end + + opt = Table(k); + for i=1:length(str) + if part(opt,i) <> part(str,i) + break; + end + end + + opt1 = k; + + str = part(str,i:length(str)); + + if (size(opt1,"*") > 1) // unreachable case normally + warning(msprintf(gettext("%s: Wrong number of input arguments: %d expected.\n"),"getColorIndex",1)); + return; + end + + +endfunction diff --git a/modules/graphics/macros/getLineSpec.bin b/modules/graphics/macros/getLineSpec.bin Binary files differnew file mode 100755 index 000000000..306c97e34 --- /dev/null +++ b/modules/graphics/macros/getLineSpec.bin diff --git a/modules/graphics/macros/getLineSpec.sci b/modules/graphics/macros/getLineSpec.sci new file mode 100755 index 000000000..214aa0978 --- /dev/null +++ b/modules/graphics/macros/getLineSpec.sci @@ -0,0 +1,128 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2004-2006 - INRIA - Fabrice Leray +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [Color,Line,LineStyle,Marker,MarkerStyle,MarkerSize,fail]=getLineSpec(str,current_figure,cur_draw_mode) + + LineStyle=1; + Color=[]; + MarkerStyle=[]; + MarkerSize=1; + LineStyle=1; + fail=0; + + //conversion to lower format + str = convstr(str); + + // 1) LINE STYLE + // Line type modifiers + + if strindex(str,"--") + str=strsubst(str,"--",""); + LineStyle=2; + Line = %T; + elseif strindex(str,"-.") + str=strsubst(str,"-.",""); + LineStyle=4; + Line = %T; + elseif strindex(str,":") + str=strsubst(str,":",""); + LineStyle=5; + Line = %T; + elseif strindex(str,"-") + str=strsubst(str,"-",""); + LineStyle=1; + Line = %T; + end + + // + + //disp("str vaut:::::::: 1/2") + //disp(str) + + // 2) COLORS + MARKS STYLE + + opt1=[]; + + //Marks + Table = [ "+" "o" "*" "." "x" "square" "diamond" "^" "v" ">" "<" "pentagram"]; + MarksStyleVal=[1 9 10 0 2 11 5 6 7 12 13 14]; + //MarksSizeVal =[4 3 7 1 3 3 4 3 3 3 3 3]; + //MarksSizeVal =[6 6 6 6 6 6 6 6 6 6 6 6]; // size is given in points now (25.02.05) + + //Colors + Table= [Table "red" "green" "blue" "cyan" "magenta" "yellow" "black" "k" "white"] + ColorVal = ["red" "green" "blue" "cyan" "magenta" "yellow" "black" "black" "white"] + + //color management + //difficulty here since we have to allow every kind of writings: + //i.e: + //magenta can be set by: 'm' 'ma' 'mag' 'mage' 'magen' 'magent' or at least 'magenta' + // + + + str = str+"@"; + + while length(str) > 1 + c1 = part(str,1); // We get the first character + k=find(part(Table,1)==c1); + + if (k == [] | (size(k,"*") > 1 & c1 <> "b")) + ResetFigureDDM(current_figure, cur_draw_mode); + error(msprintf(gettext("%s: Wrong type for input argument.\n"), "getLineSpec")); + end + + if c1=="b" // special case here : we have to distinguish between black and blue colors + c2 = part(str,2); + if (c2 == "l") + c3 = part(str,3); + if (c3 == "a") + k=19; // k is set to black color + else + k=15; // k is set to blue color + end + else + k=15; // k is set to blue color + end + end + + opt = Table(k); + for i=1:length(str) + if part(opt,i) <> part(str,i) + break; + end + end + + opt1 = [opt1 k]; + + str = part(str,i:length(str)); + + end + + + // LineSpec is parsed now + //Marker = %F; + //Line = %T; + + for i=1:size(opt1,"*") + + if (opt1(i) <= 12) + Marker = %T; + MarkerStyle = MarksStyleVal(opt1(i)); + MarkerSize = 6; + //MarkerSize = MarksSizeVal (opt1(i)); + // disp("MarkerSize ="); + // disp(MarkerSize); + else + Color = color(ColorVal(opt1(i)-12)); + end + + end + + +endfunction +// end of getLineSpec diff --git a/modules/graphics/macros/getPlotPropertyName.bin b/modules/graphics/macros/getPlotPropertyName.bin Binary files differnew file mode 100755 index 000000000..4f09eb5ab --- /dev/null +++ b/modules/graphics/macros/getPlotPropertyName.bin diff --git a/modules/graphics/macros/getPlotPropertyName.sci b/modules/graphics/macros/getPlotPropertyName.sci new file mode 100755 index 000000000..fde9094d9 --- /dev/null +++ b/modules/graphics/macros/getPlotPropertyName.sci @@ -0,0 +1,67 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2004-2006 - INRIA - Fabrice Leray +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +function [PName] = getPlotPropertyName(PropertyName,current_figure,cur_draw_mode) + + //conversion to lower format + err = execstr("str = convstr(PropertyName);", "errcatch", "m"); + + if err <> 0 + warning(msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"getPlotPropertyName",1)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + Table = ["clipping" "color" "foreground" "linestyle" "linewidth" "thickness" "marker" .. + "markstyle" "markeredgecolor" "markforeground" "markerfacecolor" "markbackground" .. + "markersize" "marksize" "visible" "xdata" "ydata" "zdata"]; + TableEQ = ["clipping" "foreground" "foreground" "linestyle" "thickness" "thickness" "markstyle".. + "markstyle" "markforeground" "markforeground" "markbackground" "markbackground" .. + "marksize" "marksize" "visible" "xdata" "ydata" "zdata"]; // equivalent Table + + opt1=[]; + + k=find(part(Table,1:length(str))==str); + + if (k == []) + warning(msprintf(gettext("%s: Wrong value for input argument #%d: A valid property name expected.\n"),"getPlotPropertyName",1)); + PName=[]; + ResetFigureDDM(current_figure, cur_draw_mode); + return; + elseif ( size(k,"*") > 1) + if or(find(k==7)) // case PropertyName == 'marker' + k=7; // set to PropertyName == 'marker' only + else + warning(msprintf(gettext("%s: Ambiguous line property.\n"),"getPlotPropertyName")); + PName=[]; + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + end + + opt = Table(k); + for i=1:length(str) + if part(opt,i) <> part(str,i) + break; + end + end + + opt1 = [opt1 k]; + + str = part(str,i:length(str)); + + if (size(opt1,"*") > 1) + warning(msprintf(gettext("%s: Wrong size for input argument #%d: Only one property expected.\n"),"getPlotPropertyName",1)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + PName = TableEQ(opt1); + +endfunction diff --git a/modules/graphics/macros/getSurfPropertyName.bin b/modules/graphics/macros/getSurfPropertyName.bin Binary files differnew file mode 100755 index 000000000..67e081824 --- /dev/null +++ b/modules/graphics/macros/getSurfPropertyName.bin diff --git a/modules/graphics/macros/getSurfPropertyName.sci b/modules/graphics/macros/getSurfPropertyName.sci new file mode 100755 index 000000000..02062d938 --- /dev/null +++ b/modules/graphics/macros/getSurfPropertyName.sci @@ -0,0 +1,74 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2004-2006 - INRIA - Fabrice Leray +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [PName] = getSurfPropertyName(PropertyName,current_figure,cur_draw_mode) + + if ~isdef("PropertyName") | ~isdef("current_figure") | ~isdef("cur_draw_mode") then + error(msprintf(gettext("%s: Wrong number of input arguments: %d expected.\n"), "getSurfPropertyName", 3)); + end + + //conversion to lower format + str = convstr(PropertyName); + + // WARNING: if you add/remove a property from these tables, + // please update the value of k in lines marked with the following comment: + // UPDATE K HERE IF TABLES MODIFIED + Table = ["cdata" "colordata" "cdata_mapping" "cdatamapping" "colordatamapping" .. + "cdatamode" "colordatamode" "clipping" "edgecolor" "foreground" "facecolor" .. + "linestyle" "linewidth" "thickness" "marker" .. + "markstyle" "markeredgecolor" "markforeground" "markerfacecolor" "markbackground" .. + "markersize" "marksize" "visible" "xdata" "ydata" "zdata"]; + + TableEQ = ["colordata" "colordata" "colordatamapping" "colordatamapping" "colordatamapping" .. + "colordatamode" "colordatamode" "clipping" "foreground" "foreground" "facecolor" .. + "linestyle" "thickness" "thickness" "markstyle" .. + "markstyle" "markforeground" "markforeground" "markbackground" "markbackground" .. + "marksize" "marksize" "visible" "xdata" "ydata" "zdata"]; // equivalent Table + + opt1=[]; + + k=find(part(Table,1:length(str))==str); + + if (k == []) + warning(msprintf(gettext("%s: Wrong value for input argument #%d: A valid property name expected.\n"),"getSurfPropertyName",1)); + PName=[]; + ResetFigureDDM(current_figure, cur_draw_mode); + return; + elseif ( size(k,"*") > 1) + if or(find(k==15)) // case PropertyName == 'marker' // UPDATE K HERE IF TABLES MODIFIED + k=15; // set to PropertyName == 'marker' only // UPDATE K HERE IF TABLES MODIFIED + elseif or(find(k==2)) // case PropertyName == 'colordata' // UPDATE K HERE IF TABLES MODIFIED + k=2; // UPDATE K HERE IF TABLES MODIFIED + else + warning(msprintf(gettext("%s: Ambiguous surface property: %s.\n"),"getSurfPropertyName","PropertyName")); + PName=[]; + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + end + + opt = Table(k); + for i=1:length(str) + if part(opt,i) <> part(str,i) + break; + end + end + + opt1 = [opt1 k]; + + str = part(str,i:length(str)); + + if (size(opt1,"*") > 1) + warning(msprintf(gettext("%s: Wrong size for input argument #%d: Only one property expected.\n"),"getSurfPropertyName",1)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + PName = TableEQ(opt1); + +endfunction diff --git a/modules/graphics/macros/getTitleLabelPropertyNam.bin b/modules/graphics/macros/getTitleLabelPropertyNam.bin Binary files differnew file mode 100755 index 000000000..9f3a61517 --- /dev/null +++ b/modules/graphics/macros/getTitleLabelPropertyNam.bin diff --git a/modules/graphics/macros/getTitleLabelPropertyNam.sci b/modules/graphics/macros/getTitleLabelPropertyNam.sci new file mode 100755 index 000000000..a6d393176 --- /dev/null +++ b/modules/graphics/macros/getTitleLabelPropertyNam.sci @@ -0,0 +1,71 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2004-2006 - INRIA - Farid Belahcene +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [PName] = getTitleLabelPropertyNam(PropertyName,current_figure,cur_draw_mode) + // Copyright INRIA + // GETTITLELABELPROPERTYNAME function + // is used by the functions title, xlabel, ylabel, zlabel + // this function gets the matlab properties names and repalce them by the equivalent scilab properties names, using Table and TableEQ + + //conversion to lower format + str = convstr(PropertyName); + + + Table = [ "visible" "fontname" "fontangle" "fontsize" "rotation" .. + "position" "color" "edgecolor" "backgroundcolor" ]; + + TableEQ = [ "visible" "font_style" "font_style" "font_size" "font_angle" .. + "position" "font_foreground" "foreground" "background"] + + //TableEQ = [ 'visible' 'font_style' 'font_style' 'font_size' 'font_angle' .. + // 'position' 'foreground' 'background' .. + // 'visible' 'fill_mode' 'auto_position' 'auto_rotation']; // equivalent Table + + opt1=[]; + k=find(part(Table,1:length(str))==str); + + if (isempty(k)) then + // Scilab names are allowed too... + k=find(part(TableEQ,1:length(str))==str); + if ~isempty(k) then + PName = TableEQ(k(1)) + return; + end + end + + if (k == []) + warning("Error in Property specification : bad argument specified"); + PName=[]; + ResetFigureDDM(current_figure, cur_draw_mode); + return; + elseif (size(k,"*") > 1) + warning("Ambiguous text property"); + PName=[]; + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + opt = Table(k); + for i=1:length(str) + if part(opt,i) <> part(str,i) + break; + end + end + + opt1 = [opt1 k]; + + str = part(str,i:length(str)); + + if (size(opt1,"*") > 1) + warning("Error in Property specification : too much properties specified"); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + PName = TableEQ(opt1); +endfunction diff --git a/modules/graphics/macros/get_figure_handle.bin b/modules/graphics/macros/get_figure_handle.bin Binary files differnew file mode 100755 index 000000000..17fed8736 --- /dev/null +++ b/modules/graphics/macros/get_figure_handle.bin diff --git a/modules/graphics/macros/get_figure_handle.sci b/modules/graphics/macros/get_figure_handle.sci new file mode 100755 index 000000000..770653a0a --- /dev/null +++ b/modules/graphics/macros/get_figure_handle.sci @@ -0,0 +1,32 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Jean-Baptiste Silvy +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +function [fig]=get_figure_handle(index) + + if argn(2)<>1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "get_figure_handle", 1)); + end + + // check index + figureIndices = winsid(); + // check that index is within the opened windows + if (find(figureIndices == index) == []) then + fig = []; + return; + end + + // return the figure handle from its index + curFig = gcf(); + fig = scf(index); + + // scf sets the figure, so switch back to curFig + scf(curFig); + +endfunction + diff --git a/modules/graphics/macros/getcolor.bin b/modules/graphics/macros/getcolor.bin Binary files differnew file mode 100755 index 000000000..8b80e0b4b --- /dev/null +++ b/modules/graphics/macros/getcolor.bin diff --git a/modules/graphics/macros/getcolor.sci b/modules/graphics/macros/getcolor.sci new file mode 100755 index 000000000..48ff63faf --- /dev/null +++ b/modules/graphics/macros/getcolor.sci @@ -0,0 +1,177 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [c] = getcolor(Title,cini) + + [lhs,rhs] = argn(0) + + if rhs==0 then + Title = ""; + cini = 1; + elseif rhs==1 then + if type(Title)~=10 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: A string expected.\n"), "getcolor", 1)); + end + if size(Title, "*")~=1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: A string expected.\n"), "getcolor", 1)); + end + cini = 1; + elseif rhs==2 then + if type(Title)~=10 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: A string expected.\n"), "getcolor", 1)); + end + if size(Title, "*")~=1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: A string expected.\n"), "getcolor", 1)); + end + if type(cini)~=1 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: A real expected.\n"), "getcolor", 2)); + end + if size(cini, "*")~=1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: A real expected.\n"), "getcolor", 2)); + end + else + error(msprintf(gettext("%s: Wrong number of input arguments: %d to %d expected.\n"), "getcolor", 2, 0, 2)); + end + + if winsid()~=[] then + curFig = gcf(); + cmap = curFig.color_map; + curwin = curFig.figure_id; + else + cmap = [] + curwin = [] + end; + + // create the window for getcolor + win = max(winsid()) + 1; + scf(win); + + sdf; + sda; + fig = gcf(); + if cmap~=[] then + fig.color_map = cmap; + else + cmap = fig.color_map; + end; + + N = size(cmap,1); + wdim = [1,1]; + r = wdim(1)/wdim(2); + n = round(sqrt(N/r)); + m = int(n*r); + H = m*45; // These numbers set the size of the getcolor window + W = n*45; + fig.figure_size = [H,W]; + + toolbar(win, "off") + + delmenu(win,gettext("&File")) + delmenu(win,gettext("&Tools")) + delmenu(win,gettext("&Edit")) + delmenu(win,gettext("&?")) + + dx = wdim(1)/m; + dy = wdim(2)/n; + x = -dx; + y = wdim(2); + R = [0;0;dx*0.95;dy*0.95]; + rects = []; + for k = 1:N + if modulo(k,n)==1 then + x = x+dx; + y = wdim(2); + end; + rects = [rects,R+[x;y;0;0]]; + y = y-dy; + end; + + if Title~="" then + xsetech([-1/8,0,1+1/6,1+1/6-1/8],[0,0,wdim(1),wdim(2)]); + else + xsetech([-1/8,-1/8,1+1/6,1+1/6],[0,0,wdim(1),wdim(2)]); + end; + // rectangles with the colors + xrects(rects,1:N); + // frame around the colors + r = m*n-N; + ddx = 0.05*dx; + ddy = 0.05*dy; + if r==0 then + xpoly([-ddx,1,1,-ddx],[0,0,1+ddy,1+ddy],"lines",1); + else + xpoly([-ddx,1-1/n,1-1/n,1,1,-ddx],[0,0,r/m,r/m,1+ddy,1+ddy],"lines",1); + end; + + // title + if Title~="" then + xtitle(Title); + t = gce(); + t.font_size = 4; + t.font_style = 6; + end; + + k1 = min(max(cini,1),N); + xrects(rects(eye(),k1),-k1); + e = gce(); + rector = e.children; + rector.thickness = 4; + rector.foreground = color(255*(1-cmap(k1,1)),255*(1-cmap(k1,2)),255*(1-cmap(k1,3))); + + //add a menu and its callback + done = %f; + Ok = "execstr("+gettext("Ok")+"_"+string(win)+"(1))"; + Cancel = "execstr("+gettext("Cancel")+"_"+string(win)+"(1))"; + + addmenu(win, gettext("Ok")); + addmenu(win, gettext("Cancel")); + + c_i = 0; + c = cini; + windowCloseButton = -1000; + while %t + str = ""; + [c_i,cx,cy,cw,str] = xclick(); + if (c_i == windowCloseButton) then + // window has been closed + k = []; + c = []; + break; + elseif (c_i== -2) then + if str==Ok then k = k1; c = k; break;end; + if str==Cancel then k = []; c = []; break;end; + end; + + mc = int(cx/dx)+1; + nc = n-int(cy/dy); + k = (mc-1)*n+nc; + if or(c_i==[0,3])&k<=N&k>0 then + if k1~=0 then + move(rector,[rects(1,k)-rects(1,k1),rects(2,k)-rects(2,k1)]); + rector.foreground = color(255*(1-cmap(k,1)),255*(1-cmap(k,2)),255*(1-cmap(k,3))); + end; + k1 = k; + name = rgb2name(cmap(k,eye())*255); + fig.info_message = .. + gettext("Color number")+" "+string(k)+": R="+string(floor(cmap(k,1)*255))+" G="+string(floor(cmap(k,2)*255))+" B="+string(floor(cmap(k,3)*255))+" "+gettext("Name")+"="""+name(1)+""""; + + + end; + end; + + if (c_i <> windowCloseButton) then + delete(fig); + end + + if curwin~=[] then + scf(curwin); + end; + + +endfunction + diff --git a/modules/graphics/macros/ghdl2tree.bin b/modules/graphics/macros/ghdl2tree.bin Binary files differnew file mode 100755 index 000000000..160b84273 --- /dev/null +++ b/modules/graphics/macros/ghdl2tree.bin diff --git a/modules/graphics/macros/ghdl2tree.sci b/modules/graphics/macros/ghdl2tree.sci new file mode 100755 index 000000000..0139e3bc6 --- /dev/null +++ b/modules/graphics/macros/ghdl2tree.sci @@ -0,0 +1,47 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2005 - INRIA - Serge Steer +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [t] = ghdl2tree(h) + // converts a graphic handle into a scilab tree (resursive tlist + + if argn(2)<>1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "ghdl2tree", 1)); + end + + if size(h,"*")> 1 then + t=list();for k=1:size(h,"*"),t(k)=ghdl2tree(h(k)),end + return + end + + typ=h.type + + //get the vector of fields names and make it a row + fields=matrix(ghdl_fields(h),1,-1) + + if fields<>[] then + t=tlist([typ,fields]) + for name=fields + if execstr("p=get(h,name)","errcatch")<>0 then + disp("error ghdl2tree "+typ+" "+name) + else + if type(p)==9 then // current field is a handle or a vector of handle + if size(p,"*")== 1 then + p=ghdl2tree(p), + else + chl=list();for k=1:size(p,"*"),chl(k)=ghdl2tree(p(k)),end + p=chl + end + end + t($+1)=p + end + end + else //no fields defined + t=tlist(typ) + end +endfunction + diff --git a/modules/graphics/macros/ghdl_fields.bin b/modules/graphics/macros/ghdl_fields.bin Binary files differnew file mode 100755 index 000000000..9ca13fbe7 --- /dev/null +++ b/modules/graphics/macros/ghdl_fields.bin diff --git a/modules/graphics/macros/ghdl_fields.sci b/modules/graphics/macros/ghdl_fields.sci new file mode 100755 index 000000000..7a2135152 --- /dev/null +++ b/modules/graphics/macros/ghdl_fields.sci @@ -0,0 +1,94 @@ + +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2005 - INRIA - Serge Steer +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +function fields=ghdl_fields(h) + + if argn(2)<>1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "ghdl_fields", 1)); + end + + //returns the set of fields associated with a given graphic handle + if size(h,"*")<>1 then error("argument must be a single handle"),end + typ=h.type + select h.type + case "Figure" + fields=["visible";"figure_position";"figure_size";"axes_size"; + "auto_resize";"figure_name";"figure_id";"color_map"; + "pixel_drawing_mode";"immediate_drawing";"background"; + "rotation_style";"children";"user_data"]' + case "Axes" + fields=["children";"visible";"axes_visible";"axes_reverse";"grid";"x_location"; + "y_location";"title";"x_label";"y_label";"z_label";"auto_ticks"; + "x_ticks";"y_ticks";"z_ticks";"box";"sub_ticks"; + "font_style";"font_size";"font_color";"isoview";"cube_scaling"; + "view";"rotation_angles";"log_flags";"tight_limits";"data_bounds" ; + "zoom_box";"margins";"axes_bounds";"auto_clear";"auto_scale"; + "hiddencolor";"line_mode";"line_style";"thickness";"mark_mode"; + "mark_style";"mark_size_unit";"mark_size";"mark_foreground"; + "mark_background";"foreground";"background";"clip_state";"clip_box"; + "user_data"]'; + case "Polyline" + fields=["visible";"data";"line_mode";"line_style";"thickness"; + "polyline_style";"foreground";"mark_mode";"mark_style"; + "mark_size_unit";"mark_size";"mark_foreground";"mark_background"; + "clip_state";"clip_box";"user_data"]'; + case "Plot3d"; + fields=["visible";"surface_mode";"foreground";"thickness"; + "mark_mode";"mark_style";"mark_size_unit";"mark_size"; + "mark_foreground";"mark_background";"data";"color_mode"; + "color_flag";"hiddencolor";"user_data"]'; + case "Fac3d"; + fields=["visible";"surface_mode";"foreground";"thickness"; + "mark_mode";"mark_style";"mark_size_unit";"mark_size"; + "mark_foreground";"mark_background";"data"; + "color_mode";"color_flag";"hiddencolor";"user_data"]'; + case "Compound" + fields=["children";"user_data"]'; + case "Rectangle" + fields=["mark_mode";"mark_style";"mark_size_unit";"mark_size"; + "mark_foreground";"mark_background";"line_mode";"line_style"; + "thickness";"fill_mode";"foreground";"data";"visible"; + "clip_state";"clip_box";"user_data"]'; + case "Arc" + fields=["thickness";"line_style";"fill_mode";"foreground";"data"; + "visible";"clip_state";"clip_box";"user_data"]'; + case "Segs" + fields =["visible";"data";"line_mode";"line_style";"thickness"; + "arrow_size";"segs_color";"mark_mode";"mark_style"; + "mark_size_unit";"mark_size";"mark_foreground"; + "mark_background";"clip_state";"clip_box";"user_data"]'; + case "Grayplot" + fields =["visible";"data";"data_mapping";"clip_state";"clip_box";"user_data"]'; + case "Fec" + fields =["visible";"data";"triangles";"z_bounds";"clip_state";"clip_box";"user_data"]'; + case "Legend" + fields =["visible";"text"; + "foreground";"font_style";"font_size";"font_angle"; + "clip_state";"clip_box"]'; + case "Text" + fields =["visible";"text";"data";"text_box";"text_box_mode"; + "foreground";"font_style";"font_size";"font_angle"; + "clip_state";"clip_box"]'; + case "Label" + fields =["visible";"text";"foreground";"font_style";"font_size"]'; + + case "Axis" + fields =["visible";"tics_direction";"xtics_coord";"ytics_coord"; + "tics_color";"tics_segment";"tics_style";"sub_tics"; + "tics_labels";"labels_font_size";"labels_font_color"; + "clip_state";"clip_box";"user_data"]'; + + else + disp("handle of type "+h.type+" unhandled") + fields =[] + end +endfunction + + diff --git a/modules/graphics/macros/gr_macros.sce b/modules/graphics/macros/gr_macros.sce new file mode 100755 index 000000000..c3f2d009e --- /dev/null +++ b/modules/graphics/macros/gr_macros.sce @@ -0,0 +1,690 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at; +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function []=Delete(sd) + //destruction d'un objet + xx=locate(1);eps=0.2 + mm=clearmode(); + //recherche de l'objet contenant le point + for ko=2:ksd; + obj=sd(ko); + to="rien";if size(obj)<>0 then to=obj(1);end, + select to + case "ligne" then + z=obj(2),[nw,npt]=size(z), + for kpt=2:npt + e=norm(xx-z(:,kpt),2)+norm(xx-z(:,kpt-1),2) + if abs(e-norm(z(:,kpt)-z(:,kpt-1),2))< eps then + sd(ko)=ligne(obj,"del"); + end, + end, + case "fligne" then + z=obj(2),[nw,npt]=size(z), + for kpt=2:npt + e=norm(xx-z(:,kpt),2)+norm(xx-z(:,kpt-1),2) + if abs(e-norm(z(:,kpt)-z(:,kpt-1),2))< eps then + sd(ko)=fligne(obj,"del"); + end, + end, + case "rect" then + x1=obj(2);x2=obj(3);y1=obj(4);y2=obj(5); + z=[x1,x1,x2,x2,x1 ; y1,y2,y2,y1,y1]; + [nw,npt]=size(z), + for kpt=2:npt + e=norm(xx-z(:,kpt),2)+norm(xx-z(:,kpt-1),2) + if abs(e-norm(z(:,kpt)-z(:,kpt-1),2))< eps then + sd(ko)=rect(obj,"del"); + end, + end, + case "frect" then + x1=obj(2);x2=obj(3);y1=obj(4);y2=obj(5); + z=[x1,x1,x2,x2,x1 ; y1,y2,y2,y1,y1]; + [nw,npt]=size(z), + for kpt=2:npt + e=norm(xx-z(:,kpt),2)+norm(xx-z(:,kpt-1),2) + if abs(e-norm(z(:,kpt)-z(:,kpt-1),2))< eps then + sd(ko)=frect(obj,"del"); + end, + end, + case "points" then + z=obj(2),[nw,npt]=size(z), + for kpt=2:npt + e=norm(xx-z(:,kpt),2)+norm(xx-z(:,kpt-1),2) + if abs(e-norm(z(:,kpt)-z(:,kpt-1),2))< eps then + sd(ko)=points(obj,"del"); + end, + end, + case "cercle" then + dist=norm(obj(2)-xx,2); + if abs(dist-obj(3))<eps then sd(ko)=cerc(obj,"del");end, + case "fcercle" then + dist=norm(obj(2)-xx,2); + if abs(dist-obj(3))<eps then sd(ko)=fcerc(obj,"del");end, + case "fleche" then + o1=obj(2);o2=obj(3);p1=[o1(1);o2(1)];p2=[o1(2);o2(2)]; + e=norm(xx-p1,2)+norm(xx-p2,2) + if abs(e-norm(p2-p1))< eps then sd(ko)=fleche(obj,"del");end, + case "comm" then + xxr=xstringl(0,0,obj(3)) + hx=xxr(3); + hy=xxr(4); + crit=norm(obj(2)-xx)+norm(obj(2)+[hx;hy]-xx) + if crit<hx+hy then sd(ko)=comment(obj,"del");end + end, //fin selec to + end; //fin for ko ... + modeback(mm); + sd=resume(sd) +endfunction + +function sd=Move(sd) + //deplacement d'un objet + // Copyright INRIA + xx=locate(1);eps=0.03 + //mm=clearmode(); + //recherche de l'objet contenant le point + for ko=2:ksd; + obj=sd(ko); + to="rien";if size(obj)<>0 then to=obj(1);end, + select to + case "ligne" then + z=obj(2),[nw,npt]=size(z), + for kpt=2:npt + e=norm(xx-z(:,kpt),2)+norm(xx-z(:,kpt-1),2) + if abs(e-norm(z(:,kpt)-z(:,kpt-1),2))< eps then + new=ligne(obj,"mov"); + if new<>list() then + sd(ko)=new + end + return; + end, + end, + case "fligne" then + z=obj(2),[nw,npt]=size(z), + for kpt=2:npt + e=norm(xx-z(:,kpt),2)+norm(xx-z(:,kpt-1),2) + if abs(e-norm(z(:,kpt)-z(:,kpt-1),2))< eps then + new=fligne(obj,"mov"); + if new<>list() then + sd(ko)=new + end + return; + end, + end, + case "rect" then + x1=obj(2);x2=obj(3);y1=obj(4);y2=obj(5); + z=[x1,x1,x2,x2,x1 ; y1,y2,y2,y1,y1]; + [nw,npt]=size(z), + for kpt=2:npt + e=norm(xx-z(:,kpt),2)+norm(xx-z(:,kpt-1),2) + if abs(e-norm(z(:,kpt)-z(:,kpt-1),2))< eps then + new=rect(obj,"mov"); + if new<>list() then + sd(ko)=new + end + return; + end, + end, + case "frect" then + x1=obj(2);x2=obj(3);y1=obj(4);y2=obj(5); + z=[x1,x1,x2,x2,x1 ; y1,y2,y2,y1,y1]; + [nw,npt]=size(z), + for kpt=2:npt + e=norm(xx-z(:,kpt),2)+norm(xx-z(:,kpt-1),2) + if abs(e-norm(z(:,kpt)-z(:,kpt-1),2))< eps then + new=frect(obj,"mov"); + if new<>list() then + sd(ko)=new + end + return; + end, + end, + case "points" then + z=obj(2),[nw,npt]=size(z), + for kpt=2:npt + e=norm(xx-z(:,kpt),2)+norm(xx-z(:,kpt-1),2) + if abs(e-norm(z(:,kpt)-z(:,kpt-1),2))< eps then + new=points(obj,"mov"); + if new<>list() then + sd(ko)=new + end + return; + end, + end, + case "cercle" then + dist=norm(obj(2)-xx,2); + if abs(dist-obj(3))<eps then + new=cerc(obj,"mov"); + if new<>list() then + sd(ko)=new + end + return; + end + case "fcercle" then + dist=norm(obj(2)-xx,2); + if abs(dist-obj(3))<eps then + new=fcerc(obj,"mov"); + if new<>list() then + sd(ko)=new + end + return; + end + case "fleche" then + o1=obj(2);o2=obj(3);p1=[o1(1);o2(1)];p2=[o1(2);o2(2)]; + e=norm(xx-p1,2)+norm(xx-p2,2) + if abs(e-norm(p2-p1))< eps then + new=fleche(obj,"mov"); + if new<>list() then + sd(ko)=new + end + return; + end + case "comm" then + xxr=xstringl(0,0,obj(3)) + hx=xxr(3); + hy=xxr(4); + crit=norm(obj(2)-xx)+norm(obj(2)+[hx;hy]-xx) + if crit<hx+hy then + new=comment(obj,"mov"); + if new<>list() then + sd(ko)=new + end + return; + end + end, //fin selec to + end; //fin for ko ... +endfunction + +function [sd1]=symbs(sd,del) + [lhs,rhs]=argn(0);sd1=[]; + if rhs<=0 then + c=xget("mark") + n1=c(1);dime=c(2) + sd1=list("symbs",c(1),c(2)); + else + n1=sd(2);dime=sd(3) + end + xset("mark",n1,dime); +endfunction + +function [sd1]=dashs(sd,del) + [lhs,rhs]=argn(0);sd1=[]; + if rhs<=0 then + n1=x_choose(dash,"Choose a dash style"); + if n1==[] then + sd1=list() + else + sd1=list("dashs",n1); + end + else + n1=sd(2) + end + xset("dashes",n1); +endfunction + +function [sd1]=patts(sd,del) + [lhs,rhs]=argn(0);sd1=[]; + if rhs<=0 then + n1=getcolor("Choose a pattern ",0) + if n1==[] then + sd1=list() + else + sd1=list("patts",n1); + end + else + + n1=sd(2) + end + xset("pattern",n1); +endfunction + +function [sd1]=Thick(sd,del) + [lhs,rhs]=argn(0);sd1=[]; + if rhs<=0 then + + T=string(1:15) + ll=list() + t=xget("thickness") + ll(1)=list("Thickness",t,T); + n1=x_choices("Choose a Thickness",ll); + if n1==[] then + sd1=list() + else + sd1=list("thick",n1); + end + else + n1=sd(2) + end + xset("thickness",n1); +endfunction + +function sd1 =rect(sd,del) + [lhs,rhs]=argn(0);sd1=[]; + if rhs<=0 then //get + [x1,y1,x2,y2,but]=xgetm(d_xrect) + if but==2 then sd1=list();return,end + sd1=list("rect",x1,x2,y1,y2); + d_xrect(x1,y1,x2,y2); + elseif rhs==1 then //draw + x1=sd(2);x2=sd(3),y1=sd(4),y2=sd(5); + d_xrect(x1,y1,x2,y2); + elseif del=="del" then //erase + x1=sd(2);x2=sd(3),y1=sd(4),y2=sd(5); + d_xrect(x1,y1,x2,y2); + elseif del=="mov" then //move + x1=sd(2);x2=sd(3),y1=sd(4),y2=sd(5) + x0=xx(1);y0=xx(2); + [xo,yo]=move_object("d_xrect(x1-(x0-xo),y1-(y0-yo),x2-(x0-xo),y2-(y0-yo))",x0,y0); + sd1=sd; + sd1(2)=sd(2)-(x0-xo) + sd1(3)=sd(3)-(x0-xo) + sd1(4)=sd(4)-(y0-yo) + sd1(5)=sd(5)-(y0-yo) + end +endfunction + +function sd1=frect(sd,del) + [lhs,rhs]=argn(0);sd1=[]; + if rhs<=0 then // get + [x1,y1,x2,y2,but]=xgetm(d_xrect) + if but==2 then sd1=list();return,end + sd1=list("frect",x1,x2,y1,y2); + d_xfrect(x1,y1,x2,y2); + elseif rhs==1 then //draw + x1=sd(2);x2=sd(3),y1=sd(4),y2=sd(5) + d_xfrect(x1,y1,x2,y2); + elseif del=="del" then //erase + x1=sd(2);x2=sd(3),y1=sd(4),y2=sd(5) + d_xfrect(x1,y1,x2,y2); + elseif del=="mov" then //move + x1=sd(2);x2=sd(3),y1=sd(4),y2=sd(5) + x0=xx(1);y0=xx(2); + [xo,yo]=move_object("d_xfrect(x1-(x0-xo),y1-(y0-yo),x2-(x0-xo),y2-(y0-yo))",x0,y0); + sd1=sd + sd1(2)=sd(2)-(x0-xo) + sd1(3)=sd(3)-(x0-xo) + sd1(4)=sd(4)-(y0-yo) + sd1(5)=sd(5)-(y0-yo) + end +endfunction + +function sd1=cerc(sd,del) + [lhs,rhs]=argn(0);sd1=[]; + if rhs<=0 then // get + [c1,c2,x1,x2,but]=xgetm(d_circle); + if but==2 then sd1=list();return,end + x=[x1;x2],c=[c1;c2];r=norm(x-c,2); + sd1=list("cercle",c,r); + d_circle(c,r); + elseif rhs==1 then //draw + c=sd(2);r=sd(3); + d_circle(c,r); + elseif del=="del" then //erase + c=sd(2);r=sd(3); + d_circle(c,r); + elseif del=="mov" then //move + c=sd(2);r=sd(3) + x0=xx(1);y0=xx(2); + [xo,yo]=move_object("d_circle(c-[x0-xo;y0-yo],r)",x0,y0); + sd(2)=sd(2)-[x0-xo;y0-yo] + sd1=sd + end; +endfunction + +function sd1=fcerc(sd,del) + [lhs,rhs]=argn(0);sd1=[]; + if rhs<=0 then // get + [c1,c2,x1,x2,but]=xgetm(d_circle); + if but==2 then sd1=list();return,end + x=[x1;x2],c=[c1;c2];r=norm(x-c,2); + sd1=list("fcercle",c,r); + d_fcircle(c,r); + elseif rhs==1 then //draw + c=sd(2);r=sd(3) + d_fcircle(c,r); + elseif del=="del" then //erase + c=sd(2);r=sd(3) + d_fcircle(c,r); + elseif del=="mov" then //move + c=sd(2);r=sd(3) + x0=xx(1);y0=xx(2); + [xo,yo]=move_object("d_fcircle(c-[x0-xo;y0-yo],r)",x0,y0); + sd(2)=sd(2)-[x0-xo;y0-yo] + sd1=sd + end; +endfunction + +function [sd1]=fleche(sd,del) + [lhs,rhs]=argn(0);sd1=[] + if rhs<=0 then // get + [oi1,oi2,of1,of2,but]=xgetm(d_arrow); + if but==2 then sd1=list();return,end + o1=[oi1;of1],o2=[oi2;of2]; + [r1,r2]=xgetech() + sz=1/(40*min(abs(r2(3)-r2(1)),abs(r2(4)-r2(2)))) + sd1=list("fleche",o1,o2,sz); + d_arrow(o1,o2,sz); + elseif rhs==1 then //draw + o1=sd(2),o2=sd(3), + sz=-1 + if size(sd)>=4 then sz=sd(4),end + d_arrow(o1,o2,sz); + elseif del=="del" then //erase + o1=sd(2),o2=sd(3), + sz=-1 + if size(sd)>=4 then sz=sd(4),end + d_arrow(o1,o2,sz); + elseif del=="mov" then //move + o1=sd(2),o2=sd(3), + sz=-1 + if size(sd)>=4 then sz=sd(4),end + x0=xx(1);y0=xx(2); + [xo,yo]=move_object("d_arrow(o1-(x0-xo),o2-(y0-yo),sz)",x0,y0); + sd(2)=sd(2)-(x0-xo) + sd(3)=sd(3)-(y0-yo) + sd1=sd + end +endfunction + +function [sd1]=comment(sd,del) + [lhs,rhs]=argn(0),sd1=[]; + if rhs<=0 then // get + [i,z1,z2]=xclick(0);z=[z1;z2]; + com=x_dialog("Enter string"," "); + if com<>[] then + sd1=list("comm",z,com), + xstring(z(1),z(2),com,0,0); + end + elseif rhs==1 then //draw + z=sd(2);com=sd(3); + xstring(z(1),z(2),com,0,0); + elseif del=="del" then //erase + z=sd(2);com=sd(3); + xstring(z(1),z(2),com,0,0); + elseif del=="mov" then //move + z=sd(2);com=sd(3); + [xo,yo]=move_object("xstring(xo,yo,com,0,0)",z(1),z(2)); + sd1=sd;sd1(2)(1)=xo;sd1(2)(2)=yo; + end; +endfunction + +function [sd1]=ligne(sd,del) + // polyline + [lhs,rhs]=argn(0);sd1=[]; + if rhs<=0 then // get + z=xgetpoly(d_seg); + if z==[], return;end; + sd1=list("ligne",z); + xpoly(z(1,:)',z(2,:)',"lines") + elseif rhs==1 then //draw + z=sd(2); + xpoly(z(1,:)',z(2,:)',"lines") + elseif del=="del" then //erase + z=sd(2); + xpoly(z(1,:)',z(2,:)',"lines") + elseif del=="mov" then //move + z=sd(2); + x0=xx(1);y0=xx(2); + [xo,yo]=move_object("xpoly(z(1,:)''-(x0-xo),z(2,:)''-(y0-yo),""lines"")",x0,y0); + sd(2)=[z(1,:)-(x0-xo);z(2,:)-(y0-yo)] + sd1=sd + end; +endfunction + +function [sd1]=fligne(sd,del) + // filled polyline + [lhs,rhs]=argn(0);sd1=[]; + if rhs<=0 then // get + z=xgetpoly(d_seg); + if z==[], return;end; + sd1=list("fligne",z); + xfpoly(z(1,:),z(2,:),1); + elseif rhs==1 then //draw + z=sd(2); + xfpoly(z(1,:),z(2,:),1); + elseif del=="del" then //erase + z=sd(2); + xfpoly(z(1,:),z(2,:),1) + elseif del=="mov" then //move + z=sd(2); + x0=xx(1);y0=xx(2); + [xo,yo]=move_object("xfpoly(z(1,:)-(x0-xo),z(2,:)-(y0-yo),1)",x0,y0); + sd(2)=[z(1,:)-(x0-xo);z(2,:)-(y0-yo)] + sd1=sd + end; +endfunction + +function [sd1]=curve(sd,del) + // smoothed curve + [lhs,rhs]=argn(0);sd1=[]; + if rhs<=0 then ,//get + z=xgetpoly(d_seg); + if z==[], return;end + mm=clearmode();xpoly(z(1,:)',z(2,:)',"lines");modeback(mm) + [x1,k1]=gsort(z(1,:));y1=z(2,k1);z=[x1;y1]; + [n1,n2]=size(z);z=smooth(z(:,n2:-1:1)); + sd1=list("ligne",z); + else + z=sd(2); + end; + xpoly(z(1,:)',z(2,:)',"lines"); + +endfunction + +function [sd1]=points(sd,del) + // polymark + [lhs,rhs]=argn(0);sd1=[]; + if rhs<=0 then //get + z=xgetpoly(d_point); + if z==[], return;end; + sd1=list("point",z); + xpoly(z(1,:)',z(2,:)',"marks"); + elseif rhs==1 then //draw + z=sd(2); + xpoly(z(1,:)',z(2,:)',"marks"); + elseif del=="del" then //erase + z=sd(2); + xpoly(z(1,:)',z(2,:)',"marks"); + elseif del=="mov" then //move + z=sd(2); + x0=xx(1);y0=xx(2); + [xo,yo]=move_object("xpoly(z(1,:)''-(x0-xo),z(2,:)''-(y0-yo),""marks"")",x0,y0); + sd(2)=[z(1,:)-(x0-xo);z(2,:)-(y0-yo)] + sd1=sd + end; +endfunction + +function [sd1]=grclipoff(sd,del) + [lhs,rhs]=argn(0),sd1=[]; + if rhs<=0 then , + sd1=list("clipoff") + end; + // disable clipping + axes = gca(); + axes.clip_state = "off"; +endfunction + +function [sd1]=grclipon(sd,del) + [lhs,rhs]=argn(0),sd1=[]; + if rhs<=0 then , + sd1=list("clipon") + end; + // axes clip + axes = gca(); + axes.clip_state = "clipgrf"; +endfunction + +function []=redraw(sd,s_t) + ksd=size(sd) + plot2d(0,0,[-1],s_t," ",sd(2)); + xset("clipgrf"); + for k=3:ksd, + obj=sd(k); + if size(obj)<>0 then + to=obj(1) + select to, + case "rect" then rect(obj); + case "frect" then frect(obj); + case "cercle" then cerc(obj); + case "fcercle" then fcerc(obj); + case "fleche" then fleche(obj); + case "comm" then comment(obj); + case "ligne" then ligne(obj); + case "fligne" then fligne(obj); + case "point" then points(obj); + case "symbs" then symbs(obj); + case "dashs" then dashs(obj); + case "patts" then patts(obj); + case "clipon" then grclipon(obj); + case "clipoff" then grclipoff(obj); + end + end + end +endfunction + +function [x0,y0,x,y,ibutton]=xgetm(m_m) + // Object aquisition + kpd=driver(); + driver("X11"); + alu=xget("alufunction") + xset("alufunction",6); + // attente du click + [ii,x0,y0]=xclick() + x=x0;y=y0; + // suivit de la souris en attendant le button release + ibutton=-1 + while ( ibutton<0) + // dessin + m_m(x0,y0,x,y); + rep=xgetmouse(0); + ibutton = rep(3) + m_m(x0,y0,x,y) + x=rep(1);y=rep(2); + end + xset("alufunction",alu); + //m_m(x0,y0,x,y) + driver(kpd); +endfunction + +function []=d_xrect(x0,yy0,x,y) + xi=min(x0,x); + w=abs(x0-x); + yi=max(yy0,y); + h=abs(yy0-y); + xrect(xi,yi,w,h); +endfunction + +function []=d_xfrect(x0,yy0,x,y) + xi=min(x0,x); + w=abs(x0-x); + yi=max(yy0,y); + h=abs(yy0-y); + xrects([xi,yi,w,h]',xget("pattern")); +endfunction + +function []=d_circle(c1,c2,x1,x2) + [lhs,rhs]=argn(0); + if rhs==2 then + r=c2;c2=c1(2);c1=c1(1); + xarc(c1-r,c2+r,2*r,2*r,0,64*360); + + else + r=norm([x1-c1;x2-c2],2); + xarc(c1-r,c2+r,2*r,2*r,0,64*360); + end +endfunction + +function []=d_fcircle(c1,c2,x1,x2) + [lhs,rhs]=argn(0); + if rhs==2 then r=c2;c2=c1(2);c1=c1(1); + else + r=norm([x1-c1;x2-c2],2); + end + xfarc(c1-r,c2+r,2*r,2*r,0,64*360); +endfunction + +function d_arrow(c1,c2,x1,x2) + [lhs,rhs]=argn(0); + if rhs<>4 then + sz=x1;x1=c1(2);c1=c1(1);x2=c2(2);c2=c2(1); + else + [r1,r2]=xgetech() + sz=1/(40*min(abs(r2(3)-r2(1)),abs(r2(4)-r2(2)))) + end + xarrows([c1;x1],[c2;x2],sz,-1); +endfunction + +function [z]=xgetpoly(m_m) + // interactive polyline aquisition m_m is + // used to draw between aquisitions + kpd=driver(); + //driver("X11"); + // attente du click + [ii,x0,y0]=xclick(0) + x=x0;y=y0; + z=[x0;y0]; + ibutton=1 + alu=xget("alufunction") + xset("alufunction",6); + while and(ibutton<>[0 3 10]) + ibutton=-1 + while ibutton==-1 + // dessin + m_m(x0,y0,x,y); + rep=xgetmouse(0); + ibutton = rep(3) + m_m(x0,y0,x,y) + x=rep(1);y=rep(2); + end + if and(ibutton<>[0 3 10]) then + m_m(x0,y0,x,y) + z=[z,[x;y]] + x0=x;y0=y; + end + end + xset("alufunction",alu); + + [nn,ll]=size(z); + if ll==1 then z=[];end + driver(kpd); +endfunction + +function []=d_seg(x1,y1,x2,y2) + xpoly([x1,x2],[y1,y2],"lines"); +endfunction + +function []=d_point(x1,y1,x2,y2) + xpoly([x1,x2],[y1,y2],"marks"); + +endfunction + +function [xo,yo]=move_object(inst,xo,yo) + // Object aquisition + xos=xo;yos=yo + kpd=driver(); + alu=xget("alufunction") + xset("alufunction",6); + execstr(inst) //erase + driver("X11"); + // suivi de la souris en attendant le button release + rep=[0 0 -1]; + while rep(3)<0 + execstr(inst) //draw + rep=xgetmouse(0); + execstr(inst) //erase + xo=rep(1);yo=rep(2); + end + if or(rep(3)==[2 5 12]) then + xo=xos;yo=yos, //move canceled + else + xo=rep(1);yo=rep(2); + end + xset("alufunction",alu); + driver(kpd); + execstr(inst) //draw +endfunction diff --git a/modules/graphics/macros/graduate.bin b/modules/graphics/macros/graduate.bin Binary files differnew file mode 100755 index 000000000..e8a82a75e --- /dev/null +++ b/modules/graphics/macros/graduate.bin diff --git a/modules/graphics/macros/graduate.sci b/modules/graphics/macros/graduate.sci new file mode 100755 index 000000000..bdc26c56e --- /dev/null +++ b/modules/graphics/macros/graduate.sci @@ -0,0 +1,158 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 1992-2010 - INRIA - Serge Steer +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [xi,xa,np]=graduate( xmi, xma,n1,n2) + // graduate - axis pretty graduations + //%Syntax + // [xa,xi,np]=graduate( xma, xmi,n1,n2) + // [xa,xi,np]=graduate( xma, xmi) + //%Parameters + // xmi, xma : real scalars + // n1 , n2 : integer scalars default values 3,10 + // xi , xa : real scalars + // np :integer scalar + //%Description + // graduate looks for the mimimum interval [xi,xa] and a number of tics np + // such that: + // xi <= xmi <= xma <= xa + // xa - xi / np = k(10**n) k in [1 3 5] for an integer n + // n1 <= np <= n2 + //%Exemple + // y=0:0.33:145.78 + // clf();plot2d1('enn',0,y) + // [ymn,ymx,np]=graduate(min(y),max(y)) + // rect=[1,ymn,prod(size(y)),ymx]; + // clf();plot2d1('enn',0,y,-1,'011',' ',rect,[10,3,10,np]) + + kadm=[1,2,5];nadm=prod(size(kadm)) + + // test + // ---- + // + [lhs,rhs]=argn(0) + if rhs <2 then + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"), "graduate", 2)); + end + if rhs <4 then + n1=3 + n2=10 + end + if n1 == 0 & n2 == 0 then + k1 = 1 + k2 = 1 + else + k1 = min ( abs(n1) , abs(n2) ) + k1 = max ( 1 , k1 ) + k2 = max ( abs(n1) , abs(n2) ) + end + if xma == xmi then + if xma==0 then + xma=0.1;xmi=-0.1 + else + xma=xma+xmi/10 + xmi=xmi-xmi/10 + end + end + + xx0 = max ( xma , xmi ) + xx1 = min ( xma , xmi ) + del=abs(xx1-xx0) + if abs(xx0-xx1)<=1d-6*max(xx0,xx1) then + xa = xma + xi = xmi + np=1 + return + end + + // + // boucle sur les pas possibles + // ---------------------------- + // + for npi = k1:k2 + + // + // recherche de l'intervalle [ x1 , x0 ] tel que : + // x1 < xmi < xma < x0 + // x0 - x1 / npi = k.10**n k = 1,.,9 n entier + // + // + // recherche du pas + // ---------------- + // il est compris entre 10**ipa-1 et 10**ipa + // + if xx0*xx1<0 then + pas=max(abs([xx0 xx1])/npi) + else + pas = (xx0-xx1)/npi + end + ipa = int(log(pas)/log(10)) + if pas<1 then ipa = ipa - 1,end + + pa2 = 10**ipa + // + ik=find(pas<=kadm*pa2) + if ik==[] then + pa2 = 10.0d+00 * pa2 + ipa = kadm(1) + pa1=ipa*pa2 + else + ipa=kadm(ik(1)) + pa1=ipa*pa2 + end + while %t + // + // recherche des extremites + // ------------------------ + // + if xx1*xx0<0 then + x1 = xx1/pa1 + np1=int(x1) + x1=np1*pa1 + if x1>xx1 then x1=x1-pa1,end + else + x1 = xx1/pa2 + np1=int(x1) + x1=np1*pa2 + if x1>xx1 then x1=x1-pa1,end + end + x0 = x1+npi*pa1 + + + // + // test + // ---- + // + if x0<xx0 then + ik=find(kadm==ipa) + if ik<nadm then + ipa = kadm(ik+1) + pa1 = ipa * pa2 + else + ipa = kadm(1) + pa1 = 10.0d+00 * pa2 + pa2 = pa1 + end + else + break + end + end + if npi==k1 then + xl=x0-x1 + xa=x0 + xi=x1 + np=k1 + else + if (x0-x1)< xl then + np = npi + xl = x0 - x1 + xa = x0 + xi = x1 + end + end + end +endfunction diff --git a/modules/graphics/macros/graycolormap.bin b/modules/graphics/macros/graycolormap.bin Binary files differnew file mode 100755 index 000000000..3a0f22aa4 --- /dev/null +++ b/modules/graphics/macros/graycolormap.bin diff --git a/modules/graphics/macros/graycolormap.sci b/modules/graphics/macros/graycolormap.sci new file mode 100755 index 000000000..a2ff7f2a4 --- /dev/null +++ b/modules/graphics/macros/graycolormap.sci @@ -0,0 +1,32 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +function cmap = graycolormap(varargin) + //graycmap linear gray-scale color map. + //r=g=b + + // Check number of input argument + if size(varargin)<>1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "graycolormap", 1)); + end + n=varargin(1); + + // Check type of input argument + // Check if input argument is real + if typeof(n)<>"constant" | ~isreal(n) then + error(msprintf(gettext("%s: Wrong type for input argument #%d: a real scalar expected.\n"), "graycolormap", 1)); + end + + // Check size of input argument + if size(n,"*")<>1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: a real scalar expected.\n"), "graycolormap", 1)); + end + + cmap=((0:n-1)'/max(n-1,1))*[1 1 1]; +endfunction diff --git a/modules/graphics/macros/graypolarplot.bin b/modules/graphics/macros/graypolarplot.bin Binary files differnew file mode 100755 index 000000000..7a16b867b --- /dev/null +++ b/modules/graphics/macros/graypolarplot.bin diff --git a/modules/graphics/macros/graypolarplot.sci b/modules/graphics/macros/graypolarplot.sci new file mode 100755 index 000000000..328ce7119 --- /dev/null +++ b/modules/graphics/macros/graypolarplot.sci @@ -0,0 +1,197 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// Copyright (C) Samuel GOUGEON - 2013 : vectorization, code style +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +function graypolarplot(theta,rho,z,varargin) + [lhs,rhs] = argn(0) + if rhs<=0 then + rho = 1:0.2:4 + theta = (0:0.02:1)*2*%pi + z = 30+round(theta'*(1+rho.^2)) + clf() + f = gcf() + f.color_map = hotcolormap(128) + f.background= 128 + a = gca() + a.background = 128 + a.foreground = 1 + graypolarplot(theta,rho,z) + return + end + + if rhs<3 then + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"), "graypolarplot", 3)); + end + + + R = max(rho) + nv = size(varargin) + if nv>=1 + strf = varargin(2) + else + strf = "030" + end + if nv>=2 + rect = varargin(4) + else + rect = [-R -R R R]*1.1 + end + + // drawlater + fig = gcf(); + immediate_drawing = fig.immediate_drawing; + fig.immediate_drawing = "off"; + + axes = gca(); + axes.data_bounds = [rect(1), rect(2); rect(3), rect(4)]; + axes.clip_state = "clipgrf"; + + drawGrayplot(theta,rho,z); + + objectList = gce(); // get all the created objects to glue them at the end. + + axes.isoview = "on"; + axes.box = "off"; + axes.axes_visible = ["off","off","off"]; + axes.x_label.text = ""; + axes.y_label.text = ""; + axes.z_label.text = ""; + + step = R/5 + r = step; + dr = 0.02*r; + for k = 1:4 + xarc(-r, r, 2*r, 2*r, 0, 360*64) + objectList($ + 1) = gce(); + arc = gce(); + arc.line_style = 3; + xstring((r+dr)*cos(5*%pi/12),(r+dr)*sin(5*%pi/12), string(round(10*r)/10)) + objectList($ + 1) = gce(); + r=r+step + end + xarc(-r,r,2*r,2*r,0,360*64) + objectList($ + 1) = gce(); + xstring((r+dr)*cos(5*%pi/12),(r+dr)*sin(5*%pi/12), string(round(10*r)/10)) + objectList($ + 1) = gce(); + + rect = xstringl(0,0,"360"); + w = rect(3); + h = rect(4); + r = R*1.05 + for k = 0:11 + xsegs([0 ; R*cos(k*(%pi/6))],[0 ; R*sin(k*(%pi/6))]) + objectList($ + 1) = gce(); + arc = gce(); + arc.line_style = 3; + xstring((r+w/2)*cos(k*(%pi/6))-w/2, (r+h/2)*sin(k*(%pi/6))-h/2,string(k*30)) + objectList($ + 1) = gce(); + end + + // glue all the created objects + glue(objectList); + + // drawnow + fig.immediate_drawing = immediate_drawing; + +endfunction +// --------------------------------------------------------------------------- + +function [x,y] = polar2Cart(rho, theta) + x = rho * cos(theta); + y = rho * sin(theta); +endfunction +// --------------------------------------------------------------------------- + +function [nbDecomp] = computeNeededDecompos(theta) + // Compute the needed decomposition for each patch + + // minimal decompostion for each ring + nbFactesPerRingMin = 512; + + nbDecomp = ceil(nbFactesPerRingMin / size(theta, "*")); + +endfunction +// --------------------------------------------------------------------------- +function drawGrayplot(theta, rho, z) + // draw only the colored part of the grayplot + + // the aim of the function is to draw a set of curved facets + // In previous versions, it used arcs to perform this. + // However, since arcs are drawn from the origin to the outside + // there were overlapping and cause Z fighting in 3D. + // Consequenlty we now decompose each curved facet into a set of rectangular + // facets. + + nbRho = size(rho,"*"); + nbTheta = size(theta,"*"); + + nbDecomposition = computeNeededDecompos(theta); // number of approximation facets + + // first step decompose theta in smaller intervals + // Actually compute cosTheta and sinTheta for speed [vectorized] + t = (1:nbDecomposition) / nbDecomposition + [I,T] = meshgrid(theta, t) + interpolatedData = T(:,2:$).*I(:,2:$) + (1-T(:,1:$-1)).*I(:,1:$-1) + cosTheta = [cos(theta(1)) cos(interpolatedData(:))' ] + sinTheta = [sin(theta(1)) sin(interpolatedData(:))' ] + + // compute the 4xnbFacets matrices for plot 3d + // + // get the 4 corners of a facet + // (we minimize the memory footprint, since big transient and final matrices + // are built) + Jmax = size(sinTheta,2) + + [R, C] = meshgrid(rho, cosTheta) + R = R.*C + clear C + corner = R(1:Jmax-1,1:nbRho-1); xCoords = corner(:)' + corner = R(2:Jmax ,1:nbRho-1); xCoords(2,:) = corner(:)' + corner = R(2:Jmax ,2:nbRho); xCoords(3,:) = corner(:)' + corner = R(1:Jmax-1,2:nbRho); xCoords(4,:) = corner(:)' + + [R, S] = meshgrid(rho, sinTheta) + R = R.*S + clear S + corner = R(1:Jmax-1,1:nbRho-1); yCoords = corner(:)' + corner = R(2:Jmax ,1:nbRho-1); yCoords(2,:) = corner(:)' + corner = R(2:Jmax ,2:nbRho); yCoords(3,:) = corner(:)' + corner = R(1:Jmax-1,2:nbRho); yCoords(4,:) = corner(:)' + clear R + + // color is the same for each nbDecomposition facets + // keep the 4 outside colors of the patch + // to be able to switch between average or matlab color. + i = 1:nbRho + j = (0:Jmax-1)/ nbDecomposition + 1 + [I, J] = meshgrid(i,j) + clear I + corner = z(J(1:$-1,1) , 1:$-1); colors = corner(:)' + corner = z(J(1:$-1,1)+1, 1:$-1); colors(2,:) = corner(:)' + corner = z(J(1:$-1,1)+1, 2:$); colors(3,:) = corner(:)' + corner = z(J(1:$-1,1) , 2:$); colors(4,:) = corner(:)' + clear J corner + + // flat plot + nbQuadFacets = (nbRho - 1) * (Jmax - 1); + zCoords = zeros(4, nbQuadFacets); + + // disable line draing and hidden color + plot3d(xCoords, yCoords, list(zCoords,colors)); + gPlot = gce(); + gPlot.color_mode = -1; // no wireframe + gPlot.hiddencolor = 0; // no hidden color + gPlot.color_flag = 2; // average color on each facets + + // restore 2d view + axes = gca(); + axes.view = "2d"; + +endfunction diff --git a/modules/graphics/macros/hist3d.bin b/modules/graphics/macros/hist3d.bin Binary files differnew file mode 100755 index 000000000..3c8584b03 --- /dev/null +++ b/modules/graphics/macros/hist3d.bin diff --git a/modules/graphics/macros/hist3d.sci b/modules/graphics/macros/hist3d.sci new file mode 100755 index 000000000..11e1e366f --- /dev/null +++ b/modules/graphics/macros/hist3d.sci @@ -0,0 +1,95 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// Copyright (C) 2012 - Scilab Enterprises - Adeline CARNIS +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +function hist3d(f,theta,alpha,leg,flags,ebox) + //! + nep=8 + + if ~isdef("theta","local") then theta = 35; end; + if ~isdef("alpha","local") then alpha = 45; end; + if ~isdef("leg","local") then leg = "X@Y@Z"; end; + if ~isdef("flags","local") then flags = [2 1 4]; end; + + def=list(theta,alpha,leg,flags); + [lhs,rhs]=argn(0) + if rhs<=0 then //demo + towns = ["Agen" "Bastia" "Chamonix" "Cognac" "Hyères" "Le Mans" "Le Puy" .. + "Lille" "Lorient" "Mende" ] + months = [_("January") _("Febuary") _("March") _("April") _("May") _("June").. + _("July") _("August") _("September") _("October") _("November") .. + _("December") _("Average") ] + months = "$\scalebox{1.3}{\rotatebox{90}{\mbox{" + months + "}}}$" + + T = [5.7 5.9 9.8 12.1 16.0 19.4 21.8 21.5 18.4 14.7 9.3 5.2 13.5 + 9.4 9.4 11.2 13.3 17.3 21.0 24.1 24.5 21.2 17.6 13.3 10.4 16.1 + -2.3 -0.8 3.0 6.6 11.2 14.4 15.5 15.9 12.5 8.6 2.7 -1.6 7.2 + 6.1 5.9 9.7 11.9 15.8 19.0 21.1 20.9 17.9 14.4 9.3 5.6 13.3 + 8.7 8.9 11.0 13.1 16.7 20.3 23.2 23.3 20.2 16.8 12.6 9.8 15.4 + 5.0 5.5 8.3 10.7 14.5 17.8 19.9 19.7 18.5 12.8 8.1 5.4 12.8 + 1.0 1.3 4.8 7.2 11.3 14.3 17.6 17.1 13.5 9.9 4.6 1.8 8.8 + 3.7 4.1 7.1 9.8 13.5 16.2 18.6 18.5 15.5 11.7 7.2 4.2 10.8 + 6.6 6.7 8.6 10.3 13.6 16.2 18.1 18.0 16.0 13.0 9.4 7.0 12.0 + 0.6 1.3 3.7 5.5 9.6 13.1 16.2 16.0 12.8 8.8 3.8 1.8 7.8 + ]; + hist3d(T) + ax = gca() + ax.y_ticks = tlist(["ticks" "locations" "labels"], (0:12)+0.5, months) + ax.x_ticks = tlist(["ticks" "locations" "labels"], (0:9)+0.5, towns) + zlabel("T [°C]") + xtitle(_("Average monthly temperatures in french cities"),"","") + ax.title.font_size = 3 + ax.rotation_angles = [28 19] + return; + end + if typeof(f)=="list" then + [f,x,y]=f(1:3); + sx=prod(size(x)); + sy=prod(size(y)); + if [sx-1,sy-1]<>size(f) then + write(%io(2),"f: Incompatible length "); + return; + end + dx=(x(2)-x(1))/nep; + dy=(y(2)-y(1))/nep; + bnds=[x(1) x($), y(1) y($),min(0,min(f)) max(0,max(f))] + x=(x(1:sx-1)+x(2:sx))/2; + y=(y(1:sy-1)+y(2:sy))/2; + [nl,nc]=size(f); + else + [nl,nc]=size(f); + x=(1:nl)-(0.5)*ones(1,nl); + y=(1:nc)-(0.5)*ones(1,nc); + dx=1/nep; dy=1/nep; + bnds=[0 nl,0 nc,min(0,min(f)) max(0,max(f))] + end + x=x.*.[1,1] + dx*ones(x).*.[0,1] - dx*ones(x).*.[1,0]; + y=y.*.[1,1] + dy*ones(y).*.[0,1] - dy*ones(y).*.[1,0]; + a=[0;0;1;1] + b=[0;1;1;0] + c=[0;0;0;0] + d=[1;1;1;1] + ix=[b,b,a,a,c,d]; + iy=[a,a,c,d,b,b]; + indx=ones(1,nc) .*. (ones(1,nl).*.ix +(1:2:2*nl-1).*.ones(ix)); + iy=matrix(iy,24,1); + //indy=(ones(1,nl).*.iy+(1:2:2*nl-1).*.ones(iy)) .*. ones(1,nc); + indy=(ones(1,nc).*.iy+(1:2:2*nc-1).*.ones(iy)) .*. ones(1,nl); + indy=matrix(indy,4,6*nc*nl); + [nnl,nnc]=size(indx); + + xx=matrix(x(matrix(indx,1,nnl*nnc)),nnl,nnc); + yy=matrix(y(matrix(indy,1,nnl*nnc)),nnl,nnc); + zz=matrix(f,1,nl*nc).*.[c,d,b,b,a,a]; + + if ~isdef("ebox","local") then ebox = bnds; else "ebox = ebox"; end; + plot3d(xx,yy,zz,def(1),def(2),def(3),def(4),ebox) + +endfunction + diff --git a/modules/graphics/macros/histplot.bin b/modules/graphics/macros/histplot.bin Binary files differnew file mode 100755 index 000000000..c598c5296 --- /dev/null +++ b/modules/graphics/macros/histplot.bin diff --git a/modules/graphics/macros/histplot.sci b/modules/graphics/macros/histplot.sci new file mode 100755 index 000000000..88ac339b4 --- /dev/null +++ b/modules/graphics/macros/histplot.sci @@ -0,0 +1,123 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// Copyright (C) Bruno Pincon +// Copyright (C) 2010 - Samuel Gougeon +// Copyright (C) 2012 - Scilab Enterprises - Adeline CARNIS +// Copyright (C) 2013 - A. Khorshidi (new option) +// Copyright (C) 2013 - Scilab Enterpriss - Paul Bignier: added output +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +function [y, ind] = histplot(n,data,style,strf,leg,rect,nax,logflag,frameflag,axesflag,normalization,polygon) + // histplot(n,data,<opt_arg_seq>) + // draws histogram of entries in data put into n classes + // + // histplot(xi,data,<opt_arg_seq>) + // generates the histogram of entries in data put into classes + // [xi(1),xi(2)], (xi(k) xi(k+1)], k=2,..,n. + // xi's are assumed st. increasing (this point is verified now). + // + // optional args: + // 1/ the same than for a plot2d: + // style,strf,leg,rect,nax,logflag,frameflag,axesflag + // 2/ normalization flag (default value %t). When true the + // histogram is normalized so that to approach a density: + // xmax + // / + // | h(x) dx = 1 (true if xmin <= min(data) and max(data) <= xmax) + // / + // xmin + // + // Example : enter histplot() + // + // modifs to use dsearch (Bruno Pincon 10/12/2001) + // others modifs from Bruno (feb 2005): + // - may be a cleaner and shorter way to deal with optional arg ? + // - now the histgram is drawn using only one polyline + // (so properties (color, thickness,...) are easier + // to change with new graphics). + // - removed computation of nax and rect if they are not + // passed (let plot2d doing it) + // - modify a little the demo + // - add some checking on n|x and data + // + [lhs, rhs] = argn() + + y = []; + ind = []; + if rhs == 0 then // demo + histplot([-4.5:0.25:4.5],rand(1,20000,"n"),style=2,axesflag=1,.. + frameflag=1,rect=[-4.5 0 4.5 0.47]); + deff("[y]=f(x)","y=exp(-x.*x/2)/sqrt(2*%pi);"); + x=-4.5:0.125:4.5; + x=x'; + plot2d(x,f(x),26,"000"); + titre= gettext("histplot() : (normalized) histogram plot"); + xtitle(titre,"C (Classes)","N(C) / (Nmax length(C))"); // Not clear + legend(gettext("Gaussian random sample histogram"), .. + gettext("Exact gaussian density")); + return + end + + if rhs < 2 + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"),"histplot",2)); + end + + if type(n) ~= 1 | ~isreal(n) + error(msprintf(gettext("%s: Wrong type for input argument #%d: Real expected.\n"),"histplot",1)); + elseif type(data) ~= 1 | ~isreal(data) + error(msprintf(gettext("%s: Wrong type for input argument #%d: Real expected.\n"),"histplot",2)); + end + + // This is the only specific optional argument for histplot + if ~exists("normalization","local") then, normalization=%t,end + if ~exists("polygon","local") then, polygon=%f,end + + // Now parse optional arguments to be sent to plot2d + opt_arg_seq = [] + opt_arg_list = ["style","strf","leg","rect","nax","logflag","frameflag","axesflag"] + for opt_arg = opt_arg_list + if exists(opt_arg,"local") then + opt_arg_seq = opt_arg_seq +","+ opt_arg + "=" + opt_arg + end + end + + [y, ind] = histc(n, data, normalization); + + if length(n) == 1 then // The number of classes is provided + x = linspace(min(data), max(data), n+1); // Class boundary + else // The classes are provided + x = matrix(n,1,-1); // Force row form + n = length(x)-1 + end + + if polygon then + xmid=(x(1:$-1)+x(2:$))/2;... + xp=[x(1)-(x(2)-x(1))/2 xmid x($)+(x($)-x($-1))/2];... + yp=[0 y 0]; + end // new lines + + // now form the polyline + // X = [x1 x1 x2 x2 x2 x3 x3 x3 x4 ... xn xn+1 xn+1]' + // Y = [0 y1 y1 0 y2 y2 0 y3 y3 ... 0 yn yn 0 ]' + X = [x(1);x(1);matrix([1;1;1]*x(2:n),-1,1);x(n+1);x(n+1)] + // BUG#1885 + // We start the histplot line to %eps rather than 0 + // So when switching to logarithmic mode we do not fall + // in log(0) special behaviour. + Y = [matrix([%eps;1;1]*y,-1,1);%eps] + + if opt_arg_seq == [] then + plot2d(X,Y) + if polygon then plot(xp,yp,"b-o"), end // new line + else + execstr("plot2d(X,Y"+opt_arg_seq+")") + if polygon then plot(xp,yp,"r-o"), end // new line + end + +endfunction diff --git a/modules/graphics/macros/hotcolormap.bin b/modules/graphics/macros/hotcolormap.bin Binary files differnew file mode 100755 index 000000000..69b74e678 --- /dev/null +++ b/modules/graphics/macros/hotcolormap.bin diff --git a/modules/graphics/macros/hotcolormap.sci b/modules/graphics/macros/hotcolormap.sci new file mode 100755 index 000000000..f433f98c4 --- /dev/null +++ b/modules/graphics/macros/hotcolormap.sci @@ -0,0 +1,38 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +function cmap = hotcolormap(varargin) + //graycmap yellow to red color map. + + // Check number of input argument + if size(varargin)<>1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "hotcolormap", 1)); + end + n=varargin(1); + + // Check type of input argument + // Check if input argument is real + if typeof(n)<>"constant" | ~isreal(n) then + error(msprintf(gettext("%s: Wrong type for input argument #%d: a real scalar expected.\n"), "hotcolormap", 1)); + end + + // Check size of input argument + if size(n,"*")<>1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: a real scalar expected.\n"), "hotcolormap", 1)); + end + + n1=fix(3/8*n); + n2=n1 + n3=n-(n1+n2) + // + cmap=[(1:n1)'/n1 zeros(n1,1) zeros(n1,1); + ones(n2,1) (1:n2)'/n2 zeros(n2,1); + ones(n3,1) ones(n3,1) (1:n3)'/(n3)] + +endfunction diff --git a/modules/graphics/macros/hsv2rgb.bin b/modules/graphics/macros/hsv2rgb.bin Binary files differnew file mode 100755 index 000000000..7c9b564ef --- /dev/null +++ b/modules/graphics/macros/hsv2rgb.bin diff --git a/modules/graphics/macros/hsv2rgb.sci b/modules/graphics/macros/hsv2rgb.sci new file mode 100755 index 000000000..b88eabb99 --- /dev/null +++ b/modules/graphics/macros/hsv2rgb.sci @@ -0,0 +1,41 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [r,g,b]=hsv2rgb(h,s,v) + + if and(argn(2)<>[1 3]) then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d or %d expected.\n"), "hsv2rgb", 1, 3)); + end + + if argn(2)==1 then + v=h(:,3);s=h(:,2);h=h(:,1) + else + h = h(:);s = s(:);v = v(:) + end + + h=6*h + k=fix(h-6*%eps) + f=h-k + + t=1-s + n=1-s.*f + p=1-s.*(1-f) + e=ones(h) + + K=bool2s(k*ones(1,6)==ones(k)*(0:5)) + r=sum(K.*[e n t t p e],2) + g=sum(K.*[p e e n t t],2) + b=sum(K.*[t t p e e n],2) + f=v ./ max([r(:);g(:);b(:)]) + + if argn(1)==1 then + r=[f.*r,f.*g,f.*b] + else + r=f.*r;g=f.*g;b=f.*b + end +endfunction diff --git a/modules/graphics/macros/hsvcolormap.bin b/modules/graphics/macros/hsvcolormap.bin Binary files differnew file mode 100755 index 000000000..9d70b5886 --- /dev/null +++ b/modules/graphics/macros/hsvcolormap.bin diff --git a/modules/graphics/macros/hsvcolormap.sci b/modules/graphics/macros/hsvcolormap.sci new file mode 100755 index 000000000..557865240 --- /dev/null +++ b/modules/graphics/macros/hsvcolormap.sci @@ -0,0 +1,33 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function c=hsvcolormap(varargin) + + // Check number of input argument + if size(varargin)<>1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "hsvcolormap", 1)); + end + n=varargin(1); + + // Check type of input argument + // Check if input argument is real + if typeof(n)<>"constant" | ~isreal(n) then + error(msprintf(gettext("%s: Wrong type for input argument #%d: a real scalar expected.\n"), "hsvcolormap", 1)); + end + + // Check size of input argument + if size(n,"*")<>1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: a real scalar expected.\n"), "hsvcolormap", 1)); + end + h = (0:n-1)'/max(n,1); + if isempty(h) then + c = []; + else + c = hsv2rgb([h ones(n,2)]); + end +endfunction diff --git a/modules/graphics/macros/isoview.bin b/modules/graphics/macros/isoview.bin Binary files differnew file mode 100755 index 000000000..9d02e475c --- /dev/null +++ b/modules/graphics/macros/isoview.bin diff --git a/modules/graphics/macros/isoview.sci b/modules/graphics/macros/isoview.sci new file mode 100755 index 000000000..2d21171b9 --- /dev/null +++ b/modules/graphics/macros/isoview.sci @@ -0,0 +1,33 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// Copyright (C) 2010 - DIGITEO - Pierre Lando <pierre.lando@scilab.org> +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function []=isoview(varargin) + // setting default plotting to be isoview + + if size(varargin)<>4 then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "isoview", 4)); + end + + for i=1:4 do + if type(varargin(i)) <> 1 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: A real expected.\n"), "isoview", i)); + end + end; + + xmin = varargin(1); + xmax = varargin(2); + ymin = varargin(3); + ymax = varargin(4); + + a = gca(); + a.isoview = "on"; + a.data_bounds = [xmin, ymin ; xmax, ymax]; + a.clip_state = "clipgrf"; + +endfunction diff --git a/modules/graphics/macros/jetcolormap.bin b/modules/graphics/macros/jetcolormap.bin Binary files differnew file mode 100755 index 000000000..de521a929 --- /dev/null +++ b/modules/graphics/macros/jetcolormap.bin diff --git a/modules/graphics/macros/jetcolormap.sci b/modules/graphics/macros/jetcolormap.sci new file mode 100755 index 000000000..705c7eee1 --- /dev/null +++ b/modules/graphics/macros/jetcolormap.sci @@ -0,0 +1,49 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [cmap] = jetcolormap(varargin) + // PURPOSE + // to get the usual classic colormap which goes from + // blue - lightblue - green - yellow - orange then red + // AUTHOR + // Bruno Pincon + // + + // Check number of input argument + if size(varargin)<>1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "jetcolormap", 1)); + end + n=varargin(1); + + // Check type of input argument + // Check if input argument is real + if typeof(n)<>"constant" | ~isreal(n) then + error(msprintf(gettext("%s: Wrong type for input argument #%d: a real scalar expected.\n"), "jetcolormap", 1)); + end + + // Check size of input argument + if size(n,"*")<>1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: a real scalar expected.\n"), "jetcolormap", 1)); + end + + if n==0 then + cmap = []; + return + end + + r = [0.000 0.125 0.375 0.625 0.875 1.000 ; 0.000 0.000 0.000 1.000 1.000 0.500] + g = [0.000 0.125 0.375 0.625 0.875 1.000 ; 0.000 0.000 1.000 1.000 0.000 0.000] + b = [0.000 0.125 0.375 0.625 0.875 1.000 ; 0.500 1.000 1.000 0.000 0.000 0.000] + + d = 0.5/max(n,1); + x = linspace(d,1-d, n) + cmap = [ interpln(r, x);... + interpln(g, x);... + interpln(b, x) ]'; + cmap = min(1, max(0 , cmap)) // normaly not necessary +endfunction diff --git a/modules/graphics/macros/legend.bin b/modules/graphics/macros/legend.bin Binary files differnew file mode 100755 index 000000000..b1fe1816f --- /dev/null +++ b/modules/graphics/macros/legend.bin diff --git a/modules/graphics/macros/legend.sci b/modules/graphics/macros/legend.sci new file mode 100755 index 000000000..b58ee6081 --- /dev/null +++ b/modules/graphics/macros/legend.sci @@ -0,0 +1,161 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007-2010 - INRIA - Serge Steer <serge.steer@inria.fr> +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function c=legend(varargin) + + if size(varargin)<1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"), "legend", 1)); + end + + options_names=["in_upper_right";"in_upper_left";"in_lower_left"; + "in_lower_right";"by_coordinates";"out_upper_right"; + "out_upper_left";"out_lower_left";"out_lower_right"; + "upper_caption";"lower_caption"]; + + options_codes=[1;2;3; + 4;5;-1; + -2;-3;-4; + -5;-6]; + f = gcf(); + vis = f.immediate_drawing; + vis_on = vis == "on"; // current figure draw status (to decide if drawnow or standby) + narg = size(varargin); + k0 = 1; + H = []; + leg = []; + Acur = gca(); + A = Acur; + kopt = 1; + with_box = %T; + coords=[]; + + if type(varargin(narg))==4 then + with_box=varargin(narg) + narg=narg-1 + end + if type(varargin(narg))==1 then + pos=varargin(narg) + if size(pos,"*")==2 then //position given by coordinates + coords=pos; + narg=narg-1 + elseif size(pos,"*")==1 then //position given by code + if or(pos==options_codes) then + kopt=find(pos==options_codes) + narg=narg-1 + else + error(msprintf(_("%s: Wrong value for input argument #%d: Must be in the set {%s}.\n"),.. + "legend",narg,strcat(string(options_codes),","))); + end + else + error(msprintf(_("%s: Wrong size for input argument #%d."),"legend",narg)); + end + elseif type(varargin(narg))==10 then + k=find(varargin(narg)==options_names) + if ~isempty(k) then + kopt=k + narg=narg-1 + end + end + + while type(varargin(k0))==9 then //a handle that could be an Axes, Agreg. or Polyline handle. + tmpH=varargin(k0) + if tmpH.type=="Axes" then + A = tmpH; + end + tmpH=tmpH($:-1:1); + H=[getvalidchildren(tmpH);H]; + k0 = k0+1; + end + + if H==[] then + //walk subtree to get all proper children + H=getvalidchildren(A) + end + + if H==[] then + error(msprintf(_("%s: No ''%s'' handle found.\n"), "legend","Polyline")); + end + + //get all labels + for k=k0:narg + if type(varargin(k))<>10 then + break; + end + vk=varargin(k) + leg=[leg; vk(:)] + end + nleg=size(leg,"*") + + + //upper left coordinates + if ~isempty(coords) then + bnds=get(gca(),"axes_bounds"); + as=get(gcf(),"axes_size"); + + [x1,y1,rect]=xchange(coords(1),coords(2),"f2i") + x1=x1-as(1)*bnds(1) + y1=y1-as(2)*bnds(2) + pos=[x1/(as(1)*bnds(3)), y1/(as(2)*bnds(4))] + kopt=5 + elseif kopt==5 then + pos=[] + end + // the number of labels might be lower than the number of polylines + nbLeg = min(size(H, "*"), size(leg, "*")); + first_handle=size(H, "*")-nbLeg+1; + H = H(first_handle:size(H, "*")); + leg = leg(1:nbLeg); + + + drawlater() + c=captions(H,leg) + if options_codes(kopt)<0 then + c.background=f.background + else + c.background=Acur.background + end + if with_box then c.line_mode="on",else c.line_mode="off",end + c.legend_location=options_names(kopt) + if kopt==5 then + if pos<>[] then + c.position=pos; + else + if vis_on then drawnow(); end // draw if figure status allows it (otherwise standby) + bnds=get(gca(),"axes_bounds"); + as=get(gcf(),"axes_size"); + while %t + rep=xgetmouse() + if rep(3)<> -1 then break,end + [x1,y1,rect]=xchange(rep(1),rep(2),"f2i") + x1=x1-as(1)*bnds(1) + y1=y1-as(2)*bnds(2) + pos=[x1/(as(1)*bnds(3)), y1/(as(2)*bnds(4))] + c.position=pos; + end + end + end + if vis_on then drawnow(); end // draw if figure status allows it (otherwise standbye) +endfunction + +function h=getvalidchildren(A) + h=[] + for k=1:size(A,"*") + a=A(k) + select a.type + case "Polyline" then + h=[h;a] + case "Axes" + ax=a.children + h=[h;getvalidchildren(ax)] + case "Compound" + for k=1:1:size(a.children,"*") + h=[h;getvalidchildren(a.children(k))] + end + end + end +endfunction diff --git a/modules/graphics/macros/legends.bin b/modules/graphics/macros/legends.bin Binary files differnew file mode 100755 index 000000000..e70c7c119 --- /dev/null +++ b/modules/graphics/macros/legends.bin diff --git a/modules/graphics/macros/legends.sci b/modules/graphics/macros/legends.sci new file mode 100755 index 000000000..15afad5c0 --- /dev/null +++ b/modules/graphics/macros/legends.sci @@ -0,0 +1,204 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +function legends(leg, style, opt, with_box, font_size ) + // + // PURPOSE + // draw legends on a plot + // AUTHORS + // F. Delebecque + slight modif from B. Pincon + // modified again by Eric Dubois and Jean-Baptiste Silvy 18/01/07 + + rhs=argn(2) + + if rhs < 2 then + error(msprintf(gettext("%s: Wrong number of input arguments: At least %d expected.\n"), "legends", 2)); + end + if type(leg) ~= 10 then, + error(msprintf(gettext("%s: Wrong type for input argument #%d: String array expected.\n"), "legends", 1)); + end + nleg=size(leg,"*") + if type(style) ~= 1 & type(style) ~= 9 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: Real array or graphic handle array expected.\n"), "legends", 2)); + end + if ~exists("opt","local") then + opt=5 + elseif typeof(opt)=="string" then + select opt + case "ur" then, opt=1, + case "ul" then, opt=2, + case "ll" then, opt=3, + case "lr" then, opt=4, + case "?" then, opt=5, + case "below" then, opt=6, + else + error(msprintf(gettext("%s: Wrong value for input argument #%d: ''%s'', ''%s'', ''%s'', ''%s'', ''%s'' or ''%s'' expected.\n"),"legends", 3, "ur", "ul", "ll", "lr", "?", "below")); + end + end + if ~exists("with_box","local") then, with_box=%t, end + if ~exists("font_size","local") then + font_size = 1 ; // default size + end + + ns=size(style) + if ns ~= [2 1] & or(ns==1) then, style=matrix(style,1,-1),end + ns=size(style,2) + + //preserve current graphic context + f=gcf() + vis=f.immediate_drawing; + old_ax=gca(), + arect=old_ax.margins; + r1=old_ax.axes_bounds; + + //create small axes on the top left corner (the axes is chosen very + //small to avoid it can be selected for rotation in new graphic mode + //case (a little tricky) + xsetech(wrect=[r1(1),r1(2),r1(3)/1000,r1(4)/1000],frect=[0 0 1,1]/1000,arect=[0,0,0,0]) + xmin=arect(1);xmax=1-arect(2);ymin=-1+arect(4);ymax=-arect(3); + cur_ax=gca(), + cur_ax.clip_state="off"; + + dy = ymax-ymin ; + yOffset = dy / 60 ; + + drx=(xmax-xmin)/20 //length of the line + xOffset = drx/5 ; + + bbx=[] + for k=1:nleg + r = stringbox( leg(k), 0, 0, 0, old_ax.font_style, font_size ) ; + bbx=[bbx;r(1,3) - r(1,1) , r(2,3) - r(2,1)]; //[width height] + end + + height = sum(bbx(:,2)) + width = max(bbx(:,1)) + drx * 1.6 ; // 1.6 * drx = 1.2 * drx + 2 * drx / 5 ; + + //upper left coordinates + if size(opt,"*")>1 then + // fix for bug 1237 (Bruno 9 march 2005) + if old_ax.tight_limits == "on" then // data_bounds' corresponds to the old frec + r2 = old_ax.data_bounds' + else + r2 = [old_ax.x_ticks.locations(1),old_ax.y_ticks.locations(1),... + old_ax.x_ticks.locations($),old_ax.y_ticks.locations($)] + end + pos(1) = xmin + ((opt(1)-r2(1))/(r2(3)-r2(1)))*(1-arect(1)-arect(2)) + pos(2) = ymin + ((opt(2)-r2(2))/(r2(4)-r2(2)))*(1-arect(3)-arect(4)) + // end bugfix + opt=0 ; + elseif opt<1 | opt>6 then + error(msprintf(gettext("%s: Wrong value for input argument %s: Must be in the interval [%d, %d]."),"legends", "opt", 1, 6)); // if opt is entered by a string by the user it is in the range + end + select opt + case 1 then + pos=[xmax-width-xOffset,ymax-yOffset] + case 2 then + pos=[xmin+xOffset,ymax-yOffset] + case 3 then + pos=[xmin+xOffset,ymin+height+yOffset] + case 4 then + pos=[xmax-width-xOffset,ymin+height+yOffset] + case 5 then + rect=dragrect([xmax-width-xOffset,ymax-yOffset,width,height]) + pos=rect(1:2) + case 6 then + // decrease the size of the graph to leave place for the legend + old_ax.margins=[xmin;arect(2);arect(4);arect(3)+height + 2 * yOffset ] + pos=[(xmin+xmax)/2-width/2, ymin + height - 2 * yOffset ] + end + + x=pos(1)+xOffset + y=pos(2) + + f.immediate_drawing = "off", + a=gca() ; + a.foreground=old_ax.foreground ; + a.background=old_ax.background ; + a.font_color=old_ax.font_color ; + a.font_size =old_ax.font_size ; + a.font_style=old_ax.font_style ; + + R=[] + if with_box then + xpol = [pos(1), pos(1)+width, pos(1)+width, pos(1)]; + ypol = [pos(2), pos(2), pos(2)-height, pos(2)-height]; + xfpoly(xpol, ypol,1) + R = gce(); + R.foreground=a.foreground; + R.background=a.background; + end + for k=1:nleg + if k<=size(style,2) then + if type(style)==9 then + h=style(k) + select h.type + case "Polyline" + if h.polyline_style==5 then //patch + xfpoly([x;x+drx;x+drx;x;x],[y-bbx(k,2);y-bbx(k,2);y;y;y-bbx(k,2)]); + r=gce(); + r = unglue(r); // one xfpoly returns 2 polylines -> tmp bug to fix later F.Leray + r.foreground=h.foreground; + r.thickness=h.thickness; + r.polyline_style=h.polyline_style; + r.line_style=h.line_style; + else + if stripblanks(h.mark_mode)=="off" + xpoly([x;x+drx],[y;y]-bbx(k,2)/2,"lines");r=gce(); + r.foreground=h.foreground; + r.thickness=h.thickness; + r.polyline_style=h.polyline_style; + r.line_style=h.line_style; + else + xpoly(x+drx/2,y-bbx(k,2)/2);r=gce(); + r.foreground=h.foreground; + r.thickness=h.thickness; + r.mark_style=h.mark_style; + r.mark_size=h.mark_size; + end + end + else + error(msprintf(gettext("%s: Wrong type for input argument #%d: Polyline handles expected.\n"),"legends",2)); + end + else + if style(1,k)<= 0 then + xpoly(x+drx/2,y-bbx(k,2)/2) + r=gce(), + r.mark_mode="on" + r.mark_style=-style(1,k) + if size(style,1)==2 then r.mark_foreground=style(2,k);end + else + xpoly([x;x+drx],[y;y]-bbx(k,2)/2,"lines") + r=gce(), + r.foreground=style(1,k) + if size(style,1)==2 then r.line_style=style(2,k);end + end + end + end + R=[R,r'] + xstring(x + drx*1.2 + bbx(k,1)/2,y-bbx(k,2)/2,leg(k)) + + r=gce() + r.font_size = font_size ; + r.alignment = "center" ; + r.text_box_mode = "centered" ; // the string is centered on (x,y) + R=[R,r] + y=y-bbx(k,2) ; + end + glue(R) + a=gca(); + a.data_bounds = [0,0;0.001,0.001]; + + set("current_axes",old_ax), + + // if immediate_drawing was "on", then the figure will redraw itself. + f.immediate_drawing = vis; + +endfunction diff --git a/modules/graphics/macros/lib b/modules/graphics/macros/lib Binary files differnew file mode 100755 index 000000000..3cc12d582 --- /dev/null +++ b/modules/graphics/macros/lib diff --git a/modules/graphics/macros/locate.bin b/modules/graphics/macros/locate.bin Binary files differnew file mode 100755 index 000000000..3970ec077 --- /dev/null +++ b/modules/graphics/macros/locate.bin diff --git a/modules/graphics/macros/locate.sci b/modules/graphics/macros/locate.sci new file mode 100755 index 000000000..abbfff78a --- /dev/null +++ b/modules/graphics/macros/locate.sci @@ -0,0 +1,71 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [x,but]=locate(n,flag) + //[x]=locate(n,flag) + //fonction permettant d'obtenir les coordonnees d'un ou plusieurs + //points designes a l'aide de la souris sur un trace. + //Les resultats ne sont significatifs que sur les axes lineaires. + //x=locate(n) . Si n>0 retourne dans x(2,n) les coordonnees des n + // points designes. + // . Si n<=0 retourne dans x les coordonnees des points + // designes jusqu'a l'indication de fin de saisie, ce + // dernier point n'etant pas retenu. + //x=locate() . equivault au cas n <= 0 + //si flag=1, on trace une croix sur chaque point saisi + // + //Sur les systemes ayant une souris a boutons, on designe un point + //en cliquant sur un des boutons, la fin de saisie pour n<=0 est + //indiquee en cliquant sur le bouton de gauche. + //! + + [lhs,rhs]=argn(0) + but=[] + show_window(); + if rhs<=1,flag=0;end + if rhs==0;n=-1;end + + ax=gca() + mark_style=ax.mark_style;mark_size=ax.mark_size;mark_size_unit=ax.mark_size_unit; + ax.mark_style=2;ax.mark_size=0;ax.mark_size_unit = "tabulated" + deff( "[]=clearmode(flag)",[ + "npt=size(x,2);" + "if npt>0&flag==1 then" + " delete(ax.children(1:npt))" + "end" + "ax.mark_size_unit=mark_size_unit;" + "ax.mark_style=mark_style;" + "ax.mark_size=mark_size;"]); + x=[]; + if n >= 0 then + for i=1:n, + while %t + [ib,x1,y1]=xclick(); + if or(ib==[0:5 10 11 12]) then break,end + if ib==-100 then return,end //the window has been closed + end + if flag==1,xpoly(x1,y1,"marks");end + x=[x,[x1;y1]]; + but=[but,ib] + end + else + while %t, + while %t + [ib,x1,y1]=xclick(), + if or(ib==[0:5 10 11 12]) then break,end + if ib==-100 then return,end //the window has been closed + end + if or(ib==[0 3 10]) then + break //terminate the acquisition loop + elseif flag==1 then xpoly(x1,y1,"marks"),end + x=[x,[x1;y1]]; + but=[but,ib] + end + end + clearmode(flag); +endfunction diff --git a/modules/graphics/macros/mesh.bin b/modules/graphics/macros/mesh.bin Binary files differnew file mode 100755 index 000000000..2ae32c623 --- /dev/null +++ b/modules/graphics/macros/mesh.bin diff --git a/modules/graphics/macros/mesh.sci b/modules/graphics/macros/mesh.sci new file mode 100755 index 000000000..112ff01f3 --- /dev/null +++ b/modules/graphics/macros/mesh.sci @@ -0,0 +1,33 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2004-2006 - INRIA - Farid Belahcene +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function mesh(varargin) + // Copyright INRIA + // + // Syntax: + // mesh(z) + // mesh(x,y,z) + // mesh(...,<GlobalProperty>) + // mesh(...,<color>,<GlobalProperty>) + // mesh(<axes_handle>,...) + // + // MESH function draws white surfaces, it's based on surf function with the properties e.color_mode = color('white') and e.color_flag = 0. + // Inputs + // x,y,z : matrices which define the grid + + + // Copy RHS arguments + ListArg = varargin; + + drawlater(); + surf(ListArg(:)); + e = gce(); + e.color_mode = color("white"); + e.color_flag = 0; + drawnow(); +endfunction diff --git a/modules/graphics/macros/names b/modules/graphics/macros/names new file mode 100755 index 000000000..bf27bf520 --- /dev/null +++ b/modules/graphics/macros/names @@ -0,0 +1,179 @@ +%BevelBor_i_h +%BevelBor_p +%BorderCo_i_h +%BorderCo_p +%Compound_i_h +%Compound_p +%EmptyBor_i_h +%EmptyBor_p +%EtchedBo_i_h +%EtchedBo_p +%GridBagC_i_h +%GridBagC_p +%GridCons_i_h +%GridCons_p +%LineBord_i_h +%LineBord_p +%MatteBor_i_h +%MatteBor_p +%NoBorder_i_h +%NoBorder_p +%NoLayout_i_h +%NoLayout_p +%OptBorde_i_h +%OptBorde_p +%OptGridB_i_h +%OptGridB_p +%OptGrid_i_h +%OptGrid_p +%OptNoLay_i_h +%OptNoLay_p +%SoftBeve_i_h +%SoftBeve_p +%TitledBo_i_h +%TitledBo_p +%_Matplot +%_Matplot1 +%_champ +%_champ1 +%_fec +%_grayplot +%_param3d +%_param3d1 +%_plot2d +%_plot2d1 +%_plot2d2 +%_plot2d3 +%_plot2d4 +%_plot3d +%_plot3d1 +%_xget +%_xset +%_xstringb +%_xtitle +%h_copy +%h_delete +%h_e +%h_get +%h_i_h +%h_load +%h_matrix +%h_p +%h_save +%h_set +ResetFigureDDM +Sfgrayplot +Sgrayplot +TitleLabel +autumncolormap +bar +barh +barhomogenize +bonecolormap +check2dFun +checkXYPair +clf +colorbar +colordef +comet +comet3d +contour +contour2d +contourf +coolcolormap +coppercolormap +createConstraints +createLayoutOptions +dragrect +edit_curv +errbar +eval3d +eval3dp +fac3d +fac3d1 +fchamp +fcontour +fcontour2d +fgrayplot +fplot2d +fplot3d +fplot3d1 +gca +gce +gcf +gda +gdf +ged +ged_insert +genfac3d +getColorIndex +getLineSpec +getPlotPropertyName +getSurfPropertyName +getTitleLabelPropertyNam +get_figure_handle +getcolor +ghdl2tree +ghdl_fields +graduate +graycolormap +graypolarplot +hist3d +histplot +hotcolormap +hsv2rgb +hsvcolormap +isoview +jetcolormap +legend +legends +locate +mesh +nf3d +oceancolormap +paramfplot2d +pie +pinkcolormap +plot +plot3d2 +plot3d3 +plotframe +polarplot +projaff +rainbowcolormap +replot +rgb2name +rotate +sca +scaling +scf +sda +sdf +secto3d +setDefaultColor +setPlotProperty +setSurfProperty +setTitleLabelProperty +seteventhandler +springcolormap +square +subplot +summercolormap +surf +title +titlepage +twinkle +whitecolormap +wintercolormap +xclear +xgetech +xinfo +xlabel +xload +xnumb +xrpoly +xsave +xsetech +xstringl +ylabel +zlabel diff --git a/modules/graphics/macros/nf3d.bin b/modules/graphics/macros/nf3d.bin Binary files differnew file mode 100755 index 000000000..ad3ce9f40 --- /dev/null +++ b/modules/graphics/macros/nf3d.bin diff --git a/modules/graphics/macros/nf3d.sci b/modules/graphics/macros/nf3d.sci new file mode 100755 index 000000000..320ec954f --- /dev/null +++ b/modules/graphics/macros/nf3d.sci @@ -0,0 +1,27 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [xx,yy,zz]=nf3d(x,y,z) + // 3d coding transformation + // from facets coded in three matrices x,y,z to scilab code for facets + // accepted by plot3d + //--------------------------------------------------------- + if argn(2)<>3 then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "nf3d", 3)); + end + + + [n1,n2]=size(x) + ind=ones(1,n1-1).*.[0 1 n1+1 n1]+ (1:n1-1).*.[1 1 1 1]; + // ind=[1,2,n1+2,n1+1 , 2,3,n1+3,n1+2, .... ,n1-1,n1,2n1,2n1-1 + ind2=ones(1,n2-1).*.ind+((0:n2-2)*n1).*.ones(ind); + nx=prod(size(ind2)) + xx=matrix(x(ind2),4,nx/4); + yy=matrix(y(ind2),4,nx/4); + zz=matrix(z(ind2),4,nx/4); +endfunction diff --git a/modules/graphics/macros/oceancolormap.bin b/modules/graphics/macros/oceancolormap.bin Binary files differnew file mode 100755 index 000000000..f9c380bc3 --- /dev/null +++ b/modules/graphics/macros/oceancolormap.bin diff --git a/modules/graphics/macros/oceancolormap.sci b/modules/graphics/macros/oceancolormap.sci new file mode 100755 index 000000000..5a4dac1de --- /dev/null +++ b/modules/graphics/macros/oceancolormap.sci @@ -0,0 +1,48 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Pierre MARECHAL <pierre.marechal@scilab.org> +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function cmap = oceancolormap(varargin) + + //rainbowcolormap : Black to White though blue + + // Check number of input argument + if size(varargin)<>1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "oceancolormap", 1)); + end + n=varargin(1); + + // Check type of input argument + // Check if input argument is real + if typeof(n)<>"constant" | ~isreal(n) then + error(msprintf(gettext("%s: Wrong type for input argument #%d: a real scalar expected.\n"), "oceancolormap", 1)); + end + + // Check size of input argument + if size(n,"*")<>1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: a real scalar expected.\n"), "oceancolormap", 1)); + end + + if n==0 then + cmap = []; + return + end + + r = [ 0/3 1/3 2/3 3/3 ; 0 0 0 1 ]; + g = [ 0/3 1/3 2/3 3/3 ; 0 0 1/2 1 ]; + b = [ 0/3 1/3 2/3 3/3 ; 0 1/3 2/3 1 ]; + + d = 0.5/max(n,1); + + x = linspace(d,1-d,n) + cmap = [interpln(r, x) ;... + interpln(g, x) ;... + interpln(b, x) ]' ; + + cmap = min(1, max(0 , cmap)) // normaly not necessary + +endfunction diff --git a/modules/graphics/macros/paramfplot2d.bin b/modules/graphics/macros/paramfplot2d.bin Binary files differnew file mode 100755 index 000000000..95a2f0db5 --- /dev/null +++ b/modules/graphics/macros/paramfplot2d.bin diff --git a/modules/graphics/macros/paramfplot2d.sci b/modules/graphics/macros/paramfplot2d.sci new file mode 100755 index 000000000..38dac6712 --- /dev/null +++ b/modules/graphics/macros/paramfplot2d.sci @@ -0,0 +1,78 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function paramfplot2d(f,x,theta,flag,rect) + //animated plot of x-->f(x,t) for t=theta(1),theta(2),etc + //x=N-vector of x-values + //f(x,t)=N-vector of y-values. + //f: mapping x,t -> f(x,t) = R^N valued function for x= vector of R^N and t=real number. + //f can be a either Scilab function or a dynamically linked routine since + // y=f(x,t) is evaluated as y=feval(x(:),t,f). See feval. + // Here y should be a column vector. + // vector of parameters theta=[theta(1), theta(2),... theta(M)] + // Optional parameters + //flag = 'yes' (screen is cleared between two consecutive plots). + //flag = 'no' (screen is not cleared between two consecutive plots). + // + //rect = "rectangle" [xmin, xmax, ymin, ymax] (1 x 4 real vector), + // containing a-priori lower and upper bounds for x and f(t,x). + //function y=f(x,t),y=abs(cos(1.5*x+4*t)).*sin(x+10*t),endfunction + //x=linspace(0,20*%pi,500);theta=0:0.05:5; + [lhs,rhs]=argn(0) + + if ~rhs then + deff("y=f(x,t)","y=t*sin(x)") + x=linspace(0,2*%pi,50);theta=0:0.05:1; + clf; + paramfplot2d(f,x,theta); + return; + end + + if rhs<3 then + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"), "paramfplot2d", 3)); + end + + x=x(:); + theta=theta(:).'; // it should be a row-vector + if rhs<5 then //compute the data bounds + xmin=min(x);xmax=max(x); + ymin=%inf;ymax=-%inf; + for t=theta + y=f(x,t); ymin=min(ymin,min(y)); ymax=max(ymax,max(y)); + end + rect=[xmin,xmax,ymin,ymax]; + end + if rhs<4 then flag="no";end + realtimeinit(0.1); + + clf(); + fig=gcf(); + a=gca(); + a.data_bounds=matrix(rect,2,2); + a.axes_visible="on"; + y=feval(x,theta(1),f); + xpoly(x,y(:));p=gce(); //the polyline handle + realtime(0); + if flag=="no" then + drawlater(); + for k=1:size(theta,"*") + realtime(k); + y=feval(x,theta(k),f); + p.data(:,2)=y(:); + drawnow(); + end + else + drawlater(); + for k=1:size(theta,"*") + realtime(k); + plot2d(x,feval(x,theta(k),f)) + drawnow(); + end + end + +endfunction diff --git a/modules/graphics/macros/pie.bin b/modules/graphics/macros/pie.bin Binary files differnew file mode 100755 index 000000000..80ca6e85e --- /dev/null +++ b/modules/graphics/macros/pie.bin diff --git a/modules/graphics/macros/pie.sci b/modules/graphics/macros/pie.sci new file mode 100755 index 000000000..bd1f24b5c --- /dev/null +++ b/modules/graphics/macros/pie.sci @@ -0,0 +1,147 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2004-2006 - INRIA - Farid Belahcene +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function pie(varargin) + // Copyright INRIA + // This function draws a pie, if size of x is N then pie function draws a pie with N parts, the area of the ith part is equal to (x(i)/sum(x))*( surface of the unit cercle). + // + // + // syntax : pie(x[,sp[,txt]]) + // Input : The input arguments must have the same size + // x : a scalar or a vector of positive reals. + // sp : a scalar or a vector of reals. The sp vector allows to cut one or several parts of the pie + // txt : a cell or a vector of strings. The txt vector allows to write a text for each part of the pie + + varlist = varargin; + // Input arguments must have the same length + + for i=2:size(varlist) + if size(varlist(i-1),"*") <> size(varlist(i),"*") then + error(msprintf(gettext("%s: Wrong size for input arguments: Matrices of same size expected.\n"), "pie")); + end + end + + txt = []; + esp = []; + + // Detect and set the RHS arguments + // case : pie(x) + if size(varlist) == 1 then + if type(varlist(1))==1 & and(varlist(1)>0) then + x = varlist(1) + else + error(msprintf(gettext("%s: Wrong type for input argument #%d: A real scalar or vector expected.\n"), "pie", 1)); + end + // case : pie(x,sp) or pie(x,txt) + elseif size(varlist) == 2 then + if type(varlist(1)) == 1 & and(varlist(1)>0) then + x = varlist(1); + else + error(msprintf(gettext("%s: Wrong type for input argument #%d: A real scalar or vector expected.\n"), "pie", 1)); + end + if type(varlist(2)) == 1 | type(varlist(2)) == 4 + esp = varlist(2); + elseif type(varlist(2)) == 10 | iscellstr(varlist(2)) then + txt = varlist(2); + end + // case : pie(x,sp,txt) + elseif size(varlist) == 3 then + if type(varlist(1)) == 1 & and(varlist(1)>0) then + x = varlist(1); + else + error(msprintf(gettext("%s: Wrong type for input argument #%d: A real scalar or vector expected.\n"), "pie", 1)); + end + if type(varlist(2)) == 1 | type(varlist(2)) == 4 + esp = varlist(2); + else + error(msprintf(gettext("%s: Wrong type for input argument #%d: A real scalar or vector expected.\n"), "pie", 2)); + end + if type(varlist(3)) == 10 + txt = varlist(3); + elseif iscellstr(varlist(3)) then + for j=1:size(varlist(3),"*") + txt(j) = varlist(3).entries(j); + end + else + error(msprintf(gettext("%s: Wrong size for input argument #%d: Vector of strings expected.\n"),"pie", 3)); + end + else + error(msprintf(gettext("%s: Wrong number of input argument(s): %d to %d expected.\n"), "pie", 1, 3)); + end + + if isempty(x) then + error(msprintf(gettext("%s: Wrong type for input argument #%d: A real scalar or vector expected.\n"), "pie", 1)); + end + // xi and yi represents the coordinates of each polyline + // iesp is the index of the part of i which are separated of the pie + // teta_1 is the start angle of the arc polyline, teta_2 is the end angle of the arc polyline + iesp = find(esp>0 | esp<0); + teta_2 = 0 + %pi/2; + yi = []; + xi = []; + CurColor = 0; + + drawlater(); + // Create a close polyline for every parts of pie, the polyline inside color is determinated by the plot colormap + for i=1:size(x,"*") + xi = []; + yi = []; + teta_1 = teta_2; + teta_i = (x(i)/sum(x))*2*%pi; + teta_2 = teta_1 + teta_i + if size(x,"*") <> 1 then + xi(1) = 0; + yi(1) = 0; + xi(2) = cos(teta_1); + yi(2) = sin(teta_1); + else + xi(1) = cos(teta_1); + yi(1) = sin(teta_1); + end + inter = 1/(100*x(i)/sum(x)); + k = inter; + while k<1 + xi($+1) = cos((1-k)*teta_1 +k*teta_2); + yi($+1) = sin((1-k)*teta_1 +k*teta_2); + k= k + inter; + end + xi($+1) = cos(teta_2); + yi($+1) = sin(teta_2); + + xfpolys(xi,yi); + e = gce(); + a = gca(); + ei = e.children; + if or(i == iesp) then + ei.x_shift = ones(1,size(xi,"*")) * (1/10) * cos((teta_2+teta_1)/2); + ei.y_shift = ones(1,size(yi,"*")) * (1/10) * sin((teta_2+teta_1)/2); + if txt <> [] + xstring(cos((teta_2+teta_1)/2)*1.2+ei.x_shift(1)-0.1*(cos((teta_2+teta_1)/2)<0),sin((teta_2+teta_1)/2)*1.2+ei.y_shift(1),txt(i)); + else + xstring(cos((teta_2+teta_1)/2)*1.2+ei.x_shift(1)-0.1*(cos((teta_2+teta_1)/2)<0),sin((teta_2+teta_1)/2)*1.2+ei.y_shift(1),string(round((x(i)/sum(x))*100)) + "%"); + end + else + if txt <> [] + xstring(cos((teta_2+teta_1)/2)*1.2-0.1*(cos((teta_2+teta_1)/2)<0),sin((teta_2+teta_1)/2)*1.2,txt(i)); + else + xstring(cos((teta_2+teta_1)/2)*1.2-0.1*(cos((teta_2+teta_1)/2)<0),sin((teta_2+teta_1)/2)*1.2,string(round((x(i)/sum(x))*100)) + "%"); + end + end + + [Color,CurColor] = setDefaultColor(CurColor); + ei.background = Color; + ei.fill_mode = "on"; + a.isoview = "on"; + a.box = "off"; + a.axes_visible = "off"; + // Update data_bounds + a.data_bounds = [min(-1.3,a.data_bounds(1,1)) min(-1.3,a.data_bounds(1,2));max(1.3,a.data_bounds(2,1)) max(1.3,a.data_bounds(2,2))]; + end + drawnow(); + +endfunction diff --git a/modules/graphics/macros/pinkcolormap.bin b/modules/graphics/macros/pinkcolormap.bin Binary files differnew file mode 100755 index 000000000..4c3377c77 --- /dev/null +++ b/modules/graphics/macros/pinkcolormap.bin diff --git a/modules/graphics/macros/pinkcolormap.sci b/modules/graphics/macros/pinkcolormap.sci new file mode 100755 index 000000000..a5d4faaea --- /dev/null +++ b/modules/graphics/macros/pinkcolormap.sci @@ -0,0 +1,48 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Pierre MARECHAL <pierre.marechal@scilab.org> +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function cmap = pinkcolormap(varargin) + + //pinkcolormap : Sepia tone on black and white images + + // Check number of input argument + if size(varargin)<>1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "pinkcolormap", 1)); + end + n=varargin(1); + + // Check type of input argument + // Check if input argument is real + if typeof(n)<>"constant" | ~isreal(n) then + error(msprintf(gettext("%s: Wrong type for input argument #%d: a real scalar expected.\n"), "pinkcolormap", 1)); + end + + // Check size of input argument + if size(n,"*")<>1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: a real scalar expected.\n"), "pinkcolormap", 1)); + end + + red_1 = (0:n-1)'/max(n-1,1); + green_1 = (0:n-1)'/max(n-1,1); + blue_1 = (0:n-1)'/max(n-1,1); + + n1 = fix(3/8*n); + n2 = n1; + n3 = n-(n1+n2); + + red_2 = [(1:n1)'/n1 ; ones(n2,1) ; ones(n3,1)]; + green_2 = [zeros(n1,1) ; (1:n2)'/n2 ; ones(n3,1)]; + blue_2 = [zeros(n1,1) ; zeros(n2,1) ; (1:n3)'/(n3)]; + + red = sqrt((2*red_1 + red_2) /3); + green = sqrt((2*green_1 + green_2)/3); + blue = sqrt((2*blue_1 + blue_2) /3); + + cmap = [red green blue]; + +endfunction diff --git a/modules/graphics/macros/plot.bin b/modules/graphics/macros/plot.bin Binary files differnew file mode 100755 index 000000000..2a99f58e1 --- /dev/null +++ b/modules/graphics/macros/plot.bin diff --git a/modules/graphics/macros/plot.sci b/modules/graphics/macros/plot.sci new file mode 100755 index 000000000..e4b8bc09c --- /dev/null +++ b/modules/graphics/macros/plot.sci @@ -0,0 +1,455 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2004-2006 - INRIA - Fabrice Leray +// Copyright (C) 2008 - INRIA - Jean-Baptiste Silvy +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function plot(varargin) + // Try to build a new better parser that could manage things like: + // plot(x,y,'X',1:10); // where X stands for Xdata (Matlab recognizes + //it and treats it well...) + + [lhs,rhs]=argn(0); + + if ~rhs + //LineSpec and PropertySpec examples: + t = 0:%pi/20:2*%pi; + tt = t'; + drawlater(); + subplot(211); + plot(tt, sin(tt), "ro-.", tt, cos(tt), "cya+", tt, abs(sin(tt)), "--mo"); + subplot(212); + plot([t ;t],[sin(t); cos(t)],"xdat",[1:2]); + drawnow(); + return; + end + + + + CurColor = 0; // current color used if no color specified via LineSpec + // nor PropertyName + + + + ListArg = varargin; + + //detect and set the current axes now: + if type(ListArg(1)) == 9 + hdle = ListArg(1); + if (hdle.type == "Axes") + sca(ListArg(1)); + ListArg(1) = null(); // remove this parameter from the list + else + warning("Handle should be an Axes handle") + return; + end + end + + + nv = size(ListArg) + + + argTypes=[]; + couple=[]; + + typeOfPlot = "plot"; + provided_data = 2; + + for curArgIndex=1:nv + argTypes(curArgIndex,1) = type(ListArg(curArgIndex)) + end + + Ttmp=argTypes; + + for i=1:nv-1 + acceptedTypes=[]; + acceptedTypes=find(Ttmp(i,1)==1 & or(Ttmp(i+1,1)==[1,13,130])) // to accept double, macro function or primitive as second argument + + if (acceptedTypes<>[]) then + couple=[couple i]; + Ttmp(i,1) = 99; // Replace a known type by 99 (no meaning) to count it once only! + Ttmp(i+1,1)= 99; // to avoid having (x1,y1,x2,y2) ->couple=[1,2,3] + // With this trick, couple=[1,3]; + end + + end + + + if (couple==[]) // No data couple found + // Search for at least a single data , i.e.: plot(y) + + if ((argTypes(1,1)==1 | argTypes(1,1)==8) & ListArg(1)<>[]) then // case plot(SINGLE y,...) + couple = 1; + provided_data = 1; + + if (modulo(nv-couple,2)<>0) then + P1 = couple+2 // Position of the first PropertyName field + else + P1 = couple+1 + end + + else + warning("Error inside input argument : no data"); + return; + end + + else + + // Some test to check wrong inputs + // + // 1. Test if 2 data couples (first : type==1, second : type=[1,13,130]) + // are at least separated by 2 indices + if (couple(2:$)-couple(1:$-1)<2) + warning("Error inside input argument !"); + return; + end + + // 2. Test if no string couples happen before P1 (see below for P1 definition) + for index=1:couple($) + acceptedTypes=[]; + acceptedTypes=find(Ttmp(index,1)==10 & Ttmp(index+1,1)==10) + + if (acceptedTypes<>[]) then + warning("Error inside input argument : String argument is an unknown option."); + return; + end + end + + + + if (modulo(nv-(couple($)+1),2)<>0) then + P1 = couple($)+3 // Position of the first PropertyName field + else + P1 = couple($)+2 + end + + end + + numplot = size(couple,"*"); + + xyIndexLineSpec = zeros(numplot,3); + // xyIndexLineSpec is a matrix storing the index of x, y and linespec + // if one of these indices is 0 => it does not exist + // (which is possible for x and linepsec, not for y) + + if (provided_data == 2) then + + for curCouple=1:size(couple,"*") + xyIndexLineSpec(curCouple,1:2) = couple(curCouple) +[0,1] // x,y index storage + + if (couple(curCouple)+2 < P1) + if (argTypes(couple(curCouple)+2,1)==10) then // LineSpec treatment + xyIndexLineSpec(curCouple,3) = couple(curCouple)+2; + end + end + end + else + // we are in the case where: plot(SINGLE y,... x not specified + // or plot(handle,SINGLE y,... + xyIndexLineSpec(1,1) = 0; // no x specified + xyIndexLineSpec(1,2) = couple; + + //pause; + + if (couple+1 < P1) + if (argTypes(couple+1,1)==10) then // LineSpec treatment + xyIndexLineSpec(1,3) = couple+1; + end + end + end + + + + // delay the drawing commands + // smart drawlater + current_figure=gcf(); + cur_draw_mode = current_figure.immediate_drawing; + current_figure.immediate_drawing = "off"; + + // check wether this is the first plot for the axes in which we will draw + curAxes = gca(); + // save auto_clear state. + OldAutoClear = curAxes.auto_clear; + + isFirstPlot = (curAxes.children == []) + + //Now, we plot the decomposed plots one by one with their own linespec + // provided_data = 2 : x and y are provided + + FinalAgreg=[]; // Final Compound containing all the new created plots. + + //for i=numplot:-1:1 + for i=1:numplot + // Set off auto_clear for allowing multiple graphics entity + // will be restored behond + if i>1 then + curAxes.auto_clear="off"; + end + + //default values + Marker=[]; + MarkerSize=1; + Color=[]; + LineStyle=1; + Line = %F; + Marker = %F; + + if (provided_data == 2) then + + if (type(ListArg(xyIndexLineSpec(i,2))) == 13 | type(ListArg(xyIndexLineSpec(i,2))) == 130) + // A function (macro or primitive) is given. We need to build the vector or matrix. + sizefirstarg = size(ListArg(xyIndexLineSpec(i,1))); + buildFunc = ListArg(xyIndexLineSpec(i,2)); + firstarg = ListArg(xyIndexLineSpec(i,1)); + tmp = []; + + for ii=1:sizefirstarg(1,2) + for jj=1:sizefirstarg(1,1) + + // function evaluation may fail + // try/cacth is buggy for now + // so use execstr until the bug is fixed + err = execstr("tmp(jj,ii) = buildFunc(firstarg(jj,ii))","errcatch","n"); + + if (err <> 0) then + // reset data + ResetFigureDDM(current_figure, cur_draw_mode); + + // get error + [err_message, err_number, err_line, err_func] = lasterror(%t); + + clear buildFunc; + // print it + if (err_func <> "") then + // ascii(10) = \n + error(msprintf(gettext("%s: Error : unable to evaluate input function ''%s''.") + ascii(10) + gettext("Error %d at line %d of the function: ''%s''"), "plot", err_func,err_number, err_line, err_message)); + else + error(msprintf(gettext("%s: Error : unable to evaluate input function.") + ascii(10) + gettext("Error %d at line %d of the function: ''%s''"), "plot", err_number, err_line, err_message)); + end + // exit function + return; + end + + end + end + + + ListArg(xyIndexLineSpec(i,2)) = tmp; + // if there is an other iteration, we will have error message redefining function. + // we need to clear here and not before, because user must see the warning if needed. + clear buildFunc; + end + [X,Y] = checkXYPair(typeOfPlot,ListArg(xyIndexLineSpec(i,1)),ListArg(xyIndexLineSpec(i,2)),current_figure,cur_draw_mode) + else + if or(size(ListArg(xyIndexLineSpec(1,2)))==1) // If this is a vector + if size(ListArg(xyIndexLineSpec(1,2)), "r") == 1 then + X=1:length(ListArg(xyIndexLineSpec(1,2))); // insert a column abcsissa vector of same length, + else + X=(1:length(ListArg(xyIndexLineSpec(1,2))))'; // insert a row abcsissa vector of same length, + end + else // if this is a matrix, + X=(1:size(ListArg(xyIndexLineSpec(1,2)),1))'; // insert a row abcsissa vector with same size + end + // In both cases (matrix/vector), transpose it now so no warning is issued in checkXYPair(). + [X,Y] = checkXYPair(typeOfPlot,X,ListArg(xyIndexLineSpec(1,2)),current_figure,cur_draw_mode) + end + + // Case if 'Xdata', 'Ydata' or 'Zdata' have been set in (PropertyName,Propertyvalue) couples + // must be taken into account now + + // P1 is the position of the first PropertyName field. + Property = P1; + + while (Property <= nv-1) + PropertyName = ListArg(Property); + PropertyValue = ListArg(Property+1); + + // Xdata can ONLY be a vector (cf. Matlab help) + PName = getPlotPropertyName(PropertyName,current_figure,cur_draw_mode); + if (PName == "xdata") + + if (type(PropertyValue)<>1 | and(size(PropertyValue)<>1)) + warning("Xdata value must be a column or row vector."); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + else + PropertyValue = PropertyValue(:); // force + if or(size(X))==1 // If X is a vector (inevitably a column vector because checkXYPair always returns a column vector) + X = PropertyValue; // X is replaced by PropertyValue + [X,Y] = checkXYPair(typeOfPlot,X,Y,current_figure,cur_draw_mode) + else // X is a matrix + if size(PropertyValue,"*") == size(X,1) + for j=1:size(PropertyValue,"*") + X(j,:) = PropertyValue(j,1); + end + else + str="plot : incompatible dimensions in input arguments"; + warning(str); + ResetFigureDDM(current_figure, cur_draw_mode); + end + end + end + + // Ydata ONLY be a vector (contrary to what is said by the Matlab help) + elseif (PName == "ydata") + + if (type(PropertyValue)<>1 | and(size(PropertyValue)<>1)) + warning("Ydata value must be a column or row vector."); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + else + PropertyValue = PropertyValue(:); // force + if or(size(Y))==1 // If Y is a vector (inevitably a column vector because checkXYPair always returns a column vector) + Y = PropertyValue; // Y is replaced by PropertyValue + [X,Y] = checkXYPair(typeOfPlot,X,Y,current_figure,cur_draw_mode) + else // Y is a matrix + if size(PropertyValue,"*") == size(Y,1) + for j=1:size(PropertyValue,"*") + Y(j,:) = PropertyValue(j); + end + else + str="plot : incompatible dimensions in input arguments"; + warning(str); + ResetFigureDDM(current_figure, cur_draw_mode); + end + end + + end + + // Zdata will be treated after plot building + end + + Property = Property+2; + end + + + + //Now we have an array xyIndexLineSpec [numplot x 3] containing indices pointing on T for : + // - x (<>0 if existing) + // - y + // - linespec (<>0 if existing) + // for each plot passed in argument + // x | y | linespec + // ---------------- + //plot1 0|i1 |0 <=> plot(y) + //plot2 i2|i3 |0 <=> plot(x,y) + //plot3 i4|i5 |i6 <=> plot(x,y,LINESPEC) + //... + + + + if (xyIndexLineSpec(i,3)<>0) then // if we have a line spec <=> index <> 0 + [Color,Line,LineStyle,Marker,MarkerStyle,MarkerSize,fail] = getLineSpec(ListArg(xyIndexLineSpec(i,3)),current_figure,cur_draw_mode); + end + + // The plot is made now : + err = execstr("plot2d(X,Y)","errcatch","m"); + + if err <> 0 + mprintf("Error %d : in plot2d called by plot",err); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + agreg=gce(); // when using plot2d, we always have an Compound as the current entity + + FinalAgreg = [agreg FinalAgreg]; + + if Color==[] + DefaultColor = %T; + else + DefaultColor = %F; + end + + for ii=size(agreg.children,"*"):-1:1 + curPolyline=agreg.children(ii); // we apply linespec to the lines + + // Color treatment : if no color specified by LineSpec nor PropertyName + // Set the default color to the curve + if DefaultColor == %T + [Color,CurColor] = setDefaultColor(CurColor); + end + + if (Marker == %T) + curPolyline.mark_style=MarkerStyle; + curPolyline.mark_mode ="on"; + curPolyline.mark_foreground = Color; + curPolyline.mark_style=MarkerStyle; + curPolyline.mark_size=MarkerSize; + else + curPolyline.mark_mode ="off" + end + + if (Line == %T) + curPolyline.line_mode="on"; + curPolyline.foreground = Color; + curPolyline.line_style = LineStyle; + else + curPolyline.line_mode="off" + end + + if (Line == %F & Marker ==%F) // no linespec nor PropertyName set + curPolyline.line_mode="on"; + curPolyline.foreground = Color; + curPolyline.line_style = LineStyle; + end + + end + end + + //Reset auto_clear Property + curAxes.auto_clear = OldAutoClear; + + /////////////////////////////////// + //Global Property treatment // + //PropertyName and PropertyValue // + /////////////////////////////////// + + + + // Those properties will be applied to Agreg children + Agreg = glue(FinalAgreg(1:$)) + + nbCompound = find(Agreg.children.type=="Compound") + + while (nbCompound<>[]) + nbCompound=nbCompound(1); + unglue(Agreg.children(nbCompound)); + nbCompound=find(Agreg.children.type=="Compound") + end + + + + // P1 is the position of the first PropertyName field. + Property = P1; + + Curves = Agreg.children + //Curves(:,1) = Curves(:,$:-1:1); + + // set mark_size_unit to 'point' for all the curves + Curves.mark_size_unit="point"; + + while (Property <= nv-1) + setPlotProperty(ListArg(Property),ListArg(Property+1),Curves,current_figure,cur_draw_mode) + + Property = Property+2; + end + + // force drawing of box like in matlab + // for a first plot + // unless we are using centered axes + // to keep compatibility with Scilab 4 + if isFirstPlot & curAxes.x_location <> "origin" & curAxes.y_location <> "origin" then + curAxes.box = "on"; + end + + + + //postponed drawings are done now ! + // smart drawnow + ResetFigureDDM(current_figure, cur_draw_mode) + +endfunction diff --git a/modules/graphics/macros/plot3d2.bin b/modules/graphics/macros/plot3d2.bin Binary files differnew file mode 100755 index 000000000..6713922b4 --- /dev/null +++ b/modules/graphics/macros/plot3d2.bin diff --git a/modules/graphics/macros/plot3d2.sci b/modules/graphics/macros/plot3d2.sci new file mode 100755 index 000000000..9171cdc97 --- /dev/null +++ b/modules/graphics/macros/plot3d2.sci @@ -0,0 +1,65 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function plot3d2(x,y,z,vect,theta,alpha,leg,flag,ebox) + // plot3d2(x,y,z,vect,T,A,leg,flags,ebox) + // (x,y,z) description of a set of surfaces + // to Scilab description + call to plot3d + // (x,y,z) are three matrices which describe a surface + // the surface is composed of four sided polygons + // The x-coordinates of a facet are given by x(i,j),x(i+1,j),x(i,j+1), + // x(i+1,j+1) + // the vect vector is used when multiple surfaces are coded + // in the same (x,y,z) matrices. vect(j) gives the line + // at which the coding of the jth surface begins + // if vect==-1 means that vect is useless + //--------------------------------------------------------- + [lhs,rhs]=argn(0); + if rhs<3 then + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"), "plot3d2", 3)) + end + isvect=1 + if exists("vect","local")==0 then isvect=1 ;vect=-1,end + if vect<>-1 then + nobjs=prod(size(vect))+1; + [rx,cx]=size(x); + vect1=[0,vect,rx]; + xx=[],yy=[],zz=[]; + for i=1:nobjs; + [xxl,yyl,zzl]=nf3d(x(vect1(i)+1:vect1(i+1),:),... + y(vect1(i)+1:vect1(i+1),:),... + z(vect1(i)+1:vect1(i+1),:)),... + xx=[xx,xxl];yy=[yy,yyl];zz=[zz,zzl]; + end; + else + [xx,yy,zz]=nf3d(x,y,z) + end + + opts=[] + if exists("theta","local")==1 then + opts=[opts,"theta=theta"] + end + if exists("alpha","local")==1 then + opts=[opts,"alpha=alpha"] + end + if exists("leg" ,"local")==1 then + opts=[opts,"leg=leg"] + end + if exists("flag" ,"local")==1 then + opts=[opts,"flag=flag"] + end + if exists("ebox" ,"local")==1 then + opts=[opts,"ebox=ebox"] + end + + if size(opts,2)+isvect+3 <rhs then + error(msprintf(gettext("%s: Wrong value for input argument: ''%s'', ''%s'', ''%s'', ''%s'' or ''%s'' expected.\n"),"plot3d2","theta","alpha","leg","flag","ebox")); + end + + execstr("plot3d(xx,yy,zz,"+strcat(opts,",")+")") +endfunction diff --git a/modules/graphics/macros/plot3d3.bin b/modules/graphics/macros/plot3d3.bin Binary files differnew file mode 100755 index 000000000..2c958790a --- /dev/null +++ b/modules/graphics/macros/plot3d3.bin diff --git a/modules/graphics/macros/plot3d3.sci b/modules/graphics/macros/plot3d3.sci new file mode 100755 index 000000000..5e44024ad --- /dev/null +++ b/modules/graphics/macros/plot3d3.sci @@ -0,0 +1,52 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function plot3d3(x,y,z,vect,theta,alpha,leg,flags,ebox) + // mesh draw of a solid surface described + // by a set of points + // the mesh is drawn using the colums and rows of [x,y,z] + //--------------------------------------------------------- + [lhs,rhs]=argn(0); + if rhs<3 then + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"), "plot3d3", 3) ); + end; + if exists("vect","local")==0 then vect=-1,end + if vect<>-1 then + nobjs=prod(size(vect))+1; + [rx,cx]=size(x); + vect1=[0,vect,rx]; + xx=[],yy=[],zz=[]; + for i=1:nobjs; + xx=[x(vect1(i)+1:vect1(i+1),:),xx] + yy=[y(vect1(i)+1:vect1(i+1),:),yy] + zz=[z(vect1(i)+1:vect1(i+1),:);zz] + end + else + xx=x;yy=y;zz=z; + end + + [n,p]=size(z); + opts=[] + if exists("theta","local")==1 then opts=[opts,"theta=theta"],end + if exists("alpha","local")==1 then opts=[opts,"alpha=alpha"],end + if exists("leg" ,"local")==1 then opts=[opts,"leg=leg"] ,end + // set default flags + // flag(1): color of outide lines + // flag(2): color of inside lines + // flag(3): scaling type + // flag(4): box type + if exists("flags" ,"local")==0 then flags=[3,4,2,4]; ,end + if exists("ebox" ,"local")==1 then opts=[opts,"ebox=ebox"] ,end + + + execstr("param3d1(xx,yy,list(zz,flags(1)*ones(1,p)),"+.. + strcat([opts "flag=flags(3:4)"],",")+")") + + execstr("param3d1(xx'',yy'',list(zz'',flags(2)*ones(1,n)),"+.. + strcat([opts "flag=[0 flags(4)]"],",")+")") +endfunction diff --git a/modules/graphics/macros/plotframe.bin b/modules/graphics/macros/plotframe.bin Binary files differnew file mode 100755 index 000000000..848f175a4 --- /dev/null +++ b/modules/graphics/macros/plotframe.bin diff --git a/modules/graphics/macros/plotframe.sci b/modules/graphics/macros/plotframe.sci new file mode 100755 index 000000000..bfa69a36b --- /dev/null +++ b/modules/graphics/macros/plotframe.sci @@ -0,0 +1,117 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function plotframe(rect,axisdata,options,legs,subwindow) + // plotframe - fixes scales, tics and grid on a graphic, + //%Syntax + // plotframe(rect,axisdata [,flags or leg or subwindow, ...) + //%Parameters + // rect : [xmin,ymin,xmax,ymax] data boudaries + // axisdata: [nx,mx,ny,my] mx and my x and y tics, nx,ny : x and y subtics + // flags : [quad,bounds] ou quad is a boolean if %t a grid is added + // bounds a booleen also : if bounds is %t then rect can be modified + // in order to have better scales on both axes which contains the + // rect initial data. + // subwindow : see xsetech (wrect) + //! + [lhs,rhs]=argn(0) + + if rhs < 1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"), "plotframe", 1)); + return ; + end + + f_subwin = %f ; + f_flags = %f ; + f_captions = %f ; + f_tics = %f ; + + // check if we found optional args + if exists("tics","local") == 1 then + f_tics = %t ; + end + + if exists("flags","local") == 1 then + f_flags = %t ; + else + flags = [%f,%f] ; + end + + if exists("Captions","local") == 1 then + f_captions = %t ; + end + if exists("captions","local") == 1 then + f_captions = %t ; + Captions = captions; + end + + if exists("subwin","local") == 1 then + f_subwin = %t ; + end + + if rhs >= 2 & ~f_subwin & ~f_captions & ~f_flags & ~f_tics then + // no optional argument specified we use the old syntax + // with 2,3,4 or five parameters + + f_tics = %t ; + tics = axisdata ; + if rhs == 5 then + select type(subwindow), + case 1 , subwin = subwindow, f_subwin = %t ; + case 4 , flags = subwindow, f_flags = %t ; + case 10, Captions = subwindow, f_captions = %t ; + end + end + if rhs >= 4 then + select type(legs), + case 1 , subwin = legs, f_subwin = %t ; + case 4 , flags = legs, f_flags = %t ; + case 10, Captions = legs, f_captions = %t ; + end + end + if rhs >= 3 then + select type(options), + case 1 , subwin = options, f_subwin = %t ; + case 4 , flags = options, f_flags = %t ; + case 10, Captions = options, f_captions = %t ; + end + end + + end + + + if f_subwin then + xsetech(subwin,rect); + end + // -- trace du cadre et des echelles + if flags(2) then + if f_tics then + plot2d( [],[],0,"051"," ",rect,tics ) ; + else + plot2d( [],[],0,"051"," ",rect ) ; + end + else + if f_tics then + plot2d( [],[],0,"011"," ",rect, tics ) ; + else + plot2d( [],[],0,"011"," ",rect ) ; + end + end + + // -- trace des legendes d'axes et du titre + if f_captions then + select size(Captions,"*"), + case 1, xtitle(Captions(1)) ; + case 2, xtitle(Captions(1),Captions(2)) ; + case 3, xtitle(Captions(1),Captions(2),Captions(3)); + end + end + + if flags(1) then xgrid(); end + +endfunction diff --git a/modules/graphics/macros/polarplot.bin b/modules/graphics/macros/polarplot.bin Binary files differnew file mode 100755 index 000000000..038cdfbcb --- /dev/null +++ b/modules/graphics/macros/polarplot.bin diff --git a/modules/graphics/macros/polarplot.sci b/modules/graphics/macros/polarplot.sci new file mode 100755 index 000000000..89390c160 --- /dev/null +++ b/modules/graphics/macros/polarplot.sci @@ -0,0 +1,234 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// Copyright (C) 2010 - DIGITEO - Manuel Juliachs +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function polarplot(theta,rho,style,strf,leg,rect) + [lhs,rhs]=argn(0) + if rhs<=0 then + theta=0:.01:2*%pi; + rho=sin(2*theta).*cos(2*theta) + clf(); + polarplot(theta,rho) + return + end + if size(theta,1)==1 then + theta=theta(:), + end + if size(rho,1)==1 then + rho=rho(:), + end + rm=max(abs(rho)) + x=rho.*cos(theta) + y=rho.*sin(theta) + + opts=[] + isstrf=%f; + isframeflag=%f; + isrect=%f; + if exists("style","local")==1 then + opts=[opts,"style=style"] + end + if exists("strf","local")==1 then + opts=[opts,"strf=strf"] + isstrf=%t + end + if exists("leg","local")==1 then + opts=[opts,"leg=leg"] + end + if exists("rect","local")==1 then + opts=[opts,"rect=rect"] + isrect=%t + end + if exists("frameflag","local")==1 then + opts=[opts,"frameflag=frameflag"] + isframeflag=%t + end + + if size(opts,2)<rhs-2 then + error(msprintf(gettext("%s: Wrong value for input argument: ''%s'', ''%s'', ''%s'', ''%s'' or ''%s'' expected.\n"),"polarplot","style","strf","leg","rect","frameflag")); + end + + // Some default values: + Amin=0 // starting angle for the frame + dA=360 // span of the angular frame + nn=4 // number of quadrants to be drawn + + xmin=min(x); + xmax=max(x); + L=(xmax-xmin)*1.07; + ymin=min(y); + ymax=max(y); + H=(ymax-ymin)*1.07; + // Angle at which Radial labels will be displayed + A=round(atan((ymin+ymax)/2,(xmin+xmax)/2)/%pi*180/45)*45; + dx=-0.5, dy=-0.5 // H & V shifts in string-width and string-height units + + // Case without rect= + if ~isrect then + // Determines quadrant(s) to be drawn + Q=[%T %T %T %T]; + e=rm/500; + + if min(x)<-e then + xmin=-rm; + else + xmin=0; Q([2 3])=%F; + end + + if max(x)>e then + xmax= rm; + else + xmax=0; Q([1 4])=%F; + end + + if min(y)<-e then + ymin=-rm; + else + ymin=0; Q([3 4])=%F; + end + + if max(y)>e then + ymax= rm; + else + ymax=0; Q([1 2])=%F; + end + + L=(xmax-xmin)*1.1; if L==0, L=2*rm*1.1; end + H=(ymax-ymin)*1.1; if H==0, H=2*rm*1.1; end + x0=(xmin+xmax)/2; y0=(ymin+ymax)/2; + rect=[x0-L/2 y0-H/2 x0+L/2 y0+H/2] + + // Special case: data aligned on the x or y axis + if Q==[%F %F %F %F], + if (ymax-ymin)<2*e, // on x axis + if xmin<-e then + Q([2 3])=%T + end + if xmax> e then + Q([1 4])=%T + end + else // on y axis + if ymin<-e then + Q([3 4])=%T + end + if ymax> e then + Q([1 2])=%T + end + end + end + + n=find(Q); // id numbers of quadrants to be drawn + nn=length(n) // number of quadrants to be drawn + Amin=(n(1)-1)*90 + + select nn + case 1, + dA=90; + if n==1, A=90, dx=-1.1, dy=-0.5 + elseif n==2, A=90, dx=0.2, dy=-0.5 + elseif n==3, A=270, dx=0.2, dy=-0.5 + else A=270, dx=-1.1, dy=-0.5 + end + case 2 + dA=180; + if n(1)==1 + if n(2)==2, //A=90, dx=0.1, dy=-0.5 + else Amin=-90, A=90, dx=-1.2, dy=-0.5, end + elseif n(1)==2, A=90, dx=0.2, dy=-0.5 + else A=0, dx=-0.5, dy=0.2 + end + else + Amin=0, dA=360 + end + opts=[opts,"rect=rect"] + end // if ~isrect + + if isstrf& isframeflag then + error(msprintf(gettext("%s: ''%s'' cannot be used with ''%s''.\n"),"polarplot","frameflag","strf")); + end + if ~(isstrf) then + axesflag=0 + opts=[opts,"axesflag=axesflag"], + end + if ~(isstrf|isframeflag) then + frameflag=4 + opts=[opts,"frameflag=frameflag"], + end + drawlater() + execstr("plot2d(x,y,"+strcat(opts,",")+")") + + fcolor=color("grey70"); + xset("dashes",1) + + // CIRCULAR FRAME: + // Radial values for the frame: + fmt_in=format(), format("v",9) + // Tunning for smart values: + p=floor(log10(abs(rm))); + m=rm/10^p; + if m<1.3, dm=0.2 + elseif m<=2, dm=0.3 + elseif m<4, dm=0.5 + else dm=1, + end + k=fix(m/dm) + if m-k*dm < dm/5, k=k-1, end + R=[(1:k)*dm*10^p ] + // Tuning for smart 10^ display using LaTeX instead of D+## exponential display + if abs(p)<4, + Rtxt=string(R) + [v,k]=max(length(Rtxt)), tmp=xstringl(0,0,Rtxt(k)) + else + if dm<1, dm=dm*10, p=p-1, end + tmp=string(R/10^p)+"108" + [v,k]=max(length(tmp)), tmp=xstringl(0,0,tmp(k)) + Rtxt="$\scriptstyle "+string(R/10^p)+"\:.10^{"+string(p)+"}$"; + end + w=tmp(3); h=tmp(4); + format(fmt_in(2),fmt_in(1)) // Restoring entrance format + R = [ R rm ] + + // Drawing & labelling the radial frame + kM=size(R,"*"); + for k=1:kM + r=R(k) + xarc(-r,r,2*r,2*r,Amin*64,dA*64) + e = gce();,e.line_style=3 + e.foreground=fcolor; + if k==kM + e.line_style=1; // solid outer arc + else + xstring(r*cosd(A)+w*dx, r*sind(A)+h*dy, Rtxt(k)) + e = gce(); + e.clip_state = "off"; + end + end + + // ANGULAR FRAME: + if nn<3, eA=10, else eA=30; end // adaptative angular sampling + an=linspace(Amin,Amin+dA,round(dA/eA)+1); + // avoiding 360 == 0 + if nn>2, tmp=find(abs(an-360)<eA/10); an(tmp)=[]; end + // Adjusting H-shifts of angular labels + tmp=xstringl(0,0,"360"); + w=tmp(3); h=tmp(4); + rL=rm*1.03; // Radius of angular labels + for k=an // draws and labels angular rays + xsegs([0;rm*cosd(k)],[0;rm*sind(k)]) + e = gce(); e.segs_color=fcolor; e.line_style=3; + xstring((rL+w/2)*cosd(k)-w/2, (rL+h/2)*sind(k)-h/2, string(k)) + e = gce(); + e.clip_state = "off"; + end + + a=gca(); + a.data_bounds=[rect(1:2);rect(3:4)] + a.margins=[0.07 0.07 0.12 0.07] + + drawnow() +endfunction diff --git a/modules/graphics/macros/projaff.bin b/modules/graphics/macros/projaff.bin Binary files differnew file mode 100755 index 000000000..c07425b64 --- /dev/null +++ b/modules/graphics/macros/projaff.bin diff --git a/modules/graphics/macros/projaff.sci b/modules/graphics/macros/projaff.sci new file mode 100755 index 000000000..175e24556 --- /dev/null +++ b/modules/graphics/macros/projaff.sci @@ -0,0 +1,32 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 1991 - INRIA - Serge Steer +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function d=projaff(x,y,pt) + // projaff - projection d'un point sur une droite + //%Syntaxe + // d=projaff(x,y,pt) + //%Parametres + // x: vecteur des abscisses des 2 points definissant la droite + // y: vecteur des ordonnes des 2 points definissant la droite + // pt: coordonnes du point a projeter [abscisses ordonnees] + //%Methode + //l'equation de la droite est : + //(y2-y1)*(x-x1)-(x2-x1)*(y-y1)=0 + //celle de la normale passant par le point: + //(x2-x1)*(x-xp)+(y2-y1)*(y-yp)=0 + // + //! + + if argn(2)<>3 then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "projaff", 3)); + end + + dx=x(2)-x(1);dy=y(2)-y(1) + m=[dy -dx;dx dy] + d=m\ [-x(2)*y(1)+x(1)*y(2);m(2,:)*[pt(1);pt(2)]] +endfunction diff --git a/modules/graphics/macros/rainbowcolormap.bin b/modules/graphics/macros/rainbowcolormap.bin Binary files differnew file mode 100755 index 000000000..457886b02 --- /dev/null +++ b/modules/graphics/macros/rainbowcolormap.bin diff --git a/modules/graphics/macros/rainbowcolormap.sci b/modules/graphics/macros/rainbowcolormap.sci new file mode 100755 index 000000000..1ecf3dc53 --- /dev/null +++ b/modules/graphics/macros/rainbowcolormap.sci @@ -0,0 +1,47 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Pierre MARECHAL <pierre.marechal@scilab.org> +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function cmap = rainbowcolormap(varargin) + + //rainbowcolormap : red through orange, yellow, green, blue to violet + + // Check number of input argument + if size(varargin)<>1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "rainbowcolormap", 1)); + end + n=varargin(1); + + // Check type of input argument + // Check if input argument is real + if typeof(n)<>"constant" | ~isreal(n) then + error(msprintf(gettext("%s: Wrong type for input argument #%d: a real scalar expected.\n"), "rainbowcolormap", 1)); + end + + // Check size of input argument + if size(n,"*")<>1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: a real scalar expected.\n"), "rainbowcolormap", 1)); + end + + if n==0 then + cmap = []; + return + end + + r = [ 0/10 1/10 2/10 3/10 4/10 5/10 6/10 7/10 8/10 9/10 10/10 ; 1 1 1 1/2 0 0 0 0 0 1/2 1]; + g = [ 0/10 1/10 2/10 3/10 4/10 5/10 6/10 7/10 8/10 9/10 10/10 ; 0 1/2 1 1 1 1 1 1/2 0 0 0]; + b = [ 0/10 1/10 2/10 3/10 4/10 5/10 6/10 7/10 8/10 9/10 10/10 ; 0 0 0 0 0 1/2 1 1 1 1 1]; + + d = 0.5/max(n,1); + + x = linspace(d,1-d,n) + cmap = [ interpln(r, x);... + interpln(g, x);... + interpln(b, x) ]'; + cmap = min(1, max(0 , cmap)) // normaly not necessary + +endfunction diff --git a/modules/graphics/macros/replot.bin b/modules/graphics/macros/replot.bin Binary files differnew file mode 100755 index 000000000..4a02143c8 --- /dev/null +++ b/modules/graphics/macros/replot.bin diff --git a/modules/graphics/macros/replot.sci b/modules/graphics/macros/replot.sci new file mode 100755 index 000000000..72da06f27 --- /dev/null +++ b/modules/graphics/macros/replot.sci @@ -0,0 +1,51 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// Copyright (C) 2013 - Samuel GOUGEON : extend to 3D + set of handles + skip with %nan + +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function replot(rect,handl) + // replots the graphic axes using rect as x and y (and z) bounds + // + + [lhs,rhs] = argn(0); + + if rhs < 1 then + msg = _("%s: Wrong number of input argument(s): %d or %d expected.\n") + error(msprintf(msg, "replot", 1, 2)); + end + + if rhs == 1 + a = gca(); + else + if (type(handl) == 9) + if and(handl.type == "Axes") + a = handl; + else + msg = _("%s: Input argument #%d must be a handle on an axis.\n") + error(msprintf(msg, "replot", 2)); + end + else + msg = _("%s: Wrong type for input argument #%d: Graphic handle expected.\n") + error(msprintf(msg, "replot", 2)); + end + end + if length(rect)==4 then + rect = [rect(1) rect(2) ; rect(3) rect(4)] + elseif length(rect)==6 + rect = [rect(1) rect(2) rect(3); rect(4) rect(5) rect(6)] + end + k = ~isnan(rect) + + for i = 1:length(a) + if length(rect)==4 then + a(i).data_bounds(k) = rect(k) + elseif length(rect)==6 & a(i).view=="3d" + a(i).data_bounds(k) = rect(k) + end + end +endfunction diff --git a/modules/graphics/macros/rgb2name.bin b/modules/graphics/macros/rgb2name.bin Binary files differnew file mode 100755 index 000000000..ca200ec8c --- /dev/null +++ b/modules/graphics/macros/rgb2name.bin diff --git a/modules/graphics/macros/rgb2name.sci b/modules/graphics/macros/rgb2name.sci new file mode 100755 index 000000000..32990e6f2 --- /dev/null +++ b/modules/graphics/macros/rgb2name.sci @@ -0,0 +1,1639 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function r=rgb2name(r,g,b) + + [lhs,rhs]=argn(0) + if rhs==1 then + if (type(r)<>1 & size(r,"*")<>3) then + error(msprintf(gettext("%s: Wrong type for input argument #%d: A vector of 3 integers expected.\n"),"rgb2name",1)); + end + b=r(3); g=r(2); r=r(1); + elseif rhs==3 then + if (type(r)<>1 | type(g)<>1 | type(b)<>1 | size(r,"*")<>1 | size(g,"*")<>1 | size(b,"*")<>1) then + error(msprintf(gettext("%s: Wrong type for input arguments #%d, #%d and #%d: Scalars expected.\n"),"rgb2name", 1, 2, 3)); + end + else + error(msprintf(gettext("%s: Wrong number of input arguments: %d or %d expected.\n"),"rgb2name",1,3)); + end + if (r>255 | r<0) then + error(msprintf(gettext("%s: Wrong value for input argument #%d: must be in the interval [%d, %d].\n"),"rgb2name",1,0,255)); + end + if (g>255 | g<0) then + error(msprintf(gettext("%s: Wrong value for input argument #%d: must be in the interval [%d, %d].\n"),"rgb2name",2,0,255)); + end + if (b>255 | b<0) then + error(msprintf(gettext("%s: Wrong value for input argument #%d: must be in the interval [%d, %d].\n"),"rgb2name",3,0,255)); + end + + names=[ + "scilab blue4" + "scilabblue4" + "scilab blue3" + "scilabblue3" + "scilab blue2" + "scilabblue2" + "scilab green4" + "scilabgreen4" + "scilab green3" + "scilabgreen3" + "scilab green2" + "scilabgreen2" + "scilab cyan4" + "scilabcyan4" + "scilab cyan3" + "scilabcyan3" + "scilab cyan2" + "scilabcyan2" + "scilab red4" + "scilabred4" + "scilab red3" + "scilabred3" + "scilab red2" + "scilabred2" + "scilab magenta4" + "scilabmagenta4" + "scilab magenta3" + "scilabmagenta3" + "scilab magenta2" + "scilabmagenta2" + "scilab brown4" + "scilabbrown4" + "scilab brown3" + "scilabbrown3" + "scilab brown2" + "scilabbrown2" + "scilab pink4" + "scilabpink4" + "scilab pink3" + "scilabpink3" + "scilab pink2" + "scilabpink2" + "scilab pink" + "scilabpink" + "snow" + "ghost white" + "ghostwhite" + "white smoke" + "whitesmoke" + "gainsboro" + "floral white" + "floralwhite" + "old lace" + "oldlace" + "linen" + "antique white" + "antiquewhite" + "papaya whip" + "papayawhip" + "blanched almond" + "blanchedalmond" + "bisque" + "peach puff" + "peachpuff" + "navajo white" + "navajowhite" + "moccasin" + "cornsilk" + "ivory" + "lemon chiffon" + "lemonchiffon" + "seashell" + "honeydew" + "mint cream" + "mintcream" + "azure" + "alice blue" + "aliceblue" + "lavender" + "lavender blush" + "lavenderblush" + "misty rose" + "mistyrose" + "white" + "black" + "dark slate gray" + "darkslategray" + "dark slate grey" + "darkslategrey" + "dim gray" + "dimgray" + "dim grey" + "dimgrey" + "slate gray" + "slategray" + "slate grey" + "slategrey" + "light slate gray" + "lightslategray" + "light slate grey" + "lightslategrey" + "gray" + "grey" + "light grey" + "lightgrey" + "light gray" + "lightgray" + "midnight blue" + "midnightblue" + "navy" + "navy blue" + "navyblue" + "cornflower blue" + "cornflowerblue" + "dark slate blue" + "darkslateblue" + "slate blue" + "slateblue" + "medium slate blue" + "mediumslateblue" + "light slate blue" + "lightslateblue" + "medium blue" + "mediumblue" + "royal blue" + "royalblue" + "blue" + "dodger blue" + "dodgerblue" + "deep sky blue" + "deepskyblue" + "sky blue" + "skyblue" + "light sky blue" + "lightskyblue" + "steel blue" + "steelblue" + "light steel blue" + "lightsteelblue" + "light blue" + "lightblue" + "powder blue" + "powderblue" + "pale turquoise" + "paleturquoise" + "dark turquoise" + "darkturquoise" + "medium turquoise" + "mediumturquoise" + "turquoise" + "cyan" + "light cyan" + "lightcyan" + "cadet blue" + "cadetblue" + "medium aquamarine" + "mediumaquamarine" + "aquamarine" + "dark green" + "darkgreen" + "dark olive green" + "darkolivegreen" + "dark sea green" + "darkseagreen" + "sea green" + "seagreen" + "medium sea green" + "mediumseagreen" + "light sea green" + "lightseagreen" + "pale green" + "palegreen" + "spring green" + "springgreen" + "lawn green" + "lawngreen" + "green" + "chartreuse" + "medium spring green" + "mediumspringgreen" + "green yellow" + "greenyellow" + "lime green" + "limegreen" + "yellow green" + "yellowgreen" + "forest green" + "forestgreen" + "olive drab" + "olivedrab" + "dark khaki" + "darkkhaki" + "khaki" + "pale goldenrod" + "palegoldenrod" + "light goldenrod yellow" + "lightgoldenrodyellow" + "light yellow" + "lightyellow" + "yellow" + "gold" + "light goldenrod" + "lightgoldenrod" + "goldenrod" + "dark goldenrod" + "darkgoldenrod" + "rosy brown" + "rosybrown" + "indian red" + "indianred" + "saddle brown" + "saddlebrown" + "sienna" + "peru" + "burlywood" + "beige" + "wheat" + "sandy brown" + "sandybrown" + "tan" + "chocolate" + "firebrick" + "brown" + "dark salmon" + "darksalmon" + "salmon" + "light salmon" + "lightsalmon" + "orange" + "dark orange" + "darkorange" + "coral" + "light coral" + "lightcoral" + "tomato" + "orange red" + "orangered" + "red" + "hot pink" + "hotpink" + "deep pink" + "deeppink" + "pink" + "light pink" + "lightpink" + "pale violet red" + "palevioletred" + "maroon" + "medium violet red" + "mediumvioletred" + "violet red" + "violetred" + "magenta" + "violet" + "plum" + "orchid" + "medium orchid" + "mediumorchid" + "dark orchid" + "darkorchid" + "dark violet" + "darkviolet" + "blue violet" + "blueviolet" + "purple" + "medium purple" + "mediumpurple" + "thistle" + "snow1" + "snow2" + "snow3" + "snow4" + "seashell1" + "seashell2" + "seashell3" + "seashell4" + "antiquewhite1" + "antiquewhite2" + "antiquewhite3" + "antiquewhite4" + "bisque1" + "bisque2" + "bisque3" + "bisque4" + "peachpuff1" + "peachpuff2" + "peachpuff3" + "peachpuff4" + "navajowhite1" + "navajowhite2" + "navajowhite3" + "navajowhite4" + "lemonchiffon1" + "lemonchiffon2" + "lemonchiffon3" + "lemonchiffon4" + "cornsilk1" + "cornsilk2" + "cornsilk3" + "cornsilk4" + "ivory1" + "ivory2" + "ivory3" + "ivory4" + "honeydew1" + "honeydew2" + "honeydew3" + "honeydew4" + "lavenderblush1" + "lavenderblush2" + "lavenderblush3" + "lavenderblush4" + "mistyrose1" + "mistyrose2" + "mistyrose3" + "mistyrose4" + "azure1" + "azure2" + "azure3" + "azure4" + "slateblue1" + "slateblue2" + "slateblue3" + "slateblue4" + "royalblue1" + "royalblue2" + "royalblue3" + "royalblue4" + "blue1" + "blue2" + "blue3" + "blue4" + "dodgerblue1" + "dodgerblue2" + "dodgerblue3" + "dodgerblue4" + "steelblue1" + "steelblue2" + "steelblue3" + "steelblue4" + "deepskyblue1" + "deepskyblue2" + "deepskyblue3" + "deepskyblue4" + "skyblue1" + "skyblue2" + "skyblue3" + "skyblue4" + "lightskyblue1" + "lightskyblue2" + "lightskyblue3" + "lightskyblue4" + "slategray1" + "slategray2" + "slategray3" + "slategray4" + "lightsteelblue1" + "lightsteelblue2" + "lightsteelblue3" + "lightsteelblue4" + "lightblue1" + "lightblue2" + "lightblue3" + "lightblue4" + "lightcyan1" + "lightcyan2" + "lightcyan3" + "lightcyan4" + "paleturquoise1" + "paleturquoise2" + "paleturquoise3" + "paleturquoise4" + "cadetblue1" + "cadetblue2" + "cadetblue3" + "cadetblue4" + "turquoise1" + "turquoise2" + "turquoise3" + "turquoise4" + "cyan1" + "cyan2" + "cyan3" + "cyan4" + "darkslategray1" + "darkslategray2" + "darkslategray3" + "darkslategray4" + "aquamarine1" + "aquamarine2" + "aquamarine3" + "aquamarine4" + "darkseagreen1" + "darkseagreen2" + "darkseagreen3" + "darkseagreen4" + "seagreen1" + "seagreen2" + "seagreen3" + "seagreen4" + "palegreen1" + "palegreen2" + "palegreen3" + "palegreen4" + "springgreen1" + "springgreen2" + "springgreen3" + "springgreen4" + "green1" + "green2" + "green3" + "green4" + "chartreuse1" + "chartreuse2" + "chartreuse3" + "chartreuse4" + "olivedrab1" + "olivedrab2" + "olivedrab3" + "olivedrab4" + "darkolivegreen1" + "darkolivegreen2" + "darkolivegreen3" + "darkolivegreen4" + "khaki1" + "khaki2" + "khaki3" + "khaki4" + "lightgoldenrod1" + "lightgoldenrod2" + "lightgoldenrod3" + "lightgoldenrod4" + "lightyellow1" + "lightyellow2" + "lightyellow3" + "lightyellow4" + "yellow1" + "yellow2" + "yellow3" + "yellow4" + "gold1" + "gold2" + "gold3" + "gold4" + "goldenrod1" + "goldenrod2" + "goldenrod3" + "goldenrod4" + "darkgoldenrod1" + "darkgoldenrod2" + "darkgoldenrod3" + "darkgoldenrod4" + "rosybrown1" + "rosybrown2" + "rosybrown3" + "rosybrown4" + "indianred1" + "indianred2" + "indianred3" + "indianred4" + "sienna1" + "sienna2" + "sienna3" + "sienna4" + "burlywood1" + "burlywood2" + "burlywood3" + "burlywood4" + "wheat1" + "wheat2" + "wheat3" + "wheat4" + "tan1" + "tan2" + "tan3" + "tan4" + "chocolate1" + "chocolate2" + "chocolate3" + "chocolate4" + "firebrick1" + "firebrick2" + "firebrick3" + "firebrick4" + "brown1" + "brown2" + "brown3" + "brown4" + "salmon1" + "salmon2" + "salmon3" + "salmon4" + "lightsalmon1" + "lightsalmon2" + "lightsalmon3" + "lightsalmon4" + "orange1" + "orange2" + "orange3" + "orange4" + "darkorange1" + "darkorange2" + "darkorange3" + "darkorange4" + "coral1" + "coral2" + "coral3" + "coral4" + "tomato1" + "tomato2" + "tomato3" + "tomato4" + "orangered1" + "orangered2" + "orangered3" + "orangered4" + "red1" + "red2" + "red3" + "red4" + "deeppink1" + "deeppink2" + "deeppink3" + "deeppink4" + "hotpink1" + "hotpink2" + "hotpink3" + "hotpink4" + "pink1" + "pink2" + "pink3" + "pink4" + "lightpink1" + "lightpink2" + "lightpink3" + "lightpink4" + "palevioletred1" + "palevioletred2" + "palevioletred3" + "palevioletred4" + "maroon1" + "maroon2" + "maroon3" + "maroon4" + "violetred1" + "violetred2" + "violetred3" + "violetred4" + "magenta1" + "magenta2" + "magenta3" + "magenta4" + "orchid1" + "orchid2" + "orchid3" + "orchid4" + "plum1" + "plum2" + "plum3" + "plum4" + "mediumorchid1" + "mediumorchid2" + "mediumorchid3" + "mediumorchid4" + "darkorchid1" + "darkorchid2" + "darkorchid3" + "darkorchid4" + "purple1" + "purple2" + "purple3" + "purple4" + "mediumpurple1" + "mediumpurple2" + "mediumpurple3" + "mediumpurple4" + "thistle1" + "thistle2" + "thistle3" + "thistle4" + "gray0" + "grey0" + "gray1" + "grey1" + "gray2" + "grey2" + "gray3" + "grey3" + "gray4" + "grey4" + "gray5" + "grey5" + "gray6" + "grey6" + "gray7" + "grey7" + "gray8" + "grey8" + "gray9" + "grey9" + "gray10" + "grey10" + "gray11" + "grey11" + "gray12" + "grey12" + "gray13" + "grey13" + "gray14" + "grey14" + "gray15" + "grey15" + "gray16" + "grey16" + "gray17" + "grey17" + "gray18" + "grey18" + "gray19" + "grey19" + "gray20" + "grey20" + "gray21" + "grey21" + "gray22" + "grey22" + "gray23" + "grey23" + "gray24" + "grey24" + "gray25" + "grey25" + "gray26" + "grey26" + "gray27" + "grey27" + "gray28" + "grey28" + "gray29" + "grey29" + "gray30" + "grey30" + "gray31" + "grey31" + "gray32" + "grey32" + "gray33" + "grey33" + "gray34" + "grey34" + "gray35" + "grey35" + "gray36" + "grey36" + "gray37" + "grey37" + "gray38" + "grey38" + "gray39" + "grey39" + "gray40" + "grey40" + "gray41" + "grey41" + "gray42" + "grey42" + "gray43" + "grey43" + "gray44" + "grey44" + "gray45" + "grey45" + "gray46" + "grey46" + "gray47" + "grey47" + "gray48" + "grey48" + "gray49" + "grey49" + "gray50" + "grey50" + "gray51" + "grey51" + "gray52" + "grey52" + "gray53" + "grey53" + "gray54" + "grey54" + "gray55" + "grey55" + "gray56" + "grey56" + "gray57" + "grey57" + "gray58" + "grey58" + "gray59" + "grey59" + "gray60" + "grey60" + "gray61" + "grey61" + "gray62" + "grey62" + "gray63" + "grey63" + "gray64" + "grey64" + "gray65" + "grey65" + "gray66" + "grey66" + "gray67" + "grey67" + "gray68" + "grey68" + "gray69" + "grey69" + "gray70" + "grey70" + "gray71" + "grey71" + "gray72" + "grey72" + "gray73" + "grey73" + "gray74" + "grey74" + "gray75" + "grey75" + "gray76" + "grey76" + "gray77" + "grey77" + "gray78" + "grey78" + "gray79" + "grey79" + "gray80" + "grey80" + "gray81" + "grey81" + "gray82" + "grey82" + "gray83" + "grey83" + "gray84" + "grey84" + "gray85" + "grey85" + "gray86" + "grey86" + "gray87" + "grey87" + "gray88" + "grey88" + "gray89" + "grey89" + "gray90" + "grey90" + "gray91" + "grey91" + "gray92" + "grey92" + "gray93" + "grey93" + "gray94" + "grey94" + "gray95" + "grey95" + "gray96" + "grey96" + "gray97" + "grey97" + "gray98" + "grey98" + "gray99" + "grey99" + "gray100" + "grey100" + "dark grey" + "darkgrey" + "dark gray" + "darkgray" + "dark blue" + "darkblue" + "dark cyan" + "darkcyan" + "dark magenta" + "darkmagenta" + "dark red" + "darkred" + "light green" + "lightgreen" + ]; + + rgb=[ + 0 0 144 + 0 0 144 + 0 0 176 + 0 0 176 + 0 0 208 + 0 0 208 + 0 144 0 + 0 144 0 + 0 176 0 + 0 176 0 + 0 208 0 + 0 208 0 + 0 144 144 + 0 144 144 + 0 176 176 + 0 176 176 + 0 208 208 + 0 208 208 + 144 0 0 + 144 0 0 + 176 0 0 + 176 0 0 + 208 0 0 + 208 0 0 + 144 0 144 + 144 0 144 + 176 0 176 + 176 0 176 + 208 0 208 + 208 0 208 + 128 48 0 + 128 48 0 + 160 64 0 + 160 64 0 + 192 96 0 + 192 96 0 + 255 128 128 + 255 128 128 + 255 160 160 + 255 160 160 + 255 192 192 + 255 192 192 + 255 224 224 + 255 224 224 + 255 250 250 + 248 248 255 + 248 248 255 + 245 245 245 + 245 245 245 + 220 220 220 + 255 250 240 + 255 250 240 + 253 245 230 + 253 245 230 + 250 240 230 + 250 235 215 + 250 235 215 + 255 239 213 + 255 239 213 + 255 235 205 + 255 235 205 + 255 228 196 + 255 218 185 + 255 218 185 + 255 222 173 + 255 222 173 + 255 228 181 + 255 248 220 + 255 255 240 + 255 250 205 + 255 250 205 + 255 245 238 + 240 255 240 + 245 255 250 + 245 255 250 + 240 255 255 + 240 248 255 + 240 248 255 + 230 230 250 + 255 240 245 + 255 240 245 + 255 228 225 + 255 228 225 + 255 255 255 + 0 0 0 + 47 79 79 + 47 79 79 + 47 79 79 + 47 79 79 + 105 105 105 + 105 105 105 + 105 105 105 + 105 105 105 + 112 128 144 + 112 128 144 + 112 128 144 + 112 128 144 + 119 136 153 + 119 136 153 + 119 136 153 + 119 136 153 + 190 190 190 + 190 190 190 + 211 211 211 + 211 211 211 + 211 211 211 + 211 211 211 + 25 25 112 + 25 25 112 + 0 0 128 + 0 0 128 + 0 0 128 + 100 149 237 + 100 149 237 + 72 61 139 + 72 61 139 + 106 90 205 + 106 90 205 + 123 104 238 + 123 104 238 + 132 112 255 + 132 112 255 + 0 0 205 + 0 0 205 + 65 105 225 + 65 105 225 + 0 0 255 + 30 144 255 + 30 144 255 + 0 191 255 + 0 191 255 + 135 206 235 + 135 206 235 + 135 206 250 + 135 206 250 + 70 130 180 + 70 130 180 + 176 196 222 + 176 196 222 + 173 216 230 + 173 216 230 + 176 224 230 + 176 224 230 + 175 238 238 + 175 238 238 + 0 206 209 + 0 206 209 + 72 209 204 + 72 209 204 + 64 224 208 + 0 255 255 + 224 255 255 + 224 255 255 + 95 158 160 + 95 158 160 + 102 205 170 + 102 205 170 + 127 255 212 + 0 100 0 + 0 100 0 + 85 107 47 + 85 107 47 + 143 188 143 + 143 188 143 + 46 139 87 + 46 139 87 + 60 179 113 + 60 179 113 + 32 178 170 + 32 178 170 + 152 251 152 + 152 251 152 + 0 255 127 + 0 255 127 + 124 252 0 + 124 252 0 + 0 255 0 + 127 255 0 + 0 250 154 + 0 250 154 + 173 255 47 + 173 255 47 + 50 205 50 + 50 205 50 + 154 205 50 + 154 205 50 + 34 139 34 + 34 139 34 + 107 142 35 + 107 142 35 + 189 183 107 + 189 183 107 + 240 230 140 + 238 232 170 + 238 232 170 + 250 250 210 + 250 250 210 + 255 255 224 + 255 255 224 + 255 255 0 + 255 215 0 + 238 221 130 + 238 221 130 + 218 165 32 + 184 134 11 + 184 134 11 + 188 143 143 + 188 143 143 + 205 92 92 + 205 92 92 + 139 69 19 + 139 69 19 + 160 82 45 + 205 133 63 + 222 184 135 + 245 245 220 + 245 222 179 + 244 164 96 + 244 164 96 + 210 180 140 + 210 105 30 + 178 34 34 + 165 42 42 + 233 150 122 + 233 150 122 + 250 128 114 + 255 160 122 + 255 160 122 + 255 165 0 + 255 140 0 + 255 140 0 + 255 127 80 + 240 128 128 + 240 128 128 + 255 99 71 + 255 69 0 + 255 69 0 + 255 0 0 + 255 105 180 + 255 105 180 + 255 20 147 + 255 20 147 + 255 192 203 + 255 182 193 + 255 182 193 + 219 112 147 + 219 112 147 + 176 48 96 + 199 21 133 + 199 21 133 + 208 32 144 + 208 32 144 + 255 0 255 + 238 130 238 + 221 160 221 + 218 112 214 + 186 85 211 + 186 85 211 + 153 50 204 + 153 50 204 + 148 0 211 + 148 0 211 + 138 43 226 + 138 43 226 + 160 32 240 + 147 112 219 + 147 112 219 + 216 191 216 + 255 250 250 + 238 233 233 + 205 201 201 + 139 137 137 + 255 245 238 + 238 229 222 + 205 197 191 + 139 134 130 + 255 239 219 + 238 223 204 + 205 192 176 + 139 131 120 + 255 228 196 + 238 213 183 + 205 183 158 + 139 125 107 + 255 218 185 + 238 203 173 + 205 175 149 + 139 119 101 + 255 222 173 + 238 207 161 + 205 179 139 + 139 121 94 + 255 250 205 + 238 233 191 + 205 201 165 + 139 137 112 + 255 248 220 + 238 232 205 + 205 200 177 + 139 136 120 + 255 255 240 + 238 238 224 + 205 205 193 + 139 139 131 + 240 255 240 + 224 238 224 + 193 205 193 + 131 139 131 + 255 240 245 + 238 224 229 + 205 193 197 + 139 131 134 + 255 228 225 + 238 213 210 + 205 183 181 + 139 125 123 + 240 255 255 + 224 238 238 + 193 205 205 + 131 139 139 + 131 111 255 + 122 103 238 + 105 89 205 + 71 60 139 + 72 118 255 + 67 110 238 + 58 95 205 + 39 64 139 + 0 0 255 + 0 0 238 + 0 0 205 + 0 0 139 + 30 144 255 + 28 134 238 + 24 116 205 + 16 78 139 + 99 184 255 + 92 172 238 + 79 148 205 + 54 100 139 + 0 191 255 + 0 178 238 + 0 154 205 + 0 104 139 + 135 206 255 + 126 192 238 + 108 166 205 + 74 112 139 + 176 226 255 + 164 211 238 + 141 182 205 + 96 123 139 + 198 226 255 + 185 211 238 + 159 182 205 + 108 123 139 + 202 225 255 + 188 210 238 + 162 181 205 + 110 123 139 + 191 239 255 + 178 223 238 + 154 192 205 + 104 131 139 + 224 255 255 + 209 238 238 + 180 205 205 + 122 139 139 + 187 255 255 + 174 238 238 + 150 205 205 + 102 139 139 + 152 245 255 + 142 229 238 + 122 197 205 + 83 134 139 + 0 245 255 + 0 229 238 + 0 197 205 + 0 134 139 + 0 255 255 + 0 238 238 + 0 205 205 + 0 139 139 + 151 255 255 + 141 238 238 + 121 205 205 + 82 139 139 + 127 255 212 + 118 238 198 + 102 205 170 + 69 139 116 + 193 255 193 + 180 238 180 + 155 205 155 + 105 139 105 + 84 255 159 + 78 238 148 + 67 205 128 + 46 139 87 + 154 255 154 + 144 238 144 + 124 205 124 + 84 139 84 + 0 255 127 + 0 238 118 + 0 205 102 + 0 139 69 + 0 255 0 + 0 238 0 + 0 205 0 + 0 139 0 + 127 255 0 + 118 238 0 + 102 205 0 + 69 139 0 + 192 255 62 + 179 238 58 + 154 205 50 + 105 139 34 + 202 255 112 + 188 238 104 + 162 205 90 + 110 139 61 + 255 246 143 + 238 230 133 + 205 198 115 + 139 134 78 + 255 236 139 + 238 220 130 + 205 190 112 + 139 129 76 + 255 255 224 + 238 238 209 + 205 205 180 + 139 139 122 + 255 255 0 + 238 238 0 + 205 205 0 + 139 139 0 + 255 215 0 + 238 201 0 + 205 173 0 + 139 117 0 + 255 193 37 + 238 180 34 + 205 155 29 + 139 105 20 + 255 185 15 + 238 173 14 + 205 149 12 + 139 101 8 + 255 193 193 + 238 180 180 + 205 155 155 + 139 105 105 + 255 106 106 + 238 99 99 + 205 85 85 + 139 58 58 + 255 130 71 + 238 121 66 + 205 104 57 + 139 71 38 + 255 211 155 + 238 197 145 + 205 170 125 + 139 115 85 + 255 231 186 + 238 216 174 + 205 186 150 + 139 126 102 + 255 165 79 + 238 154 73 + 205 133 63 + 139 90 43 + 255 127 36 + 238 118 33 + 205 102 29 + 139 69 19 + 255 48 48 + 238 44 44 + 205 38 38 + 139 26 26 + 255 64 64 + 238 59 59 + 205 51 51 + 139 35 35 + 255 140 105 + 238 130 98 + 205 112 84 + 139 76 57 + 255 160 122 + 238 149 114 + 205 129 98 + 139 87 66 + 255 165 0 + 238 154 0 + 205 133 0 + 139 90 0 + 255 127 0 + 238 118 0 + 205 102 0 + 139 69 0 + 255 114 86 + 238 106 80 + 205 91 69 + 139 62 47 + 255 99 71 + 238 92 66 + 205 79 57 + 139 54 38 + 255 69 0 + 238 64 0 + 205 55 0 + 139 37 0 + 255 0 0 + 238 0 0 + 205 0 0 + 139 0 0 + 255 20 147 + 238 18 137 + 205 16 118 + 139 10 80 + 255 110 180 + 238 106 167 + 205 96 144 + 139 58 98 + 255 181 197 + 238 169 184 + 205 145 158 + 139 99 108 + 255 174 185 + 238 162 173 + 205 140 149 + 139 95 101 + 255 130 171 + 238 121 159 + 205 104 137 + 139 71 93 + 255 52 179 + 238 48 167 + 205 41 144 + 139 28 98 + 255 62 150 + 238 58 140 + 205 50 120 + 139 34 82 + 255 0 255 + 238 0 238 + 205 0 205 + 139 0 139 + 255 131 250 + 238 122 233 + 205 105 201 + 139 71 137 + 255 187 255 + 238 174 238 + 205 150 205 + 139 102 139 + 224 102 255 + 209 95 238 + 180 82 205 + 122 55 139 + 191 62 255 + 178 58 238 + 154 50 205 + 104 34 139 + 155 48 255 + 145 44 238 + 125 38 205 + 85 26 139 + 171 130 255 + 159 121 238 + 137 104 205 + 93 71 139 + 255 225 255 + 238 210 238 + 205 181 205 + 139 123 139 + 0 0 0 + 0 0 0 + 3 3 3 + 3 3 3 + 5 5 5 + 5 5 5 + 8 8 8 + 8 8 8 + 10 10 10 + 10 10 10 + 13 13 13 + 13 13 13 + 15 15 15 + 15 15 15 + 18 18 18 + 18 18 18 + 20 20 20 + 20 20 20 + 23 23 23 + 23 23 23 + 26 26 26 + 26 26 26 + 28 28 28 + 28 28 28 + 31 31 31 + 31 31 31 + 33 33 33 + 33 33 33 + 36 36 36 + 36 36 36 + 38 38 38 + 38 38 38 + 41 41 41 + 41 41 41 + 43 43 43 + 43 43 43 + 46 46 46 + 46 46 46 + 48 48 48 + 48 48 48 + 51 51 51 + 51 51 51 + 54 54 54 + 54 54 54 + 56 56 56 + 56 56 56 + 59 59 59 + 59 59 59 + 61 61 61 + 61 61 61 + 64 64 64 + 64 64 64 + 66 66 66 + 66 66 66 + 69 69 69 + 69 69 69 + 71 71 71 + 71 71 71 + 74 74 74 + 74 74 74 + 77 77 77 + 77 77 77 + 79 79 79 + 79 79 79 + 82 82 82 + 82 82 82 + 84 84 84 + 84 84 84 + 87 87 87 + 87 87 87 + 89 89 89 + 89 89 89 + 92 92 92 + 92 92 92 + 94 94 94 + 94 94 94 + 97 97 97 + 97 97 97 + 99 99 99 + 99 99 99 + 102 102 102 + 102 102 102 + 105 105 105 + 105 105 105 + 107 107 107 + 107 107 107 + 110 110 110 + 110 110 110 + 112 112 112 + 112 112 112 + 115 115 115 + 115 115 115 + 117 117 117 + 117 117 117 + 120 120 120 + 120 120 120 + 122 122 122 + 122 122 122 + 125 125 125 + 125 125 125 + 127 127 127 + 127 127 127 + 130 130 130 + 130 130 130 + 133 133 133 + 133 133 133 + 135 135 135 + 135 135 135 + 138 138 138 + 138 138 138 + 140 140 140 + 140 140 140 + 143 143 143 + 143 143 143 + 145 145 145 + 145 145 145 + 148 148 148 + 148 148 148 + 150 150 150 + 150 150 150 + 153 153 153 + 153 153 153 + 156 156 156 + 156 156 156 + 158 158 158 + 158 158 158 + 161 161 161 + 161 161 161 + 163 163 163 + 163 163 163 + 166 166 166 + 166 166 166 + 168 168 168 + 168 168 168 + 171 171 171 + 171 171 171 + 173 173 173 + 173 173 173 + 176 176 176 + 176 176 176 + 179 179 179 + 179 179 179 + 181 181 181 + 181 181 181 + 184 184 184 + 184 184 184 + 186 186 186 + 186 186 186 + 189 189 189 + 189 189 189 + 191 191 191 + 191 191 191 + 194 194 194 + 194 194 194 + 196 196 196 + 196 196 196 + 199 199 199 + 199 199 199 + 201 201 201 + 201 201 201 + 204 204 204 + 204 204 204 + 207 207 207 + 207 207 207 + 209 209 209 + 209 209 209 + 212 212 212 + 212 212 212 + 214 214 214 + 214 214 214 + 217 217 217 + 217 217 217 + 219 219 219 + 219 219 219 + 222 222 222 + 222 222 222 + 224 224 224 + 224 224 224 + 227 227 227 + 227 227 227 + 229 229 229 + 229 229 229 + 232 232 232 + 232 232 232 + 235 235 235 + 235 235 235 + 237 237 237 + 237 237 237 + 240 240 240 + 240 240 240 + 242 242 242 + 242 242 242 + 245 245 245 + 245 245 245 + 247 247 247 + 247 247 247 + 250 250 250 + 250 250 250 + 252 252 252 + 252 252 252 + 255 255 255 + 255 255 255 + 169 169 169 + 169 169 169 + 169 169 169 + 169 169 169 + 0 0 139 + 0 0 139 + 0 139 139 + 0 139 139 + 139 0 139 + 139 0 139 + 139 0 0 + 139 0 0 + 144 238 144 + 144 238 144 + ]; + + k=find(rgb(:,1)==r & rgb(:,2)==g & rgb(:, 3)==b) + if k==[] then + r=[]; + else + r=names(k); + end + +endfunction diff --git a/modules/graphics/macros/rotate.bin b/modules/graphics/macros/rotate.bin Binary files differnew file mode 100755 index 000000000..23761bf73 --- /dev/null +++ b/modules/graphics/macros/rotate.bin diff --git a/modules/graphics/macros/rotate.sci b/modules/graphics/macros/rotate.sci new file mode 100755 index 000000000..3f619414a --- /dev/null +++ b/modules/graphics/macros/rotate.sci @@ -0,0 +1,31 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [xy]=rotate(xy,teta,orig) + // effectue une rotation + // + // xy : matrice a deux lignes + // teta : angle en radian , 0 si omis + // orig : centre de la rotation, <0;0> si omis + //! + [lhs,rhs]=argn(0) + select rhs + case 2 then orig=[0;0]; + case 3 then orig=matrix(orig,2,1); + else error(msprintf(gettext("%s: Wrong number of input argument(s): %d to %d expected."), "scaling", 2, 3)); + end; + // + [m,n]=size(xy) + if m<>2 then + error(msprintf(gettext("%s: Wrong size for input argument ''%s'': A vector of size %d expected.\n"), "rotate", "xy", 2)); + end + // + xy=xy-orig*ones(1,n) + c=cos(teta),s=sin(teta) + xy=[c,-s ; s,c]*xy+orig*ones(1,n) +endfunction diff --git a/modules/graphics/macros/sca.bin b/modules/graphics/macros/sca.bin Binary files differnew file mode 100755 index 000000000..6d3c2c3bf --- /dev/null +++ b/modules/graphics/macros/sca.bin diff --git a/modules/graphics/macros/sca.sci b/modules/graphics/macros/sca.sci new file mode 100755 index 000000000..f1ec0d495 --- /dev/null +++ b/modules/graphics/macros/sca.sci @@ -0,0 +1,32 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [a]=sca(h) + //set default axes, h must be a handle + + [lhs,rhs] = argn(0); + + if rhs <> 1 then + error(msprintf(gettext("%s: Wrong number of input arguments: %d expected.\n"), "sca",1)); + return; + end + + if (type(h) <> 9) | (h.type <> "Axes") then + error(msprintf(gettext("%s: Wrong type for input argument #%d: An ''%s'' handle expected.\n"), "sca",1, "Axes")); + return; + end + + if (size(h) <> [1,1]) then + error(msprintf(gettext("%s: Wrong size for input argument #%d: An ''%s'' handle expected.\n"), "sca",1, "Axes")); + return; + end + + set("current_axes", h); + a=get("current_axes"); + +endfunction diff --git a/modules/graphics/macros/scaling.bin b/modules/graphics/macros/scaling.bin Binary files differnew file mode 100755 index 000000000..3181a6edd --- /dev/null +++ b/modules/graphics/macros/scaling.bin diff --git a/modules/graphics/macros/scaling.sci b/modules/graphics/macros/scaling.sci new file mode 100755 index 000000000..5542dfa2d --- /dev/null +++ b/modules/graphics/macros/scaling.sci @@ -0,0 +1,29 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// Copyright (C) 2010 - DIGITEO - Manuel Juliachs +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [xy]=scaling(xy,scalingFactor,orig) + // xy=xy*scalingFactor+orig + // + // xy : matrix with 2 rows + // scalingFactor : scaling factor + // orig : origin, [0;0] if omitted + //! + [lhs,rhs]=argn(0) + select rhs + case 2 then orig=[0;0]; + case 3 then orig=matrix(orig,2,1); + else error(msprintf(gettext("%s: Wrong number of input argument(s): %d to %d expected."), "scaling", 2, 3)); + end; + // + [m,n]=size(xy) + if m<>2 then error("xy must be a vector with 2 rows [x;y]"),end + // + xy=xy-orig*ones(1,n) + xy=scalingFactor*xy+orig*ones(1,n) +endfunction diff --git a/modules/graphics/macros/scf.bin b/modules/graphics/macros/scf.bin Binary files differnew file mode 100755 index 000000000..8393dbee5 --- /dev/null +++ b/modules/graphics/macros/scf.bin diff --git a/modules/graphics/macros/scf.sci b/modules/graphics/macros/scf.sci new file mode 100755 index 000000000..2473e9269 --- /dev/null +++ b/modules/graphics/macros/scf.sci @@ -0,0 +1,23 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [f]=scf(h) + //set default figure, h may be a handle or a figure_id + // (small correction to set up win number 0 when no + // gr window is opened, Bruno 22 nov 2004) + if argn(2)<1 then + num=winsid() + if num == [] then + h = 0 + else + h = max(num)+1 + end + end + set("current_figure",h); + f=get("current_figure"); +endfunction diff --git a/modules/graphics/macros/sda.bin b/modules/graphics/macros/sda.bin Binary files differnew file mode 100755 index 000000000..9698e7d86 --- /dev/null +++ b/modules/graphics/macros/sda.bin diff --git a/modules/graphics/macros/sda.sci b/modules/graphics/macros/sda.sci new file mode 100755 index 000000000..49b8fa7eb --- /dev/null +++ b/modules/graphics/macros/sda.sci @@ -0,0 +1,12 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [a]=sda() + a=get("default_axes"); + set(a,"default_values",1); +endfunction diff --git a/modules/graphics/macros/sdf.bin b/modules/graphics/macros/sdf.bin Binary files differnew file mode 100755 index 000000000..dd2a1978d --- /dev/null +++ b/modules/graphics/macros/sdf.bin diff --git a/modules/graphics/macros/sdf.sci b/modules/graphics/macros/sdf.sci new file mode 100755 index 000000000..81656536a --- /dev/null +++ b/modules/graphics/macros/sdf.sci @@ -0,0 +1,12 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [f]=sdf() + f=get("default_figure"); + set(f,"default_values",1); +endfunction diff --git a/modules/graphics/macros/secto3d.bin b/modules/graphics/macros/secto3d.bin Binary files differnew file mode 100755 index 000000000..03f8de3d5 --- /dev/null +++ b/modules/graphics/macros/secto3d.bin diff --git a/modules/graphics/macros/secto3d.sci b/modules/graphics/macros/secto3d.sci new file mode 100755 index 000000000..b73b90b41 --- /dev/null +++ b/modules/graphics/macros/secto3d.sci @@ -0,0 +1,62 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 1991 - INRIA - Serge Steer +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [m,x]=secto3d(seclist,npas) + //Etant donnee une surface 3D decrite par une liste (seclist) de sections + // dans le plan (x,z), [m [,x]]=secto3d(seclist [,npas]) retourne une + // matrice m contenant une discretisation reguliere de la surface: + // la i-ieme ligne de la matrice m correspond a la i-ieme section, + // la j-ieme colonne de m correspondant a l'abscisse x(j). + //Chaque section seclist(i) est decrite par une matrice a 2 lignes, + // correspondants respectivement aux coordonnees selon l'axe des x et des z. + //%methode + // Il est tout d'abord calcule les bornes extremales xmin,xmax sur + // l'axe des x pour l'ensemble des sections, l'intervalle [xmin,xmax] + // est ensuite decoupe en npas egaux, chaque section est ensuite interpolee + // lineairement en chaque point de cette discretisation. + // + // si npas est omis il est par defaut pris egal au nombre de sections. + //%autre syntaxe + // [m]=secto3d(seclist ,x) dans ce cas le vecteur x sera pris comme decoupage + // de l'axe des x pour l'ensemble des sections + //%voir aussi + // la macro plot3d + //! + + + [lhs,rhs]=argn(0) + + if and(argn(2)<>[1 2]) then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d or %d expected.\n"), "secto3d", 1, 2)); + end + + n=size(seclist) + // + if rhs<2 then npas=n,end + if prod(size(npas))==1 then + sec=seclist(1);sec=sec(1,:) + xmax=max(sec);xmin=min(sec) + for k=2:n + sec=seclist(k);sec=sec(1,:) + xmax=max(xmax,max(sec)) + xmin=min(xmin,min(sec)) + end + pas=(xmax-xmin)/npas + x=[xmin-pas xmin:pas:xmax xmax+pas] + else + x=npas + end + nx=prod(size(x)) + m(n,nx)=0; + for k=1:n + sec=seclist(k) + [ms,ns]=size(sec) + sec=[[x(1);sec(2,1)],sec,[x(nx);sec(2,ns)]] + m(k,:)=interpln(sec,x); + end +endfunction diff --git a/modules/graphics/macros/setDefaultColor.bin b/modules/graphics/macros/setDefaultColor.bin Binary files differnew file mode 100755 index 000000000..c93d2fea4 --- /dev/null +++ b/modules/graphics/macros/setDefaultColor.bin diff --git a/modules/graphics/macros/setDefaultColor.sci b/modules/graphics/macros/setDefaultColor.sci new file mode 100755 index 000000000..1987788e1 --- /dev/null +++ b/modules/graphics/macros/setDefaultColor.sci @@ -0,0 +1,40 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2004-2006 - INRIA - Fabrice Leray +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [Color,CurColor]=setDefaultColor(CurColor) + + // Adds a quadruple to the list of elementary plots to do + + MAXCOL = 8; + + ColorTab=[0 0 1.0000; + 0 0.5000 0; + 1.0000 0 0; + 0 0.7500 0.7500; + 0.7500 0 0.7500; + 0.7500 0.7500 0; + 0.2500 0.2500 0.2500]; + + + CurColor = CurColor+1; + + if(modulo(CurColor,MAXCOL)==0) + CurColor=1; + else + CurColor=modulo(CurColor,MAXCOL); + end + + //disp('ColorTab(CurColor,:)=') + //disp(ColorTab(CurColor,:)) + Color=addcolor(ColorTab(CurColor,:)); + + +endfunction + + + diff --git a/modules/graphics/macros/setPlotProperty.bin b/modules/graphics/macros/setPlotProperty.bin Binary files differnew file mode 100755 index 000000000..39477f42a --- /dev/null +++ b/modules/graphics/macros/setPlotProperty.bin diff --git a/modules/graphics/macros/setPlotProperty.sci b/modules/graphics/macros/setPlotProperty.sci new file mode 100755 index 000000000..88a072d17 --- /dev/null +++ b/modules/graphics/macros/setPlotProperty.sci @@ -0,0 +1,358 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2004-2006 - INRIA - Fabrice Leray +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [fail]=setPlotProperty(PropertyName,PropertyValue,Curves,current_figure,cur_draw_mode) + + fail=0; + + //conversion to lower format + str = convstr(PropertyName); + + + + //Property = ['foreground' 'clipping']; + + [PName] = getPlotPropertyName(str,current_figure,cur_draw_mode) + + + if (PName==[]) + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + + select PName + + ///////////////////////// + case "foreground" // <=> Color + ///////////////////////// + + if (type(PropertyValue) == 10) + + index = getColorIndex(PropertyValue); + + ColorVal = ["red" "green" "blue" "cyan" "magenta" "yellow" "black" "black" "white"]; + + if (index < 10) + Curves.line_mode="on"; + Curves.foreground = color(ColorVal(index)); + Curves.mark_foreground = color(ColorVal(index)); + else // 'none' selected + warning(msprintf(gettext("%s: Wrong value for input argument #%d: A color of the colormap expected.\n"),"setPlotProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + elseif (type(PropertyValue) == 1) // we entered plot(x,y,'Color',[R,G,B]) + + if (size(PropertyValue,"*")==3) + Curves.line_mode="on"; + Curves.foreground = addcolor(PropertyValue); + Curves.mark_foreground = addcolor(PropertyValue); + else + warning(msprintf(gettext("%s: Wrong size for input argument #%d: 3x1 or 1x3 vector expected.\n"),"setPlotProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + else + warning(msprintf(gettext("%s: Wrong type for input argument #%d: 3 elements vector or index in the colormap expected.\n"),"setPlotProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + + ///////////////////////// + case "clipping" // Clipping + ///////////////////////// + if (type(PropertyValue)==10 & (PropertyValue=="on" | PropertyValue=="off")) + Curves.clip_state=PropertyValue; + else + warning(msprintf(gettext("%s: Wrong value for input argument #%d: %s or %s expected.\n"),"setPlotProperty",2,"on","off")); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + + ///////////////////////// + case "linestyle" // LineStyle + ///////////////////////// + if (type(PropertyValue)==10) + if (PropertyValue=="--") + Curves.line_style=2; + Curves.line_mode = "on"; + elseif (PropertyValue=="-.") + Curves.line_style=4; + Curves.line_mode = "on"; + elseif (PropertyValue==":") + Curves.line_style=5; + Curves.line_mode = "on"; + elseif (PropertyValue=="-") + Curves.line_style=1; + Curves.line_mode = "on"; + elseif (PropertyValue=="none") + Curves.line_mode = "off"; + end + else + warning(msprintf(gettext("%s: Wrong type for input argument #%d: A string expected.\n"),"setPlotProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + ///////////////////////// + case "thickness" // <=> LineWidth + ///////////////////////// + if (type(PropertyValue)==1) + Curves.thickness=PropertyValue; + else + warning(msprintf(gettext("%s: Wrong type for input argument #%d: A scalar expected.\n"),"setPlotProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + ///////////////////////// + case "markstyle" // <=> Marker + ///////////////////////// + if (type(PropertyValue)==10) + + str = convstr(PropertyValue); + //Marks + Table = [ "+" "o" "*" "." "x" "square" "diamond" "^" "v" ">" "<" "pentagram" "none"]; + MarksStyleVal=[1 9 10 0 2 11 5 6 7 12 13 14 -99]; + // MarksSizeVal =[4 3 7 1 3 3 4 3 3 3 3 3 -99]; + + opt1=[]; + + k=find(part(Table,1:length(str))==str); + + if (k == []) + warning(msprintf(gettext("%s: Wrong value for input argument #%d: A marker style expected.\n"),"setPlotProperty", 2)); + PName=[]; + ResetFigureDDM(current_figure, cur_draw_mode); + return; + elseif ( size(k,"*") > 1) + warning(msprintf(gettext("%s: Wrong value for input argument #%d: A marker style expected.\n"),"setPlotProperty", 2)); //unreachable case normally + PName=[]; + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + opt = Table(k); + for i=1:length(str) + if part(opt,i) <> part(str,i) + break; + end + end + + opt1 = [opt1 k]; + + str = part(str,i:length(str)); + + if (size(opt1,"*") > 1) + warning(msprintf(gettext("%s: Wrong value for input argument #%d: A marker style expected.\n"),"setPlotproperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + if (opt1 > 0) + Curves.mark_style = MarksStyleVal(opt1); + Curves.mark_size = 6; + //MarksSizeVal(opt1); + else + // 'none' is selected + Curves.mark_mode="off" + end + + else + warning(msprintf(gettext("%s: Wrong type for input argument #%d: A string expected.\n"),"setPlotProperty")); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + + ///////////////////////// + case "markforeground" // <=> MarkerEdgeColor + ///////////////////////// + if (type(PropertyValue)==10) + + index = getColorIndex(PropertyValue); + + ColorVal = ["red" "green" "blue" "cyan" "magenta" "yellow" "black" "black" "white" "none"] + + markmodeON = find(Curves.mark_mode=="on"); + + if index == 10 + // 'none' specified + a=gca(); // pick up the background color of the parent axes + if markmodeON <> [] + Curves(markmodeON).mark_foreground = a.background; + end + elseif index == 11 + // 'auto' specified + if markmodeON <> [] + Curves(markmodeON).mark_foreground = Curves.foreground; + end + else + if (index==-1) + warning(msprintf(gettext("%s: Wrong value for input argument #%d: A color of the colormap expected.\n"),"setPlotProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + else + if markmodeON <> [] + Curves(markmodeON).mark_foreground = color(ColorVal(index)); + end + end + end + elseif (type(PropertyValue)==1) + if (size(PropertyValue,"*")==3) + + markmodeON = find(Curves.mark_mode=="on"); + if markmodeON <> [] + Curves(markmodeON).mark_foreground = addcolor(PropertyValue); + end + else + warning(msprintf(gettext("%s: Wrong size for input argument #%d: 3x1 or 1x3 vector expected.\n"),"setPlotProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + else + warning(msprintf(gettext("%s: Wrong type for input argument #%d: Vector or index in the colormap expected.\n"),"setPlotProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + + ///////////////////////// + case "markbackground" // <=> MarkerFaceColor + ///////////////////////// + if (type(PropertyValue)==10) + + index = getColorIndex(PropertyValue); + + ColorVal = ["red" "green" "blue" "cyan" "magenta" "yellow" "black" "black" "white" "none"] + + markmodeON = find(Curves.mark_mode=="on"); + + if index == 10 + // 'none' specified + a=gca(); // pick up the background color of the parent axes + if markmodeON <> [] + Curves(markmodeON).mark_background = a.background; + end + elseif index == 11 + // 'auto' specified + a=gca(); + if markmodeON <> [] + Curves(markmodeON).mark_background = a.background; + end + else + if (index==-1) + warning(msprintf(gettext("%s: Wrong value for input argument #%d: A color of the colormap expected.\n"),"setPlotProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + else + if markmodeON <> [] + Curves(markmodeON).mark_background = color(ColorVal(index)); + end + end + end + elseif (type(PropertyValue)==1) + + if (size(PropertyValue,"*")==3) + + markmodeON = find(Curves.mark_mode=="on"); + if markmodeON <> [] + Curves(markmodeON).mark_background = addcolor(PropertyValue); + end + else + warning(msprintf(gettext("%s: Wrong size for input argument #%d: 3x1 or 1x3 vector expected.\n"),"setPlotProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + else + warning(msprintf(gettext("%s: Wrong type for input argument #%d: Vector or index in the colormap expected.\n"),"setPlotProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + + ///////////////////////// + case "marksize" // <=> MarkerSize + ///////////////////////// + if (type(PropertyValue)==1 & size(PropertyValue,"*")==1) + + markmodeON = find(Curves.mark_mode=="on"); + + if markmodeON <> [] + Curves(markmodeON).mark_size = PropertyValue; + end + else + warning(msprintf(gettext("%s: Wrong type for input argument #%d: An integer expected.\n"),"setPlotProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + ///////////////////////// + case "visible" // <=> Visible + ///////////////////////// + if (type(PropertyValue)==10 & (PropertyValue=="on" | PropertyValue=="off")) + Curves.visible = PropertyValue; + else + warning(msprintf(gettext("%s: Wrong value for input argument #%d: %s or %s expected.\n"),"setPlotProperty",2,"on","off")); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + + ///////////////////////// + case "xdata" + ///////////////////////// + + // Already done at the beginning of plot execution. + + ///////////////////////// + case "ydata" + ///////////////////////// + + // Already done at the beginning of plot execution. + + ///////////////////////// + case "zdata" // <=> Zdata is treated after the curve was created + ///////////////////////// + + if (type(PropertyValue)<>1 | and(size(PropertyValue)<>1)) + warning(msprintf(gettext("%s: Wrong size or type for input argument #%d: A column or row vector expected.\n"),"setPlotProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + else + PropertyValue = PropertyValue(:); // force + + for j=1:size(Curves,"*") + if size(Curves(i).data,1) <> size(PropertyValue,"*") + str="plot : incompatible dimensions in input arguments"; + warning(str); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + else + for jj=1:size(PropertyValue,"*") + Curves(j).data(jj,3) = PropertyValue(jj); + end + a=gca(); + a.view="3d"; + a.data_bounds=[a.data_bounds(1,1) a.data_bounds(1,2) min(PropertyValue) ; a.data_bounds(2,1) a.data_bounds(2,2) max(PropertyValue)]; + a.view="2d"; + end + end + end + + + + end + +endfunction diff --git a/modules/graphics/macros/setSurfProperty.bin b/modules/graphics/macros/setSurfProperty.bin Binary files differnew file mode 100755 index 000000000..0c3c9d5e9 --- /dev/null +++ b/modules/graphics/macros/setSurfProperty.bin diff --git a/modules/graphics/macros/setSurfProperty.sci b/modules/graphics/macros/setSurfProperty.sci new file mode 100755 index 000000000..a1e707ce8 --- /dev/null +++ b/modules/graphics/macros/setSurfProperty.sci @@ -0,0 +1,438 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2004-2006 - INRIA - Fabrice Leray +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [fail]=setSurfProperty(PropertyName,PropertyValue,Surface,X,Y,Z,C,current_figure,cur_draw_mode) + + fail=0; + + //conversion to lower format + str = convstr(PropertyName); + + + + //Property = ['foreground' 'clipping']; + + [PName] = getSurfPropertyName(str,current_figure,cur_draw_mode) + + if (PName==[]) + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + select PName + + ///////////////////////// + case "colordata" + ///////////////////////// + + if (type(PropertyValue)<>1 | or(size(PropertyValue)==1)) + warning(msprintf(gettext("%s: Wrong type for input argument #%d: A real matrix expected.\n"),"setSurfProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + if (size(Z) == size(PropertyValue)) | (size(Z)-1 == size(PropertyValue)) + [tmp1,tmp2,tmp3,CC] = CreateFacetsFromXYZColor(X,Y,Z,PropertyValue); + Surface.data.color = CC; + else + str="surf : incompatible dimensions in input arguments"; + warning(str); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + ///////////////////////// + case "colordatamapping" + ///////////////////////// + + if (type(PropertyValue)<>10) + warning(msprintf(gettext("%s: Wrong type for input argument #%d: A string expected.\n"),"setSurfProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + if (PropertyValue=="scaled") + Surface.cdata_mapping = "scaled"; + elseif (PropertyValue=="direct") + Surface.cdata_mapping = "direct"; + else + warning(msprintf(gettext("%s: Wrong value for input argument #%d: %s or %s expected.\n"),"setSurfProperty",2, "scaled", "direct")); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + ///////////////////////// + case "cdatamode" + ///////////////////////// + + // ///////////////////////// + //case 'clipping' // Clipping // NO CLIPPING for now with 3d objects + // ///////////////////////// + // if (type(PropertyValue)==10 & (PropertyValue=='on' | PropertyValue=='off')) + // Surface.clip_state=PropertyValue; + // else + // warning("Bad value for property : Clipping") + // return; + // end + + + ///////////////////////// + case "foreground" // <=> EdgeColor + ///////////////////////// + + if (type(PropertyValue) == 10) + + index = getColorIndex(PropertyValue); + + ColorVal = ["red" "green" "blue" "cyan" "magenta" "yellow" "black" "black" "white"] + + if index < 10 + Surface.surface_mode="on"; + Surface.foreground = color(ColorVal(index)); + Surface.mark_foreground = color(ColorVal(index)); + elseif index == 10 // 'none' selected + Surface.surface_mode="on"; + Surface.color_mode = 0; // <=> - colormap(1) and not black at all!! + Surface.mark_foreground = -1; // <=> black + else + warning(msprintf(gettext("%s: Wrong value for input argument #%d: A color of the colormap expected.\n"),"setSurfProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + elseif (type(PropertyValue) == 1) // we entered plot(x,y,'Color',[R,G,B]) + + if (size(PropertyValue,"*")==3) + Surface.surface_mode="on"; + Surface.foreground = addcolor(PropertyValue); + Surface.mark_foreground = addcolor(PropertyValue); + else + warning(msprintf(gettext("%s: Wrong size for input argument #%d: 3x1 or 1x3 vector expected.\n"),"setSurfProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + else + warning(msprintf(gettext("%s: Wrong type for input argument #%d: Vector or index in the colormap expected.\n"),"setSurfProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + + ///////////////////////// + case "facecolor" // FaceColor + ///////////////////////// + + if (type(PropertyValue) == 10) + + index = getColorIndex(PropertyValue); + + ColorVal = ["red" "green" "blue" "cyan" "magenta" "yellow" "black" "black" "white"] + + if index < 10 + Surface.surface_mode="on"; + Surface.color_mode = color(ColorVal(index)); + //Surface.mark_foreground = color(ColorVal(index)); + Surface.color_flag = 0; + elseif index == 10 // 'none' selected + Surface.surface_mode="on"; + Surface.color_mode = 0; + //Surface.mark_foreground = color(ColorVal(index)); + Surface.color_flag = 0; + elseif index == 12 // 'flat' selected + Surface.surface_mode="on"; + Surface.color_flag = 4; + elseif index == 13 // 'interp' selected + Surface.surface_mode="on"; + Surface.color_flag = 3; + else + warning(msprintf(gettext("%s: Wrong value for input argument #%d: A color of the colormap expected.\n"),"setSurfProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + elseif (type(PropertyValue) == 1) // we entered plot(x,y,'Color',[R,G,B]) + + if (size(PropertyValue,"*")==3) + Surface.surface_mode="on"; + Surface.foreground = addcolor(PropertyValue); + Surface.mark_foreground = addcolor(PropertyValue); + else + warning(msprintf(gettext("%s: Wrong size for input argument #%d: 3x1 or 1x3 vector expected.\n"),"setSurfProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + else + warning(msprintf(gettext("%s: Wrong type for input argument #%d: Vector or index in the colormap expected.\n"),"setSurfProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + + ///////////////////////// + case "linestyle" // LineStyle + ///////////////////////// + if (type(PropertyValue)==10) + if (PropertyValue=="--") + Surface.line_style=2; + Surface.surface_mode = "on"; + elseif (PropertyValue=="-.") + Surface.line_style=4; + Surface.surface_mode = "on"; + elseif (PropertyValue==":") + Surface.line_style=5; + Surface.surface_mode = "on"; + elseif (PropertyValue=="-") + Surface.line_style=1; + Surface.surface_mode = "on"; + elseif (PropertyValue=="none") + Surface.surface_mode = "off"; + end + else + warning(msprintf(gettext("%s: Wrong type for input argument #%d: A string expected.\n"),"setSurfProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + ///////////////////////// + case "thickness" // <=> LineWidth + ///////////////////////// + if (type(PropertyValue)==1) + Surface.thickness=PropertyValue; + else + warning("Bad value for property : LineStyle"); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + ///////////////////////// + case "markstyle" // <=> Marker + ///////////////////////// + if (type(PropertyValue)==10) + + str = convstr(PropertyValue); + //Marks + Table = [ "+" "o" "*" "." "x" "square" "diamond" "^" "v" ">" "<" "pentagram" "none"]; + MarksStyleVal=[1 9 10 0 2 11 5 6 7 12 13 14 -99]; + // MarksSizeVal =[4 3 7 1 3 3 4 3 3 3 3 3 -99]; + + opt1=[]; + + k=find(part(Table,1:length(str))==str); + + if (k == []) + warning(msprintf(gettext("%s: Wrong value for input argument #%d: A marker style expected.\n"),"setSurfProperty",2)); + PName=[]; + ResetFigureDDM(current_figure, cur_draw_mode); + return; + elseif ( size(k,"*") > 1) + warning(msprintf(gettext("%s: Ambiguous MarkStyle value.\n"),"setSurfProperty")); //unreachable case normally + PName=[]; + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + opt = Table(k); + for i=1:length(str) + if part(opt,i) <> part(str,i) + break; + end + end + + opt1 = [opt1 k]; + + str = part(str,i:length(str)); + + if (size(opt1,"*") > 1) + warning(msprintf(gettext("%s: Wrong value for input argument #%d: A marker style expected.\n"),"setSurfproperty", 2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + if (opt1 > 0) + Surface.mark_style = MarksStyleVal(opt1); + Surface.mark_size = 6; + //MarksSizeVal(opt1); + else + // 'none' is selected + Surface.mark_mode="off" + end + + else + warning(msprintf(gettext("%s: Wrong type for input argument #%d: Vector or index in the colormap expected.\n"),"setSurfProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + + ///////////////////////// + case "markforeground" // <=> MarkerEdgeColor + ///////////////////////// + if (type(PropertyValue)==10) + + index = getColorIndex(PropertyValue); + + ColorVal = ["red" "green" "blue" "cyan" "magenta" "yellow" "black" "black" "white" "none"] + + markmodeON = find(Surface.mark_mode=="on"); + + if index == 10 + // 'none' specified + a=gca(); // pick up the background color of the parent axes + if markmodeON <> [] + Surface(markmodeON).mark_foreground = a.background; + end + elseif index == 11 + // 'auto' specified + if markmodeON <> [] + Surface(markmodeON).mark_foreground = Surface.foreground; + end + else + if (index==-1) + warning(msprintf(gettext("%s: Wrong value for input argument #%d: A color of the colormap expected.\n"),"setSurfProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + else + if markmodeON <> [] + Surface(markmodeON).mark_foreground = color(ColorVal(index)); + end + end + end + elseif (type(PropertyValue)==1) + if (size(PropertyValue,"*")==3) + + markmodeON = find(Surface.mark_mode=="on"); + if markmodeON <> [] + Surface(markmodeON).mark_foreground = addcolor(PropertyValue); + end + else + warning(msprintf(gettext("%s: Wrong size for input argument #%d: 3x1 or 1x3 vector expected.\n"),"setSurfProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + else + warning(msprintf(gettext("%s: Wrong type for input argument #%d: Vector or index in the colormap expected.\n"),"setSurfProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + + ///////////////////////// + case "markbackground" // <=> MarkerFaceColor + ///////////////////////// + if (type(PropertyValue)==10) + + index = getColorIndex(PropertyValue); + + ColorVal = ["red" "green" "blue" "cyan" "magenta" "yellow" "black" "black" "white" "none"] + + markmodeON = find(Surface.mark_mode=="on"); + + if index == 10 + // 'none' specified + a=gca(); // pick up the background color of the parent axes + if markmodeON <> [] + Surface(markmodeON).mark_background = a.background; + end + elseif index == 11 + // 'auto' specified + a=gca(); + if markmodeON <> [] + Surface(markmodeON).mark_background = a.background; + end + else + if (index==-1) + warning(msprintf(gettext("%s: Wrong value for input argument #%d: A color of the colormap expected.\n"),"setSurfProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + else + if markmodeON <> [] + Surface(markmodeON).mark_background = color(ColorVal(index)); + end + end + end + elseif (type(PropertyValue)==1) + + if (size(PropertyValue,"*")==3) + + markmodeON = find(Surface.mark_mode=="on"); + if markmodeON <> [] + Surface(markmodeON).mark_background = addcolor(PropertyValue); + end + else + warning(msprintf(gettext("%s: Wrong size for input argument #%d: 3x1 or 1x3 vector expected.\n"),"setSurfProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + else + warning(msprintf(gettext("%s: Wrong type for input argument #%d: Vector or index in the colormap expected.\n"),"setSurfProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + + ///////////////////////// + case "marksize" // <=> MarkerSize + ///////////////////////// + if (type(PropertyValue)==1 & size(PropertyValue,"*")==1) + + markmodeON = find(Surface.mark_mode=="on"); + + if markmodeON <> [] + Surface(markmodeON).mark_size = PropertyValue; + end + else + warning(msprintf(gettext("%s: Wrong type for input argument #%d: A scalar expected.\n"),"setSurfProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + ///////////////////////// + case "visible" // <=> Visible + ///////////////////////// + if (type(PropertyValue)==10 & (PropertyValue=="on" | PropertyValue=="off")) + Surface.visible = PropertyValue; + else + warning(msprintf(gettext("%s: Wrong value for input argument #%d: %s or %s expected.\n"),"setSurfProperty",2,"on","off")); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + + ///////////////////////// + case "xdata" + ///////////////////////// + + // Already done at the beginning of surf execution. + + ///////////////////////// + case "ydata" + ///////////////////////// + + // Already done at the beginning of surf execution. + + ///////////////////////// + case "zdata" + ///////////////////////// + + // Already done at the beginning of surf execution. + end + +endfunction + + + +function k=getIndexInStringTable(pattern,table) + + str = convstr(pattern); + k=find(part(table,1:length(str))==str); + +endfunction + + diff --git a/modules/graphics/macros/setTitleLabelProperty.bin b/modules/graphics/macros/setTitleLabelProperty.bin Binary files differnew file mode 100755 index 000000000..8dc40ba4c --- /dev/null +++ b/modules/graphics/macros/setTitleLabelProperty.bin diff --git a/modules/graphics/macros/setTitleLabelProperty.sci b/modules/graphics/macros/setTitleLabelProperty.sci new file mode 100755 index 000000000..b3cda3818 --- /dev/null +++ b/modules/graphics/macros/setTitleLabelProperty.sci @@ -0,0 +1,251 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2004-2006 - INRIA - Farid Belahcene +// Copyright (C) 2013 - Samuel GOUGEON +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function [fail] = setTitleLabelProperty(PropertyName,PropertyValue,titlelabel,current_figure,cur_draw_mode) + // SETTITLELABELPROPERTY function + // is used by the functions title, xlabel, ylabel, zlabel + // This function sets the title (or x_, y_, z_label) properties + + fail=0; + + //conversion to lower format + str = convstr(PropertyName); + + //Property = ['foreground' 'clipping']; + + [PName] = getTitleLabelPropertyNam(str, current_figure, cur_draw_mode) + + if (PName==[]) + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + select PName + + ///////////////////////// + case "font_size" // <=> fontsize + ///////////////////////// + + if (type(PropertyValue)<>1 | size(PropertyValue,"*")<>1) + warning(msprintf(gettext("%s: Wrong type for input argument #%d: A real matrix expected.\n"),"setTitleLabelProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + titlelabel.font_size = PropertyValue + return + + + ///////////////////////// + case "font_angle" // <=> rotation + ///////////////////////// + if (type(PropertyValue)<>1 | size(PropertyValue,"*")<>1) + warning(msprintf(gettext("%s: Wrong type for input argument #%d: A real matrix expected.\n"),"setTitleLabelProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + titlelabel.auto_rotation = "off" + newPropertyValue = modulo(PropertyValue,360) + titlelabel.font_angle = 360 - newPropertyValue + return + + + ///////////////////////// + case "font_foreground" // <=> color or edgecolor + ///////////////////////// + + if (type(PropertyValue) == 10) + index = getColorIndex(PropertyValue); + + ColorVal = ["red" "green" "blue" "cyan" "magenta" "yellow" "black" "black" "white"] + + if index < 10 + titlelabel.font_foreground = color(ColorVal(index)); + elseif index == 10 // 'none' selected + titlelabel.color_mode = 0; // <=> - colormap(1) and not black at all!! + else + warning(msprintf(gettext("%s: Wrong type for input argument #%d: Vector or index in the colormap expected.\n"),"setTitleLabelProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + elseif (type(PropertyValue) == 1) // we entered plot(x,y,'Color',[R,G,B]) + + if (size(PropertyValue,"*")==3) + titlelabel.font_foreground = addcolor(PropertyValue); + else + titlelabel.font_foreground = PropertyValue; + end + + else + warning(msprintf(gettext("%s: Wrong type for input argument #%d: Vector or index in the colormap expected.\n"),"setTitleLabelProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + + ///////////////////////// + case "foreground" // <=> foregroundcolor + ///////////////////////// + + if (type(PropertyValue) == 10) + index = getColorIndex(PropertyValue); + + ColorVal = ["red" "green" "blue" "cyan" "magenta" "yellow" "black" "black" "white"] + + if index < 10 + titlelabel.fill_mode = "on" + titlelabel.foreground = color(ColorVal(index)); + elseif index == 10 // 'none' selected + titlelabel.color_mode = 0; // <=> - colormap(1) and not black at all!! + else + warning(msprintf(gettext("%s: Wrong type for input argument #%d: Vector or index in the colormap expected.\n"),"setTitleLabelProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + elseif (type(PropertyValue) == 1) // we entered plot(x,y,'Color',[R,G,B]) + + if (size(PropertyValue,"*")==3) + titlelabel.fill_mode = "on" + titlelabel.foreground = addcolor(PropertyValue); + else + titlelabel.fill_mode = "on" + titlelabel.foreground = PropertyValue; + end + else + warning(msprintf(gettext("%s: Wrong type for input argument #%d: Vector or index in the colormap expected.\n"),"setTitleLabelProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + + ///////////////////////// + case "background" // <=> backgroundcolor + ///////////////////////// + + if (type(PropertyValue) == 10) + + index = getColorIndex(PropertyValue); + + ColorVal = ["red" "green" "blue" "cyan" "magenta" "yellow" "black" "black" "white"] + + if index < 10 + titlelabel.fill_mode = "on" + titlelabel.background = color(ColorVal(index)); + elseif index == 10 // 'none' selected + titlelabel.color_mode = 0; // <=> - colormap(1) and not black at all!! + else + warning(msprintf(gettext("%s: Wrong type for input argument #%d: Vector or index in the colormap expected.\n"),"setTitleLabelProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + elseif (type(PropertyValue) == 1) // we entered plot(x,y,'Color',[R,G,B]) + + if (size(PropertyValue,"*")==3) + titlelabel.fill_mode = "on" + titlelabel.background = addcolor(PropertyValue); + else + titlelabel.fill_mode = "on" + titlelabel.background = PropertyValue; + end + else + warning(msprintf(gettext("%s: Wrong type for input argument #%d: Vector or index in the colormap expected.\n"),"setTitleLabelProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + + ///////////////////////// + case "text" // <=> string + ///////////////////////// + if (type(PropertyValue) == 10) + titlelabel.text = PropertyValue; + return + else + warning(msprintf(_("%s: Wrong type for input argument #%d: A string expected.\n"),"setTitleLabelProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + + ///////////////////////// + case "position" // <=> position, à completer: la position par rapport à z n'est pas pris en compte, de plus le vecteur position doit contenir des coordonnées utilisateur (coordonnées selon l'axe) + ///////////////////////// + + if type(PropertyValue) == 1 & size(PropertyValue,"*")<=3 + titlelabel.auto_position = "off"; + titlelabel.position = PropertyValue ; + return + else + warning(msprintf(gettext("%s: Wrong size or type for input argument #%d: A real matrix expected.\n"),"setTitleLabelProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + + + ///////////////////////// + case "visible" // <=> visible + ///////////////////////// + + if type(PropertyValue) == 10 + if or(PropertyValue == ["off" "of"]) + titlelabel.visible = "off"; + return + elseif PropertyValue == "on" + titlelabel.visible = "on"; + return + else + warning(_("Incorrect input: ...")); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + else + warning(msprintf(_("%s: Wrong type for input argument #%d: A string expected.\n"),"setTitleLabelProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + + ///////////////////////// + case "font_style" // <=> fontangle + ///////////////////////// + fonts = ["courrier" "symbol" "times" "times italic" "times bold" .. + "times bold italic" "helvetica" "helvetica italic" "helvetica bold".. + "helvetica bold italic" ] + if typeof(PropertyValue) == "string" + PropertyValue = convstr(PropertyValue,"l") + if or(PropertyValue == fonts) + titlelabel.font_style = find(fonts==PropertyValue)-1; + else + warning(msprintf(_("%s: Wrong value for input argument #%d: At least one ""%s"" expected.\n"),"setTitleLabelProperty",2, "font")); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + elseif typeof(PropertyValue) == "constant" & or(PropertyValue==(0:9)) + titlelabel.font_style = PropertyValue; + else + warning(msprintf(_("%s: Wrong type for input argument #%d: A real matrix or a string matrix expected.\n"),"setTitleLabelProperty",2)); + ResetFigureDDM(current_figure, cur_draw_mode); + return; + end + + end + +endfunction + + +function k = getIndexInStringTable(pattern, table) + + str = convstr(pattern); + k = find(part(table,1:length(str))==str); + +endfunction + + diff --git a/modules/graphics/macros/seteventhandler.bin b/modules/graphics/macros/seteventhandler.bin Binary files differnew file mode 100755 index 000000000..bb4159ad3 --- /dev/null +++ b/modules/graphics/macros/seteventhandler.bin diff --git a/modules/graphics/macros/seteventhandler.sci b/modules/graphics/macros/seteventhandler.sci new file mode 100755 index 000000000..5fc28642a --- /dev/null +++ b/modules/graphics/macros/seteventhandler.sci @@ -0,0 +1,24 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007- INRIA - Jean-Baptiste Silvy +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function seteventhandler(name) + + [lhs,rhs] = argn(0) ; + + if ( rhs <> 1 ) then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "seteventhandler", 1)); + return ; + end + + fig = get("current_figure") ; + fig.event_handler_enable = "off" ; + fig.event_handler = name ; + if ( name <> "" ) then + fig.event_handler_enable = "on" ; + end +endfunction diff --git a/modules/graphics/macros/springcolormap.bin b/modules/graphics/macros/springcolormap.bin Binary files differnew file mode 100755 index 000000000..13134878e --- /dev/null +++ b/modules/graphics/macros/springcolormap.bin diff --git a/modules/graphics/macros/springcolormap.sci b/modules/graphics/macros/springcolormap.sci new file mode 100755 index 000000000..fd9c93001 --- /dev/null +++ b/modules/graphics/macros/springcolormap.sci @@ -0,0 +1,41 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Pierre MARECHAL <pierre.marechal@scilab.org> +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function cmap = springcolormap(varargin) + + //springcolormap : Magenta to yellow. + + // Check number of input argument + if size(varargin)<>1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "springcolormap", 1)); + end + n=varargin(1); + + // Check type of input argument + // Check if input argument is real + if typeof(n)<>"constant" | ~isreal(n) then + error(msprintf(gettext("%s: Wrong type for input argument #%d: a real scalar expected.\n"), "springcolormap", 1)); + end + + // Check size of input argument + if size(n,"*")<>1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: a real scalar expected.\n"), "springcolormap", 1)); + end + + if n==0 then + cmap = []; + return + end + + red = ones(n,1); + green = (0:n-1)'/max(n-1,1); + blue = 1 - green; + + cmap = [red green blue]; + +endfunction diff --git a/modules/graphics/macros/square.bin b/modules/graphics/macros/square.bin Binary files differnew file mode 100755 index 000000000..f310693ac --- /dev/null +++ b/modules/graphics/macros/square.bin diff --git a/modules/graphics/macros/square.sci b/modules/graphics/macros/square.sci new file mode 100755 index 000000000..3decb52cc --- /dev/null +++ b/modules/graphics/macros/square.sci @@ -0,0 +1,39 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function []=square(xmin,ymin,xmax,ymax) + + //definit un environnement graphique + //permettant un trace isometrique. + // + //xmin,ymin, (xmax,ymax) specifient les abscisses et ordonnees minimum + // (maximum) du dessin. defaut (-2,-2,2,2) + // + //square modifie le facteur d'echelle sur l'axe Ox. Pour conserver la + //meme taille de dessin, utiliser plutot la macro isoview. Les extrema + //sont imposes. + //! + + [lhs,rhs]=argn(0); + + if (rhs>0) & (rhs<>4) then + error(msprintf(gettext("%s: Wrong number of input arguments: %d or %d expected.\n"),"square",0,4)); + end + + if rhs<=0 then + xmin = -2; + ymin = -2; + xmax = 2; + ymax = 2; + end + + my_figure = gcf(); + my_figure.axes_size = max(my_figure.axes_size) * ones(1,2); + plot2d(0,0,1,"010"," ",[xmin,ymin,xmax,ymax]); + +endfunction diff --git a/modules/graphics/macros/subplot.bin b/modules/graphics/macros/subplot.bin Binary files differnew file mode 100755 index 000000000..6c743645b --- /dev/null +++ b/modules/graphics/macros/subplot.bin diff --git a/modules/graphics/macros/subplot.sci b/modules/graphics/macros/subplot.sci new file mode 100755 index 000000000..74a961689 --- /dev/null +++ b/modules/graphics/macros/subplot.sci @@ -0,0 +1,58 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function subplot(m,n,p) + [lhs,rhs]=argn(0) + + if rhs<>3 & rhs<>1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d or %d expected."), "subplot", 1, 3)); + return + end + + if rhs==1 then + p=modulo(m,10) + n=modulo((m-p)/10,10) + m=(m-p-10*n)/100 + end + + if m*n*p==0 then + error(msprintf(gettext("%s: Wrong value for input argument #%d: A %d digits integer with digits greater than %d expected.\n"),"subplot",1,3,0)); + return + end + + j=int((p-1)/n) + i=p-1-n*j + axes_bounds=[i/n,j/m,1/n,1/m]; + + a = gca(); + f = a.parent; + na=size(f.children,"*") + if na==1 then + // an axes is automatically created when a figure is created + // do not create a new axes if we have just this one + a=f.children;da=gda() + if a.children==[]& and(a.axes_bounds==da.axes_bounds) then + //a single axes with no children, just resize it + a.axes_bounds=axes_bounds; + return + end + end + // look for an axes with the same axes_bounds + for k=1:na + child = f.children(k); + if child.type == "Axes" & and(child.axes_bounds == axes_bounds) then + //make it current + sca(child); + return; + end + end + //create a new axes + a=newaxes(f); + a.axes_bounds=axes_bounds; + sca(a); +endfunction diff --git a/modules/graphics/macros/summercolormap.bin b/modules/graphics/macros/summercolormap.bin Binary files differnew file mode 100755 index 000000000..28eac46ef --- /dev/null +++ b/modules/graphics/macros/summercolormap.bin diff --git a/modules/graphics/macros/summercolormap.sci b/modules/graphics/macros/summercolormap.sci new file mode 100755 index 000000000..11d714303 --- /dev/null +++ b/modules/graphics/macros/summercolormap.sci @@ -0,0 +1,41 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Pierre MARECHAL <pierre.marechal@scilab.org> +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function cmap = summercolormap(varargin) + + //summercolormap : Green to yellow. + + // Check number of input argument + if size(varargin)<>1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "summercolormap", 1)); + end + n=varargin(1); + + // Check type of input argument + // Check if input argument is real + if typeof(n)<>"constant" | ~isreal(n) then + error(msprintf(gettext("%s: Wrong type for input argument #%d: a real scalar expected.\n"), "summercolormap", 1)); + end + + // Check size of input argument + if size(n,"*")<>1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: a real scalar expected.\n"), "summercolormap", 1)); + end + + if n==0 then + cmap = []; + return + end + + red = (0:n-1)'/max(n-1,1); + green = (1+red)/2; + blue = 0.4*ones(n,1); + + cmap = [red green blue]; + +endfunction diff --git a/modules/graphics/macros/surf.bin b/modules/graphics/macros/surf.bin Binary files differnew file mode 100755 index 000000000..195a86dca --- /dev/null +++ b/modules/graphics/macros/surf.bin diff --git a/modules/graphics/macros/surf.sci b/modules/graphics/macros/surf.sci new file mode 100755 index 000000000..a52b9d6c4 --- /dev/null +++ b/modules/graphics/macros/surf.sci @@ -0,0 +1,634 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2004-2006 - INRIA - Fabrice Leray +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +function surf(varargin) + [lhs,rhs]=argn(0); + + if ~rhs + Z= [ 0.0001 0.0013 0.0053 -0.0299 -0.1809 -0.2465 -0.1100 -0.0168 -0.0008 -0.0000; .. + 0.0005 0.0089 0.0259 -0.3673 -1.8670 -2.4736 -1.0866 -0.1602 -0.0067 0.0000; .. + 0.0004 0.0214 0.1739 -0.3147 -4.0919 -6.4101 -2.7589 -0.2779 0.0131 0.0020; .. + -0.0088 -0.0871 0.0364 1.8559 1.4995 -2.2171 -0.2729 0.8368 0.2016 0.0130; .. + -0.0308 -0.4313 -1.7334 -0.1148 3.0731 0.4444 2.6145 2.4410 0.4877 0.0301; .. + -0.0336 -0.4990 -2.3552 -2.1722 0.8856 -0.0531 2.6416 2.4064 0.4771 0.0294; .. + -0.0137 -0.1967 -0.8083 0.2289 3.3983 3.1955 2.4338 1.2129 0.2108 0.0125; .. + -0.0014 -0.0017 0.3189 2.7414 7.1622 7.1361 3.1242 0.6633 0.0674 0.0030; .. + 0.0002 0.0104 0.1733 1.0852 2.6741 2.6725 1.1119 0.1973 0.0152 0.0005; .. + 0.0000 0.0012 0.0183 0.1099 0.2684 0.2683 0.1107 0.0190 0.0014 0.0000]; + f=gcf(); + f.color_map = jetcolormap(64); + surf(Z,"edgeco","b","marker","d","markersiz",9,"markeredg","red","markerfac","k"); + return; + end + + X=[]; + Y=[]; + Z=[]; + C=[]; + + CurColor = 0; // current color used if no color specified via LineSpec + // nor PropertyName + + ListArg = varargin; + + //detect and set the current axes now: + if type(ListArg(1)) == 9 + hdle = ListArg(1); + if (hdle.type == "Axes") + sca(ListArg(1)); + ListArg(1) = null(); // remove this parameter from the list + else + error(msprintf(gettext("%s: Wrong type for input argument #%d: An ''Axes'' handle expected.\n"), "surf", 1)); + return; + end + end + + + nv = size(ListArg) + + + T=[]; + d=[]; + + typeOfPlot = "surf"; + //given_data = 2; + + for k=1:nv + T(k,1) = type(ListArg(k)) + end + + given_data = 0; + P1 = 0; + + for i=1:nv + if T(i) == 1 + given_data = given_data +1; + else + P1 = i; // Position of the first PropertyName field + break; + end + end + + + // delay the drawing commands + // smart drawlater + current_figure=gcf(); + cur_draw_mode = current_figure.immediate_drawing; + current_figure.immediate_drawing = "off"; + + colormap_size = size(current_figure.color_map,1); + + if given_data == 1 //surf(Z) with Z giving us data + color info. + // ---------------------------------------------------------- // + + if or(size(ListArg(1))==1) + ResetFigureDDM(current_figure, cur_draw_mode); + error(msprintf(gettext("%s: Wrong size for input argument #%d: A matrix of size greater than %d-by-%d expected.\n"), "surf", 1, 2, 2)); + return; + end + + X = 1:size(ListArg(1),2); + Y = 1:size(ListArg(1),1); + Z = ListArg(1)'; // here a transposition is needed + C = Z; + + [XX,YY,ZZ] = genfac3d(X,Y,Z); + CC = ZZ; // Add a color matrix based on Z values + + elseif given_data == 2 //surf(Z,COLOR) + // ---------------------------------------------------------- // + if or(size(ListArg(1))==1) + ResetFigureDDM(current_figure, cur_draw_mode); + error(msprintf(gettext("%s: Wrong size for input argument #%d: A matrix of size greater than %d-by-%d expected.\n"), "surf", 1, 2, 2)); + return; + end + + if ((size(ListArg(1)) <> size(ListArg(2))) & (size(ListArg(1))-1 <> size(ListArg(2)))) + ResetFigureDDM(current_figure, cur_draw_mode); + error(msprintf(gettext("%s: Wrong size for input argument #%d: A %d-by-%d or %d-by-%d matrix expected.\n"),.. + "surf", 2, size(ListArg(1),1), size(ListArg(1),2), size(ListArg(1),1) - 1, size(ListArg(1),2) -1 )); + return; + end + + X = 1:size(ListArg(1),2); + Y = 1:size(ListArg(1),1); + Z = ListArg(1)'; // here a transposition is needed + C = ListArg(2)'; + + [XX,YY,ZZ] = genfac3d(X,Y,Z); + + if (size(ListArg(2)) == size(ListArg(1))) // color number == zdata number + [XX,YY,CC] = genfac3d(X,Y,C); // CC must be a color matrix of size nf x n + elseif ((size(ListArg(2))) == size(ListArg(1))-1) // color number -1 == zdata number => ONLY flat mode can be enabled + Ctmp=[]; + Ctmp = [C [C(:,$)]] ; + Ctmp = [Ctmp; Ctmp($,:)]; + [XX,YY,CC] = genfac3d(X,Y,Ctmp); // CC must be a color matrix of size nf x n + end + + elseif given_data == 3 //surf(X,Y,Z) with Z giving us data + color info. + // ---------------------------------------------------------- // + + X = ListArg(1) + Y = ListArg(2); + Z = ListArg(3); + + // check if the call is OK + err = execstr("[XX,YY,ZZ,CC] = CreateFacetsFromXYZ(X,Y,Z,current_figure, cur_draw_mode)","errcatch","n"); + + if (err <> 0) then + // reset data + processSurfError(current_figure, cur_draw_mode); + end + + elseif given_data == 4 //surf(X,Y,Z,COLOR) + // ---------------------------------------------------------- // + if ((size(ListArg(3)) <> size(ListArg(4))) & (size(ListArg(3))-1 <> size(ListArg(4)))) + ResetFigureDDM(current_figure, cur_draw_mode); + error(msprintf(gettext("%s: Wrong size for input argument #%d: A %d-by-%d or %d-by-%d matrix expected.\n"),.. + "surf", 4, size(ListArg(3),1), size(ListArg(3),2), size(ListArg(3),1) - 1, size(ListArg(3),2) -1 )); + return; + end + + X = ListArg(1) + Y = ListArg(2); + Z = ListArg(3); + C = ListArg(4); + + // check if the call is OK + err = execstr("[XX,YY,ZZ,CC] = CreateFacetsFromXYZColor(X,Y,Z,C,current_figure, cur_draw_mode)","errcatch","n"); + if (err <> 0) then + // reset data + processSurfError(current_figure, cur_draw_mode); + end + end + + + // P1 is the position of the first PropertyName field. + Property = P1; + + while ((Property <> 0) & (Property <= nv-1)) + PropertyName = ListArg(Property); + PropertyValue = ListArg(Property+1); + + // Xdata + PName = getSurfPropertyName(PropertyName); + if (PName == "xdata") + + if (type(PropertyValue)<>1) + ResetFigureDDM(current_figure, cur_draw_mode); + error(msprintf(gettext("%s: Wrong type for input argument ''%s'': A Real matrix expected.\n"), "surf", "xdata")); + return; + end + + X = PropertyValue; + [XX,tmp2,tmp3] = CreateFacetsFromXYZ(PropertyValue,Y,Z,current_figure, cur_draw_mode); + + // Ydata + elseif (PName == "ydata") + + if (type(PropertyValue)<>1) + ResetFigureDDM(current_figure, cur_draw_mode); + error(msprintf(gettext("%s: Wrong type for input argument ''%s'': A Real matrix expected.\n"), "surf", "ydata")); + return; + end + + Y = PropertyValue; + [tmp1,YY,tmp3] = CreateFacetsFromXYZ(X,PropertyValue,Z,current_figure, cur_draw_mode); + + // Zdata + elseif (PName == "zdata") + + if (type(PropertyValue)<>1) then + ResetFigureDDM(current_figure, cur_draw_mode); + error(msprintf(gettext("%s: Wrong type for input argument ''%s'': A Real matrix expected.\n"), "surf", "zdata")); + return; + end + if (or(size(PropertyValue)==1)) then + ResetFigureDDM(current_figure, cur_draw_mode); + error(msprintf(gettext("%s: Wrong size for input argument ''%s'': A matrix of size greater than %d-by-%d expected.\n"), "surf", "zdata", 2, 2)); + return; + end + + Z = PropertyValue; + [tmp1,tmp2,ZZ] = CreateFacetsFromXYZ(X,Y,PropertyValue,current_figure, cur_draw_mode); + + end + + Property = Property+2; + end + + if isempty(XX) | isempty(YY) | isempty(ZZ) then + // Nothing will be drawn so return (see http://bugzilla.scilab.org/13180 ) + return + end + + // surf is made now ! + // with default option to simulate the Matlab mode + + err = execstr("plot3d(XX,YY,list(ZZ,CC))","errcatch","n"); + + if err <> 0 + processSurfError(current_figure, cur_draw_mode); + end + + a=gca(); + a.cube_scaling = "on"; + a.rotation_angles = [51 -125]; + e=gce(); + e.hiddencolor=0; // to avoid painting the hidden facets + e.color_flag=4; // Matlab special flat mode by default (different from mode 2) + e.cdata_mapping = "scaled" + + + // F.Leray + // Today: 17.03.05 + // XYZ-DataMode under Matlab seems really bugged (see following samples and read Matlab doc.): + // + // surf(X,Y,Z,'XDataMode','auto') + // surf(X,Y,Z,'XDataMode','auto') + // surf(X+20,Y,Z,'XDataMode','auto') + // surf(X+20,Y,Z,'XDataMode','man') + // surf(X+20,Y,Z,'XDataMode','auto') + // surf(X+20,Y,Z,'Xdata',X-100,'XDataMode','auto') + // surf(X+20,Y,Z,'Xdata',X-100,'XDataMode','man') + // surf(X+20,Y,Z,'XData',X-100,'XDataMode','auto') + // surf(X+20,Y,Z,'XData',X-100,'XDataMode','man') + // surf(Z,'XData',X-100,'XDataMode','man') + // surf(Z,'XData',X-100,'XDataMode','auto') + // surf(X+20,Y,Z,'XDataMode','man') + // surf(X+20,Y,Z,'XDataMode','auto') + // + // That is why I do not support those properties. + // Below and in comment is the code we could add to treat those properties. + // by giving XYZ-DataModeVal to setSurfProperty (to better treat XYZ-Data input). + // + // + //XdataModeVal=1; + //YdataModeVal=1; + //ZdataModeVal=1; + // + //if Property <> 0 + // XdataMode = getIndexInStringTable('xdatam',ListArg([Property nv])) + // if XdataMode <> [] + // XdataModeVal = getIndexInStringTable(ListArg(XdataMode+1),['auto','manual']) + // if size(XdataModeVal,'*') <> 1 + // disp("Error: Bad XdataMode selected"); + // return; + // end + // end + // + // YdataMode = getIndexInStringTable('ydatam',ListArg([Property nv])) + // if YdataMode <> [] + // YdataModeVal = getIndexInStringTable(ListArg(YdataMode+1),['auto','manual']) + // if size(YdataModeVal,'*') <> 1 + // disp("Error: Bad YdataMode selected"); + // return; + // end + // end + // + // ZdataMode = getIndexInStringTable('zdatam',ListArg([Property nv])) + // if ZdataMode <> [] + // ZdataModeVal = getIndexInStringTable(ListArg(ZdataMode+1),['auto','manual']) + // if size(ZdataModeVal,'*') <> 1 + // disp("Error: Bad ZdataMode selected"); + // return; + // end + // end + //end + // + + + /////////////////////////////////// + //Global Property treatment // + //PropertyName and PropertyValue // + /////////////////////////////////// + + + // P1 is the position of the first PropertyName field. + Property = P1; + + current_surface = gce(); // get the newly created fac3d + current_surface.mark_size_unit="point"; + + + + while ((Property <> 0) & (Property <= nv-1)) + setSurfProperty(ListArg(Property),ListArg(Property+1),current_surface,X,Y,Z,C,current_figure,cur_draw_mode) + + Property = Property+2; + end + + + //postponed drawings are done now ! + // smart drawnow + ResetFigureDDM(current_figure, cur_draw_mode); + +endfunction + +// +//function [C] = build_interp_color(C,colormap_size) +//// C is considered as a data value in Matlab +//MIN = min(C); +//MAX = max(C); +//NCOLMIN = 1; +//NCOLMAX = colormap_size; +// +//if MIN <> MAX +// C = (NCOLMIN-NCOLMAX)/(MIN-MAX) * C + (MIN*NCOLMAX - NCOLMIN*MAX)/(MIN-MAX); +// C = round(C); +//else +// C = ones(C) * (NCOLMIN+NCOLMAX)/2; +//end +//endfunction +// +// + + +function k=getIndexInStringTable(pattern,table) + + str = convstr(pattern); + k=find(part(table,1:length(str))==str); + +endfunction + +function [XX,YY,ZZ,CC] = CreateFacetsFromXYZ(X,Y,Z,current_figure, cur_draw_mode) + + if or(size(X)==1) & or(size(Y)==1) // X and Y are vector + + tmp = X; + X = Y; + Y = tmp; + + if size(X,"*") ~= size(Z,1) then + ResetFigureDDM(current_figure, cur_draw_mode); + error(msprintf(gettext("%s: Wrong size for input argument ''%s'': A vector of size %d expected.\n"), "surf", "Y", size(Z,1))); + return; + end + + if size(Y,"*") ~= size(Z,2) then + ResetFigureDDM(current_figure, cur_draw_mode); + error(msprintf(gettext("%s: Wrong size for input argument ''%s'': A vector of size %d expected.\n"), "surf", "X", size(Z,2))); + return; + end + + [XX,YY,ZZ] = genfac3d(Y,X,Z'); + + // COLOR treatment + CC = ZZ; + + elseif and(size(X)>1) & and(size(Y)>1) // X and Y are matrix + + if or(size(X) ~= size(Y)) then + ResetFigureDDM(current_figure, cur_draw_mode); + error(msprintf(gettext("%s: Wrong size for input arguments ''%s'' and ''%s'': Matrices of same size expected.\n"), "surf", "X", "Y")); + return; + end + + if or(size(X) ~= size(Z)) then + ResetFigureDDM(current_figure, cur_draw_mode); + error(msprintf(gettext("%s: Wrong size for input arguments ''%s'' and ''%s'': Matrices of same size expected.\n"), "surf", "X", "Z")); + return; + end + + [XX,YY,ZZ] = nf3d(X,Y,Z); + + // COLOR treatment + CC = ZZ; + + elseif or(size(X)==1) & and(size(Y)>1) // X is a vector and Y is a matrix + + if size(X,"*") ~= size(Z,2) then + ResetFigureDDM(current_figure, cur_draw_mode); + error(msprintf(gettext("%s: Wrong size for input argument ''%s'': A vector of size %d expected.\n"), "surf", "X", size(Z,2))); + return; + end + + if or(size(Y) ~= size(Z)) then + ResetFigureDDM(current_figure, cur_draw_mode); + error(msprintf(gettext("%s: Wrong size for input arguments ''%s'' and ''%s'': Matrices of same size expected.\n"), "surf", "Y", "Z")); + return; + end + + // X vector + // Y matrix + // Z matrix + + X=X(:)'; // X is forced to be a row vector + XMAT=[]; + + for i=1:size(Z,2) + XMAT=[XMAT;X]; + end + + [XX,YY,ZZ] = nf3d(XMAT,Y,Z); + + // COLOR treatment + CC = ZZ; + + elseif or(size(Y)==1) & and(size(X)>1) // Y is a vector and X is a matrix + + if or(size(X) ~= size(Z)) then + ResetFigureDDM(current_figure, cur_draw_mode); + error(msprintf(gettext("%s: Wrong size for input arguments ''%s'' and ''%s'': Matrices of same size expected.\n"), "surf", "X", "Z")); + return; + end + + if size(Y,"*") ~= size(Z,2) then + ResetFigureDDM(current_figure, cur_draw_mode); + error(msprintf(gettext("%s: Wrong size for input argument ''%s'': A vector of size %d expected.\n"), "surf", "Y", size(Z,2))); + return; + end + + // Y vector + // X matrix + // Z matrix + + Y=Y(:); // Y is forced to be a column vector + YMAT=[]; + + for i=1:size(Z,1) + YMAT=[YMAT,Y]; + end + + [XX,YY,ZZ] = nf3d(X,YMAT,Z); + + // COLOR treatment + CC = ZZ; + + else + ResetFigureDDM(current_figure, cur_draw_mode); + error(msprintf(gettext("%s: Wrong size for input arguments ''%s'' and ''%s'': Same size expected.\n"), "surf", "X", "Y")); + return; + end + +endfunction + +function [XX,YY,ZZ,CC] = CreateFacetsFromXYZColor(X,Y,Z,C,current_figure, cur_draw_mode) + + if or(size(X)==1) & or(size(Y)==1) // X and Y are vector + + Z = Z'; // here a transposition is needed + C = C'; // here a transposition is needed + + if size(X,"*") ~= size(Z,1) then + ResetFigureDDM(current_figure, cur_draw_mode); + error(msprintf(gettext("%s: Wrong size for input argument ''%s'': A vector of size %d expected.\n"), "surf", "X", size(Z,1))); + return; + end + + if size(Y,"*") ~= size(Z,2) then + ResetFigureDDM(current_figure, cur_draw_mode); + error(msprintf(gettext("%s: Wrong size for input argument ''%s'': A vector of size %d expected.\n"), "surf", "Y", size(Z,2))); + return; + end + + [XX,YY,ZZ] = genfac3d(X,Y,Z); + + // COLOR treatment + if (size(C) == size(Z)) // color number == zdata number + [XX,YY,CC] = genfac3d(X,Y,C); // CC must be a color matrix of size nf x n + elseif (size(C) == size(Z)-1) // color number -1 == zdata number => ONLY flat mode can be enabled + Ctmp=[]; + Ctmp = [C [C(:,$)]] ; + Ctmp = [Ctmp; Ctmp($,:)]; + [XX,YY,CC] = genfac3d(X,Y,Ctmp); // CC must be a color matrix of size nf x n + end + + elseif and(size(X)>1) & and(size(Y)>1) // X and Y are matrices + + if or(size(X) ~= size(Y)) then + ResetFigureDDM(current_figure, cur_draw_mode); + error(msprintf(gettext("%s: Wrong size for input arguments ''%s'' and ''%s'': Matrices of same size expected.\n"), "surf", "X", "Y")); + return; + end + + if or(size(X) ~= size(Z)) then + ResetFigureDDM(current_figure, cur_draw_mode); + error(msprintf(gettext("%s: Wrong size for input arguments ''%s'' and ''%s'': Matrices of same size expected.\n"), "surf", "X", "Z")); + return; + end + + [XX,YY,ZZ] = nf3d(X,Y,Z); + + // COLOR treatment + if (size(C) == size(Z)) // color number == zdata number + [XX,YY,CC] = nf3d(X,Y,C); // CC must be a color matrix of size nf x n + elseif (size(C) == size(Z)-1) // color number -1 == zdata number => ONLY flat mode can be enabled + Ctmp=[]; + Ctmp = [C [C(:,$)]] ; + Ctmp = [Ctmp; Ctmp($,:)]; + [XX,YY,CC] = nf3d(X,Y,Ctmp); // CC must be a color matrix of size nf x n + end + + elseif or(size(X)==1) & and(size(Y)>1) // X is a vector and Y is a matrix + + if size(X,"*") ~= size(Z,2) then + ResetFigureDDM(current_figure, cur_draw_mode); + error(msprintf(gettext("%s: Wrong size for input argument ''%s'': A vector of size %d expected.\n"), "surf", "X", size(Z,2))); + return; + end + + if or(size(Y) ~= size(Z)) then + ResetFigureDDM(current_figure, cur_draw_mode); + error(msprintf(gettext("%s: Wrong size for input arguments ''%s'' and ''%s'': Matrices of same size expected.\n"), "surf", "Y", "Z")); + return; + end + + // X vector + // Y matrix + // Z matrix + + X=X(:)'; // X is forced to be a row vector + XMAT=[]; + + for i=1:size(Z,2) + XMAT=[XMAT;X]; + end + + + + [XX,YY,ZZ] = nf3d(XMAT,Y,Z); + + // COLOR treatment + if (size(C) == size(Z)) // color number == zdata number + [XX,YY,CC] = nf3d(XMAT,Y,C); // CC must be a color matrix of size nf x n + elseif (size(C) == size(Z)-1) // color number -1 == zdata number => ONLY flat mode can be enabled + Ctmp=[]; + Ctmp = [C [C(:,$)]] ; + Ctmp = [Ctmp; Ctmp($,:)]; + [XX,YY,CC] = nf3d(XMAT,Y,Ctmp); // CC must be a color matrix of size nf x n + end + + elseif or(size(Y)==1) & and(size(X)>1) // Y is a vector and X is a matrix + + if or(size(X) ~= size(Z)) then + ResetFigureDDM(current_figure, cur_draw_mode); + error(msprintf(gettext("%s: Wrong size for input arguments ''%s'' and ''%s'': Matrices of same size expected.\n"), "surf", "X", "Z")); + return; + end + + if size(Y,"*") ~= size(Z,2) then + ResetFigureDDM(current_figure, cur_draw_mode); + error(msprintf(gettext("%s: Wrong size for input argument ''%s'': A vector of size %d expected.\n"), "surf", "Y", size(Z,2))); + return; + end + + + // Y vector + // X matrix + // Z matrix + + Y=Y(:); // Y is forced to be a column vector + YMAT=[]; + + for i=1:size(Z,1) + YMAT=[YMAT,Y]; + end + + [XX,YY,ZZ] = nf3d(X,YMAT,Z); + + // COLOR treatment + if (size(C) == size(Z)) // color number == zdata number + [XX,YY,CC] = nf3d(X,YMAT,C); // CC must be a color matrix of size nf x n + elseif (size(C) == size(Z)-1) // color number -1 == zdata number => ONLY flat mode can be enabled + Ctmp=[]; + Ctmp = [C [C(:,$)]] ; + Ctmp = [Ctmp; Ctmp($,:)]; + [XX,YY,CC] = nf3d(X,YMAT,Ctmp); // CC must be a color matrix of size nf x n + end + + else + ResetFigureDDM(current_figure, cur_draw_mode); + error(msprintf(gettext("%s: Wrong size for input arguments ''%s'' and ''%s'': Matrices of same size expected.\n"), "surf", "X", "Y")); + return; + end + +endfunction + +// If an error occurs in the surf code, we need to catch it +// order to reset some default values +function processSurfError(cur_figure, cur_draw_mode) + // reset data + ResetFigureDDM(current_figure, cur_draw_mode); + + // get the error + [err_message, err_number, err_line, err_func] = lasterror(%t); + + // rethrow it + + // for now error can only have a single string as input. + // If there are several lines we need to concatane them. + err_message_nbLines = size(err_message, "*"); + if (err_message_nbLines > 1) then + // put a \n betwee, each string + err_message(1) = strcat(err_message, "\n"); + end + error(err_message(1), err_number); +endfunction diff --git a/modules/graphics/macros/title.bin b/modules/graphics/macros/title.bin Binary files differnew file mode 100755 index 000000000..d615521ed --- /dev/null +++ b/modules/graphics/macros/title.bin diff --git a/modules/graphics/macros/title.sci b/modules/graphics/macros/title.sci new file mode 100755 index 000000000..f5114c785 --- /dev/null +++ b/modules/graphics/macros/title.sci @@ -0,0 +1,19 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2004-2006 - INRIA - Farid Belahcene +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function title(varargin) + // TITLE function + // Add titles on a graphics window + + if size(varargin)<1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"), "title", 1)); + end + + varargin = list("title",varargin(1:$)); + TitleLabel(varargin(:)); +endfunction diff --git a/modules/graphics/macros/titlepage.bin b/modules/graphics/macros/titlepage.bin Binary files differnew file mode 100755 index 000000000..fafb342c9 --- /dev/null +++ b/modules/graphics/macros/titlepage.bin diff --git a/modules/graphics/macros/titlepage.sci b/modules/graphics/macros/titlepage.sci new file mode 100755 index 000000000..4bc4c49df --- /dev/null +++ b/modules/graphics/macros/titlepage.sci @@ -0,0 +1,30 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 1989 - INRIA - Serge Steer +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function titlepage(str,win) + //titlepage(str) genere une page de titres graphiques contenant la ma- + //trice de chaines de caracteres str ecrite centree dans la page avec + //une taille de caractere maximale. + //! + [lhs,rhs]=argn(0) + + if ~isdef("str") then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d or %d expected.\n"), "titlepage", 1, 2)); + end + + if type(str) <> 10 then + error(msprintf(gettext("%s: Wrong type for input argument #%d: String array expected.\n"), "titlepage", 1)); + end + + + old=xget("window") + if rhs==2 then xset("window",win);end + plot2d([0,1],[0,1],[-1,-1],"022"); + xstringb(0,0,str,1,1,"fill"); + xset("window",old) +endfunction diff --git a/modules/graphics/macros/twinkle.bin b/modules/graphics/macros/twinkle.bin Binary files differnew file mode 100755 index 000000000..3cbf08e56 --- /dev/null +++ b/modules/graphics/macros/twinkle.bin diff --git a/modules/graphics/macros/twinkle.sci b/modules/graphics/macros/twinkle.sci new file mode 100755 index 000000000..9b0446775 --- /dev/null +++ b/modules/graphics/macros/twinkle.sci @@ -0,0 +1,46 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function twinkle(h,n) + + [lhs,rhs]=argn(0) + if rhs==1 then + if (type(h)<>9 | size(h,"*")<>1) then + error(msprintf(gettext("%s: Wrong type for input argument #%d: Graphic handle expected.\n"), "twinkle", 1)); + end + n=5; + elseif rhs==2 then + if (type(h)<>9 | size(h,"*")<>1) then + error(msprintf(gettext("%s: Wrong type for input argument #%d: Graphic handle expected.\n"), "twinkle", 1)); + end + if (type(n)<>1 | size(n,"*")<>1) then + error(msprintf(gettext("%s: Wrong type for input argument #%d: Scalar expected.\n"), "twinkle", 2)); + end + else + error(msprintf(gettext("%s: Wrong number of input arguments: %d or %d expected.\n"), "twinkle", 1, 2)); + end + + f=h; + while f.type<>"Figure" + f=f.parent; + end + realtimeinit(0.2); + realtime(0); + k=0; + + v=h.visible; + for i=1:n + k=k+2; + h.visible="off"; + realtime(k); + h.visible="on"; + realtime(k+1); + end + h.visible=v; + +endfunction diff --git a/modules/graphics/macros/whitecolormap.bin b/modules/graphics/macros/whitecolormap.bin Binary files differnew file mode 100755 index 000000000..3ffd2d591 --- /dev/null +++ b/modules/graphics/macros/whitecolormap.bin diff --git a/modules/graphics/macros/whitecolormap.sci b/modules/graphics/macros/whitecolormap.sci new file mode 100755 index 000000000..dafaf1144 --- /dev/null +++ b/modules/graphics/macros/whitecolormap.sci @@ -0,0 +1,32 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Pierre MARECHAL <pierre.marechal@scilab.org> +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function cmap = whitecolormap(varargin) + + //whitecolormap + + // Check number of input argument + if size(varargin)<>1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "whitecolormap", 1)); + end + n=varargin(1); + + // Check type of input argument + // Check if input argument is real + if typeof(n)<>"constant" | ~isreal(n) then + error(msprintf(gettext("%s: Wrong type for input argument #%d: a real scalar expected.\n"), "whitecolormap", 1)); + end + + // Check size of input argument + if size(n,"*")<>1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: a real scalar expected.\n"), "whitecolormap", 1)); + end + + cmap = ones(n,3); + +endfunction diff --git a/modules/graphics/macros/wintercolormap.bin b/modules/graphics/macros/wintercolormap.bin Binary files differnew file mode 100755 index 000000000..c32ab2e23 --- /dev/null +++ b/modules/graphics/macros/wintercolormap.bin diff --git a/modules/graphics/macros/wintercolormap.sci b/modules/graphics/macros/wintercolormap.sci new file mode 100755 index 000000000..f329ff326 --- /dev/null +++ b/modules/graphics/macros/wintercolormap.sci @@ -0,0 +1,41 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Pierre MARECHAL <pierre.marechal@scilab.org> +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function cmap = wintercolormap(varargin) + + //wintercolormap : Blue to green. + + // Check number of input argument + if size(varargin)<>1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "wintercolormap", 1)); + end + n=varargin(1); + + // Check type of input argument + // Check if input argument is real + if typeof(n)<>"constant" | ~isreal(n) then + error(msprintf(gettext("%s: Wrong type for input argument #%d: a real scalar expected.\n"), "wintercolormap", 1)); + end + + // Check size of input argument + if size(n,"*")<>1 then + error(msprintf(gettext("%s: Wrong size for input argument #%d: a real scalar expected.\n"), "wintercolormap", 1)); + end + + if n==0 then + cmap = []; + return + end + + red = zeros(n,1); + green = (0:n - 1)' / max(n-1,1); + blue = 0.5 + (1-green)/2; + + cmap = [red green blue]; + +endfunction diff --git a/modules/graphics/macros/xclear.bin b/modules/graphics/macros/xclear.bin Binary files differnew file mode 100755 index 000000000..321b3baf9 --- /dev/null +++ b/modules/graphics/macros/xclear.bin diff --git a/modules/graphics/macros/xclear.sci b/modules/graphics/macros/xclear.sci new file mode 100755 index 000000000..0590a2a06 --- /dev/null +++ b/modules/graphics/macros/xclear.sci @@ -0,0 +1,50 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ENPC +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function xclear(win_num) + //xclear([win_num]) + // Clear the graphic window win_num and erase the recorded graphics of + // window win_num + // if win_num is omited, it's the current graphic window + // win_num can also be a vector of window Id to clear a set of windows + //! + + + [lhs,rhs]=argn(0); + if (rhs == 0) then + // clear the current figure + set(gcf(), "visible", "off"); + elseif (rhs == 1) then + // clear a set of figures + if (type(win_num) <> 1) then + error(999, msprintf(gettext("%s: Wrong type for input argument #%d: A vector expected.\n"), "xclear", 1)); + return; + end + + if (winsid() == []) then + // no current figure + curFig = []; + else + curFig = gcf(); + end + + for figNum = win_num, + set(scf(figNum), "visible", "off"); + end + + // restore current figure + if (curFig <> []) then + scf(curFig); + end + + else + error(999, msprintf(gettext("%s: Wrong number of input arguments: %d or %d expected.\n"), "xclear", 0, 1)); + return; + end +endfunction + diff --git a/modules/graphics/macros/xgetech.bin b/modules/graphics/macros/xgetech.bin Binary files differnew file mode 100755 index 000000000..24c688062 --- /dev/null +++ b/modules/graphics/macros/xgetech.bin diff --git a/modules/graphics/macros/xgetech.sci b/modules/graphics/macros/xgetech.sci new file mode 100755 index 000000000..c6c9080ae --- /dev/null +++ b/modules/graphics/macros/xgetech.sci @@ -0,0 +1,20 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2012-2012 - Scilab Enterprises - Bruno JOFRET +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +// +// +function [wrect, frect, logflag, arect]=xgetech() + + a = gca(); + wrect = a.axes_bounds; + frect = matrix(a.data_bounds, 1, 4); + logflag = part(a.log_flags, 1:2); + arect = a.margins; + +endfunction diff --git a/modules/graphics/macros/xinfo.bin b/modules/graphics/macros/xinfo.bin Binary files differnew file mode 100755 index 000000000..429a6a2f4 --- /dev/null +++ b/modules/graphics/macros/xinfo.bin diff --git a/modules/graphics/macros/xinfo.sci b/modules/graphics/macros/xinfo.sci new file mode 100755 index 000000000..c5b968d18 --- /dev/null +++ b/modules/graphics/macros/xinfo.sci @@ -0,0 +1,20 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007 - INRIA - Jean-Baptiste Silvy +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function xinfo( newMessage ) + // xinfo function + // Set the text of the message bar of the current figure + + if argn(2)<1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"), "xinfo", 1)); + end + + curFig = gcf() ; + curFig.info_message = newMessage ; + +endfunction diff --git a/modules/graphics/macros/xlabel.bin b/modules/graphics/macros/xlabel.bin Binary files differnew file mode 100755 index 000000000..4748ff6a8 --- /dev/null +++ b/modules/graphics/macros/xlabel.bin diff --git a/modules/graphics/macros/xlabel.sci b/modules/graphics/macros/xlabel.sci new file mode 100755 index 000000000..4ffd2ca3e --- /dev/null +++ b/modules/graphics/macros/xlabel.sci @@ -0,0 +1,19 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2004-2006 - INRIA - Farid Belahcene +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function xlabel(varargin) + // XLABEL function + // Label x + + if size(varargin)<1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"), "xlabel", 1)); + end + + varargin = list("x_label",varargin(1:$)); + TitleLabel(varargin(:)); +endfunction diff --git a/modules/graphics/macros/xload.bin b/modules/graphics/macros/xload.bin Binary files differnew file mode 100755 index 000000000..fc85923be --- /dev/null +++ b/modules/graphics/macros/xload.bin diff --git a/modules/graphics/macros/xload.sci b/modules/graphics/macros/xload.sci new file mode 100755 index 000000000..2b5cbf290 --- /dev/null +++ b/modules/graphics/macros/xload.sci @@ -0,0 +1,29 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function []=xload(fil,num) + + if and(argn(2)<>[1 2]) then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d or %d expected.\n"), "xload", 1, 2)); + end + + if ~isfile(fil) then + error(msprintf(gettext("%s: file %s does not exist.\n"), "xload", fil)); + end + + if argn(2)==2 then scf(num),end + f=gcf() + res = execstr("load(fil)","errcatch") ; + if res==0 then + f.visible="on" + f.immediate_drawing="on"; + else + error("Given file is not a graphic one") ; + end + +endfunction diff --git a/modules/graphics/macros/xnumb.bin b/modules/graphics/macros/xnumb.bin Binary files differnew file mode 100755 index 000000000..5f6f96aab --- /dev/null +++ b/modules/graphics/macros/xnumb.bin diff --git a/modules/graphics/macros/xnumb.sci b/modules/graphics/macros/xnumb.sci new file mode 100755 index 000000000..745d0bd6e --- /dev/null +++ b/modules/graphics/macros/xnumb.sci @@ -0,0 +1,25 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function xnumb(x,y,nums,box,angle) + if and(argn(2)<>[3:5]) then + error(msprintf(gettext("%s: Wrong number of input argument(s): %d to %d expected.\n"), "xnumb", 3, 5)); + end + + n=size(x,"*"); + if argn(2)<5 then angle=zeros(1,n),end + if argn(2)<4 then box=0,end + + if size(y,"*") >n|size(nums,"*" )<>n|size(angle,"*" )<>n then + error(msprintf(_("%s: Wrong size for input arguments: Same sizes expected.\n"),"xnumb")); + end + + for k=1:n + xstring(x(k),y(k),msprintf("%-5.4g",nums(k)),angle(k),box) + end +endfunction diff --git a/modules/graphics/macros/xrpoly.bin b/modules/graphics/macros/xrpoly.bin Binary files differnew file mode 100755 index 000000000..147dac52e --- /dev/null +++ b/modules/graphics/macros/xrpoly.bin diff --git a/modules/graphics/macros/xrpoly.sci b/modules/graphics/macros/xrpoly.sci new file mode 100755 index 000000000..a8b6aff55 --- /dev/null +++ b/modules/graphics/macros/xrpoly.sci @@ -0,0 +1,30 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function []=xrpoly(orig,n,r,theta) + // permet de tracer un polygone regulier + // + // orig : centre du polygone + // n : nombre de segments + // r : rayon du cercle le circonscrit + // theta : angle, 0 si omis + // Attention utilise l'echelle d'un appel precedent de plot2d. + //! + [lhs,rhs]=argn(0); + select rhs + case 3 then b=eye(2,2); + // Transposed in order to post-multiply + case 4 then b=[cos(theta) sin(theta); -sin(theta) cos(theta)]; + else error(msprintf(gettext("%s: Wrong number of input argument(s): %d to %d expected."), "xrpoly", 3, 4)); + end; + // + ang=2*%pi/n + pt=(0:n)'*ang;xy=r*[cos(pt),sin(pt)] + xy=ones(n+1,1)*matrix(orig,1,2)+xy*b; + xpoly(xy(:,1),xy(:,2),"lines",1); +endfunction diff --git a/modules/graphics/macros/xsave.bin b/modules/graphics/macros/xsave.bin Binary files differnew file mode 100755 index 000000000..65d254c33 --- /dev/null +++ b/modules/graphics/macros/xsave.bin diff --git a/modules/graphics/macros/xsave.sci b/modules/graphics/macros/xsave.sci new file mode 100755 index 000000000..f9c5f1b5b --- /dev/null +++ b/modules/graphics/macros/xsave.sci @@ -0,0 +1,23 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) INRIA +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function xsave(fil,num) + if argn(2)<1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"), "xsave", 1)); + end + if argn(2)<2 then + f=gcf() + preservecur=%f + else + preservecur=winsid()<>[] + if preservecur then old=gcf();end + f=scf(num); + end + save(fil,"f") + if preservecur then scf(old),end +endfunction diff --git a/modules/graphics/macros/xsetech.bin b/modules/graphics/macros/xsetech.bin Binary files differnew file mode 100755 index 000000000..4b20f9241 --- /dev/null +++ b/modules/graphics/macros/xsetech.bin diff --git a/modules/graphics/macros/xsetech.sci b/modules/graphics/macros/xsetech.sci new file mode 100755 index 000000000..d764bdefc --- /dev/null +++ b/modules/graphics/macros/xsetech.sci @@ -0,0 +1,85 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2012-2012 - Scilab Enterprises - Bruno JOFRET +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +// +// +function []=xsetech(wrect, frect, logflag, arect) + + // 1 <= RHS <= 3 + if (argn(2) > 3 | argn(2) < 1) then + error(77, sprintf(_("%s: Wrong number of input argument(s): %d to %d expected."), "xsetech", 1, 3)); + end + + if ~exists("wrect", "local") + wrect = []; + else + // Check wrect + if (type(wrect) <> 1 | isreal(wrect) == %f | size(wrect) <> [1 4]) then + error(77, sprintf(_("%s: Wrong value given for %s."), "xsetech", "wrect")); + end + end + + if ~exists("frect", "local") + frect = []; + else + // Check frect + if (type(frect) <> 1 | isreal(frect) == %f | size(frect) <> [1 4]) then + error(77, sprintf(_("%s: Wrong value given for %s."), "xsetech", "frect")); + end + frect = [frect(1), frect(2); frect(3), frect(4)] + end + + if ~exists("logflag", "local") + logflag = []; + else + // check logflag + if (type(logflag) <> 10 | or(logflag == ["ll" "nn" "nl" "ln"]) == %f) then + error(77, sprintf(_("%s: Wrong value given for %s."), "xsetech", "logflag")); + end + end + + if ~exists("arect", "local") + arect = []; + else + if (type(arect) <> 1 | isreal(arect) == %f | size(arect) <> [1 4]) then + error(77, sprintf(_("%s: Wrong value given for %s."), "xsetech", "arect")); + end + end + + // Check if an existing axes matches wrect + a = gca() + curParent = a.parent; + allAxes = curParent.children; + found = %F; + for kAxes = 1:size(allAxes, "*") + if allAxes(kAxes).type == "Axes" & and(allAxes(kAxes).axes_bounds(:)==wrect(:)) then + a = sca(allAxes(kAxes)); + found = %T; + break; + end + end + + if ~found then + a = newaxes(curParent); + if ~isempty(wrect) then + a.axes_bounds = wrect; + end + end + + if ~isempty(frect) then + a.data_bounds = frect; + end + if ~isempty(logflag) then + a.log_flags = logflag; + end + if ~isempty(arect) then + a.margins = arect; + end + +endfunction diff --git a/modules/graphics/macros/xstringl.bin b/modules/graphics/macros/xstringl.bin Binary files differnew file mode 100755 index 000000000..39b7b1bb9 --- /dev/null +++ b/modules/graphics/macros/xstringl.bin diff --git a/modules/graphics/macros/xstringl.sci b/modules/graphics/macros/xstringl.sci new file mode 100755 index 000000000..12ab37818 --- /dev/null +++ b/modules/graphics/macros/xstringl.sci @@ -0,0 +1,50 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Jean-Baptiste Silvy +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +//======================================================================= +// File : xstringl.sci +// Desc : Compute the bounding rectangle of a text +// (old version of stringbox) +//====================================================================== + +function [rect] = xstringl( varargin ) + + // the call is rect=xstringl(x,y,str,[fontId,fontSize]) + + [lhs,rhs] = argn(0) ; + listArg = varargin ; + + // rect = xstringl(x,y,str,[fontId,fontSize]) + + select rhs, + case 3 then + // stringbox(str, x, y) + corners = stringbox(listArg (3), listArg (1), listArg (2)); + case 4 then + // stringbox(str, x, y, angle = 0, fontId) + corners = stringbox(listArg (3), listArg (1), listArg (2), 0, listArg (4)); + case 5 then + // stringbox(str, x, y, angle = 0, fontId, fontSize); + corners = stringbox(listArg (3), listArg (1), listArg (2), 0, listArg (4), listArg (5)); + else + // incorrect number of input argmuments + error(msprintf(gettext("%s: Wrong number of input argument(s): %d to %d expected."), "xstringl", 3, 5)); + return ; + end; + + // convert corners into position and size + // position, upper-left point + rect(1) = corners (1,2); // x + rect(2) = corners (2,2); // y + + // size width, height + rect(3) = abs(corners(1,3) - corners(1,1)); + rect(4) = abs(corners(2,3) - corners(2,1)); + +endfunction + diff --git a/modules/graphics/macros/ylabel.bin b/modules/graphics/macros/ylabel.bin Binary files differnew file mode 100755 index 000000000..7f92b5067 --- /dev/null +++ b/modules/graphics/macros/ylabel.bin diff --git a/modules/graphics/macros/ylabel.sci b/modules/graphics/macros/ylabel.sci new file mode 100755 index 000000000..e996bbcf7 --- /dev/null +++ b/modules/graphics/macros/ylabel.sci @@ -0,0 +1,19 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2004-2006 - INRIA - Farid Belahcene +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function ylabel(varargin) + // YLABEL function + // Label y + + if size(varargin)<1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"), "ylabel", 1)); + end + + varargin = list("y_label",varargin(1:$)); + TitleLabel(varargin(:)); +endfunction diff --git a/modules/graphics/macros/zlabel.bin b/modules/graphics/macros/zlabel.bin Binary files differnew file mode 100755 index 000000000..761367ff7 --- /dev/null +++ b/modules/graphics/macros/zlabel.bin diff --git a/modules/graphics/macros/zlabel.sci b/modules/graphics/macros/zlabel.sci new file mode 100755 index 000000000..216813828 --- /dev/null +++ b/modules/graphics/macros/zlabel.sci @@ -0,0 +1,18 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2005 - INRIA - Farid Belahcene +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +function zlabel(varargin) + + if size(varargin)<1 then + error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"), "zlabel", 1)); + end + + varargin = list("z_label",varargin(1:$)); + TitleLabel(varargin(:)); +endfunction |