您现在的位置:网站首页 > 经验分享 > 鞋业CAD软件柔性内核技术:源码[15]
设计师介绍:

昵称:烦夫子
类别:界面/平面设计师
年龄:37
现所在地:北京

查看该设计师的主页>>

关注好友

统计中心

主页浏览总数:24096
总积分:89
文章数:88
作品数:70

鞋业CAD软件柔性内核技术:源码[15]

作者:烦夫子  更新时间: 2007-11-19   浏览人数:18459  评论:0  
分享到:
开放源码:
                         柔性图形内核之十五
                         Pattern
//应用于CAD/CAM图形类程序设计
//我将逐步开放数以十万记的自主版权软件源码,谢谢大家的支持!
//以后将开源的项目: CAD、工控、机械设计图、电子布线图等
 
 

// Pattern.cpp: implementation of the Pattern class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "SoftDraw.h"
#include "Pattern.h"
#include "global.h"

#include "ring.h"
#include "shape.h"
#include "symbol.h"
#include "text.h"


#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

Pattern::Pattern (const Object *p) : Object (p)
{
 name = TPattern;

 color = 0;
 visible = TRUE;

 curves = new BSplineArray (this);
 symbols = new SymbolArray (this);
 shapes = new ShapeArray (this);
 texts = new TextArray (this);
 labels=new LabelArray(this);//TZH(13)
 rings=new RingArray(this);
 
 bPlainFlag = FALSE;         //是否为朴帮样//TZH.Correct.21
 OrgNum = 0;
 m_Disply = 0;
}

Pattern::~Pattern ()
{
 delete symbols;
 delete shapes;
 delete curves;
 delete texts;
 delete rings;
 delete labels;
}


void Pattern::Draw (CDC* dc, float scale, DrawMode mode, int dispmode) const
{
 if(!visible) return;
 // 以下写绘图调用代码,调用各个图元的绘图函数实现样片的整体绘制
 
}

void Pattern::FastDraw (CDC* dc, float scale, DrawMode mode, TransformFunc f) const //TZH(38)
{
 if(!visible||num==0) return;
 
 //以下分析绘图模式,调用相关对像的绘图函数
 //curves->FastDraw(dc,scale,mode,f); ; //内线的显示
}


void Pattern::GetMinMax ()
{
 Vector minp, maxp;
    VectorRun dp;

 Object::GetMinMax ();

 rings->GetMinMax (minp, maxp);
 MinP = dp.VMin (minp, MinP);
 MaxP = dp.VMax (maxp, MaxP);

    MinP = dp.VMin (minp, MinP);
 MaxP = dp.VMax (maxp, MaxP);
}


float Pattern::GetLength()
{
 Ring *pl;
 pl = ((Ring *) data[num - 1]);//get outer ring of pattern
 return pl->GetLength();
}

// 计算样片面积
float Pattern::GetArea () const
{
 Ring *rg;
 rg = ((Ring *) data[num - 1]);           //get the outer ring of pattern
 return (rg->GetArea() / 9.29 / 10000.0); //(1:0.0929)
}

long Pattern::GetSize () const
{
 return sizeof (Pattern) + symbols->GetSize () + shapes->GetSize () +
    curves->GetSize () + texts->GetSize ()+ Object::GetSize (); 
}

Object* Pattern::GetNewObject () const
{
 return new Ring (this);
}

void Pattern::GetNotePos (Vector v[2]) const
{
 v[0] = notePos[0];
 v[1] = notePos[1];
}
void Pattern::GetNotePos(Vector &v1, Vector &v2) const
{
 v1=notePos[0] ;
 v2=notePos[1] ;
}
void Pattern::SetNotePos (Vector v[2])
{
 notePos[0] = v[0];
 notePos[1] = v[1];
}

void Pattern::SetNotePos (Vector v1, Vector v2)
{
 notePos[0] = v1;
 notePos[1] = v2;
}


Object& Pattern::operator = (const Object& aObject)//TZH.Correct.23
{
 (Object::operator = (aObject));

 Pattern *p = &((Pattern &) aObject);

 notePos[0] = p->notePos[0];
 notePos[1] = p->notePos[1];

 color = p->color;
 visible = p->visible;

 m_Disply = p->m_Disply;
 bPlainFlag=p->bPlainFlag;

 *rings=*p->rings ;

 *symbols = *p->symbols;
 *shapes = *p->shapes;
 *curves = *p->curves;
 *texts = *p->texts;

 return *this;
}

Object& Pattern::operator += (Object& aObject)
{
 ASSERT (name == aObject.name);

 Pattern *p = &((Pattern &) aObject);

 *rings+=*p->rings ;
 *symbols += *p->symbols;
 *shapes += *p->shapes;
 *texts += *p->texts;

 return (Object::operator += (aObject));
}

BOOL Pattern::operator == (const Object& aObject)
{
 Pattern *p = &((Pattern &) aObject);

 if (name != p->name ||  num != p->num )
  return FALSE;

 for (int i = 0; i < num; i++)
  if (! (*data[i] == *p->data[i])) return FALSE;

 return TRUE;
}

(目前有0人发表看法,  我要发表评论
我要评论:
  只有登录后才能评论!
评论者: 匿名游客    (立即登录 或 注册)