QElectroTech  0.8-dev
Public Slots | Signals | Public Member Functions | Protected Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
DiagramView Class Reference

#include <diagramview.h>

Inherits QGraphicsView.

Collaboration diagram for DiagramView:
Collaboration graph

Public Slots

void selectNothing ()
 
void selectAll ()
 
void selectInvert ()
 
void setVisualisationMode ()
 
void setSelectionMode ()
 
void zoom (const qreal zoom_factor)
 DiagramView::zoom Zomm the view. A zoom_factor > 1 zoom in. A zoom_factor < 1 zoom out. More...
 
void zoomFit ()
 
void zoomContent ()
 
void zoomReset ()
 
void cut ()
 
void copy ()
 
void paste (const QPointF &=QPointF(), QClipboard::Mode=QClipboard::Clipboard)
 DiagramView::paste Import the element stored in the clipboard to the diagram. More...
 
void pasteHere ()
 
void adjustSceneRect ()
 DiagramView::adjustSceneRect Calcul and set the area of the scene visualized by this view. More...
 
void updateWindowTitle ()
 
void editSelectedConductorColor ()
 DiagramView::editSelectedConductorColor Edit the color of the selected conductor; does nothing if multiple conductors are selected. More...
 
void editConductorColor (Conductor *)
 
void resetConductors ()
 

Signals

void modeChanged ()
 Signal emitted after the selection mode changed. More...
 
void titleChanged (DiagramView *, const QString &)
 Signal emitted after the diagram title changed. More...
 
void findElementRequired (const ElementsLocation &)
 Signal emitted when users wish to locate an element from the diagram within elements collection. More...
 
void editElementRequired (const ElementsLocation &)
 Signal emitted when users wish to edit an element from the diagram. More...
 
void showDiagram (Diagram *)
 Signal emmitted when diagram must be show. More...
 
void freeRubberBandChanged (QPolygonF polygon)
 

Public Member Functions

 DiagramView (Diagram *diagram, QWidget *=nullptr)
 
 ~DiagramView () override
 
QString title () const
 
void editDiagramProperties ()
 DiagramView::editDiagramProperties Edit the properties of the viewed digram. More...
 
Diagramdiagram ()
 
QETDiagramEditordiagramEditor () const
 
void editSelection ()
 DiagramView::editSelection Edit the selected item if he can be edited and if only one item is selected. More...
 
void setEventInterface (DVEventInterface *event_interface)
 DiagramView::setEventInterface Set an event interface to diagram view. If diagram view already have an event interface, he delete it before. Diagram view take ownership of event interface and delete it when event interface is finish. More...
 
QList< QAction * > contextMenuActions () const
 DiagramView::contextMenuActions. More...
 

Protected Member Functions

void mouseDoubleClickEvent (QMouseEvent *) override
 DiagramView::mouseDoubleClickEvent. More...
 
void contextMenuEvent (QContextMenuEvent *) override
 DiagramView::contextMenuEvent. More...
 
void wheelEvent (QWheelEvent *) override
 DiagramView::wheelEvent Manage wheel event of mouse. More...
 
void focusInEvent (QFocusEvent *) override
 
void keyPressEvent (QKeyEvent *) override
 DiagramView::keyPressEvent Handles "key press" events. Reimplemented here to switch to visualisation mode if needed. More...
 
void keyReleaseEvent (QKeyEvent *) override
 
bool event (QEvent *) override
 DiagramView::event Manage the event on this diagram view. -At first activation (QEvent::WindowActivate or QEvent::Show) we zoomFit. -Convert event interpreted to mouse event to gesture event if needed. -send Shortcut to view (by default send to QMenu /QAction) Gere les evenements de la DiagramView. More...
 
void paintEvent (QPaintEvent *event) override
 DiagramView::paintEvent Reimplemented from QGraphicsView. More...
 
void mousePressEvent (QMouseEvent *) override
 
void mouseMoveEvent (QMouseEvent *) override
 DiagramView::mouseMoveEvent Manage the event move mouse. More...
 
