示例#1
0
Viewer::Viewer( const QColor4ub& background_color
              , double fov
              , bool z_up
              , bool orthographic
              , boost::optional< comma::csv::options > camera_csv, boost::optional< Eigen::Vector3d > cameraposition
              , boost::optional< Eigen::Vector3d > cameraorientation
              , boost::property_tree::ptree* camera_config
              , boost::optional< Eigen::Vector3d > scene_center
              , boost::optional< double > scene_radius
              , bool output_camera_position )
    : qt3d::view( background_color
                , fov
                , z_up
                , orthographic
                , scene_center ? boost::optional< QVector3D >( QVector3D( scene_center->x()
                                                                        , scene_center->y()
                                                                        , scene_center->z() ) )
                               : boost::optional< QVector3D >()
                , scene_radius )
    , m_lookAt( false )
    , m_cameraposition( cameraposition )
    , m_cameraorientation( cameraorientation )
{
    if( output_camera_position ) { camera_position_output_.reset( new camera_position_output( *this ) ); }
    QTimer* timer = new QTimer( this );
    timer->start( 40 );
    connect( timer, SIGNAL( timeout() ), this, SLOT( read() ) );
    if( camera_csv ) { m_cameraReader.reset( new CameraReader( *camera_csv ) ); }
    if( camera_config )
    {
        comma::from_ptree from_ptree( *camera_config, true );
        comma::visiting::apply( from_ptree ).to( *camera() );
        //boost::property_tree::ptree p;
        //comma::to_ptree to_ptree( p );
        //comma::visiting::apply( to_ptree ).to( *camera() );
        //std::cerr << "view-points: camera set to:" << std::endl;
        //boost::property_tree::write_json( std::cerr, p );
    }
    m_cameraFixed = m_cameraposition || m_cameraReader || camera_config;
}