Picking elements and faces in TaskCreateNodeSet
This commit is contained in:
parent
a3d68a1d34
commit
1bb9e53326
|
@ -60,6 +60,8 @@ SET(FemGui_SRCS_ViewProvider
|
|||
ViewProviderSetFaces.h
|
||||
ViewProviderSetGeometry.cpp
|
||||
ViewProviderSetGeometry.h
|
||||
FemSelectionGate.cpp
|
||||
FemSelectionGate.h
|
||||
)
|
||||
SOURCE_GROUP("ViewProvider" FILES ${FemGui_SRCS_ViewProvider})
|
||||
|
||||
|
|
52
src/Mod/Fem/Gui/FemSelectionGate.cpp
Normal file
52
src/Mod/Fem/Gui/FemSelectionGate.cpp
Normal file
|
@ -0,0 +1,52 @@
|
|||
/******************************************************************************
|
||||
* Copyright (c) 2013 Jürgen Riegel (FreeCAD@juergen-riegel.net) *
|
||||
* *
|
||||
* 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_
|
||||
#endif
|
||||
|
||||
#include "FemSelectionGate.h"
|
||||
|
||||
using namespace FemGui;
|
||||
using namespace Gui;
|
||||
|
||||
bool FemSelectionGate::allow(App::Document* pDoc, App::DocumentObject* pObj, const char* sSubName)
|
||||
{
|
||||
if (!sSubName || sSubName[0] == '\0')
|
||||
return false;
|
||||
|
||||
if( sSubName[0] == 'E' &&
|
||||
sSubName[1] == 'l' &&
|
||||
sSubName[2] == 'e' &&
|
||||
sSubName[3] == 'm' &&
|
||||
(Type == Element || Type == NodeElement) )
|
||||
return true;
|
||||
if( sSubName[0] == 'N' &&
|
||||
sSubName[1] == 'o' &&
|
||||
sSubName[2] == 'd' &&
|
||||
sSubName[3] == 'e' &&
|
||||
(Type == Node || Type == NodeElement) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
53
src/Mod/Fem/Gui/FemSelectionGate.h
Normal file
53
src/Mod/Fem/Gui/FemSelectionGate.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
/******************************************************************************
|
||||
* Copyright (c) 2013 Jürgen Riegel (FreeCAD@juergen-riegel.net) *
|
||||
* 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 *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef GUI_FemSelectionGate_H
|
||||
#define GUI_FemSelectionGate_H
|
||||
|
||||
#include <Gui/SelectionFilter.h>
|
||||
|
||||
namespace FemGui {
|
||||
|
||||
class FemSelectionGate : public Gui::SelectionFilterGate
|
||||
{
|
||||
public:
|
||||
enum ElemType {
|
||||
Nothing ,
|
||||
Node ,
|
||||
Element ,
|
||||
NodeElement
|
||||
};
|
||||
|
||||
FemSelectionGate(ElemType type)
|
||||
: Gui::SelectionFilterGate((Gui::SelectionFilter*)0),Type(type)
|
||||
{
|
||||
};
|
||||
|
||||
ElemType Type;
|
||||
|
||||
/// get called by the frame-work
|
||||
bool allow(App::Document* pDoc, App::DocumentObject* pObj, const char* sSubName);
|
||||
};
|
||||
|
||||
} //namespace FemGui
|
||||
|
||||
#endif // GUI_FemSelectionGate_H
|
|
@ -51,11 +51,13 @@
|
|||
#include <Mod/Fem/App/FemMeshObject.h>
|
||||
#include <Mod/Fem/App/FemSetNodesObject.h>
|
||||
#include "ViewProviderFemMesh.h"
|
||||
#include "FemSelectionGate.h"
|
||||
|
||||
|
||||
using namespace FemGui;
|
||||
using namespace Gui;
|
||||
|
||||
|
||||
TaskCreateNodeSet::TaskCreateNodeSet(Fem::FemSetNodesObject *pcObject,QWidget *parent)
|
||||
: TaskBox(Gui::BitmapFactory().pixmap("Fem_FemMesh_createnodebypoly"),
|
||||
tr("Nodes set"),
|
||||
|
@ -72,6 +74,7 @@ TaskCreateNodeSet::TaskCreateNodeSet(Fem::FemSetNodesObject *pcObject,QWidget *p
|
|||
this->groupLayout()->addWidget(proxy);
|
||||
|
||||
QObject::connect(ui->toolButton_Poly,SIGNAL(clicked()),this,SLOT(Poly()));
|
||||
QObject::connect(ui->toolButton_Pick,SIGNAL(clicked()),this,SLOT(Pick()));
|
||||
QObject::connect(ui->comboBox,SIGNAL(activated (int)),this,SLOT(SwitchMethod(int)));
|
||||
|
||||
MeshViewProvider = dynamic_cast<ViewProviderFemMesh*>(Gui::Application::Instance->getViewProvider( pcObject->FemMesh.getValue<Fem::FemMeshObject*>()));
|
||||
|
@ -97,12 +100,26 @@ void TaskCreateNodeSet::Poly(void)
|
|||
}
|
||||
}
|
||||
|
||||
void TaskCreateNodeSet::Pick(void)
|
||||
{
|
||||
if (selectionMode == none){
|
||||
selectionMode = PickElement;
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Selection().addSelectionGate(new FemSelectionGate(FemSelectionGate::Element));
|
||||
}
|
||||
}
|
||||
|
||||
void TaskCreateNodeSet::SwitchMethod(int Value)
|
||||
{
|
||||
if(Value == 1)
|
||||
if(Value == 1){
|
||||
ui->groupBox_AngleSearch->setEnabled(true);
|
||||
else
|
||||
ui->toolButton_Pick->setEnabled(true);
|
||||
ui->toolButton_Poly->setEnabled(false);
|
||||
}else{
|
||||
ui->groupBox_AngleSearch->setEnabled(false);
|
||||
ui->toolButton_Pick->setEnabled(false);
|
||||
ui->toolButton_Poly->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -161,6 +178,26 @@ void TaskCreateNodeSet::DefineNodes(const Base::Polygon2D &polygon,const Gui::Vi
|
|||
|
||||
}
|
||||
|
||||
void TaskCreateNodeSet::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
{
|
||||
if (selectionMode == none)
|
||||
return;
|
||||
|
||||
if (msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
std::string subName(msg.pSubName);
|
||||
unsigned int i=0;
|
||||
for(;i<subName.size();i++)
|
||||
if(msg.pSubName[i]=='F')
|
||||
break;
|
||||
|
||||
int elem = atoi(subName.substr(4).c_str());
|
||||
int face = atoi(subName.substr(i+1).c_str() );
|
||||
|
||||
Base::Console().Message("Picked Element:%i Face:%i\n",elem,face);
|
||||
selectionMode = none;
|
||||
Gui::Selection().rmvSelectionGate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TaskCreateNodeSet::~TaskCreateNodeSet()
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace FemGui {
|
|||
class ViewProviderFemMesh;
|
||||
|
||||
|
||||
class TaskCreateNodeSet : public Gui::TaskView::TaskBox
|
||||
class TaskCreateNodeSet : public Gui::TaskView::TaskBox, public Gui::SelectionObserver
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -63,6 +63,7 @@ public:
|
|||
|
||||
private Q_SLOTS:
|
||||
void Poly(void);
|
||||
void Pick(void);
|
||||
void SwitchMethod(int Value);
|
||||
|
||||
protected:
|
||||
|
@ -70,6 +71,9 @@ protected:
|
|||
static void DefineNodesCallback(void * ud, SoEventCallback * n);
|
||||
void DefineNodes(const Base::Polygon2D &polygon,const Gui::ViewVolumeProjection &proj,bool);
|
||||
|
||||
protected:
|
||||
virtual void onSelectionChanged(const Gui::SelectionChanges& msg);
|
||||
enum selectionModes { none, PickElement} selectionMode;
|
||||
|
||||
private:
|
||||
QWidget* proxy;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>177</width>
|
||||
<width>179</width>
|
||||
<height>180</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
|
Loading…
Reference in New Issue
Block a user