void mouseReleaseEvent (QMouseEvent *) override
 DiagramView::mouseReleaseEvent Manage event release click mouse. More...
 
void dragEnterEvent (QDragEnterEvent *) override
 
void dragMoveEvent (QDragMoveEvent *) override
 
void dropEvent (QDropEvent *) override
 
virtual bool switchToVisualisationModeIfNeeded (QInputEvent *e)
 
virtual bool switchToSelectionModeIfNeeded (QInputEvent *e)
 
virtual bool isCtrlShifting (QInputEvent *)
 
virtual bool selectedItemHasFocus ()
 

Private Slots

void adjustGridToZoom ()
 
void applyReadOnly ()
 

Private Member Functions

 DiagramView (const DiagramView &)
 
void handleElementDrop (QDropEvent *)
 DiagramView::handleElementDrop Handle the drop of an element. More...
 
void handleTitleBlockDrop (QDropEvent *)
 DiagramView::handleTitleBlockDrop Handle the dropEvent that contain data of a titleblock. More...
 
void handleTextDrop (QDropEvent *)
 
void scrollOnMovement (QKeyEvent *)
 
bool gestureEvent (QGestureEvent *event)
 DiagramView::gestureEvent Use the pinch of the trackpad for zoom. More...
 
QRectF viewedSceneRect () const
 
bool mustIntegrateTitleBlockTemplate (const TitleBlockTemplateLocation &) const
 
bool gestures () const
 DiagramView::gestures. More...
 

Private Attributes

Diagramm_diagram = nullptr
 
DVEventInterfacem_event_interface = nullptr
 
QAction * m_paste_here = nullptr
 
QAction * m_multi_paste = nullptr
 
QPoint m_paste_here_pos
 
QPointF m_drag_last_pos
 
bool m_fresh_focus_in
 
bool m_first_activation = true
 
QList< QAction * > m_separators
 
QPolygonF m_free_rubberband
 
bool m_free_rubberbanding = false
 

Detailed Description

This class provides a widget to render an electric diagram in an editable, interactive way.

Constructor & Destructor Documentation

◆ DiagramView() [1/2]

DiagramView::DiagramView ( Diagram diagram,
QWidget *  parent = nullptr 
)

Constructeur

Parameters
diagramSchema a afficher ; si diagram vaut 0, un nouveau Diagram est utilise
parentLe QWidget parent de cette vue de schema
Here is the call graph for this function:

◆ ~DiagramView()

DiagramView::~DiagramView ( )
override

Destructeur

◆ DiagramView() [2/2]

DiagramView::DiagramView ( const DiagramView )
private

Member Function Documentation

◆ adjustGridToZoom

void DiagramView::adjustGridToZoom ( )
privateslot

Enables or disables the drawing grid according to the amount of pixels display

Here is the call graph for this function:
Here is the caller graph for this function:

◆ adjustSceneRect

void DiagramView::adjustSceneRect ( )
slot

DiagramView::adjustSceneRect Calcul and set the area of the scene visualized by this view.

Here is the caller graph for this function:

◆ applyReadOnly

void DiagramView::applyReadOnly ( )
privateslot

Fait en sorte que le schema ne soit editable que s'il n'est pas en lecture seule

Here is the caller graph for this function:

◆ contextMenuActions()

QList< QAction * > DiagramView::contextMenuActions ( ) const

DiagramView::contextMenuActions.

Returns
a list of actions currently available for a context menu.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ contextMenuEvent()

void DiagramView::contextMenuEvent ( QContextMenuEvent *  e)
overrideprotected

DiagramView::contextMenuEvent.

Parameters
e
Here is the call graph for this function:

◆ copy

void DiagramView::copy ( )
slot

Copie les elements selectionnes du schema dans le presse-papier

Here is the caller graph for this function:

◆ cut

void DiagramView::cut ( )
slot

Copie les elements selectionnes du schema dans le presse-papier puis les supprime

Here is the call graph for this function:

◆ diagram()

Diagram* DiagramView::diagram ( )
inline
Here is the caller graph for this function:

◆ diagramEditor()

