SelectionInterface.hh 58.2 KB
Newer Older
1 2 3
/*===========================================================================*\
 *                                                                           *
 *                              OpenFlipper                                  *
Martin Schultz's avatar
Martin Schultz committed
4 5 6 7
 *           Copyright (c) 2001-2015, RWTH-Aachen University                 *
 *           Department of Computer Graphics and Multimedia                  *
 *                          All rights reserved.                             *
 *                            www.openflipper.org                            *
8 9
 *                                                                           *
 *---------------------------------------------------------------------------*
Martin Schultz's avatar
Martin Schultz committed
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
 * 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.              *
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
 *                                                                           *
\*===========================================================================*/

/*===========================================================================*\
 *                                                                           *
 *   $Revision$                                                       *
 *   $Author$                                                       *
 *   $Date$                   *
 *                                                                           *
\*===========================================================================*/


#ifndef SELECTIONINTERFACE_HH
#define SELECTIONINTERFACE_HH

54
#include <OpenFlipper/INIFile/INIFile.hh>
55
#include <OpenFlipper/common/Types.hh>
Matthias Möller's avatar
Matthias Möller committed
56 57 58 59 60 61 62 63


#if QT_VERSION >= 0x050000 
  #include <QtWidgets>
#else
  #include <QtGui>
#endif

64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88

/** \file SelectionInterface.hh
*
*  Interface for providing selection functionality for specific data types.\ref selectionInterfacePage
*/


/** \brief Interface for all plugins which want to use selection functions
  *
  * \ref selectionInterfacePage "Detailed description"
  * \n
  *
  * Using this interface you can instruct the core to select objects
  * and different primitive types.
  *
  * \nosubgrouping
  */
class SelectionInterface {

  public:

    typedef std::vector<DataType> TypeList;
    typedef unsigned int          PrimitiveType;

    /// Destructor
89
    virtual ~SelectionInterface() {};
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105

    //===========================================================================
    /** @name Registering Selection Environments and primitives
     *
     * These functions are used to register your selection environment to
     * the selection system. The environment is basically a collection of selection
     * metaphors that will be available for a set of DataTypes.
     *
     * You Register the Environment via addSelectionEnvironment(). Afterwards you can
     * register DataTypes to the previously created environment with registerType().
     * The selection interactions defined in the environment will only be available,
     * if the registered DataTypes exist.
     *
     * Each DataType can consist of different primitives (e.g. a mesh usually consists
     * of vertices edges and faces). Use addPrimitiveType() to register these
     * primitives and remember the handles you got.
106 107 108 109 110 111 112
     *
     * Here is a short example of how to add a new selection environment and
     * register some data type and primitive type:
     *
     * So in our plugin we first want to add a new selection environment:
     \code
     
113
     emit addSelectionEnvironment("Mesh Object Selections", "Select Triangle Mesh Primitives.",
Jan Möbius's avatar
Jan Möbius committed
114
                                 someIconPath + "mesh_selection.png", environmentHandle_);
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
     \endcode
     * Now, our handle to the newly created environment is in environmentHandle_.
     * We should now see a new tab widget in the selection base tool box
     * displaying our selection environment:
     *
     * \image html selectionEnvironment.png
     *
     * We now want to register a specific data type for which we want to enable
     * selection. Say DATA_TRIANGLE_MESH:
     \code
     
     emit registerType(environmentHandle_, DATA_TRIANGLE_MESH);
     
     \endcode
     *
     * Repeat this for as many data types as you want to handle in your plugin.
     * Since triangle meshes normally consist of vertex, edge and face primitives,
     * we want to enable selection for the three of them:
     \code
     
Jan Möbius's avatar
Jan Möbius committed
135 136 137
     emit addPrimitiveType(environmentHandle_, "Select Vertices", iconPath + "vertexType.png", vertexType_);
     emit addPrimitiveType(environmentHandle_, "Select Edges",    iconPath + "edgeType.png",   edgeType_);
     emit addPrimitiveType(environmentHandle_, "Select Faces",    iconPath + "faceType.png",   faceType_);
138 139 140 141 142 143 144 145 146 147 148 149 150 151
     
     \endcode
     *
     * The three variables of type SelectionInterface::PrimitiveType vertexType_, edgeType_ and faceType_
     * now hold the handles to the newly added primitive types. We use these to reference the types
     * later on. For each registered primitive type, we now see a button appearing in the recently
     * created environment tab in selection base plugin's tool box:
     *
     * \image html selectionPrimitives.png
     *
     * The user can now chose which primitive type she wants to select via simply clicking one of these
     * buttons (or more than one by holding the control key while clicking). We then go on with requesting
     * the available selection metaphors in the next section.
     *
152 153 154 155 156 157 158 159 160 161 162 163 164 165
     * @{ */
    //===========================================================================

    signals:

    /** \brief Add a selection environment in order to provide selection functions for specific data type(s)
     *
     *  This adds a toolbar button and initializes a new selection environment that supports
     *  all objects/entities of a specified data type. The type for which the selection
     *  applies is later registered via the signal registerType(QString,DataType).
     *  Use the returned _handleName for referencing the selection environment.
     *
     *  @param _modeName    The name of the selection mode, e.g. "Mesh Selection"
     *  @param _description The description for the selection mode (also tooltip)
Jan Möbius's avatar
Jan Möbius committed
166
     *  @param _icon        Path to the icon for this mode (basically a type icon)
167 168
     *  @param _handleName  The handle of the recently added selection environment. Needed for referencing
     */
Jan Möbius's avatar
Jan Möbius committed
169
    virtual void addSelectionEnvironment(QString _modeName, QString _description, QString _icon, QString& _handleName) {};
170 171 172 173 174 175 176 177 178 179 180

    /** \brief Register data type for a selection environment
     *
     *  After adding a new selection environment, one can register types which the
     *  selection environment accounts for. For example, if we added a selection environment
     *  for polylines, we would have to call registerType(environmentHandle,DATA_POLY_LINE)
     *  in order to enable polyline selections.
     *
     *  @param _handleName  The handle of the selection environment for this type
     *  @param _type        The data type that should be added
     */
181
    virtual void registerType(QString _handleName, DataType _type) {};
182 183 184 185 186 187 188 189 190

