Changeset 5969
- Timestamp:
- Jan 25, 2016, 6:28:49 PM (9 years ago)
- Location:
- geovis/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
geovis/trunk/Picker.cpp
r5961 r5969 201 201 INFO("Hit feature ID: %lu (of %d) layer: %s", feature->getFID(), index->size(), layerName.c_str()); 202 202 203 osgEarth::Symbology::Style style;204 osgEarth::Symbology::TextSymbol *ts = style.getOrCreateSymbol<osgEarth::Symbology::TextSymbol>();205 //ts->halo()->color() = osgEarth::Symbology::Color(1, 1, 1);206 //ts->halo()->width() = 2;207 ts->fill()->color() = osgEarth::Symbology::Color(0, 0, 0);208 ts->size() = 14;209 //ts->alignment() = alignment;210 ts->declutter() = false;211 //ts->encoding() = osgEarth::Symbology::TextSymbol::ENCODING_UTF8;212 203 clearSelection(); 213 204 … … 218 209 } 219 210 PlacardNode *label = 220 new PlacardNode(_renderer->getMapNode(), _pickPoint, placard, attrs , style);211 new PlacardNode(_renderer->getMapNode(), _pickPoint, placard, attrs); 221 212 label->getOrCreateStateSet()->setRenderBinDetails(INT_MAX, "RenderBin"); 222 213 _renderer->getAnnotations()->addChild(label); -
geovis/trunk/Placard.cpp
r5961 r5969 22 22 using namespace GeoVis; 23 23 24 Placard::Placard() : 25 _backdropColor(0.75, 0.75, 0.75, 0.75) 26 { 27 osgEarth::Symbology::TextSymbol *ts = _textStyle.getOrCreateSymbol<osgEarth::Symbology::TextSymbol>(); 28 //ts->halo()->color() = osgEarth::Symbology::Color(1, 1, 1); 29 //ts->halo()->width() = 2; 30 ts->fill()->color() = osgEarth::Symbology::Color(0, 0, 0); 31 ts->size() = 14; 32 //ts->alignment() = alignment; 33 ts->declutter() = false; 34 //ts->encoding() = osgEarth::Symbology::TextSymbol::ENCODING_UTF8; 35 double charSize = ts->size().isSet() ? ts->size()->eval() : 14.0; 36 _padding = (float)(charSize / 2.0); 37 } 38 24 39 PlacardLabelNode::PlacardLabelNode(osgEarth::MapNode *mapNode, 25 40 const osgEarth::GeoPoint& position, 26 41 const Placard& placardConf, 27 const osgEarth::Features::AttributeTable &attrs, 28 const osgEarth::Symbology::Style& style) : 29 osgEarth::Annotation::LabelNode(mapNode, position, style), 42 const osgEarth::Features::AttributeTable &attrs) : 43 osgEarth::Annotation::LabelNode(mapNode, position, placardConf.getStyle()), 30 44 _placardConf(placardConf), 31 45 _attrs(attrs) … … 74 88 const osgEarth::GeoPoint& position, 75 89 const Placard& placardConf, 76 const osgEarth::Features::AttributeTable &attrs, 77 const osgEarth::Symbology::Style& style) : 90 const osgEarth::Features::AttributeTable &attrs) : 78 91 osgEarth::Annotation::OrthoNode(mapNode, position), 79 _backdropColor(0.75, 0.75, 0.75, 0.75),80 92 _placardConf(placardConf), 81 93 _attrs(attrs) 82 94 { 83 95 setConfig(placardConf); 84 init( style);96 init(placardConf.getStyle()); 85 97 } 86 98 … … 172 184 if (bd) { 173 185 osg::BoundingBox bbox = d->getBoundingBox(); 174 const osgEarth::Symbology::TextSymbol* symbol = _style.get<osgEarth::Symbology::TextSymbol>();175 double charSize = symbol && symbol->size().isSet() ? symbol->size()->eval() : 16.0;176 float padding = (float)(charSize / 2.0);177 186 _backdropGeode->removeDrawables( 0, _backdropGeode->getNumDrawables() ); 178 osg::Drawable *bd = osgEarth::Annotation::AnnotationUtils::create2DQuad(bbox, padding, _backdropColor);187 osg::Drawable *bd = osgEarth::Annotation::AnnotationUtils::create2DQuad(bbox, _placardConf.getPadding(), _placardConf.getBackdropColor()); 179 188 _backdropGeode->addDrawable(bd); 180 189 } … … 207 216 _geode->setCullingActive(false); 208 217 209 double charSize = symbol && symbol->size().isSet() ? symbol->size()->eval() : 16.0;210 218 osg::BoundingBox bbox = t->getBoundingBox(); 211 float padding = (float)(charSize / 2.0);212 osg::Drawable *bd = osgEarth::Annotation::AnnotationUtils::create2DQuad(bbox, padding, _backdropColor);219 220 osg::Drawable *bd = osgEarth::Annotation::AnnotationUtils::create2DQuad(bbox, _placardConf.getPadding(), _placardConf.getBackdropColor()); 213 221 _backdropGeode->addDrawable(bd); 214 222 _backdropGeode->setCullingActive(false); … … 258 266 conf.add ( "text", _text ); 259 267 conf.addObj( "style", _style ); 268 conf.add ( "padding", _placardConf.getPadding() ); 269 conf.add ( "bg-fill", _placardConf.getBackdropColor() ); 260 270 conf.addObj( "position", getPosition() ); 261 271 -
geovis/trunk/Placard.h
r5961 r5969 22 22 class Placard { 23 23 public: 24 Placard() 25 {} 24 Placard(); 26 25 virtual ~Placard() 27 26 {} … … 53 52 return _attrNames.size(); 54 53 } 54 void setStyle(const osgEarth::Symbology::Style& style) 55 { 56 _textStyle = style; 57 } 58 const osgEarth::Symbology::Style& getStyle() const 59 { 60 return _textStyle; 61 } 62 void setPadding(float padding) 63 { 64 _padding = padding; 65 } 66 float getPadding() const 67 { 68 return _padding; 69 } 70 void setBackdropColor(const osg::Vec4& color) 71 { 72 _backdropColor = color; 73 } 74 const osg::Vec4& getBackdropColor() const 75 { 76 return _backdropColor; 77 } 55 78 private: 56 79 std::vector<std::string> _attrNames; 57 80 std::vector<std::string> _attrLabels; 81 float _padding; 82 osg::Vec4 _backdropColor; 83 osgEarth::Symbology::Style _textStyle; 58 84 }; 59 85 … … 75 101 const osgEarth::GeoPoint& position, 76 102 const Placard& placardConf, 77 const osgEarth::Features::AttributeTable &attrs, 78 const osgEarth::Symbology::Style& style = osgEarth::Symbology::Style()); 103 const osgEarth::Features::AttributeTable &attrs); 79 104 80 105 virtual ~PlacardLabelNode() … … 105 130 const osgEarth::GeoPoint& position, 106 131 const Placard& placardConf, 107 const osgEarth::Features::AttributeTable &attrs, 108 const osgEarth::Symbology::Style& style = osgEarth::Symbology::Style()); 132 const osgEarth::Features::AttributeTable &attrs); 109 133 110 134 virtual ~PlacardNode() -
geovis/trunk/RendererCmd.cpp
r5944 r5969 3043 3043 int namec; 3044 3044 Tcl_Obj **namev = NULL; 3045 const char *layerName = Tcl_GetString(objv[ 3]);3045 const char *layerName = Tcl_GetString(objv[9]); 3046 3046 3047 3047 if (Tcl_ListObjGetElements(interp, objv[2], &namec, &namev) != TCL_OK) { … … 3059 3059 placardConf.addEntry(name, label); 3060 3060 } 3061 osgEarth::Config styleConf("style", Tcl_GetString(objv[3])); 3062 styleConf.add("type", "text/css"); 3063 placardConf.setStyle(osgEarth::Symbology::Style(styleConf)); 3064 float r, g, b, a; 3065 if (GetFloatFromObj(interp, objv[4], &r) != TCL_OK || 3066 GetFloatFromObj(interp, objv[5], &g) != TCL_OK || 3067 GetFloatFromObj(interp, objv[6], &b) != TCL_OK || 3068 GetFloatFromObj(interp, objv[7], &a) != TCL_OK) { 3069 return TCL_ERROR; 3070 } 3071 placardConf.setBackdropColor(osg::Vec4(r, g, b, a)); 3072 float padding; 3073 if (GetFloatFromObj(interp, objv[8], &padding) != TCL_OK) { 3074 return TCL_ERROR; 3075 } 3076 placardConf.setPadding(padding); 3061 3077 g_renderer->setPlacardConfig(placardConf, layerName); 3062 3078 return TCL_OK; … … 3064 3080 3065 3081 static CmdSpec placardOps[] = { 3066 {"config", 1, PlacardConfigOp, 4, 4, "attrlistlayerName"},3082 {"config", 1, PlacardConfigOp, 10, 10, "attrlist textStyle bgColorR bgColorG bgColorB bgColorA padding layerName"}, 3067 3083 }; 3068 3084 static int nPlacardOps = NumCmdSpecs(placardOps);
Note: See TracChangeset
for help on using the changeset viewer.