⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 graphfun.h

📁 股票控件源代码
💻 H
字号:
#include "as_position.hxx"
#include "as_transf.hxx"
#include "as_matrix.hxx"
#include "as_unitvec.hxx"
#include "as_vector.hxx"
///////////////////////////////////////////////////////////
//绘图函数所用到的宏
//一般用于DRAW()函数中
///////////////////////////////////////////////////////////

#define SP_BEGIN_DRAW(dc,line_style,line_width,line_color)			\
		{ \
          CPen  macro_new_pen(line_style, line_width, line_color);\
    	  CPen* macro_old_pen = dc->SelectObject( & macro_new_pen );\

#define SP_END_DRAW(dc)						\
		  dc->SelectObject( macro_old_pen );	\
		  macro_new_pen.DeleteObject();\
		}\

//高亮要用到的宏
#define SP_BEGIN_HIGHLIGHT(dc,line_style,line_width,line_color)  \
	{\
	int old_rop = dc->SetROP2(R2_NOTXORPEN);\
	int highlight_color = ( ~0x0000ff ^ line_color) & 0x00ffffff;\
	SP_BEGIN_DRAW(dc,line_style,line_width,highlight_color) \

#define SP_END_HIGHLIGHT(dc)  \
	SP_END_DRAW(dc) \
	dc->SetROP2(old_rop);\
	}\

//橡皮条函数用到的宏


#define BEGIN_FILL(dc,color,bFill)			\
		{\
    CBrush brush;\
    LOGBRUSH logbru;\
	logbru.lbHatch=HS_CROSS; \
    logbru.lbColor=color;	\
    if(bFill)	\
	    logbru.lbStyle=BS_SOLID; \
	else\
	    logbru.lbStyle=BS_NULL;\
	CBrush *pOld=dc->SelectObject(&brush);\

#define END_FILL(dc)					\
		dc->SelectObject( pOld );\
		brush.DeleteObject();\
		}\

//填充用到得宏
#define BEGIN_SET_BRUSH(dc,color)			\
		{ CBrush  macro_new_brush( color );	\
		  CBrush* macro_old_brush = dc->SelectObject( & macro_new_brush );

#define END_SET_BRUSH(dc)					\
		dc->SelectObject( macro_old_brush );\
		}

#define BEGIN_SET_ROP2(dc,value)			\
		{int old_rop2 = dc->SetROP2(value);
#define END_SET_ROP2(dc)					\
		dc->SetROP2(old_rop2);}

#define BEGIN_SET_CPEN(dc,line_style,line_width,line_color)			\
		{ CPen  macro_new_pen(line_style, line_width, line_color);	\
		  CPen* macro_old_pen = dc->SelectObject( & macro_new_pen );

#define END_SET_CPEN(dc)						\
		  dc->SelectObject( macro_old_pen );	\
		}
CString GetCurModulePath();
position proj_pt_to_line(const position& pt,const position& line_pt,const unit_vector& line_dir);
double distance_to_point(const position pt1,const position pt2);
BOOL pick_edge(position&	pe,	position &ret_pos,double &dist);
BOOL closest_points(    // returns TRUE if the lines are not parallel
    const position& p1,    // root position on first line
    const unit_vector& v1, // direction of first line
    const position& p2,    // root position on second line
    const unit_vector& v2, // direction of second line
    double& t1,            // parameter of closest position on first line
    position& pt1,         // position on first line closest to second line
    double& t2,            // parameter of closest position on second line
    position& pt2          // position on second line closest to first line
    );
// Intersect a line with a circle
// Returns the number of intersections (0, 1 or 2)
int intersect_line_circle(
    const position& line_pt,     // position on line
    const unit_vector& line_dir, // direction of line
    const position& center,      // center of circle
    const unit_vector& normal,   // circle normal
    double radius,               // circle radius
    position *intpts           // intersection positions
    );
double distance_to_line(
    const position& pt,         // position to test
    const position& line_pt,    // position on line
    const unit_vector& line_dir // direction of line
    );
double angle_between(      // returns the angle in radians
     const unit_vector& v1, // vector 1
     const unit_vector& v2, // vector 2
     const unit_vector& z   // normal to plane in which to measure angle
    );

// Find the angle between two vectors in the range 0 <= angle < 2pi
double angle_between(    // returns the angle in radians
    const vector& v1,    // vector 1
    const vector& v2,    // vector 2
    const unit_vector& z // normal to plane in which to measure angle
    );
BOOL
is_equal(
    double n1,
    double n2
    );

//----------------------------------------------------------------------
// purpose---
//    determine if two positions are equal (within resabs)
//----------------------------------------------------------------------
BOOL
is_equal(                 // returns true if close within tolerance
    const position& p1,   // first point
    const position& p2    // second point
    );

BOOL
is_equal(             // returns true if close within tolerance
	const vector& v1,
	const vector& v2
    );


//----------------------------------------------------------------------
// purpose---
//    determine if two unit vectors are equal
//----------------------------------------------------------------------
BOOL
is_equal(                  // returns true if close within tolerance
	const unit_vector& v1,
	const unit_vector& v2
    );

BOOL
are_parallel(
    const unit_vector& v1, // first vector
    const unit_vector& v2, // second vector
    logical same_dir       // means they must be in same direction also
    );
BOOL are_parallel(
    const vector& v1, // first vector
    const vector& v2, // second vector
    logical same_dir);

BOOL are_perpendicular(
    const unit_vector& v1, // First vector
    const unit_vector& v2 // second vector
    );
BOOL are_perpendicular(
    const vector& v1, // First vector
    const vector& v2 // second vector
    );
BOOL is_zero(double n);
BOOL is_zero(const position& p);
BOOL is_zero(const vector& v);
BOOL is_zero(const unit_vector& v);
BOOL is_zero_mch(double n);
BOOL is_zero_nor(double n);
BOOL is_positive(double n);
BOOL is_negative(
    double n);

BOOL is_less_than(
    double n1,
    double n2);
BOOL is_greater_than(
    double n1,
    double n2);
double get_resabs();
double get_resnor();
double get_resfit();
double get_resmch();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -