viewer.cpp 29 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1
/*******************************************************************************
pitiot's avatar
init  
pitiot committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg           *
*                                                                              *
* This library is free software; you can redistribute it and/or modify it      *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 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 Lesser General Public License  *
* for more details.                                                            *
*                                                                              *
* You should have received a copy of the GNU Lesser General Public License     *
* along with this library; if not, write to the Free Software Foundation,      *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.           *
*                                                                              *
* Web site: http://cgogn.unistra.fr/                                           *
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/
Pierre Kraemer's avatar
Pierre Kraemer committed
24 25

#include "viewer.h"
pitiot's avatar
stats  
pitiot committed
26

pitiot's avatar
pitiot committed
27 28 29 30 31
void Volusion::dart_onoff(bool x)
{
    draw_dart = x;
    updateGL();
}
Pierre Kraemer's avatar
Pierre Kraemer committed
32

pitiot's avatar
pitiot committed
33 34 35 36 37
void Volusion::slot_slide(int i)
    {
        dartSlider = i;
        updateGL();
    }
Pierre Kraemer's avatar
Pierre Kraemer committed
38

pitiot's avatar
init  
pitiot committed
39
void Volusion::volumes_onoff(bool x)
Pierre Kraemer's avatar
Pierre Kraemer committed
40
{
pitiot's avatar
init  
pitiot committed
41 42
	render_volumes = x;
	updateGL();
Pierre Kraemer's avatar
Pierre Kraemer committed
43
}
Pierre Kraemer's avatar
Pierre Kraemer committed
44

pitiot's avatar
init  
pitiot committed
45
void Volusion::edges_onoff(bool x)
Pierre Kraemer's avatar
Pierre Kraemer committed
46
{
pitiot's avatar
init  
pitiot committed
47 48
	render_edges = x;
	updateGL();
Thomas Jund's avatar
Thomas Jund committed
49 50
}

pitiot's avatar
pitiot committed
51
void Volusion::MovingObject_onoff(bool x)
pitiot's avatar
pitiot committed
52
{
pitiot's avatar
pitiot committed
53
    render_MovingObject = x;
pitiot's avatar
pitiot committed
54 55 56 57 58 59 60 61 62 63 64 65 66
    updateGL();
}

void Volusion::belonging_onoff(bool x)
{
    render_belonging = x;
    updateGL();
}
void Volusion::neighbors_onoff(bool x)
{
    render_neighbors= x;
    updateGL();
}
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82

void Volusion::obj_onoff(bool x)
{
    display_obj= x;
    updateGL();
}
void Volusion::objBelong_onoff(bool x)
{
    obj_belong= x;
    updateGL();
}
void Volusion::objNeighbors_onoff(bool x)
{
    obj_neighbors= x;
    updateGL();
}
pitiot's avatar
pitiot committed
83 84 85 86 87 88 89
void Volusion::comboEdge(int x)
{
    val_comboEdge = x;
    if(x!=0)  CGoGNout<< "affichage uniquement pour l'arete"<<val_comboEdge<<CGoGNendl;
    updateGL();
}

pitiot's avatar
init  
pitiot committed
90
void Volusion::topo_onoff(bool x)
Thomas Jund's avatar
Thomas Jund committed
91
{
pitiot's avatar
init  
pitiot committed
92 93
	render_topo = x;
	if (render_topo)
Thomas Jund's avatar
Thomas Jund committed
94
	{
pitiot's avatar
pitiot committed
95
//		SelectorDartNoBoundary<MAP> nb(simul.envMap_.map);
pitiot's avatar
init  
pitiot committed
96
		//TODO MapBrowser
pitiot's avatar
pitiot committed
97
        m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position, 0.8f, m_explode_factorf-0.05f, m_explode_factor);
Thomas Jund's avatar
Thomas Jund committed
98 99
	}

pitiot's avatar
init  
pitiot committed
100 101
	updateGL();
}
Thomas Jund's avatar
Thomas Jund committed
102

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
103 104
//void Volusion::clipping_onoff(bool x)
//{
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
//	clip_volume = x;

//	if (clip_volume)
//	{
//		Geom::Vec3f pos = m_PlanePick->getPosition();
//		float pipo;
//		Geom::Vec3f normal = m_PlanePick->getAxisScale(2, pipo); // 2 = Z axis = plane normal
//		float d = -(pos*normal);
//		m_explode_render->setClippingPlane(Geom::Vec4f(normal[0],normal[1],normal[2],d));
//		m_sh1->setClipPlaneParamsAll(clip_id1, normal, pos);
//		m_sh2->setClipPlaneParamsAll(clip_id2, normal, pos);
//	}
//	else
//	{
//		m_explode_render->setNoClippingPlane();
//		m_sh1->setClipPlaneParamsAll(clip_id1, Geom::Vec3f(0,0,1), Geom::Vec3f(0,0,999999.9f));
//		m_sh2->setClipPlaneParamsAll(clip_id2, Geom::Vec3f(0,0,1), Geom::Vec3f(0,0,999999.9f));
//		m_sh1->setClipColorAttenuationFactorRelative(0.0f,0.0f);
//		m_sh2->setClipColorAttenuationFactorRelative(0.0f,0.0f);
//	}
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
125 126
//	updateGL();
//}
Thomas Jund's avatar
Thomas Jund committed
127

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
128 129
//void Volusion::hide_onoff(bool x)
//{
130
//	hide_clipping = x;
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
131 132
//	updateGL();
//}
Thomas Jund's avatar
Thomas Jund committed
133

pitiot's avatar
init  
pitiot committed
134
void Volusion::slider_explode(int x)
Thomas Jund's avatar
Thomas Jund committed
135
{
pitiot's avatar
init  
pitiot committed
136 137 138
	m_explode_factor = 0.01f*(x+1)-0.0001f;
	m_explode_render->setExplodeVolumes(m_explode_factor);
	updateGL();
Thomas Jund's avatar
Thomas Jund committed
139 140
}

pitiot's avatar
init  
pitiot committed
141
void Volusion::slider_explodeF(int x)
Thomas Jund's avatar
Thomas Jund committed
142
{
pitiot's avatar
init  
pitiot committed
143 144 145
	m_explode_factorf = 0.01f*(x+1);
	m_explode_render->setExplodeFaces(m_explode_factorf);
	updateGL();
Thomas Jund's avatar
Thomas Jund committed
146 147
}

pitiot's avatar
init  
pitiot committed
148
void Volusion::slider_pressed()
Thomas Jund's avatar
Thomas Jund committed
149
{
pitiot's avatar
init  
pitiot committed
150 151 152 153
	render_topoTemp = render_topo;
	render_topo = false;
	updateGL();
}
pitiot's avatar
merge  
pitiot committed
154

pitiot's avatar
init  
pitiot committed
155 156 157 158
void Volusion::slider_released()
{
	render_topo = render_topoTemp;
	if (render_topo)
Thomas Jund's avatar
Thomas Jund committed
159
	{
pitiot's avatar
init  
pitiot committed
160 161
//		SelectorDartNoBoundary<MAP> nb(simul.envMap.map);
		//TODO MapBrowser
pitiot's avatar
pitiot committed
162
        m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position, 0.8f, m_explode_factorf-0.05f, m_explode_factor );
Thomas Jund's avatar
Thomas Jund committed
163
	}
pitiot's avatar
init  
pitiot committed
164
	updateGL();
Pierre Kraemer's avatar
Pierre Kraemer committed
165
}
Pierre Kraemer's avatar
Pierre Kraemer committed
166

pitiot's avatar
up  
pitiot committed
167 168 169 170 171 172
void Volusion::cb_keyPress(int code)
{
    switch(code)
    {
    case 'r' :
    {
Thomas Pitiot 's avatar
Thomas Pitiot committed
173 174 175 176 177 178 179 180 181
#ifndef IHMap
//        simul.envMap_.popSegment(simul.objects[0]->Segments_[0]);

//        simul.envMap_.resetPartSubdiv(simul.objects[0]->Segments_[0]);

//        simul.envMap_.FirstRegistrationSegment(simul.objects[0]->Segments_[0]);

#else

pitiot's avatar
up  
pitiot committed
182 183 184 185
        simul.aiguille->refine();
        m_MovingObjectVBO->updateData(simul.envMap_.position);

        updateGL() ;
Thomas Pitiot 's avatar
Thomas Pitiot committed
186
#endif
pitiot's avatar
up  
pitiot committed
187 188 189 190 191 192 193 194

        break;
    }


    }
}

pitiot's avatar
init  
pitiot committed
195
void Volusion::cb_Open()
Thomas Jund's avatar
Thomas Jund committed
196
{
pitiot's avatar
init  
pitiot committed
197 198 199 200
	std::string filters("all (*.*)") ;
	std::string filename = selectFile("Open Mesh", "", filters) ;
	if (filename.empty())
		return ;
pitiot's avatar
pitiot committed
201
    else simul.envMap_.open_file(filename);
Thomas Jund's avatar
Thomas Jund committed
202 203


pitiot's avatar
pitiot committed
204 205 206
//	SelectorDartNoBoundary<MAP> nb(simul.envMap_.map);
    m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position,  0.8f, 0.8f, 0.8f);
    m_explode_render->updateData<PFP>(simul.envMap_.map, simul.envMap_.position, simul.envMap_.color);
Thomas Jund's avatar
Thomas Jund committed
207

pitiot's avatar
init  
pitiot committed
208
	updateGL() ;
Thomas Jund's avatar
Thomas Jund committed
209 210
}

pitiot's avatar
pitiot committed
211

pitiot's avatar
pitiot committed
212

pitiot's avatar
init  
pitiot committed
213 214
void Volusion::cb_initGL()
{
pitiot's avatar
pitiot committed
215 216


pitiot's avatar
init  
pitiot committed
217 218
	// choose to use GL version 2
	Utils::GLSLShader::setCurrentOGLVersion(2);
pitiot's avatar
pitiot committed
219
    m_ds = new Utils::Drawer();
pitiot's avatar
init  
pitiot committed
220 221 222
	// create the renders
	m_topo_render = new Algo::Render::GL2::Topo3RenderMap<PFP>();
    m_explode_render = new Algo::Render::GL2::ExplodeVolumeRender(true,true,true);
pitiot's avatar
pitiot committed
223

Thomas Pitiot 's avatar
Thomas Pitiot committed
224

pitiot's avatar
pitiot committed
225 226 227
//	SelectorDartNoBoundary<MAP> nb(simul.envMap_.map);
    m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position,  0.8f, 0.8f, 0.8f);
    m_explode_render->updateData<PFP>(simul.envMap_.map, simul.envMap_.position, simul.envMap_.color);
pitiot's avatar
init  
pitiot committed
228 229 230 231 232
	m_explode_render->setExplodeVolumes(1.0f);
	m_explode_render->setExplodeFaces(1.0f);
	m_explode_render->setAmbiant(Geom::Vec4f(0.2f,0.2f,0.2f,1.0f));
	m_explode_render->setBackColor(Geom::Vec4f(0.9f,0.9f,0.9f,1.0f));
	m_explode_render->setColorLine(Geom::Vec4f(0.8f,0.2f,0.2f,1.0f));
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
233
    m_explode_render->setNoClippingPlane();
234 235
//	m_sh1 = static_cast<Utils::ClippingShader*>(m_topo_render->shader1());
//	m_sh2 = static_cast<Utils::ClippingShader*>(m_topo_render->shader2());
Thomas Jund's avatar
Thomas Jund committed
236

pitiot's avatar
init  
pitiot committed
237 238
	registerShader(m_explode_render->shaderFaces());
	registerShader(m_explode_render->shaderLines());
pitiot's avatar
pitiot committed
239

240 241 242
//    m_PlanePick = new Utils::Pickable(Utils::Pickable::GRID,1);
//    m_frame = new Utils::FrameManipulator();
//    m_frame->setSize(m_WidthObj/2.0f);
Thomas Jund's avatar
Thomas Jund committed
243

244

245 246
//	m_sh1->insertClippingCode();
//	m_sh2->insertClippingCode();
pitiot's avatar
merging  
pitiot committed
247

248 249
//	clip_id1 = m_sh1->addClipPlane();
//	clip_id2 = m_sh2->addClipPlane();
pitiot's avatar
pitiot committed
250

251 252
//	m_sh1->setClipPlaneParamsAll(clip_id1, Geom::Vec3f(0,0,1), m_PosObj);
//	m_sh2->setClipPlaneParamsAll(clip_id2, Geom::Vec3f(0,0,1), m_PosObj);
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
253
//    m_explode_render->setClippingPlane(Geom::Vec4f(0,0,1,m_PosObj*Geom::Vec3f(0,0,-1)));
pitiot's avatar
pitiot committed
254

255 256 257 258
//    m_closestVBO = new Utils::VBO();
//    m_closestVBO->setDataSize(3);
//    m_closestVBO->allocate(10000);
//    PFP::VEC3* data = static_cast<PFP::VEC3*>(m_closestVBO->lockPtr());
259

260
//    int j =0;
pitiot's avatar
pitiot committed
261 262 263
    for(Surface * surf : simul.surfaces)
    {
        surf->initGL();
Thomas Pitiot 's avatar
Thomas Pitiot committed
264
        registerShader(surf->m_shader);
Thomas Pitiot 's avatar
Thomas Pitiot committed
265
        registerShader(surf->m_simpleColorShader);
266 267 268 269 270 271
//        for(Triangle * t : surf->triangles_)
//        {
//            data[j]=t->closest_point;
//            data[j+1]=t->p1;
//            j=j+2;
//        }
Thomas Pitiot 's avatar
Thomas Pitiot committed
272

pitiot's avatar
pitiot committed
273 274
    }

275
//    m_closestVBO->releasePtr();
276

277 278 279 280 281
//    m_spriteClosest = new Utils::PointSprite();
//    m_spriteClosest->setAttributePosition(m_closestVBO);
//    m_spriteClosest->setSize(simul.aiguille->width);
//    m_spriteClosest->setColor(Geom::Vec4f(0.0f,1.0f,0.5f,1.0f));
//    registerShader(m_spriteClosest);
282

pitiot's avatar
pitiot committed
283

pitiot's avatar
pitiot committed
284 285
    m_MovingObjectVBO = new Utils::VBO();
    m_MovingObjectVBO->setDataSize(3);
pitiot's avatar
up  
pitiot committed
286
    m_MovingObjectVBO->allocate(10000);
pitiot's avatar
pitiot committed
287 288 289

    //initialisation aiguille

290
   PFP::VEC3* data = static_cast<PFP::VEC3*>(m_MovingObjectVBO->lockPtr());
291

pitiot's avatar
pitiot committed
292 293 294 295 296
    for (unsigned int i=0; i< simul.aiguille->nbVertices; ++i)
    {
        VEC3 p = simul.aiguille->parts_[i]->getPosition();
        data[i] = p;
    }
Thomas Pitiot 's avatar
Thomas Pitiot committed
297
//    data[simul.aiguille->nbVertices]=simul.aiguille->closest_point;
298

pitiot's avatar
pitiot committed
299
    m_MovingObjectVBO->releasePtr();
pitiot's avatar
pitiot committed
300 301

    m_sprite = new Utils::PointSprite();
pitiot's avatar
pitiot committed
302
    m_sprite->setAttributePosition(m_MovingObjectVBO);
303
    m_sprite->setSize(simul.aiguille->width);
pitiot's avatar
pitiot committed
304 305

    registerShader(m_sprite);
pitiot's avatar
pitiot committed
306 307
    m_frame_MovingObject = new Utils::FrameManipulator();
    m_frame_MovingObject->setSize(5.0f);
pitiot's avatar
pitiot committed
308

pitiot's avatar
init  
pitiot committed
309
}
pitiot's avatar
pitiot committed
310 311


pitiot's avatar
merging  
pitiot committed
312

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
313
void Volusion::displayMO()
pitiot's avatar
init  
pitiot committed
314
{
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
315 316
    m_ds->newList(GL_COMPILE_AND_EXECUTE);
    m_ds->begin(GL_LINE_STRIP);
pitiot's avatar
pitiot committed
317

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
318 319
    m_ds->lineWidth(10.0f);
    if(simul.aiguille->nbEdges>0)
pitiot's avatar
pitiot committed
320
    {
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
321 322 323 324 325 326 327 328 329 330
        VEC3 origin = simul.aiguille->Segments_[0]->p1;
        m_ds->vertex(origin);
    }
    for(Segment * s : simul.aiguille->Segments_)
    {
        m_ds->color3f(s->r,s->g,s->b);
        VEC3 p = s->p2;
        m_ds->vertex(p);
    }
    m_ds->color3f(0,0.5f,1.0f);
pitiot's avatar
pitiot committed
331

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
332 333
    m_ds->end();
    m_ds->endList();
pitiot's avatar
pitiot committed
334 335 336 337
//        VEC3 pos1 = simul.aiguille->parts_[0]->getPosition();
//        VEC3 pos2 = simul.aiguille->parts_[1]->getPosition();
//        float f;
//        VEC3 cylinder_axis =cylinder->getAxisScale(2,f);
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
338 339 340 341 342
    PFP::VEC3* data = static_cast<PFP::VEC3*>(m_MovingObjectVBO->lockPtr());
    int i=0;
    for(auto particule : simul.aiguille->parts_)
    {
        VEC3 p = particule->getPosition();
343 344 345 346 347
//            if(i==0)
//            {
//                m_topo_render->overdrawDart(particule->d,15.0f,1.0f,0.5f,1.0f);
//                m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position,  0.8f, 0.8f, 0.8f);
//            }
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
348 349 350
        data[i] = p;
        i++;
    }
Thomas Pitiot 's avatar
Thomas Pitiot committed
351
//        data[simul.aiguille->nbVertices]=simul.aiguille->closest_point;
pitiot's avatar
pitiot committed
352

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
353
    m_MovingObjectVBO->releasePtr();
pitiot's avatar
pitiot committed
354
//        m_frame_MovingObject->draw();
pitiot's avatar
pitiot committed
355 356 357 358 359 360 361
//        CGoGNout<<Geom::angle(pos2-pos1,cylinder_axis)<<CGoGNendl;
//        cylinder->rotate(Geom::angle(pos2-pos1,cylinder_axis),cylinder_axis^(pos2-pos1));

//        cylinder->translate((((pos1+pos2)/2)-cylinder->getPosition())/2);
//        cylinder->draw();


Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
362 363 364 365 366
    m_sprite->enableVertexAttribs();
    glDrawArrays(GL_POINTS, 0, simul.aiguille->nbVertices/*+1*/);
    m_sprite->disableVertexAttribs();
    if(render_belonging) // affichage des cellules qui contiennent l'aiguille
    {
pitiot's avatar
pitiot committed
367

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
368
        m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position,  0.8f, 0.8f, 0.8f);
