@@ -128,6 +128,13 @@ LabelImages_Descriptor::LabelImages_Descriptor()
128128
129129#define ADD_OPTION (x ) m_options.add_option(x, #x)
130130
131+ IntegerEnumDropdownDatabase create_label_type_database (){
132+ IntegerEnumDropdownDatabase database;
133+ database.add (0 , " pokemon-form" , Pokemon::STRING_POKEMON + " Forms" );
134+ database.add (1 , " custom-set" , " Custom Set" );
135+ return database;
136+ }
137+
131138LabelImages::LabelImages (const LabelImages_Descriptor& descriptor)
132139 : PanelInstance(descriptor)
133140 , m_display_session(m_display_option)
@@ -136,6 +143,8 @@ LabelImages::LabelImages(const LabelImages_Descriptor& descriptor)
136143 , Y(" <b>Y Coordinate:</b>" , LockMode::UNLOCK_WHILE_RUNNING, 0.3 , 0.0 , 1.0 )
137144 , WIDTH(" <b>Width:</b>" , LockMode::UNLOCK_WHILE_RUNNING, 0.4 , 0.0 , 1.0 )
138145 , HEIGHT(" <b>Height:</b>" , LockMode::UNLOCK_WHILE_RUNNING, 0.4 , 0.0 , 1.0 )
146+ , LABEL_TYPE_DATABASE(create_label_type_database())
147+ , LABEL_TYPE(" <b>Select Label:</b>" , LABEL_TYPE_DATABASE, LockMode::UNLOCK_WHILE_RUNNING, 0 )
139148 , FORM_LABEL(" bulbasaur" )
140149 , CUSTOM_LABEL_DATABASE(create_string_select_database({
141150 " sun" ,
@@ -147,9 +156,12 @@ LabelImages::LabelImages(const LabelImages_Descriptor& descriptor)
147156 ADD_OPTION (Y);
148157 ADD_OPTION (WIDTH);
149158 ADD_OPTION (HEIGHT);
159+ ADD_OPTION (LABEL_TYPE);
150160 ADD_OPTION (FORM_LABEL);
151161 ADD_OPTION (CUSTOM_LABEL);
152162
163+ LABEL_TYPE.add_listener (*this );
164+
153165 // , m_sam_session{RESOURCE_PATH() + "ML/sam_cpu.onnx"}
154166 const std::string sam_model_path = RESOURCE_PATH () + " ML/sam_cpu.onnx" ;
155167 if (std::filesystem::exists (sam_model_path)){
@@ -467,6 +479,19 @@ void LabelImages::select_next_annotation(){
467479 }
468480}
469481
482+ void LabelImages::on_config_value_changed (void * object){
483+ // cout << "LabelImages::on_config_value_changed" << endl;
484+ if (object == &LABEL_TYPE){
485+ if (LABEL_TYPE.current_value () == 0 ){
486+ FORM_LABEL.set_visibility (ConfigOptionState::ENABLED);
487+ CUSTOM_LABEL.set_visibility (ConfigOptionState::DISABLED);
488+ } else {
489+ FORM_LABEL.set_visibility (ConfigOptionState::DISABLED);
490+ CUSTOM_LABEL.set_visibility (ConfigOptionState::ENABLED);
491+ }
492+ }
493+ }
494+
470495
471496LabelImages_Widget::~LabelImages_Widget (){
472497 m_program.X .remove_listener (*this );
@@ -547,26 +572,15 @@ LabelImages_Widget::LabelImages_Widget(
547572 QHBoxLayout* annotation_row = new QHBoxLayout ();
548573 scroll_layout->addLayout (annotation_row);
549574
550- annotation_row->addWidget (new QLabel (" <b>Select Label:</b>" , scroll_inner), 0 );
551-
552- // add a group box for user to pick whether to choose from pokemon form label or custom label
553- QGroupBox* label_type_group = new QGroupBox ();
554- QRadioButton* pokemon_radio_button = new QRadioButton (QString::fromStdString (Pokemon::STRING_POKEMON + " Forms" ));
555- QRadioButton* custom_label_radio_button = new QRadioButton (" Custom Set" );
556- pokemon_radio_button->setChecked (true );
557-
558- QHBoxLayout* group_box_layout = new QHBoxLayout;
559- group_box_layout->addWidget (pokemon_radio_button);
560- group_box_layout->addWidget (custom_label_radio_button);
561- label_type_group->setLayout (group_box_layout);
562- annotation_row->addWidget (label_type_group);
575+ // add a dropdown menu for user to pick whether to choose from pokemon form label or custom label
576+ ConfigWidget* label_type_widget = program.LABEL_TYPE .make_QtWidget (*scroll_inner);
577+ annotation_row->addWidget (&label_type_widget->widget (), 0 );
563578
564579 ConfigWidget* pokemon_label_widget = program.FORM_LABEL .make_QtWidget (*scroll_inner);
565580 annotation_row->addWidget (&pokemon_label_widget->widget (), 2 );
566581 ConfigWidget* custom_label_widget = program.CUSTOM_LABEL .make_QtWidget (*scroll_inner);
567582 annotation_row->addWidget (&custom_label_widget->widget (), 2 );
568- // disable the custom label widget to correpsond to the default selection of label_type_group
569- custom_label_widget->widget ().setEnabled (false );
583+ annotation_row->addWidget (new QLabel (scroll_inner), 10 ); // an empty label to push other UIs to the left
570584
571585 // add compute embedding button
572586
@@ -590,15 +604,6 @@ LabelImages_Widget::LabelImages_Widget(
590604 program.update_rendered_objects (this ->m_overlay_set );
591605 });
592606
593- connect (pokemon_radio_button, &QPushButton::clicked, this , [pokemon_label_widget, custom_label_widget](bool ){
594- pokemon_label_widget->widget ().setEnabled (true );
595- custom_label_widget->widget ().setEnabled (false );
596- });
597- connect (custom_label_radio_button, &QPushButton::clicked, this , [pokemon_label_widget, custom_label_widget](bool ){
598- pokemon_label_widget->widget ().setEnabled (false );
599- custom_label_widget->widget ().setEnabled (true );
600- });
601-
602607 connect (compute_embedding_button, &QPushButton::clicked, this , [this ](bool ){
603608 std::string folder_path = QFileDialog::getExistingDirectory (
604609 nullptr , " Open image folder" , " ." ).toStdString ();
0 commit comments