SelectionInterface.hh 57.6 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
#pragma once
43

44
#include <OpenFlipper/INIFile/INIFile.hh>
45
#include <OpenFlipper/common/Types.hh>
Matthias Möller's avatar
Matthias Möller committed
46 47


48
#include <QWidget>
Matthias Möller's avatar
Matthias Möller committed
49

50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

/** \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
75
    virtual ~SelectionInterface() {};
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91

    //===========================================================================
    /** @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.
92 93 94 95 96 97 98
     *
     * 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
     
99
     emit addSelectionEnvironment("Mesh Object Selections", "Select Triangle Mesh Primitives.",
Jan Möbius's avatar
Jan Möbius committed
100
                                 someIconPath + "mesh_selection.png", environmentHandle_);
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
     \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
121 122 123
     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_);
124 125 126 127 128 129 130 131 132 133 134 135 136 137
     
     \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.
     *
138 139 140 141 142 143 144 145 146 147 148 149 150 151
     * @{ */
    //===========================================================================

    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
152
     *  @param _icon        Path to the icon for this mode (basically a type icon)
153 154
     *  @param _handleName  The handle of the recently added selection environment. Needed for referencing
     */
Jan Möbius's avatar
Jan Möbius committed
155
    virtual void addSelectionEnvironment(QString _modeName, QString _description, QString _icon, QString& _handleName) {};
156 157 158 159 160 161 162 163 164 165 166

    /** \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
     */
167
    virtual void registerType(QString _handleName, DataType _type) {};
168 169 170 171 172 173 174 175 176

    /** \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
177
     *  @param _icon        Path to the icon for the primitive type
178 179
     *  @param _typeHandle  The returned handle to the added primitive type
     */
Jan Möbius's avatar
Jan Möbius committed
180
    virtual void addPrimitiveType(QString _handleName, QString _name, QString _icon, PrimitiveType& _typeHandle) {};
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198

    /** @} */


    //===========================================================================
    /** @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
199
     * You can also add your custom selection mode via addCustomSelectionMode().
200 201 202 203 204 205 206 207
     *
     * 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
208
     emit addCustomSelectionMode(environmentHandle_, "My Custom Selection", "Description of my mode", someIconFile, vertexType_ | edgeType_);
209 210 211 212 213 214 215 216 217 218 219 220 221
     
     \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.
     *
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
     * @{ */
    //===========================================================================

    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)
     */
238
    virtual void showToggleSelectionMode(QString _handleName, bool _show, PrimitiveType _associatedTypes) {};
239 240 241 242 243 244 245 246 247 248 249 250

    /** \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)
     */
251
    virtual void showLassoSelectionMode(QString _handleName, bool _show, PrimitiveType _associatedTypes) {};
252 253 254 255 256 257 258 259 260 261 262 263

    /** \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)
     */
264
    virtual void showVolumeLassoSelectionMode(QString _handleName, bool _show, PrimitiveType _associatedTypes) {};
265 266 267 268 269 270 271 272 273 274 275 276

    /** \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)
     */
277
    virtual void showSurfaceLassoSelectionMode(QString _handleName, bool _show, PrimitiveType _associatedTypes) {};
278 279 280 281 282 283 284 285 286 287 288 289

    /** \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)
     */
290
    virtual void showSphereSelectionMode(QString _handleName, bool _show, PrimitiveType _associatedTypes) {};
291 292 293 294 295 296 297 298 299 300 301 302

    /** \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)
     */
303
    virtual void showClosestBoundarySelectionMode(QString _handleName, bool _show, PrimitiveType _associatedTypes) {};
304 305 306 307 308 309 310 311 312 313 314 315

    /** \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)
     */
316
    virtual void showFloodFillSelectionMode(QString _handleName, bool _show, PrimitiveType _associatedTypes) {};
317

318 319 320 321 322 323 324 325 326 327 328
    /** \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)
     */
329
    virtual void showComponentsSelectionMode(QString _handleName, bool _show, PrimitiveType _associatedTypes) {};
330

