26 #include "wx/msw/wrapwin.h"
103 tool->ImagesUnderMouseChangedEvent();
126 for (
unsigned int image_index = 0; image_index < num_images; image_index++)
135 double image_x, image_y;
138 int(image_x),
int(image_y))))
141 imgUnderPos.insert(image_index);
152 tool->MouseButtonEvent(e);
160 tool->MouseWheelEvent(e);
169 tool->KeypressEvent(keycode, modifiers, pressed);
178 tool->BeforeDrawImagesEvent();
194 tool->AfterDrawImagesEvent();
199 tool->ReallyAfterDrawImagesEvent();
223 for (
auto tool : tools)
225 result &= tool->BeforeDrawImageEvent(image);
240 for (
auto tool : tools)
242 tool->BeforeDrawImageEvent(image);
275 tool->ImagesUnderMouseChangedEvent();
429 std::set<Tool *> *set)
431 auto foundTool = set->find(tool);
432 if (foundTool != set->end())
434 set->erase(foundTool);
439 std::vector<std::set<Tool *> > *vector)
442 for (
unsigned int image = 0; image < vector->size(); image++)
444 (*vector)[image].erase(tool);
449 std::vector<std::set<Tool *> > *vector,
452 if (vector->size() > index)
454 (*vector)[index].erase(tool);
460 if (*single != 0 || *single == tool)
473 std::vector<std::set<Tool *> > *vector,
476 if (vector->size() < index + 1)
480 vector->resize(index + 1, std::set<Tool*>());
488 (*vector)[index].insert(tool);
514 double d = panostate->
getR();
517 int tcanv_w, tcanv_h;
518 panostate->
GetViewer()->GetClientSize(&tcanv_w,&tcanv_h);
520 double canv_w, canv_h;
524 const double fov = panostate->
getFOV();
525 double fovScale = 1.0;
531 fovx = 2 * atan(tan(fovy / 2.0) * canv_w / canv_h);
532 fovScale = tan(fovy / 2.0) / (0.5 * canv_h);
537 fovy = 2 * atan(tan(fovx / 2.0) * canv_h / canv_w);
538 fovScale = tan(fovx / 2.0) / (0.5 * canv_w);
545 const double xSrc = (x - canv_w / 2.0) * fovScale;
546 const double ySrc = (canv_h / 2.0 - y) * fovScale;
547 const double yaw = atan(xSrc) + panostate->
getAngX() +
M_PI / 2.0;
548 const double pitch =
M_PI/2.0 - atan2(ySrc, std::sqrt(1.0 + xSrc * xSrc)) - panostate->
getAngY();
557 const double ax = tan(fovx / 2.0) * d * (x / (canv_w / 2.0) - 1);
558 const double ay = tan(fovy / 2.0) * d * (y / (canv_h / 2.0) - 1);
560 const double a_limit = r * d / sqrt(d * d - r * r);
562 if (ax * ax + ay * ay < a_limit * a_limit)
566 const double ta = (ax * ax + ay * ay) / (d * d) + 1;
567 const double tb = -2 * (ax * ax + ay * ay) / d;
568 const double tc = ax * ax + ay * ay - r * r;
570 const double pz = (-tb + sqrt(tb * tb - 4 * ta * tc)) / (2 * ta);
571 const double px = ax * (d - pz) / d;
572 const double py = ay * (d - pz) / d;
574 const double pl = sqrt(px * px + py * py + pz * pz);
576 const double pang_yaw = -atan(px / pz);
577 const double pang_pitch = asin(py / pl);
579 const double ang_yaw = panostate->
getAngX();
580 const double ang_pitch = panostate->
getAngY();
582 const double x = sin(ang_yaw) * cos(ang_pitch);
583 const double z = cos(ang_yaw) * cos(ang_pitch);
584 const double y = sin(ang_pitch);
593 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);
594 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);
595 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);
600 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);
601 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);
602 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);
606 yaw = atan2(res.
x, res.
z);
609 if (yaw < 0) yaw += 2 *
M_PI;
610 if (yaw > 2 *
M_PI) yaw -= 2 *
M_PI;
613 pitch =
M_PI - pitch;
725 double d = panostate->
getR();
727 int tcanv_w, tcanv_h;
728 panostate->
GetViewer()->GetClientSize(&tcanv_w,&tcanv_h);
730 double canv_w, canv_h;
734 double fov = panostate->
getFOV();
737 if (canv_w > canv_h) {
739 fovx = 2 * atan( tan(fovy / 2.0) * canv_w / canv_h);
742 fovy = 2 * atan( tan(fovx / 2.0) * canv_h / canv_w);
746 vis_w = 2.0 * tan ( fovx / 2.0 ) * d;
747 vis_h = 2.0 * tan ( fovy / 2.0 ) * d;
750 double prim_x, prim_y;
751 prim_x = (double) x / canv_w * vis_w - vis_w / 2.0 + panostate->
getX();
752 prim_y = ((double) y / canv_h * vis_h - vis_h / 2.0 - panostate->
getY());
758 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()