entity snap points
entity snap points
hi everyone,
i'm trying to understand how entity snap functionality is implemented in the library.
i'm looking at the odamfcapp example, but i can't understand the behaviour:
if i use the function to draw a line, the line points correctly snap to the other lines inserted in the drawing, but not to the ones positioned ad a different z coord.
to change the current ucs z coord i use the function:
pactivevp->setucs(ucsorigin, ucsxaxis, ucsyaxis)
only the entities positioned at the same z as the ucs z are considered to be snappable...
is this correct ?
i would like to snap to any line in the drawing...
thank you very much, bye.
carlo.
no ideas ?
is it because i've not been clear enough ??
snapping is implemented not in the library but in odamfcapp application. it calls oddbentity::getosnappoints(). this function simply calls corresponding function of protocol extension. see grippoints sample. in this sample grip and snap points functionality is implemented for a few entities.
in odamfcapp sample distance between poins is calculated in 3d so it does not work for line with different z correctly:
osnapmanager.cpp
code:
inline bool osnapmanager::checkpoint(oddb:

snapmode osm, const odgepoint3d& point)
{
// 3d distance is calculated here !
double dist = (point-*m_ppickpoint).length() * m_dworldtodevice;
if(dist < hitradius)
{
if(dist < m_dneardist && osm <= m_mode)
sergey slezkin
understood !!!
thank you very much!
ehm...
i'm trying to modify the piece of code you refer to, trying to obtain the device (eg pixel coords) coordinates of point and m_pickpoint, but no results till now...
how ca i obtain the device x and y coords of a 3d oddbpoint3d object ???
thank you very much for your help
this is because i would like to compare the distance between the device coords...
quote:
originally posted by
carlo@zirak.it
ehm...
i'm trying to modify the piece of code you refer to, trying to obtain the device (eg pixel coords) coordinates of point and m_pickpoint, but no results till now...
how ca i obtain the device x and y coords of a 3d oddbpoint3d object ???
thank you very much for your help
this is because i would like to compare the distance between the device coords...
no ideas ????
i'm very sorry if i insist, but the snap problem is making me crazy!!!!!
does anyone know how to solve the "physical coordinates" question above ?
i need the opposite of this function but can't do it by mysemf...
odgepoint3d odexeditorobject::toeyetoworld(int x, int y) const
{
odgepoint3d wcspt(x, y, 0.0);
const odgsview* pview = activeview();
wcspt.transformby((pview->screenmatrix() * pview->projectionmatrix()).inverse());
wcspt.z =0.;
// eye cs at this point.
wcspt.transformby(odabstractviewpeptr(pview)->eyetoworld(pview));
return wcspt;
}
i mean. i need a function that given a 3d wcs point, gives me the x and y (integer) coordinates of the device...
thank you again
carlo.
last edited by
carlo@zirak.it; 3rd october 2008 at 07:22 amfff">.
sorry if i insist ....
but, is because my question is too difficult or because no one understands what i mean ?
view has worldtodevicematrix() method.
the code below works but can be optimized.
code:
inline bool osnapmanager::checkpoint(oddb:

snapmode osm, const odgepoint3d& point)
{
//double dist = (point-*m_ppickpoint).length() * m_dworldtodevice;
odgematrix3d xworldtoscr = m_pview->worldtodevicematrix();
odgepoint2d p1((xworldtoscr * *m_ppickpoint).convert2d());
odgepoint2d p2((xworldtoscr * point).convert2d());
double dist = (p1 - p2).length();
great, great, great !!!!!!!
thank you very very much !
carlo.