feat: add epplise measure round mode
This commit is contained in:
@@ -186,13 +186,20 @@ void EllipseAnnotationActor::controlPointCb(vtkObject *sender, unsigned long eve
|
||||
Renderer->WorldToDisplay();
|
||||
Renderer->GetDisplayPoint(displaypos);
|
||||
double *displayp_rb = displaypos;
|
||||
drawCircle(p1, p2);
|
||||
if (Renderer->GetRenderWindow()->GetInteractor()->GetControlKey())
|
||||
{
|
||||
double d = std::min({abs(displayP[0] - displayp_rb[0]), abs(displayP[1] - displayp_rb[1])});
|
||||
displayP[0] = displayP[0]>displayp_rb[0]?displayp_rb[0]+d:displayp_rb[0]-d;
|
||||
displayP[1] = displayP[1]>displayp_rb[1]?displayp_rb[1]+d:displayp_rb[1]-d;
|
||||
pts->SetPoint(0, displayP);
|
||||
}
|
||||
double p_rt[3] = {0, 0, 0};
|
||||
MapScreenPointToWorld(displayp_rb[0], displayP[1], Renderer,p_rt);
|
||||
double p_lb[3] = {0, 0, 0};
|
||||
MapScreenPointToWorld( displayP[0], displayp_rb[1], Renderer,p_lb);
|
||||
controlP_rt->SetWorldPosition(p_rt);
|
||||
controlP_lb->SetWorldPosition(p_lb);
|
||||
drawCircle(p1, p2);
|
||||
} else if (sender == controlP_rt ) {
|
||||
p1 = result;
|
||||
p2 = controlP_lb->GetWorldPosition();
|
||||
@@ -200,42 +207,62 @@ void EllipseAnnotationActor::controlPointCb(vtkObject *sender, unsigned long eve
|
||||
Renderer->WorldToDisplay();
|
||||
Renderer->GetDisplayPoint(displaypos);
|
||||
double *displayp_lb = displaypos;
|
||||
drawCircle(p1, p2);
|
||||
if (Renderer->GetRenderWindow()->GetInteractor()->GetControlKey())
|
||||
{
|
||||
double d = std::min({abs(displayP[0] - displayp_lb[0]), abs(displayP[1] - displayp_lb[1])});
|
||||
displayP[0] = displayP[0]>displayp_lb[0]?displayp_lb[0]+d:displayp_lb[0]-d;
|
||||
displayP[1] = displayP[1]>displayp_lb[1]?displayp_lb[1]+d:displayp_lb[1]-d;
|
||||
pts->SetPoint(0, displayP);
|
||||
}
|
||||
double p_lt[3] = {0, 0, 0};
|
||||
MapScreenPointToWorld(displayp_lb[0], displayP[1], Renderer,p_lt);
|
||||
double p_rb[3] = {0, 0, 0};
|
||||
MapScreenPointToWorld( displayP[0], displayp_lb[1], Renderer,p_rb);
|
||||
controlP_lt->SetWorldPosition(p_lt);
|
||||
controlP_rb->SetWorldPosition(p_rb);
|
||||
drawCircle(p_lt, p_rb);
|
||||
|
||||
} else if (sender == controlP_lb ) {
|
||||
p2 = result;
|
||||
p1 = controlP_rt->GetWorldPosition();
|
||||
Renderer->SetWorldPoint(p1);
|
||||
p1 = result;
|
||||
p2 = controlP_rt->GetWorldPosition();
|
||||
Renderer->SetWorldPoint(p2);
|
||||
Renderer->WorldToDisplay();
|
||||
Renderer->GetDisplayPoint(displaypos);
|
||||
double *displayp_rt = displaypos;
|
||||
drawCircle(p1, p2);
|
||||
if (Renderer->GetRenderWindow()->GetInteractor()->GetControlKey())
|
||||
{
|
||||
double d = std::min({abs(displayP[0] - displayp_rt[0]), abs(displayP[1] - displayp_rt[1])});
|
||||
displayP[0] = displayP[0]>displayp_rt[0]?displayp_rt[0]+d:displayp_rt[0]-d;
|
||||
displayP[1] = displayP[1]>displayp_rt[1]?displayp_rt[1]+d:displayp_rt[1]-d;
|
||||
pts->SetPoint(0, displayP);
|
||||
}
|
||||
double p_lt[3] = {0, 0, 0};
|
||||
MapScreenPointToWorld(displayP[0],displayp_rt[1], Renderer,p_lt);
|
||||
double p_rb[3] = {0, 0, 0};
|
||||
MapScreenPointToWorld( displayp_rt[0], displayP[1], Renderer,p_rb);
|
||||
controlP_lt->SetWorldPosition(p_lt);
|
||||
controlP_rb->SetWorldPosition(p_rb);
|
||||
drawCircle(p_lt, p_rb);
|
||||
} else if (sender == controlP_rb ) {
|
||||
p2 = result;
|
||||
p1 = controlP_lt->GetWorldPosition();
|
||||
Renderer->SetWorldPoint(p1);
|
||||
p1 = result;
|
||||
p2 = controlP_lt->GetWorldPosition();
|
||||
Renderer->SetWorldPoint(p2);
|
||||
Renderer->WorldToDisplay();
|
||||
Renderer->GetDisplayPoint(displaypos);
|
||||
double *displayp_lt = displaypos;
|
||||
drawCircle(p1, p2);
|
||||
if (Renderer->GetRenderWindow()->GetInteractor()->GetControlKey())
|
||||
{
|
||||
double d = std::min({abs(displayP[0] - displayp_lt[0]), abs(displayP[1] - displayp_lt[1])});
|
||||
displayP[0] = displayP[0]>displayp_lt[0]?displayp_lt[0]+d:displayp_lt[0]-d;
|
||||
displayP[1] = displayP[1]>displayp_lt[1]?displayp_lt[1]+d:displayp_lt[1]-d;
|
||||
pts->SetPoint(0, displayP);
|
||||
}
|
||||
double p_rt[3] = {0, 0, 0};
|
||||
MapScreenPointToWorld(displayP[0], displayp_lt[1], Renderer,p_rt);
|
||||
double p_lb[3] = {0, 0, 0};
|
||||
MapScreenPointToWorld(displayp_lt[0], displayP[1], Renderer,p_lb);
|
||||
controlP_rt->SetWorldPosition(p_rt);
|
||||
controlP_lb->SetWorldPosition(p_lb);
|
||||
drawCircle(p1, p2);
|
||||
} else {
|
||||
|
||||
}
|
||||
@@ -259,6 +286,17 @@ void EllipseAnnotationActor::drawCircle(double *p1, double *p2) {
|
||||
double r1 = round(abs(p1[nIndex[0]] - p2[nIndex[0]]) / 2.0*100.0)/100;
|
||||
double r2 = round(abs(p1[nIndex[1]]- p2[nIndex[1]]) / 2.0*100.0)/100;
|
||||
|
||||
//if ctrl key is pressed ,draw a standard circle
|
||||
if (this->Renderer->GetRenderWindow()->GetInteractor()->GetControlKey()) {
|
||||
r1 = std::min({r1, r2});
|
||||
r2 = r1;
|
||||
if (abs(CenterX-p2[nIndex[0]])>r1){
|
||||
CenterX = CenterX > p2[nIndex[0]]?(r1+p2[nIndex[0]]):(p2[nIndex[0]]-r1);
|
||||
}
|
||||
if (abs(CenterY-p2[nIndex[1]])>r1){
|
||||
CenterY = CenterY > p2[nIndex[1]]?(r1+p2[nIndex[1]]):(p2[nIndex[1]]-r1);
|
||||
}
|
||||
}
|
||||
double angle = 0;
|
||||
int id = 0;
|
||||
while (angle <= 2.0 * vtkMath::Pi() + (2.0 * vtkMath::Pi() / (GRANULARITY * 1.0))) {
|
||||
|
||||
Reference in New Issue
Block a user