The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 How can I alter the fill, pattern, and gradient

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Lara Cowan Posted - 09/18/2013 : 2:26:34 PM
Origin Version and Service Release : Origin 9.0.0 (32-bit) b45 (Government)
Operating System: Windows 7 SP1

How can I programatically (using Origin C or LabTalk) set the fill color, transparency, fill pattern style, fill pattern color, fill pattern width, gradient mode, gradient color, and gradient direction of a plot?

I basically want to know how to do the things in the Plot Details form, especially the Pattern tab.

I tried the following to set the fill color, but it does not work properly for me. When my program runs, the plot is not filled.

LT_execute("set %C -pf 1;");
LT_execute("set %C -pfv 1;");
LT_execute("set %C -cf 4;"); // Make it blue

If I put a break point on the first line and step through, then the plot will fill with black, but will not fill with the designated color.

I have not found a way to set the pattern or gradient properties.

Any help would be appreciated.
2   L A T E S T    R E P L I E S    (Newest First)
Lara Cowan Posted - 09/24/2013 : 10:06:41 AM
Thank you very much Castiel, that code works perfectly.
Castiel Posted - 09/19/2013 : 09:05:07 AM
#include <Origin.h>

enum{
    NO_ERROR                            = 0,
    INVALID_GRAPHPAGE                   = -1,
    INVALID_GRAPHLAYER                  = -2,
    INVALID_DATAPLOT                    = -3,
    UPDATE_THEME_ID_FAIL                = -4,
    APPLY_FORMAT_FAIL                   = -5
};

enum FILL_AREA{
    FILL_AREA_NONE                      = 0,
    FILL_AREA_NORMAL                    = 1,
    FILL_AREA_INCLUSIVE_BROKEN          = 2,
    FILL_AREA_EXCLUSIVE_BROKEN          = 3,
    FILL_AREA_SIDELINES                 = 4,
    FILL_AREA_SPAN_VERTICALLY_BROKEN    = 5,
    FILL_AREA_SIDELINES_BASE            = 6
};

enum GRADIENT_MODE{
    GRADIENT_MODE_NONE                  = 0,
    GRADIENT_MODE_ONE                   = 1,
    GRADIENT_MODE_TWO                   = 2
};

enum GRADIENT_DIRECTION{
    GRADIENT_DIRECTION_TOP_BOTTOM       = 0,
    GRADIENT_DIRECTION_BOTTOM_TOP       = 1,
    GRADIENT_DIRECTION_LEFT_RIGHT       = 2,
    GRADIENT_DIRECTION_RIGHT_LEFT       = 3,
    GRADIENT_DIRECTION_DIAG_LT_BR       = 4,
    GRADIENT_DIRECTION_DIAG_TR_BL       = 5,
    GRADIENT_DIRECTION_VERT_C_OUT       = 6,
    GRADIENT_DIRECTION_VERT_C_IN        = 7,
    GRADIENT_DIRECTION_HORI_C_OUT       = 8,
    GRADIENT_DIRECTION_HORI_C_IN        = 9,
    GRADIENT_DIRECTION_DIAG_UCOUT       = 10,
    GRADIENT_DIRECTION_DIAG_DCOUT       = 11,
    GRADIENT_DIRECTION_CORN_TL          = 12,
    GRADIENT_DIRECTION_CORN_TR          = 13,
    GRADIENT_DIRECTION_CORN_BR          = 14,
    GRADIENT_DIRECTION_CORN_BL          = 15,
    GRADIENT_DIRECTION_CENTER           = 16
};

enum FILL_PATTERN{
    FILL_PATTERN_NONE                   = 0,
    FILL_PATTERN_BL_TR_DENSE            = 1,
    FILL_PATTERN__BL_TR_MEDIUM          = 2,
    FILL_PATTERN__BL_TR_SPARSE          = 3,
    FILL_PATTERN_TL_BR_DENSE            = 4,
    FILL_PATTERN_TL_BR_MEDIUM           = 5,
    FILL_PATTERN_TL_BR_SPARSE           = 6,
    FILL_PATTERN_X_DENSE                = 7,
    FILL_PATTERN_X_MEDIUM               = 8,
    FILL_PATTERN_X_SPARSE               = 9,
    FILL_PATTERN_H_DENSE                = 10,
    FILL_PATTERN_H_MEDIUM               = 11,
    FILL_PATTERN_H_SPARSE               = 12,
    FILL_PATTERN_V_DENSE                = 13,
    FILL_PATTERN_V_MEDIUM               = 14,
    FILL_PATTERN_V_SPARSE               = 15,
    FILL_PATTERN_HV_DENSE               = 16,
    FILL_PATTERN_HV_MEDIUM              = 17,
    FILL_PATTERN_HV_SPARSE              = 18
};

int pattern(string strGraphPage, int nLayer, int nPlot)
{
    GraphPage gp( strGraphPage );
    if( !gp )
        return INVALID_GRAPHPAGE;
    
    GraphLayer gl;
    gl = gp.Layers(nLayer);
    if( !gl )
        return INVALID_GRAPHLAYER;
    
    DataPlot dp;
    dp = gl.DataPlots(nPlot);
    if( !dp )
        return INVALID_DATAPLOT;
    
    Tree trPattern;
    trPattern.Root.Line.LineFillArea.nVal = FILL_AREA_NORMAL;                       // option of "fill area under curve"
    trPattern.Root.Pattern.Fill.FillColor.nVal = 3;                                 // fill->color->blue
    trPattern.Root.Pattern.Fill.Pattern.PatternColor.nVal = 3;                      // fill->pattern color->green
    trPattern.Root.Pattern.Fill.Pattern.Style.nVal = FILL_PATTERN_HV_MEDIUM;        // fill->pattern->hori+vert medium
    trPattern.Root.Pattern.Fill.Pattern.Width.dVal = 1.0;                           // fill->width
    trPattern.Root.Pattern.Transparency.nVal = 50;                                  // transparency
    trPattern.Root.Pattern.FollowLineTransparency.nVal = FALSE;                     // clear "follow line transparency"
    trPattern.Root.Pattern.Fill.ShadingMode.nVal = GRADIENT_MODE_TWO;               // gradient fill->mode->two colors
    trPattern.Root.Pattern.Fill.GradColor.nVal = 17;                                // gradient fill->color->white
    trPattern.Root.Pattern.Fill.GradDirection.nVal = GRADIENT_DIRECTION_BOTTOM_TOP; // gradient fill->direction
    
    if( !dp.UpdateThemeIDs(trPattern.Root) )
    {
        if( !dp.ApplyFormat(trPattern, true, true) )
            return APPLY_FORMAT_FAIL;
    }
    else
        return UPDATE_THEME_ID_FAIL;
    
    return NO_ERROR;
}


©c¡Ï   ¤È¥¹  ©f¨u©c  ©c¥ì    ¥Î¤³  ©c/     ©¦£¯
 ©c¨Ê¥Î ¤´¥¨  ¥ó ¨×   ¥ó¤á' ¥Ì©¦¥­   /¤í  ¥Õ©¦©f
   ¨Ö             ¦á          ©¦£þ  ©` ¥Õ   ©¦
                              ©¦

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000