24小时热门版块排行榜    

查看: 3035  |  回复: 3

sixulianyi

新虫 (初入文坛)

[求助] 利用Ledit的C语言的宏程序画余弦S弯曲线,能和软件连接但是画不出图!!代码已附上 已有1人参与

想在L-edit里面画余弦S弯曲线,故写了一个C语言的宏程序,在Ledit里面运行了,能与软件连接,能显示光标坐标位置以及弹出参数的对话框,但是画不出曲线图。代码如下面所示。语句上按照软件的说明以及自带的例子看了一遍没有错误,实在找不出什么原因。,求问群里的大神哪里出错了!!!
#include <stdlib.h>
#include <math.h>
#include <ldata.h>

void  SMacro ( void )
{
        /********************************************************************/
        /* 余弦S弯 */
        /********************************************************************/
        double       Height, Length,  Width, Deltax;
        long           P, Points_Total;
        double       PI = 3.141592654;
        LPoint        Points [ 1002 ];
        LObject      Polygon;
        LCell        Cell_Draw   = LCell_GetVisible( );
        LFile        File_Draw   = LCell_GetFile ( Cell_Draw );
        LPoint       pt = LCursor_GetPosition ( );
        LDialog_MsgBox( LFormat( "( %lf, %lf )", pt.x, pt.y) );
        LDialogItem  Dialog_Items [ 3 ] = { { "Height ", "50.0" },
        {"Length  ",  "1500"},
        { "Width  ", "5.0" } };
        /********************************************************************/

        if(LLayer_Find (File_Draw, "Poly" == NULL)
        {
                LDialog_AlertBox("There is no Poly layer.\nMake sure Poly is in the layer map!";
                return;
        }

        if( LDialog_MultiLineInputBox ( "S Properties", Dialog_Items, 3 ) )
        {
               Height   = atof ( Dialog_Items [ 0 ].value );
                Length   = atof ( Dialog_Items [ 1 ].value );
                Width    = atof ( Dialog_Items [ 3 ].value );
                return 1;
        }
        else
                return 0;

    Deltax       = 3.0;

        for ( P = 0; P <= Points_Total; P++ )
        {       
            Points [ P ].x = pt.x +Deltax*P;
        Points [ P ].y = pt.y + Height/2*(1-cos(PI*( Deltax*P )/Length));
                Points [ 1002 - P ].x = Points [ P ].x ;
                Points [ 1002 - P ].y = Points [ P ].y +Width ;
        }

        Polygon = LPolygon_New ( Cell_Draw, LLayer_Find ( File_Draw, "Poly" ),
                                                Points, 1002 );

        LCell_SetView ( Cell_Draw, LCell_GetMbb ( Cell_Draw ) );
        LCell_MakeVisible ( Cell_Draw );
        LCell_HomeView ( Cell_Draw );
}

int  UPI_Entry_Point( void )
{
        LMacro_Register("S", "SMacro";
        return 1;
}
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

sixulianyi

新虫 (初入文坛)

程序是复制粘贴上去的,是没有表情的,那几个表情不知道怎么回事,请忽略
2楼2016-06-21 16:06:49
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

yuguofang

新虫 (初入文坛)

【答案】应助回帖

我试了一下,改成这样子就可以了
if( !LDialog_MultiLineInputBox ( "S Properties", Dialog_Items, 2 ) )
                 return ;
        //{
  Height   = atof ( Dialog_Items [ 0 ].value );
  Length   = atof ( Dialog_Items [ 1 ].value );
  Width      = atof ( Dialog_Items [ 2].value );
             //   return;
       // }
       // else
            //    return 0;
3楼2021-05-18 18:12:26
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

梦の国度

捐助贵宾 (文学泰斗)

关注高人
4楼2021-05-21 16:54:08
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 sixulianyi 的主题更新
信息提示
请填处理意见