Esempio n. 1
0
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
    //  =======================================================================
    //  Display the splash screen using the overloaded construcutor
    //  =======================================================================
    //  Launch splash screen
    USplash splash1(TEXT(".\\ubi.bmp"), RGB(128, 128, 128), TEXT(".\\start.exe"));
    splash1.ShowSplash();

    // your start up code here
    Sleep(3000); //  simulate using a 5 second delay

    //  Close the splash screen
    splash1.CloseSplash();
	splash1.LaunchApplication();

	return 0;
}
Esempio n. 2
0
//Here we parse the gocde
void parseGCode(HWND hWnd, HINSTANCE g_hInst, char *filePath) {

    std::string line;

	std::ifstream gcodeFile;
	gcodeFile.open(filePath);

	//Get number of lines in the file
	//int numLines = std::count(std::istreambuf_iterator<char>(gcodeFile), 
	//						  std::istreambuf_iterator<char>(), '\n');
	//wchar_t szMessage[300];
	//StringCchPrintf(szMessage, ARRAYSIZE(szMessage), L"%d lines", numLines);
	//MessageBox(hWnd, szMessage, L"Error", MB_OK);

	//Reset cursor file position
	//gcodeFile.seekg(0, ios::beg);

	CSplash splash1(TEXT(""), RGB(128, 128, 128), g_hInst);
	splash1.ShowSplash();

	if (hWnd) {
		if (gcodeFile.is_open()) {
			//MessageBox(hWnd, L"File Opened !", L"Error", MB_OK);
		}
	} else {
		printf("File Opened\n");
	}

	printf("Parsing GCode File\n");

	initStatistics();

	vector3D cornerLow(0.f, 0.f, 0.f);
	vector3D cornerHigh(0.f, 0.f, 0.f);
	float extrusionWidth = 0.f;

	vector3D currentLocation(0.f,0.f,0.f);
    vector3D highCorner(-FLT_MAX,-FLT_MAX,-FLT_MAX);
    vector3D lowCorner(FLT_MAX,FLT_MAX,FLT_MAX);

    while (getline(gcodeFile, line))
    {

        float oldZ = currentLocation.z;

		//std::istringstream *iss = new std::istringstream(line.c_str());
		std::istringstream iss(line.c_str());

        // Is this a new Layer ?
        if (isNewLayer(iss, &currentLocation)) {
            statistics.layersCount++;
            
            // If height has not been found yet
            if (statistics.layerHeight == 0.0){
                
                float theoreticalHeight = floor((currentLocation.z - oldZ)*100)/100;
                
                if (theoreticalHeight > 0 && theoreticalHeight < 1){ // We assume that a layer is less than 1mm thick
                    statistics.layerHeight = theoreticalHeight;
                }
            }
        } else {
			iss = std::istringstream(line.c_str());
		}

		std::string s;
		iss >> s;
		std::string command;
		bool commandFound = scanCharactersFromSet(s, "GMT0123456789", command);


		if (!commandFound) {
            continue;
        }

		if(command == "M104" || command == "M109" || command == "G10") {
			//printf("M104 M109 G10\n");
			// M104: Set Extruder Temperature
            // Set the temperature of the current extruder and return control to the host immediately
            // (i.e. before that temperature has been reached by the extruder). See also M109 that does the same but waits.
            // /!\ This is deprecated because temperatures should be set using the G10 and T commands.
                
            // G10
            // Example: G10 P3 X17.8 Y-19.3 Z0.0 R140 S205
            // This sets the offset for extrude head 3 (from the P3) to the X and Y values specified.
            // The R value is the standby temperature in oC that will be used for the tool, and the S value is its operating temperature.

            // Makerware puts the temperature first, skip it
			iss >> s;
			if (scanString(s, "S", NULL)) {
                scanInt(s, "S");
            }
			// Extract the tool index
			iss >> s;
            if (scanString(s, "P", NULL) || scanString(s, "T", NULL)) {
                int toolIndex;
				if (scanString(s, "P", NULL))
					toolIndex = scanInt(s, "P");
				else
					toolIndex = scanInt(s, "T");
                    
                bool previouslyUsingToolB = statistics.usingToolB;
                statistics.usingToolB = (toolIndex >= 1);
                    
                if (statistics.usingToolB == !previouslyUsingToolB) {
                    statistics.dualExtrusion = true;
                }
            }
		} else if(command == "G1") {