331 332 333 334 335 336 337 338 339 340 341 342 343 344
    /** \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
345
     *  @param _icon            Path to an icon which is used for this selection mode
346 347 348
     *  @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
349
    virtual void addCustomSelectionMode(QString _handleName, QString _modeName, QString _description, QString _icon,
350
                                        PrimitiveType _associatedTypes, QString& _customIdentifier) {};
Jan Möbius's avatar
Jan Möbius committed
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365

    /** \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
366
     *  @param _icon                  Path to an icon which is used for this selection mode
Jan Möbius's avatar
Jan Möbius committed
367 368 369 370
     *  @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
371
    virtual void addCustomSelectionMode(QString _handleName, QString _modeName, QString _description, QString _icon,
372
                                        PrimitiveType _associatedTypes, QString& _customIdentifier,
373
                                        DataType _objectTypeRestriction) {};
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395

    /** @} */



    //===========================================================================
     /** @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
     */
396
    virtual void getActiveDataTypes(TypeList& _types) {};
397 398 399 400 401 402 403

    /** \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
     */
404
    virtual void getActivePrimitiveType(PrimitiveType& _type) {};
405 406 407 408 409 410 411

    /** \brief Indicates whether selection should be performed on target objects only
     *
     *  Self-explanatory
     *
     *  @param _targetsOnly True if selection should restrict to target objects
     */
412
    virtual void targetObjectsOnly(bool& _targetsOnly) {};
413 414 415 416 417 418

    /** @} */

    //===========================================================================
     /** @name File Interaction
      *
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
      * 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.
452 453 454 455 456
      * @{ */
    //===========================================================================

    private slots:

457 458 459 460 461 462 463 464
    /** \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
    */ 
465
    virtual void slotLoadSelection(const INIFile& _file) {};
466 467 468 469 470 471 472 473 474
    
    /** \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
    */
475
    virtual void slotSaveSelection(INIFile& _file) {};
476

477 478 479 480 481 482 483 484 485
    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
    */
486
    virtual void loadSelection(int _objId, const QString& _filename) {};
487

488 489 490 491
    /** @} */

    //===========================================================================
    /** @name Keyboard Interactions
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
     *
     * 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
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547
     *
     * @{ */
    //===========================================================================

    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)
     */
548
    virtual void registerKeyShortcut(int _key, Qt::KeyboardModifiers _modifiers = Qt::NoModifier) {};
549 550 551 552


    private slots:

553 554 555 556 557 558 559 560 561
    /** \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
    */  
562
    virtual void slotKeyShortcutEvent(int _key, Qt::KeyboardModifiers _modifiers) {};
563 564 565 566 567

    /** @} */

    //===========================================================================
    /** @name User Interface controls
568 569 570 571 572 573 574 575 576 577 578 579 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
     *
     * 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
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645
     *
     * @{ */
    //===========================================================================

    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)
     */
646
    virtual void addSelectionOperations(QString _handleName, QStringList _operationsList, QString _category, PrimitiveType _type = 0u) {};
647

648 649 650 651 652 653 654 655 656 657 658 659
    /** \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) {};

660 661
    private slots:

662 663 664 665 666 667 668
    /** \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
    */
669
    virtual void slotSelectionOperation(QString _operation) {};
670 671 672 673 674 675 676 677 678 679 680


    /** @} */

   //===========================================================================
    /** @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.
     *
681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711
     * 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
     *
712 713 714 715 716 717 718 719 720 721
     * @{ */
   //===========================================================================

   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.
    *
722
    *  @param _event               The mouse event that occurred
723 724 725
    *  @param _currentType         The currently active primitive type
    *  @param _deselect            True if entities should be deselected
    */
726
   virtual void slotToggleSelection(QMouseEvent* _event, PrimitiveType _currentType, bool _deselect) {};
727 728 729 730 731 732 733 734 735 736 737 738

   /** \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
    */
739
   virtual void slotLassoSelection(QMouseEvent* _event, PrimitiveType _currentType, bool _deselect) {};
740 741 742 743 744 745 746 747 748 749 750 751

   /** \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
    */
752
   virtual void slotVolumeLassoSelection(QMouseEvent* _event, PrimitiveType _currentType, bool _deselect) {};
753 754 755 756 757 758 759 760 761 762 763 764 765

   /** \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
    */
766
   virtual void slotSurfaceLassoSelection(QMouseEvent* _event, PrimitiveType _currentType, bool _deselect) {};
