+ issue #0001203: Allow User to Adjust Size of Constraint Points

This commit is contained in:
wmayer 2016-03-08 00:31:50 +01:00
parent 4672066db8
commit 4fcb93b64e
7 changed files with 330 additions and 70 deletions

View File

@ -841,6 +841,7 @@ SOURCE_GROUP("View3D\\Viewprovider" FILES ${Viewprovider_SRCS})
SET(Inventor_CPP_SRCS
Inventor/SoDrawingGrid.cpp
Inventor/SoAutoZoomTranslation.cpp
Inventor/MarkerBitmaps.cpp
SoFCBackgroundGradient.cpp
SoFCBoundingBox.cpp
SoFCColorBar.cpp
@ -863,6 +864,7 @@ SET(Inventor_SRCS
${Inventor_CPP_SRCS}
Inventor/SoDrawingGrid.h
Inventor/SoAutoZoomTranslation.h
Inventor/MarkerBitmaps.h
SoFCBackgroundGradient.h
SoFCBoundingBox.h
SoFCColorBar.h

View File

@ -0,0 +1,176 @@
/***************************************************************************
* Copyright (c) 2016 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <Inventor/nodes/SoMarkerSet.h>
#endif
#include "MarkerBitmaps.h"
using namespace Gui::Inventor;
/*
from PySide import QtCore
from PySide import QtGui
def makeIcon(s):
p=QtGui.QPixmap(s,s)
painter=QtGui.QPainter(p)
painter.setBrush(QtCore.Qt.SolidPattern)
painter.drawEllipse(1,1,s-2,s-2)
painter.end()
buffer=QtCore.QBuffer()
buffer.open(buffer.WriteOnly)
p.save(buffer,"XPM")
buffer.close()
ary=buffer.buffer()
lines=ary.split(",")
ba=QtCore.QByteArray()
for i in lines[3:]:
ba = ba.append(i)
ba=ba.replace("#","x")
ba=ba.replace("."," ")
print (ba.data())
*/
//CIRCLE_FILLED_11_11
const int CIRCLE11_WIDTH = 11;
const int CIRCLE11_HEIGHT = 11;
const char circle11_marker[CIRCLE11_WIDTH * CIRCLE11_HEIGHT + 1] = {
" "
" xxxxxx "
" xxxxxxxx "
" xxxxxxxx "
" xxxxxxxxxx"
" xxxxxxxxxx"
" xxxxxxxxxx"
" xxxxxxxxxx"
" xxxxxxxx "
" xxxxxxxx "
" xxxxxx "};
//CIRCLE_FILLED_13_13
const int CIRCLE13_WIDTH = 13;
const int CIRCLE13_HEIGHT = 13;
const char circle13_marker[CIRCLE13_WIDTH * CIRCLE13_HEIGHT + 1] = {
" "
" xxxxxx "
" xxxxxxxx "
" xxxxxxxxxx "
" xxxxxxxxxxxx"
" xxxxxxxxxxxx"
" xxxxxxxxxxxx"
" xxxxxxxxxxxx"
" xxxxxxxxxxxx"
" xxxxxxxxxxxx"
" xxxxxxxxxx "
" xxxxxxxx "
" xxxxxx "};
//CIRCLE_FILLED_15_15
const int CIRCLE15_WIDTH = 15;
const int CIRCLE15_HEIGHT = 15;
const char circle15_marker[CIRCLE15_WIDTH * CIRCLE15_HEIGHT + 1] = {
" "
" xxxxxx "
" xxxxxxxxxx "
" xxxxxxxxxxxx "
" xxxxxxxxxxxx "
" xxxxxxxxxxxxxx"
" xxxxxxxxxxxxxx"
" xxxxxxxxxxxxxx"
" xxxxxxxxxxxxxx"
" xxxxxxxxxxxxxx"
" xxxxxxxxxxxxxx"
" xxxxxxxxxxxx "
" xxxxxxxxxxxx"
" xxxxxxxxxx "
" xxxxxx "};
std::map<MarkerBitmaps::Marker, int> MarkerBitmaps::markerIndex;
void
MarkerBitmaps::initClass()
{
createBitmap("CIRCLE_FILLED", 11, 11, 11, circle11_marker);
createBitmap("CIRCLE_FILLED", 13, 13, 13, circle13_marker);
createBitmap("CIRCLE_FILLED", 15, 15, 15, circle15_marker);
// the built-in bitmaps of Coin
markerIndex [std::make_pair("CIRCLE_FILLED", 9)] = SoMarkerSet::CIRCLE_FILLED_9_9;
markerIndex [std::make_pair("CIRCLE_FILLED", 7)] = SoMarkerSet::CIRCLE_FILLED_7_7;
markerIndex [std::make_pair("CIRCLE_FILLED", 5)] = SoMarkerSet::CIRCLE_FILLED_5_5;
}
void MarkerBitmaps::createBitmap(const std::string& name, int px, int width, int height, const char* marker)
{
int byteidx = 0;
const int byteWidth = (width + 7) / 2;
int size = byteWidth * height;
std::vector<unsigned char> bitmapbytes(size);
for (int h = 0; h < height; h++) {
unsigned char bits = 0;
for (int w = 0; w < width; w++) {
if (marker[(h * width) + w] != ' ') {
bits |= (0x80 >> (w % 8));
}
if ((((w + 1) % 8) == 0) || (w == width - 1)) {
bitmapbytes[byteidx++] = bits;
bits = 0;
}
}
}
int MY_BITMAP_IDX = SoMarkerSet::getNumDefinedMarkers(); // add at end
SoMarkerSet::addMarker(MY_BITMAP_IDX, SbVec2s(width, height),
&(bitmapbytes[0]), FALSE, TRUE);
markerIndex[std::make_pair(name, px)] = MY_BITMAP_IDX;
}
int MarkerBitmaps::getMarkerIndex(const std::string& name, int px)
{
std::map<Marker, int>::iterator it = markerIndex.find(std::make_pair(name, px));
if (it != markerIndex.end()) {
return it->second;
}
return static_cast<int>(SoMarkerSet::CIRCLE_FILLED_7_7);
}
std::list<int> MarkerBitmaps::getSupportedSizes(const std::string& name)
{
std::list<int> sizes;
for (std::map<Marker, int>::iterator it = markerIndex.begin(); it != markerIndex.end(); ++it) {
if (it->first.first == name)
sizes.push_back(it->first.second);
}
return sizes;
}

View File

@ -0,0 +1,53 @@
/***************************************************************************
* Copyright (c) 2016 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef GUI_INVENTOR_MARKERBITMAPS_H
#define GUI_INVENTOR_MARKERBITMAPS_H
#include <string>
#include <list>
#include <map>
namespace Gui { namespace Inventor {
class GuiExport MarkerBitmaps {
public:
static void initClass();
static int getMarkerIndex(const std::string&, int px);
static std::list<int> getSupportedSizes(const std::string&);
private:
static void createBitmap(const std::string&, int px, int width, int height, const char* marker);
private:
typedef std::pair<std::string, int> Marker;
static std::map<Marker, int> markerIndex;
};
} // namespace Inventor
} // namespace Gui
#endif // GUI_INVENTOR_MARKERBITMAPS_H

View File

@ -52,6 +52,7 @@
#include "SoNavigationDragger.h"
#include "Inventor/SoDrawingGrid.h"
#include "Inventor/SoAutoZoomTranslation.h"
#include "Inventor/MarkerBitmaps.h"
#include "propertyeditor/PropertyItem.h"
#include "NavigationStyle.h"
@ -110,6 +111,7 @@ void Gui::SoFCDB::init()
SoRegPoint ::initClass();
SoDrawingGrid ::initClass();
SoAutoZoomTranslation ::initClass();
MarkerBitmaps ::initClass();
PropertyItem ::init();
PropertySeparatorItem ::init();

View File

@ -33,6 +33,7 @@
#include "TaskSketcherGeneral.h"
#include <App/Application.h>
#include <Gui/PrefWidgets.h>
#include <Gui/Inventor/MarkerBitmaps.h>
using namespace SketcherGui;
@ -120,6 +121,10 @@ void SketcherSettings::saveSettings()
ui->checkBoxAdvancedSolverTaskBox->onSave();
form->saveSettings();
ParameterGrp::handle hViewGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
int markerSize = ui->EditSketcherMarkerSize->itemData(ui->EditSketcherMarkerSize->currentIndex()).toInt();
hViewGrp->SetInt("EditSketcherMarkerSize", markerSize);
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Part");
QVariant data = ui->comboBox->itemData(ui->comboBox->currentIndex());
int pattern = data.toInt();
@ -154,6 +159,16 @@ void SketcherSettings::loadSettings()
ui->checkBoxAdvancedSolverTaskBox->onRestore();
form->loadSettings();
std::list<int> sizes = Gui::Inventor::MarkerBitmaps::getSupportedSizes("CIRCLE_FILLED");
for (std::list<int>::iterator it = sizes.begin(); it != sizes.end(); ++it)
ui->EditSketcherMarkerSize->addItem(tr("%1 px").arg(*it), *it);
ParameterGrp::handle hViewGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
int markerSize = hViewGrp->GetInt("EditSketcherMarkerSize", 7);
int markerIndex = ui->EditSketcherMarkerSize->findData(QVariant(markerSize));
if (markerIndex < 0)
markerIndex = 1;
ui->EditSketcherMarkerSize->setCurrentIndex(markerIndex);
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Part");
int pattern = hGrp->GetInt("GridLinePattern", 0x0f0f);
int index = ui->comboBox->findData(QVariant(pattern));

View File

@ -40,7 +40,7 @@
<property name="toolTip">
<string>The color of edges being edited</string>
</property>
<property name="color" stdset="0">
<property name="color">
<color>
<red>255</red>
<green>255</green>
@ -73,7 +73,7 @@
<property name="toolTip">
<string>The color of vertices being edited</string>
</property>
<property name="color" stdset="0">
<property name="color">
<color>
<red>255</red>
<green>255</green>
@ -106,7 +106,7 @@
<property name="toolTip">
<string>The color of edges being edited</string>
</property>
<property name="color" stdset="0">
<property name="color">
<color>
<red>255</red>
<green>255</green>
@ -139,7 +139,7 @@
<property name="toolTip">
<string>The color of vertices being edited</string>
</property>
<property name="color" stdset="0">
<property name="color">
<color>
<red>255</red>
<green>38</green>
@ -172,7 +172,7 @@
<property name="toolTip">
<string>The color of fully constrained geometry in edit mode</string>
</property>
<property name="color" stdset="0">
<property name="color">
<color>
<red>255</red>
<green>38</green>
@ -192,7 +192,7 @@
<property name="toolTip">
<string>The color of construction geometry in edit mode</string>
</property>
<property name="color" stdset="0">
<property name="color">
<color>
<red>0</red>
<green>0</green>
@ -225,7 +225,7 @@
<property name="toolTip">
<string>The color of external geometry in edit mode</string>
</property>
<property name="color" stdset="0">
<property name="color">
<color>
<red>204</red>
<green>51</green>
@ -271,7 +271,7 @@
<property name="toolTip">
<string>The color of fully constrained geometry in edit mode</string>
</property>
<property name="color" stdset="0">
<property name="color">
<color>
<red>0</red>
<green>255</green>
@ -397,7 +397,7 @@
</item>
<item row="13" column="1">
<widget class="Gui::PrefColorButton" name="CursorTextColor">
<property name="color" stdset="0">
<property name="color">
<color>
<red>0</red>
<green>0</green>
@ -446,7 +446,7 @@
<property name="toolTip">
<string>The color of driving constraints in edit mode</string>
</property>
<property name="color" stdset="0">
<property name="color">
<color>
<red>255</red>
<green>38</green>
@ -466,7 +466,7 @@
<property name="toolTip">
<string>The color of non-driving constrains or dimensions in edit mode</string>
</property>
<property name="color" stdset="0">
<property name="color">
<color>
<red>0</red>
<green>38</green>
@ -493,63 +493,71 @@
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_6">
<property name="minimumSize">
<size>
<width>182</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Font size</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefSpinBox" name="EditSketcherFontSize">
<property name="suffix">
<string>px</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>17</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>EditSketcherFontSize</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
</widget>
</item>
</layout>
<widget class="QLabel" name="label_6">
<property name="minimumSize">
<size>
<width>182</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Font size</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Gui::PrefSpinBox" name="EditSketcherFontSize">
<property name="suffix">
<string>px</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>17</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>EditSketcherFontSize</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Grid line pattern</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox">
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</item>
</layout>
<widget class="QLabel" name="label_marker">
<property name="minimumSize">
<size>
<width>182</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Marker size</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="EditSketcherMarkerSize"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Grid line pattern</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBox">
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="Gui::PrefCheckBox" name="dialogOnDistanceConstraint">
<property name="text">
<string>Ask for value after creating a distance constraint</string>
@ -565,7 +573,7 @@
</property>
</widget>
</item>
<item row="3" column="0">
<item row="4" column="0" colspan="2">
<widget class="Gui::PrefCheckBox" name="continueMode">
<property name="text">
<string>Geometry Creation &quot;Continue Mode&quot;</string>

View File

@ -96,6 +96,7 @@
#include <Gui/DlgEditFileIncludeProptertyExternal.h>
#include <Gui/SoFCBoundingBox.h>
#include <Gui/SoFCUnifiedSelection.h>
#include <Gui/Inventor/MarkerBitmaps.h>
#include <Mod/Part/App/Geometry.h>
#include <Mod/Sketcher/App/SketchObject.h>
@ -155,6 +156,7 @@ struct EditData {
PreselectPoint(-1),
PreselectCurve(-1),
PreselectCross(-1),
MarkerSize(7),
blockedPreselection(false),
FullyConstrained(false),
//ActSketch(0), // if you are wondering, it went to SketchObject, accessible via getSketchObject()->getSolvedSketch()
@ -183,6 +185,7 @@ struct EditData {
int PreselectPoint;
int PreselectCurve;
int PreselectCross;
int MarkerSize;
std::set<int> PreselectConstraintSet;
bool blockedPreselection;
bool FullyConstrained;
@ -1011,9 +1014,8 @@ bool ViewProviderSketch::mouseMove(const SbVec2s &cursorPos, Gui::View3DInventor
Mode != STATUS_SKETCH_DragConstraint &&
Mode != STATUS_SKETCH_UseRubberBand) {
SoPickedPoint *pp = this->getPointOnRay(cursorPos, viewer);
preselectChanged = detectPreselection(pp, viewer, cursorPos);
delete pp;
boost::scoped_ptr<SoPickedPoint> pp(this->getPointOnRay(cursorPos, viewer));
preselectChanged = detectPreselection(pp.get(), viewer, cursorPos);
}
switch (Mode) {
@ -4206,6 +4208,9 @@ bool ViewProviderSketch::setEdit(int ModNum)
assert(!edit);
edit = new EditData();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
edit->MarkerSize = hGrp->GetInt("EditSketcherMarkerSize", 7);
createEditInventorNodes();
edit->visibleBeforeEdit = this->isVisible();
this->hide(); // avoid that the wires interfere with the edit lines
@ -4213,7 +4218,6 @@ bool ViewProviderSketch::setEdit(int ModNum)
ShowGrid.setValue(true);
TightGrid.setValue(false);
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
float transparency;
// set the point color
@ -4417,7 +4421,7 @@ void ViewProviderSketch::createEditInventorNodes(void)
edit->PointSet = new SoMarkerSet;
edit->PointSet->setName("PointSet");
edit->PointSet->markerIndex = SoMarkerSet::CIRCLE_FILLED_7_7;
edit->PointSet->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex("CIRCLE_FILLED", edit->MarkerSize);
pointsRoot->addChild(edit->PointSet);
// stuff for the Curves +++++++++++++++++++++++++++++++++++++++