本文整理汇总了C++中HSliderControl::setWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ HSliderControl::setWidth方法的具体用法?C++ HSliderControl::setWidth怎么用?C++ HSliderControl::setWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HSliderControl
的用法示例。
在下文中一共展示了HSliderControl::setWidth方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addControls
void
addControls(HSLColorFilter* filter, Container* container, unsigned i)
{
// the outer container:
Grid* s_layerBox = container->addControl(new Grid());
s_layerBox->setBackColor(0,0,0,0.5);
s_layerBox->setMargin( 10 );
s_layerBox->setPadding( 10 );
s_layerBox->setChildSpacing( 10 );
s_layerBox->setChildVertAlign( Control::ALIGN_CENTER );
s_layerBox->setAbsorbEvents( true );
s_layerBox->setVertAlign( Control::ALIGN_TOP );
// Title:
s_layerBox->setControl( 0, 0, new LabelControl(Stringify()<<"Layer "<<i, osg::Vec4(1,1,0,1)));
// Hue:
LabelControl* hLabel = new LabelControl( "Hue" );
hLabel->setVertAlign( Control::ALIGN_CENTER );
s_layerBox->setControl( 0, 1, hLabel );
HSliderControl* hAdjust = new HSliderControl( -1.0f, 1.0f, 0.0f, new SetHSL(filter,0) );
hAdjust->setWidth( 125 );
hAdjust->setHeight( 12 );
hAdjust->setVertAlign( Control::ALIGN_CENTER );
s_layerBox->setControl( 1, 1, hAdjust );
s_layerBox->setControl( 2, 1, new LabelControl(hAdjust) );
// Saturation:
LabelControl* sLabel = new LabelControl( "Saturation" );
sLabel->setVertAlign( Control::ALIGN_CENTER );
s_layerBox->setControl( 0, 2, sLabel );
HSliderControl* sAdjust = new HSliderControl( -1.0f, 1.0f, 0.0f, new SetHSL(filter,1) );
sAdjust->setWidth( 125 );
sAdjust->setHeight( 12 );
sAdjust->setVertAlign( Control::ALIGN_CENTER );
s_layerBox->setControl( 1, 2, sAdjust );
s_layerBox->setControl( 2, 2, new LabelControl(sAdjust) );
// Lightness
LabelControl* lLabel = new LabelControl( "Lightness" );
lLabel->setVertAlign( Control::ALIGN_CENTER );
s_layerBox->setControl( 0, 3, lLabel );
HSliderControl* lAdjust = new HSliderControl( -1.0f, 1.0f, 0.0f, new SetHSL(filter,2) );
lAdjust->setWidth( 125 );
lAdjust->setHeight( 12 );
lAdjust->setVertAlign( Control::ALIGN_CENTER );
s_layerBox->setControl( 1, 3, lAdjust );
s_layerBox->setControl( 2, 3, new LabelControl(lAdjust) );
// Reset button
LabelControl* resetButton = new LabelControl( "Reset" );
resetButton->setBackColor( osg::Vec4(0.5,0.5,0.5,1) );
resetButton->setActiveColor( osg::Vec4(0.5,0.5,1,1) );
resetButton->addEventHandler( new ResetHSL(hAdjust, sAdjust, lAdjust) );
s_layerBox->setControl( 1, 4, resetButton );
}
示例2: CheckBoxControl
void
createLayerItem( Grid* grid, int gridRow, int layerIndex, int numLayers, TerrainLayer* layer, bool isActive )
{
// a checkbox to enable/disable the layer:
CheckBoxControl* enabled = new CheckBoxControl( layer->getVisible() );
enabled->addEventHandler( new LayerVisibleHandler(layer) );
grid->setControl( 0, gridRow, enabled );
// the layer name
LabelControl* name = new LabelControl( layer->getName() );
grid->setControl( 1, gridRow, name );
ImageLayer* imageLayer = dynamic_cast< ImageLayer* > (layer );
if (imageLayer)
{
// an opacity slider
HSliderControl* opacity = new HSliderControl( 0.0f, 1.0f, imageLayer->getOpacity() );
opacity->setWidth( 125 );
opacity->setHeight( 12 );
opacity->addEventHandler( new LayerOpacityHandler(imageLayer) );
grid->setControl( 2, gridRow, opacity );
}
// move buttons
if ( layerIndex < numLayers-1 && isActive )
{
LabelControl* upButton = new LabelControl( "UP", 14 );
upButton->setBackColor( .4,.4,.4,1 );
upButton->setActiveColor( .8,0,0,1 );
upButton->addEventHandler( new MoveLayerHandler( layer, layerIndex+1 ) );
grid->setControl( 3, gridRow, upButton );
}
if ( layerIndex > 0 && isActive)
{
LabelControl* upButton = new LabelControl( "DOWN", 14 );
upButton->setBackColor( .4,.4,.4,1 );
upButton->setActiveColor( .8,0,0,1 );
upButton->addEventHandler( new MoveLayerHandler( layer, layerIndex-1 ) );
grid->setControl( 4, gridRow, upButton );
}
// add/remove button:
LabelControl* addRemove = new LabelControl( isActive? "REMOVE" : "ADD", 14 );
addRemove->setHorizAlign( Control::ALIGN_CENTER );
addRemove->setBackColor( .4,.4,.4,1 );
addRemove->setActiveColor( .8,0,0,1 );
if ( isActive )
addRemove->addEventHandler( new RemoveLayerHandler(layer) );
else
addRemove->addEventHandler( new AddLayerHandler(layer) );
grid->setControl( 5, gridRow, addRemove );
}
示例3: CheckBoxControl
void
createModelLayerItem( Grid* grid, int gridRow, ModelLayer* layer, bool isActive )
{
// a checkbox to enable/disable the layer:
CheckBoxControl* enabled = new CheckBoxControl( layer->getVisible() );
enabled->addEventHandler( new ModelLayerVisibleHandler(layer) );
grid->setControl( 0, gridRow, enabled );
// the layer name
LabelControl* name = new LabelControl( layer->getName() );
grid->setControl( 1, gridRow, name );
// an opacity slider
HSliderControl* opacity = new HSliderControl( 0.0f, 1.0f, layer->getOpacity() );
opacity->setWidth( 125 );
opacity->setHeight( 12 );
opacity->addEventHandler( new ModelLayerOpacityHandler(layer) );
grid->setControl( 2, gridRow, opacity );
}
示例4: VBox
void
createControls( ControlCanvas* cs )
{
// a container centered on the screen, containing an image and a text label.
{
VBox* center = new VBox();
center->setFrame( new RoundedFrame() );
center->getFrame()->setBackColor( 1,1,1,0.5 );
center->setPadding( 10 );
center->setHorizAlign( Control::ALIGN_CENTER );
center->setVertAlign( Control::ALIGN_CENTER );
// Add an image:
osg::ref_ptr<osg::Image> image = osgDB::readImageFile("http://demo.pelicanmapping.com/rmweb/readymap_logo.png");
if ( image.valid() )
{
s_imageControl = new ImageControl( image.get() );
s_imageControl->setHorizAlign( Control::ALIGN_CENTER );
s_imageControl->setFixSizeForRotation( true );
//imageCon->addEventHandler( new ImageRotationHandler );
center->addControl( s_imageControl );
center->setHorizAlign( Control::ALIGN_CENTER );
}
// Add a text label:
LabelControl* label = new LabelControl( "osgEarth Controls Toolkit" );
label->setFont( osgEarth::Registry::instance()->getDefaultFont() );
label->setFontSize( 24.0f );
label->setHorizAlign( Control::ALIGN_CENTER );
label->setMargin( 5 );
center->addControl( label );
// Rotation slider
HBox* rotateBox = new HBox();
rotateBox->setChildVertAlign( Control::ALIGN_CENTER );
rotateBox->setHorizFill( true );
rotateBox->setBackColor( Color::Blue );
{
rotateBox->addControl( new LabelControl("Rotate: ") );
HSliderControl* rotateSlider = new HSliderControl( -180.0, 180.0, 0.0 );
rotateSlider->addEventHandler( new RotateImage() );
rotateSlider->setHeight( 8.0f );
rotateSlider->setHorizFill( true );
rotateBox->addControl( rotateSlider );
}
center->addControl( rotateBox );
cs->addControl( center );
}
// a simple vbox with absolute positioning in the upper left with two text labels.
{
VBox* ul = new VBox();
ul->setPosition( 20, 20 );
ul->setPadding( 10 );
{
LabelControl* title = new LabelControl( "Upper left control", 22, osg::Vec4f(1,1,0,1) );
ul->addControl( title );
LabelControl* content = new LabelControl( "Here is some text in the upper left control" );
ul->addControl( content );
HBox* c2 = new HBox();
c2->setChildSpacing( 10 );
{
HSliderControl* slider = new HSliderControl( 0, 100 );
slider->setBackColor( .6,0,0,1 );
slider->setHeight( 25 );
slider->setWidth( 300 );
slider->addEventHandler( new MySliderHandler() );
c2->addControl( slider );
s_sliderLabel = new LabelControl();
s_sliderLabel->setVertAlign( Control::ALIGN_CENTER );
c2->addControl( s_sliderLabel );
}
ul->addControl( c2 );
HBox* c3 = new HBox();
c3->setHorizAlign( Control::ALIGN_CENTER );
c3->setChildSpacing( 10 );
{
HBox* c4 = new HBox();
c4->setChildSpacing( 5 );
{
c4->addControl( new CheckBoxControl( true ) );
c4->addControl( new LabelControl( "Checkbox 1" ) );
}
c3->addControl( c4 );
HBox* c5 = new HBox();
c5->setChildSpacing( 5 );
{
c5->addControl( new CheckBoxControl( false ) );
c5->addControl( new LabelControl( "Checkbox 2" ) );
}
c3->addControl( c5 );
}
ul->addControl( c3 );
//.........这里部分代码省略.........
示例5: VBox
void
createControls( ControlCanvas* cs )
{
// a container centered on the screen, containing an image and a text label.
{
VBox* center = new VBox();
center->setFrame( new RoundedFrame() );
center->getFrame()->setBackColor( 1,1,1,0.5 );
center->setPadding( 10 );
center->setHorizAlign( Control::ALIGN_CENTER );
center->setVertAlign( Control::ALIGN_CENTER );
// Add an image:
osg::Image* image = osgDB::readImageFile( "http://osgearth.org/chrome/site/osgearth.gif" );
if ( image ) {
ImageControl* imageCon = new ImageControl( image );
imageCon->setHorizAlign( Control::ALIGN_CENTER );
imageCon->setFixSizeForRotation( true );
imageCon->addEventHandler( new ImageRotationHandler );
center->addControl( imageCon );
center->setHorizAlign( Control::ALIGN_CENTER );
}
// Add a text label:
LabelControl* label = new LabelControl( "osgEarth Controls Toolkit" );
label->setFont( osgText::readFontFile( "arialbd.ttf" ) );
label->setFontSize( 24.0f );
label->setHorizAlign( Control::ALIGN_CENTER );
label->setMargin( 5 );
center->addControl( label );
// Add another
LabelControl* label2 = new LabelControl( "(Click the osgEarth logo to rotate it)" );
label2->setHorizAlign( Control::ALIGN_CENTER );
center->addControl( label2 );
cs->addControl( center );
}
// a simple vbox with absolute positioning in the upper left with two text labels.
{
VBox* ul = new VBox();
ul->setFrame( new Frame() );
ul->setPosition( 20, 20 );
ul->setPadding( 10 );
{
LabelControl* title = new LabelControl( "Upper left control", 22, osg::Vec4f(1,1,0,1) );
ul->addControl( title );
LabelControl* content = new LabelControl( "Here is some text in the upper left control" );
ul->addControl( content );
HBox* c2 = new HBox();
c2->setSpacing( 10 );
{
HSliderControl* slider = new HSliderControl( 0, 100 );
slider->setBackColor( .6,0,0,1 );
slider->setHeight( 25 );
slider->setWidth( 300 );
slider->addEventHandler( new MySliderHandler() );
c2->addControl( slider );
s_sliderLabel = new LabelControl();
s_sliderLabel->setVertAlign( Control::ALIGN_CENTER );
c2->addControl( s_sliderLabel );
}
ul->addControl( c2 );
HBox* c3 = new HBox();
c3->setHorizAlign( Control::ALIGN_CENTER );
c3->setSpacing( 10 );
{
HBox* c4 = new HBox();
c4->setSpacing( 5 );
{
c4->addControl( new CheckBoxControl( true ) );
c4->addControl( new LabelControl( "Checkbox 1" ) );
}
c3->addControl( c4 );
HBox* c5 = new HBox();
c5->setSpacing( 5 );
{
c5->addControl( new CheckBoxControl( false ) );
c5->addControl( new LabelControl( "Checkbox 2" ) );
}
c3->addControl( c5 );
}
ul->addControl( c3 );
}
cs->addControl( ul );
ul->addEventHandler( new MyClickHandler );
}
// a centered hbox container along the bottom on the screen.
{
HBox* bottom = new HBox();
bottom->setFrame( new RoundedFrame() );
bottom->getFrame()->setBackColor(0,0,0,0.5);
//.........这里部分代码省略.........
示例6: arguments
//.........这里部分代码省略.........
if (!earthNode)
return usage( "Unable to load earth model." );
osgViewer::Viewer viewer(arguments);
EarthManipulator* manip = new EarthManipulator();
viewer.setCameraManipulator( manip );
osg::Group* root = new osg::Group();
root->addChild( earthNode );
//Create the control panel
root->addChild( createControlPanel(&viewer) );
viewer.setSceneData( root );
osgEarth::MapNode* mapNode = osgEarth::MapNode::findMapNode( earthNode );
if ( mapNode )
{
for (unsigned int i = 0; i < imageFiles.size(); i++)
{
std::string imageFile = imageFiles[i];
//Read the image file and play it if it's a movie
osg::Image* image = osgDB::readImageFile(imageFile);
if (image)
{
osg::ImageStream* is = dynamic_cast<osg::ImageStream*>(image);
if (is)
{
is->play();
}
}
//Create a new ImageOverlay and set it's bounds
//ImageOverlay* overlay = new ImageOverlay(mapNode->getMap()->getProfile()->getSRS()->getEllipsoid(), image);
ImageOverlay* overlay = new ImageOverlay(mapNode);
overlay->setImage( image );
overlay->setBounds(imageBounds[i]);
root->addChild( overlay );
//Create a new ImageOverlayEditor and set it's node mask to 0 to hide it initially
#if OSG_MIN_VERSION_REQUIRED(2,9,6)
osg::Node* editor = new ImageOverlayEditor( overlay);
#else
//Just make an empty group for pre-2.9.6
osg::Node* editor = new osg::Group;
#endif
editor->setNodeMask( 0 );
root->addChild( editor );
// Add an image preview
ImageControl* imageCon = new ImageControl( image );
imageCon->setSize( 64, 64 );
imageCon->setVertAlign( Control::ALIGN_CENTER );
s_layerBox->setControl( 0, i, imageCon );
//Add some controls
CheckBoxControl* enabled = new CheckBoxControl( true );
enabled->addEventHandler( new EnabledHandler(overlay) );
enabled->setVertAlign( Control::ALIGN_CENTER );
s_layerBox->setControl( 1, i, enabled );
//The overlay name
LabelControl* name = new LabelControl( osgDB::getSimpleFileName( imageFile) );
name->setVertAlign( Control::ALIGN_CENTER );
s_layerBox->setControl( 2, i, name );
// an opacity slider
HSliderControl* opacity = new HSliderControl( 0.0f, 1.0f, overlay->getAlpha() );
opacity->setWidth( 125 );
opacity->setHeight( 12 );
opacity->setVertAlign( Control::ALIGN_CENTER );
opacity->addEventHandler( new OpacityHandler(overlay) );
s_layerBox->setControl( 3, i, opacity );
// Add a text label:
LabelControl* edit = new LabelControl( "Edit" );
edit->setVertAlign( Control::ALIGN_CENTER );
edit->addEventHandler(new EditHandler(overlay, &viewer, editor));
s_layerBox->setControl(4, i, edit );
}
}
// osgEarth benefits from pre-compilation of GL objects in the pager. In newer versions of
// OSG, this activates OSG's IncrementalCompileOpeartion in order to avoid frame breaks.
viewer.getDatabasePager()->setDoPreCompile( true );
// add some stock OSG handlers:
viewer.addEventHandler(new osgViewer::StatsHandler());
viewer.addEventHandler(new osgViewer::WindowSizeHandler());
viewer.addEventHandler(new osgViewer::LODScaleHandler());
viewer.addEventHandler(new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()));
viewer.addEventHandler(new osgViewer::HelpHandler(arguments.getApplicationUsage()));
return viewer.run();
}
示例7: LabelControl
void
addLayerItem( Grid* grid, int layerIndex, int numLayers, Layer* layer, bool isActive )
{
int gridCol = 0;
int gridRow = grid->getNumRows();
VisibleLayer* visibleLayer = dynamic_cast<VisibleLayer*>(layer);
// only show layers that derive from VisibleLayer
if (!visibleLayer)
return;
ImageLayer* imageLayer = dynamic_cast<ImageLayer*>(layer);
// don't show hidden coverage layers
if (imageLayer && imageLayer->isCoverage() && !imageLayer->getVisible())
return;
ElevationLayer* elevationLayer = dynamic_cast<ElevationLayer*>(layer);
// a checkbox to toggle the layer's visibility:
if (visibleLayer && layer->getEnabled() && !(imageLayer && imageLayer->isCoverage()))
{
CheckBoxControl* visibility = new CheckBoxControl( visibleLayer->getVisible() );
visibility->addEventHandler( new ToggleLayerVisibility(visibleLayer) );
grid->setControl( gridCol, gridRow, visibility );
}
gridCol++;
// the layer name
LabelControl* name = new LabelControl( layer->getName() );
if (!layer->getEnabled())
name->setForeColor(osg::Vec4f(1,1,1,0.35));
grid->setControl( gridCol, gridRow, name );
gridCol++;
// layer type
std::string typeName = typeid(*layer).name();
typeName = typeName.substr(typeName.find_last_of(":")+1);
LabelControl* typeLabel = new LabelControl(typeName, osg::Vec4(.5,.7,.5,1));
grid->setControl( gridCol, gridRow, typeLabel );
gridCol++;
// status indicator
LabelControl* statusLabel =
layer->getStatus().isError() ? new LabelControl("[error]", osg::Vec4(1,0,0,1)) :
!layer->getEnabled()? new LabelControl("[disabled]", osg::Vec4(1,1,1,0.35)) :
new LabelControl("[ok]", osg::Vec4(0,1,0,1)) ;
grid->setControl( gridCol, gridRow, statusLabel );
gridCol++;
if (visibleLayer && !elevationLayer && visibleLayer->getEnabled())
{
// an opacity slider
HSliderControl* opacity = new HSliderControl( 0.0f, 1.0f, visibleLayer->getOpacity() );
opacity->setWidth( 125 );
opacity->setHeight( 12 );
opacity->addEventHandler( new LayerOpacityHandler(visibleLayer) );
grid->setControl( gridCol, gridRow, opacity );
}
gridCol++;
// zoom button
if (layer->getExtent().isValid())
{
LabelControl* zoomButton = new LabelControl("GO", 14);
zoomButton->setBackColor( .4,.4,.4,1 );
zoomButton->setActiveColor( .8,0,0,1 );
zoomButton->addEventHandler( new ZoomLayerHandler(layer) );
grid->setControl( gridCol, gridRow, zoomButton );
}
gridCol++;
// move buttons
if ( layerIndex < numLayers-1 && isActive )
{
LabelControl* upButton = new LabelControl( "UP", 14 );
upButton->setBackColor( .4,.4,.4,1 );
upButton->setActiveColor( .8,0,0,1 );
upButton->addEventHandler( new MoveLayerHandler( layer, layerIndex+1 ) );
grid->setControl( gridCol, gridRow, upButton );
}
gridCol++;
if ( layerIndex > 0 && isActive)
{
LabelControl* upButton = new LabelControl( "DOWN", 14 );
upButton->setBackColor( .4,.4,.4,1 );
upButton->setActiveColor( .8,0,0,1 );
upButton->addEventHandler( new MoveLayerHandler( layer, layerIndex-1 ) );
grid->setControl( gridCol, gridRow, upButton );
}
gridCol++;
// add/remove button:
LabelControl* addRemove = new LabelControl( isActive? "REMOVE" : "ADD", 14 );
addRemove->setHorizAlign( Control::ALIGN_CENTER );
addRemove->setBackColor( .4,.4,.4,1 );
addRemove->setActiveColor( .8,0,0,1 );
addRemove->addEventHandler( new RemoveLayerHandler(layer) );
//.........这里部分代码省略.........