Example #1
0
void QtStyleManager::GetStyles(StyleList& styleNames) const
{
  for (FileNameToStyleMap::const_iterator i = styles.begin(); i != styles.end(); ++i)
    styleNames.push_back(Style(i.value()->name, i.value()->fileName));
}
Example #2
0
osg::Group* createSymbologyScene(PopupManager* wm)
{
    osg::Group* grp = new osg::Group;

    osg::ref_ptr<SampleGeometryInput> dataset = new SampleGeometryInput;
    StyleList styles;

    {
        osg::ref_ptr<Style> style = new Style;
        style->setName("PolygonSymbol-color");
        osg::ref_ptr<PolygonSymbol> polySymbol = new PolygonSymbol;
        polySymbol->fill()->color() = osg::Vec4(0,1,1,1);
        style->addSymbol(polySymbol.get());
        styles.push_back(style.get());
    }

    {
        osg::ref_ptr<Style> style = new Style;
        style->setName("Custom-PolygonPointSizeSymbol-size&color");
        osg::ref_ptr<PolygonPointSizeSymbol> polySymbol = new PolygonPointSizeSymbol;
        polySymbol->fill()->color() = osg::Vec4(1,0,0,1);
        polySymbol->size() = 2.0;
        style->addSymbol(polySymbol.get());
        styles.push_back(style.get());
    }


    // style for extruded
    {
        osg::ref_ptr<Style> style = new Style;
        style->setName("Extrude-Polygon&Line-height&color");
        osg::ref_ptr<ExtrudedPolygonSymbol> polySymbol = new ExtrudedPolygonSymbol;
        polySymbol->fill()->color() = osg::Vec4(1,0,0,1);
        polySymbol->extrude()->height() = 100;
        polySymbol->extrude()->offset() = 10;
        style->addSymbol(polySymbol.get());

        osg::ref_ptr<ExtrudedLineSymbol> lineSymbol = new ExtrudedLineSymbol;
        lineSymbol->stroke()->color() = osg::Vec4(0,0,1,1);
        lineSymbol->extrude()->height() = 150;
        lineSymbol->extrude()->offset() = 10;
        style->addSymbol(lineSymbol.get());
        styles.push_back(style.get());
    }


    // style for marker
    {
        osg::ref_ptr<Style> style = new Style;
        style->setName("Marker");
        osg::ref_ptr<MarkerSymbol> pointSymbol = new MarkerSymbol;
        pointSymbol->marker() = "../data/tree.ive";
        style->addSymbol(pointSymbol.get());

        osg::ref_ptr<MarkerLineSymbol> lineSymbol = new MarkerLineSymbol;
        lineSymbol->marker() = "../data/tree.ive";
        lineSymbol->interval() = 5;
        style->addSymbol(lineSymbol.get());

        osg::ref_ptr<MarkerPolygonSymbol> polySymbol = new MarkerPolygonSymbol;
        polySymbol->marker() = "../data/tree.ive";
        polySymbol->interval() = 20;
        polySymbol->randomRatio() = 1.0;
        style->addSymbol(polySymbol.get());

        styles.push_back(style.get());
    }


    // style for popup
    {
        osg::ref_ptr<Style> style = new Style;
        style->setName("Popup");
        osg::ref_ptr<TextSymbol> symbol = new TextSymbol;
        //symbol->theme() = "../data/popup-theme.png";
        symbol->font() = "arial.ttf";
        symbol->size() = 14;
        symbol->fill()->color() = osg::Vec4(getRandomValueInOne(), getRandomValueInOne() , getRandomValueInOne(), 0.7);
        style->addSymbol(symbol.get());
        styles.push_back(style.get());
    }


    /// associate the style / symbolizer to the symbolic node
    {
        GeometrySymbolicNode* node = new GeometrySymbolicNode();
        node->setSymbolizer( new GeometrySymbolizer() );

        node->getState()->setStyle( styles[0].get() );
        node->getState()->setContent( dataset.get() );

        osg::MatrixTransform* tr = new osg::MatrixTransform;
        tr->setMatrix(osg::Matrix::translate(0, -250 , 0));
        tr->addChild(node);
        grp->addChild(tr);
    }


    {
        GeometrySymbolicNode* node = new GeometrySymbolicNode();
        node->setSymbolizer( new GeometryPointSymbolizer() );
        node->getState()->setStyle(styles[1].get());
        node->getState()->setContent(dataset.get());
        osg::MatrixTransform* tr = new osg::MatrixTransform;
        tr->addChild(node);
        tr->setMatrix(osg::Matrix::translate(0, 0 , 0));
        grp->addChild(tr);
    }


    {
        GeometrySymbolicNode* node = new GeometrySymbolicNode();
        node->setSymbolizer( new GeometryExtrudeSymbolizer() );
        node->getState()->setStyle(styles[2].get());
        node->getState()->setContent(dataset.get());
        osg::MatrixTransform* tr = new osg::MatrixTransform;
        tr->addChild(node);
        tr->setMatrix(osg::Matrix::translate(0, 250 , 0));
        grp->addChild(tr);
    }


    {
        GeometrySymbolicNode* node = new GeometrySymbolicNode();
        node->setSymbolizer( new MarkerSymbolizer() );
        node->getState()->setStyle(styles[3].get());
        node->getState()->setContent(dataset.get());
        osg::MatrixTransform* tr = new osg::MatrixTransform;
        tr->addChild(node);
        tr->setMatrix(osg::Matrix::translate(0, 500 , 0));
        grp->addChild(tr);
    }



    //{
    //    osg::ref_ptr<ModelSymbolizer> symbolizer = new ModelSymbolizer();
    //    osg::ref_ptr<SymbolicNode> node = new SymbolicNode;
    //    node->setSymbolizer(symbolizer.get());
    //    Style* style = new Style;
    //    std::string real = osgDB::getRealPath("../data/tree.ive");
    //    MarkerSymbol* marker = new MarkerSymbol;
    //    marker->marker() = real;
    //    node->setDataSet(dataset.get());
    //    style->addSymbol(marker);
    //    node->setStyle(style);
    //    osg::MatrixTransform* tr = new osg::MatrixTransform;
    //    tr->addChild(node);
    //    tr->setMatrix(osg::Matrix::scale(10,10,10) * osg::Matrix::translate(0, 750 , 0));
    //    grp->addChild(tr);
    //}

    StyleEditor* styleEditor = new StyleEditor(styles);
    {
        PopUpSymbolizerContext* ctx = new PopUpSymbolizerContext(wm);
        styleEditor->setPopupContext(ctx);

        SymbolicNode< State<GeometryContent> >* node = new SymbolicNode< State<GeometryContent> >();
        node->setSymbolizer( new PopUpSymbolizer() );
        node->getState()->setStyle(styles[4]);
        node->getState()->setContent(dataset.get());
        node->getState()->setContext(ctx);
        osg::MatrixTransform* tr = new osg::MatrixTransform;
        tr->addChild(node);
        tr->setMatrix(osg::Matrix::translate(0, 1000 , 0));
        grp->addChild(tr);
    }
    
    grp->addEventCallback(styleEditor);
    return grp;
}