MCPcopy Create free account
hub / github.com/GeoDaCenter/geoda / OnSizingBeginDragLeft

Method OnSizingBeginDragLeft

ogl/basic2.cpp:1393–1524  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1391}
1392
1393void wxShape::OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys, int WXUNUSED(attachment))
1394{
1395 m_canvas->CaptureMouse();
1396
1397 wxClientDC dc(GetCanvas());
1398 GetCanvas()->PrepareDC(dc);
1399/*
1400 if (pt->m_eraseObject)
1401 this->Erase(dc);
1402*/
1403
1404 dc.SetLogicalFunction(OGLRBLF);
1405
1406 double bound_x;
1407 double bound_y;
1408 this->GetBoundingBoxMin(&bound_x, &bound_y);
1409 this->GetEventHandler()->OnBeginSize(bound_x, bound_y);
1410
1411 // Choose the 'opposite corner' of the object as the stationary
1412 // point in case this is non-centring resizing.
1413 if (pt->GetX() < this->GetX())
1414 pt->sm_controlPointDragStartX = (double)(this->GetX() + (bound_x/2.0));
1415 else
1416 pt->sm_controlPointDragStartX = (double)(this->GetX() - (bound_x/2.0));
1417
1418 if (pt->GetY() < this->GetY())
1419 pt->sm_controlPointDragStartY = (double)(this->GetY() + (bound_y/2.0));
1420 else
1421 pt->sm_controlPointDragStartY = (double)(this->GetY() - (bound_y/2.0));
1422
1423 if (pt->m_type == CONTROL_POINT_HORIZONTAL)
1424 pt->sm_controlPointDragStartY = (double)(this->GetY() - (bound_y/2.0));
1425 else if (pt->m_type == CONTROL_POINT_VERTICAL)
1426 pt->sm_controlPointDragStartX = (double)(this->GetX() - (bound_x/2.0));
1427
1428 // We may require the old width and height.
1429 pt->sm_controlPointDragStartWidth = bound_x;
1430 pt->sm_controlPointDragStartHeight = bound_y;
1431
1432 wxPen dottedPen(*wxBLACK, 1, wxDOT);
1433 dc.SetPen(dottedPen);
1434 dc.SetBrush((* wxTRANSPARENT_BRUSH));
1435
1436 if (this->GetCentreResize())
1437 {
1438 double new_width = (double)(2.0*fabs(x - this->GetX()));
1439 double new_height = (double)(2.0*fabs(y - this->GetY()));
1440
1441 // Constrain sizing according to what control point you're dragging
1442 if (pt->m_type == CONTROL_POINT_HORIZONTAL)
1443 {
1444 if (GetMaintainAspectRatio())
1445 {
1446 new_height = bound_y*(new_width/bound_x);
1447 }
1448 else
1449 new_height = bound_y;
1450 }

Callers 1

OnBeginDragLeftMethod · 0.45

Calls 15

GetBoundingBoxMinMethod · 0.95
GetMaintainAspectRatioFunction · 0.85
EraseMethod · 0.80
SetXMethod · 0.80
SetYMethod · 0.80
CalculateBoundingBoxMethod · 0.80
CalculateNewSizeMethod · 0.80
GetCanvasFunction · 0.70
GetXMethod · 0.45
GetYMethod · 0.45
SetPenMethod · 0.45

Tested by

no test coverage detected