void HistogramView::draw( QSize sz ) { QGraphicsScene *sc = scene(); assert(sc); m_xRatio = 1.0 * ( sz.width() - 4*m_Border ) / ( m_maxX - m_minX ); m_yRatio = 1.0 * ( sz.height() - 2*m_Border ) / ( m_maxY - m_minY ); // eleimino la vecchia scena if (m_histogramItems != NULL) { sc->removeItem(m_histogramItems); delete m_histogramItems; m_histogramItems = NULL; } m_histogramItems = new QGraphicsItemGroup; // inizio i disegni addAxis( sz ); //texts on axes //addText( m_minY, QPointF( 0, PosY(m_minY,sz) ) ); //addText( m_maxY, QPointF( 0, PosY(m_maxY,sz) ) ); addGridLine( 0, H, sz ); int nlines = 5; for (int i=0; i<nlines; i++) addGridLine( AutoRound( m_minY + (m_maxY-m_minY)*i/nlines ), H, sz ); //vertical line histogram from zero const float y2 = PosY (0, sz); for (auto ih: m_histo) { const float x1 = PosX (ih.first); const float y1 = PosY (ih.second, sz); if (y1 != 0) { QGraphicsLineItem *pt = new QGraphicsLineItem( QLineF(x1, y2, x1, y1) ); pt->setPen(m_measurePen); m_histogramItems->addToGroup(pt); } } sc->addItem(m_histogramItems); //update scene rectangle. QRectF rectSc = m_histogramItems->boundingRect(); scene()->setSceneRect(rectSc); setRenderHint(QPainter::HighQualityAntialiasing, true); //assert(scene()->sceneRect() == sceneRect()); }
IfcSchema::IfcProductDefinitionShape* IfcHierarchyHelper::addAxisBox(double w, double d, double h, IfcSchema::IfcRepresentationContext* context) { IfcSchema::IfcRepresentation::list::ptr reps(new IfcSchema::IfcRepresentation::list); IfcSchema::IfcRepresentationItem::list::ptr body_items(new IfcSchema::IfcRepresentationItem::list); IfcSchema::IfcRepresentationItem::list::ptr axis_items(new IfcSchema::IfcRepresentationItem::list); IfcSchema::IfcShapeRepresentation* body_rep = new IfcSchema::IfcShapeRepresentation( context ? context : getRepresentationContext("Model"), std::string("Body"), std::string("SweptSolid"), body_items); IfcSchema::IfcShapeRepresentation* axis_rep = new IfcSchema::IfcShapeRepresentation( context ? context : getRepresentationContext("Plan"), std::string("Axis"), std::string("Curve2D"), axis_items); reps->push(axis_rep); reps->push(body_rep); IfcSchema::IfcProductDefinitionShape* shape = new IfcSchema::IfcProductDefinitionShape(boost::none, boost::none, reps); addEntity(shape); addEntity(body_rep); addBox(body_rep, w, d, h, 0, 0, 0, context); addEntity(axis_rep); addAxis(axis_rep, w); return shape; }
static CPLXMLNode* exportProjCSToXML(const OGRSpatialReference *poSRS) { const OGR_SRSNode *poProjCS = poSRS->GetAttrNode("PROJCS"); if (poProjCS == NULL) return NULL; /* -------------------------------------------------------------------- */ /* Establish initial infrastructure. */ /* -------------------------------------------------------------------- */ CPLXMLNode *psCRS_XML; psCRS_XML = CPLCreateXMLNode(NULL, CXT_Element, "gml:ProjectedCRS"); addGMLId(psCRS_XML); /* -------------------------------------------------------------------- */ /* Attach symbolic name (a name in a nameset). */ /* -------------------------------------------------------------------- */ CPLCreateXMLElementAndValue(psCRS_XML, "gml:srsName", poProjCS->GetChild(0)->GetValue()); /* -------------------------------------------------------------------- */ /* Add authority info if we have it. */ /* -------------------------------------------------------------------- */ exportAuthorityToXML(poProjCS, "gml:srsID", psCRS_XML, "crs"); /* -------------------------------------------------------------------- */ /* Use the GEOGCS as a <baseCRS> */ /* -------------------------------------------------------------------- */ CPLXMLNode *psBaseCRSXML = CPLCreateXMLNode(psCRS_XML, CXT_Element, "gml:baseCRS"); CPLAddXMLChild(psBaseCRSXML, exportGeogCSToXML(poSRS)); /* -------------------------------------------------------------------- */ /* Our projected coordinate system is "defined by Conversion". */ /* -------------------------------------------------------------------- */ CPLXMLNode *psDefinedBy; psDefinedBy = CPLCreateXMLNode(psCRS_XML, CXT_Element, "gml:definedByConversion"); /* -------------------------------------------------------------------- */ /* Projections are handled as ParameterizedTransformations. */ /* -------------------------------------------------------------------- */ const char *pszProjection = poSRS->GetAttrValue("PROJECTION"); CPLXMLNode *psConv; psConv = CPLCreateXMLNode(psDefinedBy, CXT_Element, "gml:Conversion"); addGMLId(psConv); /* -------------------------------------------------------------------- */ /* Transverse Mercator */ /* -------------------------------------------------------------------- */ if (EQUAL(pszProjection, SRS_PT_TRANSVERSE_MERCATOR)) { AddValueIDWithURN(psConv, "gml:usesMethod", "EPSG", "method", 9807); addProjArg(poSRS, psConv, "Angular", 0.0, 8801, SRS_PP_LATITUDE_OF_ORIGIN); addProjArg(poSRS, psConv, "Angular", 0.0, 8802, SRS_PP_CENTRAL_MERIDIAN); addProjArg(poSRS, psConv, "Unitless", 1.0, 8805, SRS_PP_SCALE_FACTOR); addProjArg(poSRS, psConv, "Linear", 0.0, 8806, SRS_PP_FALSE_EASTING); addProjArg(poSRS, psConv, "Linear", 0.0, 8807, SRS_PP_FALSE_NORTHING); } /* -------------------------------------------------------------------- */ /* Lambert Conformal Conic */ /* -------------------------------------------------------------------- */ else if (EQUAL(pszProjection, SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP)) { AddValueIDWithURN(psConv, "gml:usesMethod", "EPSG", "method", 9801); addProjArg(poSRS, psConv, "Angular", 0.0, 8801, SRS_PP_LATITUDE_OF_ORIGIN); addProjArg(poSRS, psConv, "Angular", 0.0, 8802, SRS_PP_CENTRAL_MERIDIAN); addProjArg(poSRS, psConv, "Unitless", 1.0, 8805, SRS_PP_SCALE_FACTOR); addProjArg(poSRS, psConv, "Linear", 0.0, 8806, SRS_PP_FALSE_EASTING); addProjArg(poSRS, psConv, "Linear", 0.0, 8807, SRS_PP_FALSE_NORTHING); } /* -------------------------------------------------------------------- */ /* Define the cartesian coordinate system. */ /* -------------------------------------------------------------------- */ CPLXMLNode *psCCS; psCCS = CPLCreateXMLNode( CPLCreateXMLNode(psCRS_XML, CXT_Element, "gml:usesCartesianCS"), CXT_Element, "gml:CartesianCS"); addGMLId(psCCS); CPLCreateXMLElementAndValue(psCCS, "gml:csName", "Cartesian"); addAuthorityIDBlock(psCCS, "gml:csID", "EPSG", "cs", 4400); addAxis(psCCS, "E", NULL); addAxis(psCCS, "N", NULL); return psCRS_XML; }
static CPLXMLNode* exportGeogCSToXML(const OGRSpatialReference *poSRS) { CPLXMLNode *psGCS_XML; const OGR_SRSNode *poGeogCS = poSRS->GetAttrNode("GEOGCS"); if (poGeogCS == NULL) return NULL; /* -------------------------------------------------------------------- */ /* Establish initial infrastructure. */ /* -------------------------------------------------------------------- */ psGCS_XML = CPLCreateXMLNode(NULL, CXT_Element, "gml:GeographicCRS"); addGMLId(psGCS_XML); /* -------------------------------------------------------------------- */ /* Attach symbolic name (srsName). */ /* -------------------------------------------------------------------- */ CPLCreateXMLElementAndValue(psGCS_XML, "gml:srsName", poGeogCS->GetChild(0)->GetValue()); /* -------------------------------------------------------------------- */ /* Does the overall coordinate system have an authority? If so */ /* attach as an identification section. */ /* -------------------------------------------------------------------- */ exportAuthorityToXML(poGeogCS, "gml:srsID", psGCS_XML, "crs"); /* -------------------------------------------------------------------- */ /* Insert a big whack of fixed stuff defining the */ /* ellipsoidalCS. Basically this defines the axes and their */ /* units. */ /* -------------------------------------------------------------------- */ CPLXMLNode *psECS; psECS = CPLCreateXMLNode( CPLCreateXMLNode(psGCS_XML, CXT_Element, "gml:usesEllipsoidalCS"), CXT_Element, "gml:EllipsoidalCS"); addGMLId(psECS); CPLCreateXMLElementAndValue(psECS, "gml:csName", "ellipsoidal"); addAuthorityIDBlock(psECS, "gml:csID", "EPSG", "cs", 6402); addAxis(psECS, "Lat", NULL); addAxis(psECS, "Long", NULL); /* -------------------------------------------------------------------- */ /* Start with the datum. */ /* -------------------------------------------------------------------- */ const OGR_SRSNode *poDatum = poGeogCS->GetNode("DATUM"); CPLXMLNode *psDatumXML; if (poDatum == NULL) { CPLDestroyXMLNode(psGCS_XML); return NULL; } psDatumXML = CPLCreateXMLNode( CPLCreateXMLNode(psGCS_XML, CXT_Element, "gml:usesGeodeticDatum"), CXT_Element, "gml:GeodeticDatum"); addGMLId(psDatumXML); /* -------------------------------------------------------------------- */ /* Set the datumName. */ /* -------------------------------------------------------------------- */ CPLCreateXMLElementAndValue(psDatumXML, "gml:datumName", poDatum->GetChild(0)->GetValue()); /* -------------------------------------------------------------------- */ /* Set authority id info if available. */ /* -------------------------------------------------------------------- */ exportAuthorityToXML(poDatum, "gml:datumID", psDatumXML, "datum"); /* -------------------------------------------------------------------- */ /* Setup prime meridian information. */ /* -------------------------------------------------------------------- */ const OGR_SRSNode *poPMNode = poGeogCS->GetNode("PRIMEM"); CPLXMLNode *psPM; char *pszPMName = (char* ) "Greenwich"; double dfPMOffset = poSRS->GetPrimeMeridian(&pszPMName); psPM = CPLCreateXMLNode( CPLCreateXMLNode(psDatumXML, CXT_Element, "gml:usesPrimeMeridian"), CXT_Element, "gml:PrimeMeridian"); addGMLId(psPM); CPLCreateXMLElementAndValue(psPM, "gml:meridianName", pszPMName); if (poPMNode) exportAuthorityToXML(poPMNode, "gml:meridianID", psPM, "meridian"); CPLXMLNode *psAngle; psAngle = CPLCreateXMLNode( CPLCreateXMLNode(psPM, CXT_Element, "gml:greenwichLongitude"), CXT_Element, "gml:angle"); CPLCreateXMLNode(CPLCreateXMLNode(psAngle, CXT_Attribute, "gml:uom"), CXT_Text, "urn:ogc:def:uom:EPSG::9102"); CPLCreateXMLNode(psAngle, CXT_Text, CPLString().Printf("%.16g", dfPMOffset)); /* -------------------------------------------------------------------- */ /* Translate the ellipsoid. */ /* -------------------------------------------------------------------- */ const OGR_SRSNode *poEllipsoid = poDatum->GetNode("SPHEROID"); if (poEllipsoid != NULL) { CPLXMLNode *psEllipseXML; psEllipseXML = CPLCreateXMLNode( CPLCreateXMLNode(psDatumXML, CXT_Element, "gml:usesEllipsoid"), CXT_Element, "gml:Ellipsoid"); addGMLId(psEllipseXML); CPLCreateXMLElementAndValue(psEllipseXML, "gml:ellipsoidName", poEllipsoid->GetChild(0)->GetValue()); exportAuthorityToXML(poEllipsoid, "gml:ellipsoidID", psEllipseXML, "ellipsoid"); CPLXMLNode *psParmXML; psParmXML = CPLCreateXMLNode(psEllipseXML, CXT_Element, "gml:semiMajorAxis"); CPLCreateXMLNode(CPLCreateXMLNode(psParmXML, CXT_Attribute, "gml:uom"), CXT_Text, "urn:ogc:def:uom:EPSG::9001"); CPLCreateXMLNode(psParmXML, CXT_Text, poEllipsoid->GetChild(1)->GetValue()); psParmXML = CPLCreateXMLNode( CPLCreateXMLNode(psEllipseXML, CXT_Element, "gml:secondDefiningParameter"), CXT_Element, "gml:inverseFlattening"); CPLCreateXMLNode(CPLCreateXMLNode(psParmXML, CXT_Attribute, "gml:uom"), CXT_Text, "urn:ogc:def:uom:EPSG::9201"); CPLCreateXMLNode(psParmXML, CXT_Text, poEllipsoid->GetChild(2)->GetValue()); } return psGCS_XML; }