1 #pragma once 2 3 #ifndef TOOL_INCLUDED 4 #define TOOL_INCLUDED 5 6 // TnzLib includes 7 #include "toonz/tstageobjectid.h" 8 #include "toonz/txsheet.h" 9 #include "toonz/imagepainter.h" 10 #include "toonz/tapplication.h" 11 #include "tools/cursors.h" 12 13 // TnzCore includes 14 #include "tcommon.h" 15 #include "tgeometry.h" 16 #include "tfilepath.h" 17 18 // Qt includes 19 #include <QString> 20 #include <QPoint> 21 22 #undef DVAPI 23 #undef DVVAR 24 #ifdef TNZTOOLS_EXPORTS 25 #define DVAPI DV_EXPORT_API 26 #define DVVAR DV_EXPORT_VAR 27 #else 28 #define DVAPI DV_IMPORT_API 29 #define DVVAR DV_IMPORT_VAR 30 #endif 31 32 //=================================================================== 33 34 // Forward Declarations 35 36 class TToolParam; 37 class TMouseEvent; 38 class TStroke; 39 class TImage; 40 class TPropertyGroup; 41 class TColorStyle; 42 class TFrameId; 43 class TPalette; 44 class TSelection; 45 46 class TFrameHandle; 47 class TXshLevelHandle; 48 class TXsheetHandle; 49 class TObjectHandle; 50 class TColumnHandle; 51 class TSceneHandle; 52 class TPaletteHandle; 53 class ToolHandle; 54 class TSelectionHandle; 55 class TOnionSkinMaskHandle; 56 class PaletteController; 57 class TFxHandle; 58 59 class ToolOptionsBox; 60 61 class QMenu; 62 class QKeyEvent; 63 64 //=================================================================== 65 66 //***************************************************************************************** 67 // TMouseEvent definition 68 //***************************************************************************************** 69 70 class DVAPI TMouseEvent { 71 public: 72 enum ModifierBitshift //! \brief Bit shifts from 1 associated with modifier 73 //! keys. 74 { SHIFT_BITSHIFT, //!< Bit shift for the Shift key modifier. 75 ALT_BITSHIFT, //!< Bit shift for the Alt key modifier. 76 CTRL_BITSHIFT //!< Bit shift for the Ctrl key modifier. 77 }; 78 79 enum ModifierMask //! \brief Bitmask specifying modifier keys applying on a 80 { //! mouse event. 81 NO_KEY = 0x0, 82 SHIFT_KEY = (1 << SHIFT_BITSHIFT), //!< Shift key is being pressed. 83 ALT_KEY = (1 << ALT_BITSHIFT), //!< Alt key is begin pressed. 84 CTRL_KEY = (1 << CTRL_BITSHIFT) //!< Ctrl key is being pressed. 85 }; 86 87 public: 88 TPointD m_pos; //!< Mouse position in window coordinates, bottom-left origin. 89 double m_pressure; //!< Pressure of the tablet pen (0.0 - 1.0) , or 1.0 for 90 //! pure mouse events. 91 92 ModifierMask m_modifiersMask; //!< Bitmask specifying key modifiers applying 93 //! on the event. 94 95 Qt::MouseButtons m_buttons; 96 Qt::MouseButton m_button; 97 QPointF m_mousePos; // mouse position obtained with QMouseEvent::pos() or 98 // QTabletEvent::pos() 99 bool m_isTablet; 100 101 public: TMouseEvent()102 TMouseEvent() 103 : m_pressure(1.0) 104 , m_modifiersMask(NO_KEY) 105 , m_buttons(Qt::NoButton) 106 , m_button(Qt::NoButton) 107 , m_isTablet(false) {} 108 isShiftPressed()109 bool isShiftPressed() const { return (m_modifiersMask & SHIFT_KEY); } isAltPressed()110 bool isAltPressed() const { return (m_modifiersMask & ALT_KEY); } isCtrlPressed()111 bool isCtrlPressed() const { return (m_modifiersMask & CTRL_KEY); } 112 isLeftButtonPressed()113 bool isLeftButtonPressed() const { return (m_buttons & Qt::LeftButton) != 0; } buttons()114 Qt::MouseButtons buttons() const { return m_buttons; } button()115 Qt::MouseButton button() const { return m_button; } mousePos()116 QPointF mousePos() const { return m_mousePos; } isTablet()117 bool isTablet() const { return m_isTablet; } 118 setModifiers(bool shiftPressed,bool altPressed,bool ctrlPressed)119 void setModifiers(bool shiftPressed, bool altPressed, bool ctrlPressed) { 120 m_modifiersMask = ModifierMask((shiftPressed << SHIFT_BITSHIFT) | 121 (altPressed << ALT_BITSHIFT) | 122 (ctrlPressed << CTRL_BITSHIFT)); 123 } 124 getModifiersMask()125 ModifierMask getModifiersMask() const { return m_modifiersMask; } 126 }; 127 128 //***************************************************************************************** 129 // TTool declaration 130 //***************************************************************************************** 131 132 /*! 133 \brief TTool is the abstract base class defining the interface for Toonz 134 tools - the ones 135 accessible from the Toolbar panel that users can activate to edit 136 the scene contents 137 interactively. 138 139 \details Toonz implements a number of interactive tools, like the <I>Brush 140 Tool</I>, <I>Fill 141 Tool</I>, <I>Zoom Tool</I> and others. They all inherit from this 142 class, which provides 143 the necessary interface and framework to implement a generic 144 interactive tool in Toonz. 145 146 A Toonz Tool should re-implement the following key functionalities: 147 <UL> 148 <LI> The abstract getToolType() method, which classifies the tool, 149 and 150 eventually getTargetType()</LI> 151 <LI> The draw() method, used to draw the tool on screen</LI> 152 <LI> The mouse-related methods, to grant user interaction</LI> 153 <LI> The getProperties() and onPropertyChanged() methods, to 154 define and track 155 a tool's TProperty members</LI> 156 <LI> The addContextMenuItems() method, to insert actions in 157 right-click menus</LI> 158 </UL> 159 \par Tool classification 160 Toonz enforces a strict classification of its tools that is used to 161 enable or disable them 162 in the appropriate contexts: 163 <UL> 164 <LI> <B>Generic Tools:</B> the tool is always enabled, since it 165 does not need to access 166 specific scene contents. Hidden tools typically prefer to 167 select this type since they 168 should handle disablements silently.</LI> 169 <LI> <B>Column Tools:</B> the tool is used to alter or define the 170 placement of a column's 171 content. It is disabled in Filmstrip view mode, since that's 172 a strictly level-related view.</LI> 173 <LI> <B>LevelRead Tools:</B> the tool is used to \a read a level's 174 images data. It is therefore 175 enabled on all view modes. The tool is disabled in camera 176 stand or 3D view modes if the 177 level's host column has sustained a placement which makes it 178 impossible to access image 179 data (as is the case with Plastic-deformed columns).</LI> 180 <LI> <B>LevelWrite Tools:</B> the tool is used to \a write a 181 level's images data. It is 182 disabled in all contexts where a LevelRead Tool would be 183 disabled. It is also disabled in 184 case the current level is of a type unsupported for write, 185 \a or the level is read-only 186 on disk.</LI> 187 </UL> 188 Furthermore, tools define a bitwise combination of <I>Target 189 Types</I>, which are the category 190 of level types it can work on (including every image type and the 191 motion path type). 192 The Target Type is used only associated with LevelRead and 193 LevelWrite tool types. 194 \n\n 195 There are a number of additional generic rules that define whenever 196 a tool is disabled: 197 <UL> 198 <LI> Every tool is disabled when a viewer is in playback.</LI> 199 <LI> Every non-Generic tool is disabled on level/columns that do 200 not host a 201 placeable image type (eg sound or magpie data).</LI> 202 <LI> Every non-Generic tool is disabled when working on 203 columns/levels that have 204 been hidden.</LI> 205 <LI> Every non-Generic tool is disabled when working on columns 206 that have been locked 207 (the lock icon on a column header).</LI> 208 </UL> 209 \par Drawing 210 Tools use OpenGL to draw in their currently associated Viewer 211 instance, which can be retrieved 212 through the getViewer() accessor function. The viewer is assigned to 213 the tool just before it 214 invokes the tool's draw() function - use the onSetViewer() virtual 215 method to access viewer data 216 \a before the viewer starts drawing (observe the tool is typically 217 drawn as an overlay, on top 218 of other stuff). 219 \n\n 220 Just before draw() is invoked by the viewer, the \p GL_MODELVIEW 221 matrix is automatically pushed 222 by the viewer with the tool-to-window affine returned by getMatrix() 223 (multiplied by the viewer's 224 view affine). Use glGetDoublev() to retrieve the effective 225 tool-to-window reference change 226 affine, and in case reimplement updateMatrix() to specify the affine 227 returned by getMatrix(). 228 \n\n 229 The default implementation for updateMatrix() sets the tool 230 reference to current object's 231 world one. 232 233 \par Tool Properties 234 A tool's properties must be implemented by defining one or more 235 TPropertyGroup containers, 236 and adding them the TProperty specializations corresponding to the 237 required parameters. 238 \n\n 239 Every TProperty instance in group 0 is automatically added to the 240 Tool Options panel 241 in Toonz's GUI. Further groups or special toolbar options must be 242 currently hard-coded 243 elsewhere. Tool Options panel construction will probably be 244 redirected to the tool in 245 future Toonz versions. 246 247 \par Context Menu Items 248 The addContextMenuItems() is used to insert context menu actions \a 249 before the standard 250 actions provided by the tool viewer. Remember to insert separators 251 to isolate commands 252 of different type (such as view, editing, etc). 253 */ 254 255 class DVAPI TTool { 256 public: 257 class Viewer; 258 259 typedef TApplication Application; 260 261 public: 262 enum ToolType //! Tool editing type. 263 { GenericTool = 1, //!< Tool will not deal with specific scene content. 264 ColumnTool = 2, //!< Tool deals with placement of column objects. 265 LevelReadTool = 4, //!< Tool reads a level's image data. 266 LevelWriteTool = 267 8, //!< Tool writes a level's image data (implies LevelReadTool). 268 269 // Convenience testing flags - getToolType() should not return these 270 271 LevelTool = LevelReadTool | LevelWriteTool }; 272 273 enum ToolTargetType //! Object types the tool can operate on. 274 { NoTarget = 0x0, 275 VectorImage = 0x1, //!< Will work on vector images 276 ToonzImage = 0x2, //!< Will work on colormap (tlv) images 277 RasterImage = 0x4, //!< Will work on fullcolor images 278 MeshImage = 0x8, //!< Will work on mesh images 279 Splines = 0x10, //!< Will work on motion paths 280 281 LevelColumns = 0x20, //!< Will work on level columns 282 MeshColumns = 0x40, //!< Will work on mesh columns 283 284 EmptyTarget = 0x80, //!< Will work on empty cells/columns 285 286 CommonImages = VectorImage | ToonzImage | RasterImage, 287 AllImages = CommonImages | MeshImage, 288 Vectors = VectorImage | Splines, 289 290 CommonLevels = CommonImages | LevelColumns, 291 MeshLevels = MeshImage | MeshColumns, 292 293 AllTargets = 0xffffffff, 294 }; 295 296 public: 297 static TTool *getTool(std::string toolName, ToolTargetType targetType); 298 299 static TApplication *getApplication(); setApplication(TApplication * application)300 static void setApplication(TApplication *application) { 301 m_application = application; 302 } 303 304 /*! \warning In case there is no level currently selected, <I>or the 305 object to be edited is a spline path</I>, the xsheet cell 306 returned by getImageCell() is empty. */ 307 308 static TXshCell 309 getImageCell(); //!< Returns the level-frame pair to be edited by the tool. 310 311 /*! \details The image returned by getImage() is either the one 312 associated to getImageCell(), or the vector image 313 corresponding to currently edited spline path. */ 314 315 static TImage *getImage( 316 bool toBeModified, 317 int subsampling = 0); //!< Returns the image to be edited by the tool. 318 319 static TImage *touchImage(); //!< Returns a pointer to the actual image - the 320 //! one of the frame that has been selected. 321 322 /*! \details This function is necessary since tools are created before 323 the main 324 application (TAB or Toonz) starts, and hence tr() calls have no 325 effect 326 (the translation is not yet installed - to install one you need at 327 least 328 an instance of QApplication / QCoreApplication). 329 330 \deprecated This so much stinks of a bug turned into design choice... */ 331 332 static void updateToolsPropertiesTranslation(); //!< Updates translation of 333 //! the bound properties of 334 //! every tool (invoking updateTranslation() for each). 335 336 public: 337 TTool(std::string toolName); ~TTool()338 virtual ~TTool() {} 339 340 virtual ToolType getToolType() const = 0; getTargetType()341 ToolTargetType getTargetType() const { return (ToolTargetType)m_targetType; } 342 getName()343 std::string getName() const { return m_name; } 344 345 /*! \details The default returns a generic box containing the options 346 for property group 0). 347 \sa See tooloptions.h for more details. */ 348 349 virtual ToolOptionsBox * 350 createOptionsBox(); //!< Factory function returning a newly created 351 //! GUI options box to be displayed for the tool 352 setViewer(Viewer * viewer)353 void setViewer(Viewer *viewer) { 354 m_viewer = viewer; 355 onSetViewer(); 356 } getViewer()357 Viewer *getViewer() const { return m_viewer; } 358 359 double getPixelSize() const; 360 361 //! Causes the refreshing of the \b rect portion of the viewer. 362 //! If rect is empty all viewer is refreshed. \b rect must be in image 363 //! coordinate. 364 void invalidate(const TRectD &rect = TRectD()); 365 366 /*! 367 Picks a region of the scene, using an OpenGL projection matrix to 368 restrict drawing to a small regionaround \p p of the viewport. 369 Retuns -1 if no object's view has been changed. 370 */ 371 int pick(const TPointD &p); isPicking()372 bool isPicking() const { return m_picking; } 373 updateTranslation()374 virtual void updateTranslation(){}; 375 376 /*! 377 This method is called before leftButtonDown() and can be used e.g. to create the 378 image if needed. 379 return true if the method execution can have changed the current tool 380 */ preLeftButtonDown()381 virtual bool preLeftButtonDown() { return false; } 382 mouseMove(const TPointD &,const TMouseEvent &)383 virtual void mouseMove(const TPointD &, const TMouseEvent &) {} leftButtonDown(const TPointD &,const TMouseEvent &)384 virtual void leftButtonDown(const TPointD &, const TMouseEvent &) {} leftButtonDrag(const TPointD &,const TMouseEvent &)385 virtual void leftButtonDrag(const TPointD &, const TMouseEvent &) {} leftButtonUp(const TPointD &,const TMouseEvent &)386 virtual void leftButtonUp(const TPointD &, const TMouseEvent &) {} leftButtonDoubleClick(const TPointD &,const TMouseEvent &)387 virtual void leftButtonDoubleClick(const TPointD &, const TMouseEvent &) {} rightButtonDown(const TPointD &,const TMouseEvent &)388 virtual void rightButtonDown(const TPointD &, const TMouseEvent &) {} keyDown(QKeyEvent *)389 virtual bool keyDown(QKeyEvent *) { return false; } 390 onInputText(std::wstring,std::wstring,int,int)391 virtual void onInputText(std::wstring, std::wstring, int, int){}; 392 onSetViewer()393 virtual void onSetViewer() {} 394 onActivate()395 virtual void onActivate() { 396 } //!< Callback invoked whenever the tool activates. onDeactivate()397 virtual void onDeactivate() { 398 } //!< Callback for tool deactivation, includes tool switch. 399 onImageChanged()400 virtual void onImageChanged() {} //!< Notifies changes in the image in use. 401 onEnter()402 virtual void onEnter() { 403 } //!< Callback for the mouse entering the viewer area. onLeave()404 virtual void onLeave() { 405 } //!< Callback for the mouse leaving the viewer area. 406 407 /*-- rasterSelectionTool 408 * のフローティング選択が残った状態でフレームが移動したときの挙動を決める --*/ onFrameSwitched()409 virtual void onFrameSwitched() {} 410 reset()411 virtual void reset() {} 412 draw()413 virtual void draw() {} //!< Draws the tool on the viewer. 414 isActive()415 bool isActive() const { 416 return m_active; 417 } //!< Used to know if a tool is active, (used in TextTool only). setActive(bool active)418 void setActive(bool active) { m_active = active; } 419 getProperties(int)420 virtual TPropertyGroup *getProperties(int) { return 0; } 421 422 /*! 423 Does the tasks associated to changes in \p propertyName and returns \p 424 true; 425 */ onPropertyChanged(std::string propertyName)426 virtual bool onPropertyChanged(std::string propertyName) { 427 return false; 428 } //!< Does the tasks associated to changes in \p propertyName and 429 //! returns \p true. getSelection()430 virtual TSelection *getSelection() { 431 return 0; 432 } //!< Returns a pointer to the tool selection. 433 434 //! \sa For a list of cursor ids cursor.h getCursorId()435 virtual int getCursorId() const { 436 return 0; 437 } //!< Returns the type of cursor used by the tool. 438 439 // returns true if the pressed key is recognized and processed. 440 // used in SceneViewer::event(), reimplemented in SelectionTool 441 // and ControlPointEditorTool isEventAcceptable(QEvent * e)442 virtual bool isEventAcceptable(QEvent *e) { return false; } 443 444 TXsheet *getXsheet() const; //!< Returns a pointer to the actual Xsheet. 445 446 int getFrame(); //!< Returns the actual frame in use. 447 int getColumnIndex(); //!< Returns the actual column index. 448 449 TStageObjectId getObjectId() 450 const; //!< Returns a pointer to the actual stage object. 451 452 void notifyImageChanged(); //!< Notifies changes on the actual image; used to 453 //! update 454 //! images on the level view. 455 void notifyImageChanged(const TFrameId &fid); //!< Notifies changes on the 456 //! frame \p fid; used to update 457 //! images on the level view. 458 459 /*! \details It can depend on the actual frame and the actual cell or 460 on the current fid (editing level). In editing scene if 461 the current cell is empty the method returns TFrameId::NO_FRAME. */ 462 463 TFrameId getCurrentFid() 464 const; //!< Returns the number of the actual editing frame. 465 getMatrix()466 const TAffine &getMatrix() const { return m_matrix; } setMatrix(const TAffine & matrix)467 void setMatrix(const TAffine &matrix) { m_matrix = matrix; } 468 469 TAffine getCurrentColumnMatrix(int frame = -1) 470 const; //!< Returns the current column matrix transformation. 471 //! if frame = -1 then it uses the current frame 472 //! \sa TXsheet::getPlacement. 473 474 TAffine getCurrentColumnParentMatrix() 475 const; //!< Returns the current matrix transformation of the 476 //! current stage object parent. 477 TAffine getCurrentObjectParentMatrix() const; 478 TAffine getCurrentObjectParentMatrix2() const; 479 480 /*! 481 Returns the matrix transformation of the stage object with column 482 index equal to \p index 483 and frame as the current frame. 484 if frame = -1 then it uses the current frame 485 \sa TXsheet::getPlacement. 486 */ 487 TAffine getColumnMatrix(int index, int frame = -1) const; 488 489 /*! 490 Updates the current matrix transformation with the actual column matrix 491 transformation. 492 \sa getCurrentColumnMatrix(). 493 */ 494 virtual void updateMatrix(); 495 496 /*! 497 Add a context menu to the actual tool, as for example pressing right mouse 498 button 499 with the stroke selection tool. 500 */ addContextMenuItems(QMenu * menu)501 virtual void addContextMenuItems(QMenu *menu) {} 502 enable(bool on)503 void enable(bool on) { m_enabled = on; } isEnabled()504 bool isEnabled() const { return m_enabled; } 505 506 QString updateEnabled(); //!< Sets the tool's \a enability and returns a 507 //! reason in case the tool was disabled. 508 virtual QString updateEnabled(int rowIndex, int columnIndex); 509 510 bool isColumnLocked(int columnIndex) const; 511 512 void resetInputMethod(); //!< Resets Input Context (IME) 513 514 // return true if the pencil mode is active in the Brush / PaintBrush / Eraser 515 // Tools. isPencilModeActive()516 virtual bool isPencilModeActive() { return false; } 517 518 // return true if the tool is busy with a mouse drag operation isDragging()519 virtual bool isDragging() const { return false; }; 520 521 void setSelectedFrames(const std::set<TFrameId> &selectedFrames); getSelectedFrames()522 static const std::set<TFrameId> &getSelectedFrames() { 523 return m_selectedFrames; 524 } 525 526 void tweenSelectedGuideStrokes(); 527 void tweenGuideStrokeToSelected(); 528 void flipGuideStrokeDirection(int mode); 529 530 public: 531 struct CellOps { 532 int r0; 533 int r1; 534 enum Type { ExistingToNew = 0, BlankToExisting, BlankToNew } type; 535 }; 536 static std::vector<CellOps> 537 m_cellsData; //!< \deprecated brutto brutto. fix 538 //! quick & dirty del baco #6213 (undo 539 //! con animation sheet) spiegazioni in 540 //! tool.cpp 541 static bool m_isLevelCreated; //!< \deprecated Shouldn't expose global 542 //! static variables. 543 static bool m_isFrameCreated; //!< \deprecated Shouldn't expose global 544 //! static variables. 545 static std::vector<TFrameId> m_oldFids; 546 static std::vector<TFrameId> m_newFids; 547 static bool m_isLevelRenumbererd; 548 549 protected: 550 std::string m_name; //!< The tool's name. 551 552 Viewer *m_viewer; //!< Tool's current viewer. 553 TAffine m_matrix; //!< World-to-window reference change affine. 554 555 int m_targetType; //!< The tool's image type target. 556 557 bool m_enabled; //!< Whether the tool allows user interaction. 558 bool m_active; 559 bool m_picking; 560 561 static TApplication *m_application; 562 563 static std::set<TFrameId> m_selectedFrames; 564 565 protected: 566 void bind(int targetType); 567 onSelectedFramesChanged()568 virtual void onSelectedFramesChanged() {} 569 disableString()570 virtual QString disableString() { 571 return QString(); 572 } //!< Returns a custom reason to disable the tool 573 }; 574 575 //***************************************************************************************** 576 // TTool::Viewer declaration 577 //***************************************************************************************** 578 579 /*! 580 \brief The TTool::Viewer class is the abstract base class that provides an 581 interface for 582 TTool viewer widgets (it is required that such widgets support 583 OpenGL). 584 */ 585 586 class TTool::Viewer { 587 protected: 588 ImagePainter::VisualSettings 589 m_visualSettings; //!< Settings used by the Viewer to draw scene contents 590 591 int guidedStrokePickMode = 0; 592 int m_guidedFrontStroke = -1; 593 int m_guidedBackStroke = -1; 594 595 public: Viewer()596 Viewer() {} ~Viewer()597 virtual ~Viewer() {} 598 visualSettings()599 const ImagePainter::VisualSettings &visualSettings() const { 600 return m_visualSettings; 601 } visualSettings()602 ImagePainter::VisualSettings &visualSettings() { return m_visualSettings; } 603 604 virtual double getPixelSize() const = 0; //!< Returns the length of a pixel 605 //!< in current OpenGL coordinates 606 607 virtual void invalidateAll() = 0; //!< Redraws the entire viewer, passing 608 //! through Qt's event system 609 virtual void GLInvalidateAll() = 0; //!< Redraws the entire viewer, bypassing 610 //! Qt's event system 611 virtual void GLInvalidateRect(const TRectD &rect) = 0; //!< Same as 612 //! GLInvalidateAll(), 613 //! for a specific 614 //! clipping rect 615 virtual void invalidateToolStatus() = 0; //!< Forces the viewer to update the 616 //! perceived status of tools getViewMatrix()617 virtual TAffine getViewMatrix() const { 618 return TAffine(); 619 } //!< Gets the viewer's current view affine (ie the transform from 620 //!< starting to current <I> world view <\I>) 621 622 //! return the column index of the drawing intersecting point \b p 623 //! (window coordinate, pixels, bottom-left origin) 624 virtual int posToColumnIndex(const TPointD &p, double distance, 625 bool includeInvisible = true) const = 0; 626 virtual void posToColumnIndexes(const TPointD &p, std::vector<int> &indexes, 627 double distance, 628 bool includeInvisible = true) const = 0; 629 630 //! return the row of the drawing intersecting point \b p (used with 631 //! onionskins) 632 //! (window coordinate, pixels, bottom-left origin) 633 virtual int posToRow(const TPointD &p, double distance, 634 bool includeInvisible = true, 635 bool currentColumnOnly = false) const = 0; 636 637 //! return pos in pixel, bottom-left origin 638 virtual TPointD worldToPos(const TPointD &worldPos) const = 0; 639 640 //! return the OpenGL nameId of the object intersecting point \b p 641 //! (window coordinate, pixels, bottom-left origin) 642 virtual int pick(const TPointD &point) = 0; 643 644 // note: winPos in pixel, top-left origin; 645 // when no camera movements have been defined then worldPos = 0 at camera 646 // center 647 virtual TPointD winToWorld(const TPointD &winPos) const = 0; 648 649 // delta.x: right panning, pixels; delta.y: down panning, pixels 650 virtual void pan(const TPointD &delta) = 0; 651 652 // center: window coordinates, pixels, bottomleft origin 653 virtual void zoom(const TPointD ¢er, double scaleFactor) = 0; 654 655 virtual void rotate(const TPointD ¢er, double angle) = 0; 656 virtual void rotate3D(double dPhi, double dTheta) = 0; 657 virtual bool is3DView() const = 0; 658 virtual bool getIsFlippedX() const = 0; 659 virtual bool getIsFlippedY() const = 0; 660 661 virtual double projectToZ(const TPointD &delta) = 0; 662 663 virtual TPointD getDpiScale() const = 0; 664 virtual int getVGuideCount() = 0; 665 virtual int getHGuideCount() = 0; 666 virtual double getHGuide(int index) = 0; 667 virtual double getVGuide(int index) = 0; 668 669 virtual void 670 resetInputMethod() = 0; // Intended to call QWidget->resetInputContext() 671 672 virtual void setFocus() = 0; 673 674 /*-- Toolで画面の内外を判断するため --*/ 675 virtual TRectD getGeometry() const = 0; 676 bindFBO()677 virtual void bindFBO() {} releaseFBO()678 virtual void releaseFBO() {} 679 getGuidedStrokePickerMode()680 int getGuidedStrokePickerMode() { return guidedStrokePickMode; } setGuidedStrokePickerMode(int mode)681 void setGuidedStrokePickerMode(int mode) { guidedStrokePickMode = mode; } 682 getGuidedStrokePickerCursor()683 int getGuidedStrokePickerCursor() { 684 if (guidedStrokePickMode < 0) 685 return ToolCursor::PickPrevCursor; 686 else if (guidedStrokePickMode > 0) 687 return ToolCursor::PickNextCursor; 688 else 689 return ToolCursor::PointingHandCursor; 690 } 691 getGuidedFrontStroke()692 int getGuidedFrontStroke() { return m_guidedFrontStroke; } setGuidedFrontStroke(int strokeIdx)693 void setGuidedFrontStroke(int strokeIdx) { 694 m_guidedFrontStroke = strokeIdx; 695 invalidateAll(); 696 } 697 getGuidedBackStroke()698 int getGuidedBackStroke() { return m_guidedBackStroke; } setGuidedBackStroke(int strokeIdx)699 void setGuidedBackStroke(int strokeIdx) { 700 m_guidedBackStroke = strokeIdx; 701 invalidateAll(); 702 } 703 704 void getGuidedFrameIdx(int *backIdx, int *frontIdx); 705 void doPickGuideStroke(const TPointD &pos); 706 }; 707 708 #endif 709