767 768 769 770 771 772 773 774

   /** \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.
    *
775
    *  @param _event               The mouse event that currently is performed
776 777 778 779
    *  @param _radius              The current radius of the selection sphere
    *  @param _currentType         The currently active primitive type
    *  @param _deselect            True if entities should be deselected
    */
780
   virtual void slotSphereSelection(QMouseEvent* _event, double _radius, PrimitiveType _currentType, bool _deselect) {};
781 782 783 784 785 786 787 788

   /** \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.
    *
789
    *  @param _event               The mouse event that currently is performed
790 791 792
    *  @param _currentType         The currently active primitive type
    *  @param _deselect            True if entities should be deselected
    */
793
   virtual void slotClosestBoundarySelection(QMouseEvent* _event, PrimitiveType _currentType, bool _deselect) {};
794 795 796 797 798 799 800 801

   /** \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.
    *
802
    *  @param _event               The mouse event that currently is performed
803 804 805
    *  @param _currentType         The currently active primitive type
    *  @param _deselect            True if entities should be deselected
    */
806
   virtual void slotFloodFillSelection(QMouseEvent* _event, PrimitiveType _currentType, bool _deselect) {};
807

808 809 810 811 812 813 814 815 816 817
   /** \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
    */
818
   virtual void slotComponentsSelection(QMouseEvent* _event, PrimitiveType _currentType, bool _deselect) {};
819

820 821 822 823 824 825 826
   /** \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
827
    *  @param _customIdentifier Holds the identifier of the custom selection modes
828 829
    *  @param _deselect            True if entities should be deselected
    */
830
   virtual void slotCustomSelection(QMouseEvent* _event, PrimitiveType _currentType, QString _customIdentifier, bool _deselect) {};
831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853


   /** @} */



   //===========================================================================
    /** @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
    */
854
   virtual void selectionOperation(QString _operation) {};
855 856 857 858


   /** \brief Emitted by selection base plugin whenever the user performs a toggle selection
    *
859
    *  This connects to slotToggleSelection() which has to be implemented
860 861
    *  by each type selection plugin if this interactive selection mode should be provided.
    *
862
    *  @param _event               The mouse event that currently is performed
863 864 865
    *  @param _currentType         The currently active primitive type
    *  @param _deselect            True if entities should be deselected
    */
866
   virtual void toggleSelection(QMouseEvent* _event, PrimitiveType _currentType, bool _deselect) {};
867 868 869

   /** \brief Emitted by selection base plugin whenever the user performs a lasso selection
    *
870
    *  This connects to slotLassoSelection() which has to be implemented
871 872 873 874 875 876
    *  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
    */
877
   virtual void lassoSelection(QMouseEvent* _event, PrimitiveType _currentType, bool _deselect) {};
878 879 880

   /** \brief Emitted by selection base plugin whenever the user performs a volume lasso selection
    *
881
    *  This connects to slotVolumeLassoSelection() which has to be implemented
882 883 884 885 886 887
    *  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
    */
888
   virtual void volumeLassoSelection(QMouseEvent* _event, PrimitiveType _currentType, bool _deselect) {};
889 890 891

   /** \brief Emitted by selection base plugin whenever the user performs a surface lasso selection
    *
892
    *  This connects to slotSurfaceLassoSelection() which has to be implemented
893 894 895 896 897 898
    *  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
    */
899
   virtual void surfaceLassoSelection(QMouseEvent* _event, PrimitiveType _currentType, bool _deselect) {};
900 901 902

   /** \brief Emitted by selection base plugin whenever the user performs a sphere selection
    *
903
    *  This connects to slotSphereSelection() which has to be implemented
904 905
    *  by each type selection plugin if this interactive selection mode should be provided.
    *
906
    *  @param _event               The mouse event that currently is performed
907 908 909 910
    *  @param _radius              The current radius of the selection sphere
    *  @param _currentType         The currently active primitive type
    *  @param _deselect            True if entities should be deselected
    */
911
   virtual void sphereSelection(QMouseEvent* _event, double _radius, PrimitiveType _currentType, bool _deselect) {};
