@@ -122,10 +122,10 @@ ShowAndEditDipoles::ShowAndEditDipoles()
122122 greenCol_ = ColorRGB (0.2 , 0.8 , 0.2 );
123123 resizeCol_ = ColorRGB (0.54 , 1.0 , 0.60 );
124124
125- sphereRadius_ = 1.0 ;
126- cylinderRadius_ = 0.5 ;
127- coneRadius_ = 1.0 ;
128- diskRadius_ = 1.0 ;
125+ sphereRadius_ = 0.25 ;
126+ cylinderRadius_ = 0.12 ;
127+ coneRadius_ = 0.25 ;
128+ diskRadius_ = 0.25 ;
129129 diskDistFromCenter_ = 0.85 ;
130130 diskWidth_ = 0.05 ;
131131 widgetID_ = 0 ;
@@ -134,9 +134,10 @@ ShowAndEditDipoles::ShowAndEditDipoles()
134134void ShowAndEditDipoles::setStateDefaults ()
135135{
136136 auto state = get_state ();
137- state->setValue (NumSeeds, 1 );
137+ state->setValue (WidgetSize, 0.23 );
138+ state->setValue (Sizing, 0 );
138139 state->setValue (ShowLastAsVector, false );
139- state->setValue (ProbeScale, 0.23 );
140+ state->setValue (ShowLines, false );
140141 state->setValue (PointPositions, VariableList ());
141142
142143 getOutputPort (DipoleWidget)->connectConnectionFeedbackListener ([this ](const ModuleFeedback& var) { processWidgetFeedback (var); });
@@ -211,9 +212,15 @@ void ShowAndEditDipoles::adjustPositionFromTransform(const Transform& transformM
211212 {
212213 // Sphere and Cylinder reposition dipole
213214 case WidgetSection::SPHERE:
214- case WidgetSection::CYLINDER:
215215 pos_ = newPoint;
216216 break ;
217+ case WidgetSection::CYLINDER:
218+ {
219+ double scale = get_state ()->getValue (WidgetSize).toDouble ();
220+ // Shift direction back because newPos is the center of the cylinder
221+ pos_ = newPoint - 1.375 * direction_ * scale * sphereRadius_;
222+ break ;
223+ }
217224 // Cone rotates dipole
218225 case WidgetSection::CONE:
219226 direction_ = (newPoint - pos_).normal () * direction_.length ();
@@ -224,6 +231,9 @@ void ShowAndEditDipoles::adjustPositionFromTransform(const Transform& transformM
224231 Vector newVec (newPoint-pos_);
225232 newVec /= diskDistFromCenter_;
226233 direction_ = Dot (newVec, direction_.normal ()) * direction_.normal ();
234+
235+ double scale = get_state ()->getValue (WidgetSize).toDouble ();
236+ direction_ /= scale;
227237 break ;
228238 }
229239 }
@@ -234,9 +244,12 @@ FieldHandle ShowAndEditDipoles::GenerateOutputField()
234244 auto ifieldhandle = getRequiredInput (DipoleInputField);
235245 auto bbox = ifieldhandle->vmesh ()->get_bounding_box ();
236246
247+ auto state = get_state ();
248+ double scale = state->getValue (WidgetSize).toDouble ();
249+ Vector scaled_dir = direction_ * scale;
237250 Point center;
238251 Point bmin = pos_;
239- Point bmax = pos_ + direction_ ;
252+ Point bmax = pos_ + scaled_dir ;
240253
241254 // Fix degenerate boxes.
242255 const double size_estimate = std::max ((bmax - bmin).length () * 0.01 , 1.0e-5 );
@@ -256,13 +269,11 @@ FieldHandle ShowAndEditDipoles::GenerateOutputField()
256269 bmax.z (bmax.z () + size_estimate);
257270 }
258271
259- center = pos_ + direction_ /2.0 ;
272+ center = pos_ + scaled_dir /2.0 ;
260273
261274 impl_->l2norm_ = (bmax - bmin).length ();
262275 impl_->last_bounds_ = bbox;
263276
264- auto state = get_state ();
265- auto scale = state->getValue (ProbeScale).toDouble ();
266277 auto widgetName = [](int i, int id) { return " SAED(" + std::to_string (i) + " )" + std::to_string (id); };
267278 impl_->pointWidgets_ .resize (0 );
268279
@@ -271,42 +282,45 @@ FieldHandle ShowAndEditDipoles::GenerateOutputField()
271282 (WidgetFactory::createSphere (
272283 *this ,
273284 widgetName (WidgetSection::SPHERE, widgetID_),
274- sphereRadius_ * direction_ .length () * scale ,
285+ sphereRadius_ * scaled_dir .length (),
275286 deflPointCol_.toString (),
276287 pos_,
277288 bbox)));
278289
279290 if (state->getValue (ShowLastAsVector).toBool ())
280291 {
292+ // Starts the cylinder position closer to the surface of the sphere
293+ Point cylinderStart = pos_ + 0.75 * (scaled_dir * sphereRadius_);
294+
281295 impl_->pointWidgets_ .push_back (boost::dynamic_pointer_cast<WidgetBase>
282296 (WidgetFactory::createCylinder (
283297 *this ,
284298 widgetName (WidgetSection::CYLINDER, widgetID_),
285- cylinderRadius_ * direction_ .length () * scale ,
299+ cylinderRadius_ * scaled_dir .length (),
286300 deflCol_.toString (),
287- pos_ ,
301+ cylinderStart ,
288302 center,
289303 bbox)));
290304 impl_->pointWidgets_ .push_back (boost::dynamic_pointer_cast<WidgetBase>
291305 (WidgetFactory::createCone (
292306 *this ,
293307 widgetName (WidgetSection::CONE, widgetID_),
294- coneRadius_ * direction_ .length () * scale ,
308+ coneRadius_ * scaled_dir .length (),
295309 deflCol_.toString (),
296310 center,
297311 bmax,
298312 bbox,
299313 true )));
300314
301- Point diskPos = pos_ + direction_ * diskDistFromCenter_;
302- Point dp1 = diskPos - diskWidth_ * direction_ ;
303- Point dp2 = diskPos + diskWidth_ * direction_ ;
315+ Point diskPos = pos_ + scaled_dir * diskDistFromCenter_;
316+ Point dp1 = diskPos - diskWidth_ * scaled_dir ;
317+ Point dp2 = diskPos + diskWidth_ * scaled_dir ;
304318
305319 impl_->pointWidgets_ .push_back (boost::dynamic_pointer_cast<WidgetBase>
306320 (WidgetFactory::createDisk (
307321 *this ,
308322 widgetName (WidgetSection::DISK, widgetID_),
309- diskRadius_ * direction_ .length () * scale ,
323+ diskRadius_ * scaled_dir .length (),
310324 resizeCol_.toString (),
311325 dp1,
312326 dp2,
@@ -328,12 +342,11 @@ FieldHandle ShowAndEditDipoles::GenerateOutputField()
328342}
329343
330344
345+ const AlgorithmParameterName ShowAndEditDipoles::WidgetSize (" WidgetSize" );
331346const AlgorithmParameterName ShowAndEditDipoles::Sizing (" Sizing" );
332347const AlgorithmParameterName ShowAndEditDipoles::ShowLastAsVector (" ShowLastAsVector" );
333348const AlgorithmParameterName ShowAndEditDipoles::ShowLines (" ShowLines" );
334- const AlgorithmParameterName ShowAndEditDipoles::ProbeScale (" ProbeScale" );
335349const AlgorithmParameterName ShowAndEditDipoles::PointPositions (" PointPositions" );
336- const AlgorithmParameterName ShowAndEditDipoles::NumSeeds (" NumSeeds" );
337350
338351
339352
0 commit comments