    /** \brief Provide selection for primitives other than the standard ones
     *
     *  Use this signal to add a new primitive type that can be selected.
     *  This returns a handle to the newly added primitive type which will be
     *  of use later on.
     *
     *  @param _handleName  The handle of the selection environment to which this type should be added
     *  @param _name        The name of the primitive type, e.g. "B-Spline Surface Control Point"
Jan Möbius's avatar
Jan Möbius committed
191
     *  @param _icon        Path to the icon for the primitive type
192 193
     *  @param _typeHandle  The returned handle to the added primitive type
     */
Jan Möbius's avatar
Jan Möbius committed
194
    virtual void addPrimitiveType(QString _handleName, QString _name, QString _icon, PrimitiveType& _typeHandle) {};
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212

    /** @} */


    //===========================================================================
    /** @name  Enabling Selection Metaphors
     * \anchor SelectionInterface_enable_metaphors_group
     * The selection system provides a set of basic selection operations.
     * These include toggle selection, volume lasso, surface lasso, painting,
     * closest boundary and flood fill selection.
     *
     * The interactions for these metaphors are controlled by the Base Selection
     * Plugin. The results of these interactions are than passed on to the
     * specific selection plugins.
     *
     * These functions are used to tell the system, that you can handle the
     * given selection metaphors in your plugin.
     *
Jan Möbius's avatar
Jan Möbius committed
213
     * You can also add your custom selection mode via addCustomSelectionMode().
214 215 216 217 218 219 220 221
     *
     * To continue the above example, we now want to make toggle, volume lasso as well
     * a custom selection mode available for our data types:
     \code
     
     emit showToggleSelectionMode(environmentHandle_,      true, vertexType_ | edgeType_ | faceType_);
     emit showVolumeLassoSelectionMode(environmentHandle_, true, vertexType_ | edgeType_ | faceType_);
     
Jan Möbius's avatar
Jan Möbius committed
222
     emit addCustomSelectionMode(environmentHandle_, "My Custom Selection", "Description of my mode", someIconFile, vertexType_ | edgeType_);
223 224 225 226 227 228 229 230 231 232 233 234 235
     
     \endcode
     *
     * In the last parameter we determine for which of the registered primitive types
     * the selection metaphor will be available. Note that multiple primitive types
     * have to be OR'ed. The selection metaphors as well as the available primitive
     * types will be displayed in the selection pick tool bar:
     *
     * \image html selectionPickbar.png
     *
     * Now each time the user uses the toggle selection metaphor slotToggleSelection()
     * is called. See below for code examples on this.
     *
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
     * @{ */
    //===========================================================================

    signals:

    /** \brief Show toggle selection mode in a specified selection environment
     *
     *  Show or hide the toggle selection mode for the specified selection environment.
     *  Note that per default no interactive selection mode will be available.
     *  One will always have to explicitly add the required selection modes for
     *  each selection environment.
     *
     *  @param _handleName      The handle of the selection environment in which this mode should be available
     *  @param _show            Indicates whether the mode should be available or not
     *  @param _associatedTypes Make this mode available only for the specified types (OR'ed)
     */
252
    virtual void showToggleSelectionMode(QString _handleName, bool _show, PrimitiveType _associatedTypes) {};
253 254 255 256 257 258 259 260 261 262 263 264

    /** \brief Show lasso selection mode in a specified selection environment
     *
     *  Show or hide the lasso selection mode for the specified selection environment.
     *  Note that per default no interactive selection mode will be available.
     *  One will always have to explicitly add the required selection modes for
     *  each selection environment.
     *
     *  @param _handleName      The handle of the selection environment in which this mode should be available
     *  @param _show            Indicates whether the mode should be available or not
     *  @param _associatedTypes Make this mode available only for the specified types (OR'ed)
     */
265
    virtual void showLassoSelectionMode(QString _handleName, bool _show, PrimitiveType _associatedTypes) {};
266 267 268 269 270 271 272 273 274 275 276 277

    /** \brief Show volume lasso selection mode in a specified selection environment
     *
     *  Show or hide the volume lasso selection mode for the specified selection environment.
     *  Note that per default no interactive selection mode will be available.
     *  One will always have to explicitly add the required selection modes for
     *  each selection environment.
     *
     *  @param _handleName      The handle of the selection environment in which this mode should be available
     *  @param _show            Indicates whether the mode should be available or not
     *  @param _associatedTypes Make this mode available only for the specified types (OR'ed)
     */
278
    virtual void showVolumeLassoSelectionMode(QString _handleName, bool _show, PrimitiveType _associatedTypes) {};
279 280 281 282 283 284 285 286 287 288 289 290

    /** \brief Show surface lasso selection mode in a specified selection environment
     *
     *  Show or hide the surface lasso selection mode for the specified selection environment.
     *  Note that per default no interactive selection mode will be available.
     *  One will always have to explicitly add the required selection modes for
     *  each selection environment.
     *
     *  @param _handleName      The handle of the selection environment in which this mode should be available
     *  @param _show            Indicates whether the mode should be available or not
     *  @param _associatedTypes Make this mode available only for the specified types (OR'ed)
     */
291
    virtual void showSurfaceLassoSelectionMode(QString _handleName, bool _show, PrimitiveType _associatedTypes) {};
292 293 294 295 296 297 298 299 300 301 302 303

    /** \brief Show sphere selection mode in a specified selection environment
     *
     *  Show or hide the sphere selection mode for the specified selection environment.
     *  Note that per default no interactive selection mode will be available.
     *  One will always have to explicitly add the required selection modes for
     *  each selection environment.
     *
     *  @param _handleName      The handle of the selection environment in which this mode should be available
     *  @param _show            Indicates whether the mode should be available or not
     *  @param _associatedTypes Make this mode available only for the specified types (OR'ed)
     */
304
    virtual void showSphereSelectionMode(QString _handleName, bool _show, PrimitiveType _associatedTypes) {};
305 306 307 308 309 310 311 312 313 314 315 316

    /** \brief Show closest boundary selection mode in a specified selection environment
     *
     *  Show or hide the closest boundary selection mode for the specified selection environment.
     *  Note that per default no interactive selection mode will be available.
     *  One will always have to explicitly add the required selection modes for
     *  each selection environment.
     *
     *  @param _handleName      The handle of the selection environment in which this mode should be available
     *  @param _show            Indicates whether the mode should be available or not
     *  @param _associatedTypes Make this mode available only for the specified types (OR'ed)
     */
317
    virtual void showClosestBoundarySelectionMode(QString _handleName, bool _show, PrimitiveType _associatedTypes) {};
318 319 320 321 322 323 324 325 326 327 328 329

