graphicscontext.cpp

来自「这是VCF框架的代码」· C++ 代码 · 共 1,799 行 · 第 1/4 页

CPP
1,799
字号
	path.concat_path( arc3 );	path.line_to( x1, y1 + cornerArcHeight/2.0 );	agg::arc arc4(x1 + cornerArcWidth/2.0,		y1 + cornerArcHeight/2.0,		cornerArcWidth/2.0, cornerArcHeight/2.0,		Math::degreesToRadians(180), Math::degreesToRadians(270));	path.concat_path( arc4 );	//agg::path_storage::const_iterator it = path.begin();	for (size_t i=0;i<path.total_vertices();i++ ) {			double vert_x, vert_y;		path.vertex( i, &vert_x, &vert_y );		Point pt;		pt.x_ = vert_x * (transform[Matrix2D::mei00]) +							vert_y * (transform[Matrix2D::mei10]) +								(transform[Matrix2D::mei20]);		pt.y_ = vert_x * (transform[Matrix2D::mei01]) +							vert_y * (transform[Matrix2D::mei11]) +								(transform[Matrix2D::mei21]);		pts.push_back( pt );	}}void GraphicsContext::buildEllipse( double x1, double y1, double x2, double y2,							std::vector<Point>& pts, const Matrix2D& transform ){	agg::path_storage path;	agg::ellipse ellipseShape( x1 + ((x2-x1)/2.0), y1 + ((y2-y1)/2.0),								abs(static_cast<long>(x2-x1)), abs(static_cast<long>(y2-y1)), 100 );	path.concat_path( ellipseShape );	for (size_t i=0;i<path.total_vertices();i++ ) {		double vert_x, vert_y;		path.vertex( i, &vert_x, &vert_y );		Point pt;		pt.x_ = vert_x * (transform[Matrix2D::mei00]) +							vert_y * (transform[Matrix2D::mei10]) +								(transform[Matrix2D::mei20]);		pt.y_ = vert_x * (transform[Matrix2D::mei01]) +							vert_y * (transform[Matrix2D::mei11]) +								(transform[Matrix2D::mei21]);		pts.push_back( pt );	}	pts.back() = pts[0];}int GraphicsContext::saveState(){	GraphicsState* newState = new GraphicsState(*stateCollection_.back());	stateCollection_.push_back( newState );	graphicsStateIndex_ = stateCollection_.size() - 1;	currentGraphicsState_ = stateCollection_[graphicsStateIndex_];	return graphicsStateIndex_;}void GraphicsContext::restoreState( int state ){	VCF_ASSERT( state < (int)stateCollection_.size() );	VCF_ASSERT( state >= 0 );	if ( (stateCollection_.size() - state) > 0 ) {		for ( size_t i=state;i<stateCollection_.size();i++ ) {			delete stateCollection_[i];		}		stateCollection_.erase( stateCollection_.begin() + state,								stateCollection_.end() );	}	graphicsStateIndex_ = maxVal<>(0,(state - 1));	currentGraphicsState_ = stateCollection_[graphicsStateIndex_];}bool GraphicsContext::isDefaultTransform(){	return (currentGraphicsState_->rotation_ == 0.0) &&			(currentGraphicsState_->translateX_ == 0.0) &&			(currentGraphicsState_->translateY_ == 0.0) &&			(currentGraphicsState_->shearX_ == 0.0) &&			(currentGraphicsState_->shearY_ == 0.0) &&			(currentGraphicsState_->scaleX_ == 1.0) &&			(currentGraphicsState_->scaleY_ == 1.0);}void GraphicsContext::makeDefaultTransform(){	currentGraphicsState_->rotation_ = 0.0;	currentGraphicsState_->translateX_ = 0.0;	currentGraphicsState_->translateY_ = 0.0;	currentGraphicsState_->shearX_ = 0.0;	currentGraphicsState_->shearY_ = 0.0;	currentGraphicsState_->scaleX_ = 1.0;	currentGraphicsState_->scaleY_ = 1.0;	currentGraphicsState_->compositeMatrix();}double GraphicsContext::getRotation(){	return currentGraphicsState_->rotation_;}double GraphicsContext::getTranslationX(){	return currentGraphicsState_->translateX_;}double GraphicsContext::getTranslationY(){	return currentGraphicsState_->translateY_;}double GraphicsContext::getShearX(){	return currentGraphicsState_->shearX_;}double GraphicsContext::getShearY(){	return currentGraphicsState_->shearY_;}double GraphicsContext::getScaleX(){	return currentGraphicsState_->scaleX_;}double GraphicsContext::getScaleY(){	return currentGraphicsState_->scaleY_;}bool GraphicsContext::isAntiAliasingOn(){	return contextPeer_->isAntiAliasingOn();}void GraphicsContext::setAntiAliasingOn( bool antiAliasingOn ){	contextPeer_->setAntiAliasingOn( antiAliasingOn );}};	// namespace VCF/***CVS Log info*$Log$*Revision 1.7  2006/04/07 02:35:41  ddiego*initial checkin of merge from 0.6.9 dev branch.**Revision 1.6.2.8  2006/03/04 02:35:48  ddiego*upgraded agg from 2.2 to the latest 2.4 version.**Revision 1.6.2.7  2006/03/01 04:34:57  ddiego*fixed tab display to use themes api.**Revision 1.6.2.6  2006/02/21 04:32:51  ddiego*comitting moer changes to theme code, progress bars, sliders and tab pages.**Revision 1.6.2.5  2005/11/27 23:55:45  ddiego*more osx updates.**Revision 1.6.2.4  2005/11/21 04:00:51  ddiego*more osx updates.**Revision 1.6.2.3  2005/11/10 02:02:39  ddiego*updated the osx build so that it*compiles again on xcode 1.5. this applies to the foundationkit and graphicskit.**Revision 1.6.2.2  2005/10/17 01:36:34  ddiego*some more under the hood image stuff. updated agg.**Revision 1.6.2.1  2005/09/03 14:03:53  ddiego*added a package manager to support package info instances, and*fixed feature request 1278069 - Background color of the TableControl cells.**Revision 1.6  2005/07/09 23:05:58  ddiego*added missing gtk files**Revision 1.5  2005/01/02 03:04:25  ddiego*merged over some of the changes from the dev branch because they're important resoource loading bug fixes. Also fixes a few other bugs as well.**Revision 1.4.2.3  2005/06/26 01:27:53  marcelloptr*added images to a PushButton**Revision 1.4.2.2  2005/04/25 00:11:59  ddiego*added more advanced text support. fixed some memory leaks. fixed some other miscellaneous things as well.**Revision 1.4.2.1  2004/12/19 04:05:03  ddiego*made modifications to methods that return a handle type. Introduced*a new typedef for handles, that is a pointer, as opposed to a 32bit int,*which was causing a problem for 64bit compiles.**Revision 1.4  2004/12/01 04:31:42  ddiego*merged over devmain-0-6-6 code. Marcello did a kick ass job*of fixing a nasty bug (1074768VCF application slows down modal dialogs.)*that he found. Many, many thanks for this Marcello.**Revision 1.3  2004/08/13 18:43:20  ddiego*fixed missing roundrect functionality, and incorrect value in vc70/71 projects**Revision 1.2.2.14  2004/11/07 19:32:20  marcelloptr*more documentation**Revision 1.2.2.13  2004/10/27 03:12:18  ddiego*integrated chrisk changes**Revision 1.2.2.12  2004/10/04 15:50:49  kiklop74*Added explicit cast to avoid ambiquity on BCB6**Revision 1.2.2.11  2004/09/09 03:09:26  marcelloptr*minor change for style**Revision 1.2.2.10  2004/09/06 04:40:43  ddiego*added font rotation back in, this time with support for matching*the graphic contexts current transform.**Revision 1.2.2.9  2004/09/06 03:33:21  ddiego*updated the graphic context code to support image transforms.**Revision 1.2.2.8  2004/09/03 04:05:46  ddiego*fixes to add matrix transform support for images.**Revision 1.2.2.7  2004/09/01 03:50:39  ddiego*fixed font drawing bug that tinkham pointed out.**Revision 1.2.2.6  2004/08/31 21:12:07  ddiego*graphice save and restore state**Revision 1.2.2.5  2004/08/31 10:24:15  marcelloptr*project changed postfix operator into prefix where not necessary so to eliminate agg warning**Revision 1.2.2.4  2004/08/31 04:12:13  ddiego*cleaned up the GraphicsContext class - made more pervasive use*of transformation matrix. Added common print dialog class. Fleshed out*printing example more.**Revision 1.2.2.3  2004/08/26 01:44:40  ddiego*fixed font pix size bug that handled non true type fonts poorly.**Revision 1.2.2.2  2004/08/24 04:29:58  ddiego*more printing work, still not yet integrated.**Revision 1.2.2.1  2004/08/19 03:22:54  ddiego*updates so new system tray code compiles**Revision 1.3  2004/08/13 18:43:20  ddiego*fixed missing roundrect functionality, and incorrect value in vc70/71 projects**Revision 1.2  2004/08/07 02:49:17  ddiego*merged in the devmain-0-6-5 branch to stable**Revision 1.1.2.3  2004/07/09 03:39:30  ddiego*merged in changes from the OSX branch for new theming API. Added*support for controlling the use of locale translated strings in components.**Revision 1.1.2.2.2.4  2004/06/27 18:19:16  ddiego*more osx updates**Revision 1.1.2.2.2.3  2004/06/20 00:36:11  ddiego*finished the new theme API updates**Revision 1.1.2.2.2.2  2004/06/16 05:18:56  ddiego*further updates to OSX theme compliant drawing code**Revision 1.1.2.2.2.1  2004/06/15 04:04:38  ddiego*revamped osx theme drawing API**Revision 1.1.2.2  2004/04/29 04:10:27  marcelloptr*reformatting of source files: macros and csvlog and copyright sections**Revision 1.1.2.1  2004/04/28 03:40:31  ddiego*migration towards new directory structure**Revision 1.23  2004/04/03 15:48:46  ddiego*Merged over code from the 0-6-3 branch.**Revision 1.22.2.1  2004/02/21 03:27:09  ddiego*updates for OSX porting**Revision 1.22  2003/12/18 05:16:01  ddiego*merge from devmain-0-6-2 branch into the stable branch**Revision 1.21.2.1  2003/10/28 04:06:12  ddiego*updated the GraphicsContext and ContextPeer classes to support*slider control drawing. adjusted the Slider control accordingly.*Also changed some of the GraphicsKit headers to conform to the*current header style.**Revision 1.21  2003/08/09 02:56:45  ddiego*merge over from the devmain-0-6-1 branch*Changes*Features:*-Added additional implementation to better support the MVC architecture in*the VCF**-Added a Document/View architecure that is similar to MFC's or NextSteps's*Doc/View architectures**-Integrated the Anti Grain Graphics library into the GraphicsKit. There is*now basic support for it in terms of drawing vector shapes*(fills and strokes). Image support will come in the next release**-Added several documented graphics tutorials**Bugfixes:**[ 775744 ] wrong buttons on a dialog*[ 585239 ] Painting weirdness in a modal dialog ?*[ 585238 ] Modal dialog which makes a modal Dialog*[ 509004 ] Opening a modal Dialog causes flicker*[ 524878 ] onDropped not called for MLTcontrol**Plus an issue with some focus and getting the right popup window to activate*has also been fixed**Revision 1.20.2.8  2003/08/08 03:21:36  ddiego*got rid of some miscellaneous graphics files**Revision 1.20.2.7  2003/07/28 23:49:58  ddiego*check in of the weekend's work from July 25*learned how to use agg image renedering, now have to integrate it into the*GraphicsKit - alos enabled setting a viewable bounds that sets the agg cliprect*as well, useful for later optimizations**Revision 1.20.2.6  2003/07/24 04:10:44  ddiego*added fixes for the following tasks:*Task #82279 ApplicationKit: add static methods to singleton objects*Task #82277 FoundationKit: add static methods to singleton objects*this required a bunch of changes in terms of getting rid of older style code**Revision 1.20.2.5  2003/07/07 03:52:08  ddiego*added further osx porting code, primarily to the GraphicsKit - hey we can*draw lines ! Woot!**Revision 1.20.2.4  2003/06/20 04:36:59  ddiego*further AGG integration*moved files over to renamed directories**Revision 1.20.2.3  2003/06/17 03:54:25  ddiego*further agg integration - took out the getImage/putImage from GraphicsContext -*this was too slow. now have an alternate solution that seems to work OK**Revision 1.20.2.2  2003/06/16 03:09:39  ddiego*beginning to add support for AGG into the VCF GraphicsKit*added some missing files*added some changes to the new version of xmake**Revision 1.20.2.1  2003/06/05 03:48:54  ddiego*added a way to get part of a graphics context into an image - no*implementation yet.**Revision 1.20  2003/05/17 20:37:21  ddiego*this is the checkin for the 0.6.1 release - represents the merge over from*the devmain-0-6-0 branch plus a few minor bug fixes**Revision 1.19.2.5  2003/05/14 03:04:29  ddiego*fixed some bugs caused by some of the changes in the graphics kit that I made*yesterday. All is well now.**Revision 1.19.2.4  2003/05/13 03:57:13  ddiego*cleaned up the GraphicsKit, got rid of some old crap files, cleaned*up the ContextPeer so that tehre are fewer methods to implement, and*moved the repetitive fillPath and strokePath code that was copied into*all the context peers back into the GraphicsContext where it belongs**Revision 1.19.2.3  2003/04/17 04:29:50  ddiego*updated scintilla, added gtk support for the application kit, with stubs*for the basic peers.**Revision 1.19.2.2  2003/03/23 03:23:55  marcelloptr*3 empty lines at the end of the files**Revision 1.19.2.1  2003/03/12 03:12:01  ddiego*switched all member variable that used the "m_"<name> prefix to* <name>"_" suffix nameing standard.*Also changed all vcf builder files to accomadate this.*Changes were made to the Stream classes to NOT multiple inheritance and to*be a little more correct. Changes include breaking the FileStream into two*distinct classes, one for input and one for output.**Revision 1.19  2003/02/26 04:30:46  ddiego*merge of code in the devmain-0-5-9 branch into the current tree.*most additions are in the area of the current linux port, but the major*addition to this release is the addition of a Condition class (currently*still under development) and the change over to using the Delegate class*exclusively from the older event handler macros.**Revision 1.18.2.4  2003/02/20 02:46:02  ddiego*added in the base files for supporting a GTK peer implementation. Core parts*of the GTKContext work (basic line primitives), and working on the GTKImage*class.**Revision 1.18.2.3  2002/12/31 07:02:17  ddiego*trying to track issues with parenting in X. Made some fixes in the Color class*and the ContextPeer class to work in gcc/X**Revision 1.18.2.2  2002/12/28 21:51:19  marcelloptr*Fixes and improvements for WM_COPYDATA, Point, Rect, Size, GraphicsContext and StringUtils**Revision 1.18.2.1  2002/12/27 23:04:47  marcelloptr*Improved macros for automatic import/export of libraries. - Warning fixes. - Other Minor Changes.**Revision 1.18  2002/11/18 00:46:09  ddiego*this is the merge over of all the bug fixes and features (mostly*VCF Builder stuff) from the devmain-0-5-8 branch**Revision 1.17.10.2  2002/09/30 21:08:18  ddiego*piddling stuff**Revision 1.17.10.1  2002/09/27 23:38:35  ddiego*added support for geting various layout information*added support for drawing various graphics UI primitives like scroll buttons*tabs, tab pages, etc, partially to have this support in place for use*in MacOSX.*Also added scrolling buttons to TabbedPages, this fixes task 56652 in the*ApplicationKit list**Revision 1.17  2002/05/09 03:10:44  ddiego*merged over code from development branch devmain-0-5-1a into the main CVS trunk**Revision 1.16.4.1  2002/04/03 19:37:17  zzack*include style changed**Revision 1.16  2002/01/24 01:46:49  ddiego*added a cvs "log" comment to the top of all files in vcf/src and vcf/include*to facilitate change tracking**/

⌨️ 快捷键说明

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