pitiot's avatar
pitiot committed
369

370

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
371 372 373 374 375 376 377 378 379 380 381 382 383
        if ((unsigned int)dock.comboBoxEdge->count()<simul.aiguille->nbEdges)
        {
            dock.comboBoxEdge->clear();
            dock.comboBoxEdge->addItem("Aiguille entiere",2);
            for(unsigned int i = 0; i< simul.aiguille->nbEdges;i++)
            {
                std::ostringstream oss ;
                oss<<"arete "<<i;
                const QString& s=oss.str().c_str();
                dock.comboBoxEdge->addItem(s,2);
            }
        }

384

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
385
        if(val_comboEdge==0)
pitiot's avatar
pitiot committed
386
        {
Thomas Pitiot 's avatar
Thomas Pitiot committed
387

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
388 389 390 391 392 393 394
            for(unsigned int i =0;i<simul.aiguille->nbEdges;i++)
            {
//                 m_topo_render->overdrawDart(simul.aiguille->parts_[i]->d,10.0f,1.0f,0,0);
                for(auto it = simul.aiguille->belonging_cells[i].begin(); it !=simul.aiguille->belonging_cells[i].end();++it)
                {
                    for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(*it)))
                    {
395

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
396 397
                        m_topo_render->overdrawDart(d,5.0f,0,1.0f,0);
                    }
pitiot's avatar
pitiot committed
398

399

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
400 401 402 403 404
                }
            }