QETDiagramEditor * DiagramView::diagramEditor ( ) const
Returns
l'editeur de schemas parent ou 0
Here is the caller graph for this function:

◆ dragEnterEvent()

void DiagramView::dragEnterEvent ( QDragEnterEvent *  e)
overrideprotected

Accepte ou refuse le drag'n drop en fonction du type de donnees entrant

Parameters
ele QDragEnterEvent correspondant au drag'n drop tente

◆ dragMoveEvent()

void DiagramView::dragMoveEvent ( QDragMoveEvent *  e)
overrideprotected

Accepte ou refuse le drag'n drop en fonction du type de donnees entrant

Parameters
ele QDragMoveEvent correspondant au drag'n drop tente

◆ dropEvent()

void DiagramView::dropEvent ( QDropEvent *  e)
overrideprotected

Handle the drops accepted on diagram (elements and title block templates).

Parameters
ethe QDropEvent describing the current drag'n drop
Here is the call graph for this function:

◆ editConductorColor

void DiagramView::editConductorColor ( Conductor edited_conductor)
slot

Edit the color of the given conductor

Parameters
edited_conductorConductor we want to change the color
Here is the call graph for this function:
Here is the caller graph for this function:

◆ editDiagramProperties()

void DiagramView::editDiagramProperties ( )

DiagramView::editDiagramProperties Edit the properties of the viewed digram.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ editElementRequired

void DiagramView::editElementRequired ( const ElementsLocation )
signal

Signal emitted when users wish to edit an element from the diagram.

Here is the caller graph for this function:

◆ editSelectedConductorColor

void DiagramView::editSelectedConductorColor ( )
slot

DiagramView::editSelectedConductorColor Edit the color of the selected conductor; does nothing if multiple conductors are selected.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ editSelection()

void DiagramView::editSelection ( )

DiagramView::editSelection Edit the selected item if he can be edited and if only one item is selected.

Here is the caller graph for this function:

◆ event()

bool DiagramView::event ( QEvent *  e)
overrideprotected

DiagramView::event Manage the event on this diagram view. -At first activation (QEvent::WindowActivate or QEvent::Show) we zoomFit. -Convert event interpreted to mouse event to gesture event if needed. -send Shortcut to view (by default send to QMenu /QAction) Gere les evenements de la DiagramView.

Parameters
e: the event.
Returns
Here is the call graph for this function:
Here is the caller graph for this function:

◆ findElementRequired

void DiagramView::findElementRequired ( const ElementsLocation )
signal

Signal emitted when users wish to locate an element from the diagram within elements collection.

Here is the caller graph for this function:

◆ focusInEvent()

void DiagramView::focusInEvent ( QFocusEvent *  e)
overrideprotected

Handles "Focus in" events. Reimplemented here to store the fact the focus was freshly acquired again using the mouse. This information is later used in DiagramView::mousePressEvent().

◆ freeRubberBandChanged

void DiagramView::freeRubberBandChanged ( QPolygonF  polygon)
signal

Signal emmtted when free rubberband changed. When free rubberband selection ends this signal will be emitted with null value.

Here is the caller graph for this function:

◆ gestureEvent()

bool DiagramView::gestureEvent ( QGestureEvent *  event)
private

DiagramView::gestureEvent Use the pinch of the trackpad for zoom.

Parameters
event
Returns
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gestures()

bool DiagramView::gestures ( ) const
private

DiagramView::gestures.

Returns
Here is the caller graph for this function:

◆ handleElementDrop()

void DiagramView::handleElementDrop ( QDropEvent *  event)
private

DiagramView::handleElementDrop Handle the drop of an element.

Parameters
eventthe QDropEvent describing the current drag'n drop
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleTextDrop()

void DiagramView::handleTextDrop ( QDropEvent *  e)
private
  @brief DiagramView::handleTextDrop

handle the drop of text

Parameters
ethe QDropEvent describing the current drag'n drop
Here is the caller graph for this function:

◆ handleTitleBlockDrop()

void DiagramView::handleTitleBlockDrop ( QDropEvent *  e)
private

