guiWire* GUICircuit::setWireConnection(long wid, long gid, string connection, bool openMode) { if(gateList.find(gid) == gateList.end()) return NULL; // error: gate not found createWire(wid); // do we need to init the wire first? if not then no effect. wireList[wid]->setID(wid); wireList[wid]->addConnection(gateList[gid], connection, openMode); gateList[gid]->addConnection(connection, wireList[wid]); return wireList[wid]; }
////////////////////////////////////////////////////////////////////// // OpenGL Functions ////////////////////////////////////////////////////////////////////// void GLC_Arrow::glDraw(const GLC_RenderProperties& renderProperties) { if (m_WireData.isEmpty()) { createWire(); } m_WireData.glDraw(renderProperties, GL_LINE_STRIP); }
////////////////////////////////////////////////////////////////////// // Get Functions ////////////////////////////////////////////////////////////////////// const GLC_BoundingBox& GLC_Arrow::boundingBox() { if (NULL == m_pBoundingBox) { m_pBoundingBox= new GLC_BoundingBox(); if (m_WireData.isEmpty()) createWire(); m_pBoundingBox->combine(m_WireData.boundingBox()); } return *m_pBoundingBox; }
// Create the box mesh void GLC_Box::createMeshAndWire() { Q_ASSERT(GLC_Mesh::isEmpty()); createWire(); const GLfloat lgX= static_cast<const GLfloat>(m_dLgX / 2.0); const GLfloat lgY= static_cast<const GLfloat>(m_dLgY / 2.0); const GLfloat lgZ= static_cast<const GLfloat>(m_dLgZ / 2.0); GLfloatVector verticeVector; GLfloatVector normalsVector; GLfloatVector texelVector; // Face 1 verticeVector << -lgX; verticeVector << -lgY; verticeVector << lgZ; normalsVector << 0.0f; normalsVector << 0.0f; normalsVector << 1.0f; texelVector << 0.0f; texelVector << 0.0f; verticeVector << lgX; verticeVector << -lgY; verticeVector << lgZ; normalsVector << 0.0f; normalsVector << 0.0f; normalsVector << 1.0f; texelVector << 1.0f; texelVector << 0.0f; verticeVector << lgX; verticeVector << lgY; verticeVector << lgZ; normalsVector << 0.0f; normalsVector << 0.0f; normalsVector << 1.0f; texelVector << 1.0f; texelVector << 1.0f; verticeVector << -lgX; verticeVector << lgY; verticeVector << lgZ; normalsVector << 0.0f; normalsVector << 0.0f; normalsVector << 1.0f; texelVector << 0.0f; texelVector << 1.0f; // Face 2 verticeVector << lgX; verticeVector << -lgY; verticeVector << lgZ; normalsVector << 1.0f; normalsVector << 0.0f; normalsVector << 0.0f; texelVector << 0.0f; texelVector << 0.0f; verticeVector << lgX; verticeVector << -lgY; verticeVector << -lgZ; normalsVector << 1.0f; normalsVector << 0.0f; normalsVector << 0.0f; texelVector << 1.0f; texelVector << 0.0f; verticeVector << lgX; verticeVector << lgY; verticeVector << -lgZ; normalsVector << 1.0f; normalsVector << 0.0f; normalsVector << 0.0f; texelVector << 1.0f; texelVector << 1.0f; verticeVector << lgX; verticeVector << lgY; verticeVector << lgZ; normalsVector << 1.0f; normalsVector << 0.0f; normalsVector << 0.0f; texelVector << 0.0f; texelVector << 1.0f; // Face 3 verticeVector << -lgX; verticeVector << -lgY; verticeVector << -lgZ; normalsVector << -1.0f; normalsVector << 0.0f; normalsVector << 0.0f; texelVector << 0.0f; texelVector << 0.0f; verticeVector << -lgX; verticeVector << -lgY; verticeVector << lgZ; normalsVector << -1.0f; normalsVector << 0.0f; normalsVector << 0.0f; texelVector << 1.0f; texelVector << 0.0f; verticeVector << -lgX; verticeVector << lgY; verticeVector << lgZ; normalsVector << -1.0f; normalsVector << 0.0f; normalsVector << 0.0f; texelVector << 1.0f; texelVector << 1.0f; verticeVector << -lgX; verticeVector << lgY; verticeVector << -lgZ; normalsVector << -1.0f; normalsVector << 0.0f; normalsVector << 0.0f; texelVector << 0.0f; texelVector << 1.0f; // Face 4 verticeVector << lgX; verticeVector << -lgY; verticeVector << -lgZ; normalsVector << 0.0f; normalsVector << 0.0f; normalsVector << -1.0f; texelVector << 0.0f; texelVector << 0.0f; verticeVector << -lgX; verticeVector << -lgY; verticeVector << -lgZ; normalsVector << 0.0f; normalsVector << 0.0f; normalsVector << -1.0f; texelVector << 1.0f; texelVector << 0.0f; verticeVector << -lgX; verticeVector << lgY; verticeVector << -lgZ; normalsVector << 0.0f; normalsVector << 0.0f; normalsVector << -1.0f; texelVector << 1.0f; texelVector << 1.0f; verticeVector << lgX; verticeVector << lgY; verticeVector << -lgZ; normalsVector << 0.0f; normalsVector << 0.0f; normalsVector << -1.0f; texelVector << 0.0f; texelVector << 1.0f; // Face 5 verticeVector << -lgX; verticeVector << lgY; verticeVector << lgZ; normalsVector << 0.0f; normalsVector << 1.0f; normalsVector << 0.0f; texelVector << 0.0f; texelVector << 0.0f; verticeVector << lgX; verticeVector << lgY; verticeVector << lgZ; normalsVector << 0.0f; normalsVector << 1.0f; normalsVector << 0.0f; texelVector << 1.0f; texelVector << 0.0f; verticeVector << lgX; verticeVector << lgY; verticeVector << -lgZ; normalsVector << 0.0f; normalsVector << 1.0f; normalsVector << 0.0f; texelVector << 1.0f; texelVector << 1.0f; verticeVector << -lgX; verticeVector << lgY; verticeVector << -lgZ; normalsVector << 0.0f; normalsVector << 1.0f; normalsVector << 0.0f; texelVector << 0.0f; texelVector << 1.0f; // Face 6 verticeVector << -lgX; verticeVector << -lgY; verticeVector << -lgZ; normalsVector << 0.0f; normalsVector << -1.0f; normalsVector << 0.0f; texelVector << 0.0f; texelVector << 0.0f; verticeVector << lgX; verticeVector << -lgY; verticeVector << -lgZ; normalsVector << 0.0f; normalsVector << -1.0f; normalsVector << 0.0f; texelVector << 1.0f; texelVector << 0.0f; verticeVector << lgX; verticeVector << -lgY; verticeVector << lgZ; normalsVector << 0.0f; normalsVector << -1.0f; normalsVector << 0.0f; texelVector << 1.0f; texelVector << 1.0f; verticeVector << -lgX; verticeVector << -lgY; verticeVector << lgZ; normalsVector << 0.0f; normalsVector << -1.0f; normalsVector << 0.0f; texelVector << 0.0f; texelVector << 1.0f; // Add bulk data in to the mesh GLC_Mesh::addVertice(verticeVector); GLC_Mesh::addNormals(normalsVector); GLC_Mesh::addTexels(texelVector); // Set the material to use GLC_Material* pMaterial; if (hasMaterial()) { pMaterial= this->firstMaterial(); } else { pMaterial= new GLC_Material(); } IndexList index; // Face 1 index << 0 << 1 << 3 << 2; GLC_Mesh::addTrianglesStrip(pMaterial, index); index.clear(); // Face 2 index << 4 << 5 << 7 << 6; GLC_Mesh::addTrianglesStrip(pMaterial, index); index.clear(); // Face 3 index << 8 << 9 << 11 << 10; GLC_Mesh::addTrianglesStrip(pMaterial, index); index.clear(); // Face 4 index << 12 << 13 << 15 << 14; GLC_Mesh::addTrianglesStrip(pMaterial, index); index.clear(); // Face 5 index << 16 << 17 << 19 << 18; GLC_Mesh::addTrianglesStrip(pMaterial, index); index.clear(); // Face 6 index << 20 << 21 << 23 << 22; GLC_Mesh::addTrianglesStrip(pMaterial, index); index.clear(); GLC_Mesh::finish(); }