C:\home\SVGCats_src\src\Line_cpp.cpp
1|/*********************************************************************** 2| 1. <<< ライン (Line) >>> 3|************************************************************************/ 4| 5|#include "mixer_precomp.h" /* Auto precompiled header, Look at mixer-... folder */ 6|// #pragma hdrstop 7| 8|#if defined(USES_MXP_AUTOINC) 9| #include "line.ah" /* Auto include header, Look at mixer-... folder */ 10|#endif 11| 12| 13|#define Line_isColorBright( c ) \ 14| ( Color_WinRGB_getR(c) > 0xD0 && Color_WinRGB_getG(c) > 0xD0 ) 15| 16|/*-------------------------------------------------------------------------*/ 17|/* 2. <<<< ◆ (Line_Ex) ライン・詳細(ディスプレイ表示用) >>>> */ 18|/*-------------------------------------------------------------------------*/ 19| 20| 21|#ifdef LINE_USES_WINDOWS_DC 22| 23| 24|Line_Ex::Line_Ex() 25|{ 26| m_bInUndoBuf = false; 27| m_bHold = false; 28| m_bSelected = false; 29| 30| m_Line.x1 = 0; 31| m_Line.y1 = 0; 32| m_Line.x2 = 10; 33| m_Line.y2 = 10; 34| m_Width = 1; 35| m_Color = 0x000000; 36| m_bDash = false; 37| 38| m_Arrow1 = 0; 39| m_Arrow2 = 0; 40| m_ArrowsInReading = NULL; 41| 42| m_Controler[0] = NULL; 43| m_Controler[1] = NULL; 44| m_Link[0].prim = NULL; 45| m_Link[1].prim = NULL; 46| 47| m_Controler_id[0] = 0; 48| m_Controler_id[1] = 0; 49| m_Link[0].prim_id = 0; 50| m_Link[1].prim_id = 0; 51| 52| StdPlus_onMalloc( this ); 53|} 54| 55| 56|Line_Ex::~Line_Ex() 57|{ 58| StdPlus_onFree( this ); 59| if ( ! m_bInUndoBuf ) UnlinkAll(); 60| if ( (int)m_ArrowsInReading != 1 && 61| m_ArrowsInReading != NULL ) free( m_ArrowsInReading ); 62|} 63| 64| 65|/*********************************************************************** 66| 2-1. <<< [Line_Ex::print] CadPrim::print の実装部 >>> 67|************************************************************************/ 68|void Line_Ex::print( const char* title ) 69|{ 70| #ifndef NDEBUG 71| Errors_printf( "%sLine_Ex[%d:%p]: (%d,%d)-(%d,%d), hold=%d, sel=%d, undo=%d, m_ArrowsInReading=%p", 72| title, 73| m_id, this, m_Line.x1, m_Line.y1, m_Line.x2, m_Line.y2, m_bHold, 74| m_bSelected, m_bInUndoBuf, m_ArrowsInReading ); 75| Errors_printf( "%s m_Controler[0] = %p, id=%d, arrow = %d", title, 76| m_Controler[0], m_Controler_id[0], m_Arrow1 ); 77| Errors_printf( "%s m_Controler[1] = %p, id=%d, arrow = %d", title, 78| m_Controler[1], m_Controler_id[1], m_Arrow2 ); 79| m_Link[0].print( title ); 80| m_Link[1].print( title ); 81| #endif 82|} 83| 84| 85|/*********************************************************************** 86| 2-2. <<< [Line_Ex::GetID] CadPrim::GetID の実装部 >>> 87|************************************************************************/ 88|int Line_Ex::GetID() 89|{ 90| return m_id; 91|} 92| 93| 94|/*********************************************************************** 95| 2-3. <<< [Line_Ex::SetID] CadPrim::SetID の実装部 >>> 96|************************************************************************/ 97|void Line_Ex::SetID( int id ) 98|{ 99| m_id = id; 100|} 101| 102| 103|/*********************************************************************** 104| 2-4. <<< [Line_Ex::OnChgedLinkID] CadPrim::OnChgedLinkID の実装部 >>> 105|************************************************************************/ 106|void Line_Ex::OnChgedLinkID( int oldID, int newID ) 107|{ 108| if ( m_Link[0].prim_id == oldID ) m_Link[0].prim_id = newID; 109| if ( m_Link[1].prim_id == oldID ) m_Link[1].prim_id = newID; 110| if ( m_Controler_id[0] == oldID ) m_Controler_id[0] = newID; 111| if ( m_Controler_id[1] == oldID ) m_Controler_id[1] = newID; 112|} 113| 114| 115|/*********************************************************************** 116| 2-5. <<< [Line_Ex::GetTypeID] CadPrim::GetTypeID の実装部 >>> 117|************************************************************************/ 118|int Line_Ex::GetTypeID() 119|{ 120| return Line_Ex_TypeID; 121|} 122| 123| 124|/*********************************************************************** 125| 2-6. <<< [Line_Ex::GetTypeNameJp] CadPrim::GetTypeNameJp の実装部 >>> 126|************************************************************************/ 127|char* Line_Ex::GetTypeNameJp() 128|{ 129| return "直線"; 130|} 131| 132| 133|/*********************************************************************** 134| 2-7. <<< [Line_Ex::GetTypeNameEn] CadPrim::GetTypeNameEn の実装部 >>> 135|************************************************************************/ 136|char* Line_Ex::GetTypeNameEn() 137|{ 138| return "Line"; 139|} 140| 141| 142|/*********************************************************************** 143| 2-8. <<< [Line_Ex::SetBInUndoBuf] CadPrim::SetBInUndoBuf の実装部 >>> 144|************************************************************************/ 145|void Line_Ex::SetBInUndoBuf( bool b ) 146|{ 147| m_bInUndoBuf = b; 148|} 149| 150| 151|/*********************************************************************** 152| 2-9. <<< [Line_Ex::GetLinkURL] CadPrim::GetLinkURL の実装部 >>> 153|************************************************************************/ 154|char* Line_Ex::GetLinkURL() 155|{ 156| return ""; 157|} 158| 159| 160|/*********************************************************************** 161| 2-10. <<< [Line_Ex::GetIdLabel] CadPrim::GetIdLabel の実装部 >>> 162|************************************************************************/ 163|char* Line_Ex::GetIdLabel() 164|{ 165| return ""; 166|} 167| 168| 169| 170|/*********************************************************************** 171| 2-11. <<< [Line_Ex::OutSVG] SVGファイルに属性値を出力する >>> 172|************************************************************************/ 173|void Line_Ex::OutSVG( CadPrim_SaveParam* p ) 174|{ 175| if ( m_Arrow1 != 0 || m_Arrow2 != 0 ) 176| fprintf( p->f, "\t<g>\n" ); 177| 178| fprintf( p->f, "\t<line x1=\"%d.5\" y1=\"%d.5\" x2=\"%d.5\" y2=\"%d.5\"\n", 179| m_Line.x1, m_Line.y1, m_Line.x2, m_Line.y2 ); 180| 181| fprintf( p->f, "\t\tstyle=\"fill:none;stroke:rgb(%d,%d,%d);" 182| "stroke-width:%d%s;stroke-linecap:round\"", 183| Color_WinRGB_getR( m_Color ), Color_WinRGB_getG( m_Color ), 184| Color_WinRGB_getB( m_Color ), 185| m_Width, 186| m_bDash ? ";stroke-dasharray:4,4" : "" ); 187| 188| if ( m_Arrow1 != 0 || m_Arrow2 != 0 || 189| m_Controler[0] != NULL || m_Controler[1] != NULL ) { 190| fprintf( p->f, "\n\t\tp1=\"%d,%d,%d,%d\" p2=\"%d,%d,%d,%d\"", /* x,y,arrow,link */ 191| m_Line.x1, m_Line.y1, m_Arrow1, m_Controler[0] != NULL ? 1 : 0, 192| m_Line.x2, m_Line.y2, m_Arrow2, m_Controler[1] != NULL ? 1 : 0 ); 193| } 194| 195| fputs( "/>\n", p->f ); 196| 197| 198| /* 矢印を描画する */ 199| if ( m_Arrow1 == 1 || m_Arrow2 == 1 ) { 200| Line leftWing, rightWing; 201| 202| if ( m_Arrow1 == 1 ) { 203| GetArrowParamType1( 1, &leftWing, &rightWing ); 204| 205| fprintf( p->f, "\t<line x1=\"%d.5\" y1=\"%d.5\" x2=\"%d.5\" y2=\"%d.5\"\n", 206| leftWing.x1, leftWing.y1, leftWing.x2, leftWing.y2 ); 207| 208| fprintf( p->f, "\t\tstyle=\"fill:none;stroke:rgb(%d,%d,%d);" 209| "stroke-width:%d;stroke-linecap:round\"/>\n", 210| Color_WinRGB_getR( m_Color ), Color_WinRGB_getG( m_Color ), 211| Color_WinRGB_getB( m_Color ), 212| m_Width ); 213| 214| fprintf( p->f, "\t<line x1=\"%d.5\" y1=\"%d.5\" x2=\"%d.5\" y2=\"%d.5\"\n", 215| rightWing.x1, rightWing.y1, rightWing.x2, rightWing.y2 ); 216| 217| fprintf( p->f, "\t\tstyle=\"fill:none;stroke:rgb(%d,%d,%d);" 218| "stroke-width:%d;stroke-linecap:round\"/>\n", 219| Color_WinRGB_getR( m_Color ), Color_WinRGB_getG( m_Color ), 220| Color_WinRGB_getB( m_Color ), 221| m_Width ); 222| } 223| if ( m_Arrow2 == 1 ) { 224| GetArrowParamType1( 2, &leftWing, &rightWing ); 225| 226| fprintf( p->f, "\t<line x1=\"%d.5\" y1=\"%d.5\" x2=\"%d.5\" y2=\"%d.5\"\n", 227| leftWing.x1, leftWing.y1, leftWing.x2, leftWing.y2 ); 228| 229| fprintf( p->f, "\t\tstyle=\"fill:none;stroke:rgb(%d,%d,%d);" 230| "stroke-width:%d;stroke-linecap:round\"/>\n", 231| Color_WinRGB_getR( m_Color ), Color_WinRGB_getG( m_Color ), 232| Color_WinRGB_getB( m_Color ), 233| m_Width ); 234| 235| fprintf( p->f, "\t<line x1=\"%d.5\" y1=\"%d.5\" x2=\"%d.5\" y2=\"%d.5\"\n", 236| rightWing.x1, rightWing.y1, rightWing.x2, rightWing.y2 ); 237| 238| fprintf( p->f, "\t\tstyle=\"fill:none;stroke:rgb(%d,%d,%d);" 239| "stroke-width:%d;stroke-linecap:round\"/>\n", 240| Color_WinRGB_getR( m_Color ), Color_WinRGB_getG( m_Color ), 241| Color_WinRGB_getB( m_Color ), 242| m_Width ); 243| } 244| } 245| 246| 247| if ( (m_Arrow1 >= 2 && m_Arrow1 <= 7) || (m_Arrow2 >= 2 && m_Arrow2 <= 7) ) { 248| POINT xy[4]; 249| int x, y, r; 250| 251| if ( m_Arrow1 == 2 ) { /* 丸矢印 */ 252| GetArrowParamType2( 1, &x, &y, &r ); 253| fprintf( p->f, "\t<circle cx=\"%d.5\" cy=\"%d.5\" r=\"%d\"\n", x, y, r ); 254| } 255| if ( m_Arrow1 == 3 ) { /* 三角矢印 */ 256| GetArrowParamType3( 1, xy ); 257| fprintf( p->f, "\t<polygon points=\"%d.5,%d.5 %d.5,%d.5 %d.5,%d.5\"\n", 258| xy[0].x, xy[0].y, xy[1].x, xy[1].y, xy[2].x, xy[2].y ); 259| } 260| if ( m_Arrow1 == 4 ) { /* ひし形矢印 */ 261| GetArrowParamType4( 1, xy ); 262| fprintf( p->f, "\t<polygon points=\"%d.5,%d.5 %d.5,%d.5 %d.5,%d.5 %d.5,%d.5\"\n", 263| xy[0].x, xy[0].y, xy[1].x, xy[1].y, xy[2].x, xy[2].y, xy[3].x, xy[3].y ); 264| } 265| if ( m_Arrow1 >= 2 && m_Arrow1 <= 4 ) { 266| fprintf( p->f, "\t\tstyle=\"fill:rgb(%d,%d,%d);stroke:rgb(%d,%d,%d);" 267| "stroke-width:%d\"/>\n", 268| Color_WinRGB_getR( m_Color ), Color_WinRGB_getG( m_Color ), 269| Color_WinRGB_getB( m_Color ), 270| Color_WinRGB_getR( m_Color ), Color_WinRGB_getG( m_Color ), 271| Color_WinRGB_getB( m_Color ), 272| m_Width ); 273| } 274| 275| if ( m_Arrow2 == 2 ) { 276| GetArrowParamType2( 2, &x, &y, &r ); 277| fprintf( p->f, "\t<circle cx=\"%d.5\" cy=\"%d.5\" r=\"%d\"\n", x, y, r ); 278| } 279| if ( m_Arrow2 == 3 ) { /* 三角矢印 */ 280| GetArrowParamType3( 2, xy ); 281| fprintf( p->f, "\t<polygon points=\"%d.5,%d.5 %d.5,%d.5 %d.5,%d.5\"\n", 282| xy[0].x, xy[0].y, xy[1].x, xy[1].y, xy[2].x, xy[2].y ); 283| } 284| if ( m_Arrow2 == 4 ) { /* ひし形矢印 */ 285| GetArrowParamType4( 2, xy ); 286| fprintf( p->f, "\t<polygon points=\"%d.5,%d.5 %d.5,%d.5 %d.5,%d.5 %d.5,%d.5\"\n", 287| xy[0].x, xy[0].y, xy[1].x, xy[1].y, xy[2].x, xy[2].y, xy[3].x, xy[3].y ); 288| } 289| if ( m_Arrow2 >= 2 && m_Arrow2 <= 4 ) { 290| fprintf( p->f, "\t\tstyle=\"fill:rgb(%d,%d,%d);stroke:rgb(%d,%d,%d);" 291| "stroke-width:%d\"/>\n", 292| Color_WinRGB_getR( m_Color ), Color_WinRGB_getG( m_Color ), 293| Color_WinRGB_getB( m_Color ), 294| Color_WinRGB_getR( m_Color ), Color_WinRGB_getG( m_Color ), 295| Color_WinRGB_getB( m_Color ), 296| m_Width ); 297| } 298| 299| 300| /* 白抜き */ 301| 302| if ( m_Arrow1 == 5 ) { /* 丸矢印 */ 303| GetArrowParamType2( 1, &x, &y, &r ); 304| fprintf( p->f, "\t<circle cx=\"%d.5\" cy=\"%d.5\" r=\"%d\"\n", x, y, r ); 305| } 306| if ( m_Arrow1 == 6 ) { /* 三角矢印 */ 307| GetArrowParamType3( 1, xy ); 308| fprintf( p->f, "\t<polygon points=\"%d.5,%d.5 %d.5,%d.5 %d.5,%d.5\"\n", 309| xy[0].x, xy[0].y, xy[1].x, xy[1].y, xy[2].x, xy[2].y ); 310| } 311| if ( m_Arrow1 == 7 ) { /* ひし形矢印 */ 312| GetArrowParamType4( 1, xy ); 313| fprintf( p->f, "\t<polygon points=\"%d.5,%d.5 %d.5,%d.5 %d.5,%d.5 %d.5,%d.5\"\n", 314| xy[0].x, xy[0].y, xy[1].x, xy[1].y, xy[2].x, xy[2].y, xy[3].x, xy[3].y ); 315| } 316| if ( m_Arrow1 >= 5 && m_Arrow1 <= 7 ) { 317| int c = ( Line_isColorBright(m_Color) ) ? 0 : 255; 318| 319| fprintf( p->f, "\t\tstyle=\"fill:rgb(%d,%d,%d);stroke:rgb(%d,%d,%d);" 320| "stroke-width:%d\"/>\n", 321| c, c, c, 322| Color_WinRGB_getR( m_Color ), Color_WinRGB_getG( m_Color ), 323| Color_WinRGB_getB( m_Color ), 324| m_Width ); 325| } 326| 327| if ( m_Arrow2 == 5 ) { 328| GetArrowParamType2( 2, &x, &y, &r ); 329| fprintf( p->f, "\t<circle cx=\"%d.5\" cy=\"%d.5\" r=\"%d\"\n", x, y, r ); 330| } 331| if ( m_Arrow2 == 6 ) { /* 三角矢印 */ 332| GetArrowParamType3( 2, xy ); 333| fprintf( p->f, "\t<polygon points=\"%d.5,%d.5 %d.5,%d.5 %d.5,%d.5\"\n", 334| xy[0].x, xy[0].y, xy[1].x, xy[1].y, xy[2].x, xy[2].y ); 335| } 336| if ( m_Arrow2 == 7 ) { /* ひし形矢印 */ 337| GetArrowParamType4( 2, xy ); 338| fprintf( p->f, "\t<polygon points=\"%d.5,%d.5 %d.5,%d.5 %d.5,%d.5 %d.5,%d.5\"\n", 339| xy[0].x, xy[0].y, xy[1].x, xy[1].y, xy[2].x, xy[2].y, xy[3].x, xy[3].y ); 340| } 341| if ( m_Arrow2 >= 5 && m_Arrow2 <= 7 ) { 342| int c = ( Line_isColorBright(m_Color) ) ? 0 : 255; 343| 344| fprintf( p->f, "\t\tstyle=\"fill:rgb(%d,%d,%d);stroke:rgb(%d,%d,%d);" 345| "stroke-width:%d\"/>\n", 346| c, c, c, 347| Color_WinRGB_getR( m_Color ), Color_WinRGB_getG( m_Color ), 348| Color_WinRGB_getB( m_Color ), 349| m_Width ); 350| } 351| } 352| 353| if ( m_Arrow1 != 0 || m_Arrow2 != 0 ) 354| fprintf( p->f, "\t</g>\n" ); 355|} 356| 357| 358|/*********************************************************************** 359| 2-12. <<< [Line_Ex::Draw] CadPrim::Draw の実装部 >>> 360|************************************************************************/ 361|void Line_Ex::Draw( CDC* dc, CadPrim_DrawParam* p ) 362|{ 363| int zoom = p->zoom; 364| int x1 = m_Line.x1 * zoom / 100 - p->x0; 365| int y1 = m_Line.y1 * zoom / 100 - p->y0; 366| int x2 = m_Line.x2 * zoom / 100 - p->x0; 367| int y2 = m_Line.y2 * zoom / 100 - p->y0; 368| 369| CPen pen( PS_SOLID, m_Width * zoom / 100, 370| p->bWhiteToBGColor && m_Color == 0x000000 ? 371| GetSysColor( COLOR_WINDOWTEXT ) : m_Color ); 372| CPen dashPen( PS_DOT, 1, 373| p->bWhiteToBGColor && m_Color == 0x000000 ? 374| GetSysColor( COLOR_WINDOWTEXT ) : m_Color ); 375| CPen* oldPen; 376| 377| 378| /* ラインを破線で描画する(太字の破線は CPen のみで対応できない) */ 379| if ( m_bDash ) { 380| int dx = x2 - x1; 381| int dy = y2 - y1; 382| int i; 383| 384| oldPen = dc->SelectObject( &dashPen ); 385| 386| dc->SetBkMode( TRANSPARENT ); 387| if ( abs(dx) > abs(dy) ) { 388| for ( i = - (m_Width - 1) * zoom / 200; i <= m_Width * zoom / 200; i++ ) { 389| dc->MoveTo( x1, y1 + i ); 390| dc->LineTo( x2, y2 + i ); 391| if ( ! p->bPrint ) { 392| dc->SetPixel( x2, y2 + i, m_Color == 0x000000 ? 393| GetSysColor( COLOR_WINDOWTEXT ) : m_Color ); 394| } 395| } 396| } 397| else { 398| for ( i = - (m_Width - 1) * zoom / 200; i <= m_Width * zoom / 200; i++ ) { 399| dc->MoveTo( x1 + i, y1 ); 400| dc->LineTo( x2 + i, y2 ); 401| if ( ! p->bPrint ) { 402| dc->SetPixel( x2 + i, y2, m_Color == 0x000000 ? 403| GetSysColor( COLOR_WINDOWTEXT ) : m_Color ); 404| } 405| } 406| } 407| 408| dc->SelectObject( oldPen ); 409| } 410| 411| /* ラインを実線で描画する */ 412| else { 413| oldPen = dc->SelectObject( &pen ); 414| 415| dc->MoveTo( x1, y1 ); 416| dc->LineTo( x2, y2 ); 417| if ( ! p->bPrint ) { 418| dc->SetPixel( x2, y2, 419| m_Color == 0x000000 ? GetSysColor( COLOR_WINDOWTEXT ) : m_Color ); 420| } 421| dc->SelectObject( oldPen ); 422| } 423| 424| 425| /* リンクテキストの Draw 後に決定する属性を設定する */ 426| if ( m_Controler[0] != NULL && ((Text_Box*)m_Controler[0])->IsNotSetDrawParam() ) 427| ((Text_Box*)m_Controler[0])->Draw( dc, p ); 428| 429| if ( m_Controler[1] != NULL && ((Text_Box*)m_Controler[1])->IsNotSetDrawParam() ) 430| ((Text_Box*)m_Controler[1])->Draw( dc, p ); 431| 432| 433| /* 矢印を描画する */ 434| if ( m_Arrow1 == 1 || m_Arrow2 == 1 ) { /* 羽矢印 */ 435| Line leftWing, rightWing; 436| 437| oldPen = dc->SelectObject( &pen ); 438| 439| if ( m_Arrow1 == 1 ) { 440| GetArrowParamType1( 1, &leftWing, &rightWing ); 441| dc->MoveTo( leftWing.x1 * zoom / 100 - p->x0, leftWing.y1 * zoom / 100 - p->y0 ); 442| dc->LineTo( leftWing.x2 * zoom / 100 - p->x0, leftWing.y2 * zoom / 100 - p->y0 ); 443| dc->MoveTo( rightWing.x1 * zoom / 100 - p->x0, rightWing.y1 * zoom / 100 - p->y0 ); 444| dc->LineTo( rightWing.x2 * zoom / 100 - p->x0, rightWing.y2 * zoom / 100 - p->y0 ); 445| } 446| if ( m_Arrow2 == 1 ) { 447| GetArrowParamType1( 2, &leftWing, &rightWing ); 448| dc->MoveTo( leftWing.x1 * zoom / 100 - p->x0, leftWing.y1 * zoom / 100 - p->y0 ); 449| dc->LineTo( leftWing.x2 * zoom / 100 - p->x0, leftWing.y2 * zoom / 100 - p->y0 ); 450| dc->MoveTo( rightWing.x1 * zoom / 100 - p->x0, rightWing.y1 * zoom / 100 - p->y0 ); 451| dc->LineTo( rightWing.x2 * zoom / 100 - p->x0, rightWing.y2 * zoom / 100 - p->y0 ); 452| } 453| 454| dc->SelectObject( oldPen ); 455| } 456| 457| if ( (m_Arrow1 >= 2 && m_Arrow1 <= 7) || (m_Arrow2 >= 2 && m_Arrow2 <= 7) ) { 458| POINT xy[4]; 459| int x, y, r; 460| 461| CBrush brush( m_Color ); 462| CBrush brushR( Line_isColorBright(m_Color) ? RGB(0,0,0) : RGB(0xFF,0xFF,0xFF) ); 463| CBrush* oldBrush; 464| 465| oldPen = dc->SelectObject( &pen ); 466| oldBrush = dc->SelectObject( &brush ); 467| 468| if ( m_Arrow1 == 2 ) { /* 丸矢印 */ 469| GetArrowParamType2( 1, &x, &y, &r ); 470| dc->Ellipse( (x - r) * zoom / 100 - p->x0, (y - r) * zoom / 100 - p->y0, 471| (x + r) * zoom / 100 - p->x0, (y + r) * zoom / 100 - p->y0 ); 472| } 473| if ( m_Arrow2 == 2 ) { 474| GetArrowParamType2( 2, &x, &y, &r ); 475| dc->Ellipse( (x - r) * zoom / 100 - p->x0, (y - r) * zoom / 100 - p->y0, 476| (x + r) * zoom / 100 - p->x0, (y + r) * zoom / 100 - p->y0 ); 477| } 478| if ( m_Arrow1 == 3 ) /* 三角矢印 */ 479| { GetArrowParamType3( 1, xy ); ConvertByZoom( p, xy, 3 ); dc->Polygon( xy, 3 ); } 480| if ( m_Arrow2 == 3 ) 481| { GetArrowParamType3( 2, xy ); ConvertByZoom( p, xy, 3 ); dc->Polygon( xy, 3 ); } 482| if ( m_Arrow1 == 4 ) /* ひし形矢印 */ 483| { GetArrowParamType4( 1, xy ); ConvertByZoom( p, xy, 4 ); dc->Polygon( xy, 4 ); } 484| if ( m_Arrow2 == 4 ) 485| { GetArrowParamType4( 2, xy ); ConvertByZoom( p, xy, 4 ); dc->Polygon( xy, 4 ); } 486| 487| 488| dc->SelectObject( &brushR ); /* 白抜き */ 489| 490| if ( m_Arrow1 == 5 ) { 491| GetArrowParamType2( 1, &x, &y, &r ); 492| dc->Ellipse( (x - r) * zoom / 100 - p->x0, (y - r) * zoom / 100 - p->y0, 493| (x + r) * zoom / 100 - p->x0, (y + r) * zoom / 100 - p->y0 ); 494| } 495| if ( m_Arrow2 == 5 ) { 496| GetArrowParamType2( 2, &x, &y, &r ); 497| dc->Ellipse( (x - r) * zoom / 100 - p->x0, (y - r) * zoom / 100 - p->y0, 498| (x + r) * zoom / 100 - p->x0, (y + r) * zoom / 100 - p->y0 ); 499| } 500| if ( m_Arrow1 == 6 ) 501| { GetArrowParamType3( 1, xy ); ConvertByZoom( p, xy, 3 ); dc->Polygon( xy, 3 ); } 502| if ( m_Arrow2 == 6 ) 503| { GetArrowParamType3( 2, xy ); ConvertByZoom( p, xy, 3 ); dc->Polygon( xy, 3 ); } 504| if ( m_Arrow1 == 7 ) 505| { GetArrowParamType4( 1, xy ); ConvertByZoom( p, xy, 4 ); dc->Polygon( xy, 4 ); } 506| if ( m_Arrow2 == 7 ) 507| { GetArrowParamType4( 2, xy ); ConvertByZoom( p, xy, 4 ); dc->Polygon( xy, 4 ); } 508| 509| dc->SelectObject( oldBrush ); 510| dc->SelectObject( oldPen ); 511| } 512| 513| 514| 515| /* ハンドルを描画する */ 516| if ( m_bHold && p->bDrawHandle ) 517| DrawHandles( dc, p, ~GetSysColor( COLOR_HIGHLIGHT ) & 0xFFFFFF, false ); 518|} 519| 520| 521| 522|/*********************************************************************** 523| 2-13. <<< [Line_Ex::DrawHandles] CadPrim::DrawJamdles の実装部 >>> 524|************************************************************************/ 525|void Line_Ex::DrawHandles( CDC* dc, CadPrim_DrawParam* p, COLORREF color, 526| bool bDrawFrame ) 527|{ 528| CPen pen( PS_SOLID, 1, color ^ 0xFFFFFF ); 529| CBrush brush( color ); 530| CPen* oldPen; 531| CBrush* oldBrush; 532| int i, x, y; 533| 534| oldPen = dc->SelectObject( &pen ); 535| oldBrush = dc->SelectObject( &brush ); 536| 537| for ( i = 1; i <= Line_nHandle; i++ ) { 538| Line_getCenterOfHandle( &m_Line, i, &x, &y ); 539| x = x * p->zoom / 100 - p->x0; 540| y = y * p->zoom / 100 - p->y0; 541| dc->Rectangle( x - 3, y - 3, x + 3, y + 3 ); 542| } 543| 544| dc->SelectObject( oldBrush ); 545| dc->SelectObject( oldPen ); 546|} 547| 548| 549|/*********************************************************************** 550| 2-14. <<< [Line_Ex::GetArrowParamType1] Type1 の矢印(羽)の描画に必要なパラメータを得る >>> 551|【引数】 552| ・int i; 頂点番号(1 or 2) 553|************************************************************************/ 554|void Line_Ex::GetArrowParamType1( int i, Line* leftWing, Line* rightWing ) 555|{ 556| int x, y; 557| 558| ASSERT( i == 1 || i == 2 ); 559| 560| if ( i == 1 ) { 561| if ( m_Controler[0] != NULL ) { 562| ((Text_Box*)m_Controler[0])->GetArrowPoint( 563| i, m_Line.x1, m_Line.y1, m_Line.x2, m_Line.y2, &x, &y ); 564| } 565| else 566| { x = m_Line.x1; y = m_Line.y1; } 567| 568| Line_Plus_getArrowParamType1( x, y, m_Line.x2, m_Line.y2, 569| 8 + m_Width*4, leftWing, rightWing ); 570| } 571| 572| else { 573| if ( m_Controler[1] != NULL ) { 574| ((Text_Box*)m_Controler[1])->GetArrowPoint( 575| i, m_Line.x2, m_Line.y2, m_Line.x1, m_Line.y1, &x, &y ); 576| } 577| else 578| { x = m_Line.x2; y = m_Line.y2; } 579| 580| Line_Plus_getArrowParamType1( x, y, m_Line.x1, m_Line.y1, 581| 8 + m_Width*4, leftWing, rightWing ); 582| } 583|} 584| 585| 586|/*********************************************************************** 587| 2-15. <<< [Line_Ex::GetArrowParamType2] Type2 の矢印(丸)の描画に必要なパラメータを得る >>> 588|【引数】 589| ・int i; 頂点番号(1 or 2) 590| ・int* x, y, r; (出力)丸のパラメータ 591|************************************************************************/ 592|void Line_Ex::GetArrowParamType2( int i, int* x, int* y, int* r ) 593|{ 594| ASSERT( i == 1 || i == 2 ); 595| 596| if ( i == 1 ) { 597| if ( m_Controler[0] != NULL ) { 598| ((Text_Box*)m_Controler[0])->GetArrowPoint( 599| i, m_Line.x1, m_Line.y1, m_Line.x2, m_Line.y2, x, y ); 600| } 601| else 602| { *x = m_Line.x1; *y = m_Line.y1; } 603| } 604| 605| else { 606| if ( m_Controler[1] != NULL ) { 607| ((Text_Box*)m_Controler[1])->GetArrowPoint( 608| i, m_Line.x2, m_Line.y2, m_Line.x1, m_Line.y1, x, y ); 609| } 610| else 611| { *x = m_Line.x2; *y = m_Line.y2; } 612| } 613| 614| *r = m_Width + 2; 615|} 616| 617| 618|/*********************************************************************** 619| 2-16. <<< [Line_Ex::GetArrowParamType3] Type3 の矢印(三角)の描画に必要なパラメータを得る >>> 620|【引数】 621| ・int i; 頂点番号(1 or 2) 622|************************************************************************/ 623|void Line_Ex::GetArrowParamType3( int i, POINT* xy ) 624|{ 625| int x, y; 626| 627| ASSERT( i == 1 || i == 2 ); 628| 629| if ( i == 1 ) { 630| if ( m_Controler[0] != NULL ) { 631| ((Text_Box*)m_Controler[0])->GetArrowPoint( 632| i, m_Line.x1, m_Line.y1, m_Line.x2, m_Line.y2, &x, &y ); 633| } 634| else 635| { x = m_Line.x1; y = m_Line.y1; } 636| 637| Line_Plus_getArrowParamType3( x, y, m_Line.x2, m_Line.y2, 638| 8 + m_Width*4, xy ); 639| } 640| else { 641| if ( m_Controler[1] != NULL ) { 642| ((Text_Box*)m_Controler[1])->GetArrowPoint( 643| i, m_Line.x2, m_Line.y2, m_Line.x1, m_Line.y1, &x, &y ); 644| } 645| else 646| { x = m_Line.x2; y = m_Line.y2; } 647| 648| Line_Plus_getArrowParamType3( x, y, m_Line.x1, m_Line.y1, 649| 8 + m_Width*4, xy ); 650| } 651|} 652| 653| 654|/*********************************************************************** 655| 2-17. <<< [Line_Ex::GetArrowParamType4] Type4 の矢印(ひし形)の描画に必要なパラメータを得る >>> 656|【引数】 657| ・int i; 頂点番号(1 or 2) 658|************************************************************************/ 659|void Line_Ex::GetArrowParamType4( int i, POINT* xy ) 660|{ 661| int x, y; 662| 663| ASSERT( i == 1 || i == 2 ); 664| 665| if ( i == 1 ) { 666| if ( m_Controler[0] != NULL ) { 667| ((Text_Box*)m_Controler[0])->GetArrowPoint( 668| i, m_Line.x1, m_Line.y1, m_Line.x2, m_Line.y2, &x, &y ); 669| } 670| else 671| { x = m_Line.x1; y = m_Line.y1; } 672| 673| Line_Plus_getArrowParamType4( x, y, m_Line.x2, m_Line.y2, 674| 8 + m_Width*4, xy ); 675| } 676| else { 677| if ( m_Controler[1] != NULL ) { 678| ((Text_Box*)m_Controler[1])->GetArrowPoint( 679| i, m_Line.x2, m_Line.y2, m_Line.x1, m_Line.y1, &x, &y ); 680| } 681| else 682| { x = m_Line.x2; y = m_Line.y2; } 683| 684| Line_Plus_getArrowParamType4( x, y, m_Line.x1, m_Line.y1, 685| 8 + m_Width*4, xy ); 686| } 687|} 688| 689| 690| 691|/*********************************************************************** 692| 2-18. <<< [Line_Ex::ConvertByZoom] 座標の配列にズームやオフセットを考慮させる >>> 693|【引数】 694| ・POINT* xy; (入出力)変換する頂点の配列 695| ・int nXY; 頂点数 696|************************************************************************/ 697|void Line_Ex::ConvertByZoom( CadPrim_DrawParam* p, POINT* xy, int nXY ) 698|{ 699| POINT* xy_over = xy + nXY; 700| 701| for ( ; xy < xy_over; xy++ ) { 702| xy->x = xy->x * p->zoom / 100 - p->x0; 703| xy->y = xy->y * p->zoom / 100 - p->y0; 704| } 705|} 706| 707| 708|/*********************************************************************** 709| 2-19. <<< [Line_Ex::copy] CadPrim::copy の実装部 >>> 710|************************************************************************/ 711|void Line_Ex::copy( CadPrim* a, ListX* prims ) 712|{ 713| Line_Ex* l = (Line_Ex*)a; 714| 715| m_id = l->m_id; 716| m_Line.x1 = l->m_Line.x1; 717| m_Line.y1 = l->m_Line.y1; 718| m_Line.x2 = l->m_Line.x2; 719| m_Line.y2 = l->m_Line.y2; 720| m_Width = l->m_Width; 721| m_Color = l->m_Color; 722| m_bDash = l->m_bDash; 723| 724| m_Arrow1 = l->m_Arrow1; 725| m_Arrow2 = l->m_Arrow2; 726| 727| m_Controler_id[0] = l->m_Controler_id[0]; 728| m_Controler_id[1] = l->m_Controler_id[1]; 729| m_Controler[0] = Undo_Uty_getPrimPtr( prims, m_Controler_id[0] ); 730| m_Controler[1] = Undo_Uty_getPrimPtr( prims, m_Controler_id[1] ); 731| m_Link[0].prim_id = l->m_Link[0].prim_id; 732| m_Link[1].prim_id = l->m_Link[1].prim_id; 733| m_Link[0].prim = Undo_Uty_getPrimPtr( prims, m_Link[0].prim_id ); 734| m_Link[1].prim = Undo_Uty_getPrimPtr( prims, m_Link[1].prim_id ); 735|} 736| 737|/*********************************************************************** 738| 2-20. <<< [Line_Ex::copyStyle] CadPrim::copyStyle の実装部 >>> 739|************************************************************************/ 740|void Line_Ex::copyStyle( CadPrim* a, ListX* prims ) 741|{ 742| Line_Ex* l = (Line_Ex*)a; 743| 744| m_Width = l->m_Width; 745| m_Color = l->m_Color; 746| m_bDash = l->m_bDash; 747|} 748| 749|/*********************************************************************** 750| 2-21. <<< [Line_Ex::isEqual] CadPrim::isEqual の実装部 >>> 751|************************************************************************/ 752|bool Line_Ex::isEqual( CadPrim* a ) 753|{ 754| Line_Ex* l = (Line_Ex*)a; 755| 756| return ( 757| a->GetTypeID() == Line_Ex_TypeID && 758| m_id == l->m_id && 759| m_Line.x1 == l->m_Line.x1 && 760| m_Line.y1 == l->m_Line.y1 && 761| m_Line.x2 == l->m_Line.x2 && 762| m_Line.y2 == l->m_Line.y2 && 763| m_Width == l->m_Width && 764| m_Color == l->m_Color && 765| m_bDash == l->m_bDash && 766| 767| m_Arrow1 == l->m_Arrow1 && 768| m_Arrow2 == l->m_Arrow2 && 769| 770| m_Controler_id[0] == l->m_Controler_id[0] && 771| m_Controler_id[1] == l->m_Controler_id[1] && 772| m_Link[0].prim_id == l->m_Link[0].prim_id && 773| m_Link[1].prim_id == l->m_Link[1].prim_id ); 774|} 775| 776|/*********************************************************************** 777| 2-22. <<< [Line_Ex::GetNewCopy] CadPrim::GetNewCopy の実装部 >>> 778|************************************************************************/ 779|CadPrim* Line_Ex::GetNewCopy( ListX* prims ) 780|{ 781| Line_Ex* r = new Line_Ex; 782| 783| r->copy( this, prims ); 784| return r; 785|} 786| 787| 788|/*********************************************************************** 789| 2-23. <<< [Line_Ex::GetSerializedSize] CadPrim::GetSerializedSize の実装部 >>> 790|************************************************************************/ 791|int Line_Ex::GetSerializedSize() 792|{ 793| return sizeof(*this); 794|} 795| 796| 797|/*********************************************************************** 798| 2-24. <<< [Line_Ex::CopyToSerial] CadPrim::CopyToSerial の実装部 >>> 799|************************************************************************/ 800|void Line_Ex::CopyToSerial( void* a ) 801|{ 802| Line_Ex* l = (Line_Ex*)a; 803| 804| l->m_id = m_id; 805| l->m_Line.x1 = m_Line.x1; 806| l->m_Line.y1 = m_Line.y1; 807| l->m_Line.x2 = m_Line.x2; 808| l->m_Line.y2 = m_Line.y2; 809| l->m_Width = m_Width; 810| l->m_Color = m_Color; 811| l->m_bDash = m_bDash; 812| 813| l->m_Arrow1 = m_Arrow1; 814| l->m_Arrow2 = m_Arrow2; 815| 816| l->m_Controler_id[0] = m_Controler_id[0]; 817| l->m_Controler_id[1] = m_Controler_id[1]; 818| l->m_Link[0].prim_id = m_Link[0].prim_id; 819| l->m_Link[1].prim_id = m_Link[1].prim_id; 820|} 821| 822| 823|/*********************************************************************** 824| 2-25. <<< [Line_Ex::CopyFromSerial] CadPrim::CopyFromSerial の実装部 >>> 825|************************************************************************/ 826|void Line_Ex::CopyFromSerial( void* a ) 827|{ 828| Line_Ex* l = (Line_Ex*)a; 829| 830| m_id = l->m_id; 831| m_Line.x1 = l->m_Line.x1; 832| m_Line.y1 = l->m_Line.y1; 833| m_Line.x2 = l->m_Line.x2; 834| m_Line.y2 = l->m_Line.y2; 835| m_Width = l->m_Width; 836| m_Color = l->m_Color; 837| m_bDash = l->m_bDash; 838| 839| m_Arrow1 = l->m_Arrow1; 840| m_Arrow2 = l->m_Arrow2; 841| 842| m_Controler_id[0] = l->m_Controler_id[0]; 843| m_Controler_id[1] = l->m_Controler_id[1]; 844| m_Link[0].prim_id = l->m_Link[0].prim_id; 845| m_Link[1].prim_id = l->m_Link[1].prim_id; 846|} 847| 848| 849|/*********************************************************************** 850| 2-26. <<< [Line_Ex::GetHitHandleNum] Line_getHitHandleNum の C++ ラップ >>> 851|************************************************************************/ 852|int Line_Ex::GetHitHandleNum( int x, int y, int zoom, int mode, int* dx, int* dy, int* diff, int* arrow ) 853|{ 854| int i = Line_getHitHandleNum( &m_Line, x, y, zoom, m_Width, dx, dy, diff, arrow ); 855| 856| if ( i > 0 ) { 857| if ( m_Controler[i - 1] != NULL ) 858| i = 0; 859| } 860| 861| return i; 862|} 863| 864| 865|/*********************************************************************** 866| 2-27. <<< [Line_Ex::Move] CadPrim::Move の実装部 >>> 867|************************************************************************/ 868|void Line_Ex::Move( int dx, int dy ) 869|{ 870| m_Line.x1 += dx; m_Line.y1 += dy; 871| m_Line.x2 += dx; m_Line.y2 += dy; 872| 873| if ( m_Controler[0] != NULL && ! m_Controler[0]->GetHold() ) 874| m_Controler[0]->Move( dx, dy ); 875| if ( m_Controler[1] != NULL && ! m_Controler[1]->GetHold() ) 876| m_Controler[1]->Move( dx, dy ); 877|} 878| 879| 880|/*********************************************************************** 881| 2-28. <<< [Line_Ex::MoveByHandle] CadPrim::MoveByHandle の実装部 >>> 882|************************************************************************/ 883|void Line_Ex::MoveByHandle( int iHandle, int x, int y, bool bShift, bool bRotate ) 884|{ 885| if ( iHandle == -1 ) { 886| int dx = x - m_Line.x1; 887| int dy = y - m_Line.y1; 888| 889| if ( m_Controler[0] != NULL ) m_Controler[0]->Move( dx, dy ); 890| if ( m_Controler[1] != NULL ) m_Controler[1]->Move( dx, dy ); 891| } 892| 893| Line_moveByHandle( &m_Line, iHandle, x, y, bShift ); 894|} 895| 896| 897|/*********************************************************************** 898| 2-29. <<< [Line_Ex::GetCenterOfHandle] CadPrim::GetCenterOfHandle の実装部 >>> 899|************************************************************************/ 900|void Line_Ex::GetCenterOfHandle( int iHandle, int* x, int* y ) 901|{ 902| if ( iHandle == 1 ) { *x = m_Line.x1; *y = m_Line.y1; } 903| else if ( iHandle == 2 ) { *x = m_Line.x2; *y = m_Line.y2; } 904|} 905| 906| 907|/*********************************************************************** 908| 2-30. <<< [Line_Ex::SetHold] CadPrim::SetHold の実装部 >>> 909|************************************************************************/ 910|void Line_Ex::SetHold( bool b ) 911|{ 912| m_bHold = b; 913|} 914| 915|/*********************************************************************** 916| 2-31. <<< [Line_Ex::GetHold] CadPrim::GetHold の実装部 >>> 917|************************************************************************/ 918|bool Line_Ex::GetHold() 919|{ 920| return m_bHold; 921|} 922| 923|/*********************************************************************** 924| 2-32. <<< [Line_Ex::IsHoldable] CadPrim::IsHoldable の実装部 >>> 925|【補足】 926|・[*]--[*] のときは、ラインは選択不可。両[] を動かし、リンクでラインを動かす。 927|・[*]--[ ] のときは、ラインは選択不可。片方の[]で、リンクラインを動かす。 928|・[ ]--[ ] のときは、ラインを選択可能にして、リンクラインで両[]を動かす。 929|・[*]-- のときは、ラインを選択可能にして、両選択のときはリンクでラインを動かさない。 930|・[ ]-- のときは、ラインを選択可能にして、リンクラインで[]も動かす。 931|・凡例:[*]:選択状態のText_Box, [ ]選択していないText_Box, --リンクライン。 932|************************************************************************/ 933|bool Line_Ex::IsHoldable() 934|{ 935| return m_Controler[0] == NULL || m_Controler[1] == NULL || 936| ( ( m_Controler[0] != NULL && ! m_Controler[0]->GetHold() ) && 937| ( m_Controler[1] != NULL && ! m_Controler[1]->GetHold() ) ); 938|} 939| 940| 941|/*********************************************************************** 942| 2-33. <<< [Line_Ex::SetSelected] CadPrim::SetSelected の実装部 >>> 943|************************************************************************/ 944|void Line_Ex::SetSelected( bool b ) 945|{ 946| m_bSelected = b; 947|} 948| 949|/*********************************************************************** 950| 2-34. <<< [Line_Ex::GetSelected] CadPrim::GetSelected の実装部 >>> 951|************************************************************************/ 952|bool Line_Ex::GetSelected() 953|{ 954| return m_bSelected; 955|} 956| 957| 958|/*********************************************************************** 959| 2-35. <<< [Line_Ex::IsMultiSelect] CadPrim::IsMultiSelect の実装部 >>> 960|************************************************************************/ 961|bool Line_Ex::IsMultiSelect( Rect* rect ) 962|{ 963| return Line_isCrossToRect( &m_Line, rect ); 964|} 965| 966| 967|/*********************************************************************** 968| 2-36. <<< [Line_Ex::GetForAlign] CadPrim::GetForAlign の実装部 >>> 969|************************************************************************/ 970|int Line_Ex::GetForAlign( int iPos ) 971|{ 972| switch ( iPos ) { 973| case CadPrim_AlignLeft: 974| return m_Line.x1 < m_Line.x2 ? m_Line.x1 : m_Line.x2; 975| case CadPrim_AlignRight: 976| return m_Line.x1 < m_Line.x2 ? m_Line.x2 : m_Line.x1; 977| case CadPrim_AlignTop: 978| return m_Line.y1 < m_Line.y2 ? m_Line.y1 : m_Line.y2; 979| case CadPrim_AlignBottom: 980| return m_Line.y1 < m_Line.y2 ? m_Line.y2 : m_Line.y1; 981| case CadPrim_AlignVertical: 982| return (m_Line.x1 + m_Line.x2) / 2; 983| case CadPrim_AlignHorizontal: 984| return (m_Line.y1 + m_Line.y2) / 2; 985| default: error(); return 0; 986| } 987|} 988| 989|/*********************************************************************** 990| 2-37. <<< [Line_Ex::SetForAlign] CadPrim::SetForAlign の実装部 >>> 991|************************************************************************/ 992|void Line_Ex::SetForAlign( int iPos, int value ) 993|{ 994| int diff; 995| 996| switch ( iPos ) { 997| 998| case CadPrim_AlignLeft: 999| if ( m_Line.x1 < m_Line.x2 ) 1000| { m_Line.x2 += value - m_Line.x1; m_Line.x1 = value; } 1001| else 1002| { m_Line.x1 += value - m_Line.x2; m_Line.x2 = value; } 1003| break; 1004| 1005| case CadPrim_AlignRight: 1006| if ( m_Line.x1 < m_Line.x2 ) 1007| { m_Line.x1 += value - m_Line.x2; m_Line.x2 = value; } 1008| else 1009| { m_Line.x2 += value - m_Line.x1; m_Line.x1 = value; } 1010| break; 1011| 1012| case CadPrim_AlignTop: 1013| if ( m_Line.y1 < m_Line.y2 ) 1014| { m_Line.y2 += value - m_Line.y1; m_Line.y1 = value; } 1015| else 1016| { m_Line.y1 += value - m_Line.y2; m_Line.y2 = value; } 1017| break; 1018| 1019| case CadPrim_AlignBottom: 1020| if ( m_Line.y1 < m_Line.y2 ) 1021| { m_Line.y1 += value - m_Line.y2; m_Line.y2 = value; } 1022| else 1023| { m_Line.y2 += value - m_Line.y1; m_Line.y1 = value; } 1024| break; 1025| 1026| case CadPrim_AlignVertical: 1027| diff = value - ( m_Line.x1 + m_Line.x2 ) / 2; 1028| m_Line.x1 += diff; m_Line.x2 += diff; 1029| break; 1030| 1031| case CadPrim_AlignHorizontal: 1032| diff = value - ( m_Line.y1 + m_Line.y2 ) / 2; 1033| m_Line.y1 += diff; m_Line.y2 += diff; 1034| break; 1035| 1036| default: error(); 1037| } 1038|} 1039| 1040|/*********************************************************************** 1041| 2-38. <<< [Line_Ex::GetForFitSize] CadPrim::GetForFitSize の実装部 >>> 1042|************************************************************************/ 1043|int Line_Ex::GetForFitSize( int iAttr ) 1044|{ 1045| if ( iAttr == CadPrim_Horizontal ) { 1046| if ( m_Line.x1 < m_Line.x2 ) return m_Line.x2 - m_Line.x1 +1; 1047| else return m_Line.x1 - m_Line.x2 +1; 1048| } 1049| else { 1050| if ( m_Line.y1 < m_Line.y2 ) return m_Line.y2 - m_Line.y1 +1; 1051| else return m_Line.y1 - m_Line.y2 +1; 1052| } 1053|} 1054| 1055|/*********************************************************************** 1056| 2-39. <<< [Line_Ex::SetForFitSize] CadPrim::SetForFitSize の実装部 >>> 1057|************************************************************************/ 1058|void Line_Ex::SetForFitSize( int iAttr, int value ) 1059|{ 1060| if ( iAttr == CadPrim_Horizontal ) { 1061| if ( m_Line.x1 < m_Line.x2 ) m_Line.x2 = value + m_Line.x1 -1; 1062| else m_Line.x2 = m_Line.x1 - value +1; 1063| } 1064| else { 1065| if ( m_Line.y1 < m_Line.y2 ) m_Line.y2 = value + m_Line.y1 -1; 1066| else m_Line.y2 = m_Line.y1 - value +1; 1067| } 1068|} 1069| 1070|/*********************************************************************** 1071| 2-40. <<< [Line_Ex::OnCreated] CadPrim::OnCreated の実装部 >>> 1072|************************************************************************/ 1073|void Line_Ex::OnCreated() 1074|{ 1075| int dx = m_Line.x1 - m_Line.x2; 1076| int dy = m_Line.y1 - m_Line.y2; 1077| 1078| if ( dx >= -2 && dx <= 2 && dy >= -2 && dy <= 2 ) { 1079| m_Line.x2 = m_Line.x1 + 32; m_Line.y2 = m_Line.y1 + 20; 1080| } 1081|} 1082| 1083| 1084|/*********************************************************************** 1085| 2-41. <<< [Line_Ex::GetNProp] プロパティの要素数を返す >>> 1086|************************************************************************/ 1087|int Line_Ex::GetNProp() 1088|{ 1089| #ifdef NDEBUG 1090| return 9; 1091| #else 1092| return 14; 1093| #endif 1094|} 1095| 1096| 1097|/*********************************************************************** 1098| 2-42. <<< [Line_Ex::GetProp] プロパティの名前と値を取得する >>> 1099|************************************************************************/ 1100|int Line_Ex::GetProp( int iProp, bool bJapanese, char* name, int name_size, 1101| char* value, int value_size, const char* path, void** option ) 1102|{ 1103| int r = CadPrim_ReadOnly; 1104| 1105| static ListX list; 1106| static StrX_ListElem strs[8]; 1107| static int range[2]; 1108| 1109| 1110| switch ( iProp ) { 1111| case 0: 1112| strncpy( name, "x1", name_size ); 1113| sprintf( value, "%d", m_Line.x1 ); 1114| range[0] = INT_MIN; range[1] = INT_MAX; 1115| *option = range; 1116| r = CadPrim_Int; 1117| break; 1118| case 1: 1119| strncpy( name, "y1", name_size ); 1120| sprintf( value, "%d", m_Line.y1 ); 1121| range[0] = INT_MIN; range[1] = INT_MAX; 1122| *option = range; 1123| r = CadPrim_Int; 1124| break; 1125| case 2: 1126| strncpy( name, "x2", name_size ); 1127| sprintf( value, "%d", m_Line.x2 ); 1128| range[0] = INT_MIN; range[1] = INT_MAX; 1129| *option = range; 1130| r = CadPrim_Int; 1131| break; 1132| case 3: 1133| strncpy( name, "y2", name_size ); 1134| sprintf( value, "%d", m_Line.y2 ); 1135| range[0] = INT_MIN; range[1] = INT_MAX; 1136| *option = range; 1137| r = CadPrim_Int; 1138| break; 1139| case 4: 1140| if ( bJapanese ) 1141| strncpy( name, "線幅", name_size ); 1142| else 1143| strncpy( name, "Line Width", name_size ); 1144| sprintf( value, "%d", m_Width ); 1145| range[0] = 1; range[1] = INT_MAX; 1146| *option = range; 1147| r = CadPrim_Int; 1148| break; 1149| case 5: 1150| if ( bJapanese ) 1151| strncpy( name, "色", name_size ); 1152| else 1153| strncpy( name, "Color", name_size ); 1154| StrX_getColorStr( value, m_Color ); 1155| r = CadPrim_Color; 1156| break; 1157| case 6: 1158| if ( bJapanese ) 1159| strncpy( name, "破線", name_size ); 1160| else 1161| strncpy( name, "Dashed Line", name_size ); 1162| sprintf( value, "%d", m_bDash ); 1163| r = CadPrim_Bool; 1164| break; 1165| case 7: 1166| ListX_init( &list ); 1167| if ( bJapanese ) { 1168| strncpy( name, "頂点1の形状", name_size ); 1169| ListX_addLast( &list, &strs[0] ); strs[0].p = "矢印なし"; 1170| ListX_addLast( &list, &strs[1] ); strs[1].p = "→ 矢印"; 1171| ListX_addLast( &list, &strs[2] ); strs[2].p = "● 丸"; 1172| ListX_addLast( &list, &strs[3] ); strs[3].p = "▲ 三角"; 1173| ListX_addLast( &list, &strs[4] ); strs[4].p = "◆ ひし形"; 1174| ListX_addLast( &list, &strs[5] ); strs[5].p = "○ 丸抜き"; 1175| ListX_addLast( &list, &strs[6] ); strs[6].p = "△ 三角抜き"; 1176| ListX_addLast( &list, &strs[7] ); strs[7].p = "◇ ひし形抜き"; 1177| } 1178| else { 1179| strncpy( name, "Shape of Point1", name_size ); 1180| ListX_addLast( &list, &strs[0] ); strs[0].p = "No Arrow"; 1181| ListX_addLast( &list, &strs[1] ); strs[1].p = "-> Arrow"; 1182| ListX_addLast( &list, &strs[2] ); strs[2].p = " Circle"; 1183| ListX_addLast( &list, &strs[3] ); strs[3].p = " Triangle"; 1184| ListX_addLast( &list, &strs[4] ); strs[4].p = " Diamond"; 1185| ListX_addLast( &list, &strs[5] ); strs[5].p = "O Circle(Hole)"; 1186| ListX_addLast( &list, &strs[6] ); strs[6].p = " Triangle(Hole)"; 1187| ListX_addLast( &list, &strs[7] ); strs[7].p = " Diamond(Hole)"; 1188| } 1189| sprintf( value, "%d", m_Arrow1 ); 1190| *option = &list; 1191| r = CadPrim_Select; 1192| break; 1193| case 8: 1194| ListX_init( &list ); 1195| if ( bJapanese ) { 1196| strncpy( name, "頂点2の形状", name_size ); 1197| ListX_addLast( &list, &strs[0] ); strs[0].p = "矢印なし"; 1198| ListX_addLast( &list, &strs[1] ); strs[1].p = "→ 矢印"; 1199| ListX_addLast( &list, &strs[2] ); strs[2].p = "● 丸"; 1200| ListX_addLast( &list, &strs[3] ); strs[3].p = "▲ 三角"; 1201| ListX_addLast( &list, &strs[4] ); strs[4].p = "◆ ひし形"; 1202| ListX_addLast( &list, &strs[5] ); strs[5].p = "○ 丸抜き"; 1203| ListX_addLast( &list, &strs[6] ); strs[6].p = "△ 三角抜き"; 1204| ListX_addLast( &list, &strs[7] ); strs[7].p = "◇ ひし形抜き"; 1205| } 1206| else { 1207| strncpy( name, "Shape of Point2", name_size ); 1208| ListX_addLast( &list, &strs[0] ); strs[0].p = "No Arrow"; 1209| ListX_addLast( &list, &strs[1] ); strs[1].p = "-> Arrow"; 1210| ListX_addLast( &list, &strs[2] ); strs[2].p = " Circle"; 1211| ListX_addLast( &list, &strs[3] ); strs[3].p = " Triangle"; 1212| ListX_addLast( &list, &strs[4] ); strs[4].p = " Diamond"; 1213| ListX_addLast( &list, &strs[5] ); strs[5].p = "O Circle(Hole)"; 1214| ListX_addLast( &list, &strs[6] ); strs[6].p = " Triangle(Hole)"; 1215| ListX_addLast( &list, &strs[7] ); strs[7].p = " Diamond(Hole)"; 1216| } 1217| sprintf( value, "%d", m_Arrow2 ); 1218| *option = &list; 1219| r = CadPrim_Select; 1220| break; 1221| #ifndef NDEBUG 1222| case 9: 1223| strncpy( name, "id", name_size ); 1224| sprintf( value, "%d", m_id ); 1225| break; 1226| case 10: 1227| strncpy( name, "m_Link[0]", name_size ); 1228| sprintf( value, "%d", m_Link[0].prim_id ); 1229| break; 1230| case 11: 1231| strncpy( name, "m_Link[1]", name_size ); 1232| sprintf( value, "%d", m_Link[1].prim_id ); 1233| break; 1234| case 12: 1235| strncpy( name, "m_Controler_id[0]", name_size ); 1236| sprintf( value, "%d", m_Controler_id[0] ); 1237| break; 1238| case 13: 1239| strncpy( name, "m_Controler_id[1]", name_size ); 1240| sprintf( value, "%d", m_Controler_id[1] ); 1241| break; 1242| #endif 1243| } 1244| 1245| return r; 1246|} 1247| 1248|/*********************************************************************** 1249| 2-43. <<< [Line_Ex::SetProp] プロパティの値を設定する >>> 1250|************************************************************************/ 1251|void Line_Ex::SetProp( int iProp, const char* value, const char* path ) 1252|{ 1253| switch ( iProp ) { 1254| case 0: 1255| m_Line.x1 = atoi( value ); 1256| break; 1257| case 1: 1258| m_Line.y1 = atoi( value ); 1259| break; 1260| case 2: 1261| m_Line.x2 = atoi( value ); 1262| break; 1263| case 3: 1264| m_Line.y2 = atoi( value ); 1265| break; 1266| case 4: 1267| m_Width = atoi( value ); 1268| break; 1269| case 5: 1270| m_Color = StrX_getColorValue( value ); 1271| break; 1272| case 6: 1273| m_bDash = atoi( value ) != 0; 1274| break; 1275| case 7: 1276| m_Arrow1 = atoi( value ); 1277| break; 1278| case 8: 1279| m_Arrow2 = atoi( value ); 1280| break; 1281| } 1282|} 1283| 1284| 1285|/*********************************************************************** 1286| 2-44. <<< [Line_Ex::IsNeedUnicode] CadPrim::IsNeedUnicode の実装部 >>> 1287|************************************************************************/ 1288|bool Line_Ex::IsNeedUnicode() 1289|{ 1290| return false; 1291|} 1292| 1293| 1294|/*********************************************************************** 1295| 2-45. <<< [Line_Ex::GetLinkToControler] CadPrim::GetLinkToControler の実装部 >>> 1296|************************************************************************/ 1297|CadPrim* Line_Ex::GetLinkToControler( int iHandle ) 1298|{ 1299| ASSERT( iHandle == 1 || iHandle == 2 ); 1300| return m_Controler[iHandle - 1]; 1301|} 1302| 1303|/*********************************************************************** 1304| 2-46. <<< [Line_Ex::GetLinkIDToControler] CadPrim::GetLinkIDToControler の実装部 >>> 1305|************************************************************************/ 1306|int Line_Ex::GetLinkIDToControler( int iHandle ) 1307|{ 1308| ASSERT( iHandle == 1 || iHandle == 2 ); 1309| return m_Controler_id[iHandle - 1]; 1310|} 1311| 1312|/*********************************************************************** 1313| 2-47. <<< [Line_Ex::GetNumOfLinkToControler] CadPrim::GetNumOfLinkToControler の実装部 >>> 1314|************************************************************************/ 1315|int Line_Ex::GetNumOfLinkToControler() 1316|{ 1317| return 2; 1318|} 1319| 1320| 1321|/*********************************************************************** 1322| 2-48. <<< [Line_Ex::GetLinkableHandleNum] CadPrim::GetLinkableHandleNum の実装部 >>> 1323|************************************************************************/ 1324|int Line_Ex::GetLinkableHandleNum( int x, int y ) 1325|{ 1326| return 0; 1327|} 1328| 1329| 1330|/*********************************************************************** 1331| 2-49. <<< [Line_Ex::LinkToHandle] CadPrim::LinkToHandle の実装部 >>> 1332|************************************************************************/ 1333|void Line_Ex::LinkToHandle( int iHandleOfThis, CadPrim* prim, int iHandleOfPrim ) 1334|{ 1335| ASSERT( iHandleOfThis >= 1 && iHandleOfThis <= 2 ); 1336| 1337| m_Link[iHandleOfThis - 1].prim = prim; 1338| m_Link[iHandleOfThis - 1].prim_id = prim->GetID(); 1339| m_Link[iHandleOfThis - 1].iHandle = iHandleOfPrim; 1340| if ( iHandleOfThis == 1 ) { 1341| m_Link[0].x = m_Line.x1; 1342| m_Link[0].y = m_Line.y1; 1343| } 1344| else { 1345| m_Link[1].x = m_Line.x2; 1346| m_Link[1].y = m_Line.y2; 1347| } 1348| 1349| prim->LinkToControler( iHandleOfPrim, this ); 1350|} 1351| 1352| 1353|/*********************************************************************** 1354| 2-50. <<< [Line_Ex::UnlinkToHandle] CadPrim::UnlinkToHandle の実装部 >>> 1355|************************************************************************/ 1356|void Line_Ex::UnlinkToHandle( CadPrim* prim, int iHandleOfPrim, bool mutual ) 1357|{ 1358| int i; 1359| 1360| for ( i = 0; i < 2; i++ ) { 1361| if ( m_Link[i].prim == prim && m_Link[i].iHandle == iHandleOfPrim ) 1362| break; 1363| } 1364| if ( i < 2 ) { 1365| prim->UnlinkToControler( iHandleOfPrim, this ); 1366| m_Link[i].prim = NULL; 1367| m_Link[i].prim_id = 0; 1368| } 1369|} 1370| 1371| 1372|/*********************************************************************** 1373| 2-51. <<< [Line_Ex::UnlinkAll] CadPrim::UnlinkAll の実装部 >>> 1374|************************************************************************/ 1375|void Line_Ex::UnlinkAll() 1376|{ 1377| if ( m_Controler[0] != NULL ) 1378| m_Controler[0]->UnlinkToHandle( this, 1 ); 1379| if ( m_Controler[1] != NULL ) 1380| m_Controler[1]->UnlinkToHandle( this, 2 ); 1381| if ( m_Link[0].prim != NULL ) 1382| UnlinkToHandle( m_Link[0].prim, m_Link[0].iHandle ); 1383| if ( m_Link[1].prim != NULL ) 1384| UnlinkToHandle( m_Link[1].prim, m_Link[1].iHandle ); 1385|} 1386| 1387|/*********************************************************************** 1388| 2-52. <<< [Line_Ex::LinkToControler] CadPrim::LinkToControler の実装部 >>> 1389|************************************************************************/ 1390|void Line_Ex::LinkToControler( int iHandle, CadPrim* ctrl ) 1391|{ 1392| m_Controler[ iHandle - 1 ] = ctrl; 1393| m_Controler_id[ iHandle - 1 ] = ctrl->GetID(); 1394|} 1395| 1396| 1397|/*********************************************************************** 1398| 2-53. <<< [Line_Ex::UnlinkToControler] CadPrim::UnlinkToControler の実装部 >>> 1399|************************************************************************/ 1400|void Line_Ex::UnlinkToControler( int iHandle, CadPrim* ctrl ) 1401|{ 1402| m_Controler[ iHandle - 1 ] = NULL; 1403| m_Controler_id[ iHandle - 1 ] = 0; 1404|} 1405| 1406| 1407|/*********************************************************************** 1408| 2-54. <<< [Line_Ex::AdjustLinks] CadPrim::AdjustLinks の実装部 >>> 1409|************************************************************************/ 1410|void Line_Ex::AdjustLinks( ListX* prims ) 1411|{ 1412| m_Controler[0] = Undo_Uty_getPrimPtr( prims, m_Controler_id[0] ); 1413| m_Controler[1] = Undo_Uty_getPrimPtr( prims, m_Controler_id[1] ); 1414| m_Link[0].prim = Undo_Uty_getPrimPtr( prims, m_Link[0].prim_id ); 1415| m_Link[1].prim = Undo_Uty_getPrimPtr( prims, m_Link[1].prim_id ); 1416| 1417| if ( m_Link[0].prim != NULL ) m_Link[0].prim->AdjustLinks( prims ); 1418| if ( m_Link[1].prim != NULL ) m_Link[1].prim->AdjustLinks( prims ); 1419|} 1420| 1421| 1422|#endif 1423| 1424|/*-------------------------------------------------------------------------*/ 1425|/* 3. <<<< ◆ (Line_Corner) 直角ライン >>>> */ 1426|/*-------------------------------------------------------------------------*/ 1427| 1428|#ifdef LINE_USES_WINDOWS_DC 1429| 1430| 1431|Line_Corner::Line_Corner() 1432|{ 1433| m_bInUndoBuf = false; 1434| m_bHold = false; 1435| m_bSelected = false; 1436| 1437| m_Line.x1 = 0; 1438| m_Line.y1 = 0; 1439| m_Line.x2 = 10; 1440| m_Line.y2 = 10; 1441| m_CornerX = 5; 1442| m_CornerY = 5; 1443| m_Dir = Line_DirN; 1444| m_Width = 1; 1445| m_Color = 0x000000; 1446| m_bDash = false; 1447| 1448| m_Arrow1 = 0; 1449| m_Arrow2 = 0; 1450| m_ArrowsInReading = NULL; 1451| 1452| m_Controler[0] = NULL; 1453| m_Controler[1] = NULL; 1454| m_Link[0].prim = NULL; 1455| m_Link[1].prim = NULL; 1456| 1457| m_Controler_id[0] = 0; 1458| m_Controler_id[1] = 0; 1459| m_Link[0].prim_id = 0; 1460| m_Link[1].prim_id = 0; 1461| 1462| StdPlus_onMalloc( this ); 1463|} 1464| 1465| 1466|Line_Corner::~Line_Corner() 1467|{ 1468| StdPlus_onFree( this ); 1469| if ( ! m_bInUndoBuf ) UnlinkAll(); 1470|} 1471| 1472| 1473|/*********************************************************************** 1474| 3-1. <<< [Line_Corner::print] CadPrim::print の実装部 >>> 1475|************************************************************************/ 1476|void Line_Corner::print( const char* title ) 1477|{ 1478| #ifndef NDEBUG 1479| Errors_printf( "%sLine_Corner[%d:%p]: (%d,%d)-(%d,%d), hold=%d, sel=%d, undo=%d", title, 1480| m_id, this, m_Line.x1, m_Line.y1, m_Line.x2, m_Line.y2, m_bHold, m_bSelected, m_bInUndoBuf ); 1481| Errors_printf( "%s m_Controler[0] = %p, id=%d, arrow = %d", title, 1482| m_Controler[0], m_Controler_id[0], m_Arrow1 ); 1483| Errors_printf( "%s m_Controler[1] = %p, id=%d, arrow = %d", title, 1484| m_Controler[1], m_Controler_id[1], m_Arrow2 ); 1485| m_Link[0].print( title ); 1486| m_Link[1].print( title ); 1487| #endif 1488|} 1489| 1490| 1491|/*********************************************************************** 1492| 3-2. <<< [Line_Corner::GetID] CadPrim::GetID の実装部 >>> 1493|************************************************************************/ 1494|int Line_Corner::GetID() 1495|{ 1496| return m_id; 1497|} 1498| 1499| 1500|/*********************************************************************** 1501| 3-3. <<< [Line_Corner::SetID] CadPrim::SetID の実装部 >>> 1502|************************************************************************/ 1503|void Line_Corner::SetID( int id ) 1504|{ 1505| m_id = id; 1506|} 1507| 1508| 1509|/*********************************************************************** 1510| 3-4. <<< [Line_Corner::OnChgedLinkID] CadPrim::OnChgedLinkID の実装部 >>> 1511|************************************************************************/ 1512|void Line_Corner::OnChgedLinkID( int oldID, int newID ) 1513|{ 1514| if ( m_Link[0].prim_id == oldID ) m_Link[0].prim_id = newID; 1515| if ( m_Link[1].prim_id == oldID ) m_Link[1].prim_id = newID; 1516| if ( m_Controler_id[0] == oldID ) m_Controler_id[0] = newID; 1517| if ( m_Controler_id[1] == oldID ) m_Controler_id[1] = newID; 1518|} 1519| 1520| 1521|/*********************************************************************** 1522| 3-5. <<< [Line_Corner::GetTypeID] CadPrim::GetTypeID の実装部 >>> 1523|************************************************************************/ 1524|int Line_Corner::GetTypeID() 1525|{ 1526| return Line_Corner_TypeID; 1527|} 1528| 1529| 1530|/*********************************************************************** 1531| 3-6. <<< [Line_Corner::GetTypeNameJp] CadPrim::GetTypeNameJp の実装部 >>> 1532|************************************************************************/ 1533|char* Line_Corner::GetTypeNameJp() 1534|{ 1535| return "折れ線"; 1536|} 1537| 1538| 1539|/*********************************************************************** 1540| 3-7. <<< [Line_Corner::GetTypeNameEn] CadPrim::GetTypeNameEn の実装部 >>> 1541|************************************************************************/ 1542|char* Line_Corner::GetTypeNameEn() 1543|{ 1544| return "Cornered Line"; 1545|} 1546| 1547|/*********************************************************************** 1548| 3-8. <<< [Line_Corner::SetBInUndoBuf] CadPrim::SetBInUndoBuf の実装部 >>> 1549|************************************************************************/ 1550|void Line_Corner::SetBInUndoBuf( bool b ) 1551|{ 1552| m_bInUndoBuf = b; 1553|} 1554| 1555| 1556|/*********************************************************************** 1557| 3-9. <<< [Line_Corner::GetLinkURL] CadPrim::GetLinkURL の実装部 >>> 1558|************************************************************************/ 1559|char* Line_Corner::GetLinkURL() 1560|{ 1561| return ""; 1562|} 1563| 1564| 1565|/*********************************************************************** 1566| 3-10. <<< [Line_Corner::GetIdLabel] CadPrim::GetIdLabel の実装部 >>> 1567|************************************************************************/ 1568|char* Line_Corner::GetIdLabel() 1569|{ 1570| return ""; 1571|} 1572| 1573| 1574| 1575|/*********************************************************************** 1576| 3-11. <<< [Line_Corner::OutSVG] SVGファイルに属性値を出力する >>> 1577|************************************************************************/ 1578|void Line_Corner::OutSVG( CadPrim_SaveParam* p ) 1579|{ 1580| int i; 1581| bool bLineOfArrow1; 1582| bool bLineOfArrow2; 1583| 1584| GetLines(); 1585| 1586| fprintf( p->f, "\t<g>\n" ); 1587| 1588| for ( i = 0; i < m_LinesN - 1; i++ ) { 1589| 1590| bLineOfArrow1 = (i == 0 && ! m_bArrow1IsLast) || (i == m_LinesN - 2 && m_bArrow1IsLast); 1591| bLineOfArrow2 = (i == m_LinesN - 2 && ! m_bArrow1IsLast) || (i == 0 && m_bArrow1IsLast); 1592| 1593| if ( ( m_Arrow1 != 0 && bLineOfArrow1 ) || ( m_Arrow2 != 0 && bLineOfArrow2 ) ) 1594| fprintf( p->f, "\t<g>\n" ); 1595| 1596| 1597| /* 主線を描画する */ 1598| fprintf( p->f, "\t<line x1=\"%d.5\" y1=\"%d.5\" x2=\"%d.5\" y2=\"%d.5\"\n", 1599| m_LinesX[i], m_LinesY[i], m_LinesX[i+1], m_LinesY[i+1] ); 1600| 1601| fprintf( p->f, "\t\tstyle=\"fill:none;stroke:rgb(%d,%d,%d);" 1602| "stroke-width:%d%s;stroke-linecap:round\"", 1603| Color_WinRGB_getR( m_Color ), Color_WinRGB_getG( m_Color ), 1604| Color_WinRGB_getB( m_Color ), 1605| m_Width, 1606| m_bDash ? ";stroke-dasharray:4,4" : "" ); 1607| 1608| if ( bLineOfArrow1 ) { 1609| if ( m_Arrow1 != 0 || m_Controler[0] != NULL ) { 1610| fprintf( p->f, "\n\t\tp%d=\"%d,%d,%d,%d\"", /* x,y,a,l */ 1611| m_bArrow1IsLast ? 2 : 1, 1612| m_Line.x1, m_Line.y1, m_Arrow1, m_Controler[0] != NULL ? 1 : 0 ); 1613| } 1614| } 1615| if ( bLineOfArrow2 ) { 1616| if ( m_Arrow2 != 0 || m_Controler[1] != NULL ) { 1617| fprintf( p->f, "\n\t\tp%d=\"%d,%d,%d,%d\"", /* x,y,a,l */ 1618| m_bArrow1IsLast ? 1 : 2, 1619| m_Line.x2, m_Line.y2, m_Arrow2, m_Controler[1] != NULL ? 1 : 0 ); 1620| } 1621| } 1622| 1623| fputs( "/>\n", p->f ); 1624| 1625| 1626| /* 矢印を描画する */ 1627| if ( (m_Arrow1 && bLineOfArrow1) || (m_Arrow2 && bLineOfArrow2) ) { 1628| Line leftWing, rightWing; 1629| 1630| if ( m_Arrow1 == 1 && bLineOfArrow1 ) { 1631| GetArrowParamType1( 1, &leftWing, &rightWing ); 1632| 1633| fprintf( p->f, "\t<line x1=\"%d.5\" y1=\"%d.5\" x2=\"%d.5\" y2=\"%d.5\"\n", 1634| leftWing.x1, leftWing.y1, leftWing.x2, leftWing.y2 ); 1635| 1636| fprintf( p->f, "\t\tstyle=\"fill:none;stroke:rgb(%d,%d,%d);" 1637| "stroke-width:%d;stroke-linecap:round\"/>\n", 1638| Color_WinRGB_getR( m_Color ), Color_WinRGB_getG( m_Color ), 1639| Color_WinRGB_getB( m_Color ), 1640| m_Width ); 1641| 1642| fprintf( p->f, "\t<line x1=\"%d.5\" y1=\"%d.5\" x2=\"%d.5\" y2=\"%d.5\"\n", 1643| rightWing.x1, rightWing.y1, rightWing.x2, rightWing.y2 ); 1644| 1645| fprintf( p->f, "\t\tstyle=\"fill:none;stroke:rgb(%d,%d,%d);" 1646| "stroke-width:%d;stroke-linecap:round\"/>\n", 1647| Color_WinRGB_getR( m_Color ), Color_WinRGB_getG( m_Color ), 1648| Color_WinRGB_getB( m_Color ), 1649| m_Width ); 1650| } 1651| if ( m_Arrow2 == 1 && bLineOfArrow2 ) { 1652| GetArrowParamType1( 2, &leftWing, &rightWing ); 1653| 1654| fprintf( p->f, "\t<line x1=\"%d.5\" y1=\"%d.5\" x2=\"%d.5\" y2=\"%d.5\"\n", 1655| leftWing.x1, leftWing.y1, leftWing.x2, leftWing.y2 ); 1656| 1657| fprintf( p->f, "\t\tstyle=\"fill:none;stroke:rgb(%d,%d,%d);" 1658| "stroke-width:%d;stroke-linecap:round\"/>\n", 1659| Color_WinRGB_getR( m_Color ), Color_WinRGB_getG( m_Color ), 1660| Color_WinRGB_getB( m_Color ), 1661| m_Width ); 1662| 1663| fprintf( p->f, "\t<line x1=\"%d.5\" y1=\"%d.5\" x2=\"%d.5\" y2=\"%d.5\"\n", 1664| rightWing.x1, rightWing.y1, rightWing.x2, rightWing.y2 ); 1665| 1666| fprintf( p->f, "\t\tstyle=\"fill:none;stroke:rgb(%d,%d,%d);" 1667| "stroke-width:%d;stroke-linecap:round\"/>\n", 1668| Color_WinRGB_getR( m_Color ), Color_WinRGB_getG( m_Color ), 1669| Color_WinRGB_getB( m_Color ), 1670| m_Width ); 1671| } 1672| } 1673| 1674| if ( ( m_Arrow1 == 2 && bLineOfArrow1 ) || ( m_Arrow2 == 2 && bLineOfArrow2 ) ) { 1675| int x, y, r; 1676| 1677| if ( m_Arrow1 == 2 && bLineOfArrow1 ) { 1678| GetArrowParamType2( 1, &x, &y, &r ); 1679| 1680| fprintf( p->f, "\t<circle cx=\"%d.5\" cy=\"%d.5\" r=\"%d\"\n", x, y, r ); 1681| 1682| fprintf( p->f, "\t\tstyle=\"fill:rgb(%d,%d,%d);stroke:rgb(%d,%d,%d);" 1683| "stroke-width:%d\"/>\n", 1684| Color_WinRGB_getR( m_Color ), Color_WinRGB_getG( m_Color ), 1685| Color_WinRGB_getB( m_Color ), 1686| Color_WinRGB_getR( m_Color ), Color_WinRGB_getG( m_Color ), 1687| Color_WinRGB_getB( m_Color ), 1688| 1 ); 1689| } 1690| if ( m_Arrow2 == 2 && bLineOfArrow2 ) { 1691| GetArrowParamType2( 2, &x, &y, &r ); 1692| 1693| fprintf( p->f, "\t<circle cx=\"%d.5\" cy=\"%d.5\" r=\"%d\"\n", x, y, r ); 1694| 1695| fprintf( p->f, "\t\tstyle=\"fill:rgb(%d,%d,%d);stroke:rgb(%d,%d,%d);" 1696| "stroke-width:%d\"/>\n", 1697| Color_WinRGB_getR( m_Color ), Color_WinRGB_getG( m_Color ), 1698| Color_WinRGB_getB( m_Color ), 1699| Color_WinRGB_getR( m_Color ), Color_WinRGB_getG( m_Color ), 1700| Color_WinRGB_getB( m_Color ), 1701| 1 ); 1702| } 1703| } 1704| 1705| if ( (m_Arrow1 >= 2 && m_Arrow1 <= 7 && bLineOfArrow1) || 1706| (m_Arrow2 >= 2 && m_Arrow2 <= 7 && bLineOfArrow2) ) { 1707| POINT xy[4]; 1708| int x, y, r; 1709| 1710| if ( m_Arrow1 == 2 && bLineOfArrow1 ) { /* 丸矢印 */ 1711| GetArrowParamType2( 1, &x, &y, &r ); 1712| fprintf( p->f, "\t<circle cx=\"%d.5\" cy=\"%d.5\" r=\"%d\"\n", x, y, r ); 1713| } 1714| if ( m_Arrow1 == 3 && bLineOfArrow1 ) { /* 三角矢印 */ 1715| GetArrowParamType3( 1, xy ); 1716| fprintf( p->f, "\t<polygon points=\"%d.5,%d.5 %d.5,%d.5 %d.5,%d.5\"\n", 1717| xy[0].x, xy[0].y, xy[1].x, xy[1].y, xy[2].x, xy[2].y ); 1718| } 1719| if ( m_Arrow1 == 4 && bLineOfArrow1 ) { /* ひし形矢印 */ 1720| GetArrowParamType4( 1, xy ); 1721| fprintf( p->f, "\t<polygon points=\"%d.5,%d.5 %d.5,%d.5 %d.5,%d.5 %d.5,%d.5\"\n", 1722| xy[0].x, xy[0].y, xy[1].x, xy[1].y, xy[2].x, xy[2].y, xy[3].x, xy[3].y ); 1723| } 1724| if ( m_Arrow1 >= 2 && m_Arrow1 <= 4 && bLineOfArrow1 ) { 1725| fprintf( p->f, "\t\tstyle=\"fill:rgb(%d,%d,%d);stroke:rgb(%d,%d,%d);" 1726| "stroke-width:%d\"/>\n", 1727| Color_WinRGB_getR( m_Color ), Color_WinRGB_getG( m_Color ), 1728| Color_WinRGB_getB( m_Color ), 1729| Color_WinRGB_getR( m_Color ), Color_WinRGB_getG( m_Color ), 1730| Color_WinRGB_getB( m_Color ), 1731| m_Width ); 1732| } 1733| 1734| if ( m_Arrow2 == 2 && bLineOfArrow2 ) { 1735| GetArrowParamType2( 2, &x, &y, &r ); 1736| fprintf( p->f, "\t<circle cx=\"%d.5\" cy=\"%d.5\" r=\"%d\"\n", x, y, r ); 1737| } 1738| if ( m_Arrow2 == 3 && bLineOfArrow2 ) { /* 三角矢印 */ 1739| GetArrowParamType3( 2, xy ); 1740| fprintf( p->f, "\t<polygon points=\"%d.5,%d.5 %d.5,%d.5 %d.5,%d.5\"\n", 1741| xy[0].x, xy[0].y, xy[1].x, xy[1].y, xy[2].x, xy[2].y ); 1742| } 1743| if ( m_Arrow2 == 4 && bLineOfArrow2 ) { /* ひし形矢印 */ 1744| GetArrowParamType4( 2, xy ); 1745| fprintf( p->f, "\t<polygon points=\"%d.5,%d.5 %d.5,%d.5 %d.5,%d.5 %d.5,%d.5\"\n", 1746| xy[0].x, xy[0].y, xy[1].x, xy[1].y, xy[2].x, xy[2].y, xy[3].x, xy[3].y ); 1747| } 1748| if ( m_Arrow2 >= 2 && m_Arrow2 <= 4 && bLineOfArrow2 ) { 1749| fprintf( p->f, "\t\tstyle=\"fill:rgb(%d,%d,%d);stroke:rgb(%d,%d,%d);" 1750| "stroke-width:%d\"/>\n", 1751| Color_WinRGB_getR( m_Color ), Color_WinRGB_getG( m_Color ), 1752| Color_WinRGB_getB( m_Color ), 1753| Color_WinRGB_getR( m_Color ), Color_WinRGB_getG( m_Color ), 1754| Color_WinRGB_getB( m_Color ), 1755| m_Width ); 1756| } 1757| 1758| 1759| /* 白抜き */ 1760| 1761| if ( m_Arrow1 == 5 && bLineOfArrow1 ) { /* 丸矢印 */ 1762| GetArrowParamType2( 1, &x, &y, &r ); 1763| fprintf( p->f, "\t<circle cx=\"%d.5\" cy=\"%d.5\" r=\"%d\"\n", x, y, r ); 1764| } 1765| if ( m_Arrow1 == 6 && bLineOfArrow1 ) { /* 三角矢印 */ 1766| GetArrowParamType3( 1, xy ); 1767| fprintf( p->f, "\t<polygon points=\"%d.5,%d.5 %d.5,%d.5 %d.5,%d.5\"\n", 1768| xy[0].x, xy[0].y, xy[1].x, xy[1].y, xy[2].x, xy[2].y ); 1769| } 1770| if ( m_Arrow1 == 7 && bLineOfArrow1 ) { /* ひし形矢印 */ 1771| GetArrowParamType4( 1, xy ); 1772| fprintf( p->f, "\t<polygon points=\"%d.5,%d.5 %d.5,%d.5 %d.5,%d.5 %d.5,%d.5\"\n", 1773| xy[0].x, xy[0].y, xy[1].x, xy[1].y, xy[2].x, xy[2].y, xy[3].x, xy[3].y ); 1774| } 1775| if ( m_Arrow1 >= 5 && m_Arrow1 <= 7 && bLineOfArrow1 ) { 1776| int c = ( Line_isColorBright(m_Color) ) ? 0 : 255; 1777| 1778| fprintf( p->f, "\t\tstyle=\"fill:rgb(%d,%d,%d);stroke:rgb(%d,%d,%d);" 1779| "stroke-width:%d\"/>\n", 1780| c, c, c, 1781| Color_WinRGB_getR( m_Color ), Color_WinRGB_getG( m_Color ), 1782| Color_WinRGB_getB( m_Color ), 1783| m_Width ); 1784| } 1785| 1786| if ( m_Arrow2 == 5 && bLineOfArrow2 ) { 1787| GetArrowParamType2( 2, &x, &y, &r ); 1788| fprintf( p->f, "\t<circle cx=\"%d.5\" cy=\"%d.5\" r=\"%d\"\n", x, y, r ); 1789| } 1790| if ( m_Arrow2 == 6 && bLineOfArrow2 ) { /* 三角矢印 */ 1791| GetArrowParamType3( 2, xy ); 1792| fprintf( p->f, "\t<polygon points=\"%d.5,%d.5 %d.5,%d.5 %d.5,%d.5\"\n", 1793| xy[0].x, xy[0].y, xy[1].x, xy[1].y, xy[2].x, xy[2].y ); 1794| } 1795| if ( m_Arrow2 == 7 && bLineOfArrow2 ) { /* ひし形矢印 */ 1796| GetArrowParamType4( 2, xy ); 1797| fprintf( p->f, "\t<polygon points=\"%d.5,%d.5 %d.5,%d.5 %d.5,%d.5 %d.5,%d.5\"\n", 1798| xy[0].x, xy[0].y, xy[1].x, xy[1].y, xy[2].x, xy[2].y, xy[3].x, xy[3].y ); 1799| } 1800| if ( m_Arrow2 >= 5 && m_Arrow2 <= 7 && bLineOfArrow2 ) { 1801| int c = ( Line_isColorBright(m_Color) ) ? 0 : 255; 1802| 1803| fprintf( p->f, "\t\tstyle=\"fill:rgb(%d,%d,%d);stroke:rgb(%d,%d,%d);" 1804| "stroke-width:%d\"/>\n", 1805| c, c, c, 1806| Color_WinRGB_getR( m_Color ), Color_WinRGB_getG( m_Color ), 1807| Color_WinRGB_getB( m_Color ), 1808| m_Width ); 1809| } 1810| } 1811| 1812| if ( ( m_Arrow1 != 0 && bLineOfArrow1 ) || ( m_Arrow2 != 0 && bLineOfArrow2 ) ) 1813| fprintf( p->f, "\t</g>\n" ); 1814| } 1815| 1816| fprintf( p->f, "\t</g>\n" ); 1817|} 1818| 1819| 1820|/*********************************************************************** 1821| 3-12. <<< [Line_Corner::Draw] CadPrim::Draw の実装部 >>> 1822|************************************************************************/ 1823|void Line_Corner::Draw( CDC* dc, CadPrim_DrawParam* p ) 1824|{ 1825| int zoom = p->zoom; 1826| CPen pen( PS_SOLID, m_Width * zoom / 100, 1827| p->bWhiteToBGColor && m_Color == 0x000000 ? 1828| GetSysColor( COLOR_WINDOWTEXT ) : m_Color ); 1829| CPen dashPen( PS_DOT, 1, 1830| p->bWhiteToBGColor && m_Color == 0x000000 ? 1831| GetSysColor( COLOR_WINDOWTEXT ) : m_Color ); 1832| CPen* oldPen; 1833| int i; 1834| 1835| GetLines(); 1836| 1837| 1838| /* ラインを破線で描画する(太字の破線は CPen のみで対応できない) */ 1839| if ( m_bDash ) { 1840| int j; 1841| 1842| oldPen = dc->SelectObject( &dashPen ); 1843| 1844| for ( i = 1; i < m_LinesN; i++ ) { 1845| int x1 = m_LinesX[i - 1] * zoom / 100 - p->x0; 1846| int y1 = m_LinesY[i - 1] * zoom / 100 - p->y0; 1847| int x2 = m_LinesX[i] * zoom / 100 - p->x0; 1848| int y2 = m_LinesY[i] * zoom / 100 - p->y0; 1849| int dx = x2 - x1; 1850| int dy = y2 - y1; 1851| int j_start = - (m_Width - 1) * zoom / 200; 1852| int j_end = m_Width * zoom / 200; 1853| 1854| if ( abs(dx) > abs(dy) ) { 1855| for ( j = j_start; j <= j_end; j++ ) { /* 太線 */ 1856| dc->MoveTo( x1, y1 + j ); 1857| dc->LineTo( x2, y2 + j ); 1858| } 1859| } 1860| else { 1861| for ( j = j_start; j <= j_end; j++ ) { /* 太線 */ 1862| dc->MoveTo( x1 + j, y1 ); 1863| dc->LineTo( x2 + j, y2 ); 1864| } 1865| } 1866| } 1867| 1868| dc->SelectObject( oldPen ); 1869| } 1870| 1871| /* ラインを実線で描画する */ 1872| else { 1873| oldPen = dc->SelectObject( &pen ); 1874| 1875| dc->MoveTo( m_LinesX[0] * zoom / 100 - p->x0, m_LinesY[0] * zoom / 100 - p->y0 ); 1876| for ( i = 1; i < m_LinesN; i++ ) 1877| dc->LineTo( m_LinesX[i] * zoom / 100 - p->x0, m_LinesY[i] * zoom / 100 - p->y0 ); 1878| 1879| dc->SelectObject( oldPen ); 1880| } 1881| 1882| 1883| /* リンクテキストの Draw 後に決定する属性を設定する */ 1884| if ( m_Controler[0] != NULL && ((Text_Box*)m_Controler[0])->IsNotSetDrawParam() ) 1885| ((Text_Box*)m_Controler[0])->Draw( dc, p ); 1886| 1887| if ( m_Controler[1] != NULL && ((Text_Box*)m_Controler[1])->IsNotSetDrawParam() ) 1888| ((Text_Box*)m_Controler[1])->Draw( dc, p ); 1889| 1890| 1891| /* 羽根型の矢印を描画する */ 1892| if ( m_Arrow1 == 1 || m_Arrow2 == 1 ) { 1893| Line leftWing, rightWing; 1894| 1895| oldPen = dc->SelectObject( &pen ); 1896| 1897| if ( m_Arrow1 == 1 ) { 1898| GetArrowParamType1( 1, &leftWing, &rightWing ); 1899| dc->MoveTo( leftWing.x1 * zoom / 100 - p->x0, leftWing.y1 * zoom / 100 - p->y0 ); 1900| dc->LineTo( leftWing.x2 * zoom / 100 - p->x0, leftWing.y2 * zoom / 100 - p->y0 ); 1901| dc->MoveTo( rightWing.x1 * zoom / 100 - p->x0, rightWing.y1 * zoom / 100 - p->y0 ); 1902| dc->LineTo( rightWing.x2 * zoom / 100 - p->x0, rightWing.y2 * zoom / 100 - p->y0 ); 1903| } 1904| if ( m_Arrow2 == 1 ) { 1905| GetArrowParamType1( 2, &leftWing, &rightWing ); 1906| dc->MoveTo( leftWing.x1 * zoom / 100 - p->x0, leftWing.y1 * zoom / 100 - p->y0 ); 1907| dc->LineTo( leftWing.x2 * zoom / 100 - p->x0, leftWing.y2 * zoom / 100 - p->y0 ); 1908| dc->MoveTo( rightWing.x1 * zoom / 100 - p->x0, rightWing.y1 * zoom / 100 - p->y0 ); 1909| dc->LineTo( rightWing.x2 * zoom / 100 - p->x0, rightWing.y2 * zoom / 100 - p->y0 ); 1910| } 1911| 1912| dc->SelectObject( oldPen ); 1913| } 1914| 1915| /* 丸型の矢印を描画する */ 1916| if ( (m_Arrow1 >= 2 && m_Arrow1 <= 7) || (m_Arrow2 >= 2 && m_Arrow2 <= 7) ) { 1917| POINT xy[4]; 1918| int x, y, r; 1919| 1920| CBrush brush( m_Color ); 1921| CBrush brushR( Line_isColorBright(m_Color) ? RGB(0,0,0) : RGB(0xFF,0xFF,0xFF) ); 1922| CBrush* oldBrush; 1923| 1924| oldPen = dc->SelectObject( &pen ); 1925| oldBrush = dc->SelectObject( &brush ); 1926| 1927| if ( m_Arrow1 == 2 ) { /* 丸矢印 */ 1928| GetArrowParamType2( 1, &x, &y, &r ); 1929| dc->Ellipse( (x - r) * zoom / 100 - p->x0, (y - r) * zoom / 100 - p->y0, 1930| (x + r) * zoom / 100 - p->x0, (y + r) * zoom / 100 - p->y0 ); 1931| } 1932| if ( m_Arrow2 == 2 ) { 1933| GetArrowParamType2( 2, &x, &y, &r ); 1934| dc->Ellipse( (x - r) * zoom / 100 - p->x0, (y - r) * zoom / 100 - p->y0, 1935| (x + r) * zoom / 100 - p->x0, (y + r) * zoom / 100 - p->y0 ); 1936| } 1937| if ( m_Arrow1 == 3 ) 1938| { GetArrowParamType3( 1, xy ); dc->Polygon( xy, 3 ); } /* 三角矢印 */ 1939| if ( m_Arrow2 == 3 ) 1940| { GetArrowParamType3( 2, xy ); dc->Polygon( xy, 3 ); } 1941| if ( m_Arrow1 == 4 ) 1942| { GetArrowParamType4( 1, xy ); dc->Polygon( xy, 4 ); } /* ひし形矢印 */ 1943| if ( m_Arrow2 == 4 ) 1944| { GetArrowParamType4( 2, xy ); dc->Polygon( xy, 4 ); } 1945| 1946| 1947| dc->SelectObject( &brushR ); /* 白抜き */ 1948| 1949| if ( m_Arrow1 == 5 ) { 1950| GetArrowParamType2( 1, &x, &y, &r ); 1951| dc->Ellipse( (x - r) * zoom / 100 - p->x0, (y - r) * zoom / 100 - p->y0, 1952| (x + r) * zoom / 100 - p->x0, (y + r) * zoom / 100 - p->y0 ); 1953| } 1954| if ( m_Arrow2 == 5 ) { 1955| GetArrowParamType2( 2, &x, &y, &r ); 1956| dc->Ellipse( (x - r) * zoom / 100 - p->x0, (y - r) * zoom / 100 - p->y0, 1957| (x + r) * zoom / 100 - p->x0, (y + r) * zoom / 100 - p->y0 ); 1958| } 1959| if ( m_Arrow1 == 6 ) 1960| { GetArrowParamType3( 1, xy ); dc->Polygon( xy, 3 ); } 1961| if ( m_Arrow2 == 6 ) 1962| { GetArrowParamType3( 2, xy ); dc->Polygon( xy, 3 ); } 1963| if ( m_Arrow1 == 7 ) 1964| { GetArrowParamType4( 1, xy ); dc->Polygon( xy, 4 ); } 1965| if ( m_Arrow2 == 7 ) 1966| { GetArrowParamType4( 2, xy ); dc->Polygon( xy, 4 ); } 1967| 1968| dc->SelectObject( oldBrush ); 1969| dc->SelectObject( oldPen ); 1970| } 1971| 1972| 1973| /* ハンドルを描画する */ 1974| if ( m_bHold && p->bDrawHandle ) 1975| DrawHandles( dc, p, ~GetSysColor( COLOR_HIGHLIGHT ) & 0xFFFFFF, false ); 1976|} 1977| 1978| 1979| 1980|/*********************************************************************** 1981| 3-13. <<< [Line_Corner::DrawHandles] CadPrim::DrawJamdles の実装部 >>> 1982|************************************************************************/ 1983|void Line_Corner::DrawHandles( CDC* dc, CadPrim_DrawParam* p, COLORREF color, 1984| bool bDrawFrame ) 1985|{ 1986| CPen pen( PS_SOLID, 1, color ^ 0xFFFFFF ); 1987| CBrush brush( color ); 1988| CPen* oldPen; 1989| CBrush* oldBrush; 1990| int i, x, y; 1991| 1992| oldPen = dc->SelectObject( &pen ); 1993| oldBrush = dc->SelectObject( &brush ); 1994| 1995| for ( i = 1; i <= Line_nHandle; i++ ) { 1996| Line_getCenterOfHandle( &m_Line, i, &x, &y ); 1997| dc->Rectangle( x * p->zoom / 100 - p->x0 - 3, y * p->zoom / 100 - p->y0 - 3, 1998| x * p->zoom / 100 - p->x0 + 3, y * p->zoom / 100 - p->y0 + 3 ); 1999| } 2000| dc->Rectangle( m_CornerX * p->zoom / 100 - p->x0 - 3, m_CornerY * p->zoom / 100 - p->y0 - 3, 2001| m_CornerX * p->zoom / 100 - p->x0 + 3, m_CornerY * p->zoom / 100 - p->y0 + 3 ); 2002| 2003| dc->SelectObject( oldBrush ); 2004| dc->SelectObject( oldPen ); 2005|} 2006| 2007| 2008|/*********************************************************************** 2009| 3-14. <<< [Line_Corner::GetArrowParamType1] Type1 の矢印の描画に必要なパラメータを得る >>> 2010|【引数】 2011| ・int i; 頂点番号(1 or 2) 2012|************************************************************************/ 2013|void Line_Corner::GetArrowParamType1( int i, Line* leftWing, Line* rightWing ) 2014|{ 2015| int x1, y1; 2016| int x2, y2; 2017| int tail; 2018| 2019| tail = GetArrowPoint( i, &x1, &y1 ); 2020| 2021| x2 = m_LinesX[tail]; 2022| y2 = m_LinesY[tail]; 2023| 2024| Line_Plus_getArrowParamType1( x1, y1, x2, y2, 8+m_Width*4, leftWing, rightWing ); 2025|} 2026| 2027| 2028|/*********************************************************************** 2029| 3-15. <<< [Line_Corner::GetArrowParamType2] Type2 の矢印の描画に必要なパラメータを得る >>> 2030|【引数】 2031| ・int i; 頂点番号(1 or 2) 2032| ・int* x, y, r; (出力)丸のパラメータ 2033|************************************************************************/ 2034|void Line_Corner::GetArrowParamType2( int i, int* x, int* y, int* r ) 2035|{ 2036| GetArrowPoint( i, x, y ); 2037| *r = 4; 2038|} 2039| 2040| 2041|/*********************************************************************** 2042| 3-16. <<< [Line_Corner::GetArrowParamType3] Type3 の矢印(三角)の描画に必要なパラメータを得る >>> 2043|【引数】 2044| ・int i; 頂点番号(1 or 2) 2045|************************************************************************/ 2046|void Line_Corner::GetArrowParamType3( int i, POINT* xy ) 2047|{ 2048| int x1, y1; 2049| int x2, y2; 2050| int tail; 2051| 2052| tail = GetArrowPoint( i, &x1, &y1 ); 2053| 2054| x2 = m_LinesX[tail]; 2055| y2 = m_LinesY[tail]; 2056| 2057| Line_Plus_getArrowParamType3( x1, y1, x2, y2, 8+m_Width*4, xy ); 2058|} 2059| 2060| 2061|/*********************************************************************** 2062| 3-17. <<< [Line_Corner::GetArrowParamType4] Type4 の矢印(ひし形)の描画に必要なパラメータを得る >>> 2063|【引数】 2064| ・int i; 頂点番号(1 or 2) 2065|************************************************************************/ 2066|void Line_Corner::GetArrowParamType4( int i, POINT* xy ) 2067|{ 2068| int x1, y1; 2069| int x2, y2; 2070| int tail; 2071| 2072| tail = GetArrowPoint( i, &x1, &y1 ); 2073| 2074| x2 = m_LinesX[tail]; 2075| y2 = m_LinesY[tail]; 2076| 2077| Line_Plus_getArrowParamType4( x1, y1, x2, y2, 8+m_Width*4, xy ); 2078|} 2079| 2080| 2081|/*********************************************************************** 2082| 3-18. <<< [Line_Corner::GetArrowPoint] 矢印の先端の座標を得る >>> 2083|【引数】 2084| ・int i; 頂点番号(1 or 2) 2085| ・int* x, y; (出力)矢印の先端の座標 2086| ・int 返り値; 矢印の尾に相当する、部分ラインの頂点番号 2087|************************************************************************/ 2088|int Line_Corner::GetArrowPoint( int i, int* x, int* y ) 2089|{ 2090| int x1, y1; 2091| int x2, y2; 2092| int iLine, plus; 2093| Text_Box* text; 2094| RECT rc0; 2095| Rect rc; 2096| 2097| ASSERT( i == 1 || i == 2 ); 2098| 2099| if ( ( i == 2 ? 1 : 0 ) + ( m_Line.x1 >= m_Line.x2 ? 1 : 0 ) == 1 ) { 2100| iLine = m_LinesN - 1; plus = -1; 2101| } 2102| else { 2103| iLine = 0; plus = +1; 2104| } 2105| 2106| if ( i == 1 ) text = (Text_Box*)m_Controler[0]; 2107| else text = (Text_Box*)m_Controler[1]; 2108| 2109| if ( text != NULL ) { 2110| text->GetBox( &rc0 ); 2111| Rect_init_by2XY( &rc, rc0.left, rc0.top, rc0.right, rc0.bottom ); 2112| 2113| do { 2114| x1 = m_LinesX[iLine]; y1 = m_LinesY[iLine]; 2115| x2 = m_LinesX[iLine + plus]; y2 = m_LinesY[iLine + plus]; 2116| if ( ( Rect_isPointIn( &rc, x1, y1 ) ? 1 : 0 ) + 2117| ( Rect_isPointIn( &rc, x2, y2 ) ? 1 : 0 ) == 1 ) { 2118| text->GetArrowPoint( i, x1, y1, x2, y2, x, y ); 2119| return iLine + plus; 2120| } 2121| iLine += plus; 2122| } while ( iLine > 0 && iLine < m_LinesN - 1 ); 2123| 2124| *x = ( rc0.left + rc0.right ) / 2; 2125| *y = ( rc0.top + rc0.bottom ) / 2; 2126| return iLine; 2127| } 2128| else { 2129| *x = m_LinesX[iLine]; 2130| *y = m_LinesY[iLine]; 2131| return iLine + plus; 2132| } 2133|} 2134| 2135| 2136| 2137|/*********************************************************************** 2138| 3-19. <<< [Line_Corner::ConvertByZoom] 座標の配列にズームやオフセットを考慮させる >>> 2139|【引数】 2140| ・POINT* xy; (入出力)変換する頂点の配列 2141| ・int nXY; 頂点数 2142|************************************************************************/ 2143|void Line_Corner::ConvertByZoom( CadPrim_DrawParam* p, POINT* xy, int nXY ) 2144|{ 2145| POINT* xy_over = xy + nXY; 2146| 2147| for ( ; xy < xy_over; xy++ ) { 2148| xy->x = xy->x * p->zoom / 100 - p->x0; 2149| xy->y = xy->y * p->zoom / 100 - p->y0; 2150| } 2151|} 2152| 2153| 2154|/*********************************************************************** 2155| 3-20. <<< [Line_Corner::copy] CadPrim::copy の実装部 >>> 2156|************************************************************************/ 2157|void Line_Corner::copy( CadPrim* a, ListX* prims ) 2158|{ 2159| Line_Corner* l = (Line_Corner*)a; 2160| 2161| m_id = l->m_id; 2162| m_Line.x1 = l->m_Line.x1; 2163| m_Line.y1 = l->m_Line.y1; 2164| m_Line.x2 = l->m_Line.x2; 2165| m_Line.y2 = l->m_Line.y2; 2166| 2167| m_CornerX = l->m_CornerX; 2168| m_CornerY = l->m_CornerY; 2169| m_Dir = l->m_Dir; 2170| m_SlideCorner = l->m_SlideCorner; 2171| 2172| m_Width = l->m_Width; 2173| m_Color = l->m_Color; 2174| m_bDash = l->m_bDash; 2175| m_Arrow1 = l->m_Arrow1; 2176| m_Arrow2 = l->m_Arrow2; 2177| 2178| m_Controler_id[0] = l->m_Controler_id[0]; 2179| m_Controler_id[1] = l->m_Controler_id[1]; 2180| m_Controler[0] = Undo_Uty_getPrimPtr( prims, m_Controler_id[0] ); 2181| m_Controler[1] = Undo_Uty_getPrimPtr( prims, m_Controler_id[1] ); 2182| m_Link[0].prim_id = l->m_Link[0].prim_id; 2183| m_Link[1].prim_id = l->m_Link[1].prim_id; 2184| m_Link[0].prim = Undo_Uty_getPrimPtr( prims, m_Link[0].prim_id ); 2185| m_Link[1].prim = Undo_Uty_getPrimPtr( prims, m_Link[1].prim_id ); 2186|} 2187| 2188|/*********************************************************************** 2189| 3-21. <<< [Line_Corner::copyStyle] CadPrim::copyStyle の実装部 >>> 2190|************************************************************************/ 2191|void Line_Corner::copyStyle( CadPrim* a, ListX* prims ) 2192|{ 2193| Line_Corner* l = (Line_Corner*)a; 2194| 2195| m_Width = l->m_Width; 2196| m_Color = l->m_Color; 2197| m_bDash = l->m_bDash; 2198|} 2199| 2200|/*********************************************************************** 2201| 3-22. <<< [Line_Corner::isEqual] CadPrim::isEqual の実装部 >>> 2202|************************************************************************/ 2203|bool Line_Corner::isEqual( CadPrim* a ) 2204|{ 2205| Line_Corner* l = (Line_Corner*)a; 2206| 2207| return ( 2208| a->GetTypeID() == Line_Corner_TypeID && 2209| m_id == l->m_id && 2210| m_Line.x1 == l->m_Line.x1 && 2211| m_Line.y1 == l->m_Line.y1 && 2212| m_Line.x2 == l->m_Line.x2 && 2213| m_Line.y2 == l->m_Line.y2 && 2214| 2215| m_CornerX == l->m_CornerX && 2216| m_CornerY == l->m_CornerY && 2217| m_Dir == l->m_Dir && 2218| m_SlideCorner == l->m_SlideCorner && 2219| 2220| m_Width == l->m_Width && 2221| m_Color == l->m_Color && 2222| m_bDash == l->m_bDash && 2223| m_Arrow1 == l->m_Arrow1 && 2224| m_Arrow2 == l->m_Arrow2 && 2225| 2226| m_Controler_id[0] == l->m_Controler_id[0] && 2227| m_Controler_id[1] == l->m_Controler_id[1] && 2228| m_Link[0].prim_id == l->m_Link[0].prim_id && 2229| m_Link[1].prim_id == l->m_Link[1].prim_id ); 2230|} 2231| 2232| 2233|/*********************************************************************** 2234| 3-23. <<< [Line_Corner::GetNewCopy] CadPrim::GetNewCopy の実装部 >>> 2235|************************************************************************/ 2236|CadPrim* Line_Corner::GetNewCopy( ListX* prims ) 2237|{ 2238| Line_Corner* r = new Line_Corner; 2239| 2240| r->copy( this, prims ); 2241| return r; 2242|} 2243| 2244| 2245|/*********************************************************************** 2246| 3-24. <<< [Line_Corner::GetSerializedSize] CadPrim::GetSerializedSize の実装部 >>> 2247|************************************************************************/ 2248|int Line_Corner::GetSerializedSize() 2249|{ 2250| return sizeof(*this); 2251|} 2252| 2253| 2254|/*********************************************************************** 2255| 3-25. <<< [Line_Corner::CopyToSerial] CadPrim::CopyToSerial の実装部 >>> 2256|************************************************************************/ 2257|void Line_Corner::CopyToSerial( void* a ) 2258|{ 2259| Line_Corner* l = (Line_Corner*)a; 2260| 2261| l->m_id = m_id; 2262| l->m_Line.x1 = m_Line.x1; 2263| l->m_Line.y1 = m_Line.y1; 2264| l->m_Line.x2 = m_Line.x2; 2265| l->m_Line.y2 = m_Line.y2; 2266| 2267| l->m_CornerX = m_CornerX; 2268| l->m_CornerY = m_CornerY; 2269| l->m_Dir = m_Dir; 2270| l->m_SlideCorner = m_SlideCorner; 2271| 2272| l->m_Width = m_Width; 2273| l->m_Color = m_Color; 2274| l->m_bDash = m_bDash; 2275| l->m_Arrow1 = m_Arrow1; 2276| l->m_Arrow2 = m_Arrow2; 2277| 2278| l->m_Controler_id[0] = m_Controler_id[0]; 2279| l->m_Controler_id[1] = m_Controler_id[1]; 2280| l->m_Link[0].prim_id = m_Link[0].prim_id; 2281| l->m_Link[1].prim_id = m_Link[1].prim_id; 2282|} 2283| 2284| 2285|/*********************************************************************** 2286| 3-26. <<< [Line_Corner::CopyFromSerial] CadPrim::CopyFromSerial の実装部 >>> 2287|************************************************************************/ 2288|void Line_Corner::CopyFromSerial( void* a ) 2289|{ 2290| Line_Corner* l = (Line_Corner*)a; 2291| 2292| m_id = l->m_id; 2293| m_Line.x1 = l->m_Line.x1; 2294| m_Line.y1 = l->m_Line.y1; 2295| m_Line.x2 = l->m_Line.x2; 2296| m_Line.y2 = l->m_Line.y2; 2297| 2298| m_CornerX = l->m_CornerX; 2299| m_CornerY = l->m_CornerY; 2300| m_Dir = l->m_Dir; 2301| m_SlideCorner = l->m_SlideCorner; 2302| 2303| m_Width = l->m_Width; 2304| m_Color = l->m_Color; 2305| m_bDash = l->m_bDash; 2306| m_Arrow1 = l->m_Arrow1; 2307| m_Arrow2 = l->m_Arrow2; 2308| 2309| m_Controler_id[0] = l->m_Controler_id[0]; 2310| m_Controler_id[1] = l->m_Controler_id[1]; 2311| m_Link[0].prim_id = l->m_Link[0].prim_id; 2312| m_Link[1].prim_id = l->m_Link[1].prim_id; 2313|} 2314| 2315| 2316|/*********************************************************************** 2317| 3-27. <<< [Line_Corner::GetHitHandleNum] CadPrim::GetHitHandleNum の実装部 >>> 2318|************************************************************************/ 2319|int Line_Corner::GetHitHandleNum( int x, int y, int zoom, int mode, int* dx, int* dy, int* diff, int* arrow ) 2320|{ 2321| int i; 2322| int dx1, dy1, dx2, dy2, dx3, dy3; 2323| int diff1 = 7; 2324| int diff2 = 4 + m_Width; 2325| 2326| if ( zoom >= 400 ) diff1 = 1; 2327| 2328| dx1 = m_Line.x1 - x; 2329| dy1 = m_Line.y1 - y; 2330| dx2 = m_Line.x2 - x; 2331| dy2 = m_Line.y2 - y; 2332| dx3 = x - m_CornerX; 2333| dy3 = y - m_CornerY; 2334| 2335| *dx = 0; *dy = 0; 2336| 2337| if ( dx1 >= -diff1 && dx1 <= diff1 && dy1 >= -diff1 && dy1 <= diff1 ) { 2338| *arrow = CadPrim_CrossArrow; 2339| *dx = m_Line.x1 - x; 2340| *dy = m_Line.y1 - y; 2341| i = 1; 2342| } 2343| else if ( dx2 >= -diff1 && dx2 <= diff1 && dy2 >= -diff1 && dy2 <= diff1 ) { 2344| *arrow = CadPrim_CrossArrow; 2345| *dx = m_Line.x2 - x; 2346| *dy = m_Line.y2 - y; 2347| i = 2; 2348| } 2349| else if ( -5 < dx3 && dx3 < 5 && -5 < dy3 && dy3 < 5 ) { /* Corner ハンドル */ 2350| *arrow = CadPrim_CrossArrow; 2351| *dx = m_CornerX - x; 2352| *dy = m_CornerY - y; 2353| return 3; 2354| } 2355| else 2356| { *arrow = CadPrim_NormalArrow; i = 0; } 2357| 2358| /* 両端 */ 2359| if ( i > 0 ) { 2360| if ( m_Controler[i - 1] != NULL ) 2361| { *arrow = CadPrim_NormalArrow; i = 0; } 2362| } 2363| 2364| /* 途中 */ 2365| else { 2366| GetLines(); 2367| 2368| for ( i = 0; i < m_LinesN - 1; i++ ) { 2369| dx1 = x - m_LinesX[i]; dy1 = y - m_LinesY[i]; 2370| dx2 = x - m_LinesX[i+1]; dy2 = y - m_LinesY[i+1]; 2371| if ( dx1 < dx2 || dy1 < dy2 ) { 2372| dx3 = dx1; dx1 = dx2; dx2 = dx3; 2373| dy3 = dy1; dy1 = dy2; dy2 = dy3; 2374| } 2375| if ( ( (dx1+diff2) * (dx2-diff2) < 0 && -diff2 < dy1 && dy1 < diff2 ) || 2376| ( (dy1+diff2) * (dy2-diff2) < 0 && -diff2 < dx1 && dx1 < diff2 ) ) { 2377| *dx = m_Line.x1 - x; *dy = m_Line.y1 - y; 2378| *arrow = CadPrim_MovableArrow; 2379| return -1; 2380| } 2381| } 2382| i = 0; 2383| } 2384| 2385| return i; 2386|} 2387| 2388| 2389|/*********************************************************************** 2390| 3-28. <<< [Line_Corner::Move] CadPrim::Move の実装部 >>> 2391|************************************************************************/ 2392|void Line_Corner::Move( int dx, int dy ) 2393|{ 2394| m_Line.x1 += dx; m_Line.y1 += dy; 2395| m_Line.x2 += dx; m_Line.y2 += dy; 2396| m_CornerX += dx; m_CornerY += dy; 2397|} 2398| 2399| 2400|/*********************************************************************** 2401| 3-29. <<< [Line_Corner::MoveByHandle] CadPrim::MoveByHandle の実装部 >>> 2402|************************************************************************/ 2403|void Line_Corner::MoveByHandle( int iHandle, int x, int y, bool bShift, bool bRotate ) 2404|{ 2405| int a, b; 2406| 2407| if ( iHandle == 3 ) { 2408| m_CornerX = x; m_CornerY = y; 2409| } 2410| else { 2411| if ( iHandle != -1 || 2412| (m_Controler[0] == NULL && m_Controler[1] == NULL) ) { 2413| 2414| if ( m_SlideCorner ) { 2415| Line_moveByHandle( &m_Line, iHandle, x, y, bShift ); 2416| m_CornerX = (m_Line.x1 + m_Line.x2) / 2; 2417| m_CornerY = m_Line.y1; // (m_Line.y1 + m_Line.y2) / 2; 2418| } 2419| else if ( iHandle == -1 ) { 2420| a = m_Line.x1; b = m_Line.y1; 2421| Line_moveByHandle( &m_Line, iHandle, x, y, bShift ); 2422| m_CornerX += m_Line.x1 - a; m_CornerY += m_Line.y1 - b; 2423| } 2424| else if ( m_CornerX - m_Line.x1 < 0 && m_CornerX - m_Line.x2 < 0 ) { 2425| if ( m_Line.x1 < m_Line.x2 ) { 2426| a = m_Line.x1 - m_CornerX; 2427| Line_moveByHandle( &m_Line, iHandle, x, y, bShift ); 2428| m_CornerX = m_Line.x1 - a; 2429| } 2430| else { 2431| a = m_Line.x2 - m_CornerX; 2432| Line_moveByHandle( &m_Line, iHandle, x, y, bShift ); 2433| m_CornerX = m_Line.x2 - a; 2434| } 2435| } 2436| else if ( m_CornerX - m_Line.x1 > 0 && m_CornerX - m_Line.x2 > 0 ) { 2437| if ( m_Line.x1 > m_Line.x2 ) { 2438| a = m_Line.x1 - m_CornerX; 2439| Line_moveByHandle( &m_Line, iHandle, x, y, bShift ); 2440| m_CornerX = m_Line.x1 - a; 2441| } 2442| else { 2443| a = m_Line.x2 - m_CornerX; 2444| Line_moveByHandle( &m_Line, iHandle, x, y, bShift ); 2445| m_CornerX = m_Line.x2 - a; 2446| } 2447| } 2448| else if ( m_CornerY - m_Line.y1 < 0 && m_CornerY - m_Line.y2 < 0 ) { 2449| if ( m_Line.y1 < m_Line.y2 ) { 2450| a = m_Line.y1 - m_CornerY; 2451| Line_moveByHandle( &m_Line, iHandle, x, y, bShift ); 2452| m_CornerY = m_Line.y1 - a; 2453| } 2454| else { 2455| a = m_Line.y2 - m_CornerY; 2456| Line_moveByHandle( &m_Line, iHandle, x, y, bShift ); 2457| m_CornerY = m_Line.y2 - a; 2458| } 2459| } 2460| else if ( m_CornerY - m_Line.y1 > 0 && m_CornerY - m_Line.y2 > 0 ) { 2461| if ( m_Line.y1 > m_Line.y2 ) { 2462| a = m_Line.y1 - m_CornerY; 2463| Line_moveByHandle( &m_Line, iHandle, x, y, bShift ); 2464| m_CornerY = m_Line.y1 - a; 2465| } 2466| else { 2467| a = m_Line.y2 - m_CornerY; 2468| Line_moveByHandle( &m_Line, iHandle, x, y, bShift ); 2469| m_CornerY = m_Line.y2 - a; 2470| } 2471| } 2472| else if ( m_Dir == Line_DirN ) { 2473| Line_moveByHandle( &m_Line, iHandle, x, y, bShift ); 2474| m_CornerX = (m_Line.x1 + m_Line.x2) / 2; 2475| } 2476| else { /* m_Dir == Line_DirZ */ 2477| Line_moveByHandle( &m_Line, iHandle, x, y, bShift ); 2478| m_CornerY = (m_Line.y1 + m_Line.y2) / 2; 2479| } 2480| } 2481| } 2482|} 2483| 2484| 2485|/*********************************************************************** 2486| 3-30. <<< [Line_Corner::GetCenterOfHandle] CadPrim::GetCenterOfHandle の実装部 >>> 2487|************************************************************************/ 2488|void Line_Corner::GetCenterOfHandle( int iHandle, int* x, int* y ) 2489|{ 2490| if ( iHandle == 1 ) { *x = m_Line.x1; *y = m_Line.y1; } 2491| else if ( iHandle == 2 ) { *x = m_Line.x2; *y = m_Line.y2; } 2492| else if ( iHandle == 3 ) { *x = m_CornerX; *y =m_CornerY; } 2493|} 2494| 2495|/*********************************************************************** 2496| 3-31. <<< [Line_Corner::SetHold] CadPrim::SetHold の実装部 >>> 2497|************************************************************************/ 2498|void Line_Corner::SetHold( bool b ) 2499|{ 2500| m_bHold = b; 2501|} 2502| 2503|/*********************************************************************** 2504| 3-32. <<< [Line_Corner::GetHold] CadPrim::GetHold の実装部 >>> 2505|************************************************************************/ 2506|bool Line_Corner::GetHold() 2507|{ 2508| return m_bHold; 2509|} 2510| 2511|/*********************************************************************** 2512| 3-33. <<< [Line_Corner::IsHoldable] CadPrim::IsHoldable の実装部 >>> 2513|【補足】 2514|・参考:Line_Ex::IsHoldable 2515|************************************************************************/ 2516|bool Line_Corner::IsHoldable() 2517|{ 2518| return m_Controler[0] == NULL || m_Controler[1] == NULL || 2519| ( ( m_Controler[0] != NULL && ! m_Controler[0]->GetHold() ) && 2520| ( m_Controler[1] != NULL && ! m_Controler[1]->GetHold() ) ); 2521|} 2522| 2523|/*********************************************************************** 2524| 3-34. <<< [Line_Corner::SetSelected] CadPrim::SetSelected の実装部 >>> 2525|************************************************************************/ 2526|void Line_Corner::SetSelected( bool b ) 2527|{ 2528| m_bSelected = b; 2529|} 2530| 2531|/*********************************************************************** 2532| 3-35. <<< [Line_Corner::GetSelected] CadPrim::GetSelected の実装部 >>> 2533|************************************************************************/ 2534|bool Line_Corner::GetSelected() 2535|{ 2536| return m_bSelected; 2537|} 2538| 2539| 2540|/*********************************************************************** 2541| 3-36. <<< [Line_Corner::IsMultiSelect] CadPrim::IsMultiSelect の実装部 >>> 2542|************************************************************************/ 2543|bool Line_Corner::IsMultiSelect( Rect* rect ) 2544|{ 2545| int i, nLine; 2546| int a1, a2, w; 2547| 2548| GetLines(); 2549| nLine = m_LinesN - 1; 2550| 2551| for ( i = 0; i < nLine; i++ ) { 2552| if ( m_LinesX[i] == m_LinesX[i+1] ) { 2553| if ( rect->x <= m_LinesX[i] && m_LinesX[i] <= rect->x + rect->w ) { 2554| a1 = m_LinesY[i]; a2 = m_LinesY[i+1]; 2555| if ( a1 > a2 ) { w = a1; a1 = a2; a2 = w; } 2556| if ( a1 < rect->y + rect->h && a2 > rect->y ) 2557| return true; 2558| } 2559| } 2560| else { ASSERT( m_LinesY[i] == m_LinesY[i+1] ); 2561| if ( rect->y <= m_LinesY[i] && m_LinesY[i] <= rect->y + rect->h ) { 2562| a1 = m_LinesX[i]; a2 = m_LinesX[i+1]; 2563| if ( a1 > a2 ) { w = a1; a1 = a2; a2 = w; } 2564| if ( a1 < rect->x + rect->w && a2 > rect->x ) 2565| return true; 2566| } 2567| } 2568| } 2569| 2570| return false; 2571|} 2572| 2573| 2574|/*********************************************************************** 2575| 3-37. <<< [Line_Corner::GetForAlign] CadPrim::GetForAlign の実装部 >>> 2576|************************************************************************/ 2577|int Line_Corner::GetForAlign( int iPos ) 2578|{ 2579| switch ( iPos ) { 2580| case CadPrim_AlignLeft: 2581| return m_Line.x1 < m_Line.x2 ? m_Line.x1 : m_Line.x2; 2582| case CadPrim_AlignRight: 2583| return m_Line.x1 < m_Line.x2 ? m_Line.x2 : m_Line.x1; 2584| case CadPrim_AlignTop: 2585| return m_Line.y1 < m_Line.y2 ? m_Line.y1 : m_Line.y2; 2586| case CadPrim_AlignBottom: 2587| return m_Line.y1 < m_Line.y2 ? m_Line.y2 : m_Line.y1; 2588| case CadPrim_AlignVertical: 2589| return m_CornerX; 2590| case CadPrim_AlignHorizontal: 2591| return m_CornerY; 2592| default: error(); return 0; 2593| } 2594|} 2595| 2596|/*********************************************************************** 2597| 3-38. <<< [Line_Corner::SetForAlign] CadPrim::SetForAlign の実装部 >>> 2598|************************************************************************/ 2599|void Line_Corner::SetForAlign( int iPos, int value ) 2600|{ 2601| switch ( iPos ) { 2602| 2603| case CadPrim_AlignLeft: 2604| if ( m_Line.x1 < m_Line.x2 ) 2605| { m_Line.x2 += value - m_Line.x1; m_Line.x1 = value; } 2606| else 2607| { m_Line.x1 += value - m_Line.x2; m_Line.x2 = value; } 2608| break; 2609| 2610| case CadPrim_AlignRight: 2611| if ( m_Line.x1 < m_Line.x2 ) 2612| { m_Line.x1 += value - m_Line.x2; m_Line.x2 = value; } 2613| else 2614| { m_Line.x2 += value - m_Line.x1; m_Line.x1 = value; } 2615| break; 2616| 2617| case CadPrim_AlignTop: 2618| if ( m_Line.y1 < m_Line.y2 ) 2619| { m_Line.y2 += value - m_Line.y1; m_Line.y1 = value; } 2620| else 2621| { m_Line.y1 += value - m_Line.y2; m_Line.y2 = value; } 2622| break; 2623| 2624| case CadPrim_AlignBottom: 2625| if ( m_Line.y1 < m_Line.y2 ) 2626| { m_Line.y1 += value - m_Line.y2; m_Line.y2 = value; } 2627| else 2628| { m_Line.y2 += value - m_Line.y1; m_Line.y1 = value; } 2629| break; 2630| 2631| case CadPrim_AlignVertical: 2632| m_CornerX = value; break; 2633| 2634| case CadPrim_AlignHorizontal: 2635| m_CornerY = value; break; 2636| 2637| default: error(); 2638| } 2639|} 2640| 2641|/*********************************************************************** 2642| 3-39. <<< [Line_Corner::GetForFitSize] CadPrim::GetForFitSize の実装部 >>> 2643|************************************************************************/ 2644|int Line_Corner::GetForFitSize( int iAttr ) 2645|{ 2646| if ( iAttr == CadPrim_Horizontal ) { 2647| if ( m_Line.x1 < m_Line.x2 ) return m_Line.x2 - m_Line.x1 +1; 2648| else return m_Line.x1 - m_Line.x2 +1; 2649| } 2650| else { 2651| if ( m_Line.y1 < m_Line.y2 ) return m_Line.y2 - m_Line.y1 +1; 2652| else return m_Line.y1 - m_Line.y2 +1; 2653| } 2654|} 2655| 2656|/*********************************************************************** 2657| 3-40. <<< [Line_Corner::SetForFitSize] CadPrim::SetForFitSize の実装部 >>> 2658|************************************************************************/ 2659|void Line_Corner::SetForFitSize( int iAttr, int value ) 2660|{ 2661| if ( iAttr == CadPrim_Horizontal ) { 2662| if ( m_Line.x1 < m_Line.x2 ) m_Line.x2 = value + m_Line.x1 -1; 2663| else m_Line.x2 = m_Line.x1 - value +1; 2664| } 2665| else { 2666| if ( m_Line.y1 < m_Line.y2 ) m_Line.y2 = value + m_Line.y1 -1; 2667| else m_Line.y2 = m_Line.y1 - value +1; 2668| } 2669|} 2670| 2671|/*********************************************************************** 2672| 3-41. <<< [Line_Corner::OnCreated] CadPrim::OnCreated の実装部 >>> 2673|************************************************************************/ 2674|void Line_Corner::OnCreated() 2675|{ 2676| int dx = m_Line.x1 - m_Line.x2; 2677| int dy = m_Line.y1 - m_Line.y2; 2678| 2679| if ( dx >= -2 && dx <= 2 && dy >= -2 && dy <= 2 ) { 2680| m_Line.x2 = m_Line.x1 + 32; m_Line.y2 = m_Line.y1 + 20; 2681| m_CornerX = m_Line.x1 + 16; m_CornerY = m_Line.y1 + 10; 2682| } 2683|} 2684| 2685| 2686|/*********************************************************************** 2687| 3-42. <<< [Line_Corner::GetNProp] プロパティの要素数を返す >>> 2688|************************************************************************/ 2689|int Line_Corner::GetNProp() 2690|{ 2691| #ifdef NDEBUG 2692| return 12; 2693| #else 2694| return 17; 2695| #endif 2696|} 2697| 2698| 2699|/*********************************************************************** 2700| 3-43. <<< [Line_Corner::GetProp] プロパティの名前と値を取得する >>> 2701|************************************************************************/ 2702|int Line_Corner::GetProp( int iProp, bool bJapanese, char* name, int name_size, 2703| char* value, int value_size, const char* path, void** option ) 2704|{ 2705| int r = CadPrim_ReadOnly; 2706| 2707| static ListX list; 2708| static StrX_ListElem strs[8]; 2709| static int range[2]; 2710| 2711| 2712| switch ( iProp ) { 2713| case 0: 2714| strncpy( name, "x1", name_size ); 2715| sprintf( value, "%d", m_Line.x1 ); 2716| range[0] = INT_MIN; range[1] = INT_MAX; 2717| *option = range; 2718| r = CadPrim_Int; 2719| break; 2720| case 1: 2721| strncpy( name, "y1", name_size ); 2722| sprintf( value, "%d", m_Line.y1 ); 2723| range[0] = INT_MIN; range[1] = INT_MAX; 2724| *option = range; 2725| r = CadPrim_Int; 2726| break; 2727| case 2: 2728| strncpy( name, "x2", name_size ); 2729| sprintf( value, "%d", m_Line.x2 ); 2730| range[0] = INT_MIN; range[1] = INT_MAX; 2731| *option = range; 2732| r = CadPrim_Int; 2733| break; 2734| case 3: 2735| strncpy( name, "y2", name_size ); 2736| sprintf( value, "%d", m_Line.y2 ); 2737| range[0] = INT_MIN; range[1] = INT_MAX; 2738| *option = range; 2739| r = CadPrim_Int; 2740| break; 2741| case 4: 2742| if ( bJapanese ) 2743| strncpy( name, "通過点 x", name_size ); 2744| else 2745| strncpy( name, "Through Point X", name_size ); 2746| sprintf( value, "%d", m_CornerX ); 2747| range[0] = INT_MIN; range[1] = INT_MAX; 2748| *option = range; 2749| r = CadPrim_Int; 2750| break; 2751| case 5: 2752| if ( bJapanese ) 2753| strncpy( name, "通過点 y", name_size ); 2754| else 2755| strncpy( name, "Through Point Y", name_size ); 2756| sprintf( value, "%d", m_CornerY ); 2757| range[0] = INT_MIN; range[1] = INT_MAX; 2758| *option = range; 2759| r = CadPrim_Int; 2760| break; 2761| case 6: 2762| ListX_init( &list ); 2763| if ( bJapanese ) { 2764| strncpy( name, "折れ線方向", name_size ); 2765| ListX_addLast( &list, &strs[0] ); strs[0].p = "Z 型(横線用)"; 2766| ListX_addLast( &list, &strs[1] ); strs[1].p = "N 型(縦線用)"; 2767| } 2768| else { 2769| strncpy( name, "Corner Direction", name_size ); 2770| ListX_addLast( &list, &strs[0] ); strs[0].p = "Z type (for Horizontal)"; 2771| ListX_addLast( &list, &strs[1] ); strs[1].p = "N type (for Vertical)"; 2772| } 2773| sprintf( value, "%d", m_Dir ); 2774| *option = &list; 2775| r = CadPrim_Select; 2776| break; 2777| case 7: 2778| if ( bJapanese ) 2779| strncpy( name, "線幅", name_size ); 2780| else 2781| strncpy( name, "Line Width", name_size ); 2782| sprintf( value, "%d", m_Width ); 2783| range[0] = 1; range[1] = INT_MAX; 2784| *option = range; 2785| r = CadPrim_Int; 2786| break; 2787| case 8: 2788| if ( bJapanese ) 2789| strncpy( name, "色", name_size ); 2790| else 2791| strncpy( name, "Color", name_size ); 2792| StrX_getColorStr( value, m_Color ); 2793| r = CadPrim_Color; 2794| break; 2795| case 9: 2796| if ( bJapanese ) 2797| strncpy( name, "破線", name_size ); 2798| else 2799| strncpy( name, "Dashed Line", name_size ); 2800| sprintf( value, "%d", m_bDash ); 2801| r = CadPrim_Bool; 2802| break; 2803| case 10: 2804| ListX_init( &list ); 2805| if ( bJapanese ) { 2806| strncpy( name, "頂点1の形状", name_size ); 2807| ListX_addLast( &list, &strs[0] ); strs[0].p = "矢印なし"; 2808| ListX_addLast( &list, &strs[1] ); strs[1].p = "→ 矢印"; 2809| ListX_addLast( &list, &strs[2] ); strs[2].p = "● 丸"; 2810| ListX_addLast( &list, &strs[3] ); strs[3].p = "▲ 三角"; 2811| ListX_addLast( &list, &strs[4] ); strs[4].p = "◆ ひし形"; 2812| ListX_addLast( &list, &strs[5] ); strs[5].p = "○ 丸抜き"; 2813| ListX_addLast( &list, &strs[6] ); strs[6].p = "△ 三角抜き"; 2814| ListX_addLast( &list, &strs[7] ); strs[7].p = "◇ ひし形抜き"; 2815| } 2816| else { 2817| strncpy( name, "Shape of Point1", name_size ); 2818| ListX_addLast( &list, &strs[0] ); strs[0].p = "No Arrow"; 2819| ListX_addLast( &list, &strs[1] ); strs[1].p = "-> Arrow"; 2820| ListX_addLast( &list, &strs[2] ); strs[2].p = " Circle"; 2821| ListX_addLast( &list, &strs[3] ); strs[3].p = " Triangle"; 2822| ListX_addLast( &list, &strs[4] ); strs[4].p = " Diamond"; 2823| ListX_addLast( &list, &strs[5] ); strs[5].p = "O Circle(Hole)"; 2824| ListX_addLast( &list, &strs[6] ); strs[6].p = " Triangle(Hole)"; 2825| ListX_addLast( &list, &strs[7] ); strs[7].p = " Diamond(Hole)"; 2826| } 2827| sprintf( value, "%d", m_Arrow1 ); 2828| *option = &list; 2829| r = CadPrim_Select; 2830| break; 2831| case 11: 2832| ListX_init( &list ); 2833| if ( bJapanese ) { 2834| strncpy( name, "頂点2の形状", name_size ); 2835| ListX_addLast( &list, &strs[0] ); strs[0].p = "矢印なし"; 2836| ListX_addLast( &list, &strs[1] ); strs[1].p = "→ 矢印"; 2837| ListX_addLast( &list, &strs[2] ); strs[2].p = "● 丸"; 2838| ListX_addLast( &list, &strs[3] ); strs[3].p = "▲ 三角"; 2839| ListX_addLast( &list, &strs[4] ); strs[4].p = "◆ ひし形"; 2840| ListX_addLast( &list, &strs[5] ); strs[5].p = "○ 丸抜き"; 2841| ListX_addLast( &list, &strs[6] ); strs[6].p = "△ 三角抜き"; 2842| ListX_addLast( &list, &strs[7] ); strs[7].p = "◇ ひし形抜き"; 2843| } 2844| else { 2845| strncpy( name, "Shape of Point2", name_size ); 2846| ListX_addLast( &list, &strs[0] ); strs[0].p = "No Arrow"; 2847| ListX_addLast( &list, &strs[1] ); strs[1].p = "-> Arrow"; 2848| ListX_addLast( &list, &strs[2] ); strs[2].p = " Circle"; 2849| ListX_addLast( &list, &strs[3] ); strs[3].p = " Triangle"; 2850| ListX_addLast( &list, &strs[4] ); strs[4].p = " Diamond"; 2851| ListX_addLast( &list, &strs[5] ); strs[5].p = "O Circle(Hole)"; 2852| ListX_addLast( &list, &strs[6] ); strs[6].p = " Triangle(Hole)"; 2853| ListX_addLast( &list, &strs[7] ); strs[7].p = " Diamond(Hole)"; 2854| } 2855| sprintf( value, "%d", m_Arrow2 ); 2856| *option = &list; 2857| r = CadPrim_Select; 2858| break; 2859| 2860| #ifndef NDEBUG 2861| case 12: 2862| strncpy( name, "id", name_size ); 2863| sprintf( value, "%d", m_id ); 2864| break; 2865| case 13: 2866| strncpy( name, "m_Link[0]", name_size ); 2867| sprintf( value, "%d", m_Link[0].prim_id ); 2868| break; 2869| case 14: 2870| strncpy( name, "m_Link[1]", name_size ); 2871| sprintf( value, "%d", m_Link[1].prim_id ); 2872| break; 2873| case 15: 2874| strncpy( name, "m_Controler_id[0]", name_size ); 2875| sprintf( value, "%d", m_Controler_id[0] ); 2876| break; 2877| case 16: 2878| strncpy( name, "m_Controler_id[1]", name_size ); 2879| sprintf( value, "%d", m_Controler_id[1] ); 2880| break; 2881| #endif 2882| } 2883| 2884| return r; 2885|} 2886| 2887|/*********************************************************************** 2888| 3-44. <<< [Line_Corner::SetProp] プロパティの値を設定する >>> 2889|************************************************************************/ 2890|void Line_Corner::SetProp( int iProp, const char* value, const char* path ) 2891|{ 2892| switch ( iProp ) { 2893| case 0: 2894| m_Line.x1 = atoi( value ); 2895| break; 2896| case 1: 2897| m_Line.y1 = atoi( value ); 2898| break; 2899| case 2: 2900| m_Line.x2 = atoi( value ); 2901| break; 2902| case 3: 2903| m_Line.y2 = atoi( value ); 2904| break; 2905| case 4: 2906| m_CornerX = atoi( value ); 2907| break; 2908| case 5: 2909| m_CornerY = atoi( value ); 2910| break; 2911| case 6: 2912| m_Dir = atoi( value ); 2913| break; 2914| case 7: 2915| m_Width = atoi( value ); 2916| break; 2917| case 8: 2918| m_Color = StrX_getColorValue( value ); 2919| break; 2920| case 9: 2921| m_bDash = atoi( value ) != 0; 2922| break; 2923| case 10: 2924| m_Arrow1 = atoi( value ); 2925| break; 2926| case 11: 2927| m_Arrow2 = atoi( value ); 2928| break; 2929| } 2930|} 2931| 2932| 2933|/*********************************************************************** 2934| 3-45. <<< [Line_Corner::IsNeedUnicode] CadPrim::IsNeedUnicode の実装部 >>> 2935|************************************************************************/ 2936|bool Line_Corner::IsNeedUnicode() 2937|{ 2938| return false; 2939|} 2940| 2941| 2942|/*********************************************************************** 2943| 3-46. <<< [Line_Corner::GetLinkToControler] CadPrim::GetLinkToControler の実装部 >>> 2944|************************************************************************/ 2945|CadPrim* Line_Corner::GetLinkToControler( int iHandle ) 2946|{ 2947| ASSERT( iHandle == 1 || iHandle == 2 ); 2948| return m_Controler[iHandle - 1]; 2949|} 2950| 2951|/*********************************************************************** 2952| 3-47. <<< [Line_Corner::GetLinkIDToControler] CadPrim::GetLinkIDToControler の実装部 >>> 2953|************************************************************************/ 2954|int Line_Corner::GetLinkIDToControler( int iHandle ) 2955|{ 2956| ASSERT( iHandle == 1 || iHandle == 2 ); 2957| return m_Controler_id[iHandle - 1]; 2958|} 2959| 2960|/*********************************************************************** 2961| 3-48. <<< [Line_Corner::GetNumOfLinkToControler] CadPrim::GetNumOfLinkToControler の実装部 >>> 2962|************************************************************************/ 2963|int Line_Corner::GetNumOfLinkToControler() 2964|{ 2965| return 2; 2966|} 2967| 2968| 2969|/*********************************************************************** 2970| 3-49. <<< [Line_Corner::GetLinkableHandleNum] CadPrim::GetLinkableHandleNum の実装部 >>> 2971|************************************************************************/ 2972|int Line_Corner::GetLinkableHandleNum( int x, int y ) 2973|{ 2974| return 0; 2975|} 2976| 2977| 2978|/*********************************************************************** 2979| 3-50. <<< [Line_Corner::LinkToHandle] CadPrim::LinkToHandle の実装部 >>> 2980|************************************************************************/ 2981|void Line_Corner::LinkToHandle( int iHandleOfThis, CadPrim* prim, int iHandleOfPrim ) 2982|{ 2983| ASSERT( iHandleOfThis >= 1 && iHandleOfThis <= 2 ); 2984| 2985| m_Link[iHandleOfThis - 1].prim = prim; 2986| m_Link[iHandleOfThis - 1].prim_id = prim->GetID(); 2987| m_Link[iHandleOfThis - 1].iHandle = iHandleOfPrim; 2988| if ( iHandleOfThis == 1 ) { 2989| m_Link[0].x = m_Line.x1; 2990| m_Link[0].y = m_Line.y1; 2991| } 2992| else { 2993| m_Link[1].x = m_Line.x2; 2994| m_Link[1].y = m_Line.y2; 2995| } 2996| 2997| prim->LinkToControler( iHandleOfPrim, this ); 2998|} 2999| 3000| 3001|/*********************************************************************** 3002| 3-51. <<< [Line_Corner::UnlinkToHandle] CadPrim::UnlinkToHandle の実装部 >>> 3003|************************************************************************/ 3004|void Line_Corner::UnlinkToHandle( CadPrim* prim, int iHandleOfPrim, bool mutual ) 3005|{ 3006| int i; 3007| 3008| for ( i = 0; i < 2; i++ ) { 3009| if ( m_Link[i].prim == prim && m_Link[i].iHandle == iHandleOfPrim ) 3010| break; 3011| } 3012| if ( i < 2 ) { 3013| prim->UnlinkToControler( iHandleOfPrim, this ); 3014| m_Link[i].prim = NULL; 3015| m_Link[i].prim_id = 0; 3016| } 3017|} 3018| 3019| 3020|/*********************************************************************** 3021| 3-52. <<< [Line_Corner::UnlinkAll] CadPrim::UnlinkAll の実装部 >>> 3022|************************************************************************/ 3023|void Line_Corner::UnlinkAll() 3024|{ 3025| if ( m_Controler[0] != NULL ) 3026| m_Controler[0]->UnlinkToHandle( this, 1 ); 3027| if ( m_Controler[1] != NULL ) 3028| m_Controler[1]->UnlinkToHandle( this, 2 ); 3029| if ( m_Link[0].prim != NULL ) 3030| UnlinkToHandle( m_Link[0].prim, m_Link[0].iHandle ); 3031| if ( m_Link[1].prim != NULL ) 3032| UnlinkToHandle( m_Link[1].prim, m_Link[1].iHandle ); 3033|} 3034| 3035|/*********************************************************************** 3036| 3-53. <<< [Line_Corner::LinkToControler] CadPrim::LinkToControler の実装部 >>> 3037|************************************************************************/ 3038|void Line_Corner::LinkToControler( int iHandle, CadPrim* ctrl ) 3039|{ 3040| ASSERT( iHandle >= 1 ); 3041| 3042| m_Controler[ iHandle - 1 ] = ctrl; 3043| m_Controler_id[ iHandle - 1 ] = ctrl->GetID(); 3044|} 3045| 3046| 3047|/*********************************************************************** 3048| 3-54. <<< [Line_Corner::UnlinkToControler] CadPrim::UnlinkToControler の実装部 >>> 3049|************************************************************************/ 3050|void Line_Corner::UnlinkToControler( int iHandle, CadPrim* ctrl ) 3051|{ 3052| m_Controler[ iHandle - 1 ] = NULL; 3053| m_Controler_id[ iHandle - 1 ] = 0; 3054|} 3055| 3056| 3057|/*********************************************************************** 3058| 3-55. <<< [Line_Corner::AdjustLinks] CadPrim::AdjustLinks の実装部 >>> 3059|************************************************************************/ 3060|void Line_Corner::AdjustLinks( ListX* prims ) 3061|{ 3062| m_Controler[0] = Undo_Uty_getPrimPtr( prims, m_Controler_id[0] ); 3063| m_Controler[1] = Undo_Uty_getPrimPtr( prims, m_Controler_id[1] ); 3064| m_Link[0].prim = Undo_Uty_getPrimPtr( prims, m_Link[0].prim_id ); 3065| m_Link[1].prim = Undo_Uty_getPrimPtr( prims, m_Link[1].prim_id ); 3066| 3067| if ( m_Link[0].prim != NULL ) m_Link[0].prim->AdjustLinks( prims ); 3068| if ( m_Link[1].prim != NULL ) m_Link[1].prim->AdjustLinks( prims ); 3069|} 3070| 3071| 3072|/*********************************************************************** 3073| 3-56. <<< [Line_Corner::GetLines] 折れ線の座標を取得する >>> 3074|【補足】 3075|・m_LinesX, m_LinesY, m_LinesN に格納します。 3076|************************************************************************/ 3077|void Line_Corner::GetLines() 3078|{ 3079| enum { diff = 8, m=5 }; 3080| 3081| int dx1 = m_CornerX - m_Line.x1; 3082| int dx2 = m_CornerX - m_Line.x2; 3083| int dy1 = m_CornerY - m_Line.y1; 3084| int dy2 = m_CornerY - m_Line.y2; 3085| int i, n; 3086| 3087| if ( dx1 < dx2 ) { 3088| i = dx1; dx1 = dx2; dx2 = i; 3089| i = dy1; dy1 = dy2; dy2 = i; 3090| } 3091| 3092| /* 1点目:左側、最終点:右側を格納する */ 3093| n = 0; 3094| if ( m_Line.x1 < m_Line.x2 ) { 3095| m_LinesX[n] = m_Line.x1; m_LinesY[n] = m_Line.y1; 3096| m_LinesX[m] = m_Line.x2; m_LinesY[m] = m_Line.y2; 3097| m_bArrow1IsLast = false; 3098| } 3099| else { 3100| m_LinesX[n] = m_Line.x2; m_LinesY[n] = m_Line.y2; 3101| m_LinesX[m] = m_Line.x1; m_LinesY[m] = m_Line.y1; 3102| m_bArrow1IsLast = true; 3103| } 3104| n++; 3105| 3106| /* 2点目以降を格納する */ 3107| if ( dx1 <= diff ) { /* ハンドルが左にあるとき */ 3108| if ( dx1 < -diff ) /*横*/ 3109| { m_LinesX[n] = m_CornerX; m_LinesY[n] = m_LinesY[n-1]; n++; } 3110| 3111| if ( (dy1 < -diff && dy2 < -diff) || (dy1 > diff && dy2 > diff) || 3112| (-diff <= dx1 && dx1 <= diff && -diff-1 <= dx2 && dx2 <= diff ) ) { 3113| /*縦*/ m_LinesX[n] = m_LinesX[n-1]; m_LinesY[n] = m_CornerY; n++; 3114| /*横*/ m_LinesX[n] = m_LinesX[m]; m_LinesY[n] = m_CornerY; n++; 3115| /*縦*/ m_LinesX[n] = m_LinesX[m]; m_LinesY[n] = m_LinesY[m]; n++; 3116| } 3117| else { 3118| /*縦*/ m_LinesX[n] = m_LinesX[n-1]; m_LinesY[n] = m_LinesY[m]; n++; 3119| /*横*/ m_LinesX[n] = m_LinesX[m]; m_LinesY[n] = m_LinesY[m]; n++; 3120| } 3121| } 3122| 3123| else if ( dx2 < -diff ) { 3124| if ( (dy1 < -diff && dy2 < -diff) || 3125| (dy1 > diff && dy2 > diff ) ) { /* ハンドルが上または下にあるとき */ 3126| /*縦*/ m_LinesX[n] = m_LinesX[n-1]; m_LinesY[n] = m_CornerY; n++; 3127| /*横*/ m_LinesX[n] = m_LinesX[m]; m_LinesY[n] = m_CornerY; n++; 3128| /*縦*/ m_LinesX[n] = m_LinesX[m]; m_LinesY[n] = m_LinesY[m]; n++; 3129| } 3130| else { /* ハンドルが中にあるとき */ 3131| if ( m_Dir == Line_DirN ) { 3132| 3133| if ( -diff < dy2 && dy2 < diff ) /*縦*/ 3134| { m_LinesX[n] = m_LinesX[n-1]; m_LinesY[n] = m_LinesY[m]; n++; } 3135| else if ( dy1 <= -diff || diff <= dy1 ) 3136| { m_LinesX[n] = m_LinesX[n-1]; m_LinesY[n] = m_CornerY; n++; } 3137| 3138| /*横*/ m_LinesX[n] = m_LinesX[m]; m_LinesY[n] = m_LinesY[n-1]; n++; 3139| 3140| if ( dy2 <= -diff || diff <= dy2 ) /*縦*/ 3141| { m_LinesX[n] = m_LinesX[m]; m_LinesY[n] = m_LinesY[m]; n++; } 3142| } 3143| 3144| else { /* Line_DirZ */ 3145| 3146| if ( -diff < dx2 && dx2 < diff ) /*横*/ 3147| { m_LinesX[n] = m_LinesX[m]; m_LinesY[n] = m_LinesY[n-1]; n++; } 3148| else if ( dx1 <= -diff || diff <= dx1 ) 3149| { m_LinesX[n] = m_CornerX; m_LinesY[n] = m_LinesY[n-1]; n++; } 3150| 3151| /*縦*/ m_LinesX[n] = m_LinesX[n-1]; m_LinesY[n] = m_LinesY[m]; n++; 3152| 3153| if ( dx2 <= -diff || diff <= dx2 ) /*横*/ 3154| { m_LinesX[n] = m_LinesX[m]; m_LinesY[n] = m_LinesY[m]; n++; } 3155| } 3156| } 3157| } 3158| 3159| else { /* ハンドルが右にあるとき */ 3160| if ( (dy1 < -diff && dy2 < -diff) || (dy1 > diff && dy2 > diff) ) 3161| /*縦*/ { m_LinesX[n] = m_LinesX[n-1]; m_LinesY[n] = m_CornerY; n++; } 3162| 3163| if ( dx2 < diff ) /*横*/ 3164| { m_LinesX[n] = m_LinesX[m]; m_LinesY[n] = m_LinesY[n-1]; n++; } 3165| else 3166| { m_LinesX[n] = m_CornerX; m_LinesY[n] = m_LinesY[n-1]; n++; } 3167| 3168| /*縦*/ m_LinesX[n] = m_LinesX[n-1]; m_LinesY[n] = m_LinesY[m]; n++; 3169| 3170| if ( dx2 >= diff ) /*横*/ 3171| { m_LinesX[n] = m_LinesX[m]; m_LinesY[n] = m_LinesY[m]; n++; } 3172| } 3173| 3174| 3175| /* 同じ座標の頂点をカットする */ 3176| for ( i = 0; i < n-1; i++ ) { 3177| if ( m_LinesX[i] == m_LinesX[i+1] && m_LinesY[i] == m_LinesY[i+1] ) { 3178| int j; 3179| 3180| for ( j = i+1; j < n-1; j++ ) { 3181| m_LinesX[j] = m_LinesX[j+1]; m_LinesY[j] = m_LinesY[j+1]; 3182| } 3183| n--; 3184| } 3185| } 3186| 3187| m_LinesN = n; 3188|} 3189| 3190|#endif 3191| 3192|/*********************************************************************** 3193| 3-57. <<< [Line_Plus_getArrowParamType1] Type1 の矢印の描画に必要なパラメータを取得する >>> 3194|【引数】 3195| ・int x1, y1; 矢印の先端の座標 3196| ・int x2, y2; 矢印の尾の座標 3197| ・int length; 羽の長さ(12ぐらい) 3198| ・Line* leftWing; (出力)左の羽のパラメータ、x1,y1 が矢の先端 3199| ・Line* rightWing; (出力)右の羽のパラメータ、x1,y1 が矢の先端 3200|************************************************************************/ 3201|void Line_Plus_getArrowParamType1( int x1, int y1, int x2, int y2, 3202| int length, Line* leftWing, Line* rightWing ) 3203|{ 3204| int dx = x2 - x1; 3205| int dy = y2 - y1; 3206| int dlen; 3207| const double angle = 20 * 3.14 / 180; 3208| 3209| /* ラインを羽の長さにする */ 3210| dlen = (int)sqrt( dx*dx + dy*dy ); 3211| if ( dlen == 0 ) { 3212| dx = 1; dy = 0; 3213| } 3214| else { 3215| dx = dx * length / dlen; 3216| dy = dy * length / dlen; 3217| } 3218| 3219| /* 左の羽のパラメータを取得する */ 3220| leftWing->x1 = x1; 3221| leftWing->y1 = y1; 3222| leftWing->x2 = x1 + (int)( dx * cos(angle) - dy * sin(angle) ); 3223| leftWing->y2 = y1 + (int)( dx * sin(angle) + dy * cos(angle) ); 3224| 3225| /* 右回転する */ 3226| rightWing->x1 = x1; 3227| rightWing->y1 = y1; 3228| rightWing->x2 = x1 + (int)( dx * cos(angle) + dy * sin(angle) ); 3229| rightWing->y2 = y1 + (int)(-dx * sin(angle) + dy * cos(angle) ); 3230|} 3231| 3232| 3233| 3234|/*********************************************************************** 3235| 3-58. <<< [Line_Plus_getArrowParamType3] Type3(三角)の矢印の描画に必要なパラメータを取得する >>> 3236|【引数】 3237| ・int x1, y1; 矢印の先端の座標 3238| ・int x2, y2; 矢印の尾の座標 3239| ・int length; 1辺の長さ(12ぐらい) 3240| ・POINT* xy; (出力)3頂点の座標 3241|************************************************************************/ 3242|void Line_Plus_getArrowParamType3( int x1, int y1, int x2, int y2, 3243| int length, POINT* xy ) 3244|{ 3245| int dx = x2 - x1; 3246| int dy = y2 - y1; 3247| int dlen; 3248| const double angle = 30 * 3.14 / 180; 3249| 3250| /* ラインを羽の長さにする */ 3251| dlen = (int)sqrt( dx*dx + dy*dy ); 3252| if ( dlen == 0 ) { 3253| dx = 1; dy = 0; 3254| } 3255| else { 3256| dx = dx * length / dlen; 3257| dy = dy * length / dlen; 3258| } 3259| 3260| xy[0].x =x1; 3261| xy[0].y =y1; 3262| 3263| xy[1].x = x1 + (int)( dx * cos(angle) - dy * sin(angle) ); 3264| xy[1].y = y1 + (int)( dx * sin(angle) + dy * cos(angle) ); 3265| 3266| xy[2].x = x1 + (int)( dx * cos(angle) + dy * sin(angle) ); 3267| xy[2].y = y1 + (int)(-dx * sin(angle) + dy * cos(angle) ); 3268|} 3269| 3270| 3271| 3272|/*********************************************************************** 3273| 3-59. <<< [Line_Plus_getArrowParamType4] Type2(ひし形)の矢印の描画に必要なパラメータを取得する >>> 3274|【引数】 3275| ・int x1, y1; 矢印の先端の座標 3276| ・int x2, y2; 矢印の尾の座標 3277| ・int length; 1辺の長さ(12ぐらい) 3278| ・POINT* xy; (出力)4頂点の座標 3279|************************************************************************/ 3280|void Line_Plus_getArrowParamType4( int x1, int y1, int x2, int y2, 3281| int length, POINT* xy ) 3282|{ 3283| int dx = x2 - x1; 3284| int dy = y2 - y1; 3285| int dx2, dy2; 3286| int dlen; 3287| const double angle = 20 * 3.14 / 180; 3288| 3289| /* ラインを羽の長さにする */ 3290| dlen = (int)sqrt( dx*dx + dy*dy ); 3291| if ( dlen == 0 ) { 3292| dx = 1; dy = 0; 3293| dx2 = 1; dy2 = 0; 3294| } 3295| else { 3296| dx2 = (int)( 2 * dx * length * cos(angle) / dlen ); 3297| dy2 = (int)( 2 * dy * length * cos(angle) / dlen ); 3298| dx = dx * length / dlen; 3299| dy = dy * length / dlen; 3300| } 3301| 3302| xy[0].x =x1; 3303| xy[0].y =y1; 3304| 3305| xy[1].x = x1 + (int)( dx * cos(angle) - dy * sin(angle) ); 3306| xy[1].y = y1 + (int)( dx * sin(angle) + dy * cos(angle) ); 3307| 3308| xy[2].x = x1 + dx2; 3309| xy[2].y = y1 + dy2; 3310| 3311| xy[3].x = x1 + (int)( dx * cos(angle) + dy * sin(angle) ); 3312| xy[3].y = y1 + (int)(-dx * sin(angle) + dy * cos(angle) ); 3313|} 3314| 3315| 3316| 3317|