//             m_topo_render->overdrawDart(simul.aiguille->parts_[simul.aiguille->nbEdges]->d,10.0f,1.0f,0,0);
        }
        else
pitiot's avatar
pitiot committed
405 406
        {

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
407 408 409 410 411
//            m_topo_render->overdrawDart(simul.aiguille->parts_[val_comboEdge-1]->d,10.0f,1.0f,0,0);
//            m_topo_render->overdrawDart(simul.aiguille->parts_[val_comboEdge]->d,10.0f,1.0f,0,0);
            int i = val_comboEdge-1;
            for(auto it = simul.aiguille->belonging_cells[i].begin(); it !=simul.aiguille->belonging_cells[i].end();++it)
            {
pitiot's avatar
pitiot committed
412

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
413 414
                for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(*it)))
                {
pitiot's avatar
pitiot committed
415

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
416 417
                    m_topo_render->overdrawDart(d,5.0f,0,1.0f,0);
                }
pitiot's avatar
pitiot committed
418

Thomas Pitiot 's avatar
Thomas Pitiot committed
419

pitiot's avatar
pitiot committed
420
            }
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
421
        }
Thomas Pitiot 's avatar
Thomas Pitiot committed
422

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
423
    }
pitiot's avatar
pitiot committed
424

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
425 426 427 428 429 430
    if(render_neighbors) // affichage des cellules voisines de l'aiguille
    {
        m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position,  0.8f, 0.8f, 0.8f);
        if(val_comboEdge==0)
        {
            for(unsigned int i =0;i<simul.aiguille->nbEdges;i++)
Thomas Pitiot 's avatar
Thomas Pitiot committed
431
            {
pitiot's avatar
pitiot committed
432

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
433 434 435 436
                for(auto it = simul.aiguille->neighbor_cells[i].begin(); it !=simul.aiguille->neighbor_cells[i].end();++it)
                {
                    for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(*it)))
                    {
pitiot's avatar
pitiot committed
437

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
438 439
                        m_topo_render->overdrawDart(d,5.0f,1.0f,0.0f,0.8f);
                    }
pitiot's avatar
pitiot committed
440 441


Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
442 443 444 445 446 447 448 449 450 451 452 453 454
                }

            }
        }
        else
        {
            int i = val_comboEdge-1;
            for(auto it = simul.aiguille->neighbor_cells[i].begin(); it !=simul.aiguille->neighbor_cells[i].end();++it)
            {
                for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(*it)))
                {
                    m_topo_render->overdrawDart(d,5.0f,1.0f,0.0f,0.8f);
                }
