summaryrefslogtreecommitdiff
path: root/modules/graphics/macros/getSurfPropertyName.sci
blob: 02062d93813c1687e11bc5c4aba69e223209d434 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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