    /** \brief Show flood fill selection mode in a specified selection environment
     *
     *  Show or hide the flood fill selection mode for the specified selection environment.
     *  Note that per default no interactive selection mode will be available.
     *  One will always have to explicitly add the required selection modes for
     *  each selection environment.
     *
     *  @param _handleName      The handle of the selection environment in which this mode should be available
     *  @param _show            Indicates whether the mode should be available or not
     *  @param _associatedTypes Make this mode available only for the specified types (OR'ed)
     */
330
    virtual void showFloodFillSelectionMode(QString _handleName, bool _show, PrimitiveType _associatedTypes) {};
331

332 333 334 335 336 337 338 339 340 341 342
    /** \brief Show connected components selection mode in a specified selection environment
     *
     *  Show or hide the connected components selection mode for the specified selection environment.
     *  Note that per default no interactive selection mode will be available.
     *  One will always have to explicitly add the required selection modes for
     *  each selection environment.
     *
     *  @param _handleName      The handle of the selection environment in which this mode should be available
     *  @param _show            Indicates whether the mode should be available or not
     *  @param _associatedTypes Make this mode available only for the specified types (OR'ed)
     */
343
    virtual void showComponentsSelectionMode(QString _handleName, bool _show, PrimitiveType _associatedTypes) {};
344

345 346 347 348 349 350 351 352 353 354 355 356 357 358
    /** \brief Add a custom interactive selection mode
     *
     *  If a plugin should provide an interactive selection mode other than the
     *  standard ones (which include toggle, lasso, volume lasso, sphere, closest boundary
     *  and flood fill selection), one can add a custom interactive selection mode
     *  via this signal. Once the custom mode is added, it will appear in the sub-menu
     *  for the associated selection environment. If the user chooses this mode in order
     *  to do selection, slotCustomSelection(QMouseEvent*,QString) is called.
     *  This signal returns the added identifier for this selection mode in parameter
     *  _identifier.
     *
     *  @param _handleName      The handle of the selection environment in which this mode should be available
     *  @param _modeName        The name of this mode (also button caption)
     *  @param _description     A brief description of what the selection mode does
Jan Möbius's avatar
Jan Möbius committed
359
     *  @param _icon            Path to an icon which is used for this selection mode
360 361 362
     *  @param _associatedTypes Make this mode available only for the specified types (OR'ed)
     *  @param _customIdentifier Holds the identifier of the custom selection modes
     */
Jan Möbius's avatar
Jan Möbius committed
363
    virtual void addCustomSelectionMode(QString _handleName, QString _modeName, QString _description, QString _icon,
364
                                        PrimitiveType _associatedTypes, QString& _customIdentifier) {};
Jan Möbius's avatar
Jan Möbius committed
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379

    /** \brief Add a custom interactive selection mode
     *
     *  If a plugin should provide an interactive selection mode other than the
     *  standard ones (which include toggle, lasso, volume lasso, sphere, closest boundary
     *  and flood fill selection), one can add a custom interactive selection mode
     *  via this signal. Once the custom mode is added, it will appear in the sub-menu
     *  for the associated selection environment. If the user chooses this mode in order
     *  to do selection, slotCustomSelection(QMouseEvent*,QString) is called.
     *  This signal returns the added identifier for this selection mode in parameter
     *  _identifier.
     *
     *  @param _handleName            The handle of the selection environment in which this mode should be available
     *  @param _modeName              The name of this mode (also button caption)
     *  @param _description           A brief description of what the selection mode does
Jan Möbius's avatar
Jan Möbius committed
380
     *  @param _icon                  Path to an icon which is used for this selection mode
Jan Möbius's avatar
Jan Möbius committed
381 382 383 384
     *  @param _associatedTypes       Make this mode available only for the specified types (OR'ed)
     *  @param _customIdentifier      Holds the identifier of the custom selection modes
     *  @param _objectTypeRestriction Restrict the mode to this specific data type
     */
Jan Möbius's avatar
Jan Möbius committed
385
    virtual void addCustomSelectionMode(QString _handleName, QString _modeName, QString _description, QString _icon,
386
                                        PrimitiveType _associatedTypes, QString& _customIdentifier,
387
                                        DataType _objectTypeRestriction) {};
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409

    /** @} */



    //===========================================================================
     /** @name States of the selection system.
      *
      * You can get the active data types,
      * primitive types and if only target objects should be affected.
      *
      * @{ */
    //===========================================================================


    /** \brief Get the data types that the currently active selection environment supports
     *
     *  This fetches a list of data types that are supported by the currently activated
     *  selection environment.
     *
     *  @param _types The list of currently active data types
     */
410
    virtual void getActiveDataTypes(TypeList& _types) {};
411 412 413 414 415 416 417

    /** \brief Get the primitive type that is selected
     *
     *  This returns the id of the primitive type that is selected.
     *
     *  @param _type Id of selected primitive type
     */
418
    virtual void getActivePrimitiveType(PrimitiveType& _type) {};
419 420 421 422 423 424 425

    /** \brief Indicates whether selection should be performed on target objects only
     *
     *  Self-explanatory
     *
     *  @param _targetsOnly True if selection should restrict to target objects
     */
426
    virtual void targetObjectsOnly(bool& _targetsOnly) {};
427 428 429 430 431 432

    /** @} */

    //===========================================================================
     /** @name File Interaction
      *
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
      * Store and load selection data in an INI file.
      * In the above example we would want something like this
      * in order to store the current selection:
      \code
      
        void MySelectionPlugin::slotSaveSelection(INIFile& _file) {

            // Iterate over all triangle meshes and save
            // the selections for all entity types
            for (PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS, DataType(DATA_TRIANGLE_MESH)); 
                 o_it != PluginFunctions::objectsEnd(); ++o_it) {
                
                // Create section for each object
                // Append object name to section identifier
                QString section = QString("TriangleMeshSelection") + "//" + o_it->name();
                if(!_file.section_exists(section)) {
                    _file.add_section(section);
                } else {
                    continue;
                }
                
                // Store vertex selection
                _file.add_entry(section, "VertexSelection", getVertexSelection(o_it->id()));
                // Store edge selection
                _file.add_entry(section, "EdgeSelection",   getEdgeSelection(o_it->id()));
                // Store face selection
                _file.add_entry(section, "FaceSelection",   getFaceSelection(o_it->id()));
            }
        }
      
      \endcode
      *
      * This works analogously for loading selections.
466 467 468 469 470
      * @{ */
    //===========================================================================

