昵称:烦夫子
类别:界面/平面设计师
年龄:38
现所在地:北京
主页浏览总数:24255
总积分:89
文章数:88
作品数:70
// 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;
}