SplatCloudRenderingControlPlugin.cc 43.9 KB
Newer Older
1 2 3 4 5
//================================================================
//
/*===========================================================================*\
*                                                                            *
*                              OpenFlipper                                   *
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
 *           Copyright (c) 2001-2015, RWTH-Aachen University                 *
 *           Department of Computer Graphics and Multimedia                  *
 *                          All rights reserved.                             *
 *                            www.openflipper.org                            *
 *                                                                           *
 *---------------------------------------------------------------------------*
 * This file is part of OpenFlipper.                                         *
 *---------------------------------------------------------------------------*
 *                                                                           *
 * Redistribution and use in source and binary forms, with or without        *
 * modification, are permitted provided that the following conditions        *
 * are met:                                                                  *
 *                                                                           *
 * 1. Redistributions of source code must retain the above copyright notice, *
 *    this list of conditions and the following disclaimer.                  *
 *                                                                           *
 * 2. Redistributions in binary form must reproduce the above copyright      *
 *    notice, this list of conditions and the following disclaimer in the    *
 *    documentation and/or other materials provided with the distribution.   *
 *                                                                           *
 * 3. Neither the name of the copyright holder nor the names of its          *
 *    contributors may be used to endorse or promote products derived from   *
 *    this software without specific prior written permission.               *
 *                                                                           *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS       *
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A           *
 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,  *
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,       *
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR        *
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    *
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING      *
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS        *
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              *
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
*                                                                            *
\*===========================================================================*/


//================================================================
//
//  CLASS SplatCloudRenderingControlPlugin - IMPLEMENTATION
//
//================================================================


//== INCLUDES ====================================================


#include "SplatCloudRenderingControlPlugin.hh"

#include <OpenFlipper/BasePlugin/PluginFunctions.hh>

#include <ObjectTypes/SplatCloud/SplatCloud.hh>

#include <OpenFlipper/common/GlobalOptions.hh>

63 64 65 66 67 68 69 70
#include <QHBoxLayout>
#include <QPushButton>
#include <QRadioButton>
#include <QLabel>
#include <QMenu>
#include <QTabWidget>


71 72 73 74

//== IMPLEMENTATION ==============================================


75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
SplatCloudRenderingControlPlugin::SplatCloudRenderingControlPlugin() :
  toolboxPointsizeScale_  ( 0 ),
  toolboxDefaultColorR_   ( 0 ),
  toolboxDefaultColorG_   ( 0 ),
  toolboxDefaultColorB_   ( 0 ),
  toolboxDefaultNormalX_  ( 0 ),
  toolboxDefaultNormalY_  ( 0 ),
  toolboxDefaultNormalZ_  ( 0 ),
  toolboxDefaultPointsize_( 0 ),
  contextScaleAction_        ( 0 ),
  contextCullingAction_      ( 0 ),
  contextDefaultsAction_     ( 0 ),
  contextReloadShadersAction_( 0 ),
  contextRebuildVBOAction_   ( 0 ),
  contextScaleWidget_              ( 0 ),
  contextScaleWidgetPointsizeScale_( 0 ),
  contextDefaultsWidget_                ( 0 ),
  contextDefaultsWidgetDefaultColorR_   ( 0 ),
  contextDefaultsWidgetDefaultColorG_   ( 0 ),
  contextDefaultsWidgetDefaultColorB_   ( 0 ),
  contextDefaultsWidgetDefaultNormalX_  ( 0 ),
  contextDefaultsWidgetDefaultNormalY_  ( 0 ),
  contextDefaultsWidgetDefaultNormalZ_  ( 0 ),
  contextDefaultsWidgetDefaultPointsize_( 0 )
Jan Möbius's avatar
Jan Möbius committed
99 100 101 102 103 104 105
{
}


//----------------------------------------------------------------


106 107
void SplatCloudRenderingControlPlugin::initializePlugin()
{
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
  // --------------------------------
  // -------- create toolbox --------
  // --------------------------------

  // ---- options tab ----

  // pointsize scale
  toolboxPointsizeScale_ = new QDoubleSpinBox();
  toolboxPointsizeScale_->setRange( 0.0, 100.0 );
  toolboxPointsizeScale_->setDecimals( 4 );
  toolboxPointsizeScale_->setSingleStep( 0.1 );
  toolboxPointsizeScale_->setValue( 1.0 );
  toolboxPointsizeScale_->setToolTip( "The scaling factor of the pointsizes used during the rendering of objects" );

  // pointsize scale layout
  QHBoxLayout *toolboxPointsizeScaleLayout = new QHBoxLayout();
  toolboxPointsizeScaleLayout->setSpacing( 6 );
  toolboxPointsizeScaleLayout->addWidget( new QLabel( "Pointsize Scaling Factor:" ) );
  toolboxPointsizeScaleLayout->addWidget( toolboxPointsizeScale_                    );

  // buttons
129 130 131 132 133 134
  QPushButton  *toolboxEnableBackfaceCullingButton  = new QPushButton ( "Enable Backface Culling"  );
  QPushButton  *toolboxDisableBackfaceCullingButton = new QPushButton ( "Disable Backface Culling" );
  QPushButton  *toolboxReloadShadersButton          = new QPushButton ( "Reload Shaders"           );
  QPushButton  *toolboxRebuildVBOsButton            = new QPushButton ( "Rebuild VBOs"             );
  QRadioButton *toolboxPointSizeButton              = new QRadioButton( "Use gl_PointSize"         );
  QRadioButton *toolboxGeometryShaderButton         = new QRadioButton( "Use Geometry Shader"      );
135 136 137 138
  toolboxEnableBackfaceCullingButton->setToolTip ( "Enable the culling of backfaces"       );
  toolboxDisableBackfaceCullingButton->setToolTip( "Disable the culling of backfaces"      );
  toolboxReloadShadersButton->setToolTip         ( "Reload all shader files"           );
  toolboxRebuildVBOsButton->setToolTip           ( "Rebuild all vertex-buffer-objects" );
139 140 141 142
  toolboxPointSizeButton->setToolTip             ( "Set gl_PointSize in vertex shader" );
  toolboxGeometryShaderButton->setToolTip        ( "Create quads in geometry shader"   );

  toolboxPointSizeButton->setChecked(true);
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160

  // buttonsA layout
  QHBoxLayout *toolboxButtonsALayout = new QHBoxLayout();
  toolboxButtonsALayout->setSpacing( 6 );
  toolboxButtonsALayout->addWidget( toolboxEnableBackfaceCullingButton  );
  toolboxButtonsALayout->addWidget( toolboxDisableBackfaceCullingButton );

  // separator frame
  QFrame *toolboxSeparatorFrame = new QFrame();
  toolboxSeparatorFrame->setFrameShape( QFrame::HLine );
  toolboxSeparatorFrame->setFrameShadow( QFrame::Sunken );

  // buttonsB layout
  QHBoxLayout *toolboxButtonsBLayout = new QHBoxLayout();
  toolboxButtonsBLayout->setSpacing( 6 );
  toolboxButtonsBLayout->addWidget( toolboxReloadShadersButton );
  toolboxButtonsBLayout->addWidget( toolboxRebuildVBOsButton   );

161 162 163 164 165 166 167 168 169 170 171
  // separator frame
  QFrame *toolboxSeparatorFrameBC = new QFrame();
  toolboxSeparatorFrameBC->setFrameShape(QFrame::HLine);
  toolboxSeparatorFrameBC->setFrameShadow(QFrame::Sunken);

  // buttonsC layout
  QHBoxLayout *toolboxButtonsCLayout = new QHBoxLayout();
  toolboxButtonsCLayout->setSpacing(6);
  toolboxButtonsCLayout->addWidget(toolboxPointSizeButton);
  toolboxButtonsCLayout->addWidget(toolboxGeometryShaderButton);

172 173 174 175 176 177 178 179 180
  // options layout
  QVBoxLayout *toolboxOptionsLayout = new QVBoxLayout();
  toolboxOptionsLayout->setAlignment( Qt::AlignTop );
  toolboxOptionsLayout->setSpacing( 6 );
  toolboxOptionsLayout->addItem  ( toolboxPointsizeScaleLayout );
  toolboxOptionsLayout->addItem  ( toolboxButtonsALayout       );
  toolboxOptionsLayout->addItem  ( new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding ) );
  toolboxOptionsLayout->addWidget( toolboxSeparatorFrame       );
  toolboxOptionsLayout->addItem  ( toolboxButtonsBLayout       );
