26 #include "wx/msw/wrapwin.h"
104 tool->ImagesUnderMouseChangedEvent();
127 for (
unsigned int image_index = 0; image_index < num_images; image_index++)
136 double image_x, image_y;
139 int(image_x),
int(image_y))))
142 imgUnderPos.insert(image_index);
153 tool->MouseButtonEvent(e);
161 tool->MouseWheelEvent(e);
170 tool->KeypressEvent(keycode, modifiers, pressed);
179 tool->BeforeDrawImagesEvent();
195 tool->AfterDrawImagesEvent();
200 tool->ReallyAfterDrawImagesEvent();
224 for (
auto tool : tools)
226 result &= tool->BeforeDrawImageEvent(image);
241 for (
auto tool : tools)
243 tool->BeforeDrawImageEvent(image);
276 tool->ImagesUnderMouseChangedEvent();
430 std::set<Tool *> *set)
432 auto foundTool = set->find(tool);
433 if (foundTool != set->end())
435 set->erase(foundTool);
440 std::vector<std::set<Tool *> > *vector)
443 for (
unsigned int image = 0; image < vector->size(); image++)
445 (*vector)[image].erase(tool);
450 std::vector<std::set<Tool *> > *vector,
453 if (vector->size() > index)
455 (*vector)[index].erase(tool);
461 if (*single != 0 || *single == tool)
474 std::vector<std::set<Tool *> > *vector,
477 if (vector->size() < index + 1)
481 vector->resize(index + 1, std::set<Tool*>());
489 (*vector)[index].insert(tool);
515 double d = panostate->
getR();
518 int tcanv_w, tcanv_h;
519 panostate->
GetViewer()->GetClientSize(&tcanv_w,&tcanv_h);
521 double canv_w, canv_h;
525 const double fov = panostate->
getFOV();
526 double fovScale = 1.0;
532 fovx = 2 * atan(tan(fovy / 2.0) * canv_w / canv_h);
533 fovScale = tan(fovy / 2.0) / (0.5 * canv_h);
538 fovy = 2 * atan(tan(fovx / 2.0) * canv_h / canv_w);
539 fovScale = tan(fovx / 2.0) / (0.5 * canv_w);
546 const double xSrc = (x - canv_w / 2.0) * fovScale;
547 const double ySrc = (canv_h / 2.0 - y) * fovScale;
548 const double yaw = atan(xSrc) + panostate->
getAngX() +
M_PI / 2.0;
549 const double pitch =
M_PI/2.0 - atan2(ySrc, std::sqrt(1.0 + xSrc * xSrc)) - panostate->
getAngY();
558 const double ax = tan(fovx / 2.0) * d * (x / (canv_w / 2.0) - 1);
559 const double ay = tan(fovy / 2.0) * d * (y / (canv_h / 2.0) - 1);
561 const double a_limit = r * d / sqrt(d * d - r * r);
563 if (ax * ax + ay * ay < a_limit * a_limit)
567 const double ta = (ax * ax + ay * ay) / (d * d) + 1;
568 const double tb = -2 * (ax * ax + ay * ay) / d;
569 const double tc = ax * ax + ay * ay - r * r;
571 const double pz = (-tb + sqrt(tb * tb - 4 * ta * tc)) / (2 * ta);
572 const double px = ax * (d - pz) / d;
573 const double py = ay * (d - pz) / d;
575 const double pl = sqrt(px * px + py * py + pz * pz);
577 const double pang_yaw = -atan(px / pz);
578 const double pang_pitch = asin(py / pl);
580 const double ang_yaw = panostate->
getAngX();
581 const double ang_pitch = panostate->
getAngY();
583 const double x = sin(ang_yaw) * cos(ang_pitch);
584 const double z = cos(ang_yaw) * cos(ang_pitch);
585 const double y = sin(ang_pitch);
594 tres.
x = ptop.
x * (ptop.
x * vec.
x + ptop.
y * vec.
y + ptop.
z * vec.
z) + cos(pang_yaw) * (ptop.
x * (-ptop.
y * vec.
y - ptop.
z * vec.
z) + vec.
x * (ptop.
y * ptop.
y + ptop.
z * ptop.
z)) + sin(pang_yaw) * (-ptop.
z * vec.
y + ptop.
y * vec.
z);
595 tres.
y = ptop.
y * (ptop.
x * vec.
x + ptop.
y * vec.
y + ptop.
z * vec.
z) + cos(pang_yaw) * (ptop.
y * (-ptop.
x * vec.
x - ptop.
z * vec.
z) + vec.
y * (ptop.
x * ptop.
x + ptop.
z * ptop.
z)) + sin(pang_yaw) * (-ptop.
z * vec.
x + ptop.
x * vec.
z);
596 tres.
z = ptop.
z * (ptop.
x * vec.
x + ptop.
y * vec.
y + ptop.
z * vec.
z) + cos(pang_yaw) * (ptop.
z * (-ptop.
x * vec.
x - ptop.
y * vec.
y) + vec.
z * (ptop.
x * ptop.
x + ptop.
y * ptop.
y)) + sin(pang_yaw) * (-ptop.
y * vec.
x + ptop.
x * vec.
y);
601 res.
x = pside.
x * (pside.
x * tres.
x + pside.
y * tres.
y + pside.
z * tres.
z) + cos(pang_pitch) * (pside.
x * (-pside.
y * tres.
y - pside.
z * tres.
z) + tres.
x * (pside.
y * pside.
y + pside.
z * pside.
z)) + sin(pang_pitch) * (-pside.
z * tres.
y + pside.
y * tres.
z);
602 res.
y = pside.
y * (pside.
x * tres.
x + pside.
y * tres.
y + pside.
z * tres.
z) + cos(pang_pitch) * (pside.
y * (-pside.
x * tres.
x - pside.
z * tres.
z) + tres.
y * (pside.
x * pside.
x + pside.
z * pside.
z)) + sin(-pang_pitch) * (-pside.
z * tres.
x + pside.
x * tres.
z);
603 res.
z = pside.
z * (pside.
x * tres.
x + pside.
y * tres.
y + pside.
z * tres.
z) + cos(pang_pitch) * (pside.
z * (-pside.
x * tres.
x - pside.
y * tres.
y) + tres.
z * (pside.
x * pside.
x + pside.
y * pside.
y)) + sin(pang_pitch) * (-pside.
y * tres.
x + pside.
x * tres.
y);
607 yaw = atan2(res.
x, res.
z);
610 if (yaw < 0) yaw += 2 *
M_PI;
611 if (yaw > 2 *
M_PI) yaw -= 2 *
M_PI;
614 pitch =
M_PI - pitch;
726 double d = panostate->
getR();
728 int tcanv_w, tcanv_h;
729 panostate->
GetViewer()->GetClientSize(&tcanv_w,&tcanv_h);
731 double canv_w, canv_h;
735 double fov = panostate->
getFOV();
738 if (canv_w > canv_h) {
740 fovx = 2 * atan( tan(fovy / 2.0) * canv_w / canv_h);
743 fovy = 2 * atan( tan(fovx / 2.0) * canv_h / canv_w);
747 vis_w = 2.0 * tan ( fovx / 2.0 ) * d;
748 vis_h = 2.0 * tan ( fovy / 2.0 ) * d;
751 double prim_x, prim_y;
752 prim_x = (double) x / canv_w * vis_w - vis_w / 2.0 + panostate->
getX();
753 prim_y = ((double) y / canv_h * vis_h - vis_h / 2.0 - panostate->
getY());
759 double width, height;
void SetStatusMessage(wxString message)
The OpenGL preview frame.
Vector3 GetNormalized() const
return a normalized vector
unsigned int getHeight() const
get panorama height
bool set_contains(const _Container &c, const typename _Container::key_type &key)
bool isInside(vigra::Point2D p, bool ignoreMasks=false) const
check if a coordinate is inside the source image
std::set< unsigned int > UIntSet
virtual HuginBase::SrcPanoImage * GetSrcImage(unsigned int image_nr)
std::size_t getNrOfImages() const
number of images.
vigra::Rect2D GetVisibleArea()
TDiff2D< double > FDiff2D
Vector3 Cross(const Vector3 &v) const
cross product
ViewState * getViewState()
UIntSet getActiveImages() const
get active images
static const double scale
unsigned int getWidth() const
virtual HuginBase::PanoramaOptions * GetOptions()
HuginBase::PanoramaOptions * GetOptions()
general : Vector3 is a class for handling 3D Vectors manipulation.
double x
x,y,z coordinates, 0 at the initialisation
HuginBase::SrcPanoImage * GetSrcImage(unsigned int image_nr)
HuginBase::PanoramaOptions * GetOptions()