void MissingControl::draw() { ofPushStyle(); ofEnableAlphaBlending(); ofBackground(0); ofSetColor(255, 128); drawPerspective(); drawPlan(ofGetWidth() - 256, 0, 256); drawSection(ofGetWidth() - 256, 256, 256); vector<unsigned char>& packet = driver.getPacket(); string msg; for(int i = 0; i < packet.size(); i++) { msg += ofToString(i, 2, '0') + " 0x" + ofToHex(packet[i]) + "\n"; } MiniFont::draw(msg, 10, 10); ofPushMatrix(); ofPushStyle(); ofTranslate(10, ofGetHeight() - 10); ofScale(100, 1); ofSetColor(ofColor::fromHex(0xffee00)); ofLine(0, 0, (rawPresence ? 1 : 0), 0); ofSetColor(ofColor::fromHex(0x00abec)); ofLine(0, 2, presence.get(), 2); ofSetColor(ofColor::fromHex(0xec008c)); ofLine(0, 4, volume.get(), 4); ofPopStyle(); ofPopMatrix(); ofPopStyle(); }
void PartitionBarsView::drawPartitions( QPainter* painter, const QRect& rect, const QModelIndex& parent ) { PartitionModel* modl = qobject_cast< PartitionModel* >( model() ); if ( !modl ) return; const int totalWidth = rect.width(); auto pair = computeItemsVector( parent ); QVector< PartitionBarsView::Item >& items = pair.first; qreal& total = pair.second; int x = rect.x(); for ( int row = 0; row < items.count(); ++row ) { const auto& item = items[ row ]; int width; if ( row < items.count() - 1 ) width = totalWidth * ( item.size / total ); else // Make sure we fill the last pixel column width = rect.right() - x + 1; drawSection( painter, rect, x, width, item.index ); if ( m_nestedPartitionsMode == DrawNestedPartitions && modl->hasChildren( item.index ) ) { QRect subRect( x + EXTENDED_PARTITION_MARGIN, rect.y() + EXTENDED_PARTITION_MARGIN, width - 2 * EXTENDED_PARTITION_MARGIN, rect.height() - 2 * EXTENDED_PARTITION_MARGIN ); drawPartitions( painter, subRect, item.index ); } x += width; } if ( !items.count() && !modl->device()->partitionTable() ) // No disklabel or unknown { int width = rect.right() - rect.x() + 1; drawSection( painter, rect, rect.x(), width, QModelIndex() ); } }
/** * @brief Entity::drawSections * @param painter */ void Entity::drawSections(QPainter *painter) { painter->save(); // Calculate initial parameters QColor color = typeColor(); auto topLeft = boundingRect().topLeft() + QPointF(margin, margin); topLeft.ry() += minimumHeight; qreal len = height() - minimumHeight; // Draw sections drawSection(painter, tr("Properties"), m_Type->properties(), topLeft, len, width(), color); drawSection(painter, tr("Methods"), m_Type->methods(), topLeft, len, width(), color); drawSection(painter, tr("Fields"), m_Type->fields(), topLeft, len, width(), color); drawSection(painter, tr("Elements"), m_Type->enumerators(), topLeft, len, width(), color); painter->restore(); }
void GBillboardWorld::draw(GImage* pImage, double* pDepthMap, GCamera& camera) { G3DVector coords[VERTEX_COUNT + 1]; int coordMap[VERTEX_COUNT + 1]; for(size_t i = 0; i < pImage->width() * pImage->height(); i++) pDepthMap[i] = 1e200; for(vector<GBillboard*>::iterator it = m_billboards.begin(); it != m_billboards.end(); it++) { // Project each of the corners onto the view GBBAugmented bb(**it); int gap = -1; int coordCount = 0; for(int i = 0; i < VERTEX_COUNT; i++) { camera.project(bb.m_pCorners[i], &coords[coordCount]); if(coords[coordCount].m_vals[2] > 0.0) coordMap[coordCount++] = i; else if(gap < 0) { gap = coordCount; coordCount = gap + 2; } } // Fudge the gap due to vertices that are behind the camera if(gap >= 0) { if(coordCount == 0) continue; // Nothing to draw // Fudge the vertex that follows the chain of valid vertices G3DVector tmp; G3DVector tmp2; int indexValid = coordMap[(gap + coordCount - 1) % coordCount]; // The corner just before the gap int indexFudge = (indexValid + 1) % VERTEX_COUNT; // The first corner that was behind the camera tmp.copy(bb.m_pCorners[indexValid]); tmp.subtract(bb.m_pCorners[indexFudge]); tmp2.copy(camera.lookFromPoint()); tmp2.subtract(bb.m_pCorners[indexFudge]); double d = (1e-6 + tmp2.dotProduct(camera.lookDirection())) / tmp.dotProduct(camera.lookDirection()); tmp.multiply(d); tmp.add(bb.m_pCorners[indexFudge]); camera.project(&tmp, &coords[gap]); // Fudge the vertex that precedes the chain of valid vertices indexValid = coordMap[(gap + 2) % coordCount]; // The corner just after the gap indexFudge = (indexValid + VERTEX_COUNT - 1) % VERTEX_COUNT; // The last corner that was behind the camera tmp.copy(bb.m_pCorners[indexValid]); tmp.subtract(bb.m_pCorners[indexFudge]); tmp2.copy(camera.lookFromPoint()); tmp2.subtract(bb.m_pCorners[indexFudge]); d = (1e-6 + tmp2.dotProduct(camera.lookDirection())) / tmp.dotProduct(camera.lookDirection()); tmp.multiply(d); tmp.add(bb.m_pCorners[indexFudge]); camera.project(&tmp, &coords[gap + 1]); } // Find the starting point (which is the lowest coordinate in the view) int a = 0; for(int i = 1; i < coordCount; i++) { if(coords[i].m_vals[1] < coords[a].m_vals[1]) a = i; } int b = a; // Find the left and right order in which the corners will be visted (bottom to top) while(true) { int c = (b + 1) % coordCount; if(a == c) break; int d = (a + coordCount - 1) % coordCount; drawSection(pImage, pDepthMap, camera, bb, &coords[a], &coords[b], &coords[c], &coords[d]); if(coords[d].m_vals[1] < coords[c].m_vals[1]) a = d; else b = c; } } }