void NebulaMgr::drawPointer(const StelCore* core, StelPainter& sPainter)
{
	const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000);

	const QList<StelObjectP> newSelected = GETSTELMODULE(StelObjectMgr)->getSelectedObject("Nebula");
	if (!newSelected.empty())
	{
		const StelObjectP obj = newSelected[0];
		Vec3d pos=obj->getJ2000EquatorialPos(core);

		// Compute 2D pos and return if outside screen
		if (!prj->projectInPlace(pos)) return;		
		if (StelApp::getInstance().getVisionModeNight())
			sPainter.setColor(0.8f,0.0f,0.0f);
		else
			sPainter.setColor(0.4f,0.5f,0.8f);

		texPointer->bind();

		sPainter.enableTexture2d(true);
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transparency mode

		// Size on screen
		float size = obj->getAngularSize(core)*M_PI/180.*prj->getPixelPerRadAtCenter();

		size+=20.f + 10.f*std::sin(2.f * StelApp::getInstance().getTotalRunTime());
		sPainter.drawSprite2dMode(pos[0]-size/2, pos[1]-size/2, 10, 90);
		sPainter.drawSprite2dMode(pos[0]-size/2, pos[1]+size/2, 10, 0);
		sPainter.drawSprite2dMode(pos[0]+size/2, pos[1]+size/2, 10, -90);
		sPainter.drawSprite2dMode(pos[0]+size/2, pos[1]-size/2, 10, -180);
	}
}
示例#2
0
void TargetsDialog::createTargetFromSelection()
{
	if (StelApp::getInstance().getStelObjectMgr().getWasSelected()) {
		QList<StelObjectP> selectedObjects = StelApp::getInstance().getStelObjectMgr().getSelectedObject();
		QListIterator<StelObjectP> objectIterator(selectedObjects);
		StelCore* core = StelApp::getInstance().getCore();
		while (objectIterator.hasNext()) {
			StelObjectP stelObject = objectIterator.next();
			QString type = stelObject->getType();
			QString englishName = stelObject->getEnglishName();
			if (englishName == "") {
				englishName = "No Name";
			}
			float magnatude = stelObject->getVMagnitude(core);
			double angularSize = stelObject->getAngularSize(core);
			
			Vec3d pos;
			double ra, dec;
			// ra/dec in J2000
			pos = stelObject->getJ2000EquatorialPos(core);
			StelUtils::rectToSphe(&ra, &dec, pos);
			
		    QSqlField field1("name", QVariant::String);
			QSqlField field2("right_ascension", QVariant::Double);
			QSqlField field3("declination", QVariant::Double);
			QSqlField field4("target_type_id", QVariant::Int);
			QSqlField field5("magnitude", QVariant::Double);
			QSqlField field6("size", QVariant::Double);
			field1.setValue(QVariant(englishName));
			field2.setValue(QVariant(ra));
			field3.setValue(QVariant(dec));
			field4.setValue(QVariant(1));
			field5.setValue(QVariant(magnatude));
			field6.setValue(QVariant(angularSize));
			QSqlRecord newRecord = QSqlRecord();
			newRecord.append(field1);
			newRecord.append(field2);
			newRecord.append(field3);
			newRecord.append(field4);
			newRecord.append(field5);
			newRecord.append(field6);
			
			if (tableModel->insertRecord(-1, newRecord)) {
				ui->targetsListView->setCurrentIndex(tableModel->index(tableModel->rowCount() - 1, 1));
			} else {
				qWarning() << "LogBook: could not insert new target.  The error is: " << tableModel->lastError();
			}
		}
	} else {
		qDebug() << "====> Nothing selected.";
	}
}	
bool SkyLabel::draw(StelCore* core, StelPainter& sPainter)
{
	if(labelFader.getInterstate() <= 0.0)
		return false;

	Vec3d objectPos = labelObject->getJ2000EquatorialPos(core);
	Vec3d labelXY;
	sPainter.getProjector()->project(objectPos,labelXY);

	sPainter.setFont(labelFont);
			
	double xOffset(0.);
	double yOffset(0.);
	char hJustify = 'c';
	char vJustify = 'c';

	if (labelSide.toUpper().contains("N"))
	{
		yOffset = 1.0;
		vJustify = 'b'; // bottom justify text
	}
	else if (labelSide.toUpper().contains("S"))
	{
		yOffset = -1.0;
		vJustify = 't'; // top justufy text
	}

	if (labelSide.toUpper().contains("E"))
	{
		xOffset = 1.0;
		hJustify = 'l'; // right justify text
	}
	else if (labelSide.toUpper().contains("W"))
	{
		xOffset = -1.0;
		hJustify = 'r'; // left justify text
	}

	if (labelDistance >= 0.0)
	{
		xOffset *= labelDistance;
		yOffset *= labelDistance;
	}
	else
	{
		float shift = 4.f + labelObject->getAngularSize(core)*M_PI/180.*sPainter.getProjector()->getPixelPerRadAtCenter()/1.8f;
		// use the object size
		xOffset *= shift;
		yOffset *= shift;
	}

	double jxOffset(0.);
	double jyOffset(0.); 
	if (hJustify == 'r')
		jxOffset = sPainter.getFontMetrics().width(labelText);
	else if (hJustify == 'c')
		jxOffset = sPainter.getFontMetrics().width(labelText) / 2.;

	if (vJustify == 't')
		jyOffset = sPainter.getFontMetrics().height();
	else if (vJustify == 'c')
		jyOffset = sPainter.getFontMetrics().height() / 2.;

	sPainter.setColor(labelColor[0], labelColor[1], labelColor[2], labelFader.getInterstate());
	sPainter.drawText(labelXY[0]+xOffset-jxOffset, labelXY[1]+yOffset-jyOffset, labelText, 0, 0, 0, false);

	if (labelStyle == SkyLabel::Line)
	{
		sPainter.enableTexture2d(false);
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

		// screen coordinates of object
		Vec3d objXY;
		sPainter.getProjector()->project(objectPos,objXY);

		double lineEndX = labelXY[0]+xOffset;
		double lineEndY = labelXY[1]+yOffset;

		if (vJustify == 'b')
			lineEndY -= 5;
		else if (vJustify == 't')
			lineEndY += 5;
				
		if (hJustify == 'l')
			lineEndX -= 5;
		else if (hJustify == 'r')
			lineEndX += 5;
				
		sPainter.setColor(labelColor[0], labelColor[1], labelColor[2], labelFader.getInterstate());
		
		sPainter.drawLine2d(lineEndX,lineEndY,objXY[0], objXY[1]);
	}

	return true;
}
示例#4
0
bool SkyLabel::draw(StelCore* core, StelRenderer* renderer, StelProjectorP projector)
{
	if(labelFader.getInterstate() <= 0.0)
		return false;

	Vec3d objectPos = labelObject->getJ2000EquatorialPos(core);
	Vec3d labelXY;

	projector->project(objectPos, labelXY);
	renderer->setFont(labelFont);

	double xOffset(0.);
	double yOffset(0.);
	char hJustify = 'c';
	char vJustify = 'c';

	if (labelSide.toUpper().contains("N"))
	{
		yOffset = 1.0;
		vJustify = 'b'; // bottom justify text
	}
	else if (labelSide.toUpper().contains("S"))
	{
		yOffset = -1.0;
		vJustify = 't'; // top justufy text
	}

	if (labelSide.toUpper().contains("E"))
	{
		xOffset = 1.0;
		hJustify = 'l'; // right justify text
	}
	else if (labelSide.toUpper().contains("W"))
	{
		xOffset = -1.0;
		hJustify = 'r'; // left justify text
	}

	if (labelDistance >= 0.0)
	{
		xOffset *= labelDistance;
		yOffset *= labelDistance;
	}
	else
	{
		float shift = 4.0f + labelObject->getAngularSize(core) * M_PI / 180.0f *
		              projector->getPixelPerRadAtCenter() / 1.8f;
		// use the object size
		xOffset *= shift;
		yOffset *= shift;
	}

	QFontMetrics fontMetrics(labelFont);
	const float jxOffset = hJustify == 'r' ? fontMetrics.width(labelText) :
	                       hJustify == 'c' ? fontMetrics.width(labelText) * 0.5 :
	                                         0.0;
	const float jyOffset = vJustify == 't' ? fontMetrics.height() :
	                       vJustify == 'c' ? fontMetrics.height() * 0.5 :
	                                         0.0;

	renderer->setGlobalColor(labelColor[0], labelColor[1], 
	                         labelColor[2], labelFader.getInterstate());
	renderer->drawText(TextParams(labelXY[0] + xOffset - jxOffset, 
	                              labelXY[1] + yOffset - jyOffset, 
	                              labelText).useGravity());

	if (labelStyle == SkyLabel::Line)
	{
		renderer->setBlendMode(BlendMode_Alpha);

		// screen coordinates of object
		Vec3d objXY;
		projector->project(objectPos, objXY);

		double lineEndX = labelXY[0]+xOffset;
		double lineEndY = labelXY[1]+yOffset;



		if (vJustify == 'b')
			lineEndY -= 5;
		else if (vJustify == 't')
			lineEndY += 5;
				
		if (hJustify == 'l')
			lineEndX -= 5;
		else if (hJustify == 'r')
			lineEndX += 5;
				
		renderer->setGlobalColor(labelColor[0], labelColor[1], labelColor[2],
		                         labelFader.getInterstate());

		renderer->drawLine(lineEndX,lineEndY,objXY[0], objXY[1]);
	}

	return true;
}