181 182 183
  toolboxOptionsLayout->addItem  ( new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding ) );
  toolboxOptionsLayout->addWidget( toolboxSeparatorFrameBC       );
  toolboxOptionsLayout->addItem  ( toolboxButtonsCLayout       );
184 185 186 187 188

  // options widget
  QWidget *toolboxOptionsWidget = new QWidget();
  toolboxOptionsWidget->setLayout( toolboxOptionsLayout );
  toolboxOptionsWidget->setToolTip( "Rendering options" );
189
  
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
  // ---- defaults tab ----

  // default color
  toolboxDefaultColorR_ = new QSpinBox();
  toolboxDefaultColorG_ = new QSpinBox();
  toolboxDefaultColorB_ = new QSpinBox();
  toolboxDefaultColorR_->setRange( 0, 255 );
  toolboxDefaultColorG_->setRange( 0, 255 );
  toolboxDefaultColorB_->setRange( 0, 255 );
  toolboxDefaultColorR_->setSingleStep( 1 );
  toolboxDefaultColorG_->setSingleStep( 1 );
  toolboxDefaultColorB_->setSingleStep( 1 );
  toolboxDefaultColorR_->setValue( 255 );
  toolboxDefaultColorG_->setValue( 255 );
  toolboxDefaultColorB_->setValue( 255 );
  toolboxDefaultColorR_->setToolTip( "The default red-component of the color used when an object has no colors"   );
  toolboxDefaultColorG_->setToolTip( "The default green-component of the color used when an object has no colors" );
  toolboxDefaultColorB_->setToolTip( "The default blue-component of the color used when an object has no colors"  );

  // default normal
  toolboxDefaultNormalX_ = new QDoubleSpinBox();
  toolboxDefaultNormalY_ = new QDoubleSpinBox();
  toolboxDefaultNormalZ_ = new QDoubleSpinBox();
  toolboxDefaultNormalX_->setRange( -1.0, 1.0 );
  toolboxDefaultNormalY_->setRange( -1.0, 1.0 );
  toolboxDefaultNormalZ_->setRange( -1.0, 1.0 );
  toolboxDefaultNormalX_->setDecimals( 2 );
  toolboxDefaultNormalY_->setDecimals( 2 );
  toolboxDefaultNormalZ_->setDecimals( 2 );
  toolboxDefaultNormalX_->setSingleStep( 0.1 );
  toolboxDefaultNormalY_->setSingleStep( 0.1 );
  toolboxDefaultNormalZ_->setSingleStep( 0.1 );
  toolboxDefaultNormalX_->setValue( 0.0 );
  toolboxDefaultNormalY_->setValue( 0.0 );
  toolboxDefaultNormalZ_->setValue( 1.0 );
  toolboxDefaultNormalX_->setToolTip( "The default x-component of the normal used when an object has no normals" );
  toolboxDefaultNormalY_->setToolTip( "The default y-component of the normal used when an object has no normals" );
  toolboxDefaultNormalZ_->setToolTip( "The default z-component of the normal used when an object has no normals" );

  // default pointsize
  toolboxDefaultPointsize_ = new QDoubleSpinBox();
  toolboxDefaultPointsize_->setRange( 0.0, 1000.0 );
  toolboxDefaultPointsize_->setDecimals( 3 );
  toolboxDefaultPointsize_->setSingleStep( 0.01 );
  toolboxDefaultPointsize_->setValue( 0.1 );
  toolboxDefaultPointsize_->setToolTip( "The default pointsize used when an object has no pointsizes" );

  // default color layout
  QHBoxLayout *toolboxDefaultColorLayout = new QHBoxLayout();
  toolboxDefaultColorLayout->setSpacing( 6 );
  toolboxDefaultColorLayout->addWidget( toolboxDefaultColorR_ );
  toolboxDefaultColorLayout->addWidget( toolboxDefaultColorG_ );
  toolboxDefaultColorLayout->addWidget( toolboxDefaultColorB_ );

  // default normal layout
  QHBoxLayout *toolboxDefaultNormalLayout = new QHBoxLayout();
  toolboxDefaultNormalLayout->setSpacing( 6 );
  toolboxDefaultNormalLayout->addWidget( toolboxDefaultNormalX_ );
  toolboxDefaultNormalLayout->addWidget( toolboxDefaultNormalY_ );
  toolboxDefaultNormalLayout->addWidget( toolboxDefaultNormalZ_ );

  // default pointsize layout
  QHBoxLayout *toolboxDefaultPointsizeLayout = new QHBoxLayout();
  toolboxDefaultPointsizeLayout->setSpacing( 6 );
  toolboxDefaultPointsizeLayout->addWidget( toolboxDefaultPointsize_ );

  // default options layout
  QGridLayout *toolboxDefaultsLayout = new QGridLayout();
  toolboxDefaultsLayout->setSpacing( 6 );
  toolboxDefaultsLayout->addWidget( new QLabel( "Default Color:"     ), 0, 0 );
  toolboxDefaultsLayout->addWidget( new QLabel( "Default Normal:"    ), 1, 0 );
  toolboxDefaultsLayout->addWidget( new QLabel( "Default Pointsize:" ), 2, 0 );
  toolboxDefaultsLayout->addItem  ( toolboxDefaultColorLayout,          0, 1 );
  toolboxDefaultsLayout->addItem  ( toolboxDefaultNormalLayout,         1, 1 );
  toolboxDefaultsLayout->addItem  ( toolboxDefaultPointsizeLayout,      2, 1 );

  // defaults widget
  QWidget *toolboxDefaultsWidget = new QWidget();
  toolboxDefaultsWidget->setLayout( toolboxDefaultsLayout );
  toolboxDefaultsWidget->setToolTip( "Default values" );

  // ----

  // tab widget
  QTabWidget *toolboxTabWidget = new QTabWidget();
  toolboxTabWidget->addTab( toolboxOptionsWidget,  "Options"  );
  toolboxTabWidget->addTab( toolboxDefaultsWidget, "Defaults" );

  // toolbox layout
  QVBoxLayout *toolboxLayout = new QVBoxLayout();
  toolboxLayout->setSpacing( 6 );
  toolboxLayout->addWidget( toolboxTabWidget );

  // toolbox
  QWidget *toolbox = new QWidget();
  toolbox->setLayout( toolboxLayout );

  // toolbox icon
  QIcon *toolboxIcon = new QIcon( OpenFlipper::Options::iconDirStr() + OpenFlipper::Options::dirSeparator() + "SplatCloudRenderingControl.png" );

  // ----

  // connect events to slots
  connect( toolboxPointsizeScale_,              SIGNAL( valueChanged(double) ), this, SLOT( slotToolboxPointsizeScaleValueChanged()          ) );
  connect( toolboxDefaultColorR_,               SIGNAL( valueChanged(int)    ), this, SLOT( slotToolboxDefaultColorValueChanged()            ) );
  connect( toolboxDefaultColorG_,               SIGNAL( valueChanged(int)    ), this, SLOT( slotToolboxDefaultColorValueChanged()            ) );
  connect( toolboxDefaultColorB_,               SIGNAL( valueChanged(int)    ), this, SLOT( slotToolboxDefaultColorValueChanged()            ) );
  connect( toolboxDefaultNormalX_,              SIGNAL( valueChanged(double) ), this, SLOT( slotToolboxDefaultNormalValueChanged()           ) );
  connect( toolboxDefaultNormalY_,              SIGNAL( valueChanged(double) ), this, SLOT( slotToolboxDefaultNormalValueChanged()           ) );
  connect( toolboxDefaultNormalZ_,              SIGNAL( valueChanged(double) ), this, SLOT( slotToolboxDefaultNormalValueChanged()           ) );
  connect( toolboxDefaultPointsize_,            SIGNAL( valueChanged(double) ), this, SLOT( slotToolboxDefaultPointsizeValueChanged()        ) );

  connect( toolboxEnableBackfaceCullingButton,  SIGNAL( clicked()            ), this, SLOT( slotToolboxEnableBackfaceCullingButtonClicked()  ) );
  connect( toolboxDisableBackfaceCullingButton, SIGNAL( clicked()            ), this, SLOT( slotToolboxDisableBackfaceCullingButtonClicked() ) );
  connect( toolboxReloadShadersButton,          SIGNAL( clicked()            ), this, SLOT( slotToolboxReloadShadersButtonClicked()          ) );
  connect( toolboxRebuildVBOsButton,            SIGNAL( clicked()            ), this, SLOT( slotToolboxRebuildVBOsButtonClicked()            ) );
306 307
  connect( toolboxPointSizeButton,              SIGNAL( toggled(bool)        ), this, SLOT( slotToolboxPointSizeButtonClicked()              ) );
  connect( toolboxGeometryShaderButton,         SIGNAL( toggled(bool)        ), this, SLOT( slotToolboxGeometryShaderButtonClicked()         ) );
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342

  // emit signal to add the new toolbox
  emit addToolbox( tr("SplatCloud Rendering Control") , toolbox , toolboxIcon );

  // -------------------------------------
  // -------- create context menu --------
  // -------------------------------------

  // actions
  contextScaleAction_         = new QAction( tr( "Pointsize Scaling Factor..."), this );
  contextCullingAction_       = new QAction( tr( "Backface Culling"           ), this );
  contextDefaultsAction_      = new QAction( tr( "Defaults..."                ), this );
  contextReloadShadersAction_ = new QAction( tr( "Reload Shaders"             ), this );
  contextRebuildVBOAction_    = new QAction( tr( "Rebuild VBO"                ), this );
  contextCullingAction_->setCheckable( true );

  // context menu
  QMenu *contextMenu = new QMenu( "SplatCloud Rendering Control" );
  contextMenu->setIcon( QIcon( OpenFlipper::Options::iconDirStr() + OpenFlipper::Options::dirSeparator() + "SplatCloudRenderingControl.png" ) );
  contextMenu->addAction( contextScaleAction_         );
  contextMenu->addAction( contextCullingAction_       );
  contextMenu->addSeparator();
  contextMenu->addAction( contextDefaultsAction_      );
  contextMenu->addSeparator();
  contextMenu->addAction( contextReloadShadersAction_ );
  contextMenu->addAction( contextRebuildVBOAction_    );

  // ----

  // connect events to slots
  connect( contextScaleAction_,         SIGNAL( triggered() ), this, SLOT( slotContextScaleActionTriggered()         ) );
  connect( contextCullingAction_,       SIGNAL( triggered() ), this, SLOT( slotContextCullingActionTriggered()       ) );
  connect( contextDefaultsAction_,      SIGNAL( triggered() ), this, SLOT( slotContextDefaultsActionTriggered()      ) );
  connect( contextReloadShadersAction_, SIGNAL( triggered() ), this, SLOT( slotContextReloadShadersActionTriggered() ) );
  connect( contextRebuildVBOAction_,    SIGNAL( triggered() ), this, SLOT( slotContextRebuildVBOActionTriggered()    ) );
