#include "screen/ScreenDome.h" using namespace projection; using namespace gmtl; /** * Constructor. * * @param pScreen Screen data. */ ScreenDome::ScreenDome(Screen* pScreen) : ScreenShape(pScreen) { m_radius = 1.0; m_elevResolution = 16; m_azimResolution = 16; m_subdiv = 4; m_bFullDome = false; } /** * Destructor. */ ScreenDome::~ScreenDome() { } /** * Set radius of the dome screen. * * @param radius Radius of the dome screen. */ void ScreenDome::setRadius(double radius) { if (m_radius != radius) { m_radius = radius; notifyRedraw(); } } /** * Set elevation resolution of the dome screen. * * @param resolution Elevation resolution of the dome screen. */ void ScreenDome::setElevResolution(unsigned int resolution) { m_elevResolution = resolution; notifyRedraw(); } /** * Set azimuth resolution of the dome screen. * * @param resolution Azimuth resolution of the dome screen. */ void ScreenDome::setAzimResolution(unsigned int resolution) { m_azimResolution = resolution; notifyRedraw(); } /** * Retrieve azimuth resolution of the dome screen. * * @return Azimuth resolution of the dome screen. */ void ScreenDome::setSubdivision(unsigned int subdiv) { m_subdiv = subdiv; notifyRedraw(); } /** * Select full dome or half dome. * * @param bFullDome True to select a full dome, False to select a half dome. */ void ScreenDome::setFullDome(bool bFullDome) { m_bFullDome = bFullDome; notifyRedraw(); } /** * Retrieve bounding box of the screen shape. * * @param min One corner of the screen shape. * @param max Another corner of the screen shape. */ void ScreenDome::getBoundingBox(gmtl::Vec3f& min, gmtl::Vec3f& max) { min.set(-m_radius, -m_radius, 0.0); max.set(m_radius, m_radius, m_radius); } /** * Restore the screen shape from XML data. * * @param element Parent XML element of the screen shape data. */ bool ScreenDome::initFromDOMElement(const QDomElement& element) { // don't notify redrawing by each restoring step if (!element.isNull()) { m_radius = element.attribute("radius").toFloat(); m_elevResolution = element.attribute("elevResolution").toInt(); m_azimResolution = element.attribute("azimResolution").toInt(); m_subdiv = element.attribute("subdivision").toInt(); m_bFullDome= element.attribute("fullDome")=="true"; // if change notifyRedraw(); } return true; // todo: secure this function and return false on any critical error } /** * Store the current screen shape as XML data. * * @param name XML node name of the data. * @param doc XML document to store the data. * @return Current screen shape data as XML data. */ QDomElement ScreenDome::domElement(const QString& name, QDomDocument& doc) const { QDomElement de = doc.createElement(name); de.setAttribute("name", getName()); de.setAttribute("radius", m_radius); de.setAttribute("elevResolution", m_elevResolution); de.setAttribute("azimResolution", m_azimResolution); de.setAttribute("subdivision", m_subdiv); de.setAttribute("fullDome", m_bFullDome?"true":"false"); return de; } /** * Draw the shape model in inherited class. * * @param bFrame True to draw a wire frame mesh. False to draw as a polygon model. */ void ScreenDome::drawShape(bool bFrame) { if (!bFrame) { // draw as a polygon model double azimDelta = Math::PI / m_azimResolution / m_subdiv; double elevDelta = Math::PI / 2.0 / m_elevResolution / m_subdiv; if (m_bFullDome) azimDelta *= 2.0; for (unsigned int elevCount=0; elevCount