コード例 #1
0
ファイル: main.cpp プロジェクト: gbagteam/graphbag
  void mousePressEvent ( QGraphicsSceneMouseEvent * mouseEvent )
  {
    
    QPointF pos(mouseEvent->pos());
    QPointF scene_pos( mouseEvent->scenePos());
    QPoint screen_pos( mouseEvent->screenPos());
      
    qDebug() << "Press in Scene.";
    qDebug() <<"\tpos: " << pos;
    qDebug() <<"\tscene_pos: "<< scene_pos;
    qDebug() <<"\tscreen_pos: "<< screen_pos;
    
    qDebug();

    if( itemAt( scene_pos ) ){

    QGraphicsScene::mousePressEvent( mouseEvent );  

    }else{

      Vertex* vx = new Vertex( scene_pos.x(), scene_pos.y() );
    
      addItem( vx );
    }

  }
コード例 #2
0
ファイル: MainForm.cpp プロジェクト: jiixyj/Kartograf
void MainForm::mouseMoveEvent(QMouseEvent* mevent) {
  QGraphicsView::mousePressEvent(mevent);
  QPoint mpos = mevent->pos();
  QPointF scene_pos_float = mapToScene(mpos);
  QPoint scene_pos(static_cast<int>(floor(scene_pos_float.x())),
                   static_cast<int>(floor(scene_pos_float.y())));
  if (bf_ && bf_->set().topview) {
    std::pair<int, int> scene_pos_mapped =
                     projectCoords(std::make_pair(scene_pos.x(), scene_pos.y()),
                                   (4 - bf_->set().rotate) % 4);
    std::cerr << scene_pos_mapped.first << " " << scene_pos_mapped.second << std::endl;
  }
}
コード例 #3
0
ファイル: main.cpp プロジェクト: gbagteam/graphbag
  void mousePressEvent ( QGraphicsSceneMouseEvent * mouseEvent )
  {

    QPointF pos(mouseEvent->pos());
    QPointF scene_pos( mouseEvent->scenePos());
      
    qDebug() << "Press in Vertex.";
    qDebug() <<"\tpos: " << pos;
    qDebug() <<"\tscene_pos: "<< scene_pos;
    qDebug() <<"\tItem currently at pos: " << this->pos();
    qDebug() <<"\tItem currently at scene_pos: "<< scenePos();

    qDebug();
    
    QGraphicsEllipseItem::mousePressEvent( mouseEvent );  

  }