@@ -74,38 +74,137 @@ TaskFemConstraintRigidBody::TaskFemConstraintRigidBody(
74
74
75
75
/* Note: */
76
76
// Get the feature data
77
- Fem::ConstraintRigidBody* pcConstraint =
78
- static_cast <Fem::ConstraintRigidBody*>(ConstraintView->getObject ());
79
- double fStates [15 ];
80
- fStates [0 ] = pcConstraint->xRefNode .getValue ();
81
- fStates [1 ] = pcConstraint->yRefNode .getValue ();
82
- fStates [2 ] = pcConstraint->zRefNode .getValue ();
83
- fStates [3 ] = pcConstraint->xDisplacement .getValue ();
84
- fStates [4 ] = pcConstraint->yDisplacement .getValue ();
85
- fStates [5 ] = pcConstraint->zDisplacement .getValue ();
86
- fStates [6 ] = pcConstraint->xRotation .getValue ();
87
- fStates [7 ] = pcConstraint->yRotation .getValue ();
88
- fStates [8 ] = pcConstraint->zRotation .getValue ();
89
- fStates [9 ] = pcConstraint->xForce .getValue ();
90
- fStates [10 ] = pcConstraint->yForce .getValue ();
91
- fStates [11 ] = pcConstraint->zForce .getValue ();
92
- fStates [12 ] = pcConstraint->xMoment .getValue ();
93
- fStates [13 ] = pcConstraint->yMoment .getValue ();
94
- fStates [14 ] = pcConstraint->zMoment .getValue ();
77
+ auto pcConstraint = static_cast <Fem::ConstraintRigidBody*>(ConstraintView->getObject ());
78
+
79
+ const Base::Vector3d& refNode = pcConstraint->ReferenceNode .getValue ();
80
+ const Base::Vector3d& disp = pcConstraint->Displacement .getValue ();
81
+ Base::Vector3d rotDir;
82
+ double rotAngleRad;
83
+ pcConstraint->Rotation .getValue ().getValue (rotDir, rotAngleRad);
84
+ Base::Quantity rotAngle (rotAngleRad, QString::fromUtf8 (" rad" ));
85
+ Base::Quantity force = pcConstraint->Force .getQuantityValue ();
86
+ const Base::Vector3d& forceDir = pcConstraint->ForceDirection .getValue ();
87
+ Base::Quantity moment = pcConstraint->Moment .getQuantityValue ();
88
+ const Base::Vector3d& momentDir = pcConstraint->MomentDirection .getValue ();
95
89
96
90
std::vector<App::DocumentObject*> Objects = pcConstraint->References .getValues ();
97
91
std::vector<std::string> SubElements = pcConstraint->References .getSubValues ();
98
92
99
93
// Fill data into dialog elements
100
- ui->if_ref_node_x ->setValue (fStates [0 ]);
101
- ui->if_ref_node_y ->setValue (fStates [1 ]);
102
- ui->if_ref_node_z ->setValue (fStates [2 ]);
103
- ui->if_ref_force_x ->setValue (fStates [9 ]);
104
- ui->if_ref_force_y ->setValue (fStates [10 ]);
105
- ui->if_ref_force_z ->setValue (fStates [11 ]);
106
- ui->if_rot_force_x ->setValue (fStates [12 ]);
107
- ui->if_rot_force_y ->setValue (fStates [13 ]);
108
- ui->if_rot_force_z ->setValue (fStates [14 ]);
94
+ ui->qsb_ref_node_x ->setValue (refNode.x );
95
+ ui->qsb_ref_node_y ->setValue (refNode.y );
96
+ ui->qsb_ref_node_z ->setValue (refNode.z );
97
+ ui->qsb_ref_node_x ->bind (
98
+ App::ObjectIdentifier::parse (pcConstraint, std::string (" ReferenceNode.x" )));
99
+ ui->qsb_ref_node_y ->bind (
100
+ App::ObjectIdentifier::parse (pcConstraint, std::string (" ReferenceNode.y" )));
101
+ ui->qsb_ref_node_z ->bind (
102
+ App::ObjectIdentifier::parse (pcConstraint, std::string (" ReferenceNode.z" )));
103
+ ui->qsb_ref_node_x ->setMinimum (-FLOAT_MAX);
104
+ ui->qsb_ref_node_x ->setMaximum (FLOAT_MAX);
105
+ ui->qsb_ref_node_y ->setMinimum (-FLOAT_MAX);
106
+ ui->qsb_ref_node_y ->setMaximum (FLOAT_MAX);
107
+ ui->qsb_ref_node_z ->setMinimum (-FLOAT_MAX);
108
+ ui->qsb_ref_node_z ->setMaximum (FLOAT_MAX);
109
+
110
+ ui->qsb_disp_x ->setValue (disp.x );
111
+ ui->qsb_disp_y ->setValue (disp.y );
112
+ ui->qsb_disp_z ->setValue (disp.z );
113
+ ui->qsb_disp_x ->bind (App::ObjectIdentifier::parse (pcConstraint, std::string (" Displacement.x" )));
114
+ ui->qsb_disp_y ->bind (App::ObjectIdentifier::parse (pcConstraint, std::string (" Displacement.y" )));
115
+ ui->qsb_disp_z ->bind (App::ObjectIdentifier::parse (pcConstraint, std::string (" Displacement.z" )));
116
+ ui->qsb_disp_x ->setMinimum (-FLOAT_MAX);
117
+ ui->qsb_disp_x ->setMaximum (FLOAT_MAX);
118
+ ui->qsb_disp_y ->setMinimum (-FLOAT_MAX);
119
+ ui->qsb_disp_y ->setMaximum (FLOAT_MAX);
120
+ ui->qsb_disp_z ->setMinimum (-FLOAT_MAX);
121
+ ui->qsb_disp_z ->setMaximum (FLOAT_MAX);
122
+
123
+ ui->spb_rot_axis_x ->setValue (rotDir.x );
124
+ ui->spb_rot_axis_y ->setValue (rotDir.y );
125
+ ui->spb_rot_axis_z ->setValue (rotDir.z );
126
+ ui->qsb_rot_angle ->setValue (rotAngle.getValueAs (Base::Quantity::Degree));
127
+ ui->spb_rot_axis_x ->bind (
128
+ App::ObjectIdentifier::parse (pcConstraint, std::string (" Rotation.Axis.x" )));
129
+ ui->spb_rot_axis_y ->bind (
130
+ App::ObjectIdentifier::parse (pcConstraint, std::string (" Rotation.Axis.y" )));
131
+ ui->spb_rot_axis_z ->bind (
132
+ App::ObjectIdentifier::parse (pcConstraint, std::string (" Rotation.Axis.z" )));
133
+ ui->qsb_rot_angle ->bind (
134
+ App::ObjectIdentifier::parse (pcConstraint, std::string (" Rotation.Angle" )));
135
+ ui->spb_rot_axis_x ->setMinimum (-FLOAT_MAX);
136
+ ui->spb_rot_axis_x ->setMaximum (FLOAT_MAX);
137
+ ui->spb_rot_axis_y ->setMinimum (-FLOAT_MAX);
138
+ ui->spb_rot_axis_y ->setMaximum (FLOAT_MAX);
139
+ ui->spb_rot_axis_z ->setMinimum (-FLOAT_MAX);
140
+ ui->spb_rot_axis_z ->setMaximum (FLOAT_MAX);
141
+ ui->qsb_rot_angle ->setMinimum (-FLOAT_MAX);
142
+ ui->qsb_rot_angle ->setMaximum (FLOAT_MAX);
143
+
144
+ ui->spb_force_dir_x ->setValue (forceDir.x );
145
+ ui->spb_force_dir_y ->setValue (forceDir.y );
146
+ ui->spb_force_dir_z ->setValue (forceDir.z );
147
+ ui->qsb_force ->setValue (force);
148
+ ui->spb_force_dir_x ->bind (
149
+ App::ObjectIdentifier::parse (pcConstraint, std::string (" ForceDirection.x" )));
150
+ ui->spb_force_dir_y ->bind (
151
+ App::ObjectIdentifier::parse (pcConstraint, std::string (" ForceDirection.y" )));
152
+ ui->spb_force_dir_z ->bind (
153
+ App::ObjectIdentifier::parse (pcConstraint, std::string (" ForceDirection.z" )));
154
+ ui->qsb_force ->bind (pcConstraint->Force );
155
+ ui->spb_force_dir_x ->setMinimum (-FLOAT_MAX);
156
+ ui->spb_force_dir_x ->setMaximum (FLOAT_MAX);
157
+ ui->spb_force_dir_y ->setMinimum (-FLOAT_MAX);
158
+ ui->spb_force_dir_y ->setMaximum (FLOAT_MAX);
159
+ ui->spb_force_dir_z ->setMinimum (-FLOAT_MAX);
160
+ ui->spb_force_dir_z ->setMaximum (FLOAT_MAX);
161
+ ui->qsb_force ->setMinimum (-FLOAT_MAX);
162
+ ui->qsb_force ->setMaximum (FLOAT_MAX);
163
+
164
+ ui->spb_moment_dir_x ->setValue (momentDir.x );
165
+ ui->spb_moment_dir_y ->setValue (momentDir.y );
166
+ ui->spb_moment_dir_z ->setValue (momentDir.z );
167
+ ui->qsb_moment ->setValue (moment);
168
+ ui->spb_moment_dir_x ->bind (
169
+ App::ObjectIdentifier::parse (pcConstraint, std::string (" MomentDirection.x" )));
170
+ ui->spb_moment_dir_y ->bind (
171
+ App::ObjectIdentifier::parse (pcConstraint, std::string (" MomentDirection.y" )));
172
+ ui->spb_moment_dir_z ->bind (
173
+ App::ObjectIdentifier::parse (pcConstraint, std::string (" MomentDirection.z" )));
174
+ ui->spb_moment_dir_x ->setMinimum (-FLOAT_MAX);
175
+ ui->spb_moment_dir_x ->setMaximum (FLOAT_MAX);
176
+ ui->spb_moment_dir_y ->setMinimum (-FLOAT_MAX);
177
+ ui->spb_moment_dir_y ->setMaximum (FLOAT_MAX);
178
+ ui->spb_moment_dir_z ->setMinimum (-FLOAT_MAX);
179
+ ui->spb_moment_dir_z ->setMaximum (FLOAT_MAX);
180
+ ui->qsb_moment ->setMinimum (-FLOAT_MAX);
181
+ ui->qsb_moment ->setMaximum (FLOAT_MAX);
182
+ ui->qsb_moment ->bind (pcConstraint->Moment );
183
+
184
+ QStringList modeList;
185
+
186
+ App::PropertyEnumeration* transMode = &pcConstraint->FreeTranslationalMode ;
187
+ for (auto item : transMode->getEnumVector ()) {
188
+ modeList << QString::fromUtf8 (item.c_str ());
189
+ }
190
+ ui->cb_trans_mode ->addItems (modeList);
191
+ ui->cb_trans_mode ->setCurrentIndex (transMode->getValue ());
192
+
193
+ modeList.clear ();
194
+ App::PropertyEnumeration* rotMode = &pcConstraint->FreeRotationalMode ;
195
+ for (auto item : rotMode->getEnumVector ()) {
196
+ modeList << QString::fromUtf8 (item.c_str ());
197
+ }
198
+ ui->cb_rotation_mode ->addItems (modeList);
199
+ ui->cb_rotation_mode ->setCurrentIndex (rotMode->getValue ());
200
+
201
+ modeList.clear ();
202
+ App::PropertyEnumeration* loadMode = &pcConstraint->LoadMode ;
203
+ for (auto item : loadMode->getEnumVector ()) {
204
+ modeList << QString::fromUtf8 (item.c_str ());
205
+ }
206
+ ui->cb_load_mode ->addItems (modeList);
207
+ ui->cb_load_mode ->setCurrentIndex (loadMode->getValue ());
109
208
110
209
ui->lw_references ->clear ();
111
210
for (std::size_t i = 0 ; i < Objects.size (); i++) {
@@ -284,46 +383,75 @@ const std::string TaskFemConstraintRigidBody::getReferences() const
284
383
return TaskFemConstraint::getReferences (items);
285
384
}
286
385
287
- double TaskFemConstraintRigidBody::get_xRefNode () const
386
+ Base::Vector3d TaskFemConstraintRigidBody::getReferenceNode () const
288
387
{
289
- return ui->if_ref_node_x ->rawValue ();
388
+ double x = ui->qsb_ref_node_x ->rawValue ();
389
+ double y = ui->qsb_ref_node_y ->rawValue ();
390
+ double z = ui->qsb_ref_node_z ->rawValue ();
391
+
392
+ return Base::Vector3d (x, y, z);
290
393
}
291
- double TaskFemConstraintRigidBody::get_yRefNode () const
394
+
395
+ Base::Vector3d TaskFemConstraintRigidBody::getDisplacement () const
292
396
{
293
- return ui->if_ref_node_y ->rawValue ();
397
+ double x = ui->qsb_disp_x ->rawValue ();
398
+ double y = ui->qsb_disp_y ->rawValue ();
399
+ double z = ui->qsb_disp_z ->rawValue ();
400
+
401
+ return Base::Vector3d (x, y, z);
294
402
}
295
- double TaskFemConstraintRigidBody::get_zRefNode () const
403
+
404
+ Base::Rotation TaskFemConstraintRigidBody::getRotation () const
296
405
{
297
- return ui->if_ref_node_z ->rawValue ();
406
+ double x = ui->spb_rot_axis_x ->value ();
407
+ double y = ui->spb_rot_axis_y ->value ();
408
+ double z = ui->spb_rot_axis_z ->value ();
409
+ double angle = ui->qsb_rot_angle ->value ().getValueAs (Base::Quantity::Radian);
410
+
411
+ return Base::Rotation (Base::Vector3d (x, y, z), angle);
298
412
}
299
- double TaskFemConstraintRigidBody::get_xForce () const
413
+
414
+ Base::Vector3d TaskFemConstraintRigidBody::getForceDirection () const
300
415
{
301
- return ui->if_ref_force_x ->rawValue ();
416
+ double x = ui->spb_force_dir_x ->value ();
417
+ double y = ui->spb_force_dir_y ->value ();
418
+ double z = ui->spb_force_dir_z ->value ();
419
+
420
+ return Base::Vector3d (x, y, z);
302
421
}
303
- double TaskFemConstraintRigidBody::get_yForce () const
422
+
423
+ Base::Vector3d TaskFemConstraintRigidBody::getMomentDirection () const
304
424
{
305
- return ui->if_ref_force_y ->rawValue ();
425
+ double x = ui->spb_moment_dir_x ->value ();
426
+ double y = ui->spb_moment_dir_y ->value ();
427
+ double z = ui->spb_moment_dir_z ->value ();
428
+
429
+ return Base::Vector3d (x, y, z);
306
430
}
307
- double TaskFemConstraintRigidBody::get_zForce () const
431
+
432
+ std::string TaskFemConstraintRigidBody::getForce () const
308
433
{
309
- return ui->if_ref_force_z -> rawValue ();
434
+ return ui->qsb_force -> value (). getSafeUserString (). toStdString ();
310
435
}
311
- double TaskFemConstraintRigidBody::get_xMoment () const
436
+
437
+ std::string TaskFemConstraintRigidBody::getMoment () const
312
438
{
313
- return ui->if_rot_force_x -> rawValue ();
439
+ return ui->qsb_moment -> value (). getSafeUserString (). toStdString ();
314
440
}
315
- double TaskFemConstraintRigidBody::get_yMoment () const
441
+
442
+ std::string TaskFemConstraintRigidBody::getFreeTranslationalMode () const
316
443
{
317
- return ui->if_rot_force_y -> rawValue ();
444
+ return ui->cb_trans_mode -> currentText (). toStdString ();
318
445
}
319
- double TaskFemConstraintRigidBody::get_zMoment () const
446
+
447
+ std::string TaskFemConstraintRigidBody::getFreeRotationalMode () const
320
448
{
321
- return ui->if_rot_force_z -> rawValue ();
449
+ return ui->cb_rotation_mode -> currentText (). toStdString ();
322
450
}
323
- // TODO: This needs to be implemented
324
- bool TaskFemConstraintRigidBody::get_DefineRefNode () const
451
+
452
+ std::string TaskFemConstraintRigidBody::getLoadMode () const
325
453
{
326
- return true ;
454
+ return ui-> cb_load_mode -> currentText (). toStdString () ;
327
455
}
328
456
329
457
bool TaskFemConstraintRigidBody::event (QEvent* e)
@@ -381,52 +509,80 @@ bool TaskDlgFemConstraintRigidBody::accept()
381
509
const TaskFemConstraintRigidBody* parameters =
382
510
static_cast <const TaskFemConstraintRigidBody*>(parameter);
383
511
try {
512
+ Base::Vector3d ref = parameters->getReferenceNode ();
384
513
Gui::Command::doCommand (Gui::Command::Doc,
385
- " App.ActiveDocument.%s.xRefNode = %f " ,
514
+ " App.ActiveDocument.%s.ReferenceNode = App.Vector(%f, %f, %f) " ,
386
515
name.c_str (),
387
- parameters-> get_xRefNode ());
388
- Gui::Command::doCommand (Gui::Command::Doc ,
389
- " App.ActiveDocument.%s.yRefNode = %f " ,
390
- name. c_str (),
391
- parameters->get_yRefNode () );
516
+ ref. x ,
517
+ ref. y ,
518
+ ref. z );
519
+
520
+ Base::Vector3d disp = parameters->getDisplacement ( );
392
521
Gui::Command::doCommand (Gui::Command::Doc,
393
- " App.ActiveDocument.%s.zRefNode = %f " ,
522
+ " App.ActiveDocument.%s.Displacement = App.Vector(%f, %f, %f) " ,
394
523
name.c_str (),
395
- parameters->get_zRefNode ());
524
+ disp.x ,
525
+ disp.y ,
526
+ disp.z );
527
+
528
+ Base::Rotation rot = parameters->getRotation ();
529
+ Base::Vector3d axis;
530
+ double angle;
531
+ rot.getValue (axis, angle);
532
+ Gui::Command::doCommand (
533
+ Gui::Command::Doc,
534
+ " App.ActiveDocument.%s.Rotation = App.Rotation(App.Vector(%f,% f, %f), Radian=%f)" ,
535
+ name.c_str (),
536
+ axis.x ,
537
+ axis.y ,
538
+ axis.z ,
539
+ angle);
540
+
396
541
Gui::Command::doCommand (Gui::Command::Doc,
397
- " App.ActiveDocument.%s.xForce = %f " ,
542
+ " App.ActiveDocument.%s.Force = \" %s \" " ,
398
543
name.c_str (),
399
- parameters->get_xForce ());
544
+ parameters->getForce ().c_str ());
545
+
546
+ Base::Vector3d forceDir = parameters->getForceDirection ();
400
547
Gui::Command::doCommand (Gui::Command::Doc,
401
- " App.ActiveDocument.%s.yForce = %f " ,
548
+ " App.ActiveDocument.%s.ForceDirection = App.Vector(%f, %f, %f) " ,
402
549
name.c_str (),
403
- parameters->get_yForce ());
550
+ forceDir.x ,
551
+ forceDir.y ,
552
+ forceDir.z );
553
+
404
554
Gui::Command::doCommand (Gui::Command::Doc,
405
- " App.ActiveDocument.%s.zForce = %f " ,
555
+ " App.ActiveDocument.%s.Moment = \" %s \" " ,
406
556
name.c_str (),
407
- parameters->get_zForce ());
557
+ parameters->getMoment ().c_str ());
558
+
559
+ Base::Vector3d momentDir = parameters->getMomentDirection ();
408
560
Gui::Command::doCommand (Gui::Command::Doc,
409
- " App.ActiveDocument.%s.xMoment = %f " ,
561
+ " App.ActiveDocument.%s.MomentDirection = App.Vector(%f, %f, %f) " ,
410
562
name.c_str (),
411
- parameters->get_xMoment ());
563
+ momentDir.x ,
564
+ momentDir.y ,
565
+ momentDir.z );
566
+
412
567
Gui::Command::doCommand (Gui::Command::Doc,
413
- " App.ActiveDocument.%s.yMoment = %f " ,
568
+ " App.ActiveDocument.%s.FreeTranslationalMode = \" %s \" " ,
414
569
name.c_str (),
415
- parameters->get_yMoment ());
570
+ parameters->getFreeTranslationalMode ().c_str ());
571
+
416
572
Gui::Command::doCommand (Gui::Command::Doc,
417
- " App.ActiveDocument.%s.zMoment = %f " ,
573
+ " App.ActiveDocument.%s.FreeRotationalMode = \" %s \" " ,
418
574
name.c_str (),
419
- parameters->get_zMoment ());
575
+ parameters->getFreeRotationalMode ().c_str ());
576
+
420
577
Gui::Command::doCommand (Gui::Command::Doc,
421
- " App.ActiveDocument.%s.DefineRefNode = %s " ,
578
+ " App.ActiveDocument.%s.LoadMode = \" %s \" " ,
422
579
name.c_str (),
423
- parameters->get_DefineRefNode () ? " True " : " False " );
580
+ parameters->getLoadMode (). c_str () );
424
581
425
- std::string scale = parameters->getScale (); // OvG: determine modified scale
426
582
Gui::Command::doCommand (Gui::Command::Doc,
427
583
" App.ActiveDocument.%s.Scale = %s" ,
428
584
name.c_str (),
429
- scale .c_str ()); // OvG: implement modified scale
585
+ parameters-> getScale () .c_str ());
430
586
}
431
587
catch (const Base::Exception& e) {
432
588
QMessageBox::warning (parameter, tr (" Input error" ), QString::fromLatin1 (e.what ()));
0 commit comments