    private slots:

471 472 473 474 475 476 477 478
    /** \brief Load selection for specific objects in the scene
    *
    *  OpenFlipper allows for saving of selections in an INI file (implemented by the
    *  different selection plugins by overriding function slotSaveSelection()).
    *  So this slot is called each time such INI file is about to be loaded.
    *
    *  @param _file The file from which one can read the selection data
    */ 
479
    virtual void slotLoadSelection(const INIFile& _file) {};
480 481 482 483 484 485 486 487 488
    
    /** \brief Save selection for all objects in the scene
    *
    *  Override this slot in order to save selections for a specific data type.
    *  These selections are then stored within an INI file and can be loaded
    *  via slotLoadSelection().
    *
    *  @param _file The file into which one can store selection data
    */
489
    virtual void slotSaveSelection(INIFile& _file) {};
490

491 492 493 494 495 496 497 498 499
    public slots:

    /** \brief Scripting slot for loading selections
    *
    *  Override this slot in order to directly load selections from files.
    *
    *  @param _objId    The target object's id
    *  @param _filename The file in which the data is stored
    */
500
    virtual void loadSelection(int _objId, const QString& _filename) {};
501

502 503 504 505
    /** @} */

    //===========================================================================
    /** @name Keyboard Interactions
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
     *
     * Register keyboard shortcuts for your selection plugin by emitting the registerKeyShortcut()
     * slot. For example:
     \code
     
     // Select (a)ll, Control + A keys
     emit registerKeyShortcut(Qt::Key_A, Qt::ControlModifier);
     // (C)lear selection, C key
     emit registerKeyShortcut(Qt::Key_C,      Qt::NoModifier);
     
     \endcode
     *
     * Now if the user presses a key, we can handle this by overriding
     * slotKeyShortcutEvent(). Don't forget to test whether at least one
     * of the registered primitives is active and whether we want to restrict
     * to target objects only:
     \code
     
     void MySelectionPlugin::slotKeyShortcutEvent(int _key, Qt::KeyboardModifiers _modifiers) {
         
        SelectionInterface::PrimitiveType type = 0u;
        emit getActivePrimitiveType(type);
        
        if((type & (vertexType_ | edgeType_ | faceType_)) == 0) {
            // No supported type is active
            return;
        }
        
        bool targetsOnly = false;
        emit targetObjectsOnly(targetsOnly);
        
        PluginFunctions::IteratorRestriction restriction =
                (targetsOnly ? PluginFunctions::TARGET_OBJECTS : PluginFunctions::ALL_OBJECTS);
        
        // And so on...
     }
     
     \endcode
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561
     *
     * @{ */
    //===========================================================================

    signals:
    /** \brief Register key shortcut
     *
     *  This signal is emitted whenever a type selection plugin wants
     *  to provide key shortcuts for its functions. Note that multiple
     *  registration of one key will be possible. Key events will be passed
     *  to ALL type selection plugins that want to listen to key events of this
     *  key, thus, one has to ignore the event if the currently active primitive
     *  type (request via signal getActivePrimitiveType(PrimitiveType&) ) is
     *  not handled by the type selection plugin.
     *
     *  @param _key       Key to register
     *  @param _modifiers Key modifiers (i.e. shift, control, meta keys, defaults to none)
     */
562
    virtual void registerKeyShortcut(int _key, Qt::KeyboardModifiers _modifiers = Qt::NoModifier) {};
563 564 565 566


    private slots:

567 568 569 570 571 572 573 574 575
    /** \brief One of the previously registered keys has been pressed
    *
    *  This slot is called whenever the user has pressed one of the registered keys.
    *  Note that this is actually handled by the selection base plugin since
    *  the different plugins might want to register the same key multiple times.
    *
    *  @param _key       The pressed key
    *  @param _modifiers Indicates whether mod-keys have been pressed synchronously
    */  
576
    virtual void slotKeyShortcutEvent(int _key, Qt::KeyboardModifiers _modifiers) {};
577 578 579 580 581

    /** @} */

    //===========================================================================
    /** @name User Interface controls
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
     *
     * In many cases it is desired to offer selection operations such as "select all vertices"
     * or "invert edge selection". For this purpose, use the addSelectionOperations() slot.
     * In our example, we now add some of these functions using the following code:
     \code
     
     QStringList vertexOperations;
     vertexOperations.append("Select All Vertices");
     vertexOperations.append("Invert Vertex Selection");
     vertexOperations.append("Delete All Selected Vertices");
    
     emit addSelectionOperations(environmentHandle_, vertexOperations, "Vertex Operations");
     
     \endcode
     *
     * These operations will now appear in the selection environment tab of
     * the selection base plugin:
     *
     * \image html selectionOperations.png
     *
     * The user can now perform these operations  by simply clicking the buttons.
     * Each time one of the buttons has been pressed, slotSelectionOperation() is called.
     * You will have to override this in order to provide such operations.
     *
     * An example would be:
     \code
     
     void MySelectionPlugin::slotSelectionOperation(QString _operation) {
    
        SelectionInterface::PrimitiveType type = 0u;
        emit getActivePrimitiveType(type);
        
        // If none of our primitives is currently active
        if((type & (vertexType_ | edgeType_ | faceType_)) == 0)
            return;
        
        // Test if operation should be applied to target objects only
        bool targetsOnly = false;
        emit targetObjectsOnly(targetsOnly);
        PluginFunctions::IteratorRestriction restriction =
                (targetsOnly ? PluginFunctions::TARGET_OBJECTS : PluginFunctions::ALL_OBJECTS);

        if(_operation == "Select All Vertices") {
               
               for (PluginFunctions::ObjectIterator o_it(restriction, DataType(DATA_TRIANGLE_MESH)); 
                    o_it != PluginFunctions::objectsEnd(); ++o_it) {
               
               if (o_it->visible()) {
                  selectAllVertices(o_it->id());
               }
            
              // Don't forget this in order to update the render buffers
              emit updatedObject(o_it->id(), UPDATE_SELECTION);    
           }
        }
        // ...and so on...
     }
     
     \endcode
641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659
     *
     * @{ */
    //===========================================================================

