Logo Search packages:      
Sourcecode: qelectrotech version File versions  Download package

void ElementScene::mouseReleaseEvent ( QGraphicsSceneMouseEvent *  e  )  [protected, virtual]

Gere les relachements de boutons de la souris

Parameters:
e objet decrivant l'evenement

Definition at line 282 of file elementscene.cpp.

References behavior, endCurrentBehavior(), fsi_pos, mustSnapToGrid(), partsAdded(), paste_area_, pasteAreaDefined(), qgiManager(), snapToGrid(), and undo_stack.

                                                                {
      QPointF event_pos = e -> scenePos();
      if (mustSnapToGrid(e)) snapToGrid(event_pos);
      
      PartTerminal *terminal;
      PartText *text;
      PartTextField *textfield;
      if (behavior != Polygon && current_polygon != NULL) current_polygon = NULL;
      
      if (behavior == PasteArea) {
            defined_paste_area_ = paste_area_ -> rect();
            removeItem(paste_area_);
            emit(pasteAreaDefined(defined_paste_area_));
            behavior = Normal;
            return;
      }
      
      if (e -> button() & Qt::LeftButton) {
            switch(behavior) {
                  case Line:
                        if (qgiManager().manages(current_line)) break;
                        undo_stack.push(new AddPartCommand(tr("ligne"), this, current_line));
                        emit(partsAdded());
                        endCurrentBehavior(e);
                        break;
                  case Rectangle:
                        if (qgiManager().manages(current_rectangle)) break;
                        current_rectangle -> setRect(current_rectangle -> rect().normalized());
                        undo_stack.push(new AddPartCommand(tr("rectangle"), this, current_rectangle));
                        emit(partsAdded());
                        endCurrentBehavior(e);
                        break;
                  case Ellipse:
                        if (qgiManager().manages(current_ellipse)) break;
                        current_ellipse -> setRect(current_ellipse -> rect().normalized());
                        undo_stack.push(new AddPartCommand(tr("ellipse"), this, current_ellipse));
                        emit(partsAdded());
                        endCurrentBehavior(e);
                        break;
                  case Arc:
                        if (qgiManager().manages(current_arc)) break;
                        current_arc-> setRect(current_arc -> rect().normalized());
                        undo_stack.push(new AddPartCommand(tr("arc"), this, current_arc));
                        emit(partsAdded());
                        endCurrentBehavior(e);
                        break;
                  case Circle:
                        if (qgiManager().manages(current_circle)) break;
                        current_circle -> setRect(current_circle -> rect().normalized());
                        undo_stack.push(new AddPartCommand(tr("cercle"), this, current_circle));
                        emit(partsAdded());
                        endCurrentBehavior(e);
                        break;
                  case Terminal:
                        terminal = new PartTerminal(element_editor, 0, this);
                        terminal -> setPos(event_pos);
                        undo_stack.push(new AddPartCommand(tr("borne"), this, terminal));
                        emit(partsAdded());
                        endCurrentBehavior(e);
                        break;
                  case Text:
                        text = new PartText(element_editor, 0, this);
                        text -> setPos(event_pos);
                        undo_stack.push(new AddPartCommand(tr("texte"), this, text));
                        emit(partsAdded());
                        endCurrentBehavior(e);
                        break;
                  case TextField:
                        textfield = new PartTextField(element_editor, 0, this);
                        textfield -> setPos(event_pos);
                        undo_stack.push(new AddPartCommand(tr("champ de texte"), this, textfield));
                        emit(partsAdded());
                        endCurrentBehavior(e);
                        break;
                  case Normal:
                  default:
                        // detecte les deplacements de parties
                        if (!selectedItems().isEmpty() && moving_parts_) {
                              QPointF movement = selectedItems().first() -> scenePos() - fsi_pos;
                              if (!movement.isNull()) {
                                    undo_stack.push(new MovePartsCommand(movement, this, selectedItems()));
                              }
                        }
                        QGraphicsScene::mouseReleaseEvent(e);
                        moving_parts_ = false;
            }
      } else if (e -> button() & Qt::RightButton) {
            if (behavior == Polygon && current_polygon != NULL) {
                  undo_stack.push(new AddPartCommand(tr("polygone"), this, current_polygon));
                  current_polygon = NULL;
                  emit(partsAdded());
                  endCurrentBehavior(e);
            } else QGraphicsScene::mouseReleaseEvent(e);
      } else QGraphicsScene::mouseReleaseEvent(e);
}


Generated by  Doxygen 1.6.0   Back to index