Thomas Pitiot 's avatar
Thomas Pitiot committed
455

pitiot's avatar
pitiot committed
456

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
457
            }
pitiot's avatar
pitiot committed
458 459

        }
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
460 461
    }
}
pitiot's avatar
pitiot committed
462

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
463 464
void Volusion::displayObj()
{
pitiot's avatar
pitiot committed
465

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
466 467 468 469
    //        PFP::VEC3* data2 = static_cast<PFP::VEC3*>(m_closestVBO->lockPtr());

    //        int j =0;
    for(Surface * surf : simul.surfaces)
pitiot's avatar
up  
pitiot committed
470
    {
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
471 472 473 474 475 476
        surf->draw();
//            for(Triangle * t : surf->triangles_)
//            {
//                data2[j]=t->closest_point;
////                data2[j+1]=t->p1;
//                j++;
pitiot's avatar
pitiot committed
477

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
478
//            }
pitiot's avatar
pitiot committed
479

pitiot's avatar
up  
pitiot committed
480 481
    }

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
482 483 484 485 486 487
//        m_closestVBO->releasePtr();
//        m_spriteClosest->enableVertexAttribs();
//        glDrawArrays(GL_POINTS, 0, j+1);
//        m_spriteClosest->disableVertexAttribs();

    for (ArticulatedObject * art : simul.objects)
pitiot's avatar
up  
pitiot committed
488
    {
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
489 490 491 492 493 494 495 496 497




        m_ds->newList(GL_COMPILE_AND_EXECUTE);
        m_ds->begin(GL_LINE_STRIP);

        m_ds->lineWidth(10.0f);
        if(art->nbEdges>0)
pitiot's avatar
up  
pitiot committed
498
        {
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
499 500 501 502 503 504 505 506 507 508 509
            VEC3 origin = art->Segments_[0]->p1;
            Segment * s=art->Segments_[0];
            m_ds->color3f(s->r,s->g,s->b);
            m_ds->vertex(origin);
        }
        for(Segment * s : art->Segments_)
        {
            m_ds->color3f(s->r,s->g,s->b);
            VEC3 p = s->p2;
            m_ds->vertex(p);
        }
pitiot's avatar
pitiot committed
510

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529

        m_ds->end();
        m_ds->endList();
//        VEC3 pos1 = art->parts_[0]->getPosition();
//        VEC3 pos2 = art->parts_[1]->getPosition();
//        float f;
//        VEC3 cylinder_axis =cylinder->getAxisScale(2,f);
        PFP::VEC3* data = static_cast<PFP::VEC3*>(m_MovingObjectVBO->lockPtr());
        int i=0;
        for(auto particule : art->parts_)
        {
            VEC3 p = particule->getPosition();
//            if(i==0)
//            {
//                m_topo_render->overdrawDart(particule->d,15.0f,1.0f,0.5f,1.0f);
//                m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position,  0.8f, 0.8f, 0.8f);
//            }
            data[i] = p;
            i++;
pitiot's avatar
up  
pitiot committed
530
        }
pitiot's avatar
up  
pitiot committed
531

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548

        m_MovingObjectVBO->releasePtr();
//        m_frame_MovingObject->draw();
//        CGoGNout<<Geom::angle(pos2-pos1,cylinder_axis)<<CGoGNendl;
//        cylinder->rotate(Geom::angle(pos2-pos1,cylinder_axis),cylinder_axis^(pos2-pos1));

//        cylinder->translate((((pos1+pos2)/2)-cylinder->getPosition())/2);
//        cylinder->draw();


        m_sprite->enableVertexAttribs();
        glDrawArrays(GL_POINTS, 0, art->nbVertices);
        m_sprite->disableVertexAttribs();


    }
    if(obj_belong)
pitiot's avatar
pitiot committed
549
    {
pitiot's avatar
up  
pitiot committed
550
        m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position,  0.8f, 0.8f, 0.8f);
551 552 553 554 555 556 557 558 559
        for (ArticulatedObject * o : simul.objects)
        {
            for(unsigned int i =0;i<o->nbEdges;i++)
            {
    //                 m_topo_render->overdrawDart(simul.aiguille->parts_[i]->d,10.0f,1.0f,0,0);
                for(auto it = o->belonging_cells[i].begin(); it !=o->belonging_cells[i].end();++it)
                {
                    for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(*it)))
                    {
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
560
                        m_topo_render->overdrawDart(d,5.0f,0.0f,0.6f,0.4f);
561 562 563 564 565 566 567
                    }


                }
            }
        }

