瀏覽代碼

增加划线和ShapeRange添加物件和建立选择_版本03

蘭雅sRGB 6 月之前
父節點
當前提交
68e3ee318d
共有 3 個文件被更改,包括 48 次插入13 次删除
  1. 2 2
      Makefile
  2. 30 11
      cdrapp.cpp
  3. 16 0
      cdrapp.h

+ 2 - 2
Makefile

@@ -2,8 +2,8 @@ CC = cl.exe
 LINK = link.exe
 
 # 编译和链接选项
-CFLAGS = /nologo /W3 /EHsc /Ox /DNDEBUG /I ..\TypeLibs
-LDFLAGS = /nologo Gdi32.lib user32.lib Kernel32.lib
+CFLAGS = /nologo /W3 /EHsc /Ox /DNDEBUG /MT /I ..\TypeLibs
+LDFLAGS = /nologo libcmt.lib libcpmt.lib Gdi32.lib user32.lib Kernel32.lib
 
 # 源文件和最终输出
 SOURCE = main.cpp cdrapp.cpp

+ 30 - 11
cdrapp.cpp

@@ -1,13 +1,7 @@
 #include "cdrapp.h"
 #include <stdio.h>
 
-#define ZERO_4PC 0, 0, 0, 0
 
-IVGShapePtr MakeEllipse(corel* cdr, double x, double y, double r);
-IVGShapePtr MakeEllipse(corel* cdr, IVGShapePtr s, double r);
-
-IVGShapePtr MakeRectangle(corel* cdr, double x, double y, double w, double h);
-IVGShapePtr MakeRectangle(corel* cdr, IVGShapePtr s, double w, double h);
 bool polygon_gravity_dot(corel* cdr){
     cdr->ActiveDocument->Unit = cdrMillimeter;
     double x, y;
@@ -15,6 +9,9 @@ bool polygon_gravity_dot(corel* cdr){
 //  IVGShapePtr ActiveShape;    // 获取当前选中的图形 函数原型
     auto s = cdr->ActiveShape;
 
+//  IVGShapeRangePtr IVGApplication::CreateShapeRange ( );
+    auto srs = cdr->CreateShapeRange();
+
 //  获取节点函数原型
 //  IVGNodePtr IVGNodes::GetItem ( long Index );
 //  IVGNodePtr IVGNodeRange::GetItem ( long Index );
@@ -26,14 +23,19 @@ bool polygon_gravity_dot(corel* cdr){
         y = n->PositionY;
         printf("%f, %f\n", x, y);
 
-        auto sy = MakeEllipse(cdr, x, y, 5); 
-        sy->Outline->Color->RGBAssign(255, 0, 0);
+        // auto sy = MakeEllipse(cdr, x, y, 5); 
+        // sy->Outline->Color->RGBAssign(255, 0, 0);
 
-        auto sj = MakeRectangle(cdr, x, y, 10, 10); 
-        sj->Outline->Color->RGBAssign(0, 255, 0);
+        // auto sj = MakeRectangle(cdr, x, y, 10, 10); 
+        // sj->Outline->Color->RGBAssign(0, 255, 0);
 
+        auto l = DrawLine(cdr, x, y, s->CenterX, s->CenterY);
+        srs->Add(l);
     }
 
+// HRESULT IVGShapeRange::CreateSelection ( );
+    srs->CreateSelection();
+
     return true;
 }
 
@@ -69,4 +71,21 @@ IVGShapePtr MakeRectangle(corel* cdr, IVGShapePtr s, double w, double h){
     sj->PutCenterX(x);
     sj->PutCenterY(y);
     return  sj;
-}
+}
+
+
+// IVGShapePtr IVGLayer::CreateLineSegment ( double StartX, double StartY, double EndX, double EndY );
+// 画一条线,设置轮廓色 M100
+IVGShapePtr DrawLine(corel* cdr, double x1, double y1, double x2, double y2){
+    auto line = cdr->ActiveLayer->CreateLineSegment(x1, y1, x2, y2);
+    line->Outline->Color->CMYKAssign(0, 100, 0, 0);
+    return line;
+}
+
+// IVGShapePtr IVGLayer::FindShape ( _bstr_t Name, enum cdrShapeType Type, long StaticID, VARIANT_BOOL Recursive );
+
+// IVGShapePtr IVGLayer::CreateCurveSegment ( double StartX, double StartY, double EndX, double EndY, double StartingControlPointLength, 
+//                                     double StartingControlPointAngle, double EndingControlPointLength, double EndingControlPointAngle );
+
+// IVGShapePtr IVGLayer::CreateCurveSegment2 ( double x1, double y1, double StartingControlPointX, double StartingControlPointY, 
+//                                         double EndingControlPointX, double EndingControlPointY, double x2, double y2 );

+ 16 - 0
cdrapp.h

@@ -3,6 +3,8 @@
 
 #import "VGCoreAuto.tlb"
 
+#include "VGCoreAuto.tlh"
+
 
 #define corel VGCore::IVGApplication
 using namespace VGCore;
@@ -12,4 +14,18 @@ void Call_CorelDRAW();
 
 bool polygon_gravity_dot(corel* cdr);
 
+
+
+
+// 重新包装 创建物件函数
+#define ZERO_4PC 0, 0, 0, 0
+
+IVGShapePtr MakeEllipse(corel* cdr, double x, double y, double r);
+IVGShapePtr MakeEllipse(corel* cdr, IVGShapePtr s, double r);
+
+IVGShapePtr MakeRectangle(corel* cdr, double x, double y, double w, double h);
+IVGShapePtr MakeRectangle(corel* cdr, IVGShapePtr s, double w, double h);
+
+IVGShapePtr DrawLine(corel* cdr, double x1, double y1, double x2, double y2);
+
 #endif // CDRAPP_H_INCLUDED