示例#1
0
/**
	The fixture objects may be in the 'theApp.m_program->Fixtures()' tree (for globally applied fixtures) but
	they may also be children of operations 'theApp.m_program->Operations()'.
 */
CFixture *CFixtures::Find( const CFixture::eCoordinateSystemNumber_t coordinate_system_number, const bool only_public_fixtures /* = false */ )
{
    for(HeeksObj* ob = GetFirstChild(); ob; ob = GetNextChild())
    {
        if (ob->GetType() != FixtureType) continue;

        if (ob != NULL)
        {
            if (((CFixture *)ob)->m_coordinate_system_number == coordinate_system_number)
            {
                return( (CFixture *) ob );
            } // End if - then
        } // End if - then
    } // End for

    if (only_public_fixtures == false)
    {
        for(HeeksObj* operation = theApp.m_program->Operations()->GetFirstChild(); operation; operation = theApp.m_program->Operations()->GetNextChild())
        {
            for (HeeksObj *ob = operation->GetFirstChild(); ob != NULL; ob = operation->GetNextChild())
            {
                if (ob->GetType() != FixtureType) continue;

                if (ob != NULL)
                {
                    if (((CFixture *)ob)->m_coordinate_system_number == coordinate_system_number)
                    {
                        return( (CFixture *) ob );
                    } // End if - then
                } // End if - then
            } // End for
        } // End for
    } // End if - then

    return(NULL);

} // End Find() method
示例#2
0
void CTreeCanvas::OnLabelLeftDown(HeeksObj* object, wxMouseEvent& event)
{
	if(event.ShiftDown())
	{
		// mark a list of siblings
#ifdef MULTIPLE_OWNERS
		HeeksObj* parent = object->HEEKSOBJ_OWNER;
#else
		HeeksObj* parent = object->m_owner;
#endif
		std::set<HeeksObj*> sibling_set;
		std::list<HeeksObj*> sibling_list;
		for(HeeksObj* sibling = parent->GetFirstChild(); sibling; sibling = parent->GetNextChild())
		{
			sibling_set.insert(sibling);
			sibling_list.push_back(sibling);
		}
		// find most recently marked sibling
		std::list<HeeksObj*> &marked = wxGetApp().m_marked_list->list();
		HeeksObj* recently_marked_sibling = NULL;
		bool recent_first = false;
		for(std::list<HeeksObj*>::reverse_iterator It = marked.rbegin(); It != marked.rend(); It++)
		{
			if(*It == object)recent_first = true;
			if(sibling_set.find(*It) != sibling_set.end())
			{
				recently_marked_sibling = *It;
				break;
			}
		}

		if(recently_marked_sibling)
		{
			if(!event.ControlDown())
			{
				wxGetApp().m_marked_list->Clear(false);
			}

			bool marking = false;
			std::list<HeeksObj*> list_to_mark;
			bool finish_marking = false;
			for(std::list<HeeksObj*>::iterator It = sibling_list.begin(); !finish_marking && It != sibling_list.end(); It++)
			{
				HeeksObj* sibling = *It;
				if(sibling == object || sibling == recently_marked_sibling)
				{
					if(marking)finish_marking = true;
					else marking = true;
				}

				if(marking)
				{
					list_to_mark.push_back(sibling);
				}
			}

			wxGetApp().m_marked_list->Add(list_to_mark, true);
		}
		else
		{
			if(event.ControlDown())
			{
				if(wxGetApp().m_marked_list->ObjectMarked(object))
				{
					wxGetApp().m_marked_list->Remove(object, true);
				}
				else{
					wxGetApp().m_marked_list->Add(object, true);
				}
			}
			else
			{
				if(wxGetApp().m_marked_list->ObjectMarked(object))
				{
					m_waiting_until_left_up = true;
				}
				else
				{
					wxGetApp().m_marked_list->Clear(false);
					wxGetApp().m_marked_list->Add(object, true);
				}
			}
		}
	}
	else
	{
		// shift not down
		if(event.ControlDown())
		{
			if(wxGetApp().m_marked_list->ObjectMarked(object))
			{
				wxGetApp().m_marked_list->Remove(object, true);
			}
			else{
				wxGetApp().m_marked_list->Add(object, true);
			}
		}
		else
		{
			if(wxGetApp().m_marked_list->ObjectMarked(object))
			{
				m_waiting_until_left_up = true;
			}
			else
			{
				wxGetApp().m_marked_list->Clear(false);
				wxGetApp().m_marked_list->Add(object, true);
			}
		}
	}
}
示例#3
0
Python CAdaptive::AppendTextToProgram(CMachineState *pMachineState )
{
	Python python;

	python << COp::AppendTextToProgram(pMachineState);

	heeksCAD->CreateUndoPoint();

	//write stl file
	std::list<HeeksObj*> solids;
	for(std::list<int>::iterator It = m_solids.begin(); It != m_solids.end(); It++)
	{
		HeeksObj* object = heeksCAD->GetIDObject(SolidType, *It);
		if (object != NULL)
		{
			// Need to rotate a COPY of the solid by the fixture settings.
			HeeksObj* copy = object->MakeACopy();
			if (copy != NULL)
			{
				double m[16];	// A different form of the transformation matrix.
				CFixture::extract( pMachineState->Fixture().GetMatrix(CFixture::YZ), m );
				copy->ModifyByMatrix(m);

				CFixture::extract( pMachineState->Fixture().GetMatrix(CFixture::XZ), m );
				copy->ModifyByMatrix(m);

				CFixture::extract( pMachineState->Fixture().GetMatrix(CFixture::XY), m );
				copy->ModifyByMatrix(m);

				solids.push_back(copy);
			} // End if - then
		} // End if - then
	} // End for

	// Reconfirm that our retractzheight value is sufficient.
	const double small_buffer = 5.0;	// Don't scrape the mountain tops.
	double max_z = CAdaptive::GetMaxHeight( SolidType, m_solids );
	if (m_params.m_retractzheight < (max_z + small_buffer))
	{
		m_params.m_retractzheight = max_z + small_buffer;
	} // End if - then

	max_z = CAdaptive::GetMaxHeight( SketchType, m_sketches );
	if (m_params.m_boundaryclear < max_z) m_params.m_boundaryclear = max_z;

    wxStandardPaths standard_paths;
    wxFileName filepath;

    filepath.Assign( standard_paths.GetTempDir().c_str(), wxString::Format(_T("adaptive%d.stl"), number_for_stl_file).c_str() );

	number_for_stl_file++;
	heeksCAD->SaveSTLFile(solids, filepath.GetFullPath());

	// We don't need the duplicate solids any more.  Delete them.
	for (std::list<HeeksObj*>::iterator l_itSolid = solids.begin(); l_itSolid != solids.end(); l_itSolid++)
	{
		heeksCAD->Remove( *l_itSolid );
	} // End for

	python << _T("rapid(z=") << m_params.m_retractzheight << _T(")\n");

	gp_Pnt start = pMachineState->Fixture().Adjustment( gp_Pnt( m_params.m_startpoint_x, m_params.m_startpoint_y, m_params.m_retractzheight ) );
	python << _T("rapid(x=") << start.X() << _T(", y=") << start.Y() << _T(")\n");

	python << _T("actp.setleadoffdz(") << m_params.m_leadoffdz << _T(")\n");

	python << _T("actp.setleadofflen(") << m_params.m_leadofflen << _T(")\n");

	python << _T("actp.setleadoffrad(") << m_params.m_leadoffrad << _T(")\n");

	python << _T("actp.setretractzheight(") << m_params.m_retractzheight << _T(")\n");

	python << _T("actp.setleadoffsamplestep(") << m_params.m_leadoffsamplestep << _T(")\n");

	if ((((COp *)this)->m_tool_number > 0) &&
	    (CTool::FindTool( ((COp *)this)->m_tool_number ) > 0) )
	{
		// We have a  tool to refer to.  Get these values from there instead.

		CTool *pTool = (CTool *) CTool::Find( ((COp *)this)->m_tool_number );
		if (pTool != NULL)
		{
			python << _T("actp.settoolcornerrad(") << pTool->m_params.m_corner_radius << _T(")\n");
			python << _T("actp.settoolflatrad(") << pTool->m_params.m_flat_radius << _T(")\n");
		} // End if - then
	} // End if - then
	else
	{
		// This object has values and/or we don't have a  tool number to refer to.
		// Use these values instead.

		python << _T("actp.settoolcornerrad(") << m_params.m_toolcornerrad << _T(")\n");
		python << _T("actp.settoolflatrad(") << m_params.m_toolflatrad << _T(")\n");
	} // End if - else

	python << _T("actp.setsamplestep(") << m_params.m_samplestep << _T(")\n");

	python << _T("actp.setstepdown(") << m_params.m_stepdown << _T(")\n");

	python << _T("actp.setclearcuspheight(") << m_params.m_clearcuspheight << _T(")\n");

	python << _T("actp.settriangleweaveres(") << m_params.m_triangleweaveres << _T(")\n");

	python << _T("actp.setflatradweaveres(") << m_params.m_flatradweaveres << _T(")\n");

	python << _T("actp.setdchangright(") << m_params.m_dchangright << _T(")\n");

	python << _T("actp.setdchangrightoncontour(") << m_params.m_dchangrightoncontour << _T(")\n");

	python << _T("actp.setdchangleft(") << m_params.m_dchangleft << _T(")\n");

	python << _T("actp.setdchangefreespace(") << m_params.m_dchangefreespace << _T(")\n");

	python << _T("actp.setsidecutdisplch(") << m_params.m_sidecutdisplch << _T(")\n");

	python << _T("actp.setfcut(") << m_params.m_fcut << _T(")\n");

	python << _T("actp.setfretract(") << m_params.m_fretract << _T(")\n");

	python << _T("actp.setthintol(") << m_params.m_thintol << _T(")\n");

	python << _T("actp.setstartpoint(") << start.X() << _T(", ") << start.Y() << _T(", ") << m_params.m_startvel_x << _T(", ") << m_params.m_startvel_y << _T(")\n");

	python << _T("actp.setminz(") << m_params.m_minz << _T(")\n");

	python << _T("actp.boundaryclear(") << m_params.m_boundaryclear << _T(")\n");

	if(!m_sketches.empty())
	{
		std::list<HeeksObj*> sketches;
		for(std::list<int>::iterator It = m_sketches.begin(); It != m_sketches.end(); It++)
		{
			HeeksObj* sketch = heeksCAD->GetIDObject(SketchType, *It);
			if(sketch){
				for(HeeksObj* span_object = sketch->GetFirstChild(); span_object; span_object = sketch->GetNextChild())
				{
					double s[3] = {0, 0, 0};
					double e[3] = {0, 0, 0};
					if(span_object){
						int type = span_object->GetType();
						//TODO: add support for arcs
						if(type == LineType)
						{
							span_object->GetStartPoint(s);
							pMachineState->Fixture().Adjustment(s);

							span_object->GetEndPoint(e);
							pMachineState->Fixture().Adjustment(e);

							python << _T("actp.boundaryadd(") << s[0] << _T(", ") << s[1] << _T(")\n");
							python << _T("actp.boundaryadd(") << e[0] << _T(", ") << e[1] << _T(")\n");
						}
					}
				}
			}
			python << _T("actp.boundarybreak()\n");
		}
	}
	else
	{
		gp_Pnt boundary[2];
		boundary[0] = pMachineState->Fixture().Adjustment( gp_Pnt( m_params.m_boundary_x0, m_params.m_boundary_y0, 0.0 ) );
		boundary[1] = pMachineState->Fixture().Adjustment( gp_Pnt( m_params.m_boundary_x1, m_params.m_boundary_y1, 0.0 ) );

		python << _T("actp.boundaryadd(") << boundary[0].X() << _T(", ") << boundary[0].Y() << _T(")\n");

		python << _T("actp.boundaryadd(") << boundary[0].X() << _T(", ") << boundary[1].Y() << _T(")\n");

		python << _T("actp.boundaryadd(") << boundary[1].X() << _T(", ") << boundary[1].Y() << _T(")\n");

		python << _T("actp.boundaryadd(") << boundary[1].X() << _T(", ") << boundary[0].Y() << _T(")\n");

		python << _T("actp.boundarybreak()\n");

	}

	python << _T("actp_funcs.cut(") << PythonString(filepath.GetFullPath()) << _T(")\n");

	python << _T("rapid(z=") << m_params.m_retractzheight << _T(")\n");

	return(python);
}