DiagramView::handleTitleBlockDrop Handle the dropEvent that contain data of a titleblock.

Parameters
e
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isCtrlShifting()

bool DiagramView::isCtrlShifting ( QInputEvent *  e)
protectedvirtual
Returns
true if the user is pressing Ctrl and Shift simultaneously.
Here is the caller graph for this function:

◆ keyPressEvent()

void DiagramView::keyPressEvent ( QKeyEvent *  e)
overrideprotected

DiagramView::keyPressEvent Handles "key press" events. Reimplemented here to switch to visualisation mode if needed.

Parameters
e
Here is the call graph for this function:

◆ keyReleaseEvent()

void DiagramView::keyReleaseEvent ( QKeyEvent *  e)
overrideprotected

Handles "key release" events. Reimplemented here to switch to selection mode if needed.

Here is the call graph for this function:

◆ modeChanged

void DiagramView::modeChanged ( )
signal

Signal emitted after the selection mode changed.

Here is the caller graph for this function:

◆ mouseDoubleClickEvent()

void DiagramView::mouseDoubleClickEvent ( QMouseEvent *  e)
overrideprotected

DiagramView::mouseDoubleClickEvent.

Parameters
e
Here is the call graph for this function:

◆ mouseMoveEvent()

void DiagramView::mouseMoveEvent ( QMouseEvent *  e)
overrideprotected

DiagramView::mouseMoveEvent Manage the event move mouse.

Here is the call graph for this function:

◆ mousePressEvent()

void DiagramView::mousePressEvent ( QMouseEvent *  e)
overrideprotected

Manage the events press click : click to add an independent text field

Here is the call graph for this function:

◆ mouseReleaseEvent()

void DiagramView::mouseReleaseEvent ( QMouseEvent *  e)
overrideprotected

DiagramView::mouseReleaseEvent Manage event release click mouse.

Here is the call graph for this function:

◆ mustIntegrateTitleBlockTemplate()

bool DiagramView::mustIntegrateTitleBlockTemplate ( const TitleBlockTemplateLocation tbt_loc) const
private
Parameters
tbt_locA title block template location
Returns
true if the title block template needs to be integrated in the parent project before being applied to the current diagram, or false if it can be directly applied
Here is the call graph for this function:
Here is the caller graph for this function:

◆ paintEvent()

void DiagramView::paintEvent ( QPaintEvent *  event)
overrideprotected

DiagramView::paintEvent Reimplemented from QGraphicsView.

Parameters
event
Here is the call graph for this function:

◆ paste

void DiagramView::paste ( const QPointF &  pos = QPointF(),
QClipboard::Mode  clipboard_mode = QClipboard::Clipboard 
)
slot

DiagramView::paste Import the element stored in the clipboard to the diagram.

Parameters
pos: top left corner of the bounding rect of imported elements
clipboard_mode
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pasteHere

void DiagramView::pasteHere ( )
slot

Colle le contenu du presse-papier sur le schema a la position de la souris

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetConductors

void DiagramView::resetConductors ( )
slot

Reinitialise le profil des conducteurs selectionnes

◆ scrollOnMovement()

void DiagramView::scrollOnMovement ( QKeyEvent *  e)
private

Handles element movement when editor is zoomed in and scrolls vertical and horizontal bar. If element is moved to the right side of the editor or below the editor SceneRect is expanded

Here is the call graph for this function:
Here is the caller graph for this function:

◆ selectAll

void DiagramView::selectAll ( )
slot

Selectionne tous les objets du schema

Here is the caller graph for this function:

◆ selectedItemHasFocus()

bool DiagramView::selectedItemHasFocus ( )
protectedvirtual
Returns
true if there is a selected item and that item has the focus.
Here is the caller graph for this function:

◆ selectInvert

void DiagramView::selectInvert ( )
slot

Inverse l'etat de selection de tous les objets du schema

Here is the caller graph for this function:

◆ selectNothing

void DiagramView::selectNothing ( )
slot

Deslectionne tous les objets selectionnes

Here is the caller graph for this function:

◆ setEventInterface()

void DiagramView::setEventInterface ( DVEventInterface event_interface)