343
  
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546
  // emit signal to add the new context menu
  emit addContextMenuItem( contextMenu->menuAction(), DATA_SPLATCLOUD, CONTEXTOBJECTMENU );

  // --------------------------------------------------
  // -------- create context menu scale widget --------
  // --------------------------------------------------

  // pointsize scale
  contextScaleWidgetPointsizeScale_ = new QDoubleSpinBox();
  contextScaleWidgetPointsizeScale_->setRange( 0.0, 100.0 );
  contextScaleWidgetPointsizeScale_->setDecimals( 4 );
  contextScaleWidgetPointsizeScale_->setSingleStep( 0.1 );
  contextScaleWidgetPointsizeScale_->setToolTip( "The scaling factor of the pointsizes used during the rendering of the picked object" );

  // pointsize scale layout
  QHBoxLayout *contextScaleWidgetPointsizeScaleLayout = new QHBoxLayout();
  contextScaleWidgetPointsizeScaleLayout->setSpacing( 6 );
  contextScaleWidgetPointsizeScaleLayout->addWidget( new QLabel( "Pointsize Scaling Factor:" ) );
  contextScaleWidgetPointsizeScaleLayout->addWidget( contextScaleWidgetPointsizeScale_         );

  // widget layout
  QVBoxLayout *contextScaleWidgetLayout = new QVBoxLayout();
  contextScaleWidgetLayout->setAlignment( Qt::AlignTop );
  contextScaleWidgetLayout->setSpacing( 6 );
  contextScaleWidgetLayout->addItem( contextScaleWidgetPointsizeScaleLayout );

  // widget
  contextScaleWidget_ = new QWidget();
  contextScaleWidget_->setWindowTitle( "Pointsize Scaling Factor" );
  contextScaleWidget_->setLayout( contextScaleWidgetLayout );

  // ----

  // connect events to slots
  connect( contextScaleWidgetPointsizeScale_, SIGNAL( valueChanged(double) ), this, SLOT( slotContextScaleWidgetPointsizeScaleValueChanged() ) );

  // -----------------------------------------------------
  // -------- create context menu defaults widget --------
  // -----------------------------------------------------

  // default color
  contextDefaultsWidgetDefaultColorR_ = new QSpinBox();
  contextDefaultsWidgetDefaultColorG_ = new QSpinBox();
  contextDefaultsWidgetDefaultColorB_ = new QSpinBox();
  contextDefaultsWidgetDefaultColorR_->setRange( 0, 255 );
  contextDefaultsWidgetDefaultColorG_->setRange( 0, 255 );
  contextDefaultsWidgetDefaultColorB_->setRange( 0, 255 );
  contextDefaultsWidgetDefaultColorR_->setSingleStep( 1 );
  contextDefaultsWidgetDefaultColorG_->setSingleStep( 1 );
  contextDefaultsWidgetDefaultColorB_->setSingleStep( 1 );
  contextDefaultsWidgetDefaultColorR_->setToolTip( "The default red-component of the color used when the picked object has no colors"   );
  contextDefaultsWidgetDefaultColorG_->setToolTip( "The default green-component of the color used when the picked object has no colors" );
  contextDefaultsWidgetDefaultColorB_->setToolTip( "The default blue-component of the color used when the picked object has no colors"  );

  // default normal
  contextDefaultsWidgetDefaultNormalX_ = new QDoubleSpinBox();
  contextDefaultsWidgetDefaultNormalY_ = new QDoubleSpinBox();
  contextDefaultsWidgetDefaultNormalZ_ = new QDoubleSpinBox();
  contextDefaultsWidgetDefaultNormalX_->setRange( -1.0, 1.0 );
  contextDefaultsWidgetDefaultNormalY_->setRange( -1.0, 1.0 );
  contextDefaultsWidgetDefaultNormalZ_->setRange( -1.0, 1.0 );
  contextDefaultsWidgetDefaultNormalX_->setDecimals( 2 );
  contextDefaultsWidgetDefaultNormalY_->setDecimals( 2 );
  contextDefaultsWidgetDefaultNormalZ_->setDecimals( 2 );
  contextDefaultsWidgetDefaultNormalX_->setSingleStep( 0.1 );
  contextDefaultsWidgetDefaultNormalY_->setSingleStep( 0.1 );
  contextDefaultsWidgetDefaultNormalZ_->setSingleStep( 0.1 );
  contextDefaultsWidgetDefaultNormalX_->setToolTip( "The default x-component of the normal used when the picked object has no normals" );
  contextDefaultsWidgetDefaultNormalY_->setToolTip( "The default y-component of the normal used when the picked object has no normals" );
  contextDefaultsWidgetDefaultNormalZ_->setToolTip( "The default z-component of the normal used when the picked object has no normals" );

  // default pointsize
  contextDefaultsWidgetDefaultPointsize_ = new QDoubleSpinBox();
  contextDefaultsWidgetDefaultPointsize_->setRange( 0.0, 1000.0 );
  contextDefaultsWidgetDefaultPointsize_->setDecimals( 3 );
  contextDefaultsWidgetDefaultPointsize_->setSingleStep( 0.01 );
  contextDefaultsWidgetDefaultPointsize_->setToolTip( "The default pointsize used when the picked object has no pointsizes" );

  // default color layout
  QHBoxLayout *contextDefaultsWidgetDefaultColorLayout = new QHBoxLayout();
  contextDefaultsWidgetDefaultColorLayout->setSpacing( 6 );
  contextDefaultsWidgetDefaultColorLayout->addWidget( contextDefaultsWidgetDefaultColorR_ );
  contextDefaultsWidgetDefaultColorLayout->addWidget( contextDefaultsWidgetDefaultColorG_ );
  contextDefaultsWidgetDefaultColorLayout->addWidget( contextDefaultsWidgetDefaultColorB_ );

  // default normal layout
  QHBoxLayout *contextDefaultsWidgetDefaultNormalLayout = new QHBoxLayout();
  contextDefaultsWidgetDefaultNormalLayout->setSpacing( 6 );
  contextDefaultsWidgetDefaultNormalLayout->addWidget( contextDefaultsWidgetDefaultNormalX_ );
  contextDefaultsWidgetDefaultNormalLayout->addWidget( contextDefaultsWidgetDefaultNormalY_ );
  contextDefaultsWidgetDefaultNormalLayout->addWidget( contextDefaultsWidgetDefaultNormalZ_ );

  // default pointsize layout
  QHBoxLayout *contextDefaultsWidgetDefaultPointsizeLayout = new QHBoxLayout();
  contextDefaultsWidgetDefaultPointsizeLayout->setSpacing( 6 );
  contextDefaultsWidgetDefaultPointsizeLayout->addWidget( contextDefaultsWidgetDefaultPointsize_ );

  // default options layout
  QGridLayout *contextDefaultsWidgetDefaultOptionsLayout = new QGridLayout();
  contextDefaultsWidgetDefaultOptionsLayout->setSpacing( 6 );
  contextDefaultsWidgetDefaultOptionsLayout->addWidget( new QLabel( "Default Color:"     ),          0, 0 );
  contextDefaultsWidgetDefaultOptionsLayout->addWidget( new QLabel( "Default Normal:"    ),          1, 0 );
  contextDefaultsWidgetDefaultOptionsLayout->addWidget( new QLabel( "Default Pointsize:" ),          2, 0 );
  contextDefaultsWidgetDefaultOptionsLayout->addItem  ( contextDefaultsWidgetDefaultColorLayout,     0, 1 );
  contextDefaultsWidgetDefaultOptionsLayout->addItem  ( contextDefaultsWidgetDefaultNormalLayout,    1, 1 );
  contextDefaultsWidgetDefaultOptionsLayout->addItem  ( contextDefaultsWidgetDefaultPointsizeLayout, 2, 1 );

  // widget layout
  QVBoxLayout *contextDefaultsWidgetLayout = new QVBoxLayout();
  contextDefaultsWidgetLayout->setAlignment( Qt::AlignTop );
  contextDefaultsWidgetLayout->setSpacing( 6 );
  contextDefaultsWidgetLayout->addItem( contextDefaultsWidgetDefaultOptionsLayout );

  // widget
  contextDefaultsWidget_ = new QWidget();
  contextDefaultsWidget_->setWindowTitle( "Defaults" );
  contextDefaultsWidget_->setLayout( contextDefaultsWidgetLayout );

  // ----

  // connect events to slots
  connect( contextDefaultsWidgetDefaultColorR_,    SIGNAL( valueChanged(int)    ), this, SLOT( slotContextDefaultsWidgetDefaultColorValueChanged()     ) );
  connect( contextDefaultsWidgetDefaultColorG_,    SIGNAL( valueChanged(int)    ), this, SLOT( slotContextDefaultsWidgetDefaultColorValueChanged()     ) );
  connect( contextDefaultsWidgetDefaultColorB_,    SIGNAL( valueChanged(int)    ), this, SLOT( slotContextDefaultsWidgetDefaultColorValueChanged()     ) );
  connect( contextDefaultsWidgetDefaultNormalX_,   SIGNAL( valueChanged(double) ), this, SLOT( slotContextDefaultsWidgetDefaultNormalValueChanged()    ) );
  connect( contextDefaultsWidgetDefaultNormalY_,   SIGNAL( valueChanged(double) ), this, SLOT( slotContextDefaultsWidgetDefaultNormalValueChanged()    ) );
  connect( contextDefaultsWidgetDefaultNormalZ_,   SIGNAL( valueChanged(double) ), this, SLOT( slotContextDefaultsWidgetDefaultNormalValueChanged()    ) );
  connect( contextDefaultsWidgetDefaultPointsize_, SIGNAL( valueChanged(double) ), this, SLOT( slotContextDefaultsWidgetDefaultPointsizeValueChanged() ) );

  // ----------------------------------
  // -------- create view mode --------
  // ----------------------------------

  // toolboxes
  QStringList viewModeToolboxes;
  viewModeToolboxes += "Data Control";
  viewModeToolboxes += "Selections";
  viewModeToolboxes += "SplatCloud Estimator";
  viewModeToolboxes += "SplatCloud Rendering Control";

  // toolbars
  QStringList viewModeToolbars;
  viewModeToolbars += "Main Toolbar";
  viewModeToolbars += "Viewer Toolbar";
  viewModeToolbars += "Color Toolbar";
  viewModeToolbars += "Viewing Directions";
  viewModeToolbars += "Selection Base";
  viewModeToolbars += "Backup Toolbar";

  // context menus
  QStringList viewModeContextMenus;
  viewModeContextMenus += "DataControl->Material Properties";
  viewModeContextMenus += "DataControl->Object";
  viewModeContextMenus += "SplatCloudEstimatorPlugin->SplatCloud Estimator";
  viewModeContextMenus += "SplatCloudRenderingControlPlugin->SplatCloud Rendering Control";
  viewModeContextMenus += "ViewControl->Visualization";
  viewModeContextMenus += "Backup->&Redo";
  viewModeContextMenus += "Backup->&Undo";

  // emit signals to add new viewmode
  emit defineViewModeToolboxes   ( "SplatCloud", viewModeToolboxes    );
  emit defineViewModeToolbars    ( "SplatCloud", viewModeToolbars     );
  emit defineViewModeContextMenus( "SplatCloud", viewModeContextMenus );
  emit defineViewModeIcon        ( "SplatCloud", "SplatCloudType.png" );
}


