Esempio n. 1
0
void AddSolidsProperties(std::list<Property *> *list, HeeksObj* object)
{
	std::list<int> solids;
	for(HeeksObj* child = object->GetFirstChild(); child; child = object->GetNextChild())
	{
		if(child->GetIDGroupType() == SolidType)solids.push_back(child->GetID());
	}
#else
void AddSolidsProperties(std::list<Property *> *list, const std::list<int> &solids)
{
#endif
	if(solids.size() == 0)list->push_back(new PropertyString(_("solids"), _("None"), NULL));
	else if(solids.size() == 1)list->push_back(new PropertyInt(_("solid id"), solids.front(), NULL));
	else list->push_back(new PropertyString(_("solids"), GetIntListString(solids), NULL));
}

#ifdef OP_SKETCHES_AS_CHILDREN
void AddSketchesProperties(std::list<Property *> *list, HeeksObj* object)
{
	std::list<int> sketches;
	for(HeeksObj* child = object->GetFirstChild(); child; child = object->GetNextChild())
	{
		if(child->GetIDGroupType() == SketchType)sketches.push_back(child->GetID());
	}
#else
void AddSketchesProperties(std::list<Property *> *list, const std::list<int> &sketches)
{
#endif
	if(sketches.size() == 0)list->push_back(new PropertyString(_("sketches"), _("None"), NULL));
	else if(sketches.size() == 1)list->push_back(new PropertyInt(_("sketch id"), sketches.front(), NULL));
	else list->push_back(new PropertyString(_("sketches"), GetIntListString(sketches), NULL));
}
Esempio n. 2
0
void CWaterline::WriteXML(TiXmlNode *root)
{
	TiXmlElement * element = heeksCAD->NewXMLElement( "Waterline" );
	heeksCAD->LinkXMLEndChild( root,  element );
	m_params.WriteXMLAttributes(element);

	// write solid ids
	for (HeeksObj *object = GetFirstChild(); object != NULL; object = GetNextChild())
	{
		if (object->GetIDGroupType() != SolidType)continue;
		int solid = object->GetID();
		TiXmlElement * solid_element = heeksCAD->NewXMLElement( "solid" );
		heeksCAD->LinkXMLEndChild( element, solid_element );
		solid_element->SetAttribute("id", solid);
	}

	WriteBaseXML(element);
}
Esempio n. 3
0
bool DrillingDlg::Do(CDrilling* object)
{
	DrillingDlg dlg(heeksCAD->GetMainFrame(), object);

	while(1)
	{
		int result = dlg.ShowModal();

		if(result == wxID_OK)
		{
			dlg.GetData(object);
			return true;
		}
		else if(result == ID_POINTS_PICK)
		{
			heeksCAD->ClearMarkedList();
            MarkingFilter filters[] = { PointMarkingFilter };
            std::set<MarkingFilter> filterset (filters, filters + sizeof(filters) / sizeof(MarkingFilter));
			heeksCAD->PickObjects(_("Pick points to drill"), filterset, false);

			std::list<int> ids;
			const std::list<HeeksObj*> &list = heeksCAD->GetMarkedList();
			if(list.size() > 0)
			{
				for(std::list<HeeksObj*>::const_iterator It = list.begin(); It != list.end(); It++)
				{
					HeeksObj* object = *It;
					ids.push_back(object->GetID());
				}
			}

			dlg.m_idsPoints->SetFromIDList(ids);

			dlg.Fit();
		}
		else
		{
			return false;
		}
	}
}
Esempio n. 4
0
void CAttachOp::WriteXML(TiXmlNode *root)
{
	TiXmlElement * element = heeksCAD->NewXMLElement( "AttachOp" );
	heeksCAD->LinkXMLEndChild( root,  element );

	element->SetDoubleAttribute( "tolerance", m_tolerance);
	element->SetDoubleAttribute( "minz", m_min_z);
	element->SetDoubleAttribute( "material_allowance", m_material_allowance);

	// write solid ids
#ifdef OP_SKETCHES_AS_CHILDREN
	for (HeeksObj *object = GetFirstChild(); object != NULL; object = GetNextChild())
	{
		if (object->GetIDGroupType() != SolidType)continue;
		int solid = object->GetID();
#else
	for (std::list<int>::iterator It = m_solids.begin(); It != m_solids.end(); It++)
    {
		int solid = *It;
#endif
		TiXmlElement * solid_element = heeksCAD->NewXMLElement( "solid" );
		heeksCAD->LinkXMLEndChild( element, solid_element );
		solid_element->SetAttribute("id", solid);
	}

	COp::WriteBaseXML(element);
}

// static member function
HeeksObj* CAttachOp::ReadFromXMLElement(TiXmlElement* element)
{
	CAttachOp* new_object = new CAttachOp;

	element->Attribute("tolerance", &new_object->m_tolerance);
	element->Attribute("minz", &new_object->m_min_z);
	element->Attribute("material_allowance", &new_object->m_material_allowance);

	std::list<TiXmlElement *> elements_to_remove;

	// read solid ids
	for(TiXmlElement* pElem = heeksCAD->FirstXMLChildElement( element ) ; pElem; pElem = pElem->NextSiblingElement())
	{
		std::string name(pElem->Value());
		if(name == "solid"){
			for(TiXmlAttribute* a = pElem->FirstAttribute(); a; a = a->Next())
			{
				std::string name(a->Name());
				if(name == "id"){
					int id = a->IntValue();
					new_object->m_solids.push_back(id);
				}
			}
			elements_to_remove.push_back(pElem);
		}
	}

	for (std::list<TiXmlElement*>::iterator itElem = elements_to_remove.begin(); itElem != elements_to_remove.end(); itElem++)
	{
		heeksCAD->RemoveXMLChild( element, *itElem);
	}

	new_object->ReadBaseXML(element);

	return new_object;
}
Esempio n. 5
0
Python CPocket::AppendTextToProgram()
{
	Python python;

	CTool *pTool = CTool::Find( m_tool_number );
	if (pTool == NULL)
	{
		wxMessageBox(_T("Cannot generate GCode for pocket without a tool assigned"));
		return python;
	} // End if - then


	python << CSketchOp::AppendTextToProgram();

	HeeksObj* object = wxGetApp().GetIDObject(SketchType, m_sketch);

	if(object == NULL) {
		wxMessageBox(wxString::Format(_("Pocket operation - Sketch doesn't exist")));
		return python;
	}

	int type = object->GetType();

	// do areas and circles first, separately
    {
		switch(type)
		{
		case CircleType:
		case AreaType:
			{
				wxGetApp().ObjectAreaString(object, python);
				WritePocketPython(python);
			}
			break;
		}
	}

	if(type == SketchType)
	{
		python << _T("a = area.Area()\n");
		python << _T("entry_moves = []\n");

		if (object->GetNumChildren() == 0){
			wxMessageBox(wxString::Format(_("Pocket operation - Sketch %d has no children"), object->GetID()));
			return python;
		}

		HeeksObj* re_ordered_sketch = NULL;
		SketchOrderType order = ((CSketch*)object)->GetSketchOrder();
		if( 	(order != SketchOrderTypeCloseCW) &&
			(order != SketchOrderTypeCloseCCW) &&
			(order != SketchOrderTypeMultipleCurves) &&
			(order != SketchOrderHasCircles))
		{
			re_ordered_sketch = object->MakeACopy();
			((CSketch*)re_ordered_sketch)->ReOrderSketch(SketchOrderTypeReOrder);
			object = re_ordered_sketch;
			order = ((CSketch*)object)->GetSketchOrder();
			if(	(order != SketchOrderTypeCloseCW) &&
				(order != SketchOrderTypeCloseCCW) &&
				(order != SketchOrderTypeMultipleCurves) &&
				(order != SketchOrderHasCircles))
			{
				switch (((CSketch*)object)->GetSketchOrder())
				{
				case SketchOrderTypeOpen:
					{
						wxMessageBox(wxString::Format(_("Pocket operation - Sketch must be a closed shape - sketch %d"), object->m_id));
						delete re_ordered_sketch;
						return python;
					}
					break;

				default:
					{
						wxMessageBox(wxString::Format(_("Pocket operation - Badly ordered sketch - sketch %d"), object->m_id));
						delete re_ordered_sketch;
						return python;
					}
					break;
				}
			}
		}

		if(object)
		{
			python << WriteSketchDefn(object);
		}

		if(re_ordered_sketch)
		{
			delete re_ordered_sketch;
		}

	} // End for

	// reorder the area, the outside curves must be made anti-clockwise and the insides clockwise
	python << _T("a.Reorder()\n");

	WritePocketPython(python);

	return python;
}