2019-03-20 13:26:24 -07:00
/ *
Copyright ( c ) 2019 , Lars Brubaker , John Lewin
All rights reserved .
Redistribution and use in source and binary forms , with or without
modification , are permitted provided that the following conditions are met :
1. Redistributions of source code must retain the above copyright notice , this
list of conditions and the following disclaimer .
2. Redistributions in binary form must reproduce the above copyright notice ,
this list of conditions and the following disclaimer in the documentation
and / or other materials provided with the distribution .
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT , INDIRECT , INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES
( INCLUDING , BUT NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ;
LOSS OF USE , DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT
( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies ,
either expressed or implied , of the FreeBSD Project .
* /
using System ;
2019-05-17 17:18:23 -07:00
using MatterHackers.Agg ;
2019-03-20 13:26:24 -07:00
using MatterHackers.Agg.UI ;
using MatterHackers.Localizations ;
using MatterHackers.MatterControl.ConfigurationPage.PrintLeveling ;
namespace MatterHackers.MatterControl
{
public class XyCalibrationCollectDataPage : WizardPage
{
2019-05-17 10:17:45 -07:00
private readonly XyCalibrationWizard calibrationWizard ;
2019-03-20 13:26:24 -07:00
2019-03-26 11:50:52 -07:00
public XyCalibrationCollectDataPage ( XyCalibrationWizard calibrationWizard )
2019-03-26 11:48:29 -07:00
: base ( calibrationWizard )
2019-03-20 13:26:24 -07:00
{
2019-03-26 11:48:29 -07:00
this . calibrationWizard = calibrationWizard ;
2019-03-20 13:26:24 -07:00
this . WindowTitle = "Nozzle Offset Calibration Wizard" . Localize ( ) ;
2019-05-29 17:00:18 -07:00
this . HeaderText = "Nozzle Offset Calibration" . Localize ( ) ;
2019-03-20 13:26:24 -07:00
contentRow . Padding = theme . DefaultContainerPadding ;
2019-05-29 17:00:18 -07:00
contentRow . AddChild (
new TextWidget ( "Remove the calibration part from the bed and compare the sides of the pads in each axis." . Localize ( ) , textColor : theme . TextColor , pointSize : theme . DefaultFontSize )
{
Margin = new BorderDouble ( 0 , 15 , 0 , 0 )
} ) ;
contentRow . AddChild (
2019-05-31 17:01:56 -07:00
new TextWidget ( "Pick the pad that is the most aligned with the base, the pad that is the most balance and centered." . Localize ( ) , textColor : theme . TextColor , pointSize : theme . DefaultFontSize )
2019-05-29 17:00:18 -07:00
{
Margin = new BorderDouble ( 0 , 15 , 0 , 0 )
} ) ;
2019-03-20 13:26:24 -07:00
2019-03-26 11:48:29 -07:00
// disable the next button until we receive data about both the x and y axis alignment
2019-03-20 13:26:24 -07:00
NextButton . Enabled = false ;
2019-05-17 17:18:23 -07:00
var calibrationRow = new GuiWidget ( )
2019-03-20 13:26:24 -07:00
{
2019-05-17 17:18:23 -07:00
HAnchor = HAnchor . Stretch ,
VAnchor = VAnchor . Stretch
2019-03-20 13:26:24 -07:00
} ;
2019-05-17 17:18:23 -07:00
contentRow . AddChild ( calibrationRow ) ;
2019-05-08 18:02:44 -07:00
2019-05-17 17:18:23 -07:00
calibrationRow . AddChild (
new CalibrationTabWidget ( calibrationWizard , NextButton , theme )
2019-03-20 16:06:07 -07:00
{
2019-05-17 17:18:23 -07:00
HAnchor = HAnchor . Center | HAnchor . Absolute ,
VAnchor = VAnchor . Center | VAnchor . Absolute ,
Width = 350 ,
Height = 350
2019-03-20 16:06:07 -07:00
} ) ;
2019-03-20 13:26:24 -07:00
}
2019-05-29 12:23:23 -07:00
public override void OnAdvance ( )
2019-03-20 13:26:24 -07:00
{
// save the offsets to the extruder
2019-05-29 12:23:23 -07:00
if ( calibrationWizard . XPick ! = - 1
2019-03-26 11:48:29 -07:00
& & calibrationWizard . YPick ! = - 1 )
2019-03-20 17:13:42 -07:00
{
2019-03-26 11:48:29 -07:00
var hotendOffset = printer . Settings . Helpers . ExtruderOffset ( calibrationWizard . ExtruderToCalibrateIndex ) ;
2019-05-17 17:18:23 -07:00
hotendOffset . X - = calibrationWizard . Offset * 3 - calibrationWizard . Offset * calibrationWizard . XPick ;
2019-03-26 11:48:29 -07:00
hotendOffset . Y - = calibrationWizard . Offset * - 3 + calibrationWizard . Offset * calibrationWizard . YPick ;
2019-03-20 16:06:07 -07:00
2019-03-26 11:48:29 -07:00
printer . Settings . Helpers . SetExtruderOffset ( calibrationWizard . ExtruderToCalibrateIndex , hotendOffset ) ;
2019-03-20 17:13:42 -07:00
}
2019-03-20 13:26:24 -07:00
}
}
2019-05-17 17:18:23 -07:00
}