568
        m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position,  0.8f, 0.8f, 0.8f);
Thomas Pitiot 's avatar
Thomas Pitiot committed
569
        for (Surface * o : simul.surfaces)
570
        {
Thomas Pitiot 's avatar
Thomas Pitiot committed
571
            for(unsigned int i =0;i<o->nbTriangles;i++)
572 573 574 575 576 577
            {
    //                 m_topo_render->overdrawDart(simul.aiguille->parts_[i]->d,10.0f,1.0f,0,0);
                for(auto it = o->belonging_cells[i].begin(); it !=o->belonging_cells[i].end();++it)
                {
                    for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(*it)))
                    {
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
578
                        m_topo_render->overdrawDart(d,5.0f,0.0f,0.6f,0.4f);
579 580
                    }

581

582 583 584
                }
            }
        }
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
585 586 587 588 589
    }
    if(obj_neighbors)
    {
        m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position,  0.8f, 0.8f, 0.8f);
        for (ArticulatedObject * o : simul.objects)
pitiot's avatar
pitiot committed
590
        {
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
591
            for(unsigned int i =0;i<o->nbEdges;i++)
pitiot's avatar
pitiot committed
592
            {
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
593 594 595 596 597 598 599 600 601 602
    //                 m_topo_render->overdrawDart(simul.aiguille->parts_[i]->d,10.0f,1.0f,0,0);
                for(auto it = o->neighbor_cells[i].begin(); it !=o->neighbor_cells[i].end();++it)
                {
                    for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(*it)))
                    {
                        m_topo_render->overdrawDart(d,5.0f,1.0f,0.0f,0.8f);
                    }


                }
pitiot's avatar
pitiot committed
603 604 605
            }
        }

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
606 607
        m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position,  0.8f, 0.8f, 0.8f);
        for (Surface * o : simul.surfaces)
pitiot's avatar
pitiot committed
608
        {
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
609
            for(unsigned int i =0;i<o->nbTriangles;i++)
pitiot's avatar
pitiot committed
610
            {
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
611 612
    //                 m_topo_render->overdrawDart(simul.aiguille->parts_[i]->d,10.0f,1.0f,0,0);
                for(auto it = o->neighbor_cells[i].begin(); it !=o->neighbor_cells[i].end();++it)
pitiot's avatar
pitiot committed
613
                {
pitiot's avatar
pitiot committed
614
                    for (Edge d : edgesIncidentToVolume3(simul.envMap_.map,(*it)))
pitiot's avatar
pitiot committed
615
                    {
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
616
                        m_topo_render->overdrawDart(d,5.0f,1.0f,0.0f,0.8f);
pitiot's avatar
pitiot committed
617
                    }
pitiot's avatar
pitiot committed
618

pitiot's avatar
pitiot committed
619 620 621 622

                }
            }
        }
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
623 624
    }
}
pitiot's avatar
pitiot committed
625

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
626 627
void Volusion::cb_redraw()
{
pitiot's avatar
pitiot committed
628 629


pitiot's avatar
pitiot committed
630

pitiot's avatar
pitiot committed
631

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
632 633
	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
	glEnable(GL_LIGHTING);
pitiot's avatar
pitiot committed
634

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
635 636
	glEnable(GL_POLYGON_OFFSET_FILL);
	glPolygonOffset(1.0f, 1.0f);
pitiot's avatar
pitiot committed
637

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
638 639 640 641 642
    if(render_MovingObject)
    {
        displayMO();
    }
    if(display_obj) // affichage objets fixes
pitiot's avatar
pitiot committed
643
    {
pitiot's avatar
pitiot committed
644

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
645
        displayObj();
pitiot's avatar
pitiot committed
646

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
647 648 649 650 651 652
    }
    if(false) //affichage des normales
    {
        Dart volume=simul.envMap_.map.indexDart(1500);
        for (Face d : facesIncidentToVolume3(simul.envMap_.map,volume))
        {
pitiot's avatar
pitiot committed
653

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
654 655 656 657 658 659 660 661
            m_ds->newList(GL_COMPILE_AND_EXECUTE);
            m_ds->begin(GL_LINE_STRIP);
            m_ds->color3f(0,1.0f,0);
            m_ds->lineWidth(10.0f);
            m_ds->vertex(simul.envMap_.facecenter[d]);
            m_ds->vertex(simul.envMap_.facecenter[d]+simul.envMap_.normaleFromVolume(volume,d));
            m_ds->end();
            m_ds->endList();
pitiot's avatar
pitiot committed
662
        }
pitiot's avatar
pitiot committed
663

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
664
    }
pitiot's avatar
pitiot committed
665

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
666 667 668 669 670 671 672
    if (draw_dart)
    {
        m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position,  0.8f, 0.8f, 0.8f);
        dock.spinBox_dart->setRange(0, simul.envMap_.map.end().index) ;
        if( dartSlider < (simul.envMap_.map.end().index))
        {
        m_topo_render->overdrawDart(simul.envMap_.map.indexDart(dartSlider),15.0f,1.0f,0.0f,1.0f);
pitiot's avatar
pitiot committed
673 674 675 676 677

        }
    }


