Skip to content

Commit

Permalink
Merge pull request PointCloudLibrary#457 from billmuch/master
Browse files Browse the repository at this point in the history
added setWindowPosition and setWindowName to PCLPlotter
  • Loading branch information
rbrusu committed Jan 24, 2014
2 parents 669a963 + ce30d7e commit be55434
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
15 changes: 15 additions & 0 deletions visualization/include/pcl/visualization/pcl_plotter.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,19 @@ namespace pcl
void
setWindowSize (int w, int h);

/** \brief Set the position in screen coordinates.
* \param[in] x where to move the window to (X)
* \param[in] y where to move the window to (Y)
*/
void
setWindowPosition (int x, int y);

/** \brief Set the visualizer window name.
* \param[in] name the name of the window
*/
void
setWindowName (const std::string &name);

/** \brief set/get method for the window size.
* \return[in] array containing the width and height of the window
*/
Expand Down Expand Up @@ -392,7 +405,9 @@ namespace pcl
//extra state variables
int current_plot_; //stores the id of the current (most recent) plot, used in automatic coloring and other state change schemes
int win_width_, win_height_;
int win_x_, win_y_; //window position according to screen coordinate
double bkg_color_[3];
std::string win_name_;

//####event callback class####
struct ExitMainLoopTimerCallback : public vtkCommand
Expand Down
25 changes: 23 additions & 2 deletions visualization/src/pcl_plotter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,12 @@ pcl::visualization::PCLPlotter::PCLPlotter (char const *name)
//initializing default state values
win_width_ = 640;
win_height_ = 480;
win_x_ = 0;
win_y_ = 0;
bkg_color_[0] = 1; bkg_color_[1] = 1; bkg_color_[2] = 1;
current_plot_ = -1;
color_series_->SetColorScheme (vtkColorSeries::SPECTRUM);
win_name_ = "PCL Plotter";
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -394,9 +397,12 @@ pcl::visualization::PCLPlotter::plot ()
//apply current states
view_->GetRenderer ()->SetBackground (bkg_color_[0], bkg_color_[1], bkg_color_[2]);
view_->GetRenderWindow ()->SetSize (win_width_, win_height_);

view_->GetRenderWindow ()->SetPosition (win_x_, win_y_);
view_->GetInteractor ()->Initialize ();
view_->GetRenderWindow ()->Render();

//according to vtk bug 976, SetWindowName must be called after RenderWindow Initialize();
view_->GetRenderWindow ()->SetWindowName (win_name_.c_str());
view_->GetRenderWindow ()->Render ();
view_->GetInteractor ()->Start ();
}

Expand Down Expand Up @@ -544,6 +550,21 @@ pcl::visualization::PCLPlotter::getWindowSize ()
return (sz);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void
pcl::visualization::PCLPlotter::setWindowPosition (int x, int y)
{
win_x_ = x;
win_y_ = y;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void
pcl::visualization::PCLPlotter::setWindowName (const std::string &name)
{
win_name_ = name;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
void
pcl::visualization::PCLPlotter::startInteractor ()
Expand Down

0 comments on commit be55434

Please sign in to comment.