    signals:
    /** \brief Add non-interactive selection operations for a specific primitive type
     *
     *  One can add non-interactive selection operations for each primitive type
     *  that will appear as buttons in the selection base toolbar.
     *  An example for this would be "Clear selection", "Invert", "Delete", etc.
     *  If one of this operations is requested, slotSelectionOperation(QString) is
     *  called. These functions are listed in categories which are mainly used
     *  to improve usability.
     *
     *  @param _handleName      The handle of the selection environment in which this operation should be available
     *  @param _operationsList  The list of operations that can be performed for a given primitive type
     *  @param _category        The category under which the specified operations will be listed
     *  @param _type            The primitive type for which the specified operations will be available (0u if operation should always be available)
     */
660
    virtual void addSelectionOperations(QString _handleName, QStringList _operationsList, QString _category, PrimitiveType _type = 0u) {};
661

662 663 664 665 666 667 668 669 670 671 672 673
    /** \brief Add interactive selection parameters for a specific primitive type
     *
     *  One can add interactive selection parameters for each primitive type
     *  that will appear as widgets in the selection base toolbar.
     *
     *  @param _handleName      The handle of the selection environment in which this operation should be available
     *  @param _widget          The widget that shall be added for parameters enabled for a given primitive type
     *  @param _category        The category under which the specified operations will be listed
     *  @param _type            The primitive type for which the specified operations will be available (0u if operation should always be available)
     */
    virtual void addSelectionParameters(QString _handleName, QWidget* _widget, QString _category, PrimitiveType _type = 0u) {};

674 675
    private slots:

676 677 678 679 680 681 682
    /** \brief A specific operation is requested
    *
    *  This slot is called each time the user has pressed one of the operations
    *  buttons (for the various primitive types) offered in the tool box.
    *
    *  @param _operation The identifier of the operation just as registered via addSelectionOperations
    */
683
    virtual void slotSelectionOperation(QString _operation) {};
684 685 686 687 688 689 690 691 692 693 694


    /** @} */

   //===========================================================================
    /** @name Slots which have to be implemented to use the global interaction metaphors
     * If you enabled selection metaphors for your environment via the
     * \ref SelectionInterface_enable_metaphors_group "control functions" you will
     * have to implement the corresponding slots here. These will be
     * called when the events occur.
     *
695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725
     * Continuing the above example, we should now override the slots for the
     * metaphors that we have already requested above. For instance, when
     * using the toggle metaphor, we would want to handle a toggle operation only
     * if the currently selected primitive type belongs to our plugin:
     \code
     
     void MySelectionPlugin::slotToggleSelection(QPoint _mousePosition, PrimitiveType _currentType, bool _deselect) {

        // Return if none of the currently active types is handled by this plugin
        if((_currentType & (vertexType_ | edgeType_ | faceType_)) == 0) return;
        
        // Only toggle target objects if requested
        bool targetsOnly = false;
        emit targetObjectsOnly(targetsOnly);
        
        // Do the picking...
        
        // ...and the actual selection
        if(_currentType & vertexType_) {
            // Vertex selection
        }
        
        if(_currentType & edgeType_) {
            // Edge selection
        }
        
        // ...and so on...
     }
     
     \endcode
     *
726 727 728 729 730 731 732 733 734 735
     * @{ */
   //===========================================================================

   private slots:

   /** \brief Called whenever the user performs a toggle selection
    *
    *  This has to be implemented by each type selection plugin if this interactive
    *  selection mode should be provided.
    *
736
    *  @param _event               The mouse event that occurred
737 738 739
    *  @param _currentType         The currently active primitive type
    *  @param _deselect            True if entities should be deselected
    */
740
   virtual void slotToggleSelection(QMouseEvent* _event, PrimitiveType _currentType, bool _deselect) {};
741 742 743 744 745 746 747 748 749 750 751 752

   /** \brief Called whenever the user performs a lasso selection
    *
    *  This has to be implemented by each type selection plugin if this
    *  interactive selection mode should be provided. The metaphor behind it is
    *  that the user draws a polygonal line and all primitives which are <b>visible</b>
    *  get selected.
    *
    *  @param _event               The mouse event that currently is performed
    *  @param _currentType         The currently active primitive type
    *  @param _deselect            True if entities should be deselected
    */
753
   virtual void slotLassoSelection(QMouseEvent* _event, PrimitiveType _currentType, bool _deselect) {};
754 755 756 757 758 759 760 761 762 763 764 765

   /** \brief Called whenever the user performs a volume lasso selection
    *
    *  This has to be implemented by each type selection plugin if this interactive
    *  selection mode should be provided. The metaphor behind it is
    *  that the user draws a polygonal line and all primitives which are insinde the
    *  volume spanned by the eye position and the polygon get selected.
    *
    *  @param _event               The mouse event that currently is performed
    *  @param _currentType         The currently active primitive type
    *  @param _deselect            True if entities should be deselected
    */
766
   virtual void slotVolumeLassoSelection(QMouseEvent* _event, PrimitiveType _currentType, bool _deselect) {};
767 768 769 770 771 772 773 774 775 776 777 778 779

   /** \brief Called whenever the user performs a surface lasso selection
    *
    *  This has to be implemented by each type selection plugin if this
    *  interactive selection mode should be provided. The metaphor behind it is
    *  that the user draws a polygonal line on the surface of an object and
    *  all primitives which are insinde the surface patch defined
    *  by the line get selected.
    *
    *  @param _event               The mouse event that currently is performed
    *  @param _currentType         The currently active primitive type
    *  @param _deselect            True if entities should be deselected
    */
780
   virtual void slotSurfaceLassoSelection(QMouseEvent* _event, PrimitiveType _currentType, bool _deselect) {};
781 782 783 784 785 786 787 788

   /** \brief Called whenever the user performs a sphere selection
    *
    *  This has to be implemented by each type selection plugin if
    *  this interactive selection mode should be provided. The metaphor behind
    *  it is that the user draws the selection with a sphere. All primitives inside
    *  the current sphere get selected.
    *
789
    *  @param _event               The mouse event that currently is performed
790 791 792 793
    *  @param _radius              The current radius of the selection sphere
    *  @param _currentType         The currently active primitive type
    *  @param _deselect            True if entities should be deselected
    */
794
   virtual void slotSphereSelection(QMouseEvent* _event, double _radius, PrimitiveType _currentType, bool _deselect) {};
795 796 797 798 799 800 801 802

   /** \brief Called whenever the user performs a closest boundary selection
    *
    *  This has to be implemented by each type selection plugin if
    *  this interactive selection mode should be provided.  The metaphor behind
    *  it is that the user clicks on an object and the primitives at the closest boundary
    *  get selected.
    *
803
    *  @param _event               The mouse event that currently is performed
804 805 806
    *  @param _currentType         The currently active primitive type
    *  @param _deselect            True if entities should be deselected
    */
807
   virtual void slotClosestBoundarySelection(QMouseEvent* _event, PrimitiveType _currentType, bool _deselect) {};
808 809 810 811 812 813 814 815