//----------------------------------------------------------------


void SplatCloudRenderingControlPlugin::addedEmptyObject( int _objectId )
{
  if( _objectId == -1 )
    return;

  // get object by id
  BaseObjectData *object;
  if( !PluginFunctions::getObject( _objectId, object ) )
    return;

  // get splatcloud-object
  SplatCloudObject *splatCloudObject = PluginFunctions::splatCloudObject( object );

  // if object is a SplatCloud...
  if( splatCloudObject )
  {
    // set current rendering options
    splatCloudObject->enableBackfaceCulling( false                           );
    splatCloudObject->setPointsizeScale    ( toolboxPointsizeScale_->value() );

    // set default values
    SplatCloudNode *splatCloudNode = splatCloudObject->splatCloudNode();
    if( splatCloudNode )
    {
      splatCloudNode->setDefaultColor    ( SplatCloudNode::Color    ( toolboxDefaultColorR_->   value(), 
                                                                      toolboxDefaultColorG_->   value(), 
                                                                      toolboxDefaultColorB_->   value() ) );
      splatCloudNode->setDefaultNormal   ( SplatCloudNode::Normal   ( toolboxDefaultNormalX_->  value(), 
                                                                      toolboxDefaultNormalY_->  value(), 
                                                                      toolboxDefaultNormalZ_->  value() ) );
      splatCloudNode->setDefaultPointsize( SplatCloudNode::Pointsize( toolboxDefaultPointsize_->value() ) );
    }
  }
547 548 549 550 551 552 553 554
}


//----------------------------------------------------------------


void SplatCloudRenderingControlPlugin::slotUpdateContextMenu( int _objectId )
{
555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571
  if( _objectId == -1 )
    return;

  // get object by id
  BaseObjectData *object;
  if( !PluginFunctions::getObject( _objectId, object ) )
    return;

  // get splatcloud-object
  SplatCloudObject *splatCloudObject = PluginFunctions::splatCloudObject( object );

  // if object is a SplatCloud...
  if( splatCloudObject )
  {
    // update context menu value
    contextCullingAction_->setChecked( splatCloudObject->isBackfaceCullingEnabled() );
  }
572 573 574 575 576 577 578 579
}


//----------------------------------------------------------------


void SplatCloudRenderingControlPlugin::slotToolboxPointsizeScaleValueChanged()
{
580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653
  // get toolbox option value
  double scale = toolboxPointsizeScale_->value();

  // for all splatcloud-objects...
  PluginFunctions::ObjectIterator objIter( PluginFunctions::ALL_OBJECTS, DATA_SPLATCLOUD );
  for( ; objIter != PluginFunctions::objectsEnd(); ++objIter )
  {
    // get splatcloud-object
    SplatCloudObject *splatCloudObject = PluginFunctions::splatCloudObject( *objIter );

    // apply update
    splatCloudObject->setPointsizeScale( scale );
  }
}


//----------------------------------------------------------------


void SplatCloudRenderingControlPlugin::slotToolboxDefaultColorValueChanged()
{
  // for all splatcloud-objects...
  PluginFunctions::ObjectIterator objIter( PluginFunctions::ALL_OBJECTS, DATA_SPLATCLOUD );
  for( ; objIter != PluginFunctions::objectsEnd(); ++objIter )
  {
    // get scenegraph splatcloud-node
    SplatCloudNode *splatCloudNode = PluginFunctions::splatCloudNode( *objIter );

    // apply update (set default color)
    splatCloudNode->setDefaultColor( SplatCloudNode::Color( toolboxDefaultColorR_->value(), 
                                                            toolboxDefaultColorG_->value(), 
                                                            toolboxDefaultColorB_->value() ) );
  }
}


//----------------------------------------------------------------


void SplatCloudRenderingControlPlugin::slotToolboxDefaultNormalValueChanged()
{
  // for all splatcloud-objects...
  PluginFunctions::ObjectIterator objIter( PluginFunctions::ALL_OBJECTS, DATA_SPLATCLOUD );
  for( ; objIter != PluginFunctions::objectsEnd(); ++objIter )
  {
    // get scenegraph splatcloud-node
    SplatCloudNode *splatCloudNode = PluginFunctions::splatCloudNode( *objIter );

    // apply update (set default normal)
    splatCloudNode->setDefaultNormal( SplatCloudNode::Normal( toolboxDefaultNormalX_->value(), 
                                                              toolboxDefaultNormalY_->value(), 
                                                              toolboxDefaultNormalZ_->value() ) );
  }
}


//----------------------------------------------------------------


void SplatCloudRenderingControlPlugin::slotToolboxDefaultPointsizeValueChanged()
{
  // for all splatcloud-objects...
  PluginFunctions::ObjectIterator objIter( PluginFunctions::ALL_OBJECTS, DATA_SPLATCLOUD );
  for( ; objIter != PluginFunctions::objectsEnd(); ++objIter )
  {
    // get scenegraph splatcloud-node
    SplatCloudNode *splatCloudNode = PluginFunctions::splatCloudNode( *objIter );

    // apply update (set default pointsize)
    splatCloudNode->setDefaultPointsize( SplatCloudNode::Pointsize( toolboxDefaultPointsize_->value() ) );

    // emit signal that object has to be updated
    emit updatedObject( objIter->id(), UPDATE_ALL );
  }
654 655 656 657 658 659
}


//----------------------------------------------------------------


660
void SplatCloudRenderingControlPlugin::slotToolboxEnableBackfaceCullingButtonClicked()
661
{
662 663 664 665 666 667 668 669 670 671
  // for all splatcloud-objects...
  PluginFunctions::ObjectIterator objIter( PluginFunctions::ALL_OBJECTS, DATA_SPLATCLOUD );
  for( ; objIter != PluginFunctions::objectsEnd(); ++objIter )
  {
    // get splatcloud-object
    SplatCloudObject *splatCloudObject = PluginFunctions::splatCloudObject( *objIter );

    // apply update
    splatCloudObject->enableBackfaceCulling( true );
  }
672
}
673

674 675 676 677 678 679

//----------------------------------------------------------------


void SplatCloudRenderingControlPlugin::slotToolboxDisableBackfaceCullingButtonClicked()
{
680 681 682 683 684 685 686 687 688 689
  // for all splatcloud-objects...
  PluginFunctions::ObjectIterator objIter( PluginFunctions::ALL_OBJECTS, DATA_SPLATCLOUD );
  for( ; objIter != PluginFunctions::objectsEnd(); ++objIter )
  {
    // get splatcloud-object
    SplatCloudObject *splatCloudObject = PluginFunctions::splatCloudObject( *objIter );

    // apply update
    splatCloudObject->enableBackfaceCulling( false );
  }
690 691 692 693 694 695 696 697
}


