Skip to content

Commit

Permalink
Fix warnings introduced in new PartDesign
Browse files Browse the repository at this point in the history
Mostly unused wariables and compare of signed & unsigned
  • Loading branch information
Fat-Zer committed Nov 10, 2015
1 parent fa8987c commit c9bdc69
Show file tree
Hide file tree
Showing 25 changed files with 60 additions and 87 deletions.
2 changes: 0 additions & 2 deletions src/Mod/PartDesign/App/Body.cpp
Expand Up @@ -391,8 +391,6 @@ App::DocumentObjectExecReturn *Body::execute(void)
return new App::DocumentObjectExecReturn ( "Linked object is not a PartDesign feature" );
}

App::DocumentObject* link = Tip.getValue();

// get the shape of the tip
tipShape = static_cast<Part::Feature *>(tip)->Shape.getShape();

Expand Down
4 changes: 1 addition & 3 deletions src/Mod/PartDesign/App/FeatureLoft.cpp
Expand Up @@ -74,10 +74,8 @@ short Loft::mustExecute() const
App::DocumentObjectExecReturn *Loft::execute(void)
{

Part::Part2DObject* sketch = 0;
std::vector<TopoDS_Wire> wires;
try {
sketch = getVerifiedSketch();
wires = getSketchWires();
} catch (const Base::Exception& e) {
return new App::DocumentObjectExecReturn(e.what());
Expand Down Expand Up @@ -116,7 +114,7 @@ App::DocumentObjectExecReturn *Loft::execute(void)
return new App::DocumentObjectExecReturn("Loft: All sections need to be part features");

TopExp_Explorer ex;
int i=0;
size_t i=0;
for (ex.Init(static_cast<Part::Feature*>(obj)->Shape.getValue(), TopAbs_WIRE); ex.More(); ex.Next(), ++i) {
if(i>=wiresections.size())
return new App::DocumentObjectExecReturn("Loft: Sections need to have the same amount of inner wires as the base section");
Expand Down
2 changes: 0 additions & 2 deletions src/Mod/PartDesign/App/FeaturePad.cpp
Expand Up @@ -212,8 +212,6 @@ App::DocumentObjectExecReturn *Pad::execute(void)

// set the additive shape property for later usage in e.g. pattern
prism = refineShapeIfActive(prism);
const char* name = AddSubShape.getName();
const char* name1 = this->getPropertyName(&AddSubShape);
this->AddSubShape.setValue(prism);

if (!base.IsNull()) {
Expand Down
4 changes: 1 addition & 3 deletions src/Mod/PartDesign/App/FeaturePipe.cpp
Expand Up @@ -112,10 +112,8 @@ short Pipe::mustExecute() const
App::DocumentObjectExecReturn *Pipe::execute(void)
{

Part::Part2DObject* sketch = 0;
std::vector<TopoDS_Wire> wires;
try {
sketch = getVerifiedSketch();
wires = getSketchWires();
} catch (const Base::Exception& e) {
return new App::DocumentObjectExecReturn(e.what());
Expand Down Expand Up @@ -182,7 +180,7 @@ App::DocumentObjectExecReturn *Pipe::execute(void)
return new App::DocumentObjectExecReturn("All sections need to be part features");

TopExp_Explorer ex;
int i=0;
size_t i=0;
for (ex.Init(static_cast<Part::Feature*>(obj)->Shape.getValue(), TopAbs_WIRE); ex.More(); ex.Next()) {
wiresections[i].push_back(TopoDS::Wire(ex.Current()));
if(i>=wiresections.size())
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/PartDesign/App/ShapeBinder.cpp
Expand Up @@ -83,7 +83,7 @@ void ShapeBinder::getFilterdReferences(App::PropertyLinkSubList* prop, Part::Fea
}

//we only allow one part feature, so get the first one we find
int index = 0;
size_t index = 0;
while(!objs[index]->isDerivedFrom(Part::Feature::getClassTypeId()) && index < objs.size())
index++;

Expand Down
10 changes: 1 addition & 9 deletions src/Mod/PartDesign/Gui/Command.cpp
Expand Up @@ -101,10 +101,7 @@ void UnifiedDatumCommand(Gui::Command &cmd, Base::Type type, std::string name)
cmd.doCommand(Gui::Command::Gui,"Gui.activeDocument().setEdit('%s')",support.getValue()->getNameInDocument());
} else if (pcActiveBody) {

auto pcActivePart = PartDesignGui::getPartFor(pcActiveBody, false);

// TODO Check how this will work outside of a body (2015-10-20, Fat-Zer)
// TODO rewrite this to be shared with CmdPartDesignNewSketch::activated() (2015-10-20, Fat-Zer)
std::string FeatName = cmd.getUniqueObjectName(name.c_str());

std::string tmp = std::string("Create ")+name;
Expand Down Expand Up @@ -281,10 +278,8 @@ void CmdPartDesignShapeBinder::activated(int iMsg)

//test if current selection fits a mode.
if (support.getSize() > 0) {
AttachableObject* pcDatum = static_cast<AttachableObject*>(
getDocument()->getObject(FeatName.c_str()));
doCommand(Gui::Command::Doc,"App.activeDocument().%s.Support = %s",
FeatName.c_str(),support.getPyReprString().c_str());
FeatName.c_str(), support.getPyReprString().c_str());
}
doCommand(Gui::Command::Doc,"App.activeDocument().%s.addFeature(App.activeDocument().%s)",
pcActiveBody->getNameInDocument(), FeatName.c_str());
Expand Down Expand Up @@ -532,7 +527,6 @@ void CmdPartDesignNewSketch::activated(int iMsg)
};

// If there is more than one possibility, show dialog and let user pick plane
bool reversed = false;
if (validPlanes > 1) {

Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
Expand Down Expand Up @@ -1812,11 +1806,9 @@ void CmdPartDesignBoolean::activated(int iMsg)
if (!pcActiveBody) return;

Gui::SelectionFilter BodyFilter("SELECT PartDesign::Body COUNT 1..");
PartDesign::Body* body = nullptr;
std::string bodyString("");

if (BodyFilter.match()) {
body = static_cast<PartDesign::Body*>(BodyFilter.Result[0][0].getObject());
std::vector<App::DocumentObject*> bodies;
std::vector<std::vector<Gui::SelectionObject> >::iterator i = BodyFilter.Result.begin();
for (; i != BodyFilter.Result.end(); i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/PartDesign/Gui/TaskBooleanParameters.cpp
Expand Up @@ -236,7 +236,7 @@ void TaskBooleanParameters::onBodyDeleted(void)
PartDesign::Boolean* pcBoolean = static_cast<PartDesign::Boolean*>(BooleanView->getObject());
std::vector<App::DocumentObject*> bodies = pcBoolean->Bodies.getValues();
int index = ui->listWidgetBodies->currentRow();
if (index > bodies.size())
if (index < 0 && (size_t) index > bodies.size())
return;
App::DocumentObject* body = bodies[index];
bodies.erase(bodies.begin() + ui->listWidgetBodies->currentRow());
Expand Down
44 changes: 19 additions & 25 deletions src/Mod/PartDesign/Gui/TaskDatumParameters.cpp
Expand Up @@ -96,7 +96,7 @@ void TaskDatumParameters::makeRefStrings(std::vector<QString>& refstrings, std::
std::vector<App::DocumentObject*> refs = pcDatum->Support.getValues();
refnames = pcDatum->Support.getSubValues();

for (int r = 0; r < 4; r++) {
for (size_t r = 0; r < 4; r++) {
if ((r < refs.size()) && (refs[r] != NULL)) {
refstrings.push_back(makeRefString(refs[r], refnames[r]));
} else {
Expand Down Expand Up @@ -312,7 +312,8 @@ void TaskDatumParameters::updateUI(std::string message, bool error)
// Get hints for further required references
eSuggestResult msg;
std::set<eRefType> hint;
eMapMode suggMode = pcDatum->attacher().listMapModes(msg,0,&hint);

pcDatum->attacher().listMapModes(msg,0,&hint);

if (msg != srOK) {
if(hint.size() > 0)
Expand Down Expand Up @@ -374,18 +375,15 @@ void TaskDatumParameters::updateUI(std::string message, bool error)
}
}

QLineEdit* TaskDatumParameters::getLine(const int idx)
QLineEdit* TaskDatumParameters::getLine(unsigned idx)
{
if (idx == 0)
return ui->lineRef1;
else if (idx == 1)
return ui->lineRef2;
else if (idx == 2)
return ui->lineRef3;
else if (idx == 3)
return ui->lineRef4;
else
return NULL;
switch(idx) {
case 0: return ui->lineRef1;
case 1: return ui->lineRef2;
case 2: return ui->lineRef3;
case 3: return ui->lineRef4;
default: return NULL;
}
}

void TaskDatumParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
Expand All @@ -408,11 +406,11 @@ void TaskDatumParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
subname = "";

// eliminate duplicate selections
for (int r = 0; r < refs.size(); r++)
for (size_t r = 0; r < refs.size(); r++)
if ((refs[r] == selObj) && (refnames[r] == subname))
return;

if (autoNext && iActiveRef > 0 && iActiveRef == refnames.size()){
if (autoNext && iActiveRef > 0 && iActiveRef == (ssize_t) refnames.size()){
if (refs[iActiveRef-1] == selObj
&& refnames[iActiveRef-1].length() != 0 && subname.length() == 0){
//A whole object was selected by clicking it twice. Fill it
Expand All @@ -422,7 +420,7 @@ void TaskDatumParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
iActiveRef--;
}
}
if (iActiveRef < refs.size()) {
if (iActiveRef < (ssize_t) refs.size()) {
refs[iActiveRef] = selObj;
refnames[iActiveRef] = subname;
} else {
Expand Down Expand Up @@ -521,7 +519,7 @@ void TaskDatumParameters::onCheckFlip(bool on)
pcDatum->getDocument()->recomputeFeature(pcDatum);
}

void TaskDatumParameters::onButtonRef(const bool checked, const int idx)
void TaskDatumParameters::onButtonRef(const bool checked, unsigned idx)
{
autoNext = false;
if (checked) {
Expand Down Expand Up @@ -555,7 +553,7 @@ void TaskDatumParameters::onModeSelect()
pcDatum->MapMode.setValue(getActiveMapMode());
}

void TaskDatumParameters::onRefName(const QString& text, const int idx)
void TaskDatumParameters::onRefName(const QString& text, unsigned idx)
{
QLineEdit* line = getLine(idx);
if (line == NULL) return;
Expand All @@ -568,7 +566,7 @@ void TaskDatumParameters::onRefName(const QString& text, const int idx)
std::vector<std::string> refnames = pcDatum->Support.getSubValues();
std::vector<App::DocumentObject*> newrefs;
std::vector<std::string> newrefnames;
for (int r = 0; r < refs.size(); r++) {
for (size_t r = 0; r < refs.size(); r++) {
if (r != idx) {
newrefs.push_back(refs[r]);
newrefnames.push_back(refnames[r]);
Expand Down Expand Up @@ -601,7 +599,6 @@ void TaskDatumParameters::onRefName(const QString& text, const int idx)
if (obj == NULL) return;

std::string subElement;
PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject<PartDesign::Body*>(PDBODYKEY);

if (obj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) {
// everything is OK (we assume a Part can only have exactly 3 App::Plane objects located at the base of the feature tree)
Expand Down Expand Up @@ -690,7 +687,7 @@ void TaskDatumParameters::updateListOfModes(eMapMode curMode)
ui->listOfModes->clear();
QListWidgetItem* iSelect = 0;
if (modesInList.size()>0) {
for( int i = 0 ; i < modesInList.size() ; i++){
for (size_t i = 0 ; i < modesInList.size() ; ++i){
eMapMode mmode = modesInList[i];
ui->listOfModes->addItem(QString::fromLatin1(AttachEngine::eMapModeStrings[mmode]));
if (mmode == curMode)
Expand Down Expand Up @@ -874,15 +871,14 @@ bool TaskDlgDatumParameters::accept()
std::vector<App::DocumentObject*> copies;

//see if we are able to assign a mode
bool bIgnoreError = false;
if (parameter->getActiveMapMode() == mmDeactivated) {
QMessageBox msg;
msg.setWindowTitle(tr("Incompatible reference set"));
msg.setText(tr("There is no attachment mode that fits the current set"
" of references. If you choose to continue, the feature will remain where"
" it is now, and will not be moved as the references change."
" Continue?"));
auto btYes = msg.addButton(QMessageBox::Yes);
msg.addButton(QMessageBox::Yes);
auto btNo = msg.addButton(QMessageBox::No);
msg.setDefaultButton(btNo);
msg.setIcon(QMessageBox::Warning);
Expand Down Expand Up @@ -971,8 +967,6 @@ bool TaskDlgDatumParameters::reject()
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");

PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject<PartDesign::Body*>(PDBODYKEY);

return true;
}

Expand Down
7 changes: 4 additions & 3 deletions src/Mod/PartDesign/Gui/TaskDatumParameters.h
Expand Up @@ -93,9 +93,9 @@ private Q_SLOTS:
void updateUI(std::string message = std::string(), bool isWarning = false);

void makeRefStrings(std::vector<QString>& refstrings, std::vector<std::string>& refnames);
QLineEdit* getLine(const int idx);
void onButtonRef(const bool checked, const int idx);
void onRefName(const QString& text, const int idx);
QLineEdit* getLine(unsigned idx);
void onButtonRef(const bool checked, unsigned idx);
void onRefName(const QString& text, unsigned idx);

/**
* @brief updateListOfModes Fills the mode list with modes that apply to
Expand All @@ -111,6 +111,7 @@ private Q_SLOTS:
Ui_TaskDatumParameters* ui;
ViewProviderDatum *DatumView;

// TODO fix documentation here (2015-11-10, Fat-Zer)
int iActiveRef; //what reference is being picked in 3d view now? -1 means no one, 0-2 means a reference is being picked.
bool autoNext;//if we should automatically switch to next reference (true after dialog launch, false afterwards)
std::vector<Attacher::eMapMode> modesInList; //this list is synchronous to what is populated into listOfModes widget.
Expand Down
5 changes: 2 additions & 3 deletions src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp
Expand Up @@ -48,12 +48,11 @@ using namespace Gui;
/* TRANSLATOR PartDesignGui::TaskDressUpParameters */

TaskDressUpParameters::TaskDressUpParameters(ViewProviderDressUp *DressUpView, bool selectEdges, bool selectFaces, QWidget *parent)
: allowFaces(selectFaces), allowEdges(selectEdges),
TaskBox(Gui::BitmapFactory().pixmap((std::string("PartDesign_") + DressUpView->featureName()).c_str()),
: TaskBox(Gui::BitmapFactory().pixmap((std::string("PartDesign_") + DressUpView->featureName()).c_str()),
QString::fromAscii((DressUpView->featureName() + " parameters").c_str()),
true,
parent),
DressUpView(DressUpView)
DressUpView(DressUpView), allowFaces(selectFaces), allowEdges(selectEdges)
{
selectionMode = none;
}
Expand Down
1 change: 0 additions & 1 deletion src/Mod/PartDesign/Gui/TaskFeaturePick.cpp
Expand Up @@ -119,7 +119,6 @@ TaskFeaturePick::TaskFeaturePick(std::vector<App::DocumentObject*>& objects,
// Setup the origin's temporary visability
for ( const auto & originPair: originVisStatus ) {
const auto &origin = originPair.first;
const auto &status = originPair.second;

Gui::ViewProviderOrigin* vpo = static_cast<Gui::ViewProviderOrigin*> (
Gui::Application::Instance->getViewProvider ( origin ) );
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/PartDesign/Gui/TaskPrimitiveParameters.cpp
Expand Up @@ -48,7 +48,7 @@
using namespace PartDesignGui;

TaskBoxPrimitives::TaskBoxPrimitives(ViewProviderPrimitive* vp, QWidget* parent)
: vp(vp), TaskBox(QPixmap(),tr("Primitive parameters"), true, parent)
: TaskBox(QPixmap(),tr("Primitive parameters"), true, parent), vp(vp)
{
proxy = new QWidget(this);
ui.setupUi(proxy);
Expand Down Expand Up @@ -697,4 +697,4 @@ QDialogButtonBox::StandardButtons TaskPrimitiveParameters::getStandardButtons(vo
}


#include "moc_TaskPrimitiveParameters.cpp"
#include "moc_TaskPrimitiveParameters.cpp"
6 changes: 3 additions & 3 deletions src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp
Expand Up @@ -155,7 +155,7 @@ void TaskRevolutionParameters::fillAxisCombo(bool forceRefill)
if (forceRefill){
ui->axis->clear();

for(int i = 0 ; i < axesInList.size() ; i++ ){
for(size_t i = 0 ; i < axesInList.size() ; i++ ){
delete axesInList[i];
}
this->axesInList.clear();
Expand Down Expand Up @@ -198,7 +198,7 @@ void TaskRevolutionParameters::fillAxisCombo(bool forceRefill)
int indexOfCurrent = -1;
App::DocumentObject* ax = propReferenceAxis->getValue();
const std::vector<std::string> &subList = propReferenceAxis->getSubValues();
for(int i = 0 ; i < axesInList.size() ; i++) {
for(size_t i = 0 ; i < axesInList.size() ; i++) {
if(ax == axesInList[i]->getValue() && subList == axesInList[i]->getSubValues())
indexOfCurrent = i;
}
Expand Down Expand Up @@ -373,7 +373,7 @@ TaskRevolutionParameters::~TaskRevolutionParameters()

delete ui;

for(int i = 0 ; i < axesInList.size() ; i++ ){
for(size_t i = 0 ; i < axesInList.size() ; i++ ){
delete axesInList[i];
}
}
Expand Down
1 change: 0 additions & 1 deletion src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp
Expand Up @@ -96,7 +96,6 @@ void TaskSketchBasedParameters::onSelectReference(const bool pressed, const bool
// Note: Even if there is no solid, App::Plane and Part::Datum can still be selected

PartDesign::SketchBased* pcSketchBased = static_cast<PartDesign::SketchBased*>(vp->getObject());
PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject<PartDesign::Body*>(PDBODYKEY);

// The solid this feature will be fused to
App::DocumentObject* prevSolid = pcSketchBased->getBaseObject( /* silent =*/ true );
Expand Down
6 changes: 3 additions & 3 deletions src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp
Expand Up @@ -422,7 +422,7 @@ int ComboLinks::addLink(App::DocumentObject *linkObj, std::string linkSubname, Q

void ComboLinks::clear()
{
for(int i = 0 ; i < this->linksInList.size() ; i++){
for(size_t i = 0 ; i < this->linksInList.size() ; i++){
delete linksInList[i];
}
if(this->_combo)
Expand All @@ -431,7 +431,7 @@ void ComboLinks::clear()

App::PropertyLinkSub &ComboLinks::getLink(int index) const
{
if (index < 0 || index > linksInList.size()-1)
if (index < 0 || index > (ssize_t) linksInList.size()-1)
throw Base::Exception("ComboLinks::getLink:Index out of range");
if (linksInList[index]->getValue() && doc && !(doc->isIn(linksInList[index]->getValue())))
throw Base::Exception("Linked object is not in the document; it may have been deleted");
Expand All @@ -446,7 +446,7 @@ App::PropertyLinkSub &ComboLinks::getCurrentLink() const

int ComboLinks::setCurrentLink(const App::PropertyLinkSub &lnk)
{
for(int i = 0 ; i < linksInList.size() ; i++) {
for(size_t i = 0 ; i < linksInList.size() ; i++) {
App::PropertyLinkSub &it = *(linksInList[i]);
if(lnk.getValue() == it.getValue() && lnk.getSubValues() == it.getSubValues()){
bool wasBlocked = _combo->signalsBlocked();
Expand Down
1 change: 0 additions & 1 deletion src/Mod/PartDesign/Gui/ViewProviderAddSub.cpp
Expand Up @@ -126,7 +126,6 @@ void ViewProviderAddSub::updateAddSubShapeIndicator() {
bounds.Get(xMin, yMin, zMin, xMax, yMax, zMax);
Standard_Real deflection = ((xMax-xMin)+(yMax-yMin)+(zMax-zMin))/300.0 *
Deviation.getValue();
Standard_Real AngDeflectionRads = AngularDeflection.getValue() / 180.0 * M_PI;

// create or use the mesh on the data structure
#if OCC_VERSION_HEX >= 0x060600
Expand Down
2 changes: 0 additions & 2 deletions src/Mod/PartDesign/Gui/ViewProviderBody.cpp
Expand Up @@ -186,8 +186,6 @@ std::vector<App::DocumentObject*> ViewProviderBody::claimChildren3D(void)const
PartDesign::Body* body = static_cast<PartDesign::Body*>(getObject());

const std::vector<App::DocumentObject*> & features = body->Model.getValues();
App::DocumentObject *originObj = body->Origin.getValue();
App::DocumentObject *baseFeature = body->BaseFeature.getValue();

std::vector<App::DocumentObject*> rv;

Expand Down

0 comments on commit c9bdc69

Please sign in to comment.