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

#include "stdafx.h"

#include "GripperSelTransform.h"
#include "../interface/Tool.h"
#include "MarkedList.h"
#include "DigitizeMode.h"
#include "StretchTool.h"
#include "HeeksFrame.h"
#include "GraphicsCanvas.h"
#include "ObjPropsCanvas.h"
#include "Sketch.h"
#include "SolveSketch.h"
#include "EndedObject.h"

GripperSelTransform::GripperSelTransform(const gp_Pnt& pos, EnumGripperType gripper_type, void* data):Gripper(pos, _T(""), gripper_type){
	m_data = data;
}

bool GripperSelTransform::OnGripperGrabbed(const std::list<HeeksObj*>& list, bool show_grippers_on_drag, double* from){
	extract(position, m_initial_grip_pos);
	memcpy(m_from, from, 3*sizeof(double));
	memcpy(m_last_from, from, 3*sizeof(double));
	wxGetApp().m_marked_list->gripping = true;
	m_items_marked_at_grab.clear();
	std::list<HeeksObj *>::const_iterator It;
	for(It = list.begin(); It != list.end(); It++){
		m_items_marked_at_grab.push_back(*It);
		wxGetApp().m_marked_list->set_ignore_onoff(*It, true);
	}
	if ( m_gripper_type <= GripperTypeObjectScaleXY )
	{
		wxGetApp().CreateTransformGLList(list, show_grippers_on_drag);
		wxGetApp().m_drag_matrix = gp_Trsf();
		for(It = list.begin(); It != list.end(); It++){
			HeeksObj* object = *It;
			if(object->m_visible)wxGetApp().m_hidden_for_drag.push_back(object);
			object->m_visible = false;
		}
	}
	return true;
}


void GripperSelTransform::OnGripperMoved( double* from, const double* to ){
	if ( m_gripper_type >= GripperTypeStretch && m_gripper_type <= GripperTypeStretch4)
	{
		double shift[3] = {to[0] - from[0], to[1] - from[1], to[2] - from[2]};
		{
			std::list<HeeksObj *>::iterator It;
			for ( It = m_items_marked_at_grab.begin(); It != m_items_marked_at_grab.end(); It++ )
			{
				HeeksObj* object = *It;
				if(object)
				{
					double p[3];
					extract(position, p);
					if(!object->StretchTemporary(p, shift,m_data))return;
					if(wxGetApp().autosolve_constraints && ((ConstrainedObject*)object))
					{
						SolveSketch((CSketch*)object->m_owner,object,m_data);
					}
				}
			}
		}
		extract(gp_Pnt(make_point(from).XYZ() + make_vector( shift ).XYZ()), from);
		position = position.XYZ() + make_vector( shift ).XYZ();
		wxGetApp().Repaint();
		return;
	}

	double object_m[16] = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};

	if(m_items_marked_at_grab.size() > 0)m_items_marked_at_grab.front()->GetScaleAboutMatrix(object_m);

	MakeMatrix ( from, to, object_m, wxGetApp().m_drag_matrix );
	wxGetApp().Repaint();
}

void GripperSelTransform::OnGripperReleased ( const double* from, const double* to )
{
	if ( m_gripper_type > GripperTypeScale )
	{
		wxGetApp().StartHistory();
		double shift[3] = {to[0] - m_initial_grip_pos[0], to[1] - m_initial_grip_pos[1], to[2] - m_initial_grip_pos[2]};
		{<commit_msg>force redraw on geometry update<commit_after>// GripperSelTransform.cpp
// Copyright (c) 2009, <NAME>
// This program is released under the BSD license. See the file COPYING for details.

#include "stdafx.h"

#include "GripperSelTransform.h"
#include "../interface/Tool.h"
#include "MarkedList.h"
#include "DigitizeMode.h"
#include "StretchTool.h"
#include "HeeksFrame.h"
#include "GraphicsCanvas.h"
#include "ObjPropsCanvas.h"
#include "Sketch.h"
#include "SolveSketch.h"
#include "EndedObject.h"

GripperSelTransform::GripperSelTransform(const gp_Pnt& pos, EnumGripperType gripper_type, void* data):Gripper(pos, _T(""), gripper_type){
	m_data = data;
}

bool GripperSelTransform::OnGripperGrabbed(const std::list<HeeksObj*>& list, bool show_grippers_on_drag, double* from){
	extract(position, m_initial_grip_pos);
	memcpy(m_from, from, 3*sizeof(double));
	memcpy(m_last_from, from, 3*sizeof(double));
	wxGetApp().m_marked_list->gripping = true;
	m_items_marked_at_grab.clear();
	std::list<HeeksObj *>::const_iterator It;
	for(It = list.begin(); It != list.end(); It++){
		m_items_marked_at_grab.push_back(*It);
		wxGetApp().m_marked_list->set_ignore_onoff(*It, true);
	}
	if ( m_gripper_type <= GripperTypeObjectScaleXY )
	{
		wxGetApp().CreateTransformGLList(list, show_grippers_on_drag);
		wxGetApp().m_drag_matrix = gp_Trsf();
		for(It = list.begin(); It != list.end(); It++){
			HeeksObj* object = *It;
			if(object->m_visible)wxGetApp().m_hidden_for_drag.push_back(object);
			object->m_visible = false;
		}
	}
	return true;
}


void GripperSelTransform::OnGripperMoved( double* from, const double* to ){
	if ( m_gripper_type >= GripperTypeStretch && m_gripper_type <= GripperTypeStretch4)
	{
		double shift[3] = {to[0] - from[0], to[1] - from[1], to[2] - from[2]};
		{
			std::list<HeeksObj *>::iterator It;
			for ( It = m_items_marked_at_grab.begin(); It != m_items_marked_at_grab.end(); It++ )
			{
				HeeksObj* object = *It;
				if(object)
				{
					double p[3];
					extract(position, p);
					if(!object->StretchTemporary(p, shift,m_data))return;
					if(wxGetApp().autosolve_constraints && ((ConstrainedObject*)object))
					{
						SolveSketch((CSketch*)object->m_owner,object,m_data);
					}
				}
			}
		}
		extract(gp_Pnt(make_point(from).XYZ() + make_vector( shift ).XYZ()), from);
		position = position.XYZ() + make_vector( shift ).XYZ();
		wxGetApp().Repaint(true);
		return;
	}

	double object_m[16] = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};

	if(m_items_marked_at_grab.size() > 0)m_items_marked_at_grab.front()->GetScaleAboutMatrix(object_m);

	MakeMatrix ( from, to, object_m, wxGetApp().m_drag_matrix );
	wxGetApp().Repaint();
}

void GripperSelTransform::OnGripperReleased ( const double* from, const double* to )
{
	if ( m_gripper_type > GripperTypeScale )
	{
		wxGetApp().StartHistory();
		double shift[3] = {to[0] - m_initial_grip_pos[0], to[1] - m_initial_grip_pos[1], to[2] - m_initial_grip_pos[2]};
		{
{'fraction_non_alphanumeric': 0.16280653950953677, 'fraction_numerical': 0.013964577656675749, 'mean_word_length': 5.2279957582184515, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '93394', 'n_tokens_mistral': 2560, 'n_tokens_neox': 2299, 'n_words': 414}