//----------------------------------------------------------------


void SplatCloudRenderingControlPlugin::slotToolboxReloadShadersButtonClicked()
{
698 699 700 701 702 703 704 705 706 707 708 709
  // for all splatcloud-objects...
  PluginFunctions::ObjectIterator objIter( PluginFunctions::ALL_OBJECTS, DATA_SPLATCLOUD );
  for( ; objIter != PluginFunctions::objectsEnd(); ++objIter )
  {
    // get scenegraph splatcloud-object
    SplatCloudObject *splatCloudObject = PluginFunctions::splatCloudObject( *objIter );

    // apply update (reload standard and picking shaders and re-set uniforms)
    splatCloudObject->reloadShaders();
    splatCloudObject->setPointsizeScale    ( splatCloudObject->pointsizeScale()           );
    splatCloudObject->enableBackfaceCulling( splatCloudObject->isBackfaceCullingEnabled() );
  }
710 711 712 713 714 715 716 717
}


//----------------------------------------------------------------


void SplatCloudRenderingControlPlugin::slotToolboxRebuildVBOsButtonClicked()
{
718 719 720 721 722 723 724 725 726 727 728 729 730
  // for all splatcloud-objects...
  PluginFunctions::ObjectIterator objIter( PluginFunctions::ALL_OBJECTS, DATA_SPLATCLOUD );
  for( ; objIter != PluginFunctions::objectsEnd(); ++objIter )
  {
    // get scenegraph splatcloud-node
    SplatCloudNode *splatCloudNode = PluginFunctions::splatCloudNode( *objIter );

    // rebuild the vertex-buffer-object the next time the node is drawn (or picked)
    splatCloudNode->modifiedAll();

    // emit signal that object has to be updated
    emit updatedObject( objIter->id(), UPDATE_ALL );
  }
731 732
}

733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766
//----------------------------------------------------------------


void SplatCloudRenderingControlPlugin::slotToolboxPointSizeButtonClicked()
{
  // for all splatcloud-objects...
  PluginFunctions::ObjectIterator objIter(PluginFunctions::ALL_OBJECTS, DATA_SPLATCLOUD);
  for (; objIter != PluginFunctions::objectsEnd(); ++objIter)
  {
    // get splatcloud-object
    SplatCloudObject *splatCloudObject = PluginFunctions::splatCloudObject(*objIter);

    // apply update
    splatCloudObject->enableGeometryShaderQuads(false);
  }
}

//----------------------------------------------------------------


void SplatCloudRenderingControlPlugin::slotToolboxGeometryShaderButtonClicked()
{
  // for all splatcloud-objects...
  PluginFunctions::ObjectIterator objIter(PluginFunctions::ALL_OBJECTS, DATA_SPLATCLOUD);
  for (; objIter != PluginFunctions::objectsEnd(); ++objIter)
  {
    // get splatcloud-object
    SplatCloudObject *splatCloudObject = PluginFunctions::splatCloudObject(*objIter);

    // apply update
    splatCloudObject->enableGeometryShaderQuads(true);
  }
}

767 768 769 770

//----------------------------------------------------------------


771
void SplatCloudRenderingControlPlugin::slotContextScaleActionTriggered()
772
{
773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799
  // get picked object by id
  int objectId = contextScaleAction_->data().toInt();
  if( objectId == -1 )
    return;
  //
  BaseObjectData *object;
  if( ! PluginFunctions::getObject( objectId, object ) )
    return;

  // get splatcloud-object
  SplatCloudObject *splatCloudObject = PluginFunctions::splatCloudObject( object );

  // if object is a SplatCloud...
  if( splatCloudObject )
  {
    // get value from SplatCloud
    double ps = splatCloudObject->pointsizeScale();

    // update widget option value
    contextScaleWidgetPointsizeScale_->setValue( ps );

    // move widget to position of context menu entry
    contextScaleWidget_->move( contextScaleAction_->associatedWidgets()[0]->mapToGlobal( QPoint() ) );

    // show widget
    contextScaleWidget_->show();
  }
800 801 802 803 804 805
}


//----------------------------------------------------------------


806
void SplatCloudRenderingControlPlugin::slotContextScaleWidgetPointsizeScaleValueChanged()
807
{
808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828
  // get picked object by id
  int objectId = contextScaleAction_->data().toInt();
  if( objectId == -1 )
    return;
  //
  BaseObjectData *object;
  if( ! PluginFunctions::getObject( objectId, object ) )
    return;

  // get splatcloud-object
  SplatCloudObject *splatCloudObject = PluginFunctions::splatCloudObject( object );

  // if object is a SplatCloud...
  if( splatCloudObject )
  {
    // get widget option value
    double scale = contextScaleWidgetPointsizeScale_->value();

    // apply update (set pointsize scale)
    splatCloudObject->setPointsizeScale( scale );
  }
829 830 831 832 833 834
}


//----------------------------------------------------------------


835
void SplatCloudRenderingControlPlugin::slotContextDefaultsActionTriggered()
836
{
837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875
  // get picked object by id
  int objectId = contextDefaultsAction_->data().toInt();
  if( objectId == -1 )
    return;
  //
  BaseObjectData *object;
  if( ! PluginFunctions::getObject( objectId, object ) )
    return;

  // get splatcloud-node
  SplatCloudNode *splatCloudNode = PluginFunctions::splatCloudNode( object );

  // if object is a SplatCloud...
  if( splatCloudNode )
  {
    // get values from SplatCloud
    int    cr = splatCloudNode->defaultColor()[0];
    int    cg = splatCloudNode->defaultColor()[1];
    int    cb = splatCloudNode->defaultColor()[2];
    double nx = splatCloudNode->defaultNormal()[0];
    double ny = splatCloudNode->defaultNormal()[1];
    double nz = splatCloudNode->defaultNormal()[2];
    double ps = splatCloudNode->defaultPointsize();

    // update widget option values
    contextDefaultsWidgetDefaultColorR_->   setValue( cr );
    contextDefaultsWidgetDefaultColorG_->   setValue( cg );
    contextDefaultsWidgetDefaultColorB_->   setValue( cb );
    contextDefaultsWidgetDefaultNormalX_->  setValue( nx );
    contextDefaultsWidgetDefaultNormalY_->  setValue( ny );
    contextDefaultsWidgetDefaultNormalZ_->  setValue( nz );
    contextDefaultsWidgetDefaultPointsize_->setValue( ps );

    // move defaults widget to position of context menu entry
    contextDefaultsWidget_->move( contextDefaultsAction_->associatedWidgets()[0]->mapToGlobal( QPoint() ) );

    // show widget
    contextDefaultsWidget_->show();
  }
876 877 878 879 880 881
}


