bool QcMapGestureArea::can_start_pinch() { // qInfo(); int number_of_points = m_all_points.count(); const int start_drag_distance = qApp->styleHints()->startDragDistance(); if (number_of_points >= 2) { QcVectorDouble p1 = first_point().pos(); QcVectorDouble p2 = second_point().pos(); if (qAbs(p1.x() - m_start_position1.x()) > start_drag_distance or qAbs(p1.y() - m_start_position1.y()) > start_drag_distance or qAbs(p2.x() - m_start_position2.x()) > start_drag_distance or qAbs(p2.y() - m_start_position2.y()) > start_drag_distance) { m_pinch.m_event.set_angle(m_two_touch_angle); m_pinch.m_event.set_center(m_current_position); m_pinch.m_event.set_number_of_points(number_of_points); m_pinch.m_event.set_point1(p1); m_pinch.m_event.set_point2(p2); m_pinch.m_event.set_accepted(true); emit pinch_started(&m_pinch.m_event); return m_pinch.m_event.accepted(); } } return false; }
IShape* UICircle::LoadShape(std::vector<std::string> i_load_data) { Point first_point(atof(i_load_data[1].c_str()), atof(i_load_data[2].c_str())); Point second_point(atof(i_load_data[3].c_str()), atof(i_load_data[4].c_str())); UICircle* p_circle = new UICircle(first_point, second_point); p_circle->SetOutlineColor((COLORREF)atof(i_load_data[5].c_str())); p_circle->SetBrushColor((COLORREF)atof(i_load_data[6].c_str())); return p_circle; }
void QcMapGestureArea::start_pinch() { // qInfo(); m_pinch.m_last_angle = m_two_touch_angle; m_pinch.m_last_point1 = first_point().pos(); m_pinch.m_last_point2 = second_point().pos(); m_pinch.m_start_distance = m_distance_between_touch_points; m_pinch.m_zoom.m_previous = m_map->zoom_level(); m_pinch.m_zoom.m_start = m_map->zoom_level(); }
void QcMapGestureArea::start_two_touch_points() { // qInfo(); m_start_position1 = first_point().pos(); m_start_position2 = second_point().pos(); QcVectorDouble start_position = middle(m_start_position1, m_start_position2); // Fixme: duplicated code, excepted middle m_last_position_for_velocity = start_position; m_last_position_for_velocity_time.start(); QcWgsCoordinate start_coordinate = m_map->to_coordinate(start_position, false); m_start_coordinate.set_longitude(start_coordinate.longitude() + m_start_coordinate.longitude() - m_touch_center_coordinate.longitude()); m_start_coordinate.set_latitude(start_coordinate.latitude() + m_start_coordinate.latitude() - m_touch_center_coordinate.latitude()); }
void QcMapGestureArea::update_pinch() { // qInfo(); // Calculate the new zoom level if we have distance (>= 2 touchpoints), otherwise stick with old. qreal new_zoom_level = m_pinch.m_zoom.m_previous; if (m_distance_between_touch_points) { new_zoom_level = // How much further/closer the current touchpoints are (in pixels) compared to pinch start ((m_distance_between_touch_points - m_pinch.m_start_distance) * // How much one pixel corresponds in units of zoomlevel (and multiply by above delta) (m_pinch.m_zoom.maximum_change / ((width() + height()) / 2))) + // Add to starting zoom level. Sign of (dist-pinchstartdist) takes care of zoom in / out m_pinch.m_zoom.m_start; } // qreal delta_angle = m_pinch.m_last_angle - m_two_touch_angle; // if (delta_angle > 180) // delta_angle -= 360; // else if (delta_angle < -180) // delta_angle += 360; m_pinch.m_last_angle = m_two_touch_angle; m_pinch.m_last_point1 = first_point().pos(); m_pinch.m_last_point2 = second_point().pos(); m_pinch.m_event.set_angle(m_two_touch_angle); m_pinch.m_event.set_center(m_current_position); m_pinch.m_event.set_number_of_points(m_all_points.count()); m_pinch.m_event.set_point1(m_pinch.m_last_point1); m_pinch.m_event.set_point2(m_pinch.m_last_point2); m_pinch.m_event.set_accepted(true); emit pinch_updated(&m_pinch.m_event); if (m_accepted_gestures & PinchGesture) { // Take maximum and minimumzoomlevel into account qreal per_pinch_minimum_zoom_level = qMax(m_pinch.m_zoom.m_start - m_pinch.m_zoom.maximum_change, static_cast<qreal>(m_pinch.m_zoom.m_interval.inf())); qreal per_pinch_maximum_zoom_level = qMin(m_pinch.m_zoom.m_start + m_pinch.m_zoom.maximum_change, static_cast<qreal>(m_pinch.m_zoom.m_interval.sup())); new_zoom_level = qMin(qMax(per_pinch_minimum_zoom_level, new_zoom_level), per_pinch_maximum_zoom_level); m_map->set_zoom_level(new_zoom_level); m_pinch.m_zoom.m_previous = new_zoom_level; } }
void QcMapGestureArea::update_two_touch_points() { // qInfo(); QcVectorDouble p1 = first_point().pos(); QcVectorDouble p2 = second_point().pos(); QcVectorDouble delta = p2 - p1; m_distance_between_touch_points = delta.magnitude(); m_current_position = middle(p1, p2); update_velocity_list(m_current_position); m_two_touch_angle = delta.orientation(); // Fixme: required ? if (m_two_touch_angle > 180) m_two_touch_angle -= 360; }
void LCVText::draw(LcPainter* painter, LcDrawOptions* options, const lc::geo::Area& rect) const { bool modified = false; modified = true; painter->save(); if (this->selected()) { painter->source_rgba( options->selectedColor().red(), options->selectedColor().green(), options->selectedColor().blue(), options->selectedColor().alpha() ); } else { painter->source_rgba( layers().front()->color().red(), layers().front()->color().green(), layers().front()->color().blue(), layers().front()->color().alpha() ); } // double letterSpacing = 3.0; // double wordSpacing = 6.75; // double lineSpacingFactor = 1.0; // lc::geo::Coordinate letterPos = lc::geo::Coordinate(0.0, -9.0); // lc::geo::Coordinate letterSpace = lc::geo::Coordinate(letterSpacing, 0.0); // lc::geo::Coordinate space = lc::geo::Coordinate(wordSpacing, 0.0); lc::geo::Coordinate textSize(Text::boundingBox().maxP() - Text::boundingBox().minP()); // Vertical Align: double vSize = 9.0; double alignX = insertion_point().x(); double alignY = insertion_point().y(); // double alignX, alignY; switch (valign()) { case Text::VAMiddle: alignX += 0.0; alignY += vSize / 2.0; break; case Text::VABottom: alignX += 0.0; alignY += vSize + 3; break; case Text::VABaseline: alignX += 0.0; alignY += vSize; break; default: break; } // Horizontal Align: switch (halign()) { case Text::HAMiddle: alignX += (0. - textSize.x() / 2.0); alignY += (0. - (vSize + textSize.y() / 2.0 + Text::boundingBox().minP().y())); break; case Text::HACenter: alignX += (0. - textSize.x() / 2.0); alignY += alignY + (0.0); break; case Text::HARight: alignX += alignX + (0. - textSize.x()); alignY += alignY + (0.0); break; default: break; } double angle_; // Rotate: if (halign() == Text::HAAligned || halign() == Text::HAFit) { angle_ = insertion_point().angleTo(second_point()); } else { angle_ = angle(); } const char* str = text_value().c_str(); painter->text(alignX, alignY, str, angle_, height()); painter->stroke(); if (modified) { painter->restore(); } }