# Taking a wack at fixing my first heekscad bug.

I have the need to adjust a line to exactly 1″ in heekscad… (I just can’t get into that thar metric stuff just yet).

Anyway.. I’m suspect that since I running inch.. Some thing is hosed up in the code. I think the quickest way to isolate the code is to see where the green check icon loads up.

I was just chatting with Dan Heeks and Jon Pry
Apparently there are two ways to set a length to exactly 1″.. One is to set a fixed length constraint and the other is through a dimensional constraint.

I guess the fixed point constraint is deprecated in favor of the dimension constraint (which is also having issues in inch), but I think it might be easier to figure out rather then the dimensional… The fixed point constraint always displays metric even when inch
So I thought I’d give it a go.
The first thing I wanted to do is to see if I can isolate the section of code that applies changes to adjusted properties. If I can find that way… I should be able to single step myself into the other sections of code where the dimensions are display… That’s the theory anyway…

So… I’m looking at the

I poke around a bit and I think i found the section of code that I need to fix.

void Constraint::glCommands(HeeksColor color, gp_Ax1 axis)
{
double mag = sqrt(axis.Direction().X() * axis.Direction().X() + axis.Direction().Y() * axis.Direction().Y());
float rot = (float)atan2(axis.Direction().Y()/mag,axis.Direction().X()/mag);

glPushMatrix();
glTranslatef((float)axis.Location().X(),(float)axis.Location().Y(),(float)axis.Location().Z());
glRotatef(rot*180/(float)Pi,0,0,1);
glTranslatef(0,ANGLE_OFFSET_FROM_LINE,0);

switch(m_type)
{
case AbsoluteAngleConstraint:
switch(m_angle)
{
case AbsoluteAngleHorizontal:
render_text(_(“H”));
break;
case AbsoluteAngleVertical:
glRotatef(90,0,0,1);
render_text(_(“V”));
break;
}
break;
case LineLengthConstraint:
wxChar str;
wxSprintf(str,_T(“%f”),m_length);
render_text(str);
break;
case ParallelLineConstraint:
render_text(_(“L”));
break;
case PerpendicularLineConstraint:
render_text(_(“P”));
break;
default:
break;
}

glPopMatrix();
}

Ok… Something tells me that mlength is in mm… I need to convert… soo. the dimension are converting over correctly… I just need need to find that being displayed.
Lets see if I can find the dimensions.
Ok…. I think I found it..

wxString HDimension::MakeText()
{
wxString text;

double units_factor = wxGetApp().m_view_units;
switch(m_units)
{
case DimensionUnitsInches:
units_factor = 25.4;
break;
case DimensionUnitsMM:
units_factor = 1.0;
break;
case DimensionUnitsGlobal:
units_factor = wxGetApp().m_view_units;
break;
}

wxString units_str(_T(“”));
if(fabs(units_factor – 1.0) < 0.0000000001)units_str += wxString(_T(" ")) + _("mm"); else if(fabs(units_factor - 25.4) < 0.000000001)units_str += wxString(_T(" ")) + _("inch"); switch(m_text_mode) { case PythagoreanDimensionTextMode: text = wxString::Format(_T("%lg %s"), A->m_p.Distance(B->m_p)/units_factor, units_str.c_str());
break;
case HorizontalDimensionTextMode:
text = wxString::Format(_T(“%lg %s H”), fabs(A->m_p.X() – B->m_p.X())/units_factor, units_str.c_str());
break;
case VerticalDimensionTextMode:
text = wxString::Format(_T(“%lg %s V”), fabs(A->m_p.Y() – B->m_p.Y())/units_factor, units_str.c_str());
break;
}

return text;
}

Ok… So here’s my first c++ code change to heekscad. Scary..