* Bug #8784 fixed - Autoscale for cscope graph 24/18824/20
diptighosalkar [Fri, 31 Mar 2017 13:31:58 +0000 (18:31 +0530)]
Change-Id: I04391e3adf2156914201e61c70e652effcf5ba01

27 files changed:
scilab/CHANGES.md
scilab/modules/helptools/etc/images_md5.txt
scilab/modules/helptools/images/SCALE_CSCOPE.png [new file with mode: 0644]
scilab/modules/helptools/images/SCALE_CSCOPE_1.png [new file with mode: 0644]
scilab/modules/helptools/images/SCALE_CSCOPE_en_US.zcos.png [new file with mode: 0644]
scilab/modules/helptools/images/SCALE_CSCOPE_gui.gif [new file with mode: 0644]
scilab/modules/scicos/palettes/Sinks.cosf
scilab/modules/scicos_blocks/Makefile.am
scilab/modules/scicos_blocks/Makefile.in
scilab/modules/scicos_blocks/macros/Sinks/SCALE_CSCOPE.sci [new file with mode: 0644]
scilab/modules/scicos_blocks/src/c/cli/scicos_blocks-cli.vcxproj
scilab/modules/scicos_blocks/src/c/cli/scicos_blocks-cli.vcxproj.filters
scilab/modules/scicos_blocks/src/c/cscope.c
scilab/modules/scicos_blocks/src/c/scale_cscope.c [new file with mode: 0644]
scilab/modules/scicos_blocks/src/c/scicos_blocks.vcxproj
scilab/modules/scicos_blocks/src/c/scicos_blocks.vcxproj.filters
scilab/modules/xcos/Makefile.am
scilab/modules/xcos/Makefile.in
scilab/modules/xcos/etc/Xcos-style.xml
scilab/modules/xcos/etc/palettes.xml
scilab/modules/xcos/examples/sinks_pal/en_US/SCALE_CSCOPE_en_US.zcos [new file with mode: 0644]
scilab/modules/xcos/help/en_US/palettes/Sinks_pal/AA_Sinks_pal.xml
scilab/modules/xcos/help/en_US/palettes/Sinks_pal/CSCOPE.xml
scilab/modules/xcos/help/en_US/palettes/Sinks_pal/SCALE_CSCOPE.xml [new file with mode: 0644]
scilab/modules/xcos/images/blocks/SCALE_ASCOPE.svg [new file with mode: 0644]
scilab/modules/xcos/images/gui/SCALE_CSCOPE_gui.gif [new file with mode: 0644]
scilab/modules/xcos/images/palettes/SCALE_CSCOPE.png [new file with mode: 0644]

index 2b400ca..9ae6f04 100644 (file)
@@ -42,6 +42,7 @@ Compilation
    - autoconf 2.69
    - libtool 2.4.6 (patched for Mac Os X)
 
+
 Dependencies
 ------------
 
@@ -71,7 +72,7 @@ Packaging & Supported Operating Systems
 
 Feature changes and additions
 -----------------------------
+
 * Empty strings are used as the default values on String allocation
 * HTTP get, post, put, upload, patch, delete functions added
 * JSON encoding / decoding for Scilab datatypes added
@@ -79,6 +80,7 @@ Feature changes and additions
   - PVS-Studio inspections blog report
   - Coverity scan weekly source analysis
 
+
 Help pages:
 -----------
 
@@ -93,6 +95,8 @@ Xcos
 ----
 
 * scicos_log() support options parameters to retrieve model statistics.
+* Added a new block `SCALE_CSCOPE` which is `CSCOPE` block with additional feature of autoscaling of graph. It takes a parameter (1 for Yes/0 for No) for scaling/no-scaling.
+
 
 API modification
 ----------------
@@ -117,6 +121,7 @@ Bug Fixes
 ---------
 
 ### Bugs fixed in 6.1.0:
+* [#8784](http://bugzilla.scilab.org/show_bug.cgi?id=8784): automatic self-adjusting scopes.
 * [#14604](http://bugzilla.scilab.org/show_bug.cgi?id=14604): `emptystr()` is 40x slower with 6.0.0 wrt 5.5.2
 * [#14605](http://bugzilla.scilab.org/show_bug.cgi?id=14605): fixed - `bench_run` was too strict about the specification of tests names.
 * [#14812](http://bugzilla.scilab.org/show_bug.cgi?id=14812): Minor typos in messages.
index eeb91fa..b9f3d33 100644 (file)
@@ -154,6 +154,7 @@ QUANT_f_2.png=d014d30ed3d0745cc91b3cda699dbb14
 RAMP_1.png=c23fa5d3551bbd0d62ed522a383f858b
 REGISTER_1.png=b10b9eb56f4f302b40722fc37f90152
 SAWTOOTH_f_1.png=10ee1db52ca7bf5c9a88f6af721493a6
+SCALE_CSCOPE_1.png=99e0ba70bb8d2c34aec7555986b6b518
 SRFLIPFLOP_1.png=bf5bf1af128d883fe210b34b77108187
 SRFLIPFLOP_fr_FR_1.png=66fae8781f8aff2688d19345715c229d
 STEP_FUNCTION_1.png=a0f3c8ffdd4693291dc1c322c9a02fc5
diff --git a/scilab/modules/helptools/images/SCALE_CSCOPE.png b/scilab/modules/helptools/images/SCALE_CSCOPE.png
new file mode 100644 (file)
index 0000000..ace80b0
Binary files /dev/null and b/scilab/modules/helptools/images/SCALE_CSCOPE.png differ
diff --git a/scilab/modules/helptools/images/SCALE_CSCOPE_1.png b/scilab/modules/helptools/images/SCALE_CSCOPE_1.png
new file mode 100644 (file)
index 0000000..a547045
Binary files /dev/null and b/scilab/modules/helptools/images/SCALE_CSCOPE_1.png differ
diff --git a/scilab/modules/helptools/images/SCALE_CSCOPE_en_US.zcos.png b/scilab/modules/helptools/images/SCALE_CSCOPE_en_US.zcos.png
new file mode 100644 (file)
index 0000000..448ab79
Binary files /dev/null and b/scilab/modules/helptools/images/SCALE_CSCOPE_en_US.zcos.png differ
diff --git a/scilab/modules/helptools/images/SCALE_CSCOPE_gui.gif b/scilab/modules/helptools/images/SCALE_CSCOPE_gui.gif
new file mode 100644 (file)
index 0000000..3f608c3
Binary files /dev/null and b/scilab/modules/helptools/images/SCALE_CSCOPE_gui.gif differ
index 83320b4..c2a56a7 100644 (file)
@@ -166,6 +166,31 @@ scs_m.objs(1)=scicos_block(..
                        mlist(["Block","graphics","model","gui","doc"],..
                        mlist(..
                        ["graphics","orig","sz","flip","theta","exprs","pin","pout","pein","peout","gr_i",..
+                       "id","in_implicit","out_implicit"],[390,0],[40,40],%t,0,..
+                       ["1 3 5 7 9 11 13 15";"-1";"[]";"[600;400]";"-15";"15";"30";"20";"0";"";"1"],0,[],0,..
+                       [],..
+                       list(..
+                       ["thick=xget(''thickness'');xset(''thickness'',2);";
+                       "xrect(orig(1)+sz(1)/10,orig(2)+(1-1/10)*sz(2),sz(1)*8/10,sz(2)*8/10);";
+                       "xx=[orig(1)+sz(1)/5,orig(1)+sz(1)/5;";
+                       "orig(1)+(1-1/4)*sz(1),orig(1)+sz(1)/5];";
+                       "yy=[orig(2)+sz(2)/5,orig(2)+sz(2)/5;";
+                       "orig(2)+sz(2)/5,orig(2)+(1-1/3)*sz(2)];";
+                       "xarrows(xx,yy);";
+                       "t=(0:0.3:2*%pi)'';";
+                       "xx=orig(1)+(1/5+3*t/(10*%pi))*sz(1);";
+                       "yy=orig(2)+(1/4.3+(sin(t)+1)*3/10)*sz(2);";
+                       "xpoly(xx,yy,''lines'');";
+                       "xset(''thickness'',thick)"],8),"","E",[]),..
+                       mlist(..
+                       ["model","sim","in","in2","intyp","out","out2","outtyp","evtin","evtout","state",..
+                       "dstate","odstate","rpar","ipar","opar","blocktype","firing","dep_ut","label",..
+                       "nzcross","nmode","equations"],list("scale_cscope",4),-1,1,1,[],[],1,1,[],[],[],list(),..
+                       [1;-15;15;30],[-1;1;20;1;3;5;7;9;11;13;15;-1;-1;600;400],list(),"c",[],[%t,%f],..
+                       "",0,0,list()),"SCALE_CSCOPE",list()),..
+                       mlist(["Block","graphics","model","gui","doc"],..
+                       mlist(..
+                       ["graphics","orig","sz","flip","theta","exprs","pin","pout","pein","peout","gr_i",..
                        "id","in_implicit","out_implicit"],[0,70],[20,20],%t,0,"1",0,[],[],[],..
                        list("prt=string(model.ipar);xstringb(orig(1),orig(2),prt,sz(1),sz(2))",8),"",..
                        "I",[]),..
index ff1cd8a..8f5fa86 100644 (file)
@@ -55,6 +55,7 @@ SCICOS_BLOCKS_C_SOURCES = \
     src/c/cosh_blk.c \
     src/c/counter.c \
     src/c/cscope.c \
+    src/c/scale_cscope.c \
     src/c/cscopxy3d.c \
     src/c/cscopxy.c \
     src/c/csslti4.c \
index 902b1c6..89cf9ff 100644 (file)
@@ -228,6 +228,7 @@ am__objects_1 = src/c/libsciscicos_blocks_algo_la-absblk.lo \
        src/c/libsciscicos_blocks_algo_la-cosh_blk.lo \
        src/c/libsciscicos_blocks_algo_la-counter.lo \
        src/c/libsciscicos_blocks_algo_la-cscope.lo \
+       src/c/libsciscicos_blocks_algo_la-scale_cscope.lo \
        src/c/libsciscicos_blocks_algo_la-cscopxy3d.lo \
        src/c/libsciscicos_blocks_algo_la-cscopxy.lo \
        src/c/libsciscicos_blocks_algo_la-csslti4.lo \
@@ -1017,6 +1018,7 @@ SCICOS_BLOCKS_C_SOURCES = \
     src/c/cosh_blk.c \
     src/c/counter.c \
     src/c/cscope.c \
+    src/c/scale_cscope.c \
     src/c/cscopxy3d.c \
     src/c/cscopxy.c \
     src/c/csslti4.c \
@@ -1709,6 +1711,8 @@ src/c/libsciscicos_blocks_algo_la-counter.lo: src/c/$(am__dirstamp) \
        src/c/$(DEPDIR)/$(am__dirstamp)
 src/c/libsciscicos_blocks_algo_la-cscope.lo: src/c/$(am__dirstamp) \
        src/c/$(DEPDIR)/$(am__dirstamp)
+src/c/libsciscicos_blocks_algo_la-scale_cscope.lo: src/c/$(am__dirstamp) \
+       src/c/$(DEPDIR)/$(am__dirstamp)
 src/c/libsciscicos_blocks_algo_la-cscopxy3d.lo: src/c/$(am__dirstamp) \
        src/c/$(DEPDIR)/$(am__dirstamp)
 src/c/libsciscicos_blocks_algo_la-cscopxy.lo: src/c/$(am__dirstamp) \
@@ -2465,6 +2469,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libsciscicos_blocks_algo_la-cosh_blk.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libsciscicos_blocks_algo_la-counter.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libsciscicos_blocks_algo_la-cscope.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libsciscicos_blocks_algo_la-scale_cscope.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libsciscicos_blocks_algo_la-cscopxy.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libsciscicos_blocks_algo_la-cscopxy3d.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libsciscicos_blocks_algo_la-csslti4.Plo@am__quote@
@@ -2679,6 +2684,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libsciscicos_blocks_algo_la-samphold4_m.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libsciscicos_blocks_algo_la-satur.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libsciscicos_blocks_algo_la-scalar2vector.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libsciscicos_blocks_algo_la-scale_cscope.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libsciscicos_blocks_algo_la-scicos_evalhermite.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libsciscicos_blocks_algo_la-scicos_indexfinder.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@src/c/$(DEPDIR)/libsciscicos_blocks_algo_la-scicosexit.Plo@am__quote@
@@ -3024,6 +3030,13 @@ src/c/libsciscicos_blocks_algo_la-cscope.lo: src/c/cscope.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciscicos_blocks_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/c/libsciscicos_blocks_algo_la-cscope.lo `test -f 'src/c/cscope.c' || echo '$(srcdir)/'`src/c/cscope.c
 
+src/c/libsciscicos_blocks_algo_la-scale_cscope.lo: src/c/scale_cscope.c
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciscicos_blocks_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/c/libsciscicos_blocks_algo_la-scale_cscope.lo -MD -MP -MF src/c/$(DEPDIR)/libsciscicos_blocks_algo_la-scale_cscope.Tpo -c -o src/c/libsciscicos_blocks_algo_la-scale_cscope.lo `test -f 'src/c/scale_cscope.c' || echo '$(srcdir)/'`src/c/scale_cscope.c
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) src/c/$(DEPDIR)/libsciscicos_blocks_algo_la-scale_cscope.Tpo src/c/$(DEPDIR)/libsciscicos_blocks_algo_la-scale_cscope.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='src/c/scale_cscope.c' object='src/c/libsciscicos_blocks_algo_la-scale_cscope.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciscicos_blocks_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/c/libsciscicos_blocks_algo_la-scale_cscope.lo `test -f 'src/c/scale_cscope.c' || echo '$(srcdir)/'`src/c/scale_cscope.c
+
 src/c/libsciscicos_blocks_algo_la-cscopxy3d.lo: src/c/cscopxy3d.c
 @am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciscicos_blocks_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/c/libsciscicos_blocks_algo_la-cscopxy3d.lo -MD -MP -MF src/c/$(DEPDIR)/libsciscicos_blocks_algo_la-cscopxy3d.Tpo -c -o src/c/libsciscicos_blocks_algo_la-cscopxy3d.lo `test -f 'src/c/cscopxy3d.c' || echo '$(srcdir)/'`src/c/cscopxy3d.c
 @am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) src/c/$(DEPDIR)/libsciscicos_blocks_algo_la-cscopxy3d.Tpo src/c/$(DEPDIR)/libsciscicos_blocks_algo_la-cscopxy3d.Plo
diff --git a/scilab/modules/scicos_blocks/macros/Sinks/SCALE_CSCOPE.sci b/scilab/modules/scicos_blocks/macros/Sinks/SCALE_CSCOPE.sci
new file mode 100644 (file)
index 0000000..dfb2897
--- /dev/null
@@ -0,0 +1,153 @@
+//  Scicos
+//
+//  Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+//  Copyright (C) 2016-2017 - FOSSEE IIT Bombay - Dipti Ghosalkar
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See the file ../license.txt
+//
+
+function [x,y,typ]=SCALE_CSCOPE(job,arg1,arg2)
+    x=[];
+    y=[];
+    typ=[];
+    select job
+    case "set" then
+        x=arg1;
+        graphics=arg1.graphics;
+        exprs=graphics.exprs
+
+        model=arg1.model;
+        //dstate=model.in
+        while %t do
+            [ok,clrs,win,wpos,wdim,ymin,ymax,per,N,heritance,nom,autoscale,exprs]=scicos_getvalue(..
+            "Set Scope parameters",..
+            ["Color (>0) or mark (<0) vector (8 entries)";
+            "Output window number (-1 for automatic)";
+            "Output window position";
+            "Output window sizes";
+            "Ymin";
+            "Ymax";
+            "Refresh period";
+            "Buffer size"
+            "Accept herited events 0/1"
+            "Name of Scope (label&Id)"
+            "Auto scaling 0/1"],..     //For autoscaling ON/OFF
+            list("vec",8,"vec",1,"vec",-1,"vec",-1,"vec",1,..
+            "vec",1,"vec",1,"vec",1,"vec",1,"str",1,"vec",1),..
+            exprs)
+            if ~ok then
+                break,
+            end //user cancel modification
+            mess=[]
+            if size(wpos,"*")<>0 &size(wpos,"*")<>2 then
+                mess=[mess;"Window position must be [] or a 2 vector";" "]
+                ok=%f
+            end
+            if size(wdim,"*")<>0 &size(wdim,"*")<>2 then
+                mess=[mess;"Window dim must be [] or a 2 vector";" "]
+                ok=%f
+            end
+            if win<-1 then
+                mess=[mess;"Window number can''t be  < -1";" "]
+                ok=%f
+            end
+            if per<=0 then
+                mess=[mess;"Refresh period must be positive";" "]
+                ok=%f
+            end
+            if N<2 then
+                mess=[mess;"Buffer size must be at least 2";" "]
+                ok=%f
+            end
+            if ymin>=ymax then
+                mess=[mess;"Ymax must be greater than Ymin";" "]
+                ok=%f
+            end
+            if ~or(heritance==[0 1]) then
+                mess=[mess;"Accept herited events must be 0 or 1";" "]
+                ok=%f
+            end
+            if autoscale <> 0 & autoscale <> 1 then
+                mess=[mess;"Auto scaling must be 0:No or 1:Yes";" "]
+                ok=%f
+            end
+            if ~ok then
+                message(["Some specified values are inconsistent:";
+                " ";mess])
+            end
+            if ok then
+                [model,graphics,ok]=set_io(model,graphics,list([-1 1],1),list(),ones(1-heritance,1),[])
+            end
+
+            if ok then
+                if wpos==[] then
+                    wpos=[-1;-1];
+                end
+                if wdim==[] then
+                    wdim=[-1;-1];
+                end
+                rpar=[autoscale;ymin;ymax;per]
+                ipar=[win;1;N;clrs(:);wpos(:);wdim(:)]
+                //if prod(size(dstate))<>(8+1)*N+1 then dstate=-eye((8+1)*N+1,1),end
+                //model.dstate=[];
+                model.rpar=rpar;
+                model.ipar=ipar
+                model.evtin=ones(1-heritance,1)
+                model.label=nom;
+                graphics.id=nom
+                graphics.exprs=exprs;
+                x.graphics=graphics;
+                x.model=model
+                break
+            end
+        end
+    case "define" then
+        win=-1;
+        wdim=[600;400]
+        wpos=[-1;-1]
+        clrs=[1;3;5;7;9;11;13;15];
+        N=20;
+        ymin=-15;
+        ymax=+15;
+        per=30;
+        autoscale=1;
+
+        model=scicos_model()
+        model.sim=list("scale_cscope",4)
+        model.in=-1
+        model.in2=1
+        model.evtin=1
+        model.rpar=[autoscale;ymin;ymax;per]  //As Oth element was not used, It is now utilise for scaling parameter
+        model.ipar=[win;1;N;clrs;wpos;wdim]
+        model.blocktype="c"
+        model.dep_ut=[%t %f]
+
+        exprs=[strcat(string(clrs)," ");
+        string(win);
+        sci2exp([]);
+        sci2exp(wdim);
+        string(ymin);
+        string(ymax);
+        string(per);
+        string(N);
+        string(0)';
+        emptystr()  //label-id
+        string(autoscale)];
+        gr_i=[]
+        x=standard_define([2 2],model,exprs,gr_i)
+    end
+endfunction
index a77866f..68103e8 100644 (file)
@@ -266,6 +266,7 @@ lib /DEF:"$(ProjectDir)../elementary_functions_f_Import.def" /SUBSYSTEM:WINDOWS
     <ClCompile Include="..\cosh_blk.c" />
     <ClCompile Include="..\counter.c" />
     <ClCompile Include="..\cscope.c" />
+    <ClCompile Include="..\scale_cscope.c" />
     <ClCompile Include="..\cscopxy.c" />
     <ClCompile Include="..\cscopxy3d.c" />
     <ClCompile Include="..\csslti4.c" />
@@ -619,4 +620,4 @@ lib /DEF:"$(ProjectDir)../elementary_functions_f_Import.def" /SUBSYSTEM:WINDOWS
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
index 4e006a1..71af39c 100644 (file)
     <ClCompile Include="..\cscope.c">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\scale_cscope.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
     <ClCompile Include="..\cscopxy.c">
       <Filter>Source Files</Filter>
     </ClCompile>
       <Filter>Resource Files</Filter>
     </ResourceCompile>
   </ItemGroup>
-</Project>
\ No newline at end of file
+</Project>
index b149507..57dadab 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  *  Copyright (C) 2011-2012 - Scilab Enterprises - Clement DAVID
- *
+ *  Copyright (C) 2016-2017 - FOSSEE IIT Bombay - Dipti Ghosalkar
  * Copyright (C) 2012 - 2016 - Scilab Enterprises
  *
  * This file is hereby licensed under the terms of the GNU GPL v2.0,
@@ -532,74 +532,76 @@ static void appendData(scicos_block * block, int input, double t, double *data)
 
     sco_data *sco = (sco_data *) * (block->work);
 
-    /*
-     * Handle the case where the t is greater than the data_bounds
-     */
-    if (t > ((sco->scope.periodCounter + 1) * block->rpar[3]))
+    if (sco != NULL)
     {
-        sco->scope.periodCounter++;
 
-        // set the buffer coordinates to the last point
-        for (i = 0; i < block->insz[input]; i++)
+        /*
+         * Handle the case where the t is greater than the data_bounds
+         */
+        if (t > ((sco->scope.periodCounter + 1) * block->rpar[3]))
         {
-            sco->internal.bufferCoordinates[input][i][0] = sco->internal.bufferCoordinates[input][i][sco->internal.numberOfPoints - 1];
-            sco->internal.bufferCoordinates[input][i][block->ipar[2]] = sco->internal.bufferCoordinates[input][i][block->ipar[2] + sco->internal.numberOfPoints - 1];
-        }
-        sco->internal.numberOfPoints = 1;
+            sco->scope.periodCounter++;
 
-        // clear the history coordinates
-        sco->internal.maxNumberOfPoints = 0;
-        for (i = 0; i < block->insz[input]; i++)
-        {
-            if (sco->internal.historyCoordinates[input][i] != NULL)
+            // set the buffer coordinates to the last point
+            for (i = 0; i < block->insz[input]; i++)
             {
-                FREE(sco->internal.historyCoordinates[input][i]);
-                sco->internal.historyCoordinates[input][i] = NULL;
+                sco->internal.bufferCoordinates[input][i][0] = sco->internal.bufferCoordinates[input][i][sco->internal.numberOfPoints - 1];
+                sco->internal.bufferCoordinates[input][i][block->ipar[2]] = sco->internal.bufferCoordinates[input][i][block->ipar[2] + sco->internal.numberOfPoints - 1];
+            }
+            sco->internal.numberOfPoints = 1;
+
+            // clear the history coordinates
+            sco->internal.maxNumberOfPoints = 0;
+            for (i = 0; i < block->insz[input]; i++)
+            {
+                if (sco->internal.historyCoordinates[input][i] != NULL)
+                {
+                    FREE(sco->internal.historyCoordinates[input][i]);
+                    sco->internal.historyCoordinates[input][i] = NULL;
+                }
+            }
+
+            // configure scope setting
+            if (setPolylinesBounds(block, getAxe(getFigure(block), block, input), sco->scope.periodCounter) == FALSE)
+            {
+                set_block_error(-5);
+                freeScoData(block);
+                sco = NULL;
             }
         }
 
-        // configure scope setting
-        if (setPolylinesBounds(block, getAxe(getFigure(block), block, input), sco->scope.periodCounter) == FALSE)
+        /*
+         * Handle the case where the scope has more points than maxNumberOfPoints
+         */
+        if (sco->internal.numberOfPoints >= block->ipar[2])
         {
-            set_block_error(-5);
-            freeScoData(block);
-            sco = NULL;
-        }
-    }
+            int maxNumberOfPoints = sco->internal.maxNumberOfPoints;
 
-    /*
-     * Handle the case where the scope has more points than maxNumberOfPoints
-     */
-    if (sco != NULL && sco->internal.numberOfPoints >= block->ipar[2])
-    {
-        int maxNumberOfPoints = sco->internal.maxNumberOfPoints;
+            // on a full scope, re-alloc history coordinates
+            maxNumberOfPoints = maxNumberOfPoints + block->ipar[2];
+            sco = reallocHistoryBuffer(block, maxNumberOfPoints);
 
-        // on a full scope, re-alloc history coordinates
-        maxNumberOfPoints = maxNumberOfPoints + block->ipar[2];
-        sco = reallocHistoryBuffer(block, maxNumberOfPoints);
+            // set the buffer coordinates to the last point
+            for (i = 0; i < block->insz[input]; i++)
+            {
+                sco->internal.bufferCoordinates[input][i][0] = sco->internal.bufferCoordinates[input][i][block->ipar[2] - 1];
+                sco->internal.bufferCoordinates[input][i][block->ipar[2]] = sco->internal.bufferCoordinates[input][i][2 * block->ipar[2] - 1];
+            }
+            sco->internal.numberOfPoints = 1;
 
-        // set the buffer coordinates to the last point
-        for (i = 0; i < block->insz[input]; i++)
-        {
-            sco->internal.bufferCoordinates[input][i][0] = sco->internal.bufferCoordinates[input][i][block->ipar[2] - 1];
-            sco->internal.bufferCoordinates[input][i][block->ipar[2]] = sco->internal.bufferCoordinates[input][i][2 * block->ipar[2] - 1];
+            // reconfigure related graphic objects
+            if (pushHistory(block, input, sco->internal.maxNumberOfPoints) == FALSE)
+            {
+                set_block_error(-5);
+                freeScoData(block);
+                sco = NULL;
+            }
         }
-        sco->internal.numberOfPoints = 1;
 
-        // reconfigure related graphic objects
-        if (pushHistory(block, input, sco->internal.maxNumberOfPoints) == FALSE)
-        {
-            set_block_error(-5);
-            freeScoData(block);
-            sco = NULL;
-        }
-    }
+        /*
+         * Update data
+         */
 
-    /*
-     * Update data
-     */
-    if (sco != NULL)
-    {
         for (i = 0; i < block->insz[input]; i++)
         {
             const double value = data[i];
diff --git a/scilab/modules/scicos_blocks/src/c/scale_cscope.c b/scilab/modules/scicos_blocks/src/c/scale_cscope.c
new file mode 100644 (file)
index 0000000..30b60b8
--- /dev/null
@@ -0,0 +1,1055 @@
+/*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2011-2012 - Scilab Enterprises - Clement DAVID
+ *  Copyright (C) 2016-2017 - FOSSEE IIT Bombay - Dipti Ghosalkar
+ * Copyright (C) 2012 - 2016 - Scilab Enterprises
+ *
+ * This file is hereby licensed under the terms of the GNU GPL v2.0,
+ * pursuant to article 5.3.4 of the CeCILL v.2.1.
+ * This file was originally licensed under the terms of the CeCILL v2.1,
+ * and continues to be available under such terms.
+ * For more information, see the COPYING file which you should have received
+ * along with this program.
+ *
+ */
+
+#include <string.h>
+
+#include "dynlib_scicos_blocks.h"
+#include "scoUtils.h"
+
+#include "sci_malloc.h"
+#include "elementary_functions.h"
+
+#include "getGraphicObjectProperty.h"
+#include "setGraphicObjectProperty.h"
+#include "graphicObjectProperties.h"
+#include "createGraphicObject.h"
+#include "deleteGraphicObject.h"
+
+#include "CurrentFigure.h"
+#include "CurrentObject.h"
+
+#include "scicos_block4.h"
+#include "scicos.h"
+
+#include "localization.h"
+#include "os_string.h"
+
+#include "FigureList.h"
+#include "BuildObjects.h"
+#include "AxesModel.h"
+
+#define HISTORY_POINTS_THRESHOLD 4096
+
+/*****************************************************************************
+ * Internal container structure
+ ****************************************************************************/
+
+/**
+ * Container structure
+ */
+typedef struct
+{
+    struct
+    {
+        int numberOfPoints;
+        double ***bufferCoordinates;
+        int maxNumberOfPoints;
+        double ***historyCoordinates;
+    } internal;
+
+    struct
+    {
+        int periodCounter;
+
+        BOOL disableBufferUpdate;
+        int historyUpdateCounter;
+
+        int cachedFigureUID;
+        int cachedAxeUID;
+        int* cachedBufferPolylinesUIDs;
+        int* cachedHistoryPolylinesUIDs;
+    } scope;
+} sco_data;
+
+/**
+ * Get (and allocate on demand) the internal data used on this scope
+ * \param block the block
+ * \return the scope data
+ */
+static sco_data *getScoData(scicos_block * block);
+
+/**
+ * Release any internal data
+ *
+ * \param block the block
+ */
+static void freeScoData(scicos_block * block);
+
+/**
+ * Realloc the history buffer data
+ *
+ * \param block the block
+ * \param numberOfPoints realloc to store this number of points
+ */
+static sco_data *reallocHistoryBuffer(scicos_block * block, int numberOfPoints);
+
+/**
+ * Set values into the coordinates buffer.
+ *
+ * \param block the block
+ * \param coordinates the buffer
+ * \param numberOfPoints the number of points to set (actual)
+ * \param bufferPoints the buffer size (max)
+ * \param t the time to set
+ * \param value the value to set
+ */
+static void setBuffersCoordinates(scicos_block * block, double* coordinates, const int numberOfPoints,
+                                  const int bufferPoints, const double t, const double value);
+
+/**
+ * Append the data to the current data
+ *
+ * \param block the block
+ * \param input the input (0-indexed)
+ * \param t the current time
+ * \param data the data to append
+ */
+static void appendData(scicos_block * block, int input, double t, double *data);
+
+/**
+ * Push the block data to the polyline
+ *
+ * \param block the block
+ * \param input the selected input
+ * \param row the selected row
+ * \param iPolylineUID the polyline uid
+ *
+ */
+static BOOL pushData(scicos_block * block, int input, int row);
+
+/*****************************************************************************
+ * Graphics utils
+ ****************************************************************************/
+
+/**
+ * Get (and allocate on demand) the figure associated with the block
+ * \param block the block
+ * \return a valid figure UID or NULL on error
+ */
+static int getFigure(scicos_block * block);
+
+/**
+ * Get (and allocate on demand) the axe associated with the input
+ *
+ * \param iFigureUID the parent figure UID
+ * \param block the block
+ * \param input the current input index (0-indexed)
+ * \return a valid axe UID or NULL on error
+ */
+static int getAxe(int iFigureUID, scicos_block * block, int input);
+
+/**
+ * Get (and allocate on demand) the polyline associated with the row
+ *
+ * \param iAxeUID the parent axe UID
+ * \param block the block
+ * \param row the current row index (0-indexed)
+ * \param history get the history polyline
+ * \return a valid polyline UID or NULL on error
+ */
+static int getPolyline(int iAxeUID, scicos_block * block, int row, BOOL history);
+
+/**
+ * Delete all the buffer polylines.
+ *
+ * \param block the block
+ */
+static void deleteBufferPolylines(scicos_block * block);
+
+/**
+ * Set the polylines history size and push the history buffer
+ *
+ * \param block the block
+ * \param input the input port index
+ * \param maxNumberOfPoints the size of the buffer
+ */
+static BOOL pushHistory(scicos_block * block, int input, int maxNumberOfPoints);
+
+/**
+ * Set the polylines bounds
+ *
+ * \param block the current block
+ * \param iAxeUID the axe uid
+ * \param periodCounter number of past periods since startup
+ */
+static BOOL setPolylinesBounds(scicos_block * block, int iAxeUID, int periodCounter);
+
+/*****************************************************************************
+ * Simulation function
+ ****************************************************************************/
+
+/** \fn void scale_cscope(scicos_block * block,int flag)
+    \brief the computational function
+    \param block A pointer to a scicos_block
+    \param flag An int which indicates the state of the block (init, update, ending)
+*/
+SCICOS_BLOCKS_IMPEXP void scale_cscope(scicos_block * block, scicos_flag flag)
+{
+    int iFigureUID;
+
+    double t;
+    double *u;
+    sco_data *sco;
+
+    int i;
+    BOOL result;
+
+    switch (flag)
+    {
+
+        case Initialization:
+            sco = getScoData(block);
+            if (sco == NULL)
+            {
+                set_block_error(-5);
+                break;
+            }
+            iFigureUID = getFigure(block);
+            if (iFigureUID == 0)
+            {
+                // allocation error
+                set_block_error(-5);
+                break;
+            }
+            break;
+
+        case StateUpdate:
+            iFigureUID = getFigure(block);
+            if (iFigureUID == 0)
+            {
+                // allocation error
+                set_block_error(-5);
+                break;
+            }
+
+            t = get_scicos_time();
+            u = GetRealInPortPtrs(block, 1);
+
+            appendData(block, 0, t, u);
+
+            for (i = 0; i < block->insz[0]; i++)
+            {
+                result = pushData(block, 0, i);
+                if (result == FALSE)
+                {
+                    Coserror("%s: unable to push some data.", "scale_cscope");
+                    break;
+                }
+            }
+            break;
+
+        case Ending:
+            sco = getScoData(block);
+            sco = reallocHistoryBuffer(block, sco->internal.maxNumberOfPoints + sco->internal.numberOfPoints);
+            sco->scope.disableBufferUpdate = FALSE;
+            sco->scope.historyUpdateCounter = 0;
+#ifdef WITH_GUI
+            pushHistory(block, 0, sco->internal.maxNumberOfPoints);
+            deleteBufferPolylines(block);
+#endif
+            freeScoData(block);
+            break;
+
+        default:
+            break;
+    }
+}
+
+/*-------------------------------------------------------------------------*/
+
+/*****************************************************************************
+ *
+ * Container management
+ *
+ ****************************************************************************/
+
+static sco_data *getScoData(scicos_block * block)
+{
+    sco_data *sco = (sco_data *) * (block->work);
+    int i, j;
+
+    if (sco == NULL)
+    {
+        /*
+         * Data allocation
+         */
+
+        sco = (sco_data *) MALLOC(sizeof(sco_data));
+        if (sco == NULL)
+        {
+            goto error_handler_sco;
+        }
+
+        // 0 points out of a block->ipar[2] points buffer
+        sco->internal.numberOfPoints = 0;
+
+        sco->internal.bufferCoordinates = (double ***)CALLOC(block->nin, sizeof(double **));
+        if (sco->internal.bufferCoordinates == NULL)
+        {
+            goto error_handler_bufferCoordinates;
+        }
+
+        for (i = 0; i < block->nin; i++)
+        {
+            sco->internal.bufferCoordinates[i] = (double **)CALLOC(block->insz[i], sizeof(double *));
+            if (sco->internal.bufferCoordinates[i] == NULL)
+            {
+                goto error_handler_bufferCoordinates_i;
+            }
+        }
+        for (i = 0; i < block->nin; i++)
+        {
+            for (j = 0; j < block->insz[i]; j++)
+            {
+                sco->internal.bufferCoordinates[i][j] = (double *)CALLOC(3 * block->ipar[2], sizeof(double));
+
+                if (sco->internal.bufferCoordinates[i][j] == NULL)
+                {
+                    goto error_handler_bufferCoordinates_ij;
+                }
+            }
+        }
+
+        // 0 points out of a 0 points history
+        sco->internal.maxNumberOfPoints = 0;
+
+        sco->internal.historyCoordinates = (double ***)CALLOC(block->nin, sizeof(double **));
+        if (sco->internal.historyCoordinates == NULL)
+        {
+            goto error_handler_historyCoordinates;
+        }
+
+        for (i = 0; i < block->nin; i++)
+        {
+            sco->internal.historyCoordinates[i] = (double **)CALLOC(block->insz[i], sizeof(double *));
+            if (sco->internal.historyCoordinates[i] == NULL)
+            {
+                goto error_handler_historyCoordinates_i;
+            }
+        }
+
+        sco->scope.periodCounter = 0;
+
+        // flag to avoid pushing the buffer each time
+        sco->scope.disableBufferUpdate = FALSE;
+        // counter use to delay the history push
+        sco->scope.historyUpdateCounter = 0;
+
+        sco->scope.cachedFigureUID = 0;
+        sco->scope.cachedAxeUID = 0;
+        sco->scope.cachedBufferPolylinesUIDs = (int*)CALLOC(block->insz[0], sizeof(int));
+        sco->scope.cachedHistoryPolylinesUIDs = (int*)CALLOC(block->insz[0], sizeof(int));
+
+        *(block->work) = sco;
+    }
+
+    return sco;
+
+    /*
+     * Error management (out of normal flow)
+     */
+
+error_handler_historyCoordinates_i:
+    for (j = 0; j < i; j++)
+    {
+        FREE(sco->internal.historyCoordinates[j]);
+    }
+    FREE(sco->internal.historyCoordinates);
+error_handler_historyCoordinates:
+error_handler_bufferCoordinates_ij:
+    for (i = 0; i < block->nin - 1; i++)
+    {
+        for (j = 0; j < block->insz[i] - 1; j++)
+        {
+            double* ptr = sco->internal.bufferCoordinates[i][j];
+            if (ptr != NULL)
+            {
+                FREE(ptr);
+            }
+        }
+    }
+    i = block->nin - 1;
+error_handler_bufferCoordinates_i:
+    for (j = 0; j < i; j++)
+    {
+        FREE(sco->internal.bufferCoordinates[j]);
+    }
+    FREE(sco->internal.bufferCoordinates);
+error_handler_bufferCoordinates:
+    FREE(sco);
+error_handler_sco:
+    // allocation error
+    set_block_error(-5);
+    return NULL;
+}
+
+static void freeScoData(scicos_block * block)
+{
+    sco_data *sco = (sco_data *) * (block->work);
+    int i, j;
+
+    if (sco != NULL)
+    {
+        for (i = 0; i < block->nin; i++)
+        {
+            for (j = 0; j < block->insz[i]; j++)
+            {
+                if (sco->internal.historyCoordinates[i][j] != NULL)
+                {
+                    FREE(sco->internal.historyCoordinates[i][j]);
+                }
+                FREE(sco->internal.bufferCoordinates[i][j]);
+            }
+            FREE(sco->internal.historyCoordinates[i]);
+            FREE(sco->internal.bufferCoordinates[i]);
+        }
+        FREE(sco->internal.historyCoordinates);
+        FREE(sco->internal.bufferCoordinates);
+
+        FREE(sco->scope.cachedHistoryPolylinesUIDs);
+        FREE(sco->scope.cachedBufferPolylinesUIDs);
+
+        FREE(sco);
+        *(block->work) = NULL;
+    }
+}
+
+static sco_data *reallocHistoryBuffer(scicos_block * block, int numberOfPoints)
+{
+    sco_data *sco = (sco_data *) * (block->work);
+    int i;
+
+    double *ptr;
+    int allocatedNumberOfPoints;
+
+    int previousNumberOfPoints = sco->internal.maxNumberOfPoints;
+    int numberOfCopiedPoints = numberOfPoints - sco->internal.maxNumberOfPoints;
+
+    double *buffer;
+    int bufferNumberOfPoints = block->ipar[2];
+    int bufferNewPointInc;
+
+    if (previousNumberOfPoints == 0)
+    {
+        allocatedNumberOfPoints = numberOfPoints;
+        bufferNewPointInc = 0;
+    }
+    else
+    {
+        allocatedNumberOfPoints = numberOfPoints - 1;
+        bufferNewPointInc = 1;
+    }
+
+    if (sco->scope.historyUpdateCounter <= 0)
+    {
+        if (numberOfPoints > HISTORY_POINTS_THRESHOLD)
+        {
+            sco->scope.disableBufferUpdate = TRUE;
+            sco->scope.historyUpdateCounter = numberOfPoints / HISTORY_POINTS_THRESHOLD;
+        }
+        else
+        {
+            sco->scope.disableBufferUpdate = FALSE;
+            sco->scope.historyUpdateCounter = 0;
+        }
+    }
+
+    for (i = 0; i < block->insz[0]; i++)
+    {
+        ptr = (double *)MALLOC(3 * allocatedNumberOfPoints * sizeof(double));
+        if (ptr == NULL)
+        {
+            goto error_handler;
+        }
+
+        // memcpy existing X-axis values from the history
+        memcpy(ptr, sco->internal.historyCoordinates[0][i], previousNumberOfPoints * sizeof(double));
+        // memcpy existing Y-axis values from the history
+        memcpy(ptr + allocatedNumberOfPoints, sco->internal.historyCoordinates[0][i] + previousNumberOfPoints, previousNumberOfPoints * sizeof(double));
+        // clear the last points, the Z-axis values
+        memset(ptr + 2 * allocatedNumberOfPoints, 0, allocatedNumberOfPoints * sizeof(double));
+
+        // then set the last points to the last values for X-axis and Y-axis values from the buffer points
+        buffer = sco->internal.bufferCoordinates[0][i];
+        memcpy(ptr + previousNumberOfPoints, buffer + bufferNewPointInc, (numberOfCopiedPoints - bufferNewPointInc) * sizeof(double));
+        memcpy(ptr + allocatedNumberOfPoints + previousNumberOfPoints, buffer + bufferNumberOfPoints + bufferNewPointInc, (numberOfCopiedPoints - bufferNewPointInc) * sizeof(double));
+
+        FREE(sco->internal.historyCoordinates[0][i]);
+        sco->internal.historyCoordinates[0][i] = ptr;
+    }
+
+    sco->internal.maxNumberOfPoints = allocatedNumberOfPoints;
+    return sco;
+
+error_handler:
+    freeScoData(block);
+    // allocation error
+    set_block_error(-5);
+    return NULL;
+}
+
+static void setBuffersCoordinates(scicos_block* block, double* coordinates, const int numberOfPoints,
+                                  const int bufferPoints, const double t, const double value)
+{
+    int setLen;
+    sco_data *sco = (sco_data *) * (block->work);
+
+    if (sco->scope.disableBufferUpdate == TRUE)
+    {
+        coordinates[numberOfPoints] = t;
+        coordinates[bufferPoints + numberOfPoints] = value;
+        return;
+    }
+
+    // X-axis values first
+    for (setLen = numberOfPoints; setLen < bufferPoints; setLen++)
+    {
+        coordinates[setLen] = t;
+    }
+    // then Y-axis values
+    for (setLen = numberOfPoints; setLen < bufferPoints; setLen++)
+    {
+        coordinates[bufferPoints + setLen] = value;
+    }
+    // then Z-axis values (always clear'ed)
+}
+
+static void appendData(scicos_block * block, int input, double t, double *data)
+{
+    int i;
+
+    sco_data *sco = (sco_data *) * (block->work);
+
+    if (sco != NULL)
+    {
+
+        /*
+         * Handle the case where the t is greater than the data_bounds
+         */
+        if (t > ((sco->scope.periodCounter + 1) * block->rpar[3]))
+        {
+            sco->scope.periodCounter++;
+
+            // set the buffer coordinates to the last point
+            for (i = 0; i < block->insz[input]; i++)
+            {
+                sco->internal.bufferCoordinates[input][i][0] = sco->internal.bufferCoordinates[input][i][sco->internal.numberOfPoints - 1];
+                sco->internal.bufferCoordinates[input][i][block->ipar[2]] = sco->internal.bufferCoordinates[input][i][block->ipar[2] + sco->internal.numberOfPoints - 1];
+            }
+            sco->internal.numberOfPoints = 1;
+
+            // clear the history coordinates
+            sco->internal.maxNumberOfPoints = 0;
+            for (i = 0; i < block->insz[input]; i++)
+            {
+                if (sco->internal.historyCoordinates[input][i] != NULL)
+                {
+                    FREE(sco->internal.historyCoordinates[input][i]);
+                    sco->internal.historyCoordinates[input][i] = NULL;
+                }
+            }
+
+            // configure scope setting
+            if (setPolylinesBounds(block, getAxe(getFigure(block), block, input), sco->scope.periodCounter) == FALSE)
+            {
+                set_block_error(-5);
+                freeScoData(block);
+                sco = NULL;
+            }
+        }
+
+        /*
+         * Handle the case where the scope has more points than maxNumberOfPoints
+         */
+        if (sco->internal.numberOfPoints >= block->ipar[2])
+        {
+            int maxNumberOfPoints = sco->internal.maxNumberOfPoints;
+
+            // on a full scope, re-alloc history coordinates
+            maxNumberOfPoints = maxNumberOfPoints + block->ipar[2];
+            sco = reallocHistoryBuffer(block, maxNumberOfPoints);
+
+            // set the buffer coordinates to the last point
+            for (i = 0; i < block->insz[input]; i++)
+            {
+                sco->internal.bufferCoordinates[input][i][0] = sco->internal.bufferCoordinates[input][i][block->ipar[2] - 1];
+                sco->internal.bufferCoordinates[input][i][block->ipar[2]] = sco->internal.bufferCoordinates[input][i][2 * block->ipar[2] - 1];
+            }
+            sco->internal.numberOfPoints = 1;
+
+            // reconfigure related graphic objects
+            if (pushHistory(block, input, sco->internal.maxNumberOfPoints) == FALSE)
+            {
+                set_block_error(-5);
+                freeScoData(block);
+                sco = NULL;
+            }
+        }
+
+        /*
+         * Update data
+         */
+
+        for (i = 0; i < block->insz[input]; i++)
+        {
+            const double value = data[i];
+            setBuffersCoordinates(block, sco->internal.bufferCoordinates[input][i], sco->internal.numberOfPoints, block->ipar[2], t, value);
+
+
+            if ( block->rpar[0] == 1)
+            {
+                double max_curr_val, prev_max_curr_val, min_curr_val, prev_min_curr_val;
+                //Get the current maximum value of the axes
+                max_curr_val = block->rpar[2];
+                prev_max_curr_val = max_curr_val;
+
+                //Get the current minimum value of the axes
+                min_curr_val = block->rpar[1];
+                prev_min_curr_val = min_curr_val;
+
+                /* If the value to be plotted exceeds the current range, then we update the range.
+                 * We could update the range from current value to the new value i.e. (value + R)
+                 * where R varies from 0 to approx 150. So we have used (value + 100.0) to give the graph good feature.
+                 *
+                 * However, the auto-scaling feature implemented is general
+                 */
+
+                //If the value to be plotted is greater than or equal to the current max, then update the current max
+                if (value >= max_curr_val)
+                {
+                    max_curr_val = value + 10.0;
+                    block->rpar[2] = max_curr_val;
+                }
+
+                //If the value to be plotted is smaller than or equal to the current min, then update the current min
+                if (value <= min_curr_val)
+                {
+                    min_curr_val = value - 10.0;
+                    block->rpar[1] = min_curr_val;
+                }
+
+                //If value has changed, call the setPolylinesBounds function to update the ranges
+                if ((max_curr_val != prev_max_curr_val) || (min_curr_val != prev_min_curr_val))
+                {
+                    if (setPolylinesBounds(block, getAxe(getFigure(block), block, input), sco->scope.periodCounter) == FALSE)
+                    {
+                        set_block_error(-5);
+                        freeScoData(block);
+                        sco = NULL;
+                    }
+                }
+
+            }
+
+        }
+
+        sco->internal.numberOfPoints++;
+    }
+}
+
+static BOOL pushData(scicos_block * block, int input, int row)
+{
+    int iFigureUID;
+    int iAxeUID;
+    int iPolylineUID;
+
+    double *data;
+    sco_data *sco;
+
+    iFigureUID = getFigure(block);
+    iAxeUID = getAxe(iFigureUID, block, input);
+    iPolylineUID = getPolyline(iAxeUID, block, row, FALSE);
+
+    sco = getScoData(block);
+    if (sco == NULL)
+    {
+        return FALSE;
+    }
+
+    // do not push any data if disabled
+    if (sco->scope.disableBufferUpdate == TRUE)
+    {
+        return TRUE;
+    }
+
+    // select the right input and row
+    data = sco->internal.bufferCoordinates[input][row];
+
+    return setGraphicObjectProperty(iPolylineUID, __GO_DATA_MODEL_COORDINATES__, data, jni_double_vector, block->ipar[2]);
+}
+
+/*****************************************************************************
+ *
+ * Graphic utils
+ *
+ ****************************************************************************/
+
+/**
+ * Set properties on the figure.
+ *
+ * \param iFigureUID the figure uid
+ * \param block the current block
+ */
+static void setFigureSettings(int iFigureUID, scicos_block * block)
+{
+    char *label = NULL;
+
+    int nipar = GetNipar(block);
+    int *ipar = GetIparPtrs(block);
+
+    int win_pos[2];
+    int win_dim[2];
+
+    win_pos[0] = ipar[(nipar - 1) - 3];
+    win_pos[1] = ipar[(nipar - 1) - 2];
+    win_dim[0] = ipar[(nipar - 1) - 1];
+    win_dim[1] = ipar[nipar - 1];
+
+    if (win_pos[0] > 0 && win_pos[1] > 0)
+    {
+        setGraphicObjectProperty(iFigureUID, __GO_POSITION__, &win_pos, jni_int_vector, 2);
+    }
+
+    if (win_dim[0] > 0 && win_dim[1] > 0)
+    {
+        setGraphicObjectProperty(iFigureUID, __GO_SIZE__, &win_dim, jni_int_vector, 2);
+    }
+
+    label = GetLabelPtrs(block);
+    if (label != NULL)
+    {
+        if (strlen(label) > 0)
+        {
+            setGraphicObjectProperty(iFigureUID, __GO_NAME__, label, jni_string, 1);
+        }
+    }
+};
+
+/*****************************************************************************
+ *
+ * Graphic
+ *
+ ****************************************************************************/
+
+static int getFigure(scicos_block * block)
+{
+#ifdef WITH_GUI
+    signed int figNum;
+    int iFigureUID = 0;
+    int iAxe = 0;
+    int i__1 = 1;
+    sco_data *sco = (sco_data *) * (block->work);
+
+    int i;
+
+    // assert the sco is not NULL
+    if (sco == NULL)
+    {
+        return 0;
+    }
+
+    // fast path for an existing object
+    if (sco->scope.cachedFigureUID != 0)
+    {
+        return sco->scope.cachedFigureUID;
+    }
+
+    figNum = block->ipar[0];
+
+    // with a negative id, use the block number indexed from a constant.
+    if (figNum < 0)
+    {
+        figNum = 20000 + get_block_number();
+    }
+
+    iFigureUID = getFigureFromIndex(figNum);
+    // create on demand
+    if (iFigureUID == 0)
+    {
+        iFigureUID = createNewFigureWithAxes();
+        setGraphicObjectProperty(iFigureUID, __GO_ID__, &figNum, jni_int, 1);
+
+        // the stored uid is a reference to the figure map, not to the current figure
+        iFigureUID = getFigureFromIndex(figNum);
+        sco->scope.cachedFigureUID = iFigureUID;
+
+        // set configured parameters
+        setFigureSettings(iFigureUID, block);
+
+        // allocate the axes through the getter
+        for (i = 0; i < GetNin(block); i++)
+        {
+            iAxe = getAxe(iFigureUID, block, i);
+
+            /*
+             * Setup according to block settings
+             */
+            setLabel(iAxe, __GO_X_AXIS_LABEL__, "t");
+            setLabel(iAxe, __GO_Y_AXIS_LABEL__, "y");
+
+            setGraphicObjectProperty(iAxe, __GO_X_AXIS_VISIBLE__, &i__1, jni_bool, 1);
+            setGraphicObjectProperty(iAxe, __GO_Y_AXIS_VISIBLE__, &i__1, jni_bool, 1);
+
+            setPolylinesBounds(block, iAxe, 0);
+        }
+    }
+    else
+    {
+        // set configured parameters
+        setFigureSettings(iFigureUID, block);
+    }
+
+    if (sco->scope.cachedFigureUID == 0)
+    {
+        sco->scope.cachedFigureUID = iFigureUID;
+    }
+    return iFigureUID;
+#else
+    Coserror("%s: Scilab is compiled without GUI, can not use Scope.", "scale_cscope");
+    return 0;
+#endif
+}
+
+static int getAxe(int iFigureUID, scicos_block * block, int input)
+{
+    int iAxe;
+    int i;
+    sco_data *sco = (sco_data *) * (block->work);
+
+    // assert the sco is not NULL
+    if (sco == NULL)
+    {
+        return 0;
+    }
+
+    // fast path for an existing object
+    if (sco->scope.cachedAxeUID != 0)
+    {
+        return sco->scope.cachedAxeUID;
+    }
+
+    iAxe = findChildWithKindAt(iFigureUID, __GO_AXES__, input);
+
+    /*
+     * Allocate if necessary
+     */
+    if (iAxe == 0)
+    {
+        cloneAxesModel(iFigureUID);
+        iAxe = findChildWithKindAt(iFigureUID, __GO_AXES__, input);
+    }
+
+    /*
+     * Setup on first access
+     */
+    if (iAxe != 0)
+    {
+        // allocate the polylines through the getter
+        for (i = 0; i < block->insz[input]; i++)
+        {
+            getPolyline(iAxe, block, i, TRUE);
+        }
+        for (i = 0; i < block->insz[input]; i++)
+        {
+            getPolyline(iAxe, block, i, FALSE);
+        }
+    }
+    else
+    {
+        return 0;
+    }
+
+    /*
+     * then cache with local storage
+     */
+    sco->scope.cachedAxeUID = iAxe;
+    return sco->scope.cachedAxeUID;
+}
+
+static int getPolyline(int iAxeUID, scicos_block * block, int row, BOOL history)
+{
+    int iPolyline;
+    BOOL b__true = TRUE;
+
+    int color;
+
+    int* polylinesUIDs;
+    int polylineIndex;
+
+    sco_data *sco = (sco_data *) * (block->work);
+
+    // assert the sco is not NULL
+    if (sco == NULL)
+    {
+        return 0;
+    }
+
+    if (!history)
+    {
+        polylinesUIDs = sco->scope.cachedBufferPolylinesUIDs;
+        polylineIndex = block->insz[0] + row;
+    }
+    else
+    {
+        polylinesUIDs = sco->scope.cachedHistoryPolylinesUIDs;
+        polylineIndex = row;
+    }
+
+    // assert that the structure is in a good shape
+    if (polylinesUIDs == NULL)
+    {
+        return 0;
+    }
+
+    // fast path for an existing object
+    if (polylinesUIDs[row] != 0)
+    {
+        return polylinesUIDs[row];
+    }
+
+    iPolyline = findChildWithKindAt(iAxeUID, __GO_POLYLINE__, polylineIndex);
+
+    /*
+     * Allocate if necessary
+     */
+    if (iPolyline == 0)
+    {
+        iPolyline = createGraphicObject(__GO_POLYLINE__);
+
+        if (iPolyline != 0)
+        {
+            createDataObject(iPolyline, __GO_POLYLINE__);
+            setGraphicObjectRelationship(iAxeUID, iPolyline);
+        }
+        else
+        {
+            return 0;
+        }
+    }
+
+    /*
+     * Setup on first access
+     */
+
+    /*
+     * Default setup of the nGons property
+     */
+    {
+        int nGons = 1;
+        setGraphicObjectProperty(iPolyline, __GO_DATA_MODEL_NUM_GONS__, &nGons, jni_int, 1);
+    }
+
+    color = block->ipar[3 + row];
+    if (color > 0)
+    {
+        setGraphicObjectProperty(iPolyline, __GO_LINE_MODE__, &b__true, jni_bool, 1);
+        setGraphicObjectProperty(iPolyline, __GO_LINE_COLOR__, &color, jni_int, 1);
+    }
+    else
+    {
+        int iMarkSize = 4;
+        color = -color;
+        setGraphicObjectProperty(iPolyline, __GO_MARK_MODE__, &b__true, jni_bool, 1);
+        setGraphicObjectProperty(iPolyline, __GO_MARK_STYLE__, &color, jni_int, 1);
+        setGraphicObjectProperty(iPolyline, __GO_MARK_SIZE__, &iMarkSize, jni_int, 1);
+    }
+
+    {
+        int iClipState = 1; //on
+        setGraphicObjectProperty(iPolyline, __GO_CLIP_STATE__, &iClipState, jni_int, 1);
+    }
+
+    /*
+     * then cache with local storage
+     */
+    polylinesUIDs[row] = iPolyline;
+    return polylinesUIDs[row];
+}
+
+static void deleteBufferPolylines(scicos_block * block)
+{
+    int i, j;
+
+    int iPolylineUID;
+
+    sco_data *sco;
+
+    sco = getScoData(block);
+    for (i = 0; i < block->nin; i++)
+    {
+        for (j = 0; j < block->insz[i]; j++)
+        {
+            iPolylineUID = sco->scope.cachedBufferPolylinesUIDs[j];
+            deleteGraphicObject(iPolylineUID);
+        }
+    }
+}
+
+static BOOL pushHistory(scicos_block * block, int input, int maxNumberOfPoints)
+{
+    int i;
+
+    int iFigureUID;
+    int iAxeUID;
+    int iPolylineUID;
+
+    double *data;
+    sco_data *sco;
+
+    BOOL result = TRUE;
+
+    sco = getScoData(block);
+    iFigureUID = getFigure(block);
+    iAxeUID = getAxe(iFigureUID, block, input);
+
+    // push the data only if the counter == 0, decrement the counter if positive
+    if (sco->scope.historyUpdateCounter > 0)
+    {
+        sco->scope.historyUpdateCounter--;
+    }
+    if (sco->scope.historyUpdateCounter > 0)
+    {
+        return result;
+    }
+
+    for (i = 0; i < block->insz[input]; i++)
+    {
+        iPolylineUID = getPolyline(iAxeUID, block, i, TRUE);
+
+        data = sco->internal.historyCoordinates[input][i];
+        result = setGraphicObjectProperty(iPolylineUID, __GO_DATA_MODEL_COORDINATES__, data, jni_double_vector, maxNumberOfPoints);
+        if (result == FALSE)
+        {
+            return result;
+        }
+    }
+
+    return result;
+}
+
+static BOOL setPolylinesBounds(scicos_block * block, int iAxeUID, int periodCounter)
+{
+    double dataBounds[6];
+    double period = block->rpar[3];
+
+    dataBounds[0] = periodCounter * period; // xMin
+    dataBounds[1] = (periodCounter + 1) * period;   // xMax
+    dataBounds[2] = block->rpar[1]; // yMin
+    dataBounds[3] = block->rpar[2]; // yMax
+    dataBounds[4] = -1.0;       // zMin
+    dataBounds[5] = 1.0;        // zMax
+
+    return setGraphicObjectProperty(iAxeUID, __GO_DATA_BOUNDS__, dataBounds, jni_double_vector, 6);
+}
index b84506b..2def99d 100644 (file)
@@ -263,6 +263,7 @@ lib /DEF:"$(ProjectDir)elementary_functions_f_Import.def" /SUBSYSTEM:WINDOWS /MA
     <ClCompile Include="cosh_blk.c" />
     <ClCompile Include="counter.c" />
     <ClCompile Include="cscope.c" />
+    <ClCompile Include="scale_cscope.c" />
     <ClCompile Include="cscopxy.c" />
     <ClCompile Include="cscopxy3d.c" />
     <ClCompile Include="csslti4.c" />
index 8125566..1af0fc9 100644 (file)
     <ClCompile Include="cscope.c">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="scale_cscope.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
     <ClCompile Include="cscopxy.c">
       <Filter>Source Files</Filter>
     </ClCompile>
       <Filter>Resource Files</Filter>
     </ResourceCompile>
   </ItemGroup>
-</Project>
\ No newline at end of file
+</Project>
index e77ad43..78a0d4f 100644 (file)
@@ -291,6 +291,7 @@ images/palettes/CONVERT.png \
 images/palettes/COSBLK_f.png \
 images/palettes/Counter.png \
 images/palettes/CSCOPE.png \
+images/palettes/SCALE_CSCOPE.png \
 images/palettes/CSCOPXY3D.png \
 images/palettes/CSCOPXY.png \
 images/palettes/CUMSUM.png \
index 3402020..b4eec27 100644 (file)
@@ -872,6 +872,7 @@ images/palettes/CONVERT.png \
 images/palettes/COSBLK_f.png \
 images/palettes/Counter.png \
 images/palettes/CSCOPE.png \
+images/palettes/SCALE_CSCOPE.png \
 images/palettes/CSCOPXY3D.png \
 images/palettes/CSCOPXY.png \
 images/palettes/CUMSUM.png \
index d37a0da..103d2ad 100644 (file)
     <add as="CSCOPE" extend="Icon">
         <add as="image" value="$SCILAB/modules/xcos/images/blocks/ASCOPE.svg"/>
     </add>
+    <add as="SCALE_CSCOPE" extend="Icon">
+        <add as="image" value="$SCILAB/modules/xcos/images/blocks/SCALE_ASCOPE.svg"/>
+    </add>
     <add as="CSCOPXY" extend="Icon">
         <add as="image" value="$SCILAB/modules/xcos/images/blocks/CSCOPXY.svg"/>
     </add>
index 559d18b..26d34ba 100644 (file)
             <block name="CSCOPE">
                 <icon variable="SCI" path="/modules/xcos/images/palettes/CSCOPE.png"/>
             </block>
+            <block name="SCALE_CSCOPE">
+                <icon variable="SCI" path="/modules/xcos/images/palettes/SCALE_CSCOPE.png"/>
+            </block>
             <block name="CSCOPXY">
                 <icon variable="SCI" path="/modules/xcos/images/palettes/CSCOPXY.png"/>
             </block>
diff --git a/scilab/modules/xcos/examples/sinks_pal/en_US/SCALE_CSCOPE_en_US.zcos b/scilab/modules/xcos/examples/sinks_pal/en_US/SCALE_CSCOPE_en_US.zcos
new file mode 100644 (file)
index 0000000..17524e7
Binary files /dev/null and b/scilab/modules/xcos/examples/sinks_pal/en_US/SCALE_CSCOPE_en_US.zcos differ
index 1541a28..cfb9508 100644 (file)
                     <imagedata linkend="CSCOPE" fileref="../../../../../../modules/xcos/images/palettes/CSCOPE.png" width="100" depth="100" scalefit="0" align="center" valign="middle"/>
                 </imageobject>
             </inlinemediaobject>
+             <inlinemediaobject>
+                <imageobject>
+                    <imagedata linkend="SCALE_CSCOPE" fileref="../../../../../../modules/xcos/images/palettes/SCALE_CSCOPE.png" width="100" depth="100" scalefit="0" align="center" valign="middle"/>
+                </imageobject>
+            </inlinemediaobject>
             <inlinemediaobject>
                 <imageobject>
                     <imagedata linkend="CSCOPXY" fileref="../../../../../../modules/xcos/images/palettes/CSCOPXY.png" width="100" depth="100" scalefit="0" align="center" valign="middle"/>
             </listitem>
             <listitem>
                 <para>
+                    <link linkend="SCALE_CSCOPE">CSCOPE - Single Display Scope with Autoscale Graph Feature</link>
+                </para>
+            </listitem>
+            <listitem>
+                <para>
                     <link linkend="CSCOPXY">CSCOPXY - y=f(x) permanent viewer</link>
                 </para>
             </listitem>
index 7171869..4f6188a 100644 (file)
         <itemizedlist>
             <listitem>
                 <para>
+                    <link linkend="SCALE_CSCOPE">SCALE_CSCOPE - Single Display Scope with autoscale feature of graph</link>
+                </para>
+            </listitem>
+            <listitem>
+                <para>
                     <link linkend="CMSCOPE">CMSCOPE - Multi display scope</link>
                 </para>
             </listitem>
diff --git a/scilab/modules/xcos/help/en_US/palettes/Sinks_pal/SCALE_CSCOPE.xml b/scilab/modules/xcos/help/en_US/palettes/Sinks_pal/SCALE_CSCOPE.xml
new file mode 100644 (file)
index 0000000..501df82
--- /dev/null
@@ -0,0 +1,321 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Scicos
+ *
+ * Copyright (C) INRIA - METALAU Project <scicos@inria.fr> (HTML version)
+ * Copyright (C) DIGITEO - Scilab Consortium (XML Docbook version)
+ * Copyright (C) 2016-2017 - FOSSEE IIT Bombay - Dipti Ghosalkar
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * See the file ./license.txt
+ -->
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="SCALE_CSCOPE">
+    <refnamediv>
+        <refname>SCALE_CSCOPE</refname>
+        <refpurpose>Single Display Scope with autoscale feature of graph</refpurpose>
+    </refnamediv>
+    <refsection>
+        <title>Block Screenshot</title>
+        <para>
+            <inlinemediaobject>
+                <imageobject>
+                    <imagedata fileref="../../../../images/palettes/SCALE_CSCOPE.png" align="center" valign="middle"/>
+                </imageobject>
+            </inlinemediaobject>
+        </para>
+    </refsection>
+    <refsection id="Contents_SCALE_CSCOPE">
+        <title>Contents</title>
+        <itemizedlist>
+            <listitem>
+                <para>
+                    <link linkend="SCALE_CSCOPE">Single Display Scope with autoscale feature of graph</link>
+                </para>
+            </listitem>
+            <listitem>
+                <itemizedlist>
+                    <listitem>
+                        <para>
+                            <xref linkend="Palette_SCALE_CSCOPE">Palette</xref>
+                        </para>
+                    </listitem>
+                    <listitem>
+                        <para>
+                            <xref linkend="Description_SCALE_CSCOPE">Description</xref>
+                        </para>
+                    </listitem>
+                    <listitem>
+                        <para>
+                            <xref linkend="Dialogbox_SCALE_CSCOPE">Dialog box</xref>
+                        </para>
+                    </listitem>
+                    <listitem>
+                        <para>
+                            <xref linkend="Defaultproperties_SCALE_CSCOPE">Default properties</xref>
+                        </para>
+                    </listitem>
+                    <listitem>
+                        <para>
+                            <xref linkend="Interfacingfunction_SCALE_CSCOPE">Interfacing function</xref>
+                        </para>
+                    </listitem>
+                    <listitem>
+                        <para>
+                            <xref linkend="Computationalfunction_SCALE_CSCOPE">Computational function</xref>
+                        </para>
+                    </listitem>
+                    <listitem>
+                        <para>
+                            <xref linkend="Seealso_SCALE_CSCOPE">See also</xref>
+                        </para>
+                    </listitem>
+                </itemizedlist>
+            </listitem>
+        </itemizedlist>
+    </refsection>
+    <refsection id="Palette_SCALE_CSCOPE">
+        <title>Palette</title>
+        <itemizedlist>
+            <listitem>
+                <para>
+                    <link linkend="Sinks_pal">Sinks palette</link>
+                </para>
+            </listitem>
+        </itemizedlist>
+    </refsection>
+    <refsection id="Description_SCALE_CSCOPE">
+        <title>Description</title>
+        <para>
+            The Scope block displays its input with respect to simulation
+            time. Both axes have a common range.  The Scope allows you to adjust
+            the amount of time and the range of input values displayed. It has feature to scale graph at runtime.
+
+        </para>
+    </refsection>
+    <refsection id="Dialogbox_SCALE_CSCOPE">
+        <title>Dialog box</title>
+        <para>
+            <inlinemediaobject>
+                <imageobject>
+                    <imagedata fileref="../../../../images/gui/SCALE_CSCOPE_gui.gif" align="center" valign="middle"/>
+                </imageobject>
+            </inlinemediaobject>
+        </para>
+        <para>
+
+        </para>
+        <itemizedlist>
+            <listitem>
+                <para>
+                    <emphasis role="bold">Color </emphasis>
+                </para>
+                <para>
+                    a vector of integers. The i-th element is the color number (≥ 0) or marker type (&lt; 0) used to draw the evolution of the i-th input port signal. See<emphasis role="bold">plot2d</emphasis> for color (dash type) definitions.
+                </para>
+                <para> Properties : Type 'vec' of size 8 </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis role="bold">Output window number </emphasis>
+                </para>
+                <para>
+                    The number of graphic window used for the display. It is often good to use high values to avoid conflict with palettes and Super Block windows. If default value is used<emphasis role="bold">(1)</emphasis> , Scicos define the output window number.
+                </para>
+                <para> Properties : Type 'vec' of size 1 </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis role="bold">Output window position</emphasis>
+                </para>
+                <para> a 2 vector specifying the coordinates of the upper left corner of the graphic window. Answer [] for default window position.</para>
+                <para> Properties : Type 'vec' of size 1 </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis role="bold">Output window sizes</emphasis>
+                </para>
+                <para> a 2 vector specifying the coordinates of the upper left corner of the graphic window. Answer [] for default window position.</para>
+                <para> Properties : Type 'vec' of size -1 </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis role="bold">Ymin</emphasis>
+                </para>
+                <para> Minimum values of the input; used to set up the Y-axis of the plot in the graphics window.</para>
+                <para> Properties : Type 'vec' of size 1 </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis role="bold">Ymax</emphasis>
+                </para>
+                <para> Maximum values of the input; used to set up the Y-axis of the plot in the graphics window.</para>
+                <para> Properties : Type 'vec' of size 1 </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis role="bold">Refresh period</emphasis>
+                </para>
+                <para> Maximum value on the X-axis (time). The plot is redrawn when time reaches a multiple of this value.</para>
+                <para> Properties : Type 'vec' of size 1 </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis role="bold">Buffer size</emphasis>
+                </para>
+                <para>
+                    To improve efficiency it is possible to buffer the input data. The drawing is only done after each<emphasis role="bold">Buffer size</emphasis> call to the block.
+                </para>
+                <para> Properties : Type 'vec' of size 1 </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis role="bold">Accept herited events 0/1</emphasis>
+                </para>
+                <para>
+                    if 0<emphasis role="bold">CSCOPE_f</emphasis> draws a new point only when an event occurs on its event input port. If 1<emphasis role="bold">CSCOPE_f</emphasis> draws a new point when an event occurs on its event input port and when it's regular input changes due to an event on an other upstream block (herited events).
+                </para>
+                <para> Properties : Type 'vec' of size 1 </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis role="bold">Name of Scope </emphasis>
+                </para>
+                <para> Name/label of the block.</para>
+                <para> Properties : Type 'str' of size 1</para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis role="bold">Auto scale 0/1</emphasis>
+                </para>
+                <para>
+                    if 0 autoscaling of graph wont be activated  If 1 autoscaling of graph at runtime will be activated and visible.
+                </para>
+                <para> Properties : Type 'vec' of size 1</para>
+            </listitem>
+        </itemizedlist>
+    </refsection>
+    <refsection id="Defaultproperties_SCALE_CSCOPE">
+        <title>Default properties</title>
+        <itemizedlist>
+            <listitem>
+                <para>
+                    <emphasis role="bold">always active:</emphasis> no
+                </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis role="bold">direct-feedthrough:</emphasis> yes
+                </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis role="bold">zero-crossing:</emphasis> no
+                </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis role="bold">mode:</emphasis> no
+                </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis role="bold">regular inputs:</emphasis>
+                </para>
+                <para>
+                    <emphasis role="bold">- port 1 : size [-1,1] / type 1</emphasis>
+                </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis role="bold">number/sizes of activation inputs:</emphasis> 1
+                </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis role="bold">number/sizes of activation outputs:</emphasis> 0
+                </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis role="bold">continuous-time state:</emphasis> no
+                </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis role="bold">discrete-time state:</emphasis> no
+                </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis role="bold">object discrete-time state:</emphasis> no
+                </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <emphasis role="bold">name of computational function:</emphasis>
+                    <emphasis role="italic">scale_cscope</emphasis>
+                </para>
+            </listitem>
+        </itemizedlist>
+    </refsection>
+    <refsection id="Interfacingfunction_SCALE_CSCOPE">
+        <title>Interfacing function</title>
+        <itemizedlist>
+            <listitem>
+                <para> SCI/modules/scicos_blocks/macros/Sinks/SCALE_CSCOPE.sci</para>
+            </listitem>
+        </itemizedlist>
+    </refsection>
+    <refsection id="Computationalfunction_SCALE_CSCOPE">
+        <title>Computational function</title>
+        <itemizedlist>
+            <listitem>
+                <para> SCI/modules/scicos_blocks/src/c/scale_cscope.c (Type 4)</para>
+            </listitem>
+        </itemizedlist>
+    </refsection>
+    <refsection id="Example_SCALE_CSCOPE">
+        <title>Single display scope example with auto scale</title>
+        <para>
+            <link type="scilab" linkend="scilab.xcos/xcos/examples/sinks_pal/en_US/SCALE_CSCOPE_en_US.zcos">
+                <inlinemediaobject>
+                    <imageobject>
+                        <imagedata fileref="../../../../examples/sinks_pal/en_US/SCALE_CSCOPE_en_US.zcos" align="center" valign="middle"/>
+                    </imageobject>
+                </inlinemediaobject>
+            </link>
+        </para>
+        <scilab:image><![CDATA[
+            importXcosDiagram(SCI + "/modules/xcos/examples/sinks_pal/en_US/SCALE_CSCOPE_en_US.zcos");
+            xcos_simulate(scs_m, 4);
+        ]]></scilab:image>
+    </refsection>
+    <refsection id="Seealso_SCALE_CSCOPE">
+        <title>See also</title>
+        <itemizedlist>
+            <listitem>
+                <para>
+                    <link linkend="CSCOPE">CSCOPE - Single Display Scope</link>
+                </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <link linkend="CMSCOPE">CMSCOPE - Multi display scope</link>
+                </para>
+            </listitem>
+        </itemizedlist>
+    </refsection>
+</refentry>
diff --git a/scilab/modules/xcos/images/blocks/SCALE_ASCOPE.svg b/scilab/modules/xcos/images/blocks/SCALE_ASCOPE.svg
new file mode 100644 (file)
index 0000000..3ee5fe6
--- /dev/null
@@ -0,0 +1,225 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:xlink="http://www.w3.org/1999/xlink"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   id="svg11300"
+   height="46.82"
+   width="42.060001"
+   version="1.1"
+   inkscape:version="0.48.4 r9939"
+   sodipodi:docname="CSCOPE(4).svg">
+  <metadata
+     id="metadata23">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title>base scilan</dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <sodipodi:namedview
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1"
+     objecttolerance="10"
+     gridtolerance="10"
+     guidetolerance="10"
+     inkscape:pageopacity="0"
+     inkscape:pageshadow="2"
+     inkscape:window-width="1280"
+     inkscape:window-height="968"
+     id="namedview21"
+     showgrid="false"
+     inkscape:zoom="2.0644596"
+     inkscape:cx="20.531"
+     inkscape:cy="32.782928"
+     inkscape:window-x="-4"
+     inkscape:window-y="-4"
+     inkscape:window-maximized="1"
+     inkscape:current-layer="g20882"
+     inkscape:snap-global="false" />
+  <title
+     id="title3289">base scilan</title>
+  <defs
+     id="defs3">
+    <radialGradient
+       id="radialGradient20899"
+       gradientUnits="userSpaceOnUse"
+       cy="32.266998"
+       cx="23.993999"
+       gradientTransform="matrix(2.2986116,0,0,1.8027613,-165.02072,-73.515408)"
+       r="19.089001">
+      <stop
+         id="stop2224"
+         stop-color="#5187d6"
+         offset="0" />
+      <stop
+         id="stop2227"
+         stop-color="#1e4580"
+         offset="1" />
+    </radialGradient>
+    <linearGradient
+       id="linearGradient2854"
+       y2="24.238001"
+       gradientUnits="userSpaceOnUse"
+       x2="12.499"
+       gradientTransform="matrix(0,-5.2949447,2.66303,0,-81.023673,165.50863)"
+       y1="12.538"
+       x1="8.8207998">
+      <stop
+         id="stop2182"
+         stop-color="#FFF"
+         offset="0" />
+      <stop
+         id="stop2184"
+         stop-color="#FFF"
+         stop-opacity="0"
+         offset="1" />
+    </linearGradient>
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient2854"
+       id="linearGradient3787"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(0,-5.2949447,2.66303,0,-81.023673,165.50863)"
+       x1="8.8207998"
+       y1="12.538"
+       x2="12.499"
+       y2="24.238001" />
+    <radialGradient
+       inkscape:collect="always"
+       xlink:href="#radialGradient20899"
+       id="radialGradient3797"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(2.2974068,0,0,1.5938144,-164.9918,-76.107651)"
+       cx="23.993999"
+       cy="32.266998"
+       r="19.089001" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient2854"
+       id="linearGradient3799"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(0,-5.2878278,3.0292811,0,-91.4686,165.43384)"
+       x1="8.8207998"
+       y1="12.538"
+       x2="12.499"
+       y2="24.238001" />
+    <radialGradient
+       inkscape:collect="always"
+       xlink:href="#radialGradient20899"
+       id="radialGradient3810"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(2.2974068,0,0,1.5938144,-164.9918,-76.107651)"
+       cx="23.993999"
+       cy="32.266998"
+       r="19.089001" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient2854"
+       id="linearGradient3812"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(0,-5.2878278,3.0292811,0,-91.4686,165.43384)"
+       x1="8.8207998"
+       y1="12.538"
+       x2="12.499"
+       y2="24.238001" />
+  </defs>
+  <g
+     id="layer1"
+     transform="translate(-2.8842799e-7,-1.1803534)">
+    <g
+       id="layer1-0"
+       transform="matrix(0,0.68137179,-0.68137179,0,39.302853,7.826163)">
+      <g
+         id="g9544"
+         transform="translate(-2.0023665,2.2530854)">
+        <g
+           id="g9570"
+           transform="translate(0.34662852,-1.7289484)">
+          <g
+             id="g28489"
+             transform="translate(2.3098495,0.12996954)">
+            <g
+               id="g20882"
+               transform="translate(51.47752,-82.884097)">
+              <g
+                 id="g3801"
+                 transform="translate(-4.1060094e-7,1.5314042e-6)">
+                <g
+                   id="g3789">
+                  <rect
+                     id="rect1314"
+                     style="fill:url(#radialGradient3810);fill-rule:evenodd;stroke:#173562;stroke-width:0.31592739;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0"
+                     transform="matrix(0,-1,1,0,0,0)"
+                     rx="2.2013454"
+                     ry="1.9472218"
+                     height="33.269424"
+                     width="48.293674"
+                     stroke-miterlimit="4"
+                     y="-52.23753"
+                     x="-134.01468" />
+                  <g
+                     id="g3778"
+                     transform="matrix(1.1375317,0,0,0.99865592,-1.3232844,-0.70816988)">
+                    <path
+                       style="fill:none;stroke:#000000;stroke-width:1.60812891px;stroke-linecap:round;stroke-linejoin:round"
+                       inkscape:connector-curvature="0"
+                       d="m -40.53312,128.84479 c 19.420253,-0.18362 19.664793,-0.18362 19.664793,-0.18362 l 0.122138,-36.056331"
+                       id="path28138" />
+                  </g>
+                  <path
+                     id="rect2178"
+                     d="m -52.084412,133.72334 15.275975,0 c 1.190922,-5.09399 1.86899,-10.74193 1.86899,-16.69995 0,-12.40257 -2.881256,-23.510144 -7.404261,-30.927715 h -9.740468 v 47.627665 z"
+                     style="opacity:0.43181817;fill:url(#linearGradient3812);fill-rule:evenodd"
+                     inkscape:connector-curvature="0" />
+                  <path
+                     id="path18808"
+                     style="fill:none;stroke:#ef2929;stroke-width:3.42799807;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none"
+                     d="m -37.998149,124.7242 -0.458136,-0.30667 -0.454233,-0.30578 -0.448541,-0.30643 -0.44269,-0.30665 -0.860815,-0.61243 -0.416826,-0.30666 -0.405933,-0.30557 -0.394551,-0.30664 -0.38105,-0.3058 -0.368518,-0.30665 -0.353243,-0.30665 -0.337942,-0.30643 -0.320878,-0.30579 -0.304286,-0.30666 -0.286397,-0.30665 -0.267528,-0.30577 -0.248343,-0.30666 -0.228664,-0.30557 -0.207845,-0.30665 -0.186703,-0.30665 -0.165239,-0.30579 -0.1436,-0.30665 -0.120668,-0.30644 -0.0984,-0.30579 -0.07562,-0.30663 -0.05221,-0.30667 -0.02976,-0.30578 -0.0057,-0.30666 0.01708,-0.30643 0.04066,-0.30578 0.06359,-0.30666 0.08635,-0.30665 0.109283,-0.30578 0.132058,-0.30644 0.153852,-0.30665 0.175963,-0.30579 0.196951,-0.30665 0.217928,-0.30664 0.237443,-0.30579 0.257929,-0.30644 0.277126,-0.30666 0.294696,-0.30579 0.313229,-0.30664 0.329006,-0.30643 0.345593,-0.3058 0.360231,-0.30666 0.37487,-0.30663 0.387549,-0.30578 0.400242,-0.30667 0.410985,-0.30557 0.421853,-0.30664 0.430647,-0.30666 0.438297,-0.30665 0.445447,-0.30579 0.451634,-0.30644 0.456181,-0.30577 0.459275,-0.30665 0.461881,-0.30666 0.463019,-0.30579 0.463179,-0.30664 0.462522,-0.30645 0.459274,-0.30578 0.456181,-0.30665 0.451626,-0.30665 0.445945,-0.30579 0.439105,-0.30645 0.430657,-0.30665 0.421869,-0.30578 0.411626,-0.30665 0.400241,-0.30665 0.388689,-0.3058 0.374869,-0.30643 0.360881,-0.30664 0.346241,-0.3058 0.329655,-0.30664 0.313231,-0.30666 0.295995,-0.30557 0.276963,-0.30664 0.258588,-0.30579 0.238909,-0.306654 0.218579,-0.306643 0.1976,-0.306431 0.176621,-0.305799 0.154991,-0.306645 0.132055,-0.306655 0.11059,-0.305785 0.08701,-0.306433 0.06474,-0.305797 0.0413,-0.306645 0.01786,-0.306644 -0.0051,-0.306655 -0.02846,-0.305797 -0.05155,-0.306421 -0.07496,-0.305797 -0.09709,-0.306655 -0.120837,-0.306644"
+                     stroke-miterlimit="4"
+                     inkscape:connector-curvature="0" />
+                  <rect
+                     x="-133.95796"
+                     y="-22.43655"
+                     stroke-miterlimit="4"
+                     width="48.191029"
+                     height="21.494463"
+                     ry="1.258047"
+                     rx="2.196667"
+                     transform="matrix(0,-1,1,0,0,0)"
+                     style="fill:#e6e6e6;fill-rule:evenodd;stroke:#173562;stroke-width:0.45349243;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0"
+                     id="rect3004" />
+                </g>
+              </g>
+              <text
+                 xml:space="preserve"
+                 style="font-size:28.15645981px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:125%;letter-spacing:0px;word-spacing:0px;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Arial;-inkscape-font-specification:Sans"
+                 x="-140.6993"
+                 y="-6.3139634"
+                 id="text3000"
+                 sodipodi:linespacing="125%"
+                 transform="matrix(0,-0.93697107,1.0672688,0,0,0)"><tspan
+                   sodipodi:role="line"
+                   id="tspan3002"
+                   x="-140.6993"
+                   y="-6.3139634"
+                   style="font-size:11.73185921px;fill:#000000;stroke-width:0">SCALED</tspan></text>
+            </g>
+          </g>
+        </g>
+      </g>
+    </g>
+  </g>
+</svg>
diff --git a/scilab/modules/xcos/images/gui/SCALE_CSCOPE_gui.gif b/scilab/modules/xcos/images/gui/SCALE_CSCOPE_gui.gif
new file mode 100644 (file)
index 0000000..3f608c3
Binary files /dev/null and b/scilab/modules/xcos/images/gui/SCALE_CSCOPE_gui.gif differ
diff --git a/scilab/modules/xcos/images/palettes/SCALE_CSCOPE.png b/scilab/modules/xcos/images/palettes/SCALE_CSCOPE.png
new file mode 100644 (file)
index 0000000..ace80b0
Binary files /dev/null and b/scilab/modules/xcos/images/palettes/SCALE_CSCOPE.png differ