pitiot's avatar
up  
pitiot committed
678

Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
679 680


pitiot's avatar
init  
pitiot committed
681
	if (render_topo)
pitiot's avatar
pitiot committed
682
    {
pitiot's avatar
up  
pitiot committed
683
        m_topo_render->updateData(simul.envMap_.map, simul.envMap_.position,  0.8f, 0.8f, 0.8f);
pitiot's avatar
pitiot committed
684 685 686
            m_topo_render->drawTopo();

    }
pitiot's avatar
maj  
pitiot committed
687

pitiot's avatar
init  
pitiot committed
688
	if (render_edges)
David Cazier's avatar
David Cazier committed
689
	{
pitiot's avatar
init  
pitiot committed
690
		glLineWidth(2.0f);
pitiot's avatar
up  
pitiot committed
691
        m_explode_render->updateData<PFP>(simul.envMap_.map, simul.envMap_.position, simul.envMap_.color);
pitiot's avatar
init  
pitiot committed
692
		m_explode_render->drawEdges();
pitiot's avatar
pitiot committed
693

Pierre Kraemer's avatar
Pierre Kraemer committed
694
	}
pitiot's avatar
pitiot committed
695

pitiot's avatar
init  
pitiot committed
696
	glDisable(GL_POLYGON_OFFSET_FILL);
Thomas Jund's avatar
Thomas Jund committed
697

pitiot's avatar
init  
pitiot committed
698
	if (render_volumes)
David Cazier's avatar
David Cazier committed
699
	{
Thomas Pitiot 's avatar
Thomas Pitiot committed
700 701
        m_explode_render->updateData<PFP>(simul.envMap_.map, simul.envMap_.position, simul.envMap_.color);
        m_explode_render->drawFaces();
Pierre Kraemer's avatar
Pierre Kraemer committed
702
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
703

704 705 706 707 708
//	if (clip_volume && !hide_clipping)
//	{
//		m_frame->draw();
//		m_PlanePick->draw();
//	}
Pierre Kraemer's avatar
Pierre Kraemer committed
709 710
}

pitiot's avatar
pitiot committed
711

pitiot's avatar
init  
pitiot committed
712
void  Volusion::cb_mousePress(int /*button*/, int x, int y)
Pierre Kraemer's avatar
Pierre Kraemer committed
713
{
714
/*    if (Shift())
pitiot's avatar
pitiot committed
715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739
    {

        if (hide_clipping || !clip_volume)
            return;

        m_begX = x;
        m_begY = y;

        // get ray of selection
        Geom::Vec3f rayA,rayB;
        float dist = getOrthoScreenRay(x,y,rayA,rayB);
        Geom::Vec3f AB = rayB-rayA;

        unsigned int fr_picked =0;
        // picking the frame -> axis
        fr_picked = m_frame->pick(rayA,AB,dist);

        if (fr_picked != 0)
        {
            m_pickedAxis=fr_picked;
            m_frame->highlight(m_pickedAxis);
            m_frame->storeProjection(m_pickedAxis);
            updateGL();
        }
    }
740
    else*/ if (Control())
pitiot's avatar
pitiot committed
741 742 743
    {
        startX=x;
        startY=y;
pitiot's avatar
pitiot committed
744 745
        m_frame_MovingObject->storeProjection(0);
        oldPosSprite=m_frame_MovingObject->getPosition();
pitiot's avatar
pitiot committed
746 747
        updateGL();
    }
Pierre Kraemer's avatar
Pierre Kraemer committed
748
}
749

pitiot's avatar
init  
pitiot committed
750
void  Volusion::cb_mouseRelease(int /*button*/, int /*x*/, int /*y*/)
Thomas's avatar
Thomas committed
751 752
{

753 754
//    if (!hide_clipping && clip_volume)
//    {
755

756 757 758 759
//        m_pickedAxis=0;
//        m_frame->highlight(m_pickedAxis);
//        updateGL();
//    }
pitiot's avatar
pitiot committed
760
    if (render_MovingObject)
pitiot's avatar
pitiot committed
761
        updateGL();
762

Thomas's avatar
Thomas committed
763 764
}

