Working proof of concept for DPG rots & dirs
This commit is contained in:
parent
ca8adc3aab
commit
93fb9273dd
|
@ -90,6 +90,8 @@ SET(TechDraw_SRCS
|
|||
AppTechDrawPy.cpp
|
||||
DrawUtil.cpp
|
||||
DrawUtil.h
|
||||
Cube.cpp
|
||||
Cube.h
|
||||
PreCompiled.cpp
|
||||
PreCompiled.h
|
||||
EdgeWalker.cpp
|
||||
|
|
601
src/Mod/TechDraw/App/Cube.cpp
Normal file
601
src/Mod/TechDraw/App/Cube.cpp
Normal file
|
@ -0,0 +1,601 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2016 WandererFan <wandererfan@gmail.com> *
|
||||
* *
|
||||
* 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 <sstream>
|
||||
#endif
|
||||
|
||||
#include <Base/Console.h>
|
||||
//#include <Base/Vector3D.h>
|
||||
|
||||
#include "DrawUtil.h"
|
||||
#include "Cube.h"
|
||||
|
||||
using namespace TechDraw;
|
||||
|
||||
const std::map<std::string,Base::Vector3d> Cube::m_viewToStdDir = {
|
||||
{ "A", Base::Vector3d(0, -1, 0) }, //front
|
||||
{ "B", Base::Vector3d(0, 0, 1) }, //top
|
||||
{ "C", Base::Vector3d(-1, 0, 0) }, //left
|
||||
{ "D", Base::Vector3d(1, 0, 0) }, //right
|
||||
{ "E", Base::Vector3d(0, 0, -1) }, //bottom
|
||||
{ "F", Base::Vector3d(0, 1, 0) }, //rear
|
||||
{ "G", Base::Vector3d(-1,-1,1) }, //FTL
|
||||
{ "H", Base::Vector3d(1, -1, 1) }, //FTR
|
||||
{ "I", Base::Vector3d(1, -1, -1) }, //FBR
|
||||
{ "J", Base::Vector3d(-1, -1, -1) } }; //FBL
|
||||
|
||||
|
||||
Cube::Cube(void)
|
||||
{
|
||||
}
|
||||
|
||||
Cube::~Cube(void)
|
||||
{
|
||||
}
|
||||
|
||||
void Cube::initialize(Base::Vector3d r, Base::Vector3d rr, Base::Vector3d l, Base::Vector3d lr,
|
||||
Base::Vector3d f, Base::Vector3d fr, Base::Vector3d k, Base::Vector3d kr, //k for bacK (rear)
|
||||
Base::Vector3d t, Base::Vector3d tr, Base::Vector3d b, Base::Vector3d br)
|
||||
{
|
||||
Base::Console().Message("TRACE - Cube::init()\n");
|
||||
//Base::Vector3d FTR = f+t+r;
|
||||
//Base::Vector3d FTL = f+t-r;
|
||||
//Base::Vector3d FBL = f-t-r;
|
||||
//Base::Vector3d FBR = -f-t-r;
|
||||
m_mapFrameDir.insert(std::map<std::string, Base::Vector3d>::value_type("Bottom", b));
|
||||
m_mapFrameDir.insert(std::map<std::string, Base::Vector3d>::value_type("Front" , f));
|
||||
m_mapFrameDir.insert(std::map<std::string, Base::Vector3d>::value_type("Left" , l));
|
||||
m_mapFrameDir.insert(std::map<std::string, Base::Vector3d>::value_type("Rear" , k));
|
||||
m_mapFrameDir.insert(std::map<std::string, Base::Vector3d>::value_type("Right" , r));
|
||||
m_mapFrameDir.insert(std::map<std::string, Base::Vector3d>::value_type("Top" , t));
|
||||
// m_mapFrameDir.insert(std::map<std::string, Base::Vector3d>::value_type("FrontTopRight" , b));
|
||||
// m_mapFrameDir.insert(std::map<std::string, Base::Vector3d>::value_type("FrontTopLeft" , b));
|
||||
// m_mapFrameDir.insert(std::map<std::string, Base::Vector3d>::value_type("FrontBottomLeft" , b));
|
||||
// m_mapFrameDir.insert(std::map<std::string, Base::Vector3d>::value_type("FrontBottomRight", b));
|
||||
|
||||
m_mapFrameRot.insert(std::map<std::string, Base::Vector3d>::value_type("Bottom", br));
|
||||
m_mapFrameRot.insert(std::map<std::string, Base::Vector3d>::value_type("Front" , fr));
|
||||
m_mapFrameRot.insert(std::map<std::string, Base::Vector3d>::value_type("Left" , lr));
|
||||
m_mapFrameRot.insert(std::map<std::string, Base::Vector3d>::value_type("Rear" , kr));
|
||||
m_mapFrameRot.insert(std::map<std::string, Base::Vector3d>::value_type("Right" , rr));
|
||||
m_mapFrameRot.insert(std::map<std::string, Base::Vector3d>::value_type("Top" , tr));
|
||||
// m_mapFrameRot.insert(std::map<std::string, Base::Vector3d>::value_type("FrontTopRight" , br));
|
||||
// m_mapFrameRot.insert(std::map<std::string, Base::Vector3d>::value_type("FrontTopLeft" , br));
|
||||
// m_mapFrameRot.insert(std::map<std::string, Base::Vector3d>::value_type("FrontBottomLeft" , br));
|
||||
// m_mapFrameRot.insert(std::map<std::string, Base::Vector3d>::value_type("FrontBottomRight", br));
|
||||
|
||||
m_conTab.initialize(); //all possible configs of ABCDEF in RightFrontTopLeftRearBottom
|
||||
// m_conTab.dump("conTab after init");
|
||||
}
|
||||
|
||||
void Cube::rotateUp()
|
||||
{
|
||||
//Front -> Top -> Rear -> Bottom -> Front???
|
||||
saveSwap("Front");
|
||||
shiftFrame("Bottom", "Front");
|
||||
shiftFrame("Rear" , "Bottom");
|
||||
shiftFrame("Top" , "Rear");
|
||||
restoreSwap("Top");
|
||||
|
||||
updateRotsToConfig(getCurrConfig());
|
||||
dump("RotateUp(board after Rot update)");
|
||||
// dumpState("RotateUp(after update)");
|
||||
//validateBoard();
|
||||
|
||||
}
|
||||
|
||||
void Cube::rotateDown()
|
||||
{
|
||||
|
||||
//Front -> Bottom -> Rear -> Top -> Front???
|
||||
saveSwap("Front");
|
||||
shiftFrame("Top" , "Front");
|
||||
shiftFrame("Rear" , "Top");
|
||||
shiftFrame("Bottom" , "Rear");
|
||||
restoreSwap("Bottom");
|
||||
|
||||
updateRotsToConfig(getCurrConfig());
|
||||
dump("RotateDown(board after Rot update)");
|
||||
// dumpState("RotateDown(after update)");
|
||||
//validateBoard();
|
||||
|
||||
}
|
||||
|
||||
void Cube::rotateRight()
|
||||
{
|
||||
//dump("RotateRight (board before)");
|
||||
|
||||
//Front -> Right -> Rear -> Left -> Front???
|
||||
saveSwap("Front");
|
||||
shiftFrame("Left" , "Front");
|
||||
shiftFrame("Rear" , "Left");
|
||||
shiftFrame("Right" , "Rear");
|
||||
restoreSwap("Right");
|
||||
|
||||
updateRotsToConfig(getCurrConfig());
|
||||
dump("RotateRight(board after Rot update)");
|
||||
// bool boardState = validateBoard(getCurrConfig());
|
||||
// Base::Console().Message("TRACE - Cube::rotateRight - boardState: %d\n",boardState);
|
||||
// dumpState("RotateRight(state after update)");
|
||||
}
|
||||
|
||||
void Cube::rotateLeft()
|
||||
{
|
||||
//Front -> Left -> Rear -> Right -> Front???
|
||||
saveSwap("Front");
|
||||
shiftFrame("Right", "Front");
|
||||
shiftFrame("Rear" , "Right");
|
||||
shiftFrame("Left" , "Rear");
|
||||
restoreSwap("Left");
|
||||
|
||||
updateRotsToConfig(getCurrConfig());
|
||||
dump("RotateLeft(board after Rot updates)");
|
||||
// dumpState("RotateLeft(after update)");
|
||||
|
||||
}
|
||||
|
||||
void Cube::spinCCW()
|
||||
{
|
||||
//Right -> Top -> Left -> Bottom -> Right???
|
||||
saveSwap("Right");
|
||||
shiftFrame("Bottom", "Right");
|
||||
shiftFrame("Left" , "Bottom");
|
||||
shiftFrame("Top" , "Left");
|
||||
restoreSwap("Top");
|
||||
|
||||
updateRotsToConfig(getCurrConfig());
|
||||
dump("SpinCCW(board after Rot updates)");
|
||||
// dumpState("SpinCCW(after update)");
|
||||
}
|
||||
|
||||
void Cube::spinCW()
|
||||
{
|
||||
//Left -> Top -> Right -> Bottom -> Left???
|
||||
saveSwap("Left");
|
||||
shiftFrame("Bottom", "Left");
|
||||
shiftFrame("Right" , "Bottom");
|
||||
shiftFrame("Top", "Right");
|
||||
restoreSwap("Top");
|
||||
|
||||
updateRotsToConfig(getCurrConfig());
|
||||
dump("spinCW(board after Rot updates)");
|
||||
// dumpState("SpinCW(after update)");
|
||||
}
|
||||
|
||||
std::string Cube::dirToView(Base::Vector3d v)
|
||||
{
|
||||
std::string result;
|
||||
for (auto& i: m_viewToStdDir) {
|
||||
if (i.second == v) {
|
||||
result = i.first;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void Cube::updateDirsToConfig(std::string cfg)
|
||||
{
|
||||
// Base::Console().Message("TRACE - Cube::updateDirs(%s) \n",cfg.c_str());
|
||||
Base::Vector3d boardValue = m_conTab.getDirItem(cfg,"Front");
|
||||
m_mapFrameDir.at("Front") = boardValue;
|
||||
boardValue = m_conTab.getDirItem(cfg,"Rear");
|
||||
m_mapFrameDir.at("Rear") = boardValue;
|
||||
boardValue = m_conTab.getDirItem(cfg,"Left");
|
||||
m_mapFrameDir.at("Left") = boardValue;
|
||||
boardValue = m_conTab.getDirItem(cfg,"Right");
|
||||
m_mapFrameDir.at("Right") = boardValue;
|
||||
boardValue = m_conTab.getDirItem(cfg,"Top");
|
||||
m_mapFrameDir.at("Top") = boardValue;
|
||||
boardValue = m_conTab.getDirItem(cfg,"Bottom");
|
||||
m_mapFrameDir.at("Bottom") = boardValue;
|
||||
}
|
||||
|
||||
void Cube::updateRotsToConfig(std::string cfg)
|
||||
{
|
||||
Base::Console().Message("TRACE - Cube::updateRots(%s) \n",cfg.c_str());
|
||||
Base::Vector3d boardValue = m_conTab.getRotItem(cfg,"Front");
|
||||
m_mapFrameRot.at("Front") = boardValue;
|
||||
boardValue = m_conTab.getRotItem(cfg,"Rear");
|
||||
m_mapFrameRot.at("Rear") = boardValue;
|
||||
boardValue = m_conTab.getRotItem(cfg,"Left");
|
||||
m_mapFrameRot.at("Left") = boardValue;
|
||||
boardValue = m_conTab.getRotItem(cfg,"Right");
|
||||
m_mapFrameRot.at("Right") = boardValue;
|
||||
boardValue = m_conTab.getRotItem(cfg,"Top");
|
||||
m_mapFrameRot.at("Top") = boardValue;
|
||||
boardValue = m_conTab.getRotItem(cfg,"Bottom");
|
||||
m_mapFrameRot.at("Bottom") = boardValue;
|
||||
}
|
||||
|
||||
bool Cube::validateBoard(std::string cfg)
|
||||
{
|
||||
// Base::Console().Message("TRACE - Cube::validateBoard(%s)\n",cfg.c_str());
|
||||
bool result = true;
|
||||
//check that Dirs match
|
||||
std::string strCfgDir;
|
||||
std::string strBoardDir;
|
||||
|
||||
// Base::Console().Message("TRACE - Cube::validateBoard(%s) - BoardDirCount: %d BoardRotCount: %d\n",
|
||||
// cfg.c_str(),m_mapFrameDir.size(),m_mapFrameRot.size());
|
||||
for (auto& f: m_mapFrameDir) {
|
||||
Base::Vector3d boardValue = f.second;
|
||||
strBoardDir += dirToView(boardValue);
|
||||
}
|
||||
|
||||
strCfgDir = m_conTab.getCfgDirStr(cfg);
|
||||
// Base::Console().Message("TRACE - Cube::validateBoard(%s) - Config Dirs: %s Board Dirs: %s\n",
|
||||
// cfg.c_str(),strCfgDir.c_str(),strBoardDir.c_str());
|
||||
if (strCfgDir != strBoardDir) {
|
||||
result = false;
|
||||
return result;
|
||||
}
|
||||
//check that Rots match
|
||||
std::string strCfgRot;
|
||||
std::string strBoardRot;
|
||||
|
||||
for (auto& f: m_mapFrameRot) {
|
||||
Base::Vector3d boardValue = f.second;
|
||||
strBoardRot += dirToView(boardValue);
|
||||
}
|
||||
|
||||
strCfgRot = m_conTab.getCfgRotStr(cfg);
|
||||
if (strCfgRot != strBoardRot) {
|
||||
result = false;
|
||||
}
|
||||
// Base::Console().Message("TRACE - Cube::validateBoard - Config Rots: %s Board Rots: %s\n",strCfgRot.c_str(),strBoardRot.c_str());
|
||||
|
||||
// Base::Console().Message("TRACE - Cube::validateBoard - result: %d\n",result);
|
||||
return result;
|
||||
}
|
||||
|
||||
//dupl!!
|
||||
std::string Cube::getBoardKey()
|
||||
{
|
||||
std::string result;
|
||||
Base::Vector3d frontDir = m_mapFrameDir.at("Front");
|
||||
std::string frontView = dirToView(frontDir);
|
||||
Base::Vector3d rightDir = m_mapFrameDir.at("Right");
|
||||
std::string rightView = dirToView(rightDir);
|
||||
result = frontView + rightView;
|
||||
return result;
|
||||
}
|
||||
|
||||
//get the current configuration on the board
|
||||
std::string Cube::getCurrConfig(void)
|
||||
{
|
||||
Base::Vector3d boardValue = m_mapFrameDir.at("Front"); //what's in the bucket "Front"
|
||||
std::string viewFront = dirToView(boardValue);
|
||||
boardValue = m_mapFrameDir.at("Right");
|
||||
std::string viewRight = dirToView(boardValue);
|
||||
std::string result = viewFront + viewRight;
|
||||
// Base::Console().Message("TRACE - Cube::getCurrCon - Result: %s Front: %s Right: %s\n",result.c_str(),viewFront.c_str(),viewRight.c_str());
|
||||
// for (auto& i : m_mapFrameDir) {
|
||||
// Base::Console().Message("m_mapFrameDir: %s - %s - %s\n",
|
||||
// (i.first).c_str(),DrawUtil::formatVector(i.second).c_str(),dirToView(i.second).c_str());
|
||||
// }
|
||||
return result;
|
||||
}
|
||||
|
||||
//std::string Cube::stdDirToFace(Base::Vector3d dir)
|
||||
//{
|
||||
// std::string result;
|
||||
//// int i = 0;
|
||||
//// auto it = m_stdDirToFaceKeys.begin(); //map find and at don't much like vector3d
|
||||
//// for (; it != m_stdDirToFaceKeys.end(); it++) {
|
||||
//// Base::Vector3d key = (*it);
|
||||
//// if ( key == dir ) {
|
||||
//// result = m_stdDirToFaceData.at(i);
|
||||
//// break;
|
||||
//// }
|
||||
//// i++;
|
||||
//// }
|
||||
// return result;
|
||||
//}
|
||||
|
||||
void Cube::saveSwap(std::string frame)
|
||||
{
|
||||
m_swapDir = m_mapFrameDir.at(frame);
|
||||
m_swapRot = m_mapFrameRot.at(frame);
|
||||
}
|
||||
|
||||
void Cube::restoreSwap(std::string frame)
|
||||
{
|
||||
m_mapFrameDir.at(frame) = m_swapDir;
|
||||
m_mapFrameRot.at(frame) = m_swapRot;
|
||||
}
|
||||
|
||||
void Cube::shiftFrame(std::string from, std::string to)
|
||||
{
|
||||
m_mapFrameDir.at(to) = m_mapFrameDir.at(from);
|
||||
m_mapFrameRot.at(to) = m_mapFrameRot.at(from);
|
||||
}
|
||||
|
||||
|
||||
//dumps the current "board"
|
||||
void Cube::dump(char * title)
|
||||
{
|
||||
//Bottom/Front/Left/Rear/Right/Top
|
||||
// EACFDB
|
||||
Base::Console().Message("Cube: %s\n", title);
|
||||
Base::Console().Message("B: %s/%s \nF: %s/%s \nL: %s/%s\n",
|
||||
DrawUtil::formatVector(getBottom()).c_str(),DrawUtil::formatVector(getBottomRot()).c_str(),
|
||||
DrawUtil::formatVector(getFront()).c_str(),DrawUtil::formatVector(getFrontRot()).c_str(),
|
||||
DrawUtil::formatVector(getLeft()).c_str(),DrawUtil::formatVector(getLeftRot()).c_str());
|
||||
Base::Console().Message("K: %s/%s \nR: %s/%s \nT: %s/%s\n",
|
||||
DrawUtil::formatVector(getRear()).c_str(),DrawUtil::formatVector(getRearRot()).c_str(),
|
||||
DrawUtil::formatVector(getRight()).c_str(),DrawUtil::formatVector(getRightRot()).c_str(),
|
||||
DrawUtil::formatVector(getTop()).c_str(),DrawUtil::formatVector(getTopRot()).c_str());
|
||||
std::string boardDirs = dirToView(getBottom()) + dirToView(getFront()) + dirToView(getLeft()) +
|
||||
dirToView(getRear()) + dirToView(getRight()) + dirToView(getTop());
|
||||
std::string boardRots = dirToView(getBottomRot()) + dirToView(getFrontRot()) + dirToView(getLeftRot()) +
|
||||
dirToView(getRearRot()) + dirToView(getRightRot()) + dirToView(getTopRot());
|
||||
std::string boardConfig = dirToView(getFront()) + dirToView(getRight());
|
||||
Base::Console().Message("Cube: Board State - config: %s Dirs: %s Rots: %s\n",boardConfig.c_str(),boardDirs.c_str(),boardRots.c_str());
|
||||
}
|
||||
|
||||
//dumps the config state
|
||||
void Cube::dumpState(char* title)
|
||||
{
|
||||
std::string cfg = getCurrConfig();
|
||||
std::string strCfgDir = m_conTab.getCfgDirStr(cfg);
|
||||
std::string strCfgRot = m_conTab.getCfgRotStr(cfg);
|
||||
Base::Console().Message("Cube: dumpState - %s - config: %s Dirs: %s Rots: %s\n",title,cfg.c_str(),strCfgDir.c_str(),strCfgRot.c_str());
|
||||
}
|
||||
|
||||
Base::Vector3d Cube::getRight()
|
||||
{
|
||||
std::string myFace = "D";
|
||||
Base::Vector3d result;
|
||||
result = m_mapFrameDir.at("Right");
|
||||
return result;
|
||||
}
|
||||
|
||||
Base::Vector3d Cube::getFront()
|
||||
{
|
||||
std::string myFace = "A";
|
||||
Base::Vector3d result;
|
||||
result = m_mapFrameDir.at("Front");
|
||||
return result;
|
||||
}
|
||||
|
||||
Base::Vector3d Cube::getTop()
|
||||
{
|
||||
std::string myFace = "B";
|
||||
Base::Vector3d result;
|
||||
result = m_mapFrameDir.at("Top");
|
||||
return result;
|
||||
}
|
||||
|
||||
Base::Vector3d Cube::getLeft()
|
||||
{
|
||||
std::string myFace = "C";
|
||||
Base::Vector3d result;
|
||||
result = m_mapFrameDir.at("Left");
|
||||
return result;
|
||||
}
|
||||
|
||||
Base::Vector3d Cube::getRear()
|
||||
{
|
||||
std::string myFace = "F";
|
||||
Base::Vector3d result;
|
||||
result = m_mapFrameDir.at("Rear");
|
||||
return result;
|
||||
}
|
||||
|
||||
Base::Vector3d Cube::getBottom()
|
||||
{
|
||||
std::string myFace = "E";
|
||||
Base::Vector3d result;
|
||||
result = m_mapFrameDir.at("Bottom");
|
||||
return result;
|
||||
}
|
||||
|
||||
Base::Vector3d Cube::getRightRot()
|
||||
{
|
||||
std::string myFace = "D";
|
||||
Base::Vector3d result;
|
||||
result = m_mapFrameRot.at("Right");
|
||||
return result;
|
||||
}
|
||||
|
||||
Base::Vector3d Cube::getFrontRot()
|
||||
{
|
||||
std::string myFace = "A";
|
||||
Base::Vector3d result;
|
||||
result = m_mapFrameRot.at("Front");
|
||||
return result;
|
||||
}
|
||||
|
||||
Base::Vector3d Cube::getTopRot()
|
||||
{
|
||||
std::string myFace = "B";
|
||||
Base::Vector3d result;
|
||||
result = m_mapFrameRot.at("Top");
|
||||
return result;
|
||||
}
|
||||
|
||||
Base::Vector3d Cube::getLeftRot()
|
||||
{
|
||||
std::string myFace = "C";
|
||||
Base::Vector3d result;
|
||||
result = m_mapFrameRot.at("Left");
|
||||
return result;
|
||||
}
|
||||
|
||||
Base::Vector3d Cube::getRearRot()
|
||||
{
|
||||
std::string myFace = "F";
|
||||
Base::Vector3d result;
|
||||
result = m_mapFrameRot.at("Rear");
|
||||
return result;
|
||||
}
|
||||
|
||||
Base::Vector3d Cube::getBottomRot()
|
||||
{
|
||||
std::string myFace = "E";
|
||||
Base::Vector3d result;
|
||||
result = m_mapFrameRot.at("Bottom");
|
||||
return result;
|
||||
}
|
||||
|
||||
//********************************************************
|
||||
configLine::configLine(int ln, std::string ky, Base::Vector3d b, Base::Vector3d f,
|
||||
Base::Vector3d l, Base::Vector3d k,
|
||||
Base::Vector3d r, Base::Vector3d t)
|
||||
{
|
||||
lineNumber = ln;
|
||||
key = ky;
|
||||
itemMap.insert(std::map<std::string, Base::Vector3d>::value_type("Bottom", b));
|
||||
itemMap.insert(std::map<std::string, Base::Vector3d>::value_type("Front", f));
|
||||
itemMap.insert(std::map<std::string, Base::Vector3d>::value_type("Left", l));
|
||||
itemMap.insert(std::map<std::string, Base::Vector3d>::value_type("Rear", k));
|
||||
itemMap.insert(std::map<std::string, Base::Vector3d>::value_type("Right", r));
|
||||
itemMap.insert(std::map<std::string, Base::Vector3d>::value_type("Top", t));
|
||||
}
|
||||
|
||||
Base::Vector3d configLine::getItem(std::string frame)
|
||||
{
|
||||
return itemMap.at(frame);
|
||||
}
|
||||
|
||||
std::string configLine::getString()
|
||||
{
|
||||
//this outputs Bottom/Left/Front/Rear/Right/Top
|
||||
// Base::Console().Message("TRACE - conLine::getString() - key: %s\n", key.c_str());
|
||||
std::string result;
|
||||
for (auto& i: itemMap) {
|
||||
Base::Vector3d itemVec = i.second;
|
||||
result += Cube::dirToView(itemVec);
|
||||
// Base::Console().Message("TRACE - %s - %s/%s\n",
|
||||
// i.first.c_str(),DrawUtil::formatVector(i.second).c_str(), Cube::dirToView(itemVec).c_str());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void configLine::dump(char* title)
|
||||
{
|
||||
Base::Console().Message("DUMP: configLine %s key: %s\n",title,key.c_str());
|
||||
for (auto& i: itemMap) {
|
||||
Base::Console().Message(">>> %s - %s - %s\n",
|
||||
i.first.c_str(),DrawUtil::formatVector(i.second).c_str(),Cube::dirToView(i.second).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
//********************************************************
|
||||
|
||||
std::string configTable::getCfgDirStr(std::string cfg)
|
||||
{
|
||||
std::string result;
|
||||
// Base::Console().Message("TRACE - conTab::getCFGDirStr(%s)\n",cfg.c_str());
|
||||
configLine dirLine = getDirLine(cfg);
|
||||
result = dirLine.getString();
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string configTable::getCfgRotStr(std::string cfg)
|
||||
{
|
||||
std::string result;
|
||||
configLine dirLine = getRotLine(cfg);
|
||||
result = dirLine.getString();
|
||||
return result;
|
||||
}
|
||||
|
||||
configLine configTable::getDirLine(std::string key)
|
||||
{
|
||||
return getLine(key, dirs);
|
||||
}
|
||||
|
||||
configLine configTable::getRotLine(std::string k)
|
||||
{
|
||||
return getLine(k,rots);
|
||||
}
|
||||
|
||||
configLine configTable::getLine(std::string k, std::vector<configLine> list)
|
||||
{
|
||||
configLine result;
|
||||
// Base::Console().Message("TRACE - conTab::getLine(%s)\n",k.c_str());
|
||||
for (auto& l: list) {
|
||||
if (k == l.getKey()) {
|
||||
result = l;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Base::Console().Message("result: %s\n",result.getString().c_str());
|
||||
return result;
|
||||
}
|
||||
|
||||
Base::Vector3d configTable::getDirItem(std::string k, std::string v)
|
||||
{
|
||||
return getItem(k, v, dirs);
|
||||
}
|
||||
|
||||
Base::Vector3d configTable::getRotItem(std::string k, std::string v)
|
||||
{
|
||||
return getItem(k, v, rots);
|
||||
}
|
||||
|
||||
Base::Vector3d configTable::getItem(std::string k, std::string v, std::vector<configLine> list)
|
||||
{
|
||||
Base::Vector3d result;
|
||||
configLine line = getLine(k, list);
|
||||
result = line.itemMap.at(v);
|
||||
return result;
|
||||
}
|
||||
|
||||
void configTable::addDirItem(configLine cl)
|
||||
{
|
||||
dirs.push_back(cl);
|
||||
}
|
||||
|
||||
void configTable::addRotItem(configLine cl)
|
||||
{
|
||||
rots.push_back(cl);
|
||||
}
|
||||
|
||||
void configTable::initialize(void)
|
||||
{
|
||||
Base::Console().Message("TRACE - cT::initialize()\n");
|
||||
configLine cl;
|
||||
//Rotations
|
||||
#include "rots.cpp"
|
||||
//Directions items
|
||||
#include "dirs.cpp"
|
||||
|
||||
Base::Console().Message("TRACE - cT::initialize dirs: %d rots %d\n",dirs.size(),rots.size());
|
||||
}
|
||||
|
||||
void configTable::dump(char* title)
|
||||
{
|
||||
Base::Console().Message("DUMP: configTable - %s\n",title);
|
||||
for (auto& cl: dirs) {
|
||||
cl.dump("dirs - ");
|
||||
}
|
||||
for (auto& cl: rots) {
|
||||
cl.dump("rots - ");
|
||||
}
|
||||
}
|
||||
|
||||
|
156
src/Mod/TechDraw/App/Cube.h
Normal file
156
src/Mod/TechDraw/App/Cube.h
Normal file
|
@ -0,0 +1,156 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2016 WandererFan <wandererfan@gmail.com> *
|
||||
* *
|
||||
* 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 _CUBE_H_
|
||||
#define _CUBE_H_
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <Base/Vector3D.h>
|
||||
|
||||
namespace TechDraw {
|
||||
|
||||
class configLine
|
||||
{
|
||||
public:
|
||||
configLine() {}
|
||||
~configLine() {}
|
||||
|
||||
configLine(int ln, std::string ky, Base::Vector3d b, Base::Vector3d f,
|
||||
Base::Vector3d l, Base::Vector3d k,
|
||||
Base::Vector3d r, Base::Vector3d t);
|
||||
Base::Vector3d getItem(std::string s);
|
||||
std::string getKey(void) { return key; }
|
||||
std::string getString();
|
||||
void dump(char* title);
|
||||
|
||||
std::map<std::string, Base::Vector3d> itemMap;
|
||||
// Base::Vector3d getItem(std::string s);
|
||||
private:
|
||||
int lineNumber;
|
||||
std::string key;
|
||||
// std::map<std::string, Base::Vector3d> itemMap;
|
||||
};
|
||||
|
||||
class configTable
|
||||
{
|
||||
public:
|
||||
configTable(void) {}
|
||||
~configTable(void) {}
|
||||
void initialize();
|
||||
std::string getCfgDirStr(std::string cfg);
|
||||
std::string getCfgRotStr(std::string cfg);
|
||||
|
||||
configLine getDirLine(std::string k);
|
||||
configLine getRotLine(std::string k);
|
||||
Base::Vector3d getDirItem(std::string k, std::string v);
|
||||
Base::Vector3d getRotItem(std::string k, std::string v);
|
||||
void addDirItem(configLine);
|
||||
void addRotItem(configLine);
|
||||
//bool checkConfig(std::vector<std::string> c);
|
||||
void dump(char* title);
|
||||
|
||||
private:
|
||||
configLine getLine(std::string k, std::vector<configLine> list);
|
||||
Base::Vector3d getItem(std::string k, std::string v, std::vector<configLine> list);
|
||||
std::vector<configLine> dirs;
|
||||
std::vector<configLine> rots;
|
||||
};
|
||||
|
||||
|
||||
class Cube
|
||||
{
|
||||
public:
|
||||
Cube();
|
||||
~Cube();
|
||||
|
||||
void initialize(Base::Vector3d r, Base::Vector3d rr, Base::Vector3d l, Base::Vector3d lr,
|
||||
Base::Vector3d f, Base::Vector3d fr, Base::Vector3d k, Base::Vector3d kr, //k for bacK (rear)
|
||||
Base::Vector3d t, Base::Vector3d tr, Base::Vector3d b, Base::Vector3d br);
|
||||
|
||||
|
||||
|
||||
void rotateUp();
|
||||
void rotateDown();
|
||||
void rotateRight();
|
||||
void rotateLeft ();
|
||||
void spinCCW();
|
||||
void spinCW();
|
||||
|
||||
Base::Vector3d getRight();
|
||||
Base::Vector3d getFront();
|
||||
Base::Vector3d getTop();
|
||||
Base::Vector3d getLeft();
|
||||
Base::Vector3d getRear();
|
||||
Base::Vector3d getBottom();
|
||||
Base::Vector3d getRightRot();
|
||||
Base::Vector3d getFrontRot();
|
||||
Base::Vector3d getTopRot();
|
||||
Base::Vector3d getLeftRot();
|
||||
Base::Vector3d getRearRot();
|
||||
Base::Vector3d getBottomRot();
|
||||
|
||||
static std::string dirToView(Base::Vector3d v);
|
||||
std::string getBoardKey(void);
|
||||
void updateDirsToConfig(std::string cfg);
|
||||
void updateRotsToConfig(std::string cfg);
|
||||
bool validateBoard(std::string cfg);
|
||||
std::string getCurrConfig(void);
|
||||
|
||||
void dump(char * title);
|
||||
void dumpState(char * title);
|
||||
|
||||
private:
|
||||
// Base::Vector3d currRight;
|
||||
// Base::Vector3d currRightRot;
|
||||
// Base::Vector3d currFront;
|
||||
// Base::Vector3d currFrontRot;
|
||||
// Base::Vector3d currTop;
|
||||
// Base::Vector3d currTopRot;
|
||||
// Base::Vector3d currLeft;
|
||||
// Base::Vector3d currLeftRot;
|
||||
// Base::Vector3d currRear;
|
||||
// Base::Vector3d currRearRot;
|
||||
// Base::Vector3d currBottom;
|
||||
// Base::Vector3d currBottomRot;
|
||||
|
||||
|
||||
//the current state of the "board"
|
||||
//the "board" is always full - entries for every position
|
||||
std::map<std::string, Base::Vector3d> m_mapFrameDir;
|
||||
std::map<std::string, Base::Vector3d> m_mapFrameRot;
|
||||
|
||||
static const std::map<std::string,Base::Vector3d> m_viewToStdDir; //would really like this map the other way round.
|
||||
|
||||
void shiftFrame(std::string from, std::string to);
|
||||
void saveSwap(std::string frame);
|
||||
void restoreSwap(std::string frame);
|
||||
Base::Vector3d m_swapDir;
|
||||
Base::Vector3d m_swapRot;
|
||||
configTable m_conTab;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -36,7 +36,9 @@
|
|||
#include <Base/Console.h>
|
||||
#include <Base/Exception.h>
|
||||
|
||||
#include <Base/Matrix.h>
|
||||
|
||||
#include "Cube.h"
|
||||
#include "DrawUtil.h"
|
||||
#include "DrawPage.h"
|
||||
#include "DrawProjGroupItem.h"
|
||||
|
@ -51,6 +53,32 @@ const char* DrawProjGroup::ProjectionTypeEnums[] = {"Default",
|
|||
"Third Angle",
|
||||
NULL};
|
||||
|
||||
const std::map<std::string,Base::Vector3d> DrawProjGroup::m_frameToStdDir = {
|
||||
{ "Front", Base::Vector3d(0, -1, 0) }, //front
|
||||
{ "Rear", Base::Vector3d(0, 1, 0) }, //rear
|
||||
{ "Right", Base::Vector3d(1, 0, 0) }, //right
|
||||
{ "Left", Base::Vector3d(-1, 0, 0) }, //left
|
||||
{ "Top", Base::Vector3d(0, 0, 1) }, //top
|
||||
{ "Bottom", Base::Vector3d(0, 0, -1) }, //bottom
|
||||
{ "FrontTopLeft", Base::Vector3d(-1,-1,1) }, //FTL
|
||||
{ "FrontTopRight", Base::Vector3d(1, -1, 1) }, //FTR
|
||||
{ "FrontBottomRight", Base::Vector3d(1, -1, -1) }, //FBR
|
||||
{ "FrontBottomLeft", Base::Vector3d(-1, -1, -1) } }; //FBL
|
||||
|
||||
const std::map<std::string,Base::Vector3d> DrawProjGroup::m_frameToStdRot = {
|
||||
{ "Front", Base::Vector3d(1, 0, 0) }, //front
|
||||
{ "Rear", Base::Vector3d(-1, 0, 0) }, //rear
|
||||
{ "Right", Base::Vector3d(0, -1, 0) }, //right this makes the first rendering correct, but
|
||||
{ "Left", Base::Vector3d(0, 1, 0) }, //left every 2nd subsequent rendering upside down (ie cube is incorrect)
|
||||
// { "Right", Base::Vector3d(0, 1, 0) }, //right this makes the first rendering upside down
|
||||
// { "Left", Base::Vector3d(0, -1, 0) }, //left but subsequent renderings right side up (ie cube is correct)
|
||||
{ "Top", Base::Vector3d(1, 0, 0) }, //top
|
||||
{ "Bottom", Base::Vector3d(1, 0, 0) }, //bottom
|
||||
{ "FrontTopLeft", Base::Vector3d(-2, -1, 0.5) }, //FTL ???
|
||||
{ "FrontTopRight", Base::Vector3d(2, -1, 0.5) }, //FTR OK
|
||||
{ "FrontBottomRight", Base::Vector3d(2, -1, -0.5) }, //FBR probable
|
||||
{ "FrontBottomLeft", Base::Vector3d(-2, -1, -0.5) } }; //FBL ???
|
||||
|
||||
PROPERTY_SOURCE(TechDraw::DrawProjGroup, TechDraw::DrawViewCollection)
|
||||
|
||||
DrawProjGroup::DrawProjGroup(void)
|
||||
|
@ -67,10 +95,16 @@ DrawProjGroup::DrawProjGroup(void)
|
|||
ADD_PROPERTY_TYPE(spacingX, (15), agroup, App::Prop_None, "Horizontal spacing between views");
|
||||
ADD_PROPERTY_TYPE(spacingY, (15), agroup, App::Prop_None, "Vertical spacing between views");
|
||||
|
||||
m_cube = new Cube();
|
||||
m_cube->initialize(m_frameToStdDir.at("Right"), m_frameToStdRot.at("Right"),
|
||||
m_frameToStdDir.at("Left"), m_frameToStdRot.at("Left"),
|
||||
m_frameToStdDir.at("Front"), m_frameToStdRot.at("Front"), m_frameToStdDir.at("Rear"), m_frameToStdRot.at("Rear"),
|
||||
m_frameToStdDir.at("Top"), m_frameToStdRot.at("Top"), m_frameToStdDir.at("Bottom"), m_frameToStdRot.at("Bottom"));
|
||||
}
|
||||
|
||||
DrawProjGroup::~DrawProjGroup()
|
||||
{
|
||||
delete m_cube;
|
||||
}
|
||||
|
||||
void DrawProjGroup::onChanged(const App::Property* prop)
|
||||
|
@ -345,6 +379,7 @@ bool DrawProjGroup::hasProjection(const char *viewProjType) const
|
|||
|
||||
App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
|
||||
{
|
||||
//Base::Console().Message("TRACE - DPG::addProjection(%s)\n",viewProjType);
|
||||
//if this is the first Projection added, it should automatically be the Anchor/front view
|
||||
// or if viewProjType == "Front" Anchor.setValue(view)
|
||||
DrawProjGroupItem *view( nullptr );
|
||||
|
@ -363,16 +398,17 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
|
|||
view->Scale.setValue( Scale.getValue() );
|
||||
view->Type.setValue( viewProjType );
|
||||
view->Label.setValue( viewProjType );
|
||||
view->Source.setValue( Source.getValue() );
|
||||
if( strcmp(viewProjType,"Front") == 0 ) {
|
||||
|
||||
Anchor.setValue(docObj);
|
||||
view->Direction.setValue(nameToStdDirection("Front")); //just (Base::Vector3d(0.0,-1.0,0.0))
|
||||
view->recomputeFeature();
|
||||
makeInitialMap(view);
|
||||
//dumpMap();
|
||||
view->Direction.setValue(m_frameToStdDir.at("Front")); //just (Base::Vector3d(0.0,-1.0,0.0))
|
||||
view->OrientBasis.setValue(m_frameToStdRot.at("Front"));
|
||||
//view->recomputeFeature();
|
||||
} else {
|
||||
//dumpMap();
|
||||
view->Direction.setValue(m_viewDir[viewProjType]);
|
||||
//really need to check with Cube to get current dir & rot
|
||||
view->Direction.setValue(m_frameToStdDir.at(viewProjType));
|
||||
view->OrientBasis.setValue(m_frameToStdRot.at(viewProjType));
|
||||
}
|
||||
|
||||
addView(view); //from DrawViewCollection - add to ProjGroup Views
|
||||
|
@ -380,6 +416,7 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
|
|||
view->recomputeFeature();
|
||||
}
|
||||
|
||||
Base::Console().Message("TRACE - DPG::addProjection exits\n");
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -506,6 +543,7 @@ void DrawProjGroup::makeViewBbs(DrawProjGroupItem *viewPtrs[10],
|
|||
|
||||
bool DrawProjGroup::distributeProjections()
|
||||
{
|
||||
//TODO: bounding boxes do not take view orientation into account
|
||||
if (!AutoDistribute.getValue()) {
|
||||
return true;
|
||||
}
|
||||
|
@ -680,6 +718,19 @@ bool DrawProjGroup::hasAnchor(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
TechDraw::DrawProjGroupItem* DrawProjGroup::getAnchor(void)
|
||||
{
|
||||
// Base::Console().Message("TRACE - DPG::getAnchor() - %s\n",getNameInDocument());
|
||||
DrawProjGroupItem* result = nullptr;
|
||||
App::DocumentObject* docObj = Anchor.getValue();
|
||||
if (docObj == nullptr) {
|
||||
//explode! DPG w/o anchor
|
||||
Base::Console().Message("TRACE - DPG::getAnchor - DPG has no Anchor!!!\n");
|
||||
} else {
|
||||
result = static_cast<DrawProjGroupItem*>(docObj);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void DrawProjGroup::setAnchorDirection(const Base::Vector3d dir)
|
||||
|
@ -702,199 +753,137 @@ Base::Vector3d DrawProjGroup::getAnchorDirection(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
//static
|
||||
Base::Vector3d DrawProjGroup::nameToStdDirection(std::string name)
|
||||
{
|
||||
Base::Vector3d result;
|
||||
//name to standard view direction
|
||||
std::map<std::string,Base::Vector3d> stdViews = {
|
||||
{ "Front", Base::Vector3d(0, -1, 0) },
|
||||
{ "Rear", Base::Vector3d(0, 1, 0) },
|
||||
{ "Right", Base::Vector3d(1, 0, 0) },
|
||||
{ "Left", Base::Vector3d(-1, 0, 0) },
|
||||
{ "Top", Base::Vector3d(0, 0, 1) },
|
||||
{ "Bottom", Base::Vector3d(0, 0, -1) },
|
||||
{ "FrontTopLeft", Base::Vector3d(-1,-1,1) },
|
||||
{ "FrontTopRight", Base::Vector3d(1, -1, 1) },
|
||||
{ "FrontBottomRight", Base::Vector3d(1, -1, -1) },
|
||||
{ "FrontBottomLeft", Base::Vector3d(-1, -1, -1) } };
|
||||
auto it = stdViews.find(name);
|
||||
if (it != stdViews.end()) {
|
||||
result = (*it).second;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//*************************************
|
||||
//* view direction manipulation routines
|
||||
//*************************************
|
||||
|
||||
//make map from anchor u,v,w
|
||||
//std::map<std::string,Base::Vector3d> DrawProjGroup::makeInitialMap(TechDraw::DrawProjGroupItem* anchor)
|
||||
void DrawProjGroup::makeInitialMap(TechDraw::DrawProjGroupItem* anchor)
|
||||
{
|
||||
m_viewDir = makeUnspunMap(anchor->Direction.getValue(),
|
||||
anchor->getUDir(),
|
||||
anchor->getVDir() * -1); //the infamous flipped Y
|
||||
}
|
||||
|
||||
//! remake map from FRT
|
||||
std::map<std::string,Base::Vector3d> DrawProjGroup::makeUnspunMap()
|
||||
{
|
||||
return makeUnspunMap(m_viewDir["Front"],
|
||||
m_viewDir["Right"],
|
||||
m_viewDir["Top"]);
|
||||
}
|
||||
|
||||
//remake this everytime Anchor.Direction changes
|
||||
std::map<std::string,Base::Vector3d> DrawProjGroup::makeUnspunMap(Base::Vector3d f, Base::Vector3d r, Base::Vector3d t)
|
||||
{
|
||||
std::map<std::string,Base::Vector3d> viewDir;
|
||||
viewDir["Front"] = f;
|
||||
viewDir["Right"] = r;
|
||||
viewDir["Top"] = t;
|
||||
viewDir["Rear"] = viewDir["Front"] * -1.0;
|
||||
viewDir["Left"] = viewDir["Right"] * -1.0;
|
||||
viewDir["Bottom"] = viewDir["Top"] * -1.0;
|
||||
viewDir["FrontTopRight"] = viewDir["Right"] + viewDir["Front"] + viewDir["Top"];
|
||||
viewDir["FrontTopLeft"] = viewDir["Left"] + viewDir["Front"] + viewDir["Top"];
|
||||
viewDir["FrontBottomRight"] = viewDir["Right"] + viewDir["Front"] + viewDir["Bottom"];
|
||||
viewDir["FrontBottomLeft"] = viewDir["Left"] + viewDir["Front"] + viewDir["Bottom"];
|
||||
return viewDir;
|
||||
}
|
||||
|
||||
void DrawProjGroup::dumpMap()
|
||||
{
|
||||
Base::Console().Message("TRACE - DPG::dumpMap - entries: %d\n",m_viewDir.size());
|
||||
std::map<std::string, Base::Vector3d>::const_iterator it;
|
||||
for (it = m_viewDir.begin(); it != m_viewDir.end(); it++)
|
||||
{
|
||||
Base::Console().Message("%s - %s\n",(it->first).c_str(), DrawUtil::formatVector(it->second).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void DrawProjGroup::updateSecondaryDirs()
|
||||
{
|
||||
// Base::Console().Message("TRACE - DPG::updateSecondaryDirs() - %s\n",getNameInDocument());
|
||||
for (auto& docObj: Views.getValues()) {
|
||||
Base::Vector3d newDir;
|
||||
Base::Vector3d newAxis;
|
||||
std::string pic;
|
||||
DrawProjGroupItem* v = static_cast<DrawProjGroupItem*>(docObj);
|
||||
ProjItemType t = static_cast<ProjItemType>(v->Type.getValue());
|
||||
switch (t) {
|
||||
case Front : {
|
||||
newDir = m_viewDir["Front"];
|
||||
newDir = m_cube->getFront();
|
||||
newAxis = m_cube->getFrontRot();
|
||||
break;
|
||||
}
|
||||
case Rear : {
|
||||
newDir = m_viewDir["Rear"];
|
||||
newDir = m_cube->getRear();
|
||||
newAxis = m_cube->getRearRot();
|
||||
break;
|
||||
}
|
||||
case Left : {
|
||||
newDir = m_viewDir["Left"];
|
||||
newDir = m_cube->getLeft();
|
||||
newAxis = m_cube->getLeftRot();
|
||||
break;
|
||||
}
|
||||
case Right : {
|
||||
newDir = m_viewDir["Right"];
|
||||
newDir = m_cube->getRight();
|
||||
newAxis = m_cube->getRightRot();
|
||||
break;
|
||||
}
|
||||
case Top : {
|
||||
newDir = m_viewDir["Top"];
|
||||
newDir = m_cube->getTop();
|
||||
newAxis = m_cube->getTopRot();
|
||||
break;
|
||||
}
|
||||
case Bottom : {
|
||||
newDir = m_viewDir["Bottom"];
|
||||
newDir = m_cube->getBottom();
|
||||
newAxis = m_cube->getBottomRot();
|
||||
break;
|
||||
}
|
||||
case FrontTopLeft : {
|
||||
newDir = m_viewDir["FrontTopLeft"];
|
||||
newDir = m_frameToStdDir.at("FrontTopLeft");
|
||||
newAxis = m_frameToStdRot.at("FrontTopLeft");
|
||||
break;
|
||||
}
|
||||
case FrontTopRight : {
|
||||
newDir = m_viewDir["FrontTopRight"];
|
||||
newDir = m_frameToStdDir.at("FrontTopRight");
|
||||
newAxis = m_frameToStdRot.at("FrontTopRight");
|
||||
break;
|
||||
}
|
||||
case FrontBottomLeft : {
|
||||
newDir = m_viewDir["FrontBottomLeft"];
|
||||
newDir = m_frameToStdDir.at("FrontBottomLeft");
|
||||
newAxis = m_frameToStdRot.at("FrontBottomLeft");
|
||||
break;
|
||||
}
|
||||
case FrontBottomRight : {
|
||||
newDir = m_viewDir["FrontBottomRight"];
|
||||
newDir = m_frameToStdDir.at("FrontBottomRight");
|
||||
newAxis = m_frameToStdRot.at("FrontBottomRight");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
//TARFU invalid secondary type
|
||||
Base::Console().Message("ERROR - DPG::updateSecondaryDirs - invalid projection type\n");
|
||||
newDir = v->Direction.getValue();
|
||||
newAxis = v->OrientBasis.getValue();
|
||||
}
|
||||
}
|
||||
v->Direction.setValue(newDir);
|
||||
v->OrientBasis.setValue(newAxis);
|
||||
v->recomputeFeature();
|
||||
}
|
||||
// Base::Console().Message("TRACE - DPG::updateSecondaryDirs exits\n");
|
||||
}
|
||||
|
||||
|
||||
void DrawProjGroup::rotateRight()
|
||||
{
|
||||
//Front -> Right -> Rear -> Left -> Front
|
||||
Base::Vector3d f,r,t;
|
||||
f = m_viewDir["Left"];
|
||||
r = m_viewDir["Front"];
|
||||
t = m_viewDir["Top"];
|
||||
m_viewDir = makeUnspunMap(f,r,t);
|
||||
//m_cube->dump("TRACE - DPG::rotR before");
|
||||
m_cube->rotateRight();
|
||||
//m_cube->dump("TRACE - DPG::rotR after");
|
||||
updateSecondaryDirs();
|
||||
}
|
||||
|
||||
void DrawProjGroup::rotateLeft()
|
||||
{
|
||||
//Front -> Left -> Rear -> Right -> Front
|
||||
Base::Vector3d f,r,t;
|
||||
f = m_viewDir["Right"];
|
||||
r = m_viewDir["Rear"];
|
||||
t = m_viewDir["Top"];
|
||||
m_viewDir = makeUnspunMap(f,r,t);
|
||||
//m_cube->dump("TRACE - DPG::rotL before");
|
||||
m_cube->rotateLeft();
|
||||
//m_cube->dump("TRACE - DPG::rotL after");
|
||||
updateSecondaryDirs();
|
||||
}
|
||||
|
||||
void DrawProjGroup::rotateUp()
|
||||
{
|
||||
//Front -> Top -> Rear -> Bottom -> Front
|
||||
Base::Vector3d f,r,t;
|
||||
f = m_viewDir["Bottom"];
|
||||
r = m_viewDir["Right"];
|
||||
t = m_viewDir["Front"];
|
||||
m_viewDir = makeUnspunMap(f,r,t);
|
||||
//m_cube->dump("TRACE - DPG::rotU before");
|
||||
m_cube->rotateUp();
|
||||
//m_cube->dump("TRACE - DPG::rotU after");
|
||||
updateSecondaryDirs();
|
||||
}
|
||||
|
||||
void DrawProjGroup::rotateDown()
|
||||
{
|
||||
//Front -> Bottom -> Rear -> Top -> Front
|
||||
Base::Vector3d f,r,t;
|
||||
f = m_viewDir["Top"];
|
||||
r = m_viewDir["Right"];
|
||||
t = m_viewDir["Rear"];
|
||||
m_viewDir = makeUnspunMap(f,r,t);
|
||||
m_cube->dump("TRACE - DPG::rotD before");
|
||||
m_cube->rotateDown();
|
||||
m_cube->dump("TRACE - DPG::rotD after");
|
||||
updateSecondaryDirs();
|
||||
}
|
||||
|
||||
void DrawProjGroup::spinCW()
|
||||
{
|
||||
//Top -> Right -> Bottom -> Left -> Top
|
||||
Base::Vector3d f,r,t;
|
||||
f = m_viewDir["Front"];
|
||||
t = m_viewDir["Left"];
|
||||
r = m_viewDir["Top"];
|
||||
m_viewDir = makeUnspunMap(f,r,t);
|
||||
//m_cube->dump("TRACE - DPG::spinCW before");
|
||||
m_cube->spinCW();
|
||||
//m_cube->dump("TRACE - DPG::spinCW after");
|
||||
updateSecondaryDirs();
|
||||
}
|
||||
|
||||
void DrawProjGroup::spinCCW()
|
||||
{
|
||||
//Top -> Left -> Bottom -> Right -> Top
|
||||
Base::Vector3d f,r,t;
|
||||
f = m_viewDir["Front"];
|
||||
t = m_viewDir["Right"];
|
||||
r = m_viewDir["Bottom"];
|
||||
m_viewDir = makeUnspunMap(f,r,t);
|
||||
//m_cube->dump("TRACE - DPG::spingCCW before");
|
||||
m_cube->spinCCW();
|
||||
//m_cube->dump("TRACE - DPG::spinCCW after");
|
||||
updateSecondaryDirs();
|
||||
}
|
||||
|
||||
|
@ -903,45 +892,47 @@ void DrawProjGroup::spinCCW()
|
|||
//! rebuild view direction map from existing DPGI's if possible or from Anchor
|
||||
void DrawProjGroup::onDocumentRestored()
|
||||
{
|
||||
Base::Vector3d f,r,t;
|
||||
bool ffound = false;
|
||||
bool rfound = false;
|
||||
bool tfound = false;
|
||||
|
||||
for (auto& docObj: Views.getValues()) {
|
||||
DrawProjGroupItem* v = static_cast<DrawProjGroupItem*>(docObj);
|
||||
ProjItemType type = static_cast<ProjItemType>(v->Type.getValue());
|
||||
switch (type) {
|
||||
case Front : {
|
||||
f = v->Direction.getValue();
|
||||
ffound = true;
|
||||
break;
|
||||
}
|
||||
case Right : {
|
||||
r = v->Direction.getValue();
|
||||
rfound = true;
|
||||
break;
|
||||
}
|
||||
case Top : {
|
||||
t = v->Direction.getValue();
|
||||
tfound = true;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ffound && rfound && tfound) {
|
||||
m_viewDir = makeUnspunMap(f,r,t);
|
||||
} else {
|
||||
App::DocumentObject* docObj = Anchor.getValue();
|
||||
TechDraw::DrawProjGroupItem* view = static_cast<TechDraw::DrawProjGroupItem*>( docObj );
|
||||
makeInitialMap(view);
|
||||
Base::Console().Log("LOG: - DPG::restore - making map from Anchor\n");
|
||||
}
|
||||
//dumpMap();
|
||||
DrawViewCollection::onDocumentRestored();
|
||||
// Base::Vector3d f,r,t;
|
||||
// Base::Vector3d fr,rr,tr;
|
||||
// bool ffound = false;
|
||||
// bool rfound = false;
|
||||
// bool tfound = false;
|
||||
//
|
||||
// for (auto& docObj: Views.getValues()) {
|
||||
// DrawProjGroupItem* v = static_cast<DrawProjGroupItem*>(docObj);
|
||||
// ProjItemType type = static_cast<ProjItemType>(v->Type.getValue());
|
||||
// switch (type) {
|
||||
// case Front : {
|
||||
// f = v->Direction.getValue();
|
||||
// fr = v->OrientBasis.getValue();
|
||||
// ffound = true;
|
||||
// break;
|
||||
// }
|
||||
// case Right : {
|
||||
// r = v->Direction.getValue();
|
||||
// rr = v->OrientBasis.getValue();
|
||||
// rfound = true;
|
||||
// break;
|
||||
// }
|
||||
// case Top : {
|
||||
// t = v->Direction.getValue();
|
||||
// tr = v->OrientBasis.getValue();
|
||||
// tfound = true;
|
||||
// break;
|
||||
// }
|
||||
// default: {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (ffound && rfound && tfound) {
|
||||
// //m_cube->reinit(r,rr,f,fr,t,tr);
|
||||
// Base::Console().Log("LOG: - DPG::restore - found Right,Front,Top\n");
|
||||
// } else {
|
||||
// m_cube->initialize(r,f,t);
|
||||
// Base::Console().Log("LOG: - DPG::restore - didn't find Right,Front,Top\n");
|
||||
// }
|
||||
// DrawViewCollection::onDocumentRestored();
|
||||
}
|
||||
|
||||
PyObject *DrawProjGroup::getPyObject(void)
|
||||
|
|
|
@ -32,12 +32,14 @@
|
|||
#include <Base/Matrix.h>
|
||||
#include <Base/Vector3D.h>
|
||||
|
||||
//#include "Cube.h"
|
||||
#include "DrawViewCollection.h"
|
||||
|
||||
namespace TechDraw
|
||||
{
|
||||
|
||||
class DrawProjGroupItem;
|
||||
class Cube;
|
||||
|
||||
/**
|
||||
* Class super-container for managing a collection of DrawProjGroupItem
|
||||
|
@ -113,11 +115,8 @@ public:
|
|||
bool hasAnchor(void);
|
||||
void setAnchorDirection(Base::Vector3d dir);
|
||||
Base::Vector3d getAnchorDirection(void);
|
||||
TechDraw::DrawProjGroupItem* getAnchor(void);
|
||||
|
||||
void makeInitialMap(TechDraw::DrawProjGroupItem* anchor);
|
||||
std::map<std::string,Base::Vector3d> makeUnspunMap(Base::Vector3d f, Base::Vector3d r, Base::Vector3d t);
|
||||
std::map<std::string,Base::Vector3d> makeUnspunMap(void);
|
||||
void dumpMap();
|
||||
void updateSecondaryDirs();
|
||||
|
||||
void rotateRight(void);
|
||||
|
@ -127,9 +126,6 @@ public:
|
|||
void spinCW(void);
|
||||
void spinCCW(void);
|
||||
|
||||
static Base::Vector3d nameToStdDirection(std::string name);
|
||||
|
||||
|
||||
protected:
|
||||
void onChanged(const App::Property* prop);
|
||||
|
||||
|
@ -166,7 +162,10 @@ protected:
|
|||
TechDraw::DrawPage * getPage(void) const;
|
||||
void updateChildren(double scale);
|
||||
|
||||
std::map<std::string,Base::Vector3d> m_viewDir;
|
||||
//TechDraw::Cube m_cube;
|
||||
TechDraw::Cube* m_cube;
|
||||
static const std::map<std::string,Base::Vector3d> m_frameToStdDir; //for initializing cube and
|
||||
static const std::map<std::string,Base::Vector3d> m_frameToStdRot; //creating DPGI's
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -153,26 +153,14 @@ gp_Ax2 DrawProjGroupItem::getViewAxis(const Base::Vector3d& pt,
|
|||
// Base::Console().Message("TRACE - DPGI::getViewAxis - parallel flip: %d\n",flip);
|
||||
viewAxis = TechDrawGeometry::getViewAxis(pt,axis,flip); //use default orientation
|
||||
} else {
|
||||
// Base::Console().Message("TRACE - DPGI::getViewAxis - skew flip: %d\n",flip);
|
||||
viewAxis = TechDrawGeometry::getViewAxis(pt,axis,x,flip);
|
||||
//Base::Console().Message("TRACE - DPGI::getViewAxis - skew flip: %d\n",flip);
|
||||
// if (Type.isValue("Right") || Type.isValue("Left")) { //no difference with incorrect initial axis
|
||||
// viewAxis = TechDrawGeometry::getViewAxis(pt,axis,x,!flip); //no difference with correct initial axis!!
|
||||
// } else {
|
||||
viewAxis = TechDrawGeometry::getViewAxis(pt,axis,x,flip);
|
||||
// }
|
||||
}
|
||||
|
||||
// if (Type.isValue("Front")) {
|
||||
// viewAxis = TechDrawGeometry::getViewAxis(pt,axis,flip); //show front in upright stance
|
||||
// } else {
|
||||
// const char *viewProjType = Type.getValueAsString();
|
||||
// DrawProjGroup* grp = getGroup();
|
||||
// if (grp == nullptr) {
|
||||
// Base::Console().Message("TRACE - DPGI::getViewAxis - NO GROUP!!!\n");
|
||||
// return TechDrawGeometry::getViewAxis(pt,axis,flip); //too early
|
||||
// } else {
|
||||
// getGroup()->dumpViewDir("viewDir map"); //<<<<
|
||||
// getGroup()->dumpXAxisDir("xAxisDir map");
|
||||
// Base::Vector3d x = getGroup()->getXAxisDir(viewProjType);
|
||||
// Base::Vector3d x = OrientBasis.getValue();
|
||||
// viewAxis = TechDrawGeometry::getViewAxis(pt,axis,x,flip);
|
||||
// }
|
||||
// }
|
||||
//Base::Console().Message("TRACE - DPGI::getViewAxis exits\n");
|
||||
return viewAxis;
|
||||
}
|
||||
|
@ -192,12 +180,12 @@ Base::Vector3d DrawProjGroupItem::rotated(const double angle)
|
|||
DrawUtil::formatVector(line).c_str(),
|
||||
DrawUtil::formatVector(oldBasis).c_str(),
|
||||
DrawUtil::formatVector(newBasis).c_str());
|
||||
if (getGroup() != nullptr) {
|
||||
if (getGroup()->getException(Type.getValueAsString())) {
|
||||
newBasis = newBasis * -1.0;
|
||||
Base::Console().Message("TRACE - DPGI::rotated - EXCEPTION\n");
|
||||
}
|
||||
}
|
||||
// if (getGroup() != nullptr) {
|
||||
// if (getGroup()->getException(Type.getValueAsString())) {
|
||||
// newBasis = newBasis * -1.0;
|
||||
// Base::Console().Message("TRACE - DPGI::rotated - EXCEPTION\n");
|
||||
// }
|
||||
// }
|
||||
return newBasis;
|
||||
}
|
||||
|
||||
|
|
|
@ -65,9 +65,6 @@ public:
|
|||
//@}
|
||||
|
||||
DrawProjGroup* getGroup(void) const;
|
||||
virtual gp_Ax2 getViewAxis(const Base::Vector3d& pt,
|
||||
const Base::Vector3d& direction,
|
||||
const bool flip=true) const override;
|
||||
|
||||
/// returns the type name of the ViewProvider
|
||||
virtual const char* getViewProviderName(void) const {
|
||||
|
@ -75,6 +72,11 @@ public:
|
|||
}
|
||||
//return PyObject as DrawProjGroupItemPy
|
||||
virtual PyObject *getPyObject(void);
|
||||
//************************************
|
||||
Base::Vector3d rotated(const double angle) ;
|
||||
virtual gp_Ax2 getViewAxis(const Base::Vector3d& pt,
|
||||
const Base::Vector3d& direction,
|
||||
const bool flip=true) const override;
|
||||
|
||||
protected:
|
||||
/// Called by the container when a Property was changed
|
||||
|
|
|
@ -186,7 +186,8 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
|
|||
|
||||
//turn anchor(x,y,0) in projection plane(P) into displacement in 3D
|
||||
Base::Vector3d offsetCenter3D = DrawUtil::toR3(viewAxis, anchor); //displacement in R3
|
||||
if (DrawUtil::checkZParallel(dirDetail)) {
|
||||
Base::Vector3d stdZ(0.0,0.0,1.0);
|
||||
if (DrawUtil::checkParallel(dirDetail,stdZ)) {
|
||||
extentNear = extentNear + offsetCenter3D;
|
||||
} else {
|
||||
extentNear = extentNear - offsetCenter3D;
|
||||
|
|
|
@ -156,7 +156,7 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
|||
if (shape.IsNull()) {
|
||||
return new App::DocumentObjectExecReturn("FVP - Linked shape object is empty");
|
||||
}
|
||||
Base::Console().Message("TRACE - DVP::execute() - %s - %s - dir: %s\n",getNameInDocument(), Label.getValue(),DrawUtil::formatVector(Direction.getValue()).c_str());
|
||||
// Base::Console().Message("TRACE - DVP::execute() - %s - %s - dir: %s\n",getNameInDocument(), Label.getValue(),DrawUtil::formatVector(Direction.getValue()).c_str());
|
||||
|
||||
|
||||
(void) DrawView::execute(); //make sure Scale is up to date
|
||||
|
@ -187,8 +187,8 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
|||
}
|
||||
#endif //#if MOD_TECHDRAW_HANDLE_FACES
|
||||
|
||||
Base::Console().Message("TRACE _ DVP::exec - %s/%s u: %s v: %s w: %s\n",getNameInDocument(),Label.getValue(),
|
||||
DrawUtil::formatVector(getUDir()).c_str(), DrawUtil::formatVector(getVDir()).c_str(),DrawUtil::formatVector(getWDir()).c_str());
|
||||
// Base::Console().Message("TRACE _ DVP::exec - %s/%s u: %s v: %s w: %s\n",getNameInDocument(),Label.getValue(),
|
||||
// DrawUtil::formatVector(getUDir()).c_str(), DrawUtil::formatVector(getVDir()).c_str(),DrawUtil::formatVector(getWDir()).c_str());
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
@ -517,10 +517,8 @@ bool DrawViewPart::hasGeometry(void) const
|
|||
//boring here. gets more interesting in descendents.
|
||||
gp_Ax2 DrawViewPart::getViewAxis(const Base::Vector3d& pt,
|
||||
const Base::Vector3d& axis,
|
||||
const bool flip,
|
||||
const Base::Vector3d& xAxis) const
|
||||
const bool flip) const
|
||||
{
|
||||
(void)xAxis;
|
||||
gp_Ax2 viewAxis = TechDrawGeometry::getViewAxis(pt,axis,flip);
|
||||
return viewAxis;
|
||||
}
|
||||
|
|
|
@ -116,8 +116,7 @@ public:
|
|||
Base::Vector3d projectPoint(const Base::Vector3d& pt) const;
|
||||
virtual gp_Ax2 getViewAxis(const Base::Vector3d& pt,
|
||||
const Base::Vector3d& direction,
|
||||
const bool flip=true,
|
||||
const Base::Vector3d& xAxis=Base::Vector3d(0.0,0.0,0.0)) const;
|
||||
const bool flip=true) const;
|
||||
|
||||
virtual short mustExecute() const;
|
||||
|
||||
|
|
|
@ -164,8 +164,8 @@ void GeometryObject::projectShape(const TopoDS_Shape& input,
|
|||
Base::Vector3d vx(x.X(),x.Y(),x.Z());
|
||||
Base::Vector3d vy(y.X(),y.Y(),y.Z());
|
||||
Base::Vector3d vz(z.X(),z.Y(),z.Z());
|
||||
Base::Console().Message("TRACE - GO::projectShape - %s viewAxis x: %s y: %s Z: %s\n",m_parentName.c_str(),
|
||||
DrawUtil::formatVector(vx).c_str(), DrawUtil::formatVector(vy).c_str(), DrawUtil::formatVector(vz).c_str());
|
||||
// Base::Console().Message("TRACE - GO::projectShape - %s viewAxis x: %s y: %s Z: %s\n",m_parentName.c_str(),
|
||||
// DrawUtil::formatVector(vx).c_str(), DrawUtil::formatVector(vy).c_str(), DrawUtil::formatVector(vz).c_str());
|
||||
//*******
|
||||
|
||||
auto start = chrono::high_resolution_clock::now();
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <gp_Pnt.hxx>
|
||||
|
||||
#include <Base/Vector3D.h>
|
||||
#include <Base/BoundBox.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
|
74
src/Mod/TechDraw/App/dirs.cpp
Normal file
74
src/Mod/TechDraw/App/dirs.cpp
Normal file
|
@ -0,0 +1,74 @@
|
|||
|
||||
// Dirs - b/f/l/k/r/t
|
||||
cl = configLine( 1 , "AB", Base::Vector3d(1,0,0), Base::Vector3d(0,-1,0), Base::Vector3d(0,0,-1),
|
||||
Base::Vector3d(0,1,0), Base::Vector3d(0,0,1), Base::Vector3d(-1,0,0) );
|
||||
addDirItem(cl);
|
||||
cl = configLine( 2 , "AC", Base::Vector3d(0,0,1), Base::Vector3d(0,-1,0), Base::Vector3d(1,0,0),
|
||||
Base::Vector3d(0,1,0), Base::Vector3d(-1,0,0), Base::Vector3d(0,0,-1) );
|
||||
addDirItem(cl);
|
||||
cl = configLine( 3 , "AD", Base::Vector3d(0,0,-1), Base::Vector3d(0,-1,0), Base::Vector3d(-1,0,0),
|
||||
Base::Vector3d(0,1,0), Base::Vector3d(1,0,0), Base::Vector3d(0,0,1) );
|
||||
addDirItem(cl);
|
||||
cl = configLine( 4 , "AE", Base::Vector3d(-1,0,0), Base::Vector3d(0,-1,0), Base::Vector3d(0,0,1),
|
||||
Base::Vector3d(0,1,0), Base::Vector3d(0,0,-1), Base::Vector3d(1,0,0) );
|
||||
addDirItem(cl);
|
||||
cl = configLine( 5 , "BA", Base::Vector3d(-1,0,0), Base::Vector3d(0,0,1), Base::Vector3d(0,1,0),
|
||||
Base::Vector3d(0,0,-1), Base::Vector3d(0,-1,0), Base::Vector3d(1,0,0) );
|
||||
addDirItem(cl);
|
||||
cl = configLine( 6 , "BC", Base::Vector3d(0,0,-1), Base::Vector3d(0,0,1), Base::Vector3d(1,0,0),
|
||||
Base::Vector3d(0,0,-1), Base::Vector3d(-1,0,0), Base::Vector3d(0,0,1) );
|
||||
addDirItem(cl);
|
||||
cl = configLine( 7 , "BD", Base::Vector3d(0,-1,0), Base::Vector3d(0,0,1), Base::Vector3d(-1,0,0),
|
||||
Base::Vector3d(0,0,-1), Base::Vector3d(1,0,0), Base::Vector3d(0,1,0) );
|
||||
addDirItem(cl);
|
||||
cl = configLine( 8 , "BF", Base::Vector3d(1,0,0), Base::Vector3d(0,0,1), Base::Vector3d(0,-1,0),
|
||||
Base::Vector3d(0,0,-1), Base::Vector3d(0,1,0), Base::Vector3d(-1,0,0) );
|
||||
addDirItem(cl);
|
||||
cl = configLine( 9 , "CA", Base::Vector3d(0,0,-1), Base::Vector3d(-1,0,0), Base::Vector3d(0,1,0),
|
||||
Base::Vector3d(1,0,0), Base::Vector3d(0,-1,0), Base::Vector3d(0,0,1) );
|
||||
addDirItem(cl);
|
||||
cl = configLine( 10 , "CB", Base::Vector3d(0,-1,0), Base::Vector3d(-1,0,0), Base::Vector3d(0,0,-1),
|
||||
Base::Vector3d(1,0,0), Base::Vector3d(0,0,1), Base::Vector3d(0,1,0) );
|
||||
addDirItem(cl);
|
||||
cl = configLine( 11 , "CE", Base::Vector3d(0,1,0), Base::Vector3d(-1,0,0), Base::Vector3d(0,0,1),
|
||||
Base::Vector3d(1,0,0), Base::Vector3d(0,0,-1), Base::Vector3d(0,-1,0) );
|
||||
addDirItem(cl);
|
||||
cl = configLine( 12 , "CF", Base::Vector3d(0,0,1), Base::Vector3d(-1,0,0), Base::Vector3d(0,-1,0),
|
||||
Base::Vector3d(1,0,0), Base::Vector3d(0,1,0), Base::Vector3d(0,0,-1) );
|
||||
addDirItem(cl);
|
||||
cl = configLine( 13 , "DA", Base::Vector3d(0,0,1), Base::Vector3d(1,0,0), Base::Vector3d(0,1,0),
|
||||
Base::Vector3d(-1,0,0), Base::Vector3d(0,-1,0), Base::Vector3d(0,0,-1) );
|
||||
addDirItem(cl);
|
||||
cl = configLine( 14 , "DB", Base::Vector3d(0,1,0), Base::Vector3d(1,0,0), Base::Vector3d(0,0,-1),
|
||||
Base::Vector3d(-1,0,0), Base::Vector3d(0,0,1), Base::Vector3d(0,-1,0) );
|
||||
addDirItem(cl);
|
||||
cl = configLine( 15 , "DE", Base::Vector3d(0,-1,0), Base::Vector3d(1,0,0), Base::Vector3d(0,0,1),
|
||||
Base::Vector3d(-1,0,0), Base::Vector3d(0,0,-1), Base::Vector3d(0,1,0) );
|
||||
addDirItem(cl);
|
||||
cl = configLine( 16 , "DF", Base::Vector3d(0,0,-1), Base::Vector3d(1,0,0), Base::Vector3d(0,-1,0),
|
||||
Base::Vector3d(-1,0,0), Base::Vector3d(0,1,0), Base::Vector3d(0,0,1) );
|
||||
addDirItem(cl);
|
||||
cl = configLine( 17 , "EA", Base::Vector3d(1,0,0), Base::Vector3d(0,0,-1), Base::Vector3d(0,1,0),
|
||||
Base::Vector3d(0,0,1), Base::Vector3d(0,-1,0), Base::Vector3d(-1,0,0) );
|
||||
addDirItem(cl);
|
||||
cl = configLine( 18 , "EC", Base::Vector3d(0,-1,0), Base::Vector3d(0,0,-1), Base::Vector3d(1,0,0),
|
||||
Base::Vector3d(0,0,1), Base::Vector3d(-1,0,0), Base::Vector3d(0,1,0) );
|
||||
addDirItem(cl);
|
||||
cl = configLine( 19 , "ED", Base::Vector3d(0,1,0), Base::Vector3d(0,0,-1), Base::Vector3d(-1,0,0),
|
||||
Base::Vector3d(0,0,1), Base::Vector3d(1,0,0), Base::Vector3d(0,-1,0) );
|
||||
addDirItem(cl);
|
||||
cl = configLine( 20 , "EF", Base::Vector3d(-1,0,0), Base::Vector3d(0,0,-1), Base::Vector3d(0,-1,0),
|
||||
Base::Vector3d(0,0,1), Base::Vector3d(0,1,0), Base::Vector3d(1,0,0) );
|
||||
addDirItem(cl);
|
||||
cl = configLine( 21 , "FB", Base::Vector3d(-1,0,0), Base::Vector3d(0,1,0), Base::Vector3d(0,0,-1),
|
||||
Base::Vector3d(0,-1,0), Base::Vector3d(0,0,1), Base::Vector3d(1,0,0) );
|
||||
addDirItem(cl);
|
||||
cl = configLine( 22 , "FC", Base::Vector3d(0,0,-1), Base::Vector3d(0,1,0), Base::Vector3d(1,0,0),
|
||||
Base::Vector3d(0,-1,0), Base::Vector3d(-1,0,0), Base::Vector3d(0,0,1) );
|
||||
addDirItem(cl);
|
||||
cl = configLine( 23 , "FD", Base::Vector3d(0,0,1), Base::Vector3d(0,1,0), Base::Vector3d(-1,0,0),
|
||||
Base::Vector3d(0,-1,0), Base::Vector3d(1,0,0), Base::Vector3d(0,0,-1) );
|
||||
addDirItem(cl);
|
||||
cl = configLine( 24 , "FE", Base::Vector3d(1,0,0), Base::Vector3d(0,1,0), Base::Vector3d(0,0,1),
|
||||
Base::Vector3d(0,-1,0), Base::Vector3d(0,0,-1), Base::Vector3d(-1,0,0) );
|
||||
addDirItem(cl);
|
73
src/Mod/TechDraw/App/rots.cpp
Normal file
73
src/Mod/TechDraw/App/rots.cpp
Normal file
|
@ -0,0 +1,73 @@
|
|||
// Rots - b/f/l/k/r/t
|
||||
cl = configLine( 1 , "AB", Base::Vector3d(0,0,1), Base::Vector3d(0,0,1), Base::Vector3d(0,1,0),
|
||||
Base::Vector3d(0,0,-1), Base::Vector3d(0,-1,0), Base::Vector3d(0,0,1) );
|
||||
addRotItem(cl);
|
||||
cl = configLine( 2 , "AC", Base::Vector3d(-1,0,0), Base::Vector3d(-1,0,0), Base::Vector3d(0,1,0),
|
||||
Base::Vector3d(1,0,0), Base::Vector3d(0,-1,0), Base::Vector3d(-1,0,0) );
|
||||
addRotItem(cl);
|
||||
cl = configLine( 3 , "AD", Base::Vector3d(1,0,0), Base::Vector3d(1,0,0), Base::Vector3d(0,1,0),
|
||||
Base::Vector3d(-1,0,0), Base::Vector3d(0,-1,0), Base::Vector3d(1,0,0) );
|
||||
addRotItem(cl);
|
||||
cl = configLine( 4 , "AE", Base::Vector3d(0,0,-1), Base::Vector3d(0,0,-1), Base::Vector3d(0,1,0),
|
||||
Base::Vector3d(0,0,1), Base::Vector3d(0,-1,0), Base::Vector3d(0,0,-1) );
|
||||
addRotItem(cl);
|
||||
cl = configLine( 5 , "BA", Base::Vector3d(0,-1,0), Base::Vector3d(0,1,0), Base::Vector3d(0,0,-1),
|
||||
Base::Vector3d(0,-1,0), Base::Vector3d(0,0,-1), Base::Vector3d(0,1,0) );
|
||||
addRotItem(cl);
|
||||
cl = configLine( 6 , "BC", Base::Vector3d(-1,0,0), Base::Vector3d(-1,0,0), Base::Vector3d(0,0,1),
|
||||
Base::Vector3d(1,0,0), Base::Vector3d(0,0,-1), Base::Vector3d(-1,0,0) );
|
||||
addRotItem(cl);
|
||||
cl = configLine( 7 , "BD", Base::Vector3d(1,0,0), Base::Vector3d(1,0,0), Base::Vector3d(0,0,1),
|
||||
Base::Vector3d(-1,0,0), Base::Vector3d(0,0,-1), Base::Vector3d(1,0,0) );
|
||||
addRotItem(cl);
|
||||
cl = configLine( 8 , "BF", Base::Vector3d(-1,0,0), Base::Vector3d(0,-1,0), Base::Vector3d(0,0,1),
|
||||
Base::Vector3d(0,1,0), Base::Vector3d(0,0,-1), Base::Vector3d(0,1,0) );
|
||||
addRotItem(cl);
|
||||
cl = configLine( 9 , "CA", Base::Vector3d(0,1,0), Base::Vector3d(1,0,0), Base::Vector3d(-1,0,0),
|
||||
Base::Vector3d(1,0,0), Base::Vector3d(0,1,0), Base::Vector3d(0,1,0) );
|
||||
addRotItem(cl);
|
||||
cl = configLine( 10 , "CB", Base::Vector3d(0,0,1), Base::Vector3d(0,0,1), Base::Vector3d(-1,0,0),
|
||||
Base::Vector3d(0,0,-1), Base::Vector3d(1,0,0), Base::Vector3d(0,0,1) );
|
||||
addRotItem(cl);
|
||||
cl = configLine( 11 , "CE", Base::Vector3d(0,0,-1), Base::Vector3d(0,0,-1), Base::Vector3d(-1,0,0),
|
||||
Base::Vector3d(0,0,1), Base::Vector3d(1,0,0), Base::Vector3d(0,0,-1) );
|
||||
addRotItem(cl);
|
||||
cl = configLine( 12 , "CF", Base::Vector3d(0,-1,0), Base::Vector3d(0,-1,0), Base::Vector3d(-1,0,0),
|
||||
Base::Vector3d(0,1,0), Base::Vector3d(1,0,0), Base::Vector3d(0,-1,0) );
|
||||
addRotItem(cl);
|
||||
cl = configLine( 13 , "DA", Base::Vector3d(0,1,0), Base::Vector3d(0,1,0), Base::Vector3d(1,0,0),
|
||||
Base::Vector3d(0,-1,0), Base::Vector3d(-1,0,0), Base::Vector3d(0,1,0) );
|
||||
addRotItem(cl);
|
||||
cl = configLine( 14 , "DB", Base::Vector3d(0,0,1), Base::Vector3d(0,0,1), Base::Vector3d(1,0,0),
|
||||
Base::Vector3d(0,0,-1), Base::Vector3d(-1,0,0), Base::Vector3d(0,0,1) );
|
||||
addRotItem(cl);
|
||||
cl = configLine( 15 , "DE", Base::Vector3d(0,0,-1), Base::Vector3d(0,0,-1), Base::Vector3d(1,0,0),
|
||||
Base::Vector3d(0,0,1), Base::Vector3d(-1,0,0), Base::Vector3d(0,0,-1) );
|
||||
addRotItem(cl);
|
||||
cl = configLine( 16 , "DF", Base::Vector3d(0,-1,0), Base::Vector3d(-1,0,0), Base::Vector3d(1,0,0),
|
||||
Base::Vector3d(1,0,0), Base::Vector3d(0,-1,0), Base::Vector3d(0,-1,0) );
|
||||
addRotItem(cl);
|
||||
cl = configLine( 17 , "EA", Base::Vector3d(0,1,0), Base::Vector3d(0,1,0), Base::Vector3d(0,0,-1),
|
||||
Base::Vector3d(0,-1,0), Base::Vector3d(0,0,1), Base::Vector3d(0,1,0) );
|
||||
addRotItem(cl);
|
||||
cl = configLine( 18 , "EC", Base::Vector3d(-1,0,0), Base::Vector3d(-1,0,0), Base::Vector3d(0,0,-1),
|
||||
Base::Vector3d(1,0,0), Base::Vector3d(0,0,1), Base::Vector3d(-1,0,0) );
|
||||
addRotItem(cl);
|
||||
cl = configLine( 19 , "ED", Base::Vector3d(1,0,0), Base::Vector3d(-1,0,0), Base::Vector3d(0,0,-1),
|
||||
Base::Vector3d(-1,0,0), Base::Vector3d(0,0,1), Base::Vector3d(1,0,0) );
|
||||
addRotItem(cl);
|
||||
cl = configLine( 20 , "EF", Base::Vector3d(0,-1,0), Base::Vector3d(0,-1,0), Base::Vector3d(0,0,-1),
|
||||
Base::Vector3d(0,1,0), Base::Vector3d(0,0,1), Base::Vector3d(-1,0,0) );
|
||||
addRotItem(cl);
|
||||
cl = configLine( 21 , "FB", Base::Vector3d(0,0,1), Base::Vector3d(0,0,1), Base::Vector3d(0,-1,0),
|
||||
Base::Vector3d(0,0,-1), Base::Vector3d(0,1,0), Base::Vector3d(0,0,1) );
|
||||
addRotItem(cl);
|
||||
cl = configLine( 22 , "FC", Base::Vector3d(-1,0,0), Base::Vector3d(0,1,0), Base::Vector3d(-1,0,0),
|
||||
Base::Vector3d(1,0,0), Base::Vector3d(0,1,0), Base::Vector3d(-1,0,0) );
|
||||
addRotItem(cl);
|
||||
cl = configLine( 23 , "FD", Base::Vector3d(1,0,0), Base::Vector3d(1,0,0), Base::Vector3d(0,-1,0),
|
||||
Base::Vector3d(-1,0,0), Base::Vector3d(0,1,0), Base::Vector3d(1,0,0) );
|
||||
addRotItem(cl);
|
||||
cl = configLine( 24 , "FE", Base::Vector3d(0,0,-1), Base::Vector3d(0,0,-1), Base::Vector3d(0,-1,0),
|
||||
Base::Vector3d(0,0,1), Base::Vector3d(0,1,0), Base::Vector3d(0,0,-1) );
|
||||
addRotItem(cl);
|
|
@ -180,25 +180,26 @@ void TaskProjGroup::on3DClicked(void)
|
|||
TechDraw::DrawProjGroupItem* front = multiView->getProjItem("Front");
|
||||
if (front) {
|
||||
front->Direction.setValue(dir3D);
|
||||
front->recomputeFeature();
|
||||
//front->OrientBasis.setValue(rot3D);
|
||||
//front->recomputeFeature();
|
||||
setUiPrimary();
|
||||
multiView->makeInitialMap(front);
|
||||
multiView->updateSecondaryDirs();
|
||||
//multiView->makeInitialMap(front);
|
||||
//multiView->updateSecondaryDirs();
|
||||
Gui::Command::updateActive();
|
||||
}
|
||||
}
|
||||
|
||||
void TaskProjGroup::onResetClicked(void)
|
||||
{
|
||||
Base::Vector3d dir = multiView->nameToStdDirection("Front");
|
||||
// Base::Vector3d dir = multiView->nameToStdDirection("Front");
|
||||
|
||||
TechDraw::DrawProjGroupItem* front = multiView->getProjItem("Front");
|
||||
if (front) {
|
||||
front->Direction.setValue(dir);
|
||||
front->recomputeFeature();
|
||||
//multiView->reset()
|
||||
// front->recomputeFeature();
|
||||
setUiPrimary();
|
||||
multiView->makeInitialMap(front);
|
||||
multiView->updateSecondaryDirs();
|
||||
//multiView->dumpMap();
|
||||
// multiView->makeInitialMap(front);
|
||||
// multiView->updateSecondaryDirs();
|
||||
Gui::Command::updateActive();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user