コード例 #1
0
TYPED_TEST( ColorRGBATest, TestAdd )
{
	ColorRGBA<TypeParam> c = ColorRGBA<TypeParam>::Red();
	c.add( ColorRGBA<TypeParam>::Green() );
	EXPECT_EQ( 1.0, c.getRed() );
	EXPECT_EQ( 1.0, c.getGreen() );
	EXPECT_EQ( 0.0, c.getBlue() );
	EXPECT_EQ( 0.0, c.getAlpha() );
}
コード例 #2
0
ファイル: glRenderWindow.C プロジェクト: HeyJJ/ball
		void GLRenderWindow::renderText(float x, float y, float z, const String& text, const ColorRGBA& color, Size size)
		{
			// TEST!
			return;
			QFont font;
			font.setPixelSize(size);
			font.setBold(true);

			glDisable(GL_LIGHTING);
			glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
			QGLWidget::renderText(x, y, z, text.c_str(), font);
			glEnable(GL_LIGHTING);
		}
コード例 #3
0
ファイル: glRenderWindow.C プロジェクト: HeyJJ/ball
		void GLRenderWindow::renderText(int x, int y, const String& text, const ColorRGBA& color, Size size)
		{
			glMatrixMode(GL_PROJECTION);
			glLoadIdentity();

			glViewport(0, 0, m_fmt.getWidth(), m_fmt.getHeight());

			glMatrixMode(GL_MODELVIEW);
			glLoadIdentity();

			QFont font;
			font.setPixelSize(size);
			font.setBold(true);

			glDisable(GL_LIGHTING);
			glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
			QGLWidget::renderText(x, y, text.c_str(), font);
			glEnable(GL_LIGHTING);
		}
コード例 #4
0
ファイル: regularData2DWidget.C プロジェクト: HeyJJ/ball
		// creates a polygon from a given vector RegularData1D * data
		void RegularData2DWidget::createPlot()
		{
			// no data => no polygon
			if (data_ == 0 ||
					data_->size() == 0) 
			{
				return;
			}

			// set up the ColorMap... TODO: This should be done by a dialog or something similar
			
			ColorRGBA colorList[3];
			ColorMap color_table_;  
			colorList[0] = ColorRGBA(1.,0.,0.,1.);
			colorList[1] = ColorRGBA(0.,1.,0.,1.);
			colorList[2] = ColorRGBA(0.,0.,1.,1.);

			color_table_.setBaseColors(colorList, 3);
			color_table_.setNumberOfColors(100);
			
			// determine the minimal and maximal values in data_
			float min = (*data_)[0];
			float max = (*data_)[0];

			for (Position i=1; i < (*data_).size(); i++)
			{
				if      ((*data_)[i] < min) min = (*data_)[i];
				else if ((*data_)[i] > max) max = (*data_)[i];
			}			
			color_table_.setRange(min, max);
			color_table_.createMap();
			
			//maximal number of Lines and Columns
			Size max_x = (*data_).getSize().x;
			Size max_y = (*data_).getSize().y;

			// Draw the points
			QPixmap pixmap;								
			pixmap.resize(max_x, max_y);
			pixmap.fill();           			// delete the old picture
			QPainter paint;     
			paint.begin(&pixmap);         // set the Painter 

			try
			{
				QColor pCol;        
				for (Position y=0; y< max_y; y++) 
				{
					for (Position x=0; x< max_x; x++) 
					{
						ColorRGBA mapcolor = color_table_.map(data_->getData(x + y * max_x));
						pCol = QColor(mapcolor.getRed(), mapcolor.getGreen(), mapcolor.getBlue());
						paint.setPen(pCol);
						paint.drawPoint(x, y);
					}
				}
			}
			catch(...)
			{
				setStatusbarText("Error: Point in dataset out of grid!");
				Log.error() << "Error: Point in dataset out of grid!" << std::endl;
				return;
			}

			paint.end();

			//put the pixmapItem into objects
			PixmapItem* pixItem = new PixmapItem(&canvas_, pixmap);
			pixItem->show();
			objects_.push_back(dynamic_cast<Q3CanvasItem*> (pixItem)); 

			// resize the canvas to fit the data
			canvas_.resize(max_x, max_y);
		}