//----------------------------------------------------------------


882
void SplatCloudRenderingControlPlugin::slotContextDefaultsWidgetDefaultColorValueChanged()
883
{
884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906
  // get picked object by id
  int objectId = contextDefaultsAction_->data().toInt();
  if( objectId == -1 )
    return;
  //
  BaseObjectData *object;
  if( ! PluginFunctions::getObject( objectId, object ) )
    return;

  // get splatcloud-node
  SplatCloudNode *splatCloudNode = PluginFunctions::splatCloudNode( object );

  // if object is a SplatCloud...
  if( splatCloudNode )
  {
    // apply update (set default color)
    splatCloudNode->setDefaultColor( SplatCloudNode::Color( contextDefaultsWidgetDefaultColorR_->value(),
                                                            contextDefaultsWidgetDefaultColorG_->value(),
                                                            contextDefaultsWidgetDefaultColorB_->value() ) );

    // emit signal that the object has to be updated
    emit updatedObject( object->id(), UPDATE_ALL );
  }
907 908 909 910 911 912
}


//----------------------------------------------------------------


913
void SplatCloudRenderingControlPlugin::slotContextDefaultsWidgetDefaultNormalValueChanged()
914
{
915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937
  // get picked object by id
  int objectId = contextDefaultsAction_->data().toInt();
  if( objectId == -1 )
    return;
  //
  BaseObjectData *object;
  if( ! PluginFunctions::getObject( objectId, object ) )
    return;

  // get splatcloud-node
  SplatCloudNode *splatCloudNode = PluginFunctions::splatCloudNode( object );

  // if object is a SplatCloud...
  if( splatCloudNode )
  {
    // apply update (set default normal)
    splatCloudNode->setDefaultNormal( SplatCloudNode::Normal( contextDefaultsWidgetDefaultNormalX_->value(),
                                                              contextDefaultsWidgetDefaultNormalY_->value(),
                                                              contextDefaultsWidgetDefaultNormalZ_->value() ) );

    // emit signal that the object has to be updated
    emit updatedObject( object->id(), UPDATE_ALL );
  }
938 939 940 941 942 943
}


//----------------------------------------------------------------


944
void SplatCloudRenderingControlPlugin::slotContextDefaultsWidgetDefaultPointsizeValueChanged()
945
{
946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966
  // get picked object by id
  int objectId = contextDefaultsAction_->data().toInt();
  if( objectId == -1 )
    return;
  //
  BaseObjectData *object;
  if( ! PluginFunctions::getObject( objectId, object ) )
    return;

  // get splatcloud-node
  SplatCloudNode *splatCloudNode = PluginFunctions::splatCloudNode( object );

  // if object is a SplatCloud...
  if( splatCloudNode )
  {
    // apply update (set default pointsize)
    splatCloudNode->setDefaultPointsize( SplatCloudNode::Pointsize( contextDefaultsWidgetDefaultPointsize_->value() ) );

    // emit signal that the object has to be updated
    emit updatedObject( object->id(), UPDATE_ALL );
  }
967 968 969 970 971 972
}


//----------------------------------------------------------------


973
void SplatCloudRenderingControlPlugin::slotContextCullingActionTriggered()
974
{
975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998
  // get picked object by id
  int objectId = contextCullingAction_->data().toInt();
  if( objectId == -1 )
    return;
  //
  BaseObjectData *object;
  if( ! PluginFunctions::getObject( objectId, object ) )
    return;

  // get splatcloud-object
  SplatCloudObject *splatCloudObject = PluginFunctions::splatCloudObject( object );

  // if object is a SplatCloud...
  if( splatCloudObject )
  {
    // get context menu option value
    bool enable = contextCullingAction_->isChecked();

    // apply update
    splatCloudObject->enableBackfaceCulling( enable );

    // emit signal that the object has to be updated
    emit updatedObject( object->id(), UPDATE_ALL );
  }
999 1000 1001 1002 1003 1004
}


//----------------------------------------------------------------


1005
void SplatCloudRenderingControlPlugin::slotContextReloadShadersActionTriggered()
1006
{
1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029
  // get picked object by id
  int objectId = contextReloadShadersAction_->data().toInt();
  if( objectId == -1 )
    return;
  //
  BaseObjectData *object;
  if( ! PluginFunctions::getObject( objectId, object ) )
    return;

  // get splatcloud-object
  SplatCloudObject *splatCloudObject = PluginFunctions::splatCloudObject( object );

  // if object is a SplatCloud...
  if( splatCloudObject )
  {
    // apply update (reload standard and picking shaders and re-set uniforms)
    splatCloudObject->reloadShaders();
    splatCloudObject->setPointsizeScale    ( splatCloudObject->pointsizeScale()           );
    splatCloudObject->enableBackfaceCulling( splatCloudObject->isBackfaceCullingEnabled() );

    // emit signal that object has to be updated
    emit updatedObject( object->id(), UPDATE_ALL );
  }
1030 1031 1032 1033 1034 1035
}


//----------------------------------------------------------------


1036
void SplatCloudRenderingControlPlugin::slotContextRebuildVBOActionTriggered()
1037
{
1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058
  // get picked object by id
  int objectId = contextRebuildVBOAction_->data().toInt();
  if( objectId == -1 )
    return;
  //
  BaseObjectData *object;
  if( ! PluginFunctions::getObject( objectId, object ) )
    return;

  // get splatcloud-node
  SplatCloudNode *splatCloudNode = PluginFunctions::splatCloudNode( object );

  // if object is a SplatCloud...
  if( splatCloudNode )
  {
    // rebuild the vertex-buffer-object the next time the node is drawn (or picked)
        splatCloudNode->modifiedAll();

    // emit signal that object has to be updated
    emit updatedObject( object->id(), UPDATE_ALL );
  }
1059 1060 1061 1062 1063 1064
}


//================================================================


1065 1066