]> Shamusworld >> Repos - architektonas/blobdiff - src/widgets/qg_dialogfactory.cpp
Changed RS_Graphic to Drawing; this is less confusing as a drawing is
[architektonas] / src / widgets / qg_dialogfactory.cpp
index e267e6a3417678f75267381a025012d3b491d47c..f698cdb363eb8c51ee613894c441f844d6ba4f5b 100644 (file)
 
 #include "qg_dialogfactory.h"
 
+#include "qg_layerwidget.h"
+#include "qg_mainwindowinterface.h"
+#include "rs_actiondimlinear.h"
+#include "rs_actioninterface.h"
+#include "rs_document.h"
 #include "rs_patternlist.h"
 #include "settings.h"
 #include "rs_system.h"
-#include "rs_actioninterface.h"
-#include "rs_document.h"
-#include "rs_actiondimlinear.h"
+#include "rs_text.h"
 
 #if 0
 #include "ui/qg_arcoptions.h"
 #include "rs_camdialog.h"
 #endif
 
-#include "qg_layerwidget.h"
-#include "qg_mainwindowinterface.h"
-
 //QG_DialogFactory* QG_DialogFactory::uniqueInstance = NULL;
 
 /**
@@ -1877,9 +1877,179 @@ bool QG_DialogFactory::requestRotate2Dialog(RS_Rotate2Data & data)
        return false;
 }
 
+/**
+ * Shows a dialog to edit the given entity.
+ */
 bool QG_DialogFactory::requestModifyEntityDialog(RS_Entity * entity)
 {
-       return false;
+       if (entity == NULL)
+               return false;
+
+       bool ret = false;
+
+       switch (entity->rtti())
+       {
+//NOTE: These #if 0's are put here until these missing dialogs can be ported to Qt4.
+#if 0
+       case RS2::EntityPoint:
+       {
+               QG_DlgPoint dlg(parent);
+               dlg.setPoint(*((RS_Point *)entity));
+
+               if (dlg.exec())
+               {
+                       dlg.updatePoint();
+                       ret = true;
+               }
+       }
+               break;
+
+       case RS2::EntityLine:
+       {
+               QG_DlgLine dlg(parent);
+               dlg.setLine(*((RS_Line *)entity));
+
+               if (dlg.exec())
+               {
+                       dlg.updateLine();
+                       ret = true;
+               }
+       }
+               break;
+
+       case RS2::EntityArc:
+       {
+               QG_DlgArc dlg(parent);
+               dlg.setArc(*((RS_Arc *)entity));
+
+               if (dlg.exec())
+               {
+                       dlg.updateArc();
+                       ret = true;
+               }
+       }
+               break;
+
+       case RS2::EntityCircle:
+       {
+               QG_DlgCircle dlg(parent);
+               dlg.setCircle(*((RS_Circle *)entity));
+
+               if (dlg.exec())
+               {
+                       dlg.updateCircle();
+                       ret = true;
+               }
+       }
+               break;
+
+       case RS2::EntityEllipse:
+       {
+               QG_DlgEllipse dlg(parent);
+               dlg.setEllipse(*((RS_Ellipse *)entity));
+
+               if (dlg.exec())
+               {
+                       dlg.updateEllipse();
+                       ret = true;
+               }
+       }
+               break;
+
+       case RS2::EntitySpline:
+       {
+               QG_DlgSpline dlg(parent);
+               dlg.setSpline(*((RS_Spline *)entity));
+
+               if (dlg.exec())
+               {
+                       dlg.updateSpline();
+                       ret = true;
+               }
+       }
+               break;
+
+       case RS2::EntityInsert:
+       {
+               QG_DlgInsert dlg(parent);
+               dlg.setInsert(*((RS_Insert *)entity));
+
+               if (dlg.exec())
+               {
+                       dlg.updateInsert();
+                       ret = true;
+                       entity->update();
+               }
+       }
+               break;
+
+       case RS2::EntityDimAligned:
+       case RS2::EntityDimAngular:
+       case RS2::EntityDimDiametric:
+       case RS2::EntityDimRadial:
+       {
+               QG_DlgDimension dlg(parent);
+               dlg.setDim(*((RS_Dimension *)entity));
+
+               if (dlg.exec())
+               {
+                       dlg.updateDim();
+                       ret = true;
+                       ((RS_Dimension *)entity)->update(true);
+               }
+       }
+               break;
+
+       case RS2::EntityDimLinear:
+       {
+               QG_DlgDimLinear dlg(parent);
+               dlg.setDim(*((RS_DimLinear *)entity));
+
+               if (dlg.exec())
+               {
+                       dlg.updateDim();
+                       ret = true;
+                       ((RS_DimLinear *)entity)->update(true);
+               }
+       }
+               break;
+#endif
+
+       case RS2::EntityText:
+       {
+               DlgText dlg(parent);
+               dlg.setText(*((RS_Text *)entity), false);
+
+               if (dlg.exec())
+               {
+                       dlg.updateText();
+                       ret = true;
+                       ((RS_Text *)entity)->update();
+               }
+       }
+               break;
+
+#if 0
+       case RS2::EntityHatch:
+       {
+               QG_DlgHatch dlg(parent);
+               dlg.setHatch(*((RS_Hatch *)entity), false);
+
+               if (dlg.exec())
+               {
+                       dlg.updateHatch();
+                       ret = true;
+                       ((RS_Hatch *)entity)->update();
+               }
+       }
+               break;
+#endif
+
+       default:
+               break;
+       }
+
+       return ret;
 }
 
  /*
@@ -1918,7 +2088,7 @@ bool QG_DialogFactory::requestHatchDialog(RS_Hatch * hatch)
 /**
  * Shows a dialog for CAM options.
  */
-bool QG_DialogFactory::requestCamOptionsDialog(RS_Graphic& graphic)
+bool QG_DialogFactory::requestCamOptionsDialog(Drawing& graphic)
 {
        RS_DEBUG->print("QG_DialogFactory::requestCamOptionsDialog");
        RS_CamDialog dlg(graphic, parent);
@@ -1947,7 +2117,7 @@ void QG_DialogFactory::requestOptionsGeneralDialog()
 /**
  * Shows dialog for drawing options.
  */
-void QG_DialogFactory::requestOptionsDrawingDialog(RS_Graphic & graphic)
+void QG_DialogFactory::requestOptionsDrawingDialog(Drawing & graphic)
 {
        DlgOptionsDrawing dlg(parent);
        dlg.setGraphic(&graphic);