DiagramView::setEventInterface Set an event interface to diagram view. If diagram view already have an event interface, he delete it before. Diagram view take ownership of event interface and delete it when event interface is finish.

◆ setSelectionMode

void DiagramView::setSelectionMode ( )
slot

Set the Diagram in Selection mode

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setVisualisationMode

void DiagramView::setVisualisationMode ( )
slot

Set the Diagram in visualisation mode

Here is the call graph for this function:
Here is the caller graph for this function:

◆ showDiagram

void DiagramView::showDiagram ( Diagram )
signal

Signal emmitted when diagram must be show.

Here is the caller graph for this function:

◆ switchToSelectionModeIfNeeded()

bool DiagramView::switchToSelectionModeIfNeeded ( QInputEvent *  e)
protectedvirtual

Switch back to selection mode if the user is not pressing Ctrl and Shift.

Returns
true if the view was switched to selection mode, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ switchToVisualisationModeIfNeeded()

bool DiagramView::switchToVisualisationModeIfNeeded ( QInputEvent *  e)
protectedvirtual

Switch to visualisation mode if the user is pressing Ctrl and Shift.

Returns
true if the view was switched to visualisation mode, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ title()

QString DiagramView::title ( ) const
Returns
le titre de cette vue ; cela correspond au titre du schema visualise precede de la mention "Schema". Si le titre du schema est vide, la mention "Schema sans titre" est utilisee
See also
Diagram::title()
Here is the caller graph for this function:

◆ titleChanged

void DiagramView::titleChanged ( DiagramView ,
const QString &   
)
signal

Signal emitted after the diagram title changed.

Here is the caller graph for this function:

◆ updateWindowTitle

void DiagramView::updateWindowTitle ( )
slot

Met a jour le titre du widget

Here is the call graph for this function:
Here is the caller graph for this function:

◆ viewedSceneRect()

QRectF DiagramView::viewedSceneRect ( ) const
private
Returns
le rectangle du schema (classe Diagram) visualise par ce DiagramView
Here is the caller graph for this function:

◆ wheelEvent()

void DiagramView::wheelEvent ( QWheelEvent *  event)
overrideprotected

DiagramView::wheelEvent Manage wheel event of mouse.

Parameters
eventQWheelEvent
Here is the call graph for this function:

◆ zoom

void DiagramView::zoom ( const qreal  zoom_factor)
slot

DiagramView::zoom Zomm the view. A zoom_factor > 1 zoom in. A zoom_factor < 1 zoom out.

Parameters
zoom_factor
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zoomContent

void DiagramView::zoomContent ( )
slot

Adjust zoom to fit all elements in the view, regardless of diagram borders.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ zoomFit

void DiagramView::zoomFit ( )
slot

Agrandit ou rectrecit le schema de facon a ce que tous les elements du schema soient visibles a l'ecran. S'il n'y a aucun element sur le schema, le zoom est reinitialise

Here is the call graph for this function:
Here is the caller graph for this function:

◆ zoomReset

void DiagramView::zoomReset ( )
slot

Reinitialise le zoom

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_diagram

Diagram* DiagramView::m_diagram = nullptr
private

◆ m_drag_last_pos

QPointF DiagramView::m_drag_last_pos
private

◆ m_event_interface

DVEventInterface* DiagramView::m_event_interface = nullptr
private

◆ m_first_activation

bool DiagramView::m_first_activation = true
private

◆ m_free_rubberband

QPolygonF DiagramView::m_free_rubberband
private

◆ m_free_rubberbanding

bool DiagramView::m_free_rubberbanding = false
private

◆ m_fresh_focus_in

bool DiagramView::m_fresh_focus_in
private

◆ m_multi_paste

QAction* DiagramView::m_multi_paste = nullptr
private

◆ m_paste_here

QAction* DiagramView::m_paste_here = nullptr
private

◆ m_paste_here_pos

QPoint DiagramView::m_paste_here_pos
private

◆ m_separators

QList<QAction *> DiagramView::m_separators
private

The documentation for this class was generated from the following files: