#include "screen/ScreenPlane.h" using namespace projection; /** * Constructor. * * @param pScreen Screen data. */ ScreenPlane::ScreenPlane(Screen* pScreen) : ScreenShape(pScreen) { m_width = 2.0; m_height = 2.0; m_horResolution = 4; m_vertResolution = 4; } /** * Destructor. */ ScreenPlane::~ScreenPlane() { } /** * Set width of the plane screen. * * @param width Width of the plane screen. */ void ScreenPlane::setWidth(double width) { if (m_width != width) { m_width = width; notifyRedraw(); } } /** * Set height of the plane screen. * * @param height Height of the plane screen. */ void ScreenPlane::setHeight(double height) { if (m_height != height) { m_height = height; notifyRedraw(); } } /** * Set horizontal resolution of the plane screen. * * @param resolution Horizontal resolution of the plane screen. */ void ScreenPlane::setHorResolution(unsigned int resolution) { m_horResolution = resolution; notifyRedraw(); } /** * Set vertical resolution of the plane screen. * * @param resolution Vertical resolution of the plane screen. */ void ScreenPlane::setVertResolution(unsigned int resolution) { m_vertResolution = resolution; 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 ScreenPlane::getBoundingBox(gmtl::Vec3f& min, gmtl::Vec3f& max) { min.set((float)-m_width/2.0f, (float)-m_height/2.0f, 0.0f); max.set((float)m_width/2.0f, (float)m_height/2.0f, 0.0f); } /** * Restore the screen shape from XML data. * * @param element Parent XML element of the screen shape data. */ bool ScreenPlane::initFromDOMElement(const QDomElement& element) { if (!element.isNull()) { m_width = element.attribute("width").toFloat(); m_height = element.attribute("height").toFloat(); m_horResolution = element.attribute("horResolution").toInt(); m_vertResolution = element.attribute("vertResolution").toInt(); // 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 ScreenPlane::domElement(const QString& name, QDomDocument& doc) const { QDomElement de = doc.createElement(name); de.setAttribute("name", getName()); de.setAttribute("width", m_width); de.setAttribute("height", m_height); de.setAttribute("horResolution", m_horResolution); de.setAttribute("vertResolution", m_vertResolution); 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 ScreenPlane::drawShape(bool) { double horDelta = m_width / m_horResolution; double vertDelta = m_height / m_vertResolution; for (unsigned int vertCount=0; vertCount