   /** \brief Called whenever the user performs a flood fill selection
    *
    *  This has to be implemented by each type selection plugin if this interactive selection mode should be provided.
    *  The metaphor behind it is that the user clicks on an object and all primitives close to this point
    *  get selected, if the angle between the clicked point and the next point does not differ more than
    *  the specified angle.
    *
816
    *  @param _event               The mouse event that currently is performed
817 818 819
    *  @param _currentType         The currently active primitive type
    *  @param _deselect            True if entities should be deselected
    */
820
   virtual void slotFloodFillSelection(QMouseEvent* _event, PrimitiveType _currentType, bool _deselect) {};
821

822 823 824 825 826 827 828 829 830 831
   /** \brief Called whenever the user performs a connected components selection
    *
    *  This has to be implemented by each type selection plugin if this interactive selection mode should be provided.
    *  The metaphor behind it is that the user clicks on an object and all primitives that are connected to the
    *  clicked primitive are selected as well.
    *
    *  @param _event               The mouse event that currently is performed
    *  @param _currentType         The currently active primitive type
    *  @param _deselect            True if entities should be deselected
    */
832
   virtual void slotComponentsSelection(QMouseEvent* _event, PrimitiveType _currentType, bool _deselect) {};
833

834 835 836 837 838 839 840
   /** \brief Called whenever the user performs a custom selection
    *
    *  This has to be implemented by each type selection plugin if this
    *  interactive selection mode should be provided.
    *
    *  @param _event               The mouse event that currently is performed
    *  @param _currentType         The currently active primitive type
841
    *  @param _customIdentifier Holds the identifier of the custom selection modes
842 843
    *  @param _deselect            True if entities should be deselected
    */
844
   virtual void slotCustomSelection(QMouseEvent* _event, PrimitiveType _currentType, QString _customIdentifier, bool _deselect) {};
845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867


   /** @} */



   //===========================================================================
    /** @name Signals emitted by the SelectionBasePlugin
     *
     * The following signals are emitted by the selection base plugin.
     * <b>You should not use them!</b>
     * @{ */
   //===========================================================================

   signals:

   /** \brief Emitted by selection base plugin when a non-interactive selection operation is requested
    *
    *  This connects to slot slotSelectionOperation and is called whenever a non-interactive
    *  selection operation is requested.
    *
    *  @param _operation The name of the requested operation
    */
868
   virtual void selectionOperation(QString _operation) {};
869 870 871 872


   /** \brief Emitted by selection base plugin whenever the user performs a toggle selection
    *
873
    *  This connects to slotToggleSelection() which has to be implemented
874 875
    *  by each type selection plugin if this interactive selection mode should be provided.
    *
876
    *  @param _event               The mouse event that currently is performed
877 878 879
    *  @param _currentType         The currently active primitive type
    *  @param _deselect            True if entities should be deselected
    */
880
   virtual void toggleSelection(QMouseEvent* _event, PrimitiveType _currentType, bool _deselect) {};
881 882 883

   /** \brief Emitted by selection base plugin whenever the user performs a lasso selection
    *
884
    *  This connects to slotLassoSelection() which has to be implemented
885 886 887 888 889 890
    *  by each type selection plugin if this interactive selection mode should be provided.
    *
    *  @param _event               The mouse event that currently is performed
    *  @param _currentType         The currently active primitive type
    *  @param _deselect            True if entities should be deselected
    */
891
   virtual void lassoSelection(QMouseEvent* _event, PrimitiveType _currentType, bool _deselect) {};
892 893 894

   /** \brief Emitted by selection base plugin whenever the user performs a volume lasso selection
    *
895
    *  This connects to slotVolumeLassoSelection() which has to be implemented
896 897 898 899 900 901
    *  by each type selection plugin if this interactive selection mode should be provided.
    *
    *  @param _event               The mouse event that currently is performed
    *  @param _currentType         The currently active primitive type
    *  @param _deselect            True if entities should be deselected
    */
902
   virtual void volumeLassoSelection(QMouseEvent* _event, PrimitiveType _currentType, bool _deselect) {};
903 904 905

   /** \brief Emitted by selection base plugin whenever the user performs a surface lasso selection
    *
906
    *  This connects to slotSurfaceLassoSelection() which has to be implemented
907 908 909 910 911 912
    *  by each type selection plugin if this interactive selection mode should be provided.
    *
    *  @param _event               The mouse event that currently is performed
    *  @param _currentType         The currently active primitive type
    *  @param _deselect            True if entities should be deselected
    */
913
   virtual void surfaceLassoSelection(QMouseEvent* _event, PrimitiveType _currentType, bool _deselect) {};
914 915 916

   /** \brief Emitted by selection base plugin whenever the user performs a sphere selection
    *
917
    *  This connects to slotSphereSelection() which has to be implemented
918 919
    *  by each type selection plugin if this interactive selection mode should be provided.
    *
920
    *  @param _event               The mouse event that currently is performed
921 922 923 924
    *  @param _radius              The current radius of the selection sphere
    *  @param _currentType         The currently active primitive type
    *  @param _deselect            True if entities should be deselected
    */
925
   virtual void sphereSelection(QMouseEvent* _event, double _radius, PrimitiveType _currentType, bool _deselect) {};
926 927 928

   /** \brief Emitted by selection base plugin whenever the user performs a closest boundary selection
    *
929
    *  This connects to slotClosestBoundarySelection() which has to be implemented
930 931
    *  by each type selection plugin if this interactive selection mode should be provided.
    *
932
    *  @param _event               The mouse event that currently is performed
933 934 935
    *  @param _currentType         The currently active primitive type
    *  @param _deselect            True if entities should be deselected
    */
936
   virtual void closestBoundarySelection(QMouseEvent* _event, PrimitiveType _currentType, bool _deselect) {};
937 938 939