pitiot's avatar
init  
pitiot committed
765
void  Volusion::cb_mouseMove(int buttons, int x, int y)
Pierre Kraemer's avatar
Pierre Kraemer committed
766
{
767
/*    if (Shift())
pitiot's avatar
pitiot committed
768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821
    {


        if (hide_clipping || !clip_volume)
            return;

        // rotation selected ?
        if (Utils::FrameManipulator::rotationAxis(m_pickedAxis))
        {
            if (buttons&1)
            {
                float angle = m_frame->angleFromMouse(x,y,x-m_begX, y-m_begY);
                m_frame->rotate(m_pickedAxis, angle);
            }
            else if (buttons&2)
                m_frame->rotateInScreen(x-m_begX, y-m_begY);

            m_PlanePick->transfo() = m_frame->transfo();
        }
        // translation selected
        else if (Utils::FrameManipulator::translationAxis(m_pickedAxis))
        {
            if (buttons&1)
            {
                float dist =  m_frame->distanceFromMouse(x-m_begX, y-m_begY);
                m_frame->translate(m_pickedAxis, dist);
            }
            else if (buttons&2)
                m_frame->translateInScreen(x-m_begX, y-m_begY);

            m_PlanePick->transfo() = m_frame->transfo();
        }
        // scale selected
        else if (Utils::FrameManipulator::scaleAxis(m_pickedAxis) )
        {
            float scale = m_frame->scaleFromMouse(x-m_begX, y-m_begY);
            m_frame->scale(m_pickedAxis, scale );
            m_PlanePick->transfo() = m_frame->transfo();
        }

        Geom::Vec3f pos = m_PlanePick->getPosition();
        float pipo;
        Geom::Vec3f normal = m_PlanePick->getAxisScale(2, pipo); // 2 = Z axis = plane normal
        float d = -(pos*normal);
        m_explode_render->setClippingPlane(Geom::Vec4f(normal[0],normal[1],normal[2],d));

        m_sh1->setClipPlaneParamsAll(clip_id1, normal, pos);
        m_sh2->setClipPlaneParamsAll(clip_id2, normal, pos);

        m_begX = x;
        m_begY = y;
        updateGL();
        return;
    }
822
    else */if(Control())
pitiot's avatar
pitiot committed
823
    {
pitiot's avatar
pitiot committed
824
        m_frame_MovingObject->translateInScreen(x-startX, y-startY);
pitiot's avatar
pitiot committed
825

pitiot's avatar
pitiot committed
826 827 828
//        cylinder->transfo() = m_frame_MovingObject->transfo();
//        simul.aiguille->transfo(m_frame_MovingObject->transfo());
        VEC3 diff = m_frame_MovingObject->getPosition()-oldPosSprite;
pitiot's avatar
pitiot committed
829 830
//        CGoGNout<<"deplacement de : "<<diff<<CGoGNendl;

pitiot's avatar
pitiot committed
831 832
        if(simul.aiguille->nbVertices>0)
            simul.aiguille->move(diff);
pitiot's avatar
pitiot committed
833

pitiot's avatar
pitiot committed
834 835
        startX=x;
        startY=y;
pitiot's avatar
pitiot committed
836
        oldPosSprite=m_frame_MovingObject->getPosition();
pitiot's avatar
pitiot committed
837 838
        updateGL();
    }
839

pitiot's avatar
init  
pitiot committed
840
}
841

Pierre Kraemer's avatar
Pierre Kraemer committed
842

843 844


