Clean up view-number property handling
This commit is contained in:
parent
ae1d96cdfb
commit
00a4f1ecbb
2 changed files with 20 additions and 15 deletions
|
@ -42,7 +42,6 @@ FGViewMgr::FGViewMgr( void ) :
|
||||||
axis_long(0),
|
axis_long(0),
|
||||||
axis_lat(0),
|
axis_lat(0),
|
||||||
inited(false),
|
inited(false),
|
||||||
view_number(fgGetNode("/sim/current-view/view-number", true)),
|
|
||||||
config_list(fgGetNode("/sim", true)->getChildren("view")),
|
config_list(fgGetNode("/sim", true)->getChildren("view")),
|
||||||
current(0)
|
current(0)
|
||||||
{
|
{
|
||||||
|
@ -123,6 +122,8 @@ FGViewMgr::bind()
|
||||||
target_x_offs = fgGetNode("/sim/current-view/target-x-offset-m", true);
|
target_x_offs = fgGetNode("/sim/current-view/target-x-offset-m", true);
|
||||||
target_y_offs = fgGetNode("/sim/current-view/target-y-offset-m", true);
|
target_y_offs = fgGetNode("/sim/current-view/target-y-offset-m", true);
|
||||||
target_z_offs = fgGetNode("/sim/current-view/target-z-offset-m", true);
|
target_z_offs = fgGetNode("/sim/current-view/target-z-offset-m", true);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -131,13 +132,13 @@ FGViewMgr::do_bind()
|
||||||
// these are bound to the current view properties
|
// these are bound to the current view properties
|
||||||
_tiedProperties.setRoot(fgGetNode("/sim/current-view", true));
|
_tiedProperties.setRoot(fgGetNode("/sim/current-view", true));
|
||||||
|
|
||||||
_tiedProperties.Tie("view-number", this,
|
|
||||||
&FGViewMgr::getView, &FGViewMgr::setView);
|
_tiedProperties.Tie("view-number", this,
|
||||||
SGPropertyNode* view_number =
|
&FGViewMgr::getView, &FGViewMgr::setView);
|
||||||
_tiedProperties.getRoot()->getNode("view-number");
|
_viewNumberProp = _tiedProperties.getRoot()->getNode("view-number");
|
||||||
view_number->setAttribute(SGPropertyNode::ARCHIVE, false);
|
_viewNumberProp->setAttribute(SGPropertyNode::ARCHIVE, false);
|
||||||
// Keep view on reset/reinit
|
_viewNumberProp->setAttribute(SGPropertyNode::PRESERVE, true);
|
||||||
view_number->setAttribute(SGPropertyNode::PRESERVE, true);
|
|
||||||
|
|
||||||
_tiedProperties.Tie("axes/long", this,
|
_tiedProperties.Tie("axes/long", this,
|
||||||
(double_getter)0, &FGViewMgr::setViewAxisLong);
|
(double_getter)0, &FGViewMgr::setViewAxisLong);
|
||||||
|
@ -169,8 +170,9 @@ FGViewMgr::unbind ()
|
||||||
}
|
}
|
||||||
|
|
||||||
_tiedProperties.Untie();
|
_tiedProperties.Untie();
|
||||||
|
_viewNumberProp.clear();
|
||||||
|
|
||||||
config_list.clear();
|
config_list.clear();
|
||||||
view_number.clear();
|
|
||||||
target_x_offs.clear();
|
target_x_offs.clear();
|
||||||
target_y_offs.clear();
|
target_y_offs.clear();
|
||||||
target_z_offs.clear();
|
target_z_offs.clear();
|
||||||
|
@ -258,7 +260,7 @@ flightgear::View*
|
||||||
FGViewMgr::next_view()
|
FGViewMgr::next_view()
|
||||||
{
|
{
|
||||||
setView((current+1 < (int)views.size()) ? (current + 1) : 0);
|
setView((current+1 < (int)views.size()) ? (current + 1) : 0);
|
||||||
view_number->fireValueChanged();
|
_viewNumberProp->fireValueChanged();
|
||||||
return views[current];
|
return views[current];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +268,7 @@ flightgear::View*
|
||||||
FGViewMgr::prev_view()
|
FGViewMgr::prev_view()
|
||||||
{
|
{
|
||||||
setView((0 < current) ? (current - 1) : (views.size() - 1));
|
setView((0 < current) ? (current - 1) : (views.size() - 1));
|
||||||
view_number->fireValueChanged();
|
_viewNumberProp->fireValueChanged();
|
||||||
return views[current];
|
return views[current];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,15 +399,18 @@ FGViewMgr::setViewTargetZOffset_m (double z)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int FGViewMgr::getView () const
|
||||||
FGViewMgr::getView () const
|
|
||||||
{
|
{
|
||||||
return ( current );
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGViewMgr::setView (int newview)
|
FGViewMgr::setView (int newview)
|
||||||
{
|
{
|
||||||
|
if (newview == current) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// negative numbers -> set view with node index -newview
|
// negative numbers -> set view with node index -newview
|
||||||
if (newview < 0) {
|
if (newview < 0) {
|
||||||
for (int i = 0; i < (int)config_list.size(); i++) {
|
for (int i = 0; i < (int)config_list.size(); i++) {
|
||||||
|
|
|
@ -117,8 +117,8 @@ private:
|
||||||
double getViewElev_ft() const;
|
double getViewElev_ft() const;
|
||||||
|
|
||||||
bool inited;
|
bool inited;
|
||||||
SGPropertyNode_ptr view_number;
|
|
||||||
std::vector<SGPropertyNode_ptr> config_list;
|
std::vector<SGPropertyNode_ptr> config_list;
|
||||||
|
SGPropertyNode_ptr _viewNumberProp;
|
||||||
typedef std::vector<flightgear::ViewPtr> viewer_list;
|
typedef std::vector<flightgear::ViewPtr> viewer_list;
|
||||||
viewer_list views;
|
viewer_list views;
|
||||||
SGVec3d abs_viewer_position;
|
SGVec3d abs_viewer_position;
|
||||||
|
|
Loading…
Reference in a new issue