Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added setWindowPosition and setWindowName to PCLPlotter #457

Merged
merged 2 commits into from Jan 24, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions visualization/include/pcl/visualization/pcl_plotter.h
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
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