<commit_before>// Operations.cpp
// Copyright (c) 2009, <NAME>
// This program is released under the BSD license. See the file COPYING for details.

#include "stdafx.h"
#include "Operations.h"
#include "Op.h"
#include "tinyxml/tinyxml.h"
#include "Excellon.h"

#include <wx/progdlg.h>

bool COperations::CanAdd(HeeksObj* object)
{
	return 	COp::IsAnOperation(object->GetType());
}

void COperations::WriteXML(TiXmlNode *root)
{
	TiXmlElement * element;
	element = new TiXmlElement( "Operations" );
	root->LinkEndChild( element );  
	WriteBaseXML(element);
}

//static
HeeksObj* COperations::ReadFromXMLElement(TiXmlElement* pElem)
{
	COperations* new_object = new COperations;
	new_object->ReadBaseXML(pElem);
	return new_object;
}

static COperations* object_for_tools = NULL;

class SetAllActive: public Tool{
	// Tool's virtual functions
	const wxChar* GetTitle(){return _("Set All Operations Active");}
	void Run()
	{
		for(HeeksObj* object = object_for_tools->GetFirstChild(); object; object = object_for_tools->GetNextChild())
		{
			if(COp::IsAnOperation(object->GetType()))
			{
				((COp*)object)->m_active = true;
				heeksCAD->Changed();
			}
		}
	}
	wxString BitmapPath(){ return _T("setactive");}
};

static SetAllActive set_all_active;

class SetAllInactive: public Tool{
	// Tool's virtual functions
	const wxChar* GetTitle(){return _("Set All Operations Inactive");}
	void Run()
	{
		for(HeeksObj* object = object_for_tools->GetFirstChild(); object; object = object_for_tools->GetNextChild())
		{
			if(COp::IsAnOperation(object->GetType()))
			{
				((COp*)object)->m_active = false;
				heeksCAD->Changed();
			}
		}
	}
	wxString BitmapPath(){ return _T("setinactive");}
};

static SetAllInactive set_all_inactive;

class ImportExcellonDrillFile: public Tool{
	// Tool's virtual functions
	const wxChar* GetTitle(){return _("Import Excellon Drill File");}
	void Run()
	{
		wxFileDialog dialog(heeksCAD->GetMainFrame(), _("Import Excellon Drill File"), 
					wxEmptyString, wxEmptyString, 
					wxString(_("Excellon Drill Files")) + _T(" |*.cnc;*.CNC;*.drill;*.DRILL;") );
		dialog.CentreOnParent();
		if (dialog.ShowModal() == wxID_OK)
		{
			Excellon drill;
			drill.Read( Ttc(dialog.GetPath().c_str()) );
		}

	}
	wxString BitmapPath(){ return _T("drill");}
};

static ImportExcellonDrillFile import_excellon_drill_file;

void COperations::GetTools(std::list<Tool*>* t_list, const wxPoint* p)
{<commit_msg>Added '.drill' and '.drl' extensions for Excellon drill files.  These are used by KiCAD-generated files.<commit_after>// Operations.cpp
// Copyright (c) 2009, <NAME>
// This program is released under the BSD license. See the file COPYING for details.

#include "stdafx.h"
#include "Operations.h"
#include "Op.h"
#include "tinyxml/tinyxml.h"
#include "Excellon.h"

#include <wx/progdlg.h>

bool COperations::CanAdd(HeeksObj* object)
{
	return 	COp::IsAnOperation(object->GetType());
}

void COperations::WriteXML(TiXmlNode *root)
{
	TiXmlElement * element;
	element = new TiXmlElement( "Operations" );
	root->LinkEndChild( element );  
	WriteBaseXML(element);
}

//static
HeeksObj* COperations::ReadFromXMLElement(TiXmlElement* pElem)
{
	COperations* new_object = new COperations;
	new_object->ReadBaseXML(pElem);
	return new_object;
}

static COperations* object_for_tools = NULL;

class SetAllActive: public Tool{
	// Tool's virtual functions
	const wxChar* GetTitle(){return _("Set All Operations Active");}
	void Run()
	{
		for(HeeksObj* object = object_for_tools->GetFirstChild(); object; object = object_for_tools->GetNextChild())
		{
			if(COp::IsAnOperation(object->GetType()))
			{
				((COp*)object)->m_active = true;
				heeksCAD->Changed();
			}
		}
	}
	wxString BitmapPath(){ return _T("setactive");}
};

static SetAllActive set_all_active;

class SetAllInactive: public Tool{
	// Tool's virtual functions
	const wxChar* GetTitle(){return _("Set All Operations Inactive");}
	void Run()
	{
		for(HeeksObj* object = object_for_tools->GetFirstChild(); object; object = object_for_tools->GetNextChild())
		{
			if(COp::IsAnOperation(object->GetType()))
			{
				((COp*)object)->m_active = false;
				heeksCAD->Changed();
			}
		}
	}
	wxString BitmapPath(){ return _T("setinactive");}
};

static SetAllInactive set_all_inactive;

class ImportExcellonDrillFile: public Tool{
	// Tool's virtual functions
	const wxChar* GetTitle(){return _("Import Excellon Drill File");}
	void Run()
	{
		wxFileDialog dialog(heeksCAD->GetMainFrame(), _("Import Excellon Drill File"), 
					wxEmptyString, wxEmptyString, 
					wxString(_("Excellon Drill Files")) + _T(" |*.cnc;*.CNC;*.drill;*.DRILL;*.drl;*.DRL") );
		dialog.CentreOnParent();
		if (dialog.ShowModal() == wxID_OK)
		{
			Excellon drill;
			drill.Read( Ttc(dialog.GetPath().c_str()) );
		}

	}
	wxString BitmapPath(){ return _T("drill");}
};

static ImportExcellonDrillFile import_excellon_drill_file;

void COperations::GetTools(std::list<Tool*>* t_list, const wxPoint* p)
{
{'fraction_non_alphanumeric': 0.1485668146951958, 'fraction_numerical': 0.0016148566814695195, 'mean_word_length': 5.15527950310559, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2836881', 'n_tokens_mistral': 1860, 'n_tokens_neox': 1743, 'n_words': 374}