diff --git a/src/src/UI/Widget/Measure/pqFontPropertyWidget.cpp b/src/src/UI/Widget/Measure/pqFontPropertyWidget.cpp index b61da85..86f6307 100644 --- a/src/src/UI/Widget/Measure/pqFontPropertyWidget.cpp +++ b/src/src/UI/Widget/Measure/pqFontPropertyWidget.cpp @@ -3,15 +3,6 @@ #include #include "qcolordialog.h" -//pqFontPropertyWidget* pqFontPropertyWidget::instance = nullptr; -//pqFontPropertyWidget* pqFontPropertyWidget::GetInstance() { -// //lazy man -// if (!instance) { -// instance = new pqFontPropertyWidget(); -// } -// return instance; -//} - pqFontPropertyWidget* pqFontPropertyWidget::propDlg = nullptr; pqFontPropertyWidget* pqFontPropertyWidget::GetPropDlg() { @@ -27,29 +18,9 @@ pqFontPropertyWidget::pqFontPropertyWidget(QWidget *parent) { ui.setupUi(this); - ui.cbx_FontFamily->addItem("Arial"); - ui.cbx_FontFamily->addItem("Courier"); - ui.cbx_FontFamily->addItem("Times"); - connect(ui.pbtn_Accept, SIGNAL(clicked()), this, SLOT(SetTextInput())); - connect(ui.pbtn_Reset, SIGNAL(clicked()), this, SLOT(ResetText())); - - connect(ui.cbx_FontFamily, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFontFamily(int))); - connect(ui.spx_FontSize, SIGNAL(valueChanged(int)), this, SLOT(SetFontSize(int))); - connect(ui.dspx_Opacity, SIGNAL(valueChanged(double)), this, SLOT(SetOpacity(double))); - - connect(ui.tbtn_Bold, SIGNAL(clicked(bool)), this, SLOT(BoldOn(bool))); - connect(ui.tbnt_Italics, SIGNAL(clicked(bool)), this, SLOT(ItalicOn(bool))); - connect(ui.tbtn_Shadow, SIGNAL(clicked(bool)), this, SLOT(ShadowOn(bool))); - - connect(ui.pbtn_FontColor, SIGNAL(clicked()), this, SLOT(ColorChooser())); - //connect(ui.cbx_FontColor, SIGNAL(currentIndexChanged(int)), this, SLOT(ColorEditor())); - + connect(ui.pbtn_Delete, SIGNAL(clicked()), this, SLOT(cancel())); setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint); - - //QRect rect(0, 0, 32, 26); - //QRegion region(rect, QRegion::Ellipse); - //ui.pbtn_FontColor->setMask(region); } pqFontPropertyWidget::~pqFontPropertyWidget() @@ -57,69 +28,27 @@ pqFontPropertyWidget::~pqFontPropertyWidget() delete propDlg; } -void pqFontPropertyWidget::ResetText() -{ - if (this->textActor) - { - this->textActor->ResetTextProp(); - this->tRender->Render(); - reloadProperties(); - } -} - void pqFontPropertyWidget::SetTextInput() { if (this->textActor) { QString qstr = ui.led_TextInput->text(); - QByteArray ba = qstr.toUtf8(); - - this->textActor->SetTextInput(ba.constData()); - this->tRender->Render(); + if(qstr.isEmpty()) + { + return; + } + QByteArray ba = qstr.toLatin1(); + this->textActor->SetTextInput(ba.data()); + this->tRender->Render(); } - - + accept(); } - - - -//void pqFontPropertyWidget::ColorEditor() -//{ -// if (this->textActor) -// { -// QColor color = ui.cbx_FontColor->color(); -// this->textActor->GetTextPropty()->SetColor(color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0); -// this->viewer->Render(); -// } -//} - - -void pqFontPropertyWidget::ColorChooser() +void pqFontPropertyWidget::cancel() { - QColor color = QColorDialog::getColor(Qt::white, this); - if (this->textActor) - { - this->textActor->GetTextProp()->SetColor(color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0); - //ui.cbx_FontColor->setColor(color); - this->tRender->Render(); - } - char str[200]; - sprintf_s(str, - "background-color: rgb(%d, %d, %d);\ - border-style: solid;\ - border-width:2px;\ - border-radius:12px;\ - border-color: black;\ - max-width:20px;\ - max-height:20px;\ - min-width:20px;\ - min-height:20px;" - ,color.red(), color.green(), color.blue()); - ui.pbtn_FontColor->setStyleSheet(str); + QDialog::reject(); } - void pqFontPropertyWidget::SetTextActor(TextAnnotationActor* t_actor) { if (this->textActor) @@ -134,136 +63,10 @@ void pqFontPropertyWidget::SetTextActor(TextAnnotationActor* t_actor) void pqFontPropertyWidget::SetRenderWindowInteractor(vtkRenderWindowInteractor* iren) { this->tRender = iren; - //reloadProperties(); } -//void pqFontPropertyWidget::SetViewer(DicomImageView* v) { -// this->viewer = v; -//} - void pqFontPropertyWidget::reloadProperties() { vtkTextProperty *tprop = this->textActor->GetTextProp(); - - //char * str = vtkTextMapper::SafeDownCast(this->textActor->GetTextProp())->GetInput(); - ui.led_TextInput->setText(this->textActor->GetTextInput()); - ui.spx_FontSize->setValue(tprop->GetFontSize()); - ui.dspx_Opacity->setValue(tprop->GetOpacity()); - - ui.tbtn_Bold->setChecked(tprop->GetBold()); - ui.tbnt_Italics->setChecked(tprop->GetItalic()); - ui.tbtn_Shadow->setChecked(tprop->GetShadow()); - - - double *dcolor = tprop->GetColor(); - QColor color(dcolor[0]*255.0, dcolor[1] * 255.0, dcolor[2] * 255.0); - char str[200]; - sprintf_s(str, - "background-color: rgb(%d, %d, %d);\ - border-style: solid;\ - border-width:2px;\ - border-radius:12px;\ - border-color: black;\ - max-width:20px;\ - max-height:20px;\ - min-width:20px;\ - min-height:20px;" - , color.red(), color.green(), color.blue()); - ui.pbtn_FontColor->setStyleSheet(str); - } - -void pqFontPropertyWidget::SetFontSize(int size_) { - if (this->textActor) - { - this->textActor->GetTextProp()->SetFontSize(size_); - this->tRender->Render(); - } -} - -void pqFontPropertyWidget::SetOpacity(double opacity_) -{ - if (this->textActor) - { - this->textActor->GetTextProp()->SetOpacity(opacity_); - this->tRender->Render(); - } - -} - -void pqFontPropertyWidget::SetFontFamily(int index) -{ - - if (this->textActor) - { - switch (index) - { - case(VTK_ARIAL): - this->textActor->GetTextProp()->SetFontFamilyToArial(); - break; - case(VTK_COURIER): - this->textActor->GetTextProp()->SetFontFamilyToCourier(); - break; - case(VTK_TIMES): - this->textActor->GetTextProp()->SetFontFamilyToTimes(); - break; - default: - this->textActor->GetTextProp()->SetFontFamilyToArial(); - break; - } - this->tRender->Render(); - } -} -void pqFontPropertyWidget::BoldOn(bool bold_) -{ - if (this->textActor) - { - if (bold_) - { - this->textActor->GetTextProp()->BoldOn(); - } - else - { - this->textActor->GetTextProp()->BoldOff(); - } - this->tRender->Render(); - } -} - -void pqFontPropertyWidget::ItalicOn(bool italic_) -{ - if (this->textActor) - { - if (italic_) - { - this->textActor->GetTextProp()->ItalicOn(); - } - else - { - this->textActor->GetTextProp()->ItalicOff(); - } - this->tRender->Render(); - } - -} - - -void pqFontPropertyWidget::ShadowOn(bool shadow_) -{ - if (this->textActor) - { - if (shadow_) - { - this->textActor->GetTextProp()->ShadowOn(); - } - else - { - this->textActor->GetTextProp()->ShadowOff(); - } - this->tRender->Render(); - } -} - - - diff --git a/src/src/UI/Widget/Measure/pqFontPropertyWidget.h b/src/src/UI/Widget/Measure/pqFontPropertyWidget.h index 089c41e..f466ff3 100644 --- a/src/src/UI/Widget/Measure/pqFontPropertyWidget.h +++ b/src/src/UI/Widget/Measure/pqFontPropertyWidget.h @@ -21,16 +21,8 @@ public: //void SetViewer(DicomImageView*); void reloadProperties(); public slots: - void SetFontSize(int); - void SetOpacity(double); - void SetFontFamily(int); - void BoldOn(bool); - void ItalicOn(bool); - void ShadowOn(bool); - //void ColorEditor(); - void ColorChooser(); void SetTextInput(); - void ResetText(); + void cancel(); private: static pqFontPropertyWidget *propDlg; diff --git a/src/src/UI/Widget/Measure/pqFontPropertyWidget.ui b/src/src/UI/Widget/Measure/pqFontPropertyWidget.ui index f914f9f..0ee67f7 100644 --- a/src/src/UI/Widget/Measure/pqFontPropertyWidget.ui +++ b/src/src/UI/Widget/Measure/pqFontPropertyWidget.ui @@ -7,7 +7,7 @@ 0 0 500 - 136 + 79 @@ -44,7 +44,7 @@ Apply - + :/pqWidgets/Icon/pq/pqApply.png:/pqWidgets/Icon/pq/pqApply.png @@ -52,155 +52,24 @@ - - - - Resets any changed properties to their values from the last time 'Apply' was clicked. - - - Reset - - - - :/pqWidgets/Icon/pq/pqCancel.png:/pqWidgets/Icon/pq/pqCancel.png - - - - Delete + Cancel - + :/pqWidgets/Icon/pq/pqDelete.png:/pqWidgets/Icon/pq/pqDelete.png - - - - - - - Select font - - - QComboBox::AdjustToContents - - - 2 - - - - - - - Set font size - - - 1 - - - - - - - true - - - - 0 - 0 - - - - - 0 - 0 - - - - - - - - - - - - - - Set font opacity - - - 1.000000000000000 - - - 0.100000000000000 - - - - - - - Bold - - - ... - - - - :/pqWidgets/Icon/pq/pqBold24.png:/pqWidgets/Icon/pq/pqBold24.png - - - true - - - - - - - Italics - - - ... - - - - :/pqWidgets/Icon/pq/pqItalics24.png:/pqWidgets/Icon/pq/pqItalics24.png - - - true - - - - - - - Shadow - - - ... - - - - :/pqWidgets/Icon/pq/pqShadow24.png:/pqWidgets/Icon/pq/pqShadow24.png - - - true - - - - - - - + +