<commit_before>/***************************************************************************
 *   Copyright (c) 2011 <NAME> <<EMAIL>>        *
 *                                                                         *
 *   This file is part of the FreeCAD CAx development system.              *
 *                                                                         *
 *   This library is free software; you can redistribute it and/or         *
 *   modify it under the terms of the GNU Library General Public           *
 *   License as published by the Free Software Foundation; either          *
 *   version 2 of the License, or (at your option) any later version.      *
 *                                                                         *
 *   This library  is distributed in the hope that it will be useful,      *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU Library General Public License for more details.                  *
 *                                                                         *
 *   You should have received a copy of the GNU Library General Public     *
 *   License along with this library; see the file COPYING.LIB. If not,    *
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
 *   Suite 330, Boston, MA  02111-1307, USA                                *
 *                                                                         *
 ***************************************************************************/


#include "PreCompiled.h"

#ifndef _PreComp_
# include <QMessageBox>
#endif

#include "ui_TaskPadParameters.h"
#include "TaskPadParameters.h"
#include <App/Application.h>
#include <App/Document.h>
#include <Gui/Application.h>
#include <Gui/Document.h>
#include <Gui/BitmapFactory.h>
#include <Gui/ViewProvider.h>
#include <Gui/WaitCursor.h>
#include <Base/Console.h>
#include <Gui/Selection.h>
#include <Gui/Command.h>
#include <Mod/PartDesign/App/FeaturePad.h>
#include <Mod/Sketcher/App/SketchObject.h>


using namespace PartDesignGui;
using namespace Gui;

/* TRANSLATOR PartDesignGui::TaskPadParameters */

TaskPadParameters::TaskPadParameters(ViewProviderPad *PadView,QWidget *parent)
    : TaskBox(Gui::BitmapFactory().pixmap("PartDesign_Pad"),tr("Pad parameters"),true, parent),PadView(PadView)
{
    // we need a separate container widget to add all controls to
    proxy = new QWidget(this);
    ui = new Ui_TaskPadParameters();
    ui->setupUi(proxy);
    QMetaObject::connectSlotsByName(this);

    connect(ui->doubleSpinBox, SIGNAL(valueChanged(double)),
            this, SLOT(onLengthChanged(double)));
    connect(ui->checkBoxMirrored, SIGNAL(toggled(bool)),
            this, SLOT(onMirrored(bool)));
    connect(ui->checkBoxReversed, SIGNAL(toggled(bool)),
            this, SLOT(onReversed(bool)));

    this->groupLayout()->addWidget(proxy);

    PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
    double l = pcPad->Length.getValue();
    bool mirrored = pcPad->MirroredExtent.getValue();
    bool reversed = pcPad->Reversed.getValue();

    ui->doubleSpinBox->setValue(l);
    ui->doubleSpinBox->selectAll();
    ui->checkBoxMirrored->setChecked(mirrored);

    // check if the sketch has support
    Sketcher::SketchObject *pcSketch;
    if (pcPad->Sketch.getValue()) {
        pcSketch = static_cast<Sketcher::SketchObject*>(pcPad->Sketch.getValue());
        if (pcSketch->Support.getValue())
            // in case of sketch with support, reverse makes no sense (goes into the part)
            ui->checkBoxReversed->setEnabled(0);
        else
            ui->checkBoxReversed->setChecked(reversed);
    }

    ui->checkBoxReversed->setChecked(reversed);

    setFocus ();
}

void TaskPadParameters::onLengthChanged(double len)
{
    PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
    pcPad->Length.setValue((float)len);
    pcPad->getDocument()->recomputeFeature(pcPad);
}
<commit_msg>0000506: Modifying focus when creating pad.<commit_after>/***************************************************************************
 *   Copyright (c) 2011 <NAME> <<EMAIL>>        *
 *                                                                         *
 *   This file is part of the FreeCAD CAx development system.              *
 *                                                                         *
 *   This library is free software; you can redistribute it and/or         *
 *   modify it under the terms of the GNU Library General Public           *
 *   License as published by the Free Software Foundation; either          *
 *   version 2 of the License, or (at your option) any later version.      *
 *                                                                         *
 *   This library  is distributed in the hope that it will be useful,      *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU Library General Public License for more details.                  *
 *                                                                         *
 *   You should have received a copy of the GNU Library General Public     *
 *   License along with this library; see the file COPYING.LIB. If not,    *
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
 *   Suite 330, Boston, MA  02111-1307, USA                                *
 *                                                                         *
 ***************************************************************************/


#include "PreCompiled.h"

#ifndef _PreComp_
# include <QMessageBox>
#endif

#include "ui_TaskPadParameters.h"
#include "TaskPadParameters.h"
#include <App/Application.h>
#include <App/Document.h>
#include <Gui/Application.h>
#include <Gui/Document.h>
#include <Gui/BitmapFactory.h>
#include <Gui/ViewProvider.h>
#include <Gui/WaitCursor.h>
#include <Base/Console.h>
#include <Gui/Selection.h>
#include <Gui/Command.h>
#include <Mod/PartDesign/App/FeaturePad.h>
#include <Mod/Sketcher/App/SketchObject.h>


using namespace PartDesignGui;
using namespace Gui;

/* TRANSLATOR PartDesignGui::TaskPadParameters */

TaskPadParameters::TaskPadParameters(ViewProviderPad *PadView,QWidget *parent)
    : TaskBox(Gui::BitmapFactory().pixmap("PartDesign_Pad"),tr("Pad parameters"),true, parent),PadView(PadView)
{
    // we need a separate container widget to add all controls to
    proxy = new QWidget(this);
    ui = new Ui_TaskPadParameters();
    ui->setupUi(proxy);
    QMetaObject::connectSlotsByName(this);

    connect(ui->doubleSpinBox, SIGNAL(valueChanged(double)),
            this, SLOT(onLengthChanged(double)));
    connect(ui->checkBoxMirrored, SIGNAL(toggled(bool)),
            this, SLOT(onMirrored(bool)));
    connect(ui->checkBoxReversed, SIGNAL(toggled(bool)),
            this, SLOT(onReversed(bool)));

    this->groupLayout()->addWidget(proxy);

    PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
    double l = pcPad->Length.getValue();
    bool mirrored = pcPad->MirroredExtent.getValue();
    bool reversed = pcPad->Reversed.getValue();

    ui->doubleSpinBox->setValue(l);
    ui->doubleSpinBox->selectAll();
    ui->checkBoxMirrored->setChecked(mirrored);

    // check if the sketch has support
    Sketcher::SketchObject *pcSketch;
    if (pcPad->Sketch.getValue()) {
        pcSketch = static_cast<Sketcher::SketchObject*>(pcPad->Sketch.getValue());
        if (pcSketch->Support.getValue())
            // in case of sketch with support, reverse makes no sense (goes into the part)
            ui->checkBoxReversed->setEnabled(0);
        else
            ui->checkBoxReversed->setChecked(reversed);
    }

    ui->checkBoxReversed->setChecked(reversed);
    // Make sure that the spin box has the focus to get key events
    // Calling setFocus() directly doesn't work because the spin box is not
    // yet visible. 
    QMetaObject::invokeMethod(ui->doubleSpinBox, "setFocus", Qt::QueuedConnection);
}

void TaskPadParameters::onLengthChanged(double len)
{
    PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
    pcPad->Length.setValue((float)len);
    pcPad->getDocument()->recomputeFeature(pcPad);
}

{'fraction_non_alphanumeric': 0.14133016627078385, 'fraction_numerical': 0.005581947743467933, 'mean_word_length': 2.47544366487825, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 100, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 32, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2969767', 'n_tokens_mistral': 2286, 'n_tokens_neox': 2174, 'n_words': 579}