   /** \brief Emitted by selection base plugin whenever the user performs a flood fill selection
    *
940
    *  This connects to slotFloodFillSelection() which has to be implemented
941 942
    *  by each type selection plugin if this interactive selection mode should be provided.
    *
943
    *  @param _event               The mouse event that currently is performed
944 945 946
    *  @param _currentType         The currently active primitive type
    *  @param _deselect            True if entities should be deselected
    */
947
   virtual void floodFillSelection(QMouseEvent* _event, PrimitiveType _currentType, bool _deselect) {};
948

949 950 951 952 953 954 955 956 957
   /** \brief Emitted by selection base plugin whenever the user performs a connected components selection
    *
    *  This connects to slotComponentsSelection() which has to be implemented
    *  by each type selection plugin if this interactive selection mode should be provided.
    *
    *  @param _event               The mouse event that currently is performed
    *  @param _currentType         The currently active primitive type
    *  @param _deselect            True if entities should be deselected
    */
958
   virtual void componentsSelection(QMouseEvent* _event, PrimitiveType _currentType, bool _deselect) {};
959

960 961 962 963 964 965 966
   /** \brief Emitted by selection base plugin whenever the user performs a custom selection
    *
    *  This connects to slotCustomSelection(QMouseEvent*,QString) which has to be implemented
    *  by each type selection plugin if this interactive selection mode should be provided.
    *
    *  @param _event               The mouse event that currently is performed
    *  @param _currentType         The currently active primitive type
967
    *  @param _customIdentifier    Holds the identifier of the custom selection modes
968 969
    *  @param _deselect            True if entities should be deselected
    */
970
   virtual void customSelection(QMouseEvent* _event, PrimitiveType _currentType, QString _customIdentifier, bool _deselect) {};
971 972 973 974 975 976 977 978 979 980

   /** \brief Load selections from ini-file
    *
    *  This signal is emitted by SelectionBase-Plugin each time a selection
    *  should be read from a file. This ini-file handle is then passed
    *  to each object type selection plugin where object specific
    *  selections can be extracted.
    *
    *  @param _file The ini-file handle
    */
981
   virtual void loadSelection(const INIFile& _file) {};
982 983 984 985 986 987 988 989 990 991

   /** \brief Save selections into ini-file
    *
    *  This signal is emitted by SelectionBase-Plugin each time a selection
    *  should be written into a file. This ini-file handle is then passed
    *  to each object type selection plugin where object specific
    *  selections can be saved.
    *
    *  @param _file The ini-file handle
    */
992
   virtual void saveSelection(INIFile& _file) {};
993 994 995 996 997 998 999 1000

   /** \brief Key shortcut event happened
    *
    *  Emitted by selection base plugin whenever a registered key shortcut has been pressed.
    *
    *  @param _key       Key to register
    *  @param _modifiers Key modifiers (i.e. shift, control, meta keys, defaults to none)
    */
1001
   virtual void keyShortcutEvent(int _key, Qt::KeyboardModifiers _modifiers = Qt::NoModifier) {};
1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015


   /** @} */

   //===========================================================================
   /** @name Slots handled by the SelectionBasePlugin
    *
    * The following slots are implemented by the selection base plugin.
    * <b>You should not use them!</b>
    * @{ */
  //===========================================================================

   private slots:

1016 1017 1018 1019
   /** \brief Do not use. Implemented in SelectionBasePlugin
    *
    * @param _modeName               User visible name of the selection mode
    * @param _description            Description of the mode
Jan Möbius's avatar
Jan Möbius committed
1020
    * @param _icon                   Path to an icon displayed in the selection toolbar
1021 1022
    * @param _handleName             Handle of the selection mode
    */
Jan Möbius's avatar
Jan Möbius committed
1023
   virtual void slotAddSelectionEnvironment(QString _modeName, QString _description, QString _icon, QString& _handleName) {};
1024

1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037
   /** \brief Do not use. Implemented in SelectionBasePlugin
    *
    * @param _handleName             Handle of the selection mode
    * @param _type                   Datatype to register
    */
   virtual void slotRegisterType(QString _handleName, DataType _type) {};

   /** \brief Do not use. Implemented in SelectionBasePlugin
    *
    * Do not use! Implemented in SelectionBasePlugin
    *
    * @param _handleName             Handle of the selection mode
    * @param _name                   User visible name of the selection mode
Jan Möbius's avatar
Jan Möbius committed
1038
    * @param _icon                   Path to an icon displayed in the selection toolbar
1039 1040
    * @param _typeHandle             Handle for the type
    */
Jan Möbius's avatar
Jan Möbius committed
1041
   virtual void slotAddPrimitiveType(QString _handleName, QString _name, QString _icon, PrimitiveType& _typeHandle) {};
1042 1043 1044 1045

   /** \brief Do not use. Implemented in SelectionBasePlugin
    *
    * Do not use! Implemented in SelectionBasePlugin
1046 1047 1048 1049
    *
    * @param _handleName             Handle of the selection mode
    * @param _modeName               User visible name of the selection mode
    * @param _description            Description of the mode
Jan Möbius's avatar
Jan Möbius committed
1050
    * @param _icon                   Path to an icon displayed in the selection toolbar
1051 1052 1053
    * @param _associatedTypes        primitive types supported by this mode
    * @param _customIdentifier       Identifier of this mode
    */
Jan Möbius's avatar
Jan Möbius committed
1054
   virtual void slotAddCustomSelectionMode(QString _handleName, QString _modeName, QString _description, QString _icon,
1055
                                           PrimitiveType _associatedTypes, QString& _customIdentifier) {};
1056

1057
   /** \brief Do not use. Implemented in SelectionBasePlugin
1058 1059 1060 1061
    *
    * @param _handleName             Handle of the selection mode
    * @param _modeName               User visible name of the selection mode
    * @param _description            Description of the mode
Jan Möbius's avatar
Jan Möbius committed
1062
    * @param _icon                   Path to an icon displayed in the selection toolbar
1063 1064 1065 1066
    * @param _associatedTypes        primitive types supported by this mode
    * @param _customIdentifier       Identifier of this mode
    * @param _objectTypeRestriction  Object types supported by this mode
    */
Jan Möbius's avatar
Jan Möbius committed
1067
   virtual void slotAddCustomSelectionMode(QString _handleName, QString _modeName, QString _description, QString _icon,
1068
                                           PrimitiveType _associatedTypes, QString& _customIdentifier,
1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093
                                           DataType _objectTypeRestriction) {};

   /**  Do not use. Implemented in SelectionBasePlugin
    *
    * @param _handleName       handle of the mode
    * @param _show             Hide or show it
    * @param _associatedTypes  Types associated with this mode
    */
   virtual void slotShowToggleSelectionMode(QString _handleName, bool _show, PrimitiveType _associatedTypes) {};

   /**  Do not use. Implemented in SelectionBasePlugin
    *
    * @param _handleName       handle of the mode
    * @param _show             Hide or show it
    * @param _associatedTypes  Types associated with this mode
    */
   virtual void slotShowLassoSelectionMode(QString _handleName, bool _show, PrimitiveType _associatedTypes) {};

   /** Do not use. Implemented in SelectionBasePlugin
    *
    * @param _handleName       handle of the mode
    * @param _show             Hide or show it
    * @param _associatedTypes  Types associated with this mode
    */
   virtual void slotShowVolumeLassoSelectionMode(QString _handleName, bool _show, PrimitiveType _associatedTypes) {};
1094

1095 1096 1097 1098 1099 1100 1101
   /** Do not use. Implemented in SelectionBasePlugin
    *
    * @param _handleName       handle of the mode
    * @param _show             Hide or show it
    * @param _associatedTypes  Types associated with this mode
    */
   virtual void slotShowSurfaceLassoSelectionMode(QString _handleName, bool _show, PrimitiveType _associatedTypes) {};
1102

1103 1104 1105 1106 1107 1108 1109
   /** Do not use. Implemented in SelectionBasePlugin
    *
    * @param _handleName       handle of the mode
    * @param _show             Hide or show it
    * @param _associatedTypes  Types associated with this mode
    */
   virtual void slotShowSphereSelectionMode(QString _handleName, bool _show, PrimitiveType _associatedTypes) {};
1110

1111 1112 1113 1114 1115 1116 1117
   /** Do not use. Implemented in SelectionBasePlugin
    *
    * @param _handleName       handle of the mode
    * @param _show             Hide or show it
    * @param _associatedTypes  Types associated with this mode
    */
   virtual void slotShowClosestBoundarySelectionMode(QString _handleName, bool _show, PrimitiveType _associatedTypes) {};
1118

1119 1120 1121 1122 1123 1124 1125
   /** Do not use. Implemented in SelectionBasePlugin
    *
    * @param _handleName       handle of the mode
    * @param _show             Hide or show it
    * @param _associatedTypes  Types associated with this mode
    */
   virtual void slotShowFloodFillSelectionMode(QString _handleName, bool _show, PrimitiveType _associatedTypes) {};
1126

1127 1128 1129 1130 1131 1132 1133
   /** Do not use. Implemented in SelectionBasePlugin
    *
    * @param _handleName       handle of the mode
    * @param _show             Hide or show it
    * @param _associatedTypes  Types associated with this mode
    */
   virtual void slotComponentsSelectionMode(QString _handleName, bool _show, PrimitiveType _associatedTypes) {};
1134

1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167
   /** Do not use. Implemented in SelectionBasePlugin
    *
    * @param _key       Key to use
    * @param _modifiers Modifier for this key
    */
   virtual void slotRegisterKeyShortcut(int _key, Qt::KeyboardModifiers _modifiers) {};

   /** Do not use. Implemented in SelectionBasePlugin
    *
    * @param _types Returns the active types
    */
   virtual void slotGetActiveDataTypes(TypeList& _types) {};

   /** Do not use. Implemented in SelectionBasePlugin
    *
    * @param _type Returns the active primitive types
    */
   virtual void slotGetActivePrimitiveType(PrimitiveType& _type) {};

   /** Do not use. Implemented in SelectionBasePlugin
    *
    * @param _targetsOnly use target objects only
    */
   virtual void slotTargetObjectsOnly(bool& _targetsOnly) {};

   /** Do not use. Implemented in SelectionBasePlugin
    *
    * @param _handleName       handle of the mode
    * @param _operationsList   List of operations
    * @param _category         Category
    * @param _type             primitive types
    */
   virtual void slotAddSelectionOperations(QString _handleName, QStringList _operationsList, QString _category, PrimitiveType _type) {};
1168

1169 1170 1171 1172 1173 1174 1175 1176 1177
   /** Do not use. Implemented in SelectionBasePlugin
    *
    * @param _handleName       handle of the mode
    * @param _widget           The widget that controls the parameters
    * @param _category         Category
    * @param _type             primitive types
    */
   virtual void slotAddSelectionParameters(QString _handleName, QWidget* _widget, QString _category, PrimitiveType _type = 0u) {};

1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222

   /** @} */


};

/** \page selectionInterfacePage Selection Interface
\image html SelectionInterface.png

The SelectionInterface can be used to provide selection functions. Selection works
as follows. OpenFlipper basically contains the SelectionBasePlugin which offers
some graphical tools (such as selection sphere, lasso tools, etc.) that can be used for selecting entities.

Now each object type (poly/triangle meshes, skeletons, splines, whatever) has to implement
its own selection functionality. Say we wanted to implement selection for poly/tri mesh objects.
For this purpose we derive a plugin from SelectionInterface and create a new selection environment
via the addSelectionEnvironment() signal, naming it e.g. "Mesh Object Selection".

After having created the necessary selection environment, we have to register our specific data type,
that is tell the SelectionBase plugin which data types will be handled (selected) by our plugin.
In the example from above we would register DATA_POLY_MESH as well as DATA_TRIANGLE_MESH.
We do this by calling the signal registerType(). Now we have to determine which primitive type
should be selectable. For poly/tri meshes we would determine vertices, edges, halfedges and faces
to be selectable. This is performed via emission of the signal addPrimitiveType().

We can then choose which of the default selection tools should be available for this environment.
We could, for example, request the toggle, flood fill and the sphere selection tool by calling
the signals showToggleSelectionMode(), and so on. Additionally, it's possible to create
custom selection tools that can be completely different from the default ones.

After having requested the desired selection tools, each time a selection tool has been used,
the appropriate slot is called for further processing, that is the actual selection of the
primitives.

SelectionInterface also provides means to add operations for a specific primitive type
(such as, for example, "Clear Vertex Selection" or "Select All Vertices" for vertex selections).
We can tell SelectionBase to add there operations by emitting addSelectionOperations().
Each time an operation button has been clicked, slot slotSelectionOperation() is called.

The overall idea is to separate the UI and control elements from actual implementations
of selection functionality for a specific data type. So, in general SelectionBase manages
all UI control elements and and the rendering of the selection tools whereas the specific
type selection plugins manage the real selection of their entities as well as scripting functions.
*/

Jan Möbius's avatar
Jan Möbius committed
1223
Q_DECLARE_INTERFACE(SelectionInterface,"OpenFlipper.SelectionInterface/1.1")
1224 1225

#endif // SELECTIONINTERFACE_HH