Commit 7e76fd08 authored by Mikhail Karpenko's avatar Mikhail Karpenko

Move teardrops editor to tool framework

parent a1ac84e5
......@@ -279,7 +279,6 @@ set( PCB_COMMON_SRCS
../pcbnew/class_zone.cpp
../pcbnew/class_zone_settings.cpp
../pcbnew/class_teardrop.cpp
../pcbnew/edit_teardrops.cpp
../pcbnew/classpcb.cpp
../pcbnew/ratsnest_data.cpp
../pcbnew/ratsnest_viewitem.cpp
......
......@@ -276,6 +276,7 @@ set( PCBNEW_CLASS_SRCS
tools/bright_box.cpp
tools/edit_points.cpp
tools/edit_constraints.cpp
tools/edit_teardrops.cpp
tools/point_editor.cpp
tools/drawing_tool.cpp
tools/edit_tool.cpp
......
......@@ -80,7 +80,7 @@ bool TEARDROP::CurvedSegments(TRACK &aTrack, const VIA &aVia, std::vector<VECTOR
// Check that the track is not too short
double segOutsideVia = aTrack.GetLength() - (aVia.GetWidth() / 2);
double minLength = (90 * aVia.GetWidth() / 2) / 100;
double minLength = (150 * aVia.GetWidth() / 2) / 100;
if (segOutsideVia < minLength) {
return false;
}
......
......@@ -88,7 +88,7 @@ DIALOG_TEARDROPS_BASE::DIALOG_TEARDROPS_BASE( wxWindow* parent, wxWindowID id, c
m_scopeVias->SetValue(true);
sbSizer16->Add( m_scopeVias, 0, 0, 5 );
m_scopePads = new wxCheckBox( this, wxID_ANY, wxT("Pads"), wxDefaultPosition, wxDefaultSize, 0 );
m_scopePads = new wxCheckBox( this, wxID_ANY, wxT("Circular pads"), wxDefaultPosition, wxDefaultSize, 0 );
m_scopePads->SetValue(true);
sbSizer16->Add( m_scopePads, 0, 0, 5 );
......
......@@ -689,7 +689,7 @@
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Pads</property>
<property name="label">Circular pads</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_scopePads</property>
......
......@@ -62,11 +62,10 @@
#include <class_track.h>
#include <class_board.h>
#include <class_module.h>
//#include <class_teardrop.h>
#include <worksheet_viewitem.h>
#include <ratsnest_data.h>
#include <ratsnest_viewitem.h>
#include <edit_teardrops.h>
#include <tools/edit_teardrops.h>
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
......@@ -735,9 +734,7 @@ void PCB_EDIT_FRAME::ShowTeardropsEditor( wxCommandEvent& event )
int retVal = dlg_teardrops->ShowModal();
if (retVal == wxID_OK) {
SELECTION selection = m_toolManager->GetTool<SELECTION_TOOL>()->GetSelection();
TEARDROPS_EDITOR editor(this, GetGalCanvas()->GetView());
editor.EditTeardrops(selection, settings);
m_toolManager->GetTool<TEARDROPS_EDITOR>()->EditTeardrops(settings);
OnModify();
}
}
......
......@@ -458,6 +458,10 @@ TOOL_ACTION COMMON_ACTIONS::routerInlineDrag( "pcbnew.InteractiveRouter.InlineDr
AS_GLOBAL, 0,
"", "" );
TOOL_ACTION COMMON_ACTIONS::teardropsEditor( "pcbnew.TeardropsEditor.EditTeardrops",
AS_GLOBAL, 0,
_( "Run teardrops editor" ), _( "Run teardrops editor" ), NULL, AF_ACTIVATE);
// Point editor
TOOL_ACTION COMMON_ACTIONS::pointEditorUpdate( "pcbnew.PointEditor.update",
AS_GLOBAL, 0,
......
......@@ -281,6 +281,9 @@ public:
static TOOL_ACTION copySettingsToPads;
static TOOL_ACTION globalEditPads;
/// Activate teardrops editor
static TOOL_ACTION teardropsEditor;
/**
* Function TranslateLegacyId()
......
......@@ -3,12 +3,22 @@
#include "class_module.h"
#include "ratsnest_data.h"
#include "view/view.h"
#include "common_actions.h"
#include "router/pns_utils.h"
TEARDROPS_EDITOR::TEARDROPS_EDITOR(PCB_EDIT_FRAME *frame, KIGFX::VIEW *view)
TEARDROPS_EDITOR::TEARDROPS_EDITOR() :
TOOL_BASE(BATCH, TOOL_MANAGER::MakeToolId("pcbnew.TeardropsEditor"), "pcbnew.TeardropsEditor")
{
m_frame = frame;
m_view = view;
}
TEARDROPS_EDITOR::~TEARDROPS_EDITOR()
{
}
void TEARDROPS_EDITOR::Reset(RESET_REASON aReason)
{
m_frame = getEditFrame<PCB_EDIT_FRAME>();
m_view = getView();
}
void TEARDROPS_EDITOR::FilterSelection(SELECTION &selection)
......@@ -23,9 +33,10 @@ void TEARDROPS_EDITOR::FilterSelection(SELECTION &selection)
}
}
bool TEARDROPS_EDITOR::EditTeardrops(SELECTION &selection, const DIALOG_TEARDROPS::TEARDROPS_SETTINGS &settings)
bool TEARDROPS_EDITOR::EditTeardrops(const DIALOG_TEARDROPS::TEARDROPS_SETTINGS &settings)
{
bool retVal = false;
SELECTION selection = GetManager()->GetTool<SELECTION_TOOL>()->GetSelection();
switch (settings.m_type) {
case DIALOG_TEARDROPS::TEARDROPS_TYPE_CURVED:
......@@ -103,9 +114,9 @@ bool TEARDROPS_EDITOR::AddToSelected(SELECTION &selection, const DIALOG_TEARDROP
DrawSegments(teardropStart, *track);
added = true;
}
if (settings.m_clearSelection == true) {
track->ClearSelected();
}
}
if (settings.m_clearSelection == true) {
GetManager()->RunAction(COMMON_ACTIONS::selectionClear, true);
}
if (added == true) {
......
......@@ -5,12 +5,17 @@
#include "tools/selection_tool.h"
#include "dialogs/dialog_teardrops.h"
#include "class_teardrop.h"
#include "import_export.h"
class TEARDROPS_EDITOR
class APIEXPORT TEARDROPS_EDITOR : public TOOL_BASE
{
public:
TEARDROPS_EDITOR(PCB_EDIT_FRAME *frame, KIGFX::VIEW *view);
bool EditTeardrops(SELECTION &selection, const DIALOG_TEARDROPS::TEARDROPS_SETTINGS &settings);
TEARDROPS_EDITOR();
~TEARDROPS_EDITOR();
bool EditTeardrops(const DIALOG_TEARDROPS::TEARDROPS_SETTINGS &settings);
/// @copydoc TOOL_INTERACTIVE::Reset
void Reset(RESET_REASON aReason);
private:
PCB_EDIT_FRAME *m_frame;
......
......@@ -34,6 +34,7 @@
#include <tools/pcb_editor_control.h>
#include <tools/placement_tool.h>
#include <tools/common_actions.h>
#include <tools/edit_teardrops.h>
#include <router/router_tool.h>
#include <router/length_tuner_tool.h>
......@@ -49,4 +50,5 @@ void registerAllTools( TOOL_MANAGER *aToolManager )
aToolManager->RegisterTool( new PCBNEW_CONTROL );
aToolManager->RegisterTool( new PCB_EDITOR_CONTROL );
aToolManager->RegisterTool( new PLACEMENT_TOOL );
}
\ No newline at end of file
aToolManager->RegisterTool( new TEARDROPS_EDITOR );
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment