From 7703d00bf6f36bb48a72298c9a680db0c2b0d4b1 Mon Sep 17 00:00:00 2001
From: Robert Lichtenberger <r.lichtenberger@synedra.com>
Date: Tue, 17 Sep 2013 18:16:06 +0200
Subject: [PATCH] Direction enhancements.

---
 librecad/src/lib/gui/rs_graphicview.cpp        |  27 +-
 librecad/src/lib/gui/rs_graphicview.h          |  27 ++
 librecad/src/main/doc_plugin_interface.cpp     |   2 +-
 librecad/src/main/qc_applicationwindow.cpp     |  11 +-
 librecad/src/ui/forms/qg_dlgoptionsgeneral.cpp |  97 ++---
 librecad/src/ui/forms/qg_dlgoptionsgeneral.h   |   2 +
 librecad/src/ui/forms/qg_dlgoptionsgeneral.ui  | 535 ++++++++++++++-----------
 plugins/cam/cam.cpp                            |  80 ++++
 plugins/cam/cam.h                              |  38 ++
 plugins/cam/cam.json                           |   1 +
 plugins/cam/cam.pro                            |  37 ++
 plugins/plugins.pro                            |   1 +
 12 files changed, 549 insertions(+), 309 deletions(-)
 create mode 100644 plugins/cam/cam.cpp
 create mode 100644 plugins/cam/cam.h
 create mode 100644 plugins/cam/cam.json
 create mode 100644 plugins/cam/cam.pro

diff --git a/librecad/src/lib/gui/rs_graphicview.cpp b/librecad/src/lib/gui/rs_graphicview.cpp
index 22d4767..bbd6458 100644
--- a/librecad/src/lib/gui/rs_graphicview.cpp
+++ b/librecad/src/lib/gui/rs_graphicview.cpp
@@ -82,8 +82,11 @@ RS_GraphicView::RS_GraphicView()
     setGridColor(QColor(RS_SETTINGS->readEntry("/GridColor", "#7F7F7F")));
     setMetaGridColor(QColor(RS_SETTINGS->readEntry("/MetaGridColor", "#3F3F3F")));
     setSelectedColor(QColor(RS_SETTINGS->readEntry("/SelectedColor", "#A54747")));
-    setHighlightedColor(QColor(RS_SETTINGS->readEntry("/HighlightedColor",
-                                                      "#739373")));
+	setHighlightedColor(QColor(RS_SETTINGS->readEntry("/HighlightedColor", "#739373")));
+	setStartHandleColor(QColor(RS_SETTINGS->readEntry("/StartHandleColor", "#00FFFF")));
+	setHandleColor(QColor(RS_SETTINGS->readEntry("/HandleColor", "#0000FF")));
+	setEndHandleColor(QColor(RS_SETTINGS->readEntry("/EndHandleColor", "#0000FF")));
+
     RS_SETTINGS->endGroup();
 
     printPreview = false;
@@ -1326,19 +1329,13 @@ void RS_GraphicView::drawEntity(RS_Painter *painter, RS_Entity* e, double& patte
 
             for (int i=0; i<s.getNumber(); ++i) {
                 int sz = -1;
-                RS_Color col = RS_Color(0,0,255);
-                if (e->rtti()==RS2::EntityPolyline) {
-                    if (i==0 || i==s.getNumber()-1) {
-                        if (i==0) {
-                            sz = 4;
-                            col = QColor(0,64,255);
-                        }
-                        else {
-                            sz = 3;
-                            col = QColor(0,0,128);
-                        }
-                    }
-                }
+				RS_Color col = handleColor;
+				if (i == 0) {
+					col = startHandleColor;
+				}
+				else if (i == s.getNumber() - 1) {
+					col = endHandleColor;
+				}
                 if (getDeleteMode()) {
                     painter->drawHandle(toGui(s.get(i)), background, sz);
                 } else {
diff --git a/librecad/src/lib/gui/rs_graphicview.h b/librecad/src/lib/gui/rs_graphicview.h
index 83e25fe..e090eb1 100644
--- a/librecad/src/lib/gui/rs_graphicview.h
+++ b/librecad/src/lib/gui/rs_graphicview.h
@@ -175,6 +175,27 @@ public:
                 highlightedColor = c;
         }
 
+		/**
+		 * Sets the color for the first handle (start vertex)
+		 */
+		void setStartHandleColor(const RS_Color& c) {
+				startHandleColor = c;
+		}
+
+		/**
+		 * Sets the color for handles, that are neither start nor end vertices
+		 */
+		void setHandleColor(const RS_Color& c) {
+				handleColor = c;
+		}
+
+		/**
+		 * Sets the color for the last handle (end vertex)
+		 */
+		void setEndHandleColor(const RS_Color& c) {
+				endHandleColor = c;
+		}
+
     /**
      * This virtual method can be overwritten to set the mouse
      * cursor to the given type.
@@ -462,6 +483,12 @@ protected:
     RS_Color selectedColor;
     /** highlighted color */
     RS_Color highlightedColor;
+	/** Start handle color */
+	RS_Color startHandleColor;
+	/** Intermediate (not start/end vertex) handle color */
+	RS_Color handleColor;
+	/** End handle color */
+	RS_Color endHandleColor;
     /** Grid */
     RS_Grid* grid;
     /**
diff --git a/librecad/src/main/doc_plugin_interface.cpp b/librecad/src/main/doc_plugin_interface.cpp
index d1e7a9e..aafa2be 100644
--- a/librecad/src/main/doc_plugin_interface.cpp
+++ b/librecad/src/main/doc_plugin_interface.cpp
@@ -614,7 +614,7 @@ void Plugin_Entity::updateData(QHash<int, QVariant> *data){
 void Plugin_Entity::getPolylineData(QList<Plug_VertexData> *data){
     if (entity == NULL) return;
     RS2::EntityType et = entity->rtti();
-    if (et != RS2::EntityPolyline) return;
+	if (et != RS2::EntityPolyline && et != RS2::EntitySpline) return;
     RS_Polyline *l = static_cast<RS_Polyline*>(entity);
 
     RS_Entity* nextEntity = 0;
diff --git a/librecad/src/main/qc_applicationwindow.cpp b/librecad/src/main/qc_applicationwindow.cpp
index c7feb0b..25b9683 100644
--- a/librecad/src/main/qc_applicationwindow.cpp
+++ b/librecad/src/main/qc_applicationwindow.cpp
@@ -3726,9 +3726,11 @@ void QC_ApplicationWindow::slotOptionsGeneral() {
     QColor gridColor(RS_SETTINGS->readEntry("/GridColor", "Gray"));
     QColor metaGridColor(RS_SETTINGS->readEntry("/MetaGridColor", "Darkgray"));
     QColor selectedColor(RS_SETTINGS->readEntry("/SelectedColor", "#A54747"));
-    QColor highlightedColor(RS_SETTINGS->readEntry("/HighlightedColor",
-                            "#739373"));
-    RS_SETTINGS->endGroup();
+	QColor highlightedColor(RS_SETTINGS->readEntry("/HighlightedColor", "#739373"));
+	QColor startHandleColor(RS_SETTINGS->readEntry("/StartHandleColor", "#00FFFF"));
+	QColor handleColor(RS_SETTINGS->readEntry("/HandleColor", "#0000FF"));
+	QColor endHandleColor(RS_SETTINGS->readEntry("/EndHandleColor", "#0000FF"));
+	RS_SETTINGS->endGroup();
 
     QList<QMdiSubWindow*> windows = mdiAreaCAD->subWindowList();
     for (int i = 0; i < windows.size(); ++i) {
@@ -3741,6 +3743,9 @@ void QC_ApplicationWindow::slotOptionsGeneral() {
                 gv->setMetaGridColor(metaGridColor);
                 gv->setSelectedColor(selectedColor);
                 gv->setHighlightedColor(highlightedColor);
+				gv->setStartHandleColor(startHandleColor);
+				gv->setHandleColor(handleColor);
+				gv->setEndHandleColor(endHandleColor);
 //                gv->updateGrid();
                 gv->redraw(RS2::RedrawGrid);
             }
diff --git a/librecad/src/ui/forms/qg_dlgoptionsgeneral.cpp b/librecad/src/ui/forms/qg_dlgoptionsgeneral.cpp
index 905d163..3015701 100644
--- a/librecad/src/ui/forms/qg_dlgoptionsgeneral.cpp
+++ b/librecad/src/ui/forms/qg_dlgoptionsgeneral.cpp
@@ -113,54 +113,18 @@ void QG_DlgOptionsGeneral::init() {
     QString minGridSpacing = RS_SETTINGS->readEntry("/MinGridSpacing", "10");
     cbMinGridSpacing->setCurrentIndex( cbMinGridSpacing->findText(minGridSpacing) );
 
-    int idx;
     // preview:
-    QString maxPreview = RS_SETTINGS->readEntry("/MaxPreview", "100");
-    idx= cbMaxPreview->findText(maxPreview) ;
-    if(idx<0) {
-            //not found in combobox, prepend it
-        idx = 0;
-        cbMaxPreview->insertItem( idx,maxPreview);
-    }
-    cbMaxPreview->setCurrentIndex(idx);
+	initComboBox(cbMaxPreview, RS_SETTINGS->readEntry("/MaxPreview", "100"));
 
     // colors:
-    QString backgroundColor = RS_SETTINGS->readEntry("/BackgroundColor", "Black");
-    idx = cbBackgroundColor->findText(backgroundColor);
-    //backgroundColor not present in combobox, prepend it
-    if( idx < 0) {
-        idx =0;
-        cbBackgroundColor->insertItem(idx, backgroundColor);
-    }
-    cbBackgroundColor->setCurrentIndex( idx );
-    QString gridColor = RS_SETTINGS->readEntry("/GridColor", "Gray");
-    idx = cbGridColor->findText(gridColor);
-    if( idx < 0) {
-        idx =0;
-        cbGridColor->insertItem(idx, gridColor);
-    }
-    cbGridColor->setCurrentIndex(idx);
-    QString metaGridColor = RS_SETTINGS->readEntry("/MetaGridColor", "#404040");
-    idx = cbMetaGridColor->findText(metaGridColor);
-    if( idx < 0) {
-        idx =0;
-        cbMetaGridColor->insertItem(idx, metaGridColor);
-    }
-    cbMetaGridColor->setCurrentIndex( idx );
-    QString selectedColor = RS_SETTINGS->readEntry("/SelectedColor", "#a54747");
-    idx = cbSelectedColor->findText(selectedColor);
-    if( idx < 0) {
-        idx =0;
-        cbSelectedColor->insertItem(idx, selectedColor);
-    }
-    cbSelectedColor->setCurrentIndex( idx );
-    QString highlightedColor = RS_SETTINGS->readEntry("/HighlightedColor", "#739373");
-    idx = cbHighlightedColor->findText(highlightedColor);
-    if( idx < 0) {
-        idx =0;
-        cbHighlightedColor->insertItem(idx, highlightedColor);
-    }
-    cbHighlightedColor->setCurrentIndex( idx );
+	initComboBox(cbBackgroundColor, RS_SETTINGS->readEntry("/BackgroundColor", "Black"));
+	initComboBox(cbGridColor, RS_SETTINGS->readEntry("/GridColor", "Gray"));
+	initComboBox(cbMetaGridColor, RS_SETTINGS->readEntry("/MetaGridColor", "#404040"));
+	initComboBox(cbSelectedColor, RS_SETTINGS->readEntry("/SelectedColor", "#a54747"));
+	initComboBox(cbHighlightedColor, RS_SETTINGS->readEntry("/HighlightedColor", "#739373"));
+	initComboBox(cbStartHandleColor, RS_SETTINGS->readEntry("/StartHandleColor", "#00FFFF"));
+	initComboBox(cbHandleColor, RS_SETTINGS->readEntry("/HandleColor", "#0000FF"));
+	initComboBox(cbEndHandleColor, RS_SETTINGS->readEntry("/EndHandleColor", "#0000FF"));
 
     // font size:
     QString sizeStatus = RS_SETTINGS->readEntry("/StatusBarFontSize", "9");
@@ -202,12 +166,22 @@ void QG_DlgOptionsGeneral::init() {
     restartNeeded = false;
 }
 
+void QG_DlgOptionsGeneral::initComboBox(QComboBox* cb, QString text) {
+	int idx = cb->findText(text);
+	if( idx < 0) {
+		idx =0;
+		cb->insertItem(idx, text);
+	}
+	cb->setCurrentIndex( idx );
+}
+
 void QG_DlgOptionsGeneral::destroy() {
 }
 
 void QG_DlgOptionsGeneral::setRestartNeeded() {
     restartNeeded = true;
 }
+
 void QG_DlgOptionsGeneral::setTemplateFile() {
     RS2::FormatType type = RS2::FormatDXFRW;
     QG_FileDialog dlg(this);
@@ -220,26 +194,19 @@ void QG_DlgOptionsGeneral::ok() {
     RS_SETTINGS->beginGroup("/Appearance");
     RS_SETTINGS->writeEntry("/Language",cbLanguage->itemData(cbLanguage->currentIndex()));
     RS_SETTINGS->writeEntry("/LanguageCmd",cbLanguageCmd->itemData(cbLanguageCmd->currentIndex()));
-    RS_SETTINGS->writeEntry("/ShowCrosshairs",
-                            QString("%1").arg((int)cbShowCrosshairs->isChecked()));
-    RS_SETTINGS->writeEntry("/ScaleGrid",
-                            QString("%1").arg((int)cbScaleGrid->isChecked()));
-    RS_SETTINGS->writeEntry("/MinGridSpacing",
-                            cbMinGridSpacing->currentText());
-    RS_SETTINGS->writeEntry("/MaxPreview",
-                            cbMaxPreview->currentText());
-    RS_SETTINGS->writeEntry("/BackgroundColor",
-                            cbBackgroundColor->currentText());
-    RS_SETTINGS->writeEntry("/GridColor",
-                            cbGridColor->currentText());
-    RS_SETTINGS->writeEntry("/MetaGridColor",
-                            cbMetaGridColor->currentText());
-    RS_SETTINGS->writeEntry("/SelectedColor",
-                            cbSelectedColor->currentText());
-    RS_SETTINGS->writeEntry("/HighlightedColor",
-                            cbHighlightedColor->currentText());
-    RS_SETTINGS->writeEntry("/StatusBarFontSize",
-                            cbSizeStatus->currentText());
+	RS_SETTINGS->writeEntry("/ShowCrosshairs", QString("%1").arg((int)cbShowCrosshairs->isChecked()));
+	RS_SETTINGS->writeEntry("/ScaleGrid", QString("%1").arg((int)cbScaleGrid->isChecked()));
+	RS_SETTINGS->writeEntry("/MinGridSpacing", cbMinGridSpacing->currentText());
+	RS_SETTINGS->writeEntry("/MaxPreview", cbMaxPreview->currentText());
+	RS_SETTINGS->writeEntry("/BackgroundColor", cbBackgroundColor->currentText());
+	RS_SETTINGS->writeEntry("/GridColor", cbGridColor->currentText());
+	RS_SETTINGS->writeEntry("/MetaGridColor", cbMetaGridColor->currentText());
+	RS_SETTINGS->writeEntry("/SelectedColor", cbSelectedColor->currentText());
+	RS_SETTINGS->writeEntry("/HighlightedColor", cbHighlightedColor->currentText());
+	RS_SETTINGS->writeEntry("/StartHandleColor", cbStartHandleColor->currentText());
+	RS_SETTINGS->writeEntry("/HandleColor", cbHandleColor->currentText());
+	RS_SETTINGS->writeEntry("/EndHandleColor", cbEndHandleColor->currentText());
+	RS_SETTINGS->writeEntry("/StatusBarFontSize", cbSizeStatus->currentText());
     RS_SETTINGS->endGroup();
 
     RS_SETTINGS->beginGroup("/Paths");
diff --git a/librecad/src/ui/forms/qg_dlgoptionsgeneral.h b/librecad/src/ui/forms/qg_dlgoptionsgeneral.h
index 677555a..13b38d3 100644
--- a/librecad/src/ui/forms/qg_dlgoptionsgeneral.h
+++ b/librecad/src/ui/forms/qg_dlgoptionsgeneral.h
@@ -48,6 +48,8 @@ private:
     bool restartNeeded;
 
     void init();
+	void initComboBox(QComboBox* cb, QString text);
+
     void destroy();
 
 };
diff --git a/librecad/src/ui/forms/qg_dlgoptionsgeneral.ui b/librecad/src/ui/forms/qg_dlgoptionsgeneral.ui
index 1f268bf..08c897e 100644
--- a/librecad/src/ui/forms/qg_dlgoptionsgeneral.ui
+++ b/librecad/src/ui/forms/qg_dlgoptionsgeneral.ui
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>645</width>
-    <height>404</height>
+    <width>643</width>
+    <height>550</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -49,6 +49,9 @@
             </property>
            </widget>
           </item>
+          <item row="1" column="1">
+           <widget class="QComboBox" name="cbLanguageCmd"/>
+          </item>
           <item row="1" column="0">
            <widget class="QLabel" name="lLanguageCmd">
             <property name="text">
@@ -62,224 +65,18 @@
             </property>
            </widget>
           </item>
-          <item row="1" column="1">
-           <widget class="QComboBox" name="cbLanguageCmd"/>
-          </item>
           <item row="0" column="1">
            <widget class="QComboBox" name="cbLanguage"/>
           </item>
-         </layout>
-        </widget>
-       </item>
-       <item row="0" column="1" rowspan="2">
-        <widget class="QGroupBox" name="bgColors">
-         <property name="title">
-          <string>Colors</string>
-         </property>
-         <layout class="QGridLayout">
-          <item row="0" column="0">
-           <widget class="QLabel" name="lBackground">
-            <property name="text">
-             <string>Backgr&amp;ound:</string>
-            </property>
-            <property name="wordWrap">
-             <bool>false</bool>
-            </property>
-            <property name="buddy">
-             <cstring>cbBackgroundColor</cstring>
-            </property>
-           </widget>
-          </item>
-          <item row="1" column="0">
-           <widget class="QLabel" name="lGridColor">
-            <property name="text">
-             <string>G&amp;rid Color:</string>
-            </property>
-            <property name="wordWrap">
-             <bool>false</bool>
-            </property>
-            <property name="buddy">
-             <cstring>cbGridColor</cstring>
-            </property>
-           </widget>
-          </item>
-          <item row="0" column="1">
-           <widget class="QComboBox" name="cbBackgroundColor">
-            <property name="editable">
-             <bool>true</bool>
-            </property>
-            <item>
-             <property name="text">
-              <string>#000000</string>
-             </property>
-            </item>
-            <item>
-             <property name="text">
-              <string>#FFFFFF</string>
-             </property>
-            </item>
-            <item>
-             <property name="text">
-              <string>#C0C0C0</string>
-             </property>
-            </item>
-            <item>
-             <property name="text">
-              <string>#808080</string>
-             </property>
-            </item>
-           </widget>
-          </item>
-          <item row="1" column="1">
-           <widget class="QComboBox" name="cbGridColor">
-            <property name="editable">
-             <bool>true</bool>
-            </property>
-            <item>
-             <property name="text">
-              <string>#C0C0C0</string>
-             </property>
-            </item>
-            <item>
-             <property name="text">
-              <string>#FFFFFF</string>
-             </property>
-            </item>
-            <item>
-             <property name="text">
-              <string>#000000</string>
-             </property>
-            </item>
-            <item>
-             <property name="text">
-              <string>#808080</string>
-             </property>
-            </item>
-           </widget>
-          </item>
           <item row="2" column="0">
-           <widget class="QLabel" name="lMetaGridColor">
-            <property name="text">
-             <string>&amp;Meta Grid Color:</string>
-            </property>
-            <property name="wordWrap">
-             <bool>false</bool>
-            </property>
-            <property name="buddy">
-             <cstring>cbMetaGridColor</cstring>
-            </property>
-           </widget>
-          </item>
-          <item row="2" column="1">
-           <widget class="QComboBox" name="cbMetaGridColor">
-            <property name="editable">
-             <bool>true</bool>
-            </property>
-            <item>
-             <property name="text">
-              <string>#404040</string>
-             </property>
-            </item>
-            <item>
-             <property name="text">
-              <string>#000000</string>
-             </property>
-            </item>
-            <item>
-             <property name="text">
-              <string>#FFFFFF</string>
-             </property>
-            </item>
-            <item>
-             <property name="text">
-              <string>#C0C0C0</string>
-             </property>
-            </item>
-            <item>
-             <property name="text">
-              <string>#808080</string>
-             </property>
-            </item>
-           </widget>
-          </item>
-          <item row="3" column="0">
-           <widget class="QLabel" name="lSelectedColor">
-            <property name="text">
-             <string>S&amp;elected Color:</string>
-            </property>
-            <property name="wordWrap">
-             <bool>false</bool>
-            </property>
-            <property name="buddy">
-             <cstring>cbMetaGridColor</cstring>
-            </property>
-           </widget>
-          </item>
-          <item row="3" column="1">
-           <widget class="QComboBox" name="cbSelectedColor">
-            <property name="editable">
-             <bool>true</bool>
-            </property>
-            <item>
-             <property name="text">
-              <string>#A54747</string>
-             </property>
-            </item>
-           </widget>
-          </item>
-          <item row="4" column="1">
-           <widget class="QComboBox" name="cbHighlightedColor">
-            <property name="editable">
-             <bool>true</bool>
-            </property>
-            <item>
-             <property name="text">
-              <string>#739373</string>
-             </property>
-            </item>
-           </widget>
-          </item>
-          <item row="4" column="0">
-           <widget class="QLabel" name="lHighlightedColor">
-            <property name="text">
-             <string>&amp;Highlighted Color:</string>
-            </property>
-            <property name="wordWrap">
-             <bool>false</bool>
-            </property>
-            <property name="buddy">
-             <cstring>cbMetaGridColor</cstring>
-            </property>
-           </widget>
-          </item>
-          <item row="5" column="0">
-           <spacer name="spacer7">
+           <spacer name="verticalSpacer_2">
             <property name="orientation">
              <enum>Qt::Vertical</enum>
             </property>
-            <property name="sizeType">
-             <enum>QSizePolicy::Expanding</enum>
-            </property>
             <property name="sizeHint" stdset="0">
              <size>
-              <width>21</width>
-              <height>20</height>
-             </size>
-            </property>
-           </spacer>
-          </item>
-          <item row="5" column="1">
-           <spacer name="spacer8">
-            <property name="orientation">
-             <enum>Qt::Vertical</enum>
-            </property>
-            <property name="sizeType">
-             <enum>QSizePolicy::Expanding</enum>
-            </property>
-            <property name="sizeHint" stdset="0">
-             <size>
-              <width>21</width>
-              <height>20</height>
+              <width>20</width>
+              <height>40</height>
              </size>
             </property>
            </spacer>
@@ -293,16 +90,6 @@
           <string>Fontsize</string>
          </property>
          <layout class="QGridLayout">
-          <item row="0" column="0">
-           <widget class="QLabel" name="lSizeStatus">
-            <property name="text">
-             <string>Statusbar:</string>
-            </property>
-            <property name="wordWrap">
-             <bool>false</bool>
-            </property>
-           </widget>
-          </item>
           <item row="0" column="1">
            <widget class="QComboBox" name="cbSizeStatus">
             <property name="editable">
@@ -387,6 +174,16 @@
             </property>
            </spacer>
           </item>
+          <item row="0" column="0">
+           <widget class="QLabel" name="lSizeStatus">
+            <property name="text">
+             <string>Statusbar:</string>
+            </property>
+            <property name="wordWrap">
+             <bool>false</bool>
+            </property>
+           </widget>
+          </item>
          </layout>
         </widget>
        </item>
@@ -593,6 +390,286 @@
          </property>
         </spacer>
        </item>
+       <item row="0" column="1" rowspan="2">
+        <widget class="QGroupBox" name="bgColors">
+         <property name="title">
+          <string>Colors</string>
+         </property>
+         <layout class="QGridLayout">
+          <item row="3" column="1">
+           <widget class="QComboBox" name="cbSelectedColor">
+            <property name="editable">
+             <bool>true</bool>
+            </property>
+            <item>
+             <property name="text">
+              <string>#A54747</string>
+             </property>
+            </item>
+           </widget>
+          </item>
+          <item row="5" column="1">
+           <widget class="QComboBox" name="cbStartHandleColor">
+            <property name="editable">
+             <bool>true</bool>
+            </property>
+            <item>
+             <property name="text">
+              <string>#00FFFF</string>
+             </property>
+            </item>
+            <item>
+             <property name="text">
+              <string>#0000FF</string>
+             </property>
+            </item>
+            <item>
+             <property name="text">
+              <string>#FFFF00</string>
+             </property>
+            </item>
+            <item>
+             <property name="text">
+              <string>#FF00FF</string>
+             </property>
+            </item>
+           </widget>
+          </item>
+          <item row="5" column="0">
+           <widget class="QLabel" name="lStartHandleColor">
+            <property name="text">
+             <string>St&amp;art Handle Color:</string>
+            </property>
+            <property name="buddy">
+             <cstring>cbStartHandleColor</cstring>
+            </property>
+           </widget>
+          </item>
+          <item row="1" column="0">
+           <widget class="QLabel" name="lGridColor">
+            <property name="text">
+             <string>G&amp;rid Color:</string>
+            </property>
+            <property name="wordWrap">
+             <bool>false</bool>
+            </property>
+            <property name="buddy">
+             <cstring>cbGridColor</cstring>
+            </property>
+           </widget>
+          </item>
+          <item row="1" column="1">
+           <widget class="QComboBox" name="cbGridColor">
+            <property name="editable">
+             <bool>true</bool>
+            </property>
+            <item>
+             <property name="text">
+              <string>#C0C0C0</string>
+             </property>
+            </item>
+            <item>
+             <property name="text">
+              <string>#FFFFFF</string>
+             </property>
+            </item>
+            <item>
+             <property name="text">
+              <string>#000000</string>
+             </property>
+            </item>
+            <item>
+             <property name="text">
+              <string>#808080</string>
+             </property>
+            </item>
+           </widget>
+          </item>
+          <item row="0" column="1">
+           <widget class="QComboBox" name="cbBackgroundColor">
+            <property name="editable">
+             <bool>true</bool>
+            </property>
+            <item>
+             <property name="text">
+              <string>#000000</string>
+             </property>
+            </item>
+            <item>
+             <property name="text">
+              <string>#FFFFFF</string>
+             </property>
+            </item>
+            <item>
+             <property name="text">
+              <string>#C0C0C0</string>
+             </property>
+            </item>
+            <item>
+             <property name="text">
+              <string>#808080</string>
+             </property>
+            </item>
+           </widget>
+          </item>
+          <item row="2" column="0">
+           <widget class="QLabel" name="lMetaGridColor">
+            <property name="text">
+             <string>&amp;Meta Grid Color:</string>
+            </property>
+            <property name="wordWrap">
+             <bool>false</bool>
+            </property>
+            <property name="buddy">
+             <cstring>cbMetaGridColor</cstring>
+            </property>
+           </widget>
+          </item>
+          <item row="3" column="0">
+           <widget class="QLabel" name="lSelectedColor">
+            <property name="text">
+             <string>S&amp;elected Color:</string>
+            </property>
+            <property name="wordWrap">
+             <bool>false</bool>
+            </property>
+            <property name="buddy">
+             <cstring>cbMetaGridColor</cstring>
+            </property>
+           </widget>
+          </item>
+          <item row="4" column="0">
+           <widget class="QLabel" name="lHighlightedColor">
+            <property name="text">
+             <string>&amp;Highlighted Color:</string>
+            </property>
+            <property name="wordWrap">
+             <bool>false</bool>
+            </property>
+            <property name="buddy">
+             <cstring>cbMetaGridColor</cstring>
+            </property>
+           </widget>
+          </item>
+          <item row="4" column="1">
+           <widget class="QComboBox" name="cbHighlightedColor">
+            <property name="editable">
+             <bool>true</bool>
+            </property>
+            <item>
+             <property name="text">
+              <string>#739373</string>
+             </property>
+            </item>
+           </widget>
+          </item>
+          <item row="0" column="0">
+           <widget class="QLabel" name="lBackground">
+            <property name="text">
+             <string>Backgr&amp;ound:</string>
+            </property>
+            <property name="wordWrap">
+             <bool>false</bool>
+            </property>
+            <property name="buddy">
+             <cstring>cbBackgroundColor</cstring>
+            </property>
+           </widget>
+          </item>
+          <item row="2" column="1">
+           <widget class="QComboBox" name="cbMetaGridColor">
+            <property name="editable">
+             <bool>true</bool>
+            </property>
+            <item>
+             <property name="text">
+              <string>#404040</string>
+             </property>
+            </item>
+            <item>
+             <property name="text">
+              <string>#000000</string>
+             </property>
+            </item>
+            <item>
+             <property name="text">
+              <string>#FFFFFF</string>
+             </property>
+            </item>
+            <item>
+             <property name="text">
+              <string>#C0C0C0</string>
+             </property>
+            </item>
+            <item>
+             <property name="text">
+              <string>#808080</string>
+             </property>
+            </item>
+           </widget>
+          </item>
+          <item row="6" column="1">
+           <widget class="QComboBox" name="cbHandleColor">
+            <property name="editable">
+             <bool>true</bool>
+            </property>
+            <item>
+             <property name="text">
+              <string>#0000FF</string>
+             </property>
+            </item>
+           </widget>
+          </item>
+          <item row="7" column="1">
+           <widget class="QComboBox" name="cbEndHandleColor">
+            <property name="editable">
+             <bool>true</bool>
+            </property>
+            <item>
+             <property name="text">
+              <string>#0000FF</string>
+             </property>
+            </item>
+            <item>
+             <property name="text">
+              <string>#FFFF00</string>
+             </property>
+            </item>
+            <item>
+             <property name="text">
+              <string>#00FFFF</string>
+             </property>
+            </item>
+            <item>
+             <property name="text">
+              <string>#FF00FF</string>
+             </property>
+            </item>
+           </widget>
+          </item>
+          <item row="6" column="0">
+           <widget class="QLabel" name="label_2">
+            <property name="text">
+             <string>&amp;Handle Color:</string>
+            </property>
+            <property name="buddy">
+             <cstring>cbHandleColor</cstring>
+            </property>
+           </widget>
+          </item>
+          <item row="7" column="0">
+           <widget class="QLabel" name="label_3">
+            <property name="text">
+             <string>&amp;End Handle Color:</string>
+            </property>
+            <property name="buddy">
+             <cstring>cbEndHandleColor</cstring>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+       </item>
       </layout>
      </widget>
      <widget class="QWidget" name="tab_2">
@@ -883,13 +960,21 @@
   <tabstop>cbMetaGridColor</tabstop>
   <tabstop>cbSelectedColor</tabstop>
   <tabstop>cbHighlightedColor</tabstop>
+  <tabstop>cbStartHandleColor</tabstop>
+  <tabstop>cbHandleColor</tabstop>
+  <tabstop>cbEndHandleColor</tabstop>
   <tabstop>cbSizeStatus</tabstop>
-  <tabstop>lePathTranslations</tabstop>
-  <tabstop>lePathHatch</tabstop>
-  <tabstop>lePathFonts</tabstop>
-  <tabstop>lePathScripts</tabstop>
+  <tabstop>buttonBox</tabstop>
   <tabstop>lePathLibrary</tabstop>
   <tabstop>cbUnit</tabstop>
+  <tabstop>lePathScripts</tabstop>
+  <tabstop>lePathFonts</tabstop>
+  <tabstop>leTemplate</tabstop>
+  <tabstop>btTemplate</tabstop>
+  <tabstop>cbAutoSaveTime</tabstop>
+  <tabstop>cbAutoBackup</tabstop>
+  <tabstop>lePathTranslations</tabstop>
+  <tabstop>lePathHatch</tabstop>
  </tabstops>
  <resources>
   <include location="../../../res/extui/extui.qrc"/>
diff --git a/plugins/cam/cam.cpp b/plugins/cam/cam.cpp
new file mode 100644
index 0000000..f9a1816
--- /dev/null
+++ b/plugins/cam/cam.cpp
@@ -0,0 +1,80 @@
+/*****************************************************************************/
+/*  sample.cpp - plugin example for LibreCAD                                 */
+/*                                                                           */
+/*  Copyright (C) 2011 Rallaz, rallazz@gmail.com                             */
+/*                                                                           */
+/*  This library is free software, licensed under the terms of the GNU       */
+/*  General Public License as published by the Free Software Foundation,     */
+/*  either version 2 of the License, or (at your option) any later version.  */
+/*  You should have received a copy of the GNU General Public License        */
+/*  along with this program.  If not, see <http://www.gnu.org/licenses/>.    */
+/*****************************************************************************/
+
+#include <QGridLayout>
+#include <QLabel>
+#include <QPushButton>
+#include <QLineEdit>
+#include <QSettings>
+#include <QMessageBox>
+#include <QDoubleValidator>
+
+#include "document_interface.h"
+#include "cam.h"
+
+QString CAMPlugin::name() const
+ {
+	 return (tr("CAM plugin"));
+ }
+
+PluginCapabilities CAMPlugin::getCapabilities() const
+{
+    PluginCapabilities pluginCapabilities;
+	pluginCapabilities.menuEntryPoints << PluginMenuLocation("Edit", tr("Reverse direction"));
+    return pluginCapabilities;
+}
+
+void CAMPlugin::execComm(Document_Interface *doc, QWidget *parent, QString cmd)
+{
+    Q_UNUSED(cmd);
+	Q_UNUSED(parent);
+	QList<Plug_Entity *> objs;
+	bool yes  = doc->getSelect(&objs);
+	if (!yes || objs.isEmpty()) return;
+
+	foreach(Plug_Entity* obj, objs) {
+		reverse(obj);
+	}
+
+	while (!objs.isEmpty())
+		delete objs.takeFirst();
+}
+
+void CAMPlugin::reverse(Plug_Entity* obj)
+{
+	QHash<int, QVariant> data;
+	obj->getData(&data);
+	int type = data[DPI::ETYPE].toInt();
+	if (type == DPI::POLYLINE) {
+		QList<Plug_VertexData> polyLineData;
+		obj->getPolylineData(&polyLineData);
+		for(int k = 0; k < (polyLineData.size()/2); k++) {
+			polyLineData.swap(k,polyLineData.size()-(1+k));
+		}
+		obj->updatePolylineData(&polyLineData);
+	}
+	else if (type == DPI::LINE) {
+		double x1 = data[DPI::STARTX].toDouble();
+		double y1 = data[DPI::STARTY].toDouble();
+		double x2 = data[DPI::ENDX].toDouble();
+		double y2 = data[DPI::ENDY].toDouble();
+		data[DPI::STARTX] = x2;
+		data[DPI::STARTY] = y2;
+		data[DPI::ENDX] = x1;
+		data[DPI::ENDY] = y1;
+		obj->updateData(&data);
+	}
+}
+
+#if QT_VERSION < 0x050000
+Q_EXPORT_PLUGIN2(lc_sample, CAMPlugin);
+#endif
diff --git a/plugins/cam/cam.h b/plugins/cam/cam.h
new file mode 100644
index 0000000..27d0c66
--- /dev/null
+++ b/plugins/cam/cam.h
@@ -0,0 +1,38 @@
+/*****************************************************************************/
+/*  cam.h - plugin that provides functions needed for CAM applications       */
+/*                                                                           */
+/*  Copyright (C) 2013 Robert Lichtenberger, r.lichtenberger@gmail.com       */
+/*                                                                           */
+/*  This library is free software, licensed under the terms of the GNU       */
+/*  General Public License as published by the Free Software Foundation,     */
+/*  either version 2 of the License, or (at your option) any later version.  */
+/*  You should have received a copy of the GNU General Public License        */
+/*  along with this program.  If not, see <http://www.gnu.org/licenses/>.    */
+/*****************************************************************************/
+
+#ifndef CAM_H
+#define CAM_H
+
+#include "qc_plugininterface.h"
+#include <QDialog>
+class QLineEdit;
+class Plug_Entity;
+
+class CAMPlugin : public QObject, QC_PluginInterface
+{
+    Q_OBJECT
+     Q_INTERFACES(QC_PluginInterface)
+#if QT_VERSION >= 0x050000
+	 Q_PLUGIN_METADATA(IID "org.librecad.sample" FILE  "cam.json")
+#endif
+
+ public:
+    virtual PluginCapabilities getCapabilities() const;
+    virtual QString name() const;
+	virtual void execComm(Document_Interface *doc, QWidget *parent, QString cmd);
+ private:
+	void reverse(Plug_Entity *obj);
+
+};
+
+#endif // CAM_H
diff --git a/plugins/cam/cam.json b/plugins/cam/cam.json
new file mode 100644
index 0000000..dfbcc58
--- /dev/null
+++ b/plugins/cam/cam.json
@@ -0,0 +1 @@
+  { "Keys": [ ] }
diff --git a/plugins/cam/cam.pro b/plugins/cam/cam.pro
new file mode 100644
index 0000000..ed66011
--- /dev/null
+++ b/plugins/cam/cam.pro
@@ -0,0 +1,37 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2011-03-22T19:33:11
+#
+#-------------------------------------------------
+
+QT       += gui
+TEMPLATE = lib
+CONFIG += plugin
+VERSION = 1.0.1
+PLUGIN_NAME=cam
+
+GENERATED_DIR = ../../generated/plugin/cam
+# Use common project definitions.
+include(../../common.pri)
+
+# For plugins
+INCLUDEPATH    += ../../librecad/src/plugins
+
+SOURCES += cam.cpp
+
+HEADERS += cam.h
+
+
+# DLLDESTDIR = ../../unix/resources/plugins/
+win32 {
+        DLLDESTDIR = ../../windows/resources/plugins
+        TARGET = $$PLUGIN_NAME
+}
+unix {
+    macx { 
+	TARGET = ../../LibreCAD.app/Contents/Resources/plugins/$$PLUGIN_NAME
+    }
+    else { 
+	TARGET = ../../unix/resources/plugins/$$PLUGIN_NAME
+    }
+}
diff --git a/plugins/plugins.pro b/plugins/plugins.pro
index 1ebb922..d4bc967 100644
--- a/plugins/plugins.pro
+++ b/plugins/plugins.pro
@@ -12,6 +12,7 @@ QT += gui
 SUBDIRS     = \
         asciifile \
         align \
+	cam \
         list \
         sameprop \
         importshp \
-- 
1.7.11.7