912 913 914

   /** \brief Emitted by selection base plugin whenever the user performs a closest boundary selection
    *
915
    *  This connects to slotClosestBoundarySelection() which has to be implemented
916 917
    *  by each type selection plugin if this interactive selection mode should be provided.
    *
918
    *  @param _event               The mouse event that currently is performed
919 920 921
    *  @param _currentType         The currently active primitive type
    *  @param _deselect            True if entities should be deselected
    */
922
   virtual void closestBoundarySelection(QMouseEvent* _event, PrimitiveType _currentType, bool _deselect) {};
923 924 925

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

935 936 937 938 939 940 941 942 943
   /** \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
    */
944
   virtual void componentsSelection(QMouseEvent* _event, PrimitiveType _currentType, bool _deselect) {};
945

946 947 948 949 950 951 952
   /** \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
953
    *  @param _customIdentifier    Holds the identifier of the custom selection modes
954 955
    *  @param _deselect            True if entities should be deselected
    */
956
   virtual void customSelection(QMouseEvent* _event, PrimitiveType _currentType, QString _customIdentifier, bool _deselect) {};
957 958 959 960 961 962 963 964 965 966

   /** \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
    */
967
   virtual void loadSelection(const INIFile& _file) {};
968 969 970 971 972 973 974 975 976 977

   /** \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
    */
978
   virtual void saveSelection(INIFile& _file) {};
979 980 981 982 983 984 985 986

   /** \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)
    */
987
   virtual void keyShortcutEvent(int _key, Qt::KeyboardModifiers _modifiers = Qt::NoModifier) {};
988 989 990 991 992 993 994 995 996 997 998 999 1000 1001


   /** @} */

   //===========================================================================
   /** @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:

1002 1003 1004 1005
   /** \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
1006
    * @param _icon                   Path to an icon displayed in the selection toolbar
1007 1008
    * @param _handleName             Handle of the selection mode
    */
Jan Möbius's avatar
Jan Möbius committed
1009
   virtual void slotAddSelectionEnvironment(QString _modeName, QString _description, QString _icon, QString& _handleName) {};
1010

1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023
   /** \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
1024
    * @param _icon                   Path to an icon displayed in the selection toolbar
1025 1026
    * @param _typeHandle             Handle for the type
    */
Jan Möbius's avatar
Jan Möbius committed
1027
   virtual void slotAddPrimitiveType(QString _handleName, QString _name, QString _icon, PrimitiveType& _typeHandle) {};
1028 1029 1030 1031

   /** \brief Do not use. Implemented in SelectionBasePlugin
    *
    * Do not use! Implemented in SelectionBasePlugin
1032 1033 1034 1035
    *
    * @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
1036
    * @param _icon                   Path to an icon displayed in the selection toolbar
1037 1038 1039
    * @param _associatedTypes        primitive types supported by this mode
    * @param _customIdentifier       Identifier of this mode
    */
Jan Möbius's avatar
Jan Möbius committed
1040
   virtual void slotAddCustomSelectionMode(QString _handleName, QString _modeName, QString _description, QString _icon,
1041
                                           PrimitiveType _associatedTypes, QString& _customIdentifier) {};
1042

1043
   /** \brief Do not use. Implemented in SelectionBasePlugin
1044 1045 1046 1047
    *
    * @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
1048
    * @param _icon                   Path to an icon displayed in the selection toolbar
1049 1050 1051 1052
    * @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
1053
   virtual void slotAddCustomSelectionMode(QString _handleName, QString _modeName, QString _description, QString _icon,
1054
                                           PrimitiveType _associatedTypes, QString& _customIdentifier,
1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079
                                           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) {};
1080

1081 1082 1083 1084 1085 1086 1087
   /** 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) {};
1088

1089 1090 1091 1092 1093 1094 1095
   /** 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) {};
1096

1097 1098 1099 1100 1101 1102 1103
   /** 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) {};
1104

1105 1106 1107 1108 1109 1110 1111
   /** 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) {};
1112

1113 1114 1115 1116 1117 1118 1119
   /** 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) {};
1120

1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153
   /** 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) {};
1154

1155 1156 1157 1158 1159 1160 1161 1162 1163
   /** 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) {};

1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 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

   /** @} */


};

/** \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
1209
Q_DECLARE_INTERFACE(SelectionInterface,"OpenFlipper.SelectionInterface/1.1")
1210