pitiot's avatar
init  
pitiot committed
845
int main(int argc, char **argv)
Pierre Kraemer's avatar
Pierre Kraemer committed
846
{
pitiot's avatar
merging  
pitiot committed
847 848


Thomas Jund's avatar
Thomas Jund committed
849

pitiot's avatar
init  
pitiot committed
850 851 852 853
    // un peu d'interface
	QApplication app(argc, argv);
	Volusion sqt;
	sqt.simul.init(argc,argv);
Thomas Jund's avatar
Thomas Jund committed
854

pitiot's avatar
init  
pitiot committed
855
	// interface de tuto5.ui
pitiot's avatar
pitiot committed
856 857

    sqt.setDock(&(sqt.dock));
858

pitiot's avatar
init  
pitiot committed
859
	//  bounding box
pitiot's avatar
pitiot committed
860
    Geom::BoundingBox<VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(sqt.simul.envMap_.map, sqt.simul.envMap_.position);
pitiot's avatar
init  
pitiot committed
861 862
	sqt.m_WidthObj = std::max<REAL>(std::max<REAL>(bb.size(0), bb.size(1)), bb.size(2));
	sqt.m_PosObj = (bb.min() +  bb.max()) / REAL(2);
pitiot's avatar
merging  
pitiot committed
863

pitiot's avatar
init  
pitiot committed
864 865
    // envoit info BB a l'interface
	sqt.setParamObject(sqt.m_WidthObj, sqt.m_PosObj.data());
Pierre Kraemer's avatar
Pierre Kraemer committed
866

pitiot's avatar
pitiot committed
867 868 869 870 871 872
    sqt.setCallBack( sqt.dock.checkBox_volumes, SIGNAL(toggled(bool)), SLOT(volumes_onoff(bool)) );
    sqt.setCallBack( sqt.dock.checkBox_edges, SIGNAL(toggled(bool)), SLOT(edges_onoff(bool)) );
    sqt.setCallBack( sqt.dock.checkBox_topo, SIGNAL(toggled(bool)), SLOT(topo_onoff(bool)) );
    sqt.setCallBack( sqt.dock.checkBox_MovingObject, SIGNAL(toggled(bool)), SLOT(MovingObject_onoff(bool)) );
    sqt.setCallBack( sqt.dock.checkBox_belonging, SIGNAL(toggled(bool)), SLOT(belonging_onoff(bool)) );
    sqt.setCallBack( sqt.dock.checkBox_neighbors, SIGNAL(toggled(bool)), SLOT(neighbors_onoff(bool)) );
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
873 874 875 876 877
    sqt.setCallBack( sqt.dock.checkBox_displayobjects, SIGNAL(toggled(bool)), SLOT(obj_onoff(bool)) );
    sqt.setCallBack( sqt.dock.checkBox_ObjBelong, SIGNAL(toggled(bool)), SLOT(objBelong_onoff(bool)) );
    sqt.setCallBack( sqt.dock.checkBox_ObjNeighbors, SIGNAL(toggled(bool)), SLOT(objNeighbors_onoff(bool)) );
//    sqt.setCallBack( sqt.dock.checkBox_hide, SIGNAL(toggled(bool)), SLOT(hide_onoff(bool)) );
//    sqt.setCallBack( sqt.dock.checkBox_plane, SIGNAL(toggled(bool)), SLOT(clipping_onoff(bool)) );
pitiot's avatar
pitiot committed
878 879 880 881 882 883 884 885 886
     sqt.setCallBack( sqt.dock.comboBoxEdge, SIGNAL(	activated(int)), SLOT(comboEdge(int)) );
    sqt.setCallBack( sqt.dock.slider_explode, SIGNAL(sliderPressed()), SLOT(slider_pressed()) );
    sqt.setCallBack( sqt.dock.slider_explode, SIGNAL(sliderReleased()), SLOT(slider_released()) );
    sqt.setCallBack(sqt.dock.spinBox_dart, SIGNAL(valueChanged(int)), SLOT(slot_slide(int))) ;
    sqt.setCallBack(sqt.dock.checkBox_drawDart, SIGNAL(toggled(bool)), SLOT(dart_onoff(bool))) ;
    sqt.setCallBack( sqt.dock.slider_explode_face, SIGNAL(valueChanged(int)), SLOT(slider_explodeF(int)) );

    sqt.setCallBack( sqt.dock.slider_explode_face, SIGNAL(sliderPressed()), SLOT(slider_pressed()) );
    sqt.setCallBack( sqt.dock.slider_explode_face, SIGNAL(sliderReleased()), SLOT(slider_released()) );
887

pitiot's avatar
init  
pitiot committed
888
	sqt.show();
pitiot's avatar
pitiot committed
889 890
    sqt.dock.slider_explode->setValue(100);
    sqt.dock.slider_explode_face->setValue(100);
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
891
//	sqt.clipping_onoff(false);
pitiot's avatar
init  
pitiot committed
892 893
	sqt.topo_onoff(false);
	sqt.edges_onoff(true);
pitiot's avatar
pitiot committed
894
    sqt.dock.checkBox_MovingObject->setChecked(true);
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
895 896 897
    sqt.dock.checkBox_displayobjects->setChecked(true);
    sqt.dock.checkBox_ObjBelong->setChecked(false);
    sqt.dock.checkBox_ObjNeighbors->setChecked(false);
pitiot's avatar
pitiot committed
898 899 900
    sqt.dock.checkBox_topo->setChecked(false);
    sqt.dock.checkBox_belonging->setChecked(false);
    sqt.dock.checkBox_neighbors->setChecked(false);
Thomas Pitiot 's avatar
up2  
Thomas Pitiot committed
901 902
//    sqt.dock.checkBox_plane->setChecked(false);
//    sqt.dock.checkBox_hide->setChecked(true);
Thomas Pitiot 's avatar
Thomas Pitiot committed
903
    sqt.dock.checkBox_volumes->setChecked(false);
pitiot's avatar
pitiot committed
904 905 906
    sqt.dock.spinBox_dart->setRange(0, sqt.simul.envMap_.map.end().index) ;

    sqt.dock.comboBoxEdge->addItem("Aiguille entiere",2);
pitiot's avatar
pitiot committed
907 908 909 910 911
    for(unsigned int i = 0; i< sqt.simul.aiguille->nbEdges;i++)
    {
        std::ostringstream oss ;
        oss<<"arete "<<i;
        const QString& s=oss.str().c_str();
pitiot's avatar
pitiot committed
912
        sqt.dock.comboBoxEdge->addItem(s,2);
pitiot's avatar
pitiot committed
913
    }
David Cazier's avatar
David Cazier committed
914

pitiot's avatar
init  
pitiot committed
915 916
	// et on attend la fin.
	return app.exec();
pitiot's avatar
merging  
pitiot committed
917

pitiot's avatar
merging  
pitiot committed
918

Arash HABIBI's avatar
Arash HABIBI committed
919 920


pitiot's avatar
merging  
pitiot committed
921

pitiot's avatar
init  
pitiot committed
922
	// exemple utilisation chrono
Pierre Kraemer's avatar
Pierre Kraemer committed
923

pitiot's avatar
merging  
pitiot committed
924

pitiot's avatar
init  
pitiot committed
925
//	Utils::Chrono ch;
pitiot's avatar
pitiot committed
926
//
pitiot's avatar
pitiot committed
927 928
//	Vertex v(simul.envMap_.map.begin());
////	VEC3 p = Algo::Volume::Geometry::vertexNeighborhoodCentroid<PFP>(simul.envMap_.map,v,simul.envMap_.position);
pitiot's avatar
pitiot committed
929
//
pitiot's avatar
pitiot committed
930 931
//	Vol w(simul.envMap_.map.begin());
//	VEC3 q = Algo::Surface::Geometry::volumeCentroid<PFP>(simul.envMap_.map,w,simul.envMap_.position);
pitiot's avatar
init  
pitiot committed
932 933

//	ch.start();
pitiot's avatar
pitiot committed
934 935 936 937
//	float vol = Algo::Geometry::Parallel::totalVolume<PFP>(simul.envMap_.map, simul.envMap_.position);
//	vol += Algo::Geometry::Parallel::totalVolume<PFP>(simul.envMap_.map, simul.envMap_.position);
//	vol += Algo::Geometry::Parallel::totalVolume<PFP>(simul.envMap_.map, simul.envMap_.position);
//	vol += Algo::Geometry::Parallel::totalVolume<PFP>(simul.envMap_.map, simul.envMap_.position);
pitiot's avatar
init  
pitiot committed
938 939 940 941
//	std::cout << ch.elapsed()<< " ms //  val="<<vol<< std::endl;
//
//	std::cout << "Compute Volume ->"<< std::endl;
//	ch.start();
pitiot's avatar
pitiot committed
942
//	vol = Algo::Geometry::totalVolume<PFP>(simul.envMap_.map, simul.envMap_.position);
pitiot's avatar
init  
pitiot committed
943 944
//	std::cout << ch.elapsed()<< " ms  val="<<vol<< std::endl;
//	ch.start();
pitiot's avatar
pitiot committed
945
//	vol += Algo::Geometry::totalVolume<PFP>(simul.envMap_.map, simul.envMap_.position);
pitiot's avatar
init  
pitiot committed
946 947
//	std::cout << ch.elapsed()<< " ms  val="<<vol<< std::endl;
//	ch.start();
pitiot's avatar
pitiot committed
948
//	vol += Algo::Geometry::totalVolume<PFP>(simul.envMap_.map, simul.envMap_.position);
pitiot's avatar
init  
pitiot committed
949 950
//	std::cout << ch.elapsed()<< " ms  val="<<vol<< std::endl;
//	ch.start();
pitiot's avatar
pitiot committed
951
//	vol += Algo::Geometry::totalVolume<PFP>(simul.envMap_.map, simul.envMap_.position);
pitiot's avatar
init  
pitiot committed
952 953
//	std::cout << ch.elapsed()<< " ms  val="<<vol<< std::endl;

pitiot's avatar
merging  
pitiot committed
954

Pierre Kraemer's avatar
Pierre Kraemer committed
955
}