本文整理汇总了C++中ColorLayerRefPtr类的典型用法代码示例。如果您正苦于以下问题:C++ ColorLayerRefPtr类的具体用法?C++ ColorLayerRefPtr怎么用?C++ ColorLayerRefPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ColorLayerRefPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createRightPanelCheckPanel
ComponentRefPtr createRightPanelCheckPanel(void)
{
// Create and edit the CheckBoxes
CheckboxButtonRefPtr RightPanelCheck1 = OSG::CheckboxButton::create();
CheckboxButtonRefPtr RightPanelCheck2 = OSG::CheckboxButton::create();
CheckboxButtonRefPtr RightPanelCheck3 = OSG::CheckboxButton::create();
CheckboxButtonRefPtr RightPanelCheck4 = OSG::CheckboxButton::create();
//NOTE HorizontalAlignment needs to be changed to Alignment only with Vec2f arg
RightPanelCheck1->setText("Show Torus");
RightPanelCheck1->setPreferredSize(Vec2f(125,50));
RightPanelCheck1->setAlignment(0.0);
// Add Listener
RightPanelCheck1->addButtonSelectedListener(&RightPanelCheck1Listener);
RightPanelCheck2->setText("Show Box");
RightPanelCheck2->setPreferredSize(Vec2f(125,50));
RightPanelCheck2->setAlignment(Vec2f (0.5,0.0));
// Add Listener
RightPanelCheck2->addButtonSelectedListener(&RightPanelCheck2Listener);
RightPanelCheck3->setText("Show Sphere");
RightPanelCheck3->setPreferredSize(Vec2f(125,50));
RightPanelCheck3->setAlignment(Vec2f(0.0,0.0));
// Add Listener
RightPanelCheck3->addButtonSelectedListener(&RightPanelCheck3Listener);
RightPanelCheck4->setText("Show Cone");
RightPanelCheck4->setPreferredSize(Vec2f(125,50));
RightPanelCheck4->setAlignment(Vec2f(0.0,0.0));
// Add Listener
RightPanelCheck4->addButtonSelectedListener(&RightPanelCheck4Listener);
// Create an edit Panel Background
ColorLayerRefPtr RightPanelCheckPanelBackground = OSG::ColorLayer::create();
RightPanelCheckPanelBackground->setColor(Color4f(0.93,0.93,0.93,1.0));
// Create and edit Panel layout
BoxLayoutRefPtr RightPanelCheckPanelLayout = OSG::BoxLayout::create();
RightPanelCheckPanelLayout->setOrientation(BoxLayout::VERTICAL_ORIENTATION);
RightPanelCheckPanelLayout->setMinorAxisAlignment(0.5f);
// Create Panel Border
LineBorderRefPtr PanelBorder3 = OSG::LineBorder::create();
PanelBorder3->setColor(Color4f(0.0,0.0,0.0,1.0));
PanelBorder3->setWidth(1);
// Create and edit Panel
PanelRefPtr RightPanelCheckPanel = OSG::Panel::create();
RightPanelCheckPanel->setPreferredSize(Vec2f(200, 300));
RightPanelCheckPanel->pushToChildren(RightPanelCheck1);
RightPanelCheckPanel->pushToChildren(RightPanelCheck2);
RightPanelCheckPanel->pushToChildren(RightPanelCheck3);
RightPanelCheckPanel->pushToChildren(RightPanelCheck4);
RightPanelCheckPanel->setLayout(RightPanelCheckPanelLayout);
RightPanelCheckPanel->setBackgrounds(RightPanelCheckPanelBackground);
RightPanelCheckPanel->setBorders(PanelBorder3);
return RightPanelCheckPanel;
}
示例2: createRightPanelButtonPanel
ComponentRefPtr createRightPanelButtonPanel(void)
{
// Create and edit the Panel Buttons
ToggleButtonRefPtr RightPanelButton1 = OSG::ToggleButton::create();
ToggleButtonRefPtr RightPanelButton2 = OSG::ToggleButton::create();
ToggleButtonRefPtr RightPanelButton3 = OSG::ToggleButton::create();
ToggleButtonRefPtr RightPanelButton4 = OSG::ToggleButton::create();
RightPanelButton1->setText("These");
RightPanelButton1->setPreferredSize(Vec2f(100,50));
RightPanelButton2->setText("are");
RightPanelButton2->setPreferredSize(Vec2f(100,50));
RightPanelButton3->setText("toggle");
RightPanelButton3->setPreferredSize(Vec2f(100,50));
RightPanelButton4->setText("buttons");
RightPanelButton4->setPreferredSize(Vec2f(100,50));
// Create an edit Panel Background
ColorLayerRefPtr RightPanelButtonPanelBackground = OSG::ColorLayer::create();
RightPanelButtonPanelBackground->setColor(Color4f(0.93,0.93,0.93,1.0));
// Create and edit Panel layout
BoxLayoutRefPtr RightPanelButtonPanelLayout = OSG::BoxLayout::create();
RightPanelButtonPanelLayout->setOrientation(BoxLayout::VERTICAL_ORIENTATION);
// Create Panel Border
LineBorderRefPtr PanelBorder2 = OSG::LineBorder::create();
PanelBorder2->setColor(Color4f(0.0,0.0,0.0,1.0));
PanelBorder2->setWidth(1);
// Create and edit Panel
PanelRefPtr RightPanelButtonPanel = OSG::Panel::create();
RightPanelButtonPanel->setPreferredSize(Vec2f(200, 300));
RightPanelButtonPanel->pushToChildren(RightPanelButton1);
RightPanelButtonPanel->pushToChildren(RightPanelButton2);
RightPanelButtonPanel->pushToChildren(RightPanelButton3);
RightPanelButtonPanel->pushToChildren(RightPanelButton4);
RightPanelButtonPanel->setLayout(RightPanelButtonPanelLayout);
RightPanelButtonPanel->setBackgrounds(RightPanelButtonPanelBackground);
RightPanelButtonPanel->setBorders(PanelBorder2);
return RightPanelButtonPanel;
}
示例3: createComplexBackground
LayerRefPtr createComplexBackground(void)
{
// Create complex Background
ColorLayerRefPtr ComplexBackgroundBase = OSG::ColorLayer::create();
GradientLayerRefPtr ComplexBackgroundGradient1 = OSG::GradientLayer::create();
GradientLayerRefPtr ComplexBackgroundGradient2 = OSG::GradientLayer::create();
GradientLayerRefPtr ComplexBackgroundGradient3 = OSG::GradientLayer::create();
CompoundLayerRefPtr ComplexBackgroundCompound1 = OSG::CompoundLayer::create();
CompoundLayerRefPtr ComplexBackgroundCompound2 = OSG::CompoundLayer::create();
CompoundLayerRefPtr ComplexBackground = OSG::CompoundLayer::create();
ComplexBackgroundBase->setColor(Color4f(0.0, 0.0, .25, 1.0));
ComplexBackgroundGradient1->editMFColors()->push_back(Color4f(1.0, 0.0, 0.0, 0.5));
ComplexBackgroundGradient1->editMFStops()->push_back(0.0);
ComplexBackgroundGradient1->editMFColors()->push_back(Color4f(0.5, 0.0, 0.0, 0.3));
ComplexBackgroundGradient1->editMFStops()->push_back(1.0);
ComplexBackgroundGradient1->setStartPosition(Vec2f(0.0f,0.0f));
ComplexBackgroundGradient1->setEndPosition(Vec2f(1.0f,0.0f));
ComplexBackgroundGradient2->editMFColors()->push_back(Color4f(.6, 0.0, 0.3, 1.0));
ComplexBackgroundGradient2->editMFStops()->push_back(0.0);
ComplexBackgroundGradient2->editMFColors()->push_back(Color4f(.2, 0.0, 0.3, 0.5));
ComplexBackgroundGradient2->editMFStops()->push_back(1.0);
ComplexBackgroundGradient2->setStartPosition(Vec2f(0.0f,0.0f));
ComplexBackgroundGradient2->setEndPosition(Vec2f(0.0f,1.0f));
ComplexBackgroundGradient3->editMFColors()->push_back(Color4f(0.0, 0.0, 0.2, 0.2));
ComplexBackgroundGradient3->editMFStops()->push_back(0.0);
ComplexBackgroundGradient3->editMFColors()->push_back(Color4f(0.0, 0.0, 0.2, 0.3));
ComplexBackgroundGradient3->editMFStops()->push_back(1.0);
ComplexBackgroundGradient3->setStartPosition(Vec2f(0.0f,0.0f));
ComplexBackgroundGradient3->setEndPosition(Vec2f(1.0f,0.0f));
ComplexBackgroundCompound1->pushToBackgrounds(ComplexBackgroundBase);
ComplexBackgroundCompound1->pushToBackgrounds(ComplexBackgroundGradient1);
ComplexBackgroundCompound2->pushToBackgrounds(ComplexBackgroundGradient2);
ComplexBackgroundCompound2->pushToBackgrounds(ComplexBackgroundGradient3);
ComplexBackground->pushToBackgrounds(ComplexBackgroundCompound1);
ComplexBackground->pushToBackgrounds(ComplexBackgroundCompound2);
return ComplexBackground;
}
示例4: ComponentTransitPtr
ComponentTransitPtr DefaultTableCellEditor::getTableCellEditorComponent(Table* const table, const boost::any& value, bool isSelected, UInt32 row, UInt32 column)
{
if(value.empty()){
return ComponentTransitPtr(NULL);
}
TextFieldRefPtr TheTextField = TextField::create();
std::string tempString;
try
{
tempString = lexical_cast(value);
}
catch (boost::bad_lexical_cast &)
{
//Could not convert to string
}
TheTextField->setText(tempString);
TheTextField->setPreferredSize(Vec2f(100,30));
TheTextField->setAlignment(Vec2f(0.5,0.5));
TheTextField->selectAll();
TheTextField->setCaretPosition(TheTextField->getText().size());
ColorLayerRefPtr tempBackground;
tempBackground = ColorLayer::create();
TheTextField->setBackground(tempBackground);
//if(isSelected){
// tempBackground->setColor(Color4f(0.4, 0.4, 1.0, 1.0));
//}
//else{
tempBackground->setColor(Color4f(1.0, 1.0, 1.0, 1.0));
//}
LineBorderRefPtr tempBorder;
tempBorder = LineBorder::create();
tempBorder->setColor(Color4f(0.0, 0.0, 1.0, 1.0));
TheTextField->setBorder(tempBorder);
setDefaultStringEditor(TheTextField);
_EditorActionConnection = getDefaultStringEditor()->connectActionPerformed(boost::bind(&DefaultTableCellEditor::handleEditorAction, this, _1));
_EditorFocusLostConnection = getDefaultStringEditor()->connectFocusLost(boost::bind(&DefaultTableCellEditor::handleEditorFocusLost, this, _1));
_EditorKeyPressedConnection = getDefaultStringEditor()->connectKeyPressed(boost::bind(&DefaultTableCellEditor::handleEditorKeyPressed, this, _1));
return ComponentTransitPtr(getDefaultStringEditor());
}
示例5: lexical_cast
OSG_BEGIN_NAMESPACE
/***************************************************************************\
* Description *
\***************************************************************************/
/*! \class OSG::DefaultStringTableCellRenderer
A DefaultStringTableCellRenderer.
*/
/***************************************************************************\
* Class variables *
\***************************************************************************/
/***************************************************************************\
* Class methods *
\***************************************************************************/
/***************************************************************************\
* Instance methods *
\***************************************************************************/
ComponentRefPtr DefaultStringTableCellRenderer::getTableCellRendererComponent(TableRefPtr table, const boost::any& value, bool isSelected, bool hasFocus, UInt32 row, UInt32 column)
{
if(value.empty()){
return NULL;
}
LabelRefPtr TheLabel = Label::create();
std::string tempString;
try
{
tempString = lexical_cast(value);
}
catch (boost::bad_lexical_cast &)
{
//Could not convert to string
}
TheLabel->setText(tempString);
TheLabel->setPreferredSize(Vec2f(100,30));
ColorLayerRefPtr tempBackground;
tempBackground = ColorLayer::create();
TheLabel->setBackgrounds(tempBackground);
if(isSelected){
tempBackground->setColor(Color4f(0.4, 0.4, 1.0, 1.0));
}
else{
tempBackground->setColor(Color4f(1.0, 1.0, 1.0, 1.0));
}
if(hasFocus){
LineBorderRefPtr tempBorder;
tempBorder = LineBorder::create();
TheLabel->setBorders(tempBorder);
tempBorder->setColor(Color4f(0.0, 0.0, 1.0, 1.0));
}
else{
EmptyBorderRefPtr tempBorder;
tempBorder = EmptyBorder::create();
TheLabel->setBorders(tempBorder);
}
return dynamic_pointer_cast<Component>(TheLabel);
}
示例6: main
//.........这里部分代码省略.........
// SpringLayoutConstraints Information
// It is possible to set the constraint for the Y_EDGE, X_EDGE, BASELINE_EDGE, NORTH_EDGE, SOUTH_EDGE, EAST_EDGE, WEST_EDGE, HEIGHT_EDGE, and/or WIDTH_EDGE of a component.
// It is possible to constrain a component's edge x pixels above, below, to the right of, or to the left of the edges other components, frames, and/or the MainInternalWindow.
// It is possible to constrain a component to the Y_EDGE, X_EDGE, BASELINE_EDGE, NORTH_EDGE, SOUTH_EDGE, EAST_EDGE, WEST_EDGE, HORIZONTAL_CENTER_EDGE, VERTICAL_CENTER_EDGE, HEIGHT_EDGE, and/or WIDTH_EDGE of whatever component to which it is constrained.
//Example Button 1
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, ExampleButton1, 25, SpringLayoutConstraints::NORTH_EDGE, MainInternalWindow); // The North edge of ExampleButton1 is 25 pixels below the North edge of the MainInternalWindow.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, ExampleButton1, -5, SpringLayoutConstraints::VERTICAL_CENTER_EDGE, MainInternalWindow); // The South edge of ExampleButton1 is 5 pixels above the Vertical Center of the MainInternalWindow.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, ExampleButton1, -25, SpringLayoutConstraints::EAST_EDGE, MainInternalWindow); // The East edge of ExampleButton1 is 25 pixels to the left of the East edge of the MainInternalWindow.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, ExampleButton1, 25, SpringLayoutConstraints::WEST_EDGE, MainInternalWindow); // The West edge of ExampleButton1 is 25 pixels to the right of the West edge of the MainInternalWindow.
//Example Button 2
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, ExampleButton2, LayoutSpring::height(ExampleButton2)); // The Height edge of ExampleButton2 is set to the height of ExampleButton2.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, ExampleButton2, -25, SpringLayoutConstraints::SOUTH_EDGE, MainInternalWindow); // The South edge of ExampleButton2 is 25 pixels above the South edge of the MainInternalWindow.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, ExampleButton2, -5, SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, MainInternalWindow); // The East edge of ExampleButton2 is 5 pixels to the left of the Horizontal Center of the MainInternalWindow.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, ExampleButton2, 25, SpringLayoutConstraints::WEST_EDGE, MainInternalWindow); // The West edge of ExampleButton2 is 25 pixels to the right of the West edge of the MainInternalWindow.
//Example Button 3
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, ExampleButton3, LayoutSpring::height(ExampleButton3)); // The Height edge of ExampleButton3 is set to the height of ExampleButton3.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, ExampleButton3, -25, SpringLayoutConstraints::SOUTH_EDGE, MainInternalWindow); // The South edge of ExampleButton3 is 25 pixels above the South edge of the MainInternalWindow.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, ExampleButton3, 5, SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, MainInternalWindow); // The West edge of ExampleButton3 is 5 pixels to the right of the Horizontal Center of the MainInternalWindow.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, ExampleButton3, -25, SpringLayoutConstraints::EAST_EDGE, MainInternalWindow); // The East edge of ExampleButton3 is 25 pixels to the left of the East edge of the MainInternalWindow.
//Example Button 4
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, ExampleButton4, 25, SpringLayoutConstraints::SOUTH_EDGE, ExampleButton1); // The North edge of ExampleButton4 is 25 pixels below the South edge of ExampleButton1.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, ExampleButton4, -25, SpringLayoutConstraints::NORTH_EDGE, ExampleButton2); // The South edge of ExampleButton4 is 25 pixels above the North edge of ExampleButton2.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, ExampleButton4, 25, SpringLayoutConstraints::WEST_EDGE, MainInternalWindow); // The West edge of ExampleButton4 is 25 pixels to the right of the West edge of the MainInternalWindow.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, ExampleButton4, -100, SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, MainInternalWindow); // The East edge of ExampleButton4 is 100 pixels to the left of the Horizontal Center of the MainInternalWindow.
//Example Button 5
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, ExampleButton5, 25, SpringLayoutConstraints::SOUTH_EDGE, ExampleButton1); // The North edge of ExampleButton5 is 25 pixels below the South edge of ExampleButton1.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, ExampleButton5, 0, SpringLayoutConstraints::HEIGHT_EDGE, ExampleButton4); // The Height of ExampleButton5 is set to the Height of ExampleButton4.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, ExampleButton5, 75, SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, MainInternalWindow); // The East edge of ExampleButton5 is 75 pixels to the right of the Horizontal Center of the MainInternalWindow.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, ExampleButton5, -75, SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, MainInternalWindow); // The West edge of ExampleButton5 is 75 pixels to the left of the Horizontal Center of the MainInternalWindow.
//Example Button 6
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, ExampleButton6, 25, SpringLayoutConstraints::SOUTH_EDGE, ExampleButton1); // The North edge of ExampleButton6 is 25 pixels below the South edge of ExampleButton1.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, ExampleButton6, -25, SpringLayoutConstraints::NORTH_EDGE, ExampleButton2); // The South edge of ExampleButton6 is 25 pixels above the North edge of ExampleButton2.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, ExampleButton6, 100, SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, MainInternalWindow); // The West edge of ExampleButton6 is 100 pixels to the right of the Horizontal Center of the MainInternalWindow.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::WIDTH_EDGE, ExampleButton6, 0, SpringLayoutConstraints::WIDTH_EDGE, ExampleButton4); // The Width of ExampleButton6 is set to the Width of ExampleButton4.
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
MainInternalWindow->pushToChildren(ExampleButton1);
MainInternalWindow->pushToChildren(ExampleButton2);
MainInternalWindow->pushToChildren(ExampleButton3);
MainInternalWindow->pushToChildren(ExampleButton4);
MainInternalWindow->pushToChildren(ExampleButton5);
MainInternalWindow->pushToChildren(ExampleButton6);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
mgr->setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
// Show the whole Scene
mgr->showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"36SpringLayout");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例7: main
//.........这里部分代码省略.........
ExampleList->setModel(ExampleListModel);
ExampleList->setSelectionModel(ExampleListSelectionModel);
/******************************************************
Determine the SelectionModel
-SINGLE_SELECTION lets you select ONE item
via a single mouse click
-SINGLE_INTERVAL_SELECTION lets you select
one interval via mouse and SHIFT key
-MULTIPLE_INTERVAL_SELECTION lets you select
via mouse, and SHIFT and CONTRL keys
Note: this tutorial is currently set up
to allow for this to be changed via
TogggleButtons with ActionListeners attached
to them so this code is commented out.
******************************************************/
//SelectionModel.setMode(DefaultListSelectionModel::SINGLE_SELECTION);
//SelectionModel.setMode(DefaultListSelectionModel::SINGLE_INTERVAL_SELECTION);
//SelectionModel.setMode(DefaultListSelectionModel::MULTIPLE_INTERVAL_SELECTION);
// Create a ScrollPanel for easier viewing of the List (see 27ScrollPanel)
ScrollPanelRefPtr ExampleScrollPanel = ScrollPanel::create();
ExampleScrollPanel->setPreferredSize(Vec2f(200,300));
ExampleScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
//ExampleScrollPanel->setVerticalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
ExampleScrollPanel->setViewComponent(ExampleList);
// Create MainFramelayout
FlowLayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
MainInternalWindowLayout->setOrientation(FlowLayout::VERTICAL_ORIENTATION);
MainInternalWindowLayout->setMajorAxisAlignment(0.5f);
MainInternalWindowLayout->setMinorAxisAlignment(0.5f);
LabelRefPtr ListLabel = Label::create();
ListLabel->setText("Background Colors List");
ListLabel->setPreferredSize(Vec2f(200.0f, ListLabel->getPreferredSize().y()));
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(ListLabel);
MainInternalWindow->pushToChildren(ExampleScrollPanel);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.7f,0.5f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
mgr->setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
TutorialViewport->setBackground(TheBackground);
// Show the whole Scene
mgr->showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"44MFieldList");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例8: ComponentTransitPtr
OSG_BEGIN_NAMESPACE
/***************************************************************************\
* Description *
\***************************************************************************/
/*! \class OSG::DefaultBoolTableCellRenderer
A DefaultBoolTableCellRenderer.
*/
/***************************************************************************\
* Class variables *
\***************************************************************************/
/***************************************************************************\
* Class methods *
\***************************************************************************/
/***************************************************************************\
* Instance methods *
\***************************************************************************/
ComponentTransitPtr DefaultBoolTableCellRenderer::getTableCellRendererComponent(Table* const table, const boost::any& value, bool isSelected, bool hasFocus, UInt32 row, UInt32 column)
{
if(value.empty()){
return ComponentTransitPtr(NULL);
}
LabelRefPtr TheLabel = Label::create();
std::string tempString;
try
{
if(boost::any_cast<bool>(value))
{
tempString = "True";
}
else
{
tempString = "False";
}
}
catch (boost::bad_any_cast &)
{
//Not a bool
}
TheLabel->setText(tempString);
TheLabel->setPreferredSize(Vec2f(100,30));
ColorLayerRefPtr tempBackground;
tempBackground = ColorLayer::create();
TheLabel->setBackgrounds(tempBackground);
if(isSelected){
tempBackground->setColor(Color4f(0.4, 0.4, 1.0, 1.0));
}
else{
tempBackground->setColor(Color4f(1.0, 1.0, 1.0, 1.0));
}
if(hasFocus){
LineBorderRefPtr tempBorder;
tempBorder = LineBorder::create();
TheLabel->setBorders(tempBorder);
tempBorder->setColor(Color4f(0.0, 0.0, 1.0, 1.0));
}
else{
EmptyBorderRefPtr tempBorder;
tempBorder = EmptyBorder::create();
TheLabel->setBorders(tempBorder);
}
return ComponentTransitPtr(TheLabel.get());
}
示例9: ComponentTransitPtr
ComponentTransitPtr ColorChooserComboBoxComponentGenerator::getComboBoxComponent(ComboBox* const Parent, const boost::any& Value, UInt32 Index, bool IsSelected, bool HasFocus)
{
if(Value.empty()){
return ComponentTransitPtr(NULL);
}
PanelRefPtr TheComponent = Panel::create();//dynamic_pointer_cast<Component>(getDrawObjectPrototype()->shallowCopy());
TheComponent->setLayout(LayoutRefPtr(FlowLayout::create()));
LabelRefPtr theColorLabel = Label::create();
//theColorLabel->setPreferredSize(Vec2f(50.0f,50.0f));
theColorLabel->setBorders(NULL);
try
{
Color4f theColor = boost::any_cast<Color4f>(Value);
if(theColor != NULL)
{
ColorLayerRefPtr theColorLabelBackground = ColorLayer::create();
theColorLabelBackground->setColor(theColor);
theColorLabel->setBackgrounds(theColorLabelBackground);
}
}
catch(boost::bad_any_cast &)
{
std::string ValueString;
try
{
ValueString = lexical_cast(Value);
}
catch (boost::bad_lexical_cast &)
{
//Could not convert to string
SWARNING << "ColorChooserComboBoxComponentGenerator::getComboBoxComponent - The elements should either be a Color4f value or a std::string\n";
}
theColorLabel->setText(ValueString);
if(IsSelected && HasFocus)
{
if(getFocusedTextColorHasPriority())
{
theColorLabel->setTextColors(getFocusedTextColor());
}
else
{
theColorLabel->setTextColors(getSelectedTextColor());
}
}
else if(IsSelected)
{
theColorLabel->setTextColors(getSelectedTextColor());
}
else if(HasFocus)
{
theColorLabel->setTextColors(getFocusedTextColor());
}
}
TheComponent->pushToChildren(theColorLabel);
if(IsSelected && HasFocus)
{
if(getFocusedBorderHasPriority())
{
TheComponent->setBorders(getFocusedBorder());
}
else
{
TheComponent->setBorders(getSelectedBorder());
}
if(getFocusedBackgroundHasPriority())
{
TheComponent->setBackgrounds(getFocusedBackground());
TheComponent->setForegrounds(getFocusedForeground());
}
else
{
TheComponent->setBackgrounds(getSelectedBackground());
TheComponent->setForegrounds(getSelectedForeground());
}
}
else if(IsSelected)
{
TheComponent->setBorders(getSelectedBorder());
TheComponent->setBackgrounds(getSelectedBackground());
TheComponent->setForegrounds(getSelectedForeground());
}
else if(HasFocus)
{
TheComponent->setBorders(getFocusedBorder());
TheComponent->setBackgrounds(getFocusedBackground());
TheComponent->setForegrounds(getFocusedForeground());
}
return ComponentTransitPtr(TheComponent.get());
}
示例10: main
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
// Set up Window
TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
TutorialWindow->setDisplayCallback(display);
TutorialWindow->setReshapeCallback(reshape);
TutorialKeyListener TheKeyListener;
TutorialWindow->addKeyListener(&TheKeyListener);
// Make Torus Node (creates Torus in background of scene)
NodeRefPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);
// Make Main Scene Node and add the Torus
NodeRefPtr scene = OSG::Node::create();
scene->setCore(OSG::Group::create());
scene->addChild(TorusGeometryNode);
// Create the Graphics
GraphicsRefPtr TutorialGraphics = OSG::Graphics2D::create();
// Initialize the LookAndFeelManager to enable default settings
LookAndFeelManager::the()->getLookAndFeel()->init();
/******************************************************
Create some Backgrounds
******************************************************/
ColorLayerRefPtr MainFrameBackground = OSG::ColorLayer::create();
ColorLayerRefPtr ExamplePanelBackground = OSG::ColorLayer::create();
ColorLayerRefPtr ExampleSmallPanelBackground = OSG::ColorLayer::create();
ColorLayerRefPtr ExampleLabel1ColorBackground = OSG::ColorLayer::create();
GradientLayerRefPtr ExampleLabel1GradientBackground = OSG::GradientLayer::create();
CompoundLayerRefPtr ExampleLabel1CompoundBackground = OSG::CompoundLayer::create();
MainFrameBackground->setColor(Color4f(0,0,1.0,0.5));
ExamplePanelBackground->setColor(Color4f(0.0,0.0,0.0,0.5));
ExampleSmallPanelBackground->setColor(Color4f(0.0,0.5,0.7,1.0));
ExampleLabel1ColorBackground->setColor(Color4f(0.0, 0.0, 0.0, 1.0));
ExampleLabel1GradientBackground->editMFColors()->push_back(Color4f(1.0, 0.0, 1.0, 0.8));
ExampleLabel1GradientBackground->editMFStops()->push_back(0.0);
ExampleLabel1GradientBackground->editMFColors()->push_back(Color4f(0.0, 0.0, 1.0, 0.3));
ExampleLabel1GradientBackground->editMFStops()->push_back(1.0);
ExampleLabel1GradientBackground->setStartPosition(Vec2f(0.0f,0.0f));
ExampleLabel1GradientBackground->setEndPosition(Vec2f(1.0f,0.0f));
ExampleLabel1CompoundBackground->pushToBackgrounds(ExampleLabel1ColorBackground);
ExampleLabel1CompoundBackground->pushToBackgrounds(ExampleLabel1GradientBackground);
/******************************************************
Create some Borders
******************************************************/
EtchedBorderRefPtr ExamplePanelBorder = OSG::EtchedBorder::create();
EmptyBorderRefPtr ExampleLabel1Border = OSG::EmptyBorder::create();
ExamplePanelBorder->setHighlight(Color4f(1.0, 1.0, 1.0, 1.0));
ExamplePanelBorder->setShadow(Color4f(0.8, 0.8, 0.8, 1.0));
ExamplePanelBorder->setWidth(6);
/******************************************************
Creates some Button components
******************************************************/
LabelRefPtr ExampleLabel1 = OSG::Label::create();
ButtonRefPtr ExampleButton1 = OSG::Button::create();
ButtonRefPtr ExampleButton2 = OSG::Button::create();
ButtonRefPtr ExampleButton3 = OSG::Button::create();
ButtonRefPtr ExampleButton4 = OSG::Button::create();
ButtonRefPtr ExampleButton5 = OSG::Button::create();
ButtonRefPtr ExampleButton6 = OSG::Button::create();
ButtonRefPtr ExampleButton7 = OSG::Button::create();
ButtonRefPtr ExampleButton8 = OSG::Button::create();
ButtonRefPtr ExampleButton9 = OSG::Button::create();
ButtonRefPtr ExampleButton10 = OSG::Button::create();
ButtonRefPtr ExampleButton11 = OSG::Button::create();
ExampleLabel1->setPreferredSize(Vec2f(800, 50));
ExampleLabel1->setBackground(ExampleLabel1CompoundBackground);
ExampleLabel1->setBorder(ExampleLabel1Border);
ExampleButton1->setPreferredSize(Vec2f(800, 50));
ExampleButton1->setMaxSize(Vec2f(50, 50));
ExampleButton1->setText("Resize the Window to Show Diificulties with Using Just One Layout");
ExampleButton2->setPreferredSize(Vec2f(50, 50));
//.........这里部分代码省略.........
示例11: NumEvents
void GenericFieldContainerEditor::updateProducedEventsPanel(FieldContainer* fc)
{
_ProducedEventsContainer->clearChildren();
UInt32 NumEvents(fc->getNumEvents());
const EventDescription * Desc;
LabelUnrecPtr TheLabel;
ComponentRecPtr TheToolTip;
GridBagLayoutConstraintsRefPtr LayoutConstraints;
UInt32 NumRows(0);
if(NumEvents != 0)
{
BorderLayoutRefPtr TheBorderLayout = BorderLayout::create();
BorderLayoutConstraintsRefPtr WestConstraint = BorderLayoutConstraints::create();
WestConstraint->setRegion(BorderLayoutConstraints::BORDER_WEST);
BorderLayoutConstraintsRefPtr CenterConstraint = BorderLayoutConstraints::create();
CenterConstraint->setRegion(BorderLayoutConstraints::BORDER_CENTER);
//Backgrounds
ColorLayerRefPtr HeaderBgLayer = ColorLayer::create();
HeaderBgLayer->setColor(Color4f(0.7f,0.7f,0.7f,1.0f));
ColorLayerRefPtr LightBgLayer = ColorLayer::create();
LightBgLayer->setColor(Color4f(0.9f,0.9f,0.9f,1.0f));
ColorLayerRefPtr DarkBgLayer = ColorLayer::create();
DarkBgLayer->setColor(Color4f(0.8f,0.8f,0.8f,1.0f));
LabelRecPtr EventsLabel = Label::create();
EventsLabel->setAlignment(Vec2f(0.5f,0.5f));
EventsLabel->setText("Events");
EventsLabel->setBackgrounds(HeaderBgLayer);
EventsLabel->setFont(_BoldFont);
_ProducedEventsContainer->pushToChildren(EventsLabel);
++NumRows;
for(UInt32 i(1) ; i<=NumEvents ; ++i)
{
Desc = fc->getProducerType().getEventDescription(i);
if(Desc != NULL)
{
//Create the Label
TheLabel = Label::create();
TheLabel->setText(Desc->getCName());
TheToolTip = createEventToolTip(Desc);
TheLabel->setToolTip(TheToolTip);
if((i%2) == 0)
{
TheLabel->setBackgrounds(DarkBgLayer);
}
else
{
TheLabel->setBackgrounds(LightBgLayer);
}
_ProducedEventsContainer->pushToChildren(TheLabel);
++NumRows;
}
}
}
//Set the number of rows for the grid layout
dynamic_cast<GridLayout*>(_ProducedEventsContainer->getLayout())->setRows(NumRows);
_ProducedEventsContainer->setPreferredSize(Vec2f(400.0f,
NumRows*24.0f
+ _ProducedEventsContainer->getTopInset()));
}
示例12: main
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
{
// Set up Window
WindowEventProducerRecPtr TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
// Create the SimpleSceneManager helper
SimpleSceneManagerRefPtr sceneManager = SimpleSceneManager::create();
TutorialWindow->setDisplayCallback(boost::bind(display, sceneManager));
TutorialWindow->setReshapeCallback(boost::bind(reshape, _1, sceneManager));
// Tell the Manager what to manage
sceneManager->setWindow(TutorialWindow);
TutorialWindow->connectKeyTyped(boost::bind(keyTyped, _1));
// Make Torus Node (creates Torus in background of scene)
NodeRefPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);
// Make Main Scene Node and add the Torus
NodeRefPtr scene = OSG::Node::create();
scene->setCore(OSG::Group::create());
scene->addChild(TorusGeometryNode);
// Create the Graphics
GraphicsRefPtr TutorialGraphics = OSG::Graphics2D::create();
// Initialize the LookAndFeelManager to enable default settings
LookAndFeelManager::the()->getLookAndFeel()->init();
/******************************************************
Create the Layers.
******************************************************/
ColorLayerRefPtr ExampleColorLayer = OSG::ColorLayer::create();
CompoundLayerRefPtr ExampleCompoundLayer = OSG::CompoundLayer::create();
EmptyLayerRefPtr ExampleEmptyLayer = OSG::EmptyLayer::create();
GradientLayerRefPtr ExampleGradientLayer = OSG::GradientLayer::create();
MaterialLayerRefPtr ExampleMaterialLayer = OSG::MaterialLayer::create();
TextureLayerRefPtr ExampleTextureLayer = OSG::TextureLayer::create();
PatternLayerRefPtr ExamplePatternLayer = OSG::PatternLayer::create();
GlassLayerRefPtr ExampleGlassLayer = OSG::GlassLayer::create();
CompoundLayerRefPtr ExampleGlassCompoundLayer = OSG::CompoundLayer::create();
/******************************************************
The ColorLayer is a simple Layer
having just a Color to it.
-setColor(Color4f): Determine the Color of
the Layer.
******************************************************/
ExampleColorLayer->setColor(Color4f(1.0,0.0,0.0,1.0));
/******************************************************
The CompoundLayer allows you to
combine multiple Backgrounds into one.
The Backgrounds are added sequentially;
so in this example the
ExampleTextureLayer would be added
first, and the ExampleGradientLayer
rendered on top of it.
-getBackgrounds().push_back(BackgroundName):
Adds a Background to the
CompoundBackground.
******************************************************/
ExampleCompoundLayer->pushToBackgrounds(ExampleTextureLayer);
ExampleCompoundLayer->pushToBackgrounds(ExampleGradientLayer);
/******************************************************
The EmptyLayer is a Background
with no attributes.
******************************************************/
// Nothing!
/******************************************************
The GradientLayer is a Background
which displays a gradient of Color.
-getColors().push_back(Color4f): Determines the
starting Color for the gradient.
-getColors().push_back(Color4f): Determines the
ending Color for the gradient.
//.........这里部分代码省略.........
示例13: main
//.........这里部分代码省略.........
// creating a submenu. Note this does not
// involve begin/endEditCPs to do
ExampleSubMenu->addItem(SubMenuItem1);
ExampleSubMenu->addItem(SubMenuItem2);
ExampleSubMenu->addItem(SubMenuItem3);
/******************************************************
Create the PopupMenu itself.
Items are added in the order in which
they will be displayed (top to bottom)
via addItem(ItemToBeAdded)
The PopupMenu is attached to a
Button below using
setPopupMenu(PopupMenuName).
Note: PopupMenus can be added to any
Component.
******************************************************/
PopupMenuRefPtr ExamplePopupMenu = PopupMenu::create();
ExamplePopupMenu->addItem(MenuItem1);
ExamplePopupMenu->addItem(MenuItem2);
ExamplePopupMenu->addItem(MenuItem3);
ExamplePopupMenu->addSeparator();
ExamplePopupMenu->addItem(ExampleSubMenu);
ExamplePopupMenu->addItem(MenuItem4);
// Create a Button and Font
UIFontRefPtr PopupMenuButtonFont = OSG::UIFont::create();
PopupMenuButtonFont->setSize(16);
ButtonRefPtr PopupMenuButton = OSG::Button::create();
PopupMenuButton->setText("RightClickMe!");
// Add the PopupMenu to PopupMenuButton so that when right clicked,
// the PopupMenu will appear
PopupMenuButton->setPopupMenu(ExamplePopupMenu);
PopupMenuButton->setPreferredSize(Vec2f(200,100));
PopupMenuButton->setFont(PopupMenuButtonFont);
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(PopupMenuButton);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
mgr->setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
// Show the whole Scene
mgr->showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"01RubberBandCamera");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例14: main
//.........这里部分代码省略.........
//Editor Field
LabelRecPtr TheTextEditorLabel = Label::create();
TheTextEditorLabel->setText("Text");
TheTextEditorLabel->setPreferredSize(Vec2f(100.0f, 20.0f));
FieldEditorComponentRefPtr TheTextEditor = FieldEditorFactory::the()->createDefaultEditor(EditedLabel,
Label::TextFieldId,
TheCommandManager);
TheTextEditor->setPreferredSize(Vec2f(100.0f, 20.0f));
LabelRecPtr ThePreferredSizeEditorLabel = Label::create();
ThePreferredSizeEditorLabel->setText("PreferredSize");
ThePreferredSizeEditorLabel->setPreferredSize(Vec2f(100.0f, 20.0f));
FieldEditorComponentRefPtr ThePreferredSizeEditor =
FieldEditorFactory::the()->createDefaultEditor(EditedLabel,
Label::PreferredSizeFieldId,
TheCommandManager);
ThePreferredSizeEditor->setPreferredSize(Vec2f(150.0f, 20.0f));
//Editing Panel
LayoutRefPtr EditorPanelLayout = OSG::FlowLayout::create();
PanelRecPtr EditorPanel = Panel::create();
EditorPanel->setPreferredSize(Vec2f(200.0f,200.0f));
EditorPanel->pushToChildren(TheTextEditorLabel);
EditorPanel->pushToChildren(TheTextEditor);
EditorPanel->pushToChildren(ThePreferredSizeEditorLabel);
EditorPanel->pushToChildren(ThePreferredSizeEditor);
EditorPanel->setLayout(EditorPanelLayout);
//Undo Panel
LabelRecPtr UndoPanelLabel = Label::create();
UndoPanelLabel->setText("Undo Panel");
UndoPanelLabel->setPreferredSize(Vec2f(100.0f, 20.0f));
LayoutRefPtr UndoPanelLayout = OSG::FlowLayout::create();
PanelRecPtr UndoPanel = Panel::create();
UndoPanel->setPreferredSize(Vec2f(300.0f,300.0f));
UndoPanel->pushToChildren(UndoPanelLabel);
UndoPanel->pushToChildren(UndoRedoScrollPanel);
UndoPanel->pushToChildren(UndoButton);
UndoPanel->pushToChildren(RedoButton);
UndoPanel->setLayout(UndoPanelLayout);
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
MainInternalWindow->pushToChildren(EditedLabel);
MainInternalWindow->pushToChildren(EditorPanel);
MainInternalWindow->pushToChildren(UndoPanel);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.95f,0.95f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
// Tell the Manager what to manage
sceneManager.setWindow(TutorialWindow);
sceneManager.setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr TutorialViewport = sceneManager.getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
TutorialViewport->setBackground(TutorialBackground);
// Show the whole Scene
sceneManager.showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"02GenericFieldEditor");
//Enter main Loop
TutorialWindow->mainLoop();
}
osgExit();
return 0;
}
示例15: main
//.........这里部分代码省略.........
LabelRefPtr NodeActiveLabel = Label::create();
NodeActiveLabel->setText("Active");
NodeActiveLabel->setPreferredSize(Vec2f(100.0f, 20.0f));
NodeActiveValueLabel = Label::create();
NodeActiveValueLabel->setPreferredSize(Vec2f(300.0f, 20.0f));
//Details Panel
BorderLayoutConstraintsRefPtr NodeDetailPanelConstraints = OSG::BorderLayoutConstraints::create();
NodeDetailPanelConstraints->setRegion(BorderLayoutConstraints::BORDER_SOUTH);
GridLayoutRefPtr NodeDetailPanelLayout = OSG::GridLayout::create();
NodeDetailPanelLayout->setRows(9);
NodeDetailPanelLayout->setColumns(2);
NodeDetailPanelLayout->setHorizontalGap(2);
NodeDetailPanelLayout->setVerticalGap(2);
PanelRefPtr NodeDetailPanel = Panel::create();
NodeDetailPanel->setConstraints(NodeDetailPanelConstraints);
NodeDetailPanel->setPreferredSize(Vec2f(100.0f, 200.0f));
NodeDetailPanel->setLayout(NodeDetailPanelLayout);
NodeDetailPanel->pushToChildren(NodeNameLabel);
NodeDetailPanel->pushToChildren(NodeNameValueLabel);
NodeDetailPanel->pushToChildren(NodeCoreTypeLabel);
NodeDetailPanel->pushToChildren(NodeCoreTypeValueLabel);
NodeDetailPanel->pushToChildren(NodeMinLabel);
NodeDetailPanel->pushToChildren(NodeMinValueLabel);
NodeDetailPanel->pushToChildren(NodeMaxLabel);
NodeDetailPanel->pushToChildren(NodeMaxValueLabel);
NodeDetailPanel->pushToChildren(NodeCenterLabel);
NodeDetailPanel->pushToChildren(NodeCenterValueLabel);
NodeDetailPanel->pushToChildren(NodeTriCountLabel);
NodeDetailPanel->pushToChildren(NodeTriCountValueLabel);
NodeDetailPanel->pushToChildren(NodeTravMaskLabel);
NodeDetailPanel->pushToChildren(NodeTravMaskValueLabel);
NodeDetailPanel->pushToChildren(NodeOcclusionMaskLabel);
NodeDetailPanel->pushToChildren(NodeOcclusionMaskValueLabel);
NodeDetailPanel->pushToChildren(NodeActiveLabel);
NodeDetailPanel->pushToChildren(NodeActiveValueLabel);
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
LayoutRefPtr MainInternalWindowLayout = OSG::BorderLayout::create();
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(ExampleScrollPanel);
MainInternalWindow->pushToChildren(NodeDetailPanel);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(NULL);
MainInternalWindow->setBorders(NULL);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.0f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(1.0,1.0));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
mgr->setRoot(Root);
// Add the UI Foreground Object to the Scene
ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
// Show the whole Scene